@umbraco-ui/uui 2.0.0-alpha.1 → 2.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +45 -8
- package/dist/components/avatar/avatar.element.js +1 -0
- package/dist/components/avatar/avatar.element.js.map +1 -1
- package/dist/components/boolean-input/boolean-input.element.js +7 -1
- package/dist/components/boolean-input/boolean-input.element.js.map +1 -1
- package/dist/components/button/button.element.d.ts +0 -1
- package/dist/components/button/button.element.js +64 -18
- package/dist/components/button/button.element.js.map +1 -1
- package/dist/components/card-block-type/card-block-type.element.js +13 -4
- package/dist/components/card-block-type/card-block-type.element.js.map +1 -1
- package/dist/components/card-content-node/card-content-node.element.js +2 -2
- package/dist/components/card-content-node/card-content-node.element.js.map +1 -1
- package/dist/components/card-media/card-media.element.js +10 -3
- package/dist/components/card-media/card-media.element.js.map +1 -1
- package/dist/components/card-user/card-user.element.js +2 -2
- package/dist/components/card-user/card-user.element.js.map +1 -1
- package/dist/components/checkbox/checkbox.element.js +3 -6
- package/dist/components/checkbox/checkbox.element.js.map +1 -1
- package/dist/components/color-slider/color-slider.element.js +13 -3
- package/dist/components/color-slider/color-slider.element.js.map +1 -1
- package/dist/components/color-swatch/color-swatch.element.js +33 -1
- package/dist/components/color-swatch/color-swatch.element.js.map +1 -1
- package/dist/components/combobox/combobox.element.d.ts +9 -0
- package/dist/components/combobox/combobox.element.js +127 -15
- package/dist/components/combobox/combobox.element.js.map +1 -1
- package/dist/components/combobox-list/combobox-list-option.element.d.ts +1 -0
- package/dist/components/combobox-list/combobox-list-option.element.js +49 -10
- package/dist/components/combobox-list/combobox-list-option.element.js.map +1 -1
- package/dist/components/combobox-list/combobox-list.element.d.ts +14 -0
- package/dist/components/combobox-list/combobox-list.element.js +74 -25
- package/dist/components/combobox-list/combobox-list.element.js.map +1 -1
- package/dist/components/file-dropzone/file-dropzone.element.d.ts +2 -8
- package/dist/components/file-dropzone/file-dropzone.element.js +14 -25
- package/dist/components/file-dropzone/file-dropzone.element.js.map +1 -1
- package/dist/components/icon-registry-essential/UUIIconRegistryEssential.js +1 -1
- package/dist/components/icon-registry-essential/icon-registry-essential.js +33 -0
- package/dist/components/icon-registry-essential/icon-registry-essential.js.map +1 -1
- package/dist/components/index.d.ts +81 -0
- package/dist/components/input/input.element.js +33 -3
- package/dist/components/input/input.element.js.map +1 -1
- package/dist/components/input-file/input-file.element.js +33 -1
- package/dist/components/input-file/input-file.element.js.map +1 -1
- package/dist/components/input-lock/input-lock.element.js +33 -4
- package/dist/components/input-lock/input-lock.element.js.map +1 -1
- package/dist/components/input-password/input-password.element.js +33 -3
- package/dist/components/input-password/input-password.element.js.map +1 -1
- package/dist/components/keyboard-shortcut/key.element.js +7 -1
- package/dist/components/keyboard-shortcut/key.element.js.map +1 -1
- package/dist/components/loader/loader.element.js +19 -2
- package/dist/components/loader/loader.element.js.map +1 -1
- package/dist/components/modal/modal-container.js +6 -2
- package/dist/components/modal/modal-container.js.map +1 -1
- package/dist/components/modal/modal-dialog.element.js +5 -5
- package/dist/components/modal/modal-dialog.element.js.map +1 -1
- package/dist/components/modal/modal-sidebar.element.js +14 -10
- package/dist/components/modal/modal-sidebar.element.js.map +1 -1
- package/dist/components/modal/modal-with-toasts-example.element.d.ts +22 -0
- package/dist/components/modal/modal.element.d.ts +3 -1
- package/dist/components/modal/modal.element.js +31 -12
- package/dist/components/modal/modal.element.js.map +1 -1
- package/dist/components/modal/modal.js +7 -1
- package/dist/components/modal/modal.js.map +1 -1
- package/dist/components/pagination/pagination.element.d.ts +2 -0
- package/dist/components/pagination/pagination.element.js +26 -20
- package/dist/components/pagination/pagination.element.js.map +1 -1
- package/dist/components/progress-bar/progress-bar.element.js +6 -5
- package/dist/components/progress-bar/progress-bar.element.js.map +1 -1
- package/dist/components/responsive-container/responsive-container.element.js +36 -14
- package/dist/components/responsive-container/responsive-container.element.js.map +1 -1
- package/dist/components/scroll-container/scroll-container.element.js +4 -4
- package/dist/components/scroll-container/scroll-container.element.js.map +1 -1
- package/dist/components/symbol-expand/symbol-expand.element.js +1 -1
- package/dist/components/symbol-expand/symbol-expand.element.js.map +1 -1
- package/dist/components/symbol-file-thumbnail/symbol-file-thumbnail.element.js +34 -1
- package/dist/components/symbol-file-thumbnail/symbol-file-thumbnail.element.js.map +1 -1
- package/dist/components/table/table-head.element.js +4 -0
- package/dist/components/table/table-head.element.js.map +1 -1
- package/dist/components/table/table.element.js +5 -1
- package/dist/components/table/table.element.js.map +1 -1
- package/dist/components/tag/tag.element.js +4 -3
- package/dist/components/tag/tag.element.js.map +1 -1
- package/dist/components/toast-notification/toast-notification.element.js +34 -2
- package/dist/components/toast-notification/toast-notification.element.js.map +1 -1
- package/dist/components/toggle/toggle.element.js +38 -3
- package/dist/components/toggle/toggle.element.js.map +1 -1
- package/dist/index.d.ts +1 -81
- package/dist/internal/mixins/LabelMixin.js +14 -1
- package/dist/internal/mixins/LabelMixin.js.map +1 -1
- package/dist/internal/mixins/SelectOnlyMixin.d.ts +1 -1
- package/dist/internal/mixins/SelectOnlyMixin.js.map +1 -1
- package/dist/package.json.js +1 -1
- package/dist/themes/dark.css +1 -1
- package/dist/themes/high-contrast.css +1 -1
- package/dist/themes/light.css +1 -1
- package/package.json +26 -26
- package/vscode.html-custom-data.json +33 -18
|
@@ -44,14 +44,18 @@ const _UUIModalSidebarElement = class _UUIModalSidebarElement extends UUIModalEl
|
|
|
44
44
|
}, this.transitionDuration);
|
|
45
45
|
}
|
|
46
46
|
render() {
|
|
47
|
-
return html`<
|
|
47
|
+
return html`<div
|
|
48
|
+
popover="manual"
|
|
49
|
+
role="dialog"
|
|
50
|
+
aria-modal="true"
|
|
51
|
+
aria-label="Dialog">
|
|
48
52
|
<slot></slot>
|
|
49
|
-
</
|
|
53
|
+
</div>`;
|
|
50
54
|
}
|
|
51
55
|
};
|
|
52
56
|
_UUIModalSidebarElement_instances = new WeakSet();
|
|
53
57
|
getWidth_get = function() {
|
|
54
|
-
return this.
|
|
58
|
+
return this._popoverElement?.getBoundingClientRect().width ?? 0;
|
|
55
59
|
};
|
|
56
60
|
_UUIModalSidebarElement.styles = [
|
|
57
61
|
...UUIModalElement.styles,
|
|
@@ -66,7 +70,7 @@ _UUIModalSidebarElement.styles = [
|
|
|
66
70
|
--uui-modal-sidebar-left-gap: 64px;
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
|
-
|
|
73
|
+
[popover] {
|
|
70
74
|
height: 100%;
|
|
71
75
|
width: 100%;
|
|
72
76
|
box-sizing: border-box;
|
|
@@ -79,22 +83,22 @@ _UUIModalSidebarElement.styles = [
|
|
|
79
83
|
var(--uui-color-surface)
|
|
80
84
|
);
|
|
81
85
|
}
|
|
82
|
-
:host([index='0'])
|
|
86
|
+
:host([index='0']) [popover] {
|
|
83
87
|
box-shadow: var(--uui-shadow-depth-5);
|
|
84
88
|
}
|
|
85
|
-
:host(:not([index='0']))
|
|
89
|
+
:host(:not([index='0'])) [popover] {
|
|
86
90
|
outline: 1px solid rgba(0, 0, 0, 0.1);
|
|
87
91
|
}
|
|
88
|
-
:host([hide])
|
|
92
|
+
:host([hide]) [popover] {
|
|
89
93
|
display: none;
|
|
90
94
|
}
|
|
91
|
-
:host([size='large'])
|
|
95
|
+
:host([size='large']) [popover] {
|
|
92
96
|
max-width: min(1200px, calc(100% - var(--uui-modal-sidebar-left-gap)));
|
|
93
97
|
}
|
|
94
|
-
:host([size='medium'])
|
|
98
|
+
:host([size='medium']) [popover] {
|
|
95
99
|
max-width: min(800px, calc(100% - var(--uui-modal-sidebar-left-gap)));
|
|
96
100
|
}
|
|
97
|
-
:host([size='small'])
|
|
101
|
+
:host([size='small']) [popover] {
|
|
98
102
|
max-width: min(500px, calc(100% - var(--uui-modal-sidebar-left-gap)));
|
|
99
103
|
}
|
|
100
104
|
`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-sidebar.element.js","sources":["../../../src/components/modal/modal-sidebar.element.ts"],"sourcesContent":["import type { PropertyValueMap } from 'lit';\nimport { css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { UUIModalElement } from './modal.element.js';\nexport type UUIModalSidebarSize = 'small' | 'medium' | 'large' | 'full';\n\nexport class UUIModalSidebarElement extends UUIModalElement {\n /**\n * @attr\n */\n @property({ reflect: true })\n size: UUIModalSidebarSize = 'full';\n\n protected firstUpdated(\n _changedProperties: Map<string | number | symbol, unknown>,\n ): void {\n super.firstUpdated(_changedProperties);\n\n this.style.setProperty('--uui-modal-offset', -this.#getWidth + 'px');\n }\n\n protected updated(\n _changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>,\n ): void {\n super.updated(_changedProperties);\n\n // if we've reached over X layers of sidebars, hide for better performance.\n if (this.uniqueIndex > 10) {\n this.setAttribute('hide', '');\n } else {\n this.removeAttribute('hide');\n }\n }\n\n get #getWidth() {\n return this.
|
|
1
|
+
{"version":3,"file":"modal-sidebar.element.js","sources":["../../../src/components/modal/modal-sidebar.element.ts"],"sourcesContent":["import type { PropertyValueMap } from 'lit';\nimport { css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { UUIModalElement } from './modal.element.js';\nexport type UUIModalSidebarSize = 'small' | 'medium' | 'large' | 'full';\n\nexport class UUIModalSidebarElement extends UUIModalElement {\n /**\n * @attr\n */\n @property({ reflect: true })\n size: UUIModalSidebarSize = 'full';\n\n protected firstUpdated(\n _changedProperties: Map<string | number | symbol, unknown>,\n ): void {\n super.firstUpdated(_changedProperties);\n\n this.style.setProperty('--uui-modal-offset', -this.#getWidth + 'px');\n }\n\n protected updated(\n _changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>,\n ): void {\n super.updated(_changedProperties);\n\n // if we've reached over X layers of sidebars, hide for better performance.\n if (this.uniqueIndex > 10) {\n this.setAttribute('hide', '');\n } else {\n this.removeAttribute('hide');\n }\n }\n\n get #getWidth() {\n return this._popoverElement?.getBoundingClientRect().width ?? 0;\n }\n\n forceClose() {\n if (this.isClosing) return;\n\n this.isClosing = true;\n this.style.setProperty('--uui-modal-offset', -this.#getWidth + 'px');\n\n setTimeout(() => {\n super.forceClose();\n }, this.transitionDuration);\n }\n\n render() {\n return html`<div\n popover=\"manual\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Dialog\">\n <slot></slot>\n </div>`;\n }\n\n static override readonly styles = [\n ...UUIModalElement.styles,\n css`\n :host {\n outline: none;\n --uui-modal-sidebar-left-gap: 24px;\n --uui-modal-sidebar-background: var(--uui-color-surface);\n }\n @media (min-width: 600px) {\n :host {\n --uui-modal-sidebar-left-gap: 64px;\n }\n }\n [popover] {\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n max-width: calc(100% - var(--uui-modal-sidebar-left-gap));\n margin-left: auto;\n right: var(--uui-modal-offset);\n transition: right var(--uui-modal-transition-duration, 250ms);\n background: var(\n --uui-modal-sidebar-background,\n var(--uui-color-surface)\n );\n }\n :host([index='0']) [popover] {\n box-shadow: var(--uui-shadow-depth-5);\n }\n :host(:not([index='0'])) [popover] {\n outline: 1px solid rgba(0, 0, 0, 0.1);\n }\n :host([hide]) [popover] {\n display: none;\n }\n :host([size='large']) [popover] {\n max-width: min(1200px, calc(100% - var(--uui-modal-sidebar-left-gap)));\n }\n :host([size='medium']) [popover] {\n max-width: min(800px, calc(100% - var(--uui-modal-sidebar-left-gap)));\n }\n :host([size='small']) [popover] {\n max-width: min(500px, calc(100% - var(--uui-modal-sidebar-left-gap)));\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMO,MAAM,0BAAN,MAAM,gCAA+B,gBAAgB;AAAA,EAArD,cAAA;AAAA,UAAA,GAAA,SAAA;AAAA;AAKL,SAAA,OAA4B;AAAA,EAAA;AAAA,EAElB,aACR,oBACM;AACN,UAAM,aAAa,kBAAkB;AAErC,SAAK,MAAM,YAAY,sBAAsB,CAAC,mBAAK,mDAAY,IAAI;AAAA,EACrE;AAAA,EAEU,QACR,oBACM;AACN,UAAM,QAAQ,kBAAkB;AAGhC,QAAI,KAAK,cAAc,IAAI;AACzB,WAAK,aAAa,QAAQ,EAAE;AAAA,IAC9B,OAAO;AACL,WAAK,gBAAgB,MAAM;AAAA,IAC7B;AAAA,EACF;AAAA,EAMA,aAAa;AACX,QAAI,KAAK,UAAW;AAEpB,SAAK,YAAY;AACjB,SAAK,MAAM,YAAY,sBAAsB,CAAC,mBAAK,mDAAY,IAAI;AAEnE,eAAW,MAAM;AACf,YAAM,WAAA;AAAA,IACR,GAAG,KAAK,kBAAkB;AAAA,EAC5B;AAAA,EAEA,SAAS;AACP,WAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT;AAgDF;AAnGO;AA4BD,eAAA,WAAY;AACd,SAAO,KAAK,iBAAiB,sBAAA,EAAwB,SAAS;AAChE;AAuBA,wBAAyB,SAAS;AAAA,EAChC,GAAG,gBAAgB;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAvDG,IAAM,yBAAN;AAKL,gBAAA;AAAA,EADC,SAAS,EAAE,SAAS,KAAA,CAAM;AAAA,GAJhB,uBAKX,WAAA,MAAA;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TemplateResult } from 'lit';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import './modal-container.js';
|
|
4
|
+
import './modal.js';
|
|
5
|
+
import '../dialog-layout/dialog-layout.js';
|
|
6
|
+
import '../button/button.js';
|
|
7
|
+
import '../box/box.js';
|
|
8
|
+
import '../toast-notification/toast-notification.js';
|
|
9
|
+
import '../toast-notification-container/toast-notification-container.js';
|
|
10
|
+
import '../toast-notification-layout/toast-notification-layout.js';
|
|
11
|
+
export declare class UUIModalWithToastsExampleElement extends LitElement {
|
|
12
|
+
#private;
|
|
13
|
+
private readonly _modals;
|
|
14
|
+
private _toastCounter;
|
|
15
|
+
private _dialogCounter;
|
|
16
|
+
private _messageCounter;
|
|
17
|
+
private readonly _onModalOpen;
|
|
18
|
+
connectedCallback(): void;
|
|
19
|
+
disconnectedCallback(): void;
|
|
20
|
+
render(): TemplateResult<1>;
|
|
21
|
+
static readonly styles: import("lit").CSSResult;
|
|
22
|
+
}
|
|
@@ -3,7 +3,7 @@ export declare const UUIModalOpenEvent = "uui:modal-open";
|
|
|
3
3
|
export declare const UUIModalCloseEvent = "uui:modal-close";
|
|
4
4
|
export declare const UUIModalCloseEndEvent = "uui:modal-close-end";
|
|
5
5
|
export declare class UUIModalElement extends LitElement {
|
|
6
|
-
protected readonly
|
|
6
|
+
protected readonly _popoverElement?: HTMLElement;
|
|
7
7
|
isOpen: boolean;
|
|
8
8
|
isClosing: boolean;
|
|
9
9
|
index: number;
|
|
@@ -16,5 +16,7 @@ export declare class UUIModalElement extends LitElement {
|
|
|
16
16
|
close: (event?: Event) => void;
|
|
17
17
|
protected _openModal(): void;
|
|
18
18
|
forceClose(): void;
|
|
19
|
+
private readonly _onKeydown;
|
|
20
|
+
private readonly _onFocusTrap;
|
|
19
21
|
static readonly styles: import("lit").CSSResult[];
|
|
20
22
|
}
|
|
@@ -45,6 +45,17 @@ const _UUIModalElement = class _UUIModalElement extends LitElement {
|
|
|
45
45
|
if (closeEvent.defaultPrevented) return;
|
|
46
46
|
this.forceClose();
|
|
47
47
|
};
|
|
48
|
+
this._onKeydown = (e) => {
|
|
49
|
+
if (e.key === "Escape" && this.index === 0) {
|
|
50
|
+
this.close();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this._onFocusTrap = (e) => {
|
|
54
|
+
if (this.index !== 0) return;
|
|
55
|
+
if (!this._popoverElement?.contains(e.target)) {
|
|
56
|
+
this._popoverElement?.focus();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
48
59
|
}
|
|
49
60
|
get transitionDuration() {
|
|
50
61
|
return this._transitionDuration;
|
|
@@ -64,13 +75,19 @@ const _UUIModalElement = class _UUIModalElement extends LitElement {
|
|
|
64
75
|
}
|
|
65
76
|
_openModal() {
|
|
66
77
|
this.isOpen = true;
|
|
67
|
-
this.
|
|
68
|
-
this.
|
|
78
|
+
this._popoverElement?.showPopover();
|
|
79
|
+
if (!this._popoverElement?.hasAttribute("tabindex")) {
|
|
80
|
+
this._popoverElement?.setAttribute("tabindex", "-1");
|
|
81
|
+
}
|
|
82
|
+
document.addEventListener("keydown", this._onKeydown);
|
|
83
|
+
document.addEventListener("focus", this._onFocusTrap, true);
|
|
69
84
|
}
|
|
70
85
|
forceClose() {
|
|
71
86
|
this.isClosing = true;
|
|
72
87
|
this.isOpen = false;
|
|
73
|
-
this.
|
|
88
|
+
this._popoverElement?.hidePopover();
|
|
89
|
+
document.removeEventListener("keydown", this._onKeydown);
|
|
90
|
+
document.removeEventListener("focus", this._onFocusTrap, true);
|
|
74
91
|
this.dispatchEvent(new CustomEvent("close-end"));
|
|
75
92
|
this.dispatchEvent(new CustomEvent(UUIModalCloseEndEvent));
|
|
76
93
|
this.remove();
|
|
@@ -78,7 +95,9 @@ const _UUIModalElement = class _UUIModalElement extends LitElement {
|
|
|
78
95
|
};
|
|
79
96
|
_UUIModalElement.styles = [
|
|
80
97
|
css`
|
|
81
|
-
|
|
98
|
+
[popover] {
|
|
99
|
+
position: fixed;
|
|
100
|
+
inset: 0;
|
|
82
101
|
display: block;
|
|
83
102
|
margin: 0;
|
|
84
103
|
padding: 0;
|
|
@@ -88,11 +107,7 @@ _UUIModalElement.styles = [
|
|
|
88
107
|
background: none;
|
|
89
108
|
color: var(--uui-color-text);
|
|
90
109
|
}
|
|
91
|
-
|
|
92
|
-
background: none;
|
|
93
|
-
opacity: 0;
|
|
94
|
-
}
|
|
95
|
-
dialog::after {
|
|
110
|
+
[popover]::after {
|
|
96
111
|
content: '';
|
|
97
112
|
position: absolute;
|
|
98
113
|
inset: 0;
|
|
@@ -102,15 +117,19 @@ _UUIModalElement.styles = [
|
|
|
102
117
|
transition: opacity var(--uui-modal-transition-duration, 250ms);
|
|
103
118
|
z-index: 1;
|
|
104
119
|
}
|
|
105
|
-
:host([index='0'])
|
|
120
|
+
:host([index='0']) [popover]::after {
|
|
106
121
|
opacity: 0;
|
|
122
|
+
pointer-events: none;
|
|
123
|
+
}
|
|
124
|
+
:host(:not([index='0'])) [popover]::after {
|
|
125
|
+
pointer-events: auto;
|
|
107
126
|
}
|
|
108
127
|
`
|
|
109
128
|
];
|
|
110
129
|
let UUIModalElement = _UUIModalElement;
|
|
111
130
|
__decorateClass([
|
|
112
|
-
query("
|
|
113
|
-
], UUIModalElement.prototype, "
|
|
131
|
+
query("[popover]")
|
|
132
|
+
], UUIModalElement.prototype, "_popoverElement", 2);
|
|
114
133
|
__decorateClass([
|
|
115
134
|
property({ type: Boolean, reflect: true, attribute: "is-open" })
|
|
116
135
|
], UUIModalElement.prototype, "isOpen", 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.element.js","sources":["../../../src/components/modal/modal.element.ts"],"sourcesContent":["import { LitElement, css } from 'lit';\nimport { property, query } from 'lit/decorators.js';\n\nexport const UUIModalOpenEvent = 'uui:modal-open';\nexport const UUIModalCloseEvent = 'uui:modal-close';\nexport const UUIModalCloseEndEvent = 'uui:modal-close-end';\n\nexport class UUIModalElement extends LitElement {\n @query('
|
|
1
|
+
{"version":3,"file":"modal.element.js","sources":["../../../src/components/modal/modal.element.ts"],"sourcesContent":["import { LitElement, css } from 'lit';\nimport { property, query } from 'lit/decorators.js';\n\nexport const UUIModalOpenEvent = 'uui:modal-open';\nexport const UUIModalCloseEvent = 'uui:modal-close';\nexport const UUIModalCloseEndEvent = 'uui:modal-close-end';\n\nexport class UUIModalElement extends LitElement {\n @query('[popover]')\n protected readonly _popoverElement?: HTMLElement;\n\n @property({ type: Boolean, reflect: true, attribute: 'is-open' })\n isOpen = false;\n\n @property({ type: Boolean, reflect: true, attribute: 'is-closing' })\n isClosing = false;\n\n @property({ type: Number, reflect: true })\n index = 0;\n\n @property({ type: Number, reflect: true, attribute: 'unique-index' })\n uniqueIndex = 0;\n\n private _transitionDuration = 250;\n\n @property({ type: Number, attribute: 'transition-duration' })\n public get transitionDuration() {\n return this._transitionDuration;\n }\n public set transitionDuration(value: number) {\n this._transitionDuration = value;\n this.style.setProperty(\n '--uui-modal-transition-duration',\n this._transitionDuration + 'ms',\n );\n }\n\n protected firstUpdated(\n _changedProperties: Map<string | number | symbol, unknown>,\n ): void {\n super.firstUpdated(_changedProperties);\n\n if (!this.isClosing) {\n this.open();\n }\n }\n\n public open = (event?: Event) => {\n event?.preventDefault();\n event?.stopImmediatePropagation();\n\n const openEvent = new CustomEvent(UUIModalOpenEvent, {\n cancelable: true,\n });\n const legacyOpenEvent = new CustomEvent('open', {\n cancelable: true,\n });\n\n this.dispatchEvent(openEvent);\n this.dispatchEvent(legacyOpenEvent);\n if (openEvent.defaultPrevented || legacyOpenEvent.defaultPrevented) return;\n\n this._openModal();\n };\n\n public close = (event?: Event) => {\n event?.preventDefault();\n event?.stopImmediatePropagation();\n\n const closeEvent = new CustomEvent(UUIModalCloseEvent, {\n cancelable: true,\n });\n this.dispatchEvent(closeEvent);\n\n if (closeEvent.defaultPrevented) return;\n\n this.forceClose();\n };\n\n protected _openModal() {\n this.isOpen = true;\n this._popoverElement?.showPopover();\n if (!this._popoverElement?.hasAttribute('tabindex')) {\n this._popoverElement?.setAttribute('tabindex', '-1');\n }\n document.addEventListener('keydown', this._onKeydown);\n document.addEventListener('focus', this._onFocusTrap, true);\n }\n\n public forceClose() {\n this.isClosing = true;\n this.isOpen = false;\n this._popoverElement?.hidePopover();\n document.removeEventListener('keydown', this._onKeydown);\n document.removeEventListener('focus', this._onFocusTrap, true);\n\n this.dispatchEvent(new CustomEvent('close-end'));\n this.dispatchEvent(new CustomEvent(UUIModalCloseEndEvent));\n\n this.remove();\n }\n\n private readonly _onKeydown = (e: KeyboardEvent) => {\n if (e.key === 'Escape' && this.index === 0) {\n this.close();\n }\n };\n\n private readonly _onFocusTrap = (e: FocusEvent) => {\n if (this.index !== 0) return;\n if (!this._popoverElement?.contains(e.target as Node)) {\n this._popoverElement?.focus();\n }\n };\n\n static override readonly styles = [\n css`\n [popover] {\n position: fixed;\n inset: 0;\n display: block;\n margin: 0;\n padding: 0;\n max-width: unset;\n max-height: unset;\n border: none;\n background: none;\n color: var(--uui-color-text);\n }\n [popover]::after {\n content: '';\n position: absolute;\n inset: 0;\n background-color: var(--uui-modal-color-backdrop, rgba(0, 0, 0, 0.5));\n pointer-events: none;\n opacity: 1;\n transition: opacity var(--uui-modal-transition-duration, 250ms);\n z-index: 1;\n }\n :host([index='0']) [popover]::after {\n opacity: 0;\n pointer-events: none;\n }\n :host(:not([index='0'])) [popover]::after {\n pointer-events: auto;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAGO,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAE9B,MAAM,mBAAN,MAAM,yBAAwB,WAAW;AAAA,EAAzC,cAAA;AAAA,UAAA,GAAA,SAAA;AAKL,SAAA,SAAS;AAGT,SAAA,YAAY;AAGZ,SAAA,QAAQ;AAGR,SAAA,cAAc;AAEd,SAAQ,sBAAsB;AAwB9B,SAAO,OAAO,CAAC,UAAkB;AAC/B,aAAO,eAAA;AACP,aAAO,yBAAA;AAEP,YAAM,YAAY,IAAI,YAAY,mBAAmB;AAAA,QACnD,YAAY;AAAA,MAAA,CACb;AACD,YAAM,kBAAkB,IAAI,YAAY,QAAQ;AAAA,QAC9C,YAAY;AAAA,MAAA,CACb;AAED,WAAK,cAAc,SAAS;AAC5B,WAAK,cAAc,eAAe;AAClC,UAAI,UAAU,oBAAoB,gBAAgB,iBAAkB;AAEpE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AAU;AACvD,aAAS,oBAAoB,SAAS,KAAK,cAAc,IAAI;AAE7D,SAAK,cAAc,IAAI,YAAY,WAAW,CAAC;AAC/C,SAAK,cAAc,IAAI,YAAY,qBAAqB,CAAC;AAEzD,SAAK,OAAA;AAAA,EACP;AAgDF;AAjCE,iBAAyB,SAAS;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA7GG,IAAM,kBAAN;AAEc,gBAAA;AAAA,EADlB,MAAM,WAAW;AAAA,GADP,gBAEQ,WAAA,mBAAA,CAAA;AAGnB,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,WAAW;AAAA,GAJrD,gBAKX,WAAA,UAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,cAAc;AAAA,GAPxD,gBAQX,WAAA,aAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,SAAS,MAAM;AAAA,GAV9B,gBAWX,WAAA,SAAA,CAAA;AAGA,gBAAA;AAAA,EADC,SAAS,EAAE,MAAM,QAAQ,SAAS,MAAM,WAAW,gBAAgB;AAAA,GAbzD,gBAcX,WAAA,eAAA,CAAA;AAKW,gBAAA;AAAA,EADV,SAAS,EAAE,MAAM,QAAQ,WAAW,uBAAuB;AAAA,GAlBjD,gBAmBA,WAAA,sBAAA,CAAA;"}
|
|
@@ -2,12 +2,18 @@ import { defineElement } from "../../internal/registration/index.js";
|
|
|
2
2
|
import { UUIModalDialogElement } from "./modal-dialog.element.js";
|
|
3
3
|
import { UUIModalSidebarElement } from "./modal-sidebar.element.js";
|
|
4
4
|
import { UUIModalContainerElement } from "./modal-container.js";
|
|
5
|
+
import { UUIModalCloseEndEvent, UUIModalCloseEvent, UUIModalElement, UUIModalOpenEvent, UUIModalElement as UUIModalElement2 } from "./modal.element.js";
|
|
5
6
|
defineElement("uui-modal-dialog", UUIModalDialogElement);
|
|
6
7
|
defineElement("uui-modal-sidebar", UUIModalSidebarElement);
|
|
7
8
|
defineElement("uui-modal-container", UUIModalContainerElement);
|
|
8
9
|
export {
|
|
10
|
+
UUIModalCloseEndEvent,
|
|
11
|
+
UUIModalCloseEvent,
|
|
9
12
|
UUIModalContainerElement,
|
|
10
13
|
UUIModalDialogElement,
|
|
11
|
-
|
|
14
|
+
UUIModalElement,
|
|
15
|
+
UUIModalOpenEvent,
|
|
16
|
+
UUIModalSidebarElement,
|
|
17
|
+
UUIModalElement2 as default
|
|
12
18
|
};
|
|
13
19
|
//# sourceMappingURL=modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../../src/components/modal/modal.ts"],"sourcesContent":["import { defineElement } from '../../internal/registration/index.js';\nimport { UUIModalDialogElement } from './modal-dialog.element.js';\nimport { UUIModalSidebarElement } from './modal-sidebar.element.js';\nimport { UUIModalContainerElement } from './modal-container.js';\n\ndefineElement('uui-modal-dialog', UUIModalDialogElement);\ndefineElement('uui-modal-sidebar', UUIModalSidebarElement);\ndefineElement('uui-modal-container', UUIModalContainerElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uui-modal-dialog': UUIModalDialogElement;\n 'uui-modal-sidebar': UUIModalSidebarElement;\n 'uui-modal-container': UUIModalContainerElement;\n }\n}\n\nexport * from './modal-dialog.element.js';\nexport * from './modal-sidebar.element.js';\nexport * from './modal.element.js';\nexport * from './modal-container.js';\nexport { UUIModalElement as default } from './modal.element.js';\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../src/components/modal/modal.ts"],"sourcesContent":["import { defineElement } from '../../internal/registration/index.js';\nimport { UUIModalDialogElement } from './modal-dialog.element.js';\nimport { UUIModalSidebarElement } from './modal-sidebar.element.js';\nimport { UUIModalContainerElement } from './modal-container.js';\n\ndefineElement('uui-modal-dialog', UUIModalDialogElement);\ndefineElement('uui-modal-sidebar', UUIModalSidebarElement);\ndefineElement('uui-modal-container', UUIModalContainerElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'uui-modal-dialog': UUIModalDialogElement;\n 'uui-modal-sidebar': UUIModalSidebarElement;\n 'uui-modal-container': UUIModalContainerElement;\n }\n}\n\nexport * from './modal-dialog.element.js';\nexport * from './modal-sidebar.element.js';\nexport * from './modal.element.js';\nexport * from './modal-container.js';\nexport { UUIModalElement as default } from './modal.element.js';\n"],"names":[],"mappings":";;;;;AAKA,cAAc,oBAAoB,qBAAqB;AACvD,cAAc,qBAAqB,sBAAsB;AACzD,cAAc,uBAAuB,wBAAwB;"}
|
|
@@ -96,6 +96,8 @@ export declare class UUIPaginationElement extends LitElement {
|
|
|
96
96
|
protected renderLast(): import("lit-html").TemplateResult<1>;
|
|
97
97
|
protected renderDots(): import("lit-html").TemplateResult<1>;
|
|
98
98
|
protected renderPage(page: number): import("lit-html").TemplateResult<1>;
|
|
99
|
+
protected renderLeftDots(): import("lit-html").TemplateResult<1>;
|
|
100
|
+
protected renderRightDots(): import("lit-html").TemplateResult<1>;
|
|
99
101
|
protected renderNavigationLeft(): import("lit-html").TemplateResult<1>;
|
|
100
102
|
protected renderNavigationRight(): import("lit-html").TemplateResult<1>;
|
|
101
103
|
render(): import("lit-html").TemplateResult<1>;
|
|
@@ -68,7 +68,7 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
68
68
|
);
|
|
69
69
|
const rangeBaseWidth = containerWidth - navButtonsWidth;
|
|
70
70
|
const range = rangeBaseWidth / PAGE_BUTTON_MAX_WIDTH / 2;
|
|
71
|
-
this._range = Math.max(
|
|
71
|
+
this._range = Math.max(0, Math.floor(range));
|
|
72
72
|
this._visiblePages = this._generateVisiblePages(this.current);
|
|
73
73
|
}
|
|
74
74
|
_generateVisiblePages(current) {
|
|
@@ -148,9 +148,7 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
148
148
|
renderFirst() {
|
|
149
149
|
return html`<uui-button
|
|
150
150
|
compact
|
|
151
|
-
look="outline"
|
|
152
151
|
class="nav"
|
|
153
|
-
role="listitem"
|
|
154
152
|
label=${this.firstLabel}
|
|
155
153
|
?disabled=${this._current === 1}
|
|
156
154
|
@click=${() => this.goToPage(1)}></uui-button>`;
|
|
@@ -158,9 +156,7 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
158
156
|
renderPrevious() {
|
|
159
157
|
return html`<uui-button
|
|
160
158
|
compact
|
|
161
|
-
look="outline"
|
|
162
159
|
class="nav"
|
|
163
|
-
role="listitem"
|
|
164
160
|
label=${this.previousLabel}
|
|
165
161
|
?disabled=${this._current === 1}
|
|
166
162
|
@click=${this.goToPreviousPage}></uui-button>`;
|
|
@@ -168,8 +164,6 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
168
164
|
renderNext() {
|
|
169
165
|
return html`<uui-button
|
|
170
166
|
compact
|
|
171
|
-
look="outline"
|
|
172
|
-
role="listitem"
|
|
173
167
|
class="nav"
|
|
174
168
|
label=${this.nextLabel}
|
|
175
169
|
?disabled=${this._current === this.total}
|
|
@@ -179,8 +173,6 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
179
173
|
return html`
|
|
180
174
|
<uui-button
|
|
181
175
|
compact
|
|
182
|
-
look="outline"
|
|
183
|
-
role="listitem"
|
|
184
176
|
class="nav"
|
|
185
177
|
label=${this.lastLabel}
|
|
186
178
|
?disabled=${this.total === this._current}
|
|
@@ -196,7 +188,7 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
196
188
|
class="dots"
|
|
197
189
|
label="More pages"
|
|
198
190
|
>...</uui-button
|
|
199
|
-
|
|
191
|
+
>`;
|
|
200
192
|
}
|
|
201
193
|
renderPage(page) {
|
|
202
194
|
return html`<uui-button
|
|
@@ -214,38 +206,50 @@ const _UUIPaginationElement = class _UUIPaginationElement extends LitElement {
|
|
|
214
206
|
${page}
|
|
215
207
|
</uui-button>`;
|
|
216
208
|
}
|
|
209
|
+
renderLeftDots() {
|
|
210
|
+
return html` ${this._visiblePages.includes(1) ? "" : this.renderDots()}`;
|
|
211
|
+
}
|
|
212
|
+
renderRightDots() {
|
|
213
|
+
return html`${this._visiblePages.includes(this.total) ? "" : this.renderDots()}`;
|
|
214
|
+
}
|
|
217
215
|
renderNavigationLeft() {
|
|
218
|
-
return html` ${this.renderFirst()} ${this.renderPrevious()}
|
|
219
|
-
${this._visiblePages.includes(1) ? "" : this.renderDots()}`;
|
|
216
|
+
return html` ${this.renderFirst()} ${this.renderPrevious()}`;
|
|
220
217
|
}
|
|
221
218
|
renderNavigationRight() {
|
|
222
|
-
return html
|
|
223
|
-
${this.renderNext()} ${this.renderLast()}`;
|
|
219
|
+
return html` ${this.renderNext()} ${this.renderLast()}`;
|
|
224
220
|
}
|
|
225
221
|
render() {
|
|
226
|
-
return html
|
|
222
|
+
return html`
|
|
227
223
|
${this.renderNavigationLeft()}
|
|
228
|
-
|
|
224
|
+
<uui-button-group role="list" id="pages">
|
|
225
|
+
${this.renderLeftDots()}
|
|
226
|
+
${this._visiblePages.map(
|
|
229
227
|
(page) => this.renderPage(page)
|
|
230
228
|
)}
|
|
229
|
+
${this.renderRightDots()}
|
|
230
|
+
</uui-button-group>
|
|
231
231
|
${this.renderNavigationRight()}
|
|
232
|
-
</uui-button-group>
|
|
233
232
|
`;
|
|
234
233
|
}
|
|
235
234
|
};
|
|
236
235
|
_UUIPaginationElement.styles = [
|
|
237
236
|
css`
|
|
238
|
-
|
|
237
|
+
:host {
|
|
238
|
+
display: inline-flex;
|
|
239
239
|
width: 100%;
|
|
240
|
+
gap: 1px;
|
|
241
|
+
}
|
|
242
|
+
uui-button-group {
|
|
243
|
+
flex-grow: 1;
|
|
240
244
|
}
|
|
241
245
|
|
|
242
|
-
uui-button {
|
|
246
|
+
uui-button-group uui-button {
|
|
243
247
|
--uui-button-border-color: var(--uui-color-border-standalone);
|
|
244
248
|
--uui-button-border-color-hover: var(--uui-color-interactive-emphasis);
|
|
245
249
|
--uui-button-border-color-disabled: var(--uui-color-border-standalone);
|
|
246
250
|
}
|
|
247
251
|
|
|
248
|
-
uui-button:hover {
|
|
252
|
+
uui-button-group uui-button:hover {
|
|
249
253
|
z-index: 1;
|
|
250
254
|
}
|
|
251
255
|
|
|
@@ -263,6 +267,8 @@ _UUIPaginationElement.styles = [
|
|
|
263
267
|
|
|
264
268
|
.dots {
|
|
265
269
|
pointer-events: none;
|
|
270
|
+
min-width: 36px;
|
|
271
|
+
max-width: 72px;
|
|
266
272
|
}
|
|
267
273
|
|
|
268
274
|
.active {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.element.js","sources":["../../../src/components/pagination/pagination.element.ts"],"sourcesContent":["import type { UUIButtonElement } from '../button/button.js';\nimport { css, html, LitElement } from 'lit';\nimport { property, query, queryAll, state } from 'lit/decorators.js';\n\nimport { UUIPaginationEvent } from './UUIPaginationEvent.js';\n\nimport '../button/button.js';\nimport '../button-group/button-group.js';\n\n//this is how wide the button gets when it has 3 digits inside.\nconst PAGE_BUTTON_MAX_WIDTH = 45;\n\nconst limit = (val: number, min: number, max: number) => {\n return Math.min(Math.max(val, min), max);\n};\n\nconst arrayOfNumbers = (start: number, stop: number) => {\n return Array.from({ length: stop - start + 1 }, (_, i) => start + i);\n};\n\n/**\n * @element uui-pagination\n * @description Jump to a certain page and navigate to the next, last, previous or first page. The amount of visible page-buttons are adjusted to the available space.\n * @fires change - When clicked on the page button fires change event\n */\nexport class UUIPaginationElement extends LitElement {\n private readonly _observer = new ResizeObserver(\n this._calculateRange.bind(this),\n );\n\n connectedCallback() {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'navigation');\n this._visiblePages = this._generateVisiblePages(this.current);\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n firstUpdated() {\n this._observer.observe(this._pagesGroup);\n\n this.updateLabel();\n this._calculateRange();\n }\n\n willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n if (changedProperties.has('current') || changedProperties.has('label')) {\n this.updateLabel();\n }\n }\n\n protected updateLabel() {\n this.ariaLabel = `${this.label || 'Pagination navigation'}. Current page: ${\n this.current\n }.`;\n }\n\n private _calculateRange() {\n const containerWidth = this.offsetWidth;\n\n // get all the buttons with .nav-button class and sum up their widths\n const navButtonsWidth = Array.from(this._navButtons).reduce(\n (totalWidth, button) => {\n return totalWidth + button.getBoundingClientRect().width;\n },\n 0,\n );\n\n // subtract width of nav-buttons from the pagination container\n const rangeBaseWidth = containerWidth - navButtonsWidth;\n\n // divide remaining width by max-width of page button (when it has 3 digits), then divide by 2 to get the range.\n // Range is number of buttons visible on either \"side\" of current pag button. So, if range === 5 we shall see 11 buttons in total - 5 before the current page and 5 after. This is why we divide by 2.\n const range = rangeBaseWidth / PAGE_BUTTON_MAX_WIDTH / 2;\n this._range = Math.max(1, Math.floor(range));\n this._visiblePages = this._generateVisiblePages(this.current);\n }\n\n private _generateVisiblePages(current: number) {\n let start: number;\n if (current < this._range) {\n start = 1;\n } else if (current < this.total - this._range) {\n start = current - this._range;\n } else {\n start = this.total - this._range * 2;\n }\n\n let stop: number;\n if (current <= this._range) {\n stop = this._range * 2 + 1;\n } else if (current < this.total - this._range) {\n stop = current + this._range;\n } else {\n stop = this.total;\n }\n\n const pages = arrayOfNumbers(\n limit(start, 1, this.total),\n limit(stop, 1, this.total),\n );\n\n return pages;\n }\n\n @queryAll('uui-button.nav')\n private readonly _navButtons!: Array<UUIButtonElement>;\n\n @query('#pages')\n private readonly _pagesGroup!: any;\n\n /**\n * This property is used to generate a proper `aria-label`. It will be announced by screen reader as: \"<<this.label>>. Current page: <<this.current>>\"\n * @type {string}\n * @attr\n */\n @property()\n label = '';\n\n /**\n * With this property you can overwrite aria-label.\n * @type {string}\n * @attr\n */\n @property({ reflect: true, attribute: 'aria-label' })\n ariaLabel = '';\n\n /**\n * This property is used to generate the name of the first button\n * @type {string}\n * @attr\n */\n @property()\n firstLabel: string = 'First';\n\n /**\n * This property is used to generate the name of the previous button\n * @type {string}\n * @attr\n */\n @property()\n previousLabel: string = 'Previous';\n\n /**\n * This property is used to generate the name of the next button\n * @type {string}\n * @attr\n */\n @property()\n nextLabel: string = 'Next';\n /**\n * This property is used to generate the name of the last button\n * @type {string}\n * @attr\n */\n @property()\n lastLabel: string = 'Last';\n\n private _total = 100;\n\n /**\n * Set the amount of pages to navigate.\n * @type {number}\n * @attr\n * @default: 1\n */\n @property({ type: Number })\n get total() {\n return this._total;\n }\n set total(newValue: number) {\n this._total = newValue;\n this._visiblePages = this._generateVisiblePages(this._current);\n this.requestUpdate('total', newValue);\n }\n\n @state()\n private _range = 0;\n\n @state()\n private _visiblePages: number[] = [];\n\n private _current = 1;\n\n /**\n * Define the current active page.\n * @type {number}\n * @attr\n */\n @property({ type: Number })\n get current() {\n return this._current;\n }\n set current(newValue: number) {\n const oldValue = this._current;\n this._current = limit(newValue, 1, this.total);\n this._visiblePages = this._generateVisiblePages(this._current);\n this.requestUpdate('current', oldValue);\n }\n\n /**\n * This method will change the page to a next one.\n * @memberof UUIPaginationElement\n */\n goToNextPage() {\n this.current++;\n this.dispatchEvent(new UUIPaginationEvent(UUIPaginationEvent.CHANGE));\n }\n\n /**\n * Change the page to a previous one.\n * @memberof UUIPaginationElement\n */\n goToPreviousPage() {\n this.current--;\n this.dispatchEvent(new UUIPaginationEvent(UUIPaginationEvent.CHANGE));\n }\n\n /**\n * Change the page to the one passed as an argument to this method.\n * @param {number} page\n * @memberof UUIPaginationElement\n */\n goToPage(page: number) {\n this.current = page;\n this.dispatchEvent(new UUIPaginationEvent(UUIPaginationEvent.CHANGE));\n }\n\n /** When having limited display of page-buttons and clicking a page-button that changes the current range, the focus stays on the position of the clicked button which is not anymore representing the number clicked, therefore we move focus to the button that represents the current page. */\n protected focusActivePage() {\n requestAnimationFrame(() => {\n // for none range changing clicks we need to ensure a rendering before querying.\n const activeButtonElement =\n this.renderRoot.querySelector<HTMLElement>('.active');\n if (activeButtonElement) {\n activeButtonElement.focus();\n }\n });\n }\n\n protected renderFirst() {\n return html`<uui-button\n compact\n look=\"outline\"\n class=\"nav\"\n role=\"listitem\"\n label=${this.firstLabel}\n ?disabled=${this._current === 1}\n @click=${() => this.goToPage(1)}></uui-button>`;\n }\n\n protected renderPrevious() {\n return html`<uui-button\n compact\n look=\"outline\"\n class=\"nav\"\n role=\"listitem\"\n label=${this.previousLabel}\n ?disabled=${this._current === 1}\n @click=${this.goToPreviousPage}></uui-button>`;\n }\n\n protected renderNext() {\n return html`<uui-button\n compact\n look=\"outline\"\n role=\"listitem\"\n class=\"nav\"\n label=${this.nextLabel}\n ?disabled=${this._current === this.total}\n @click=${this.goToNextPage}></uui-button>`;\n }\n\n protected renderLast() {\n return html`\n <uui-button\n compact\n look=\"outline\"\n role=\"listitem\"\n class=\"nav\"\n label=${this.lastLabel}\n ?disabled=${this.total === this._current}\n @click=${() => this.goToPage(this.total)}></uui-button>\n `;\n }\n\n protected renderDots() {\n return html`<uui-button\n compact\n look=\"outline\"\n role=\"listitem\"\n tabindex=\"-1\"\n class=\"dots\"\n label=\"More pages\"\n >...</uui-button\n > `;\n }\n\n protected renderPage(page: number) {\n return html`<uui-button\n compact\n look=\"outline\"\n role=\"listitem\"\n label=\"Go to page ${page}\"\n class=${'page' + (page === this._current ? ' active' : '')}\n tabindex=${page === this._current ? '-1' : ''}\n @click=${() => {\n if (page === this._current) return;\n this.goToPage(page);\n this.focusActivePage();\n }}>\n ${page}\n </uui-button>`;\n }\n\n protected renderNavigationLeft() {\n return html` ${this.renderFirst()} ${this.renderPrevious()}\n ${this._visiblePages.includes(1) ? '' : this.renderDots()}`;\n }\n\n protected renderNavigationRight() {\n return html`${this._visiblePages.includes(this.total)\n ? ''\n : this.renderDots()}\n ${this.renderNext()} ${this.renderLast()}`;\n }\n\n render() {\n // prettier-ignore\n return html`<uui-button-group role=\"list\" id=\"pages\">\n ${this.renderNavigationLeft()}\n ${this._visiblePages.map(\n page =>\n this.renderPage(page)\n )}\n ${this.renderNavigationRight()}\n </uui-button-group>\n `;\n }\n\n static override readonly styles = [\n css`\n uui-button-group {\n width: 100%;\n }\n\n uui-button {\n --uui-button-border-color: var(--uui-color-border-standalone);\n --uui-button-border-color-hover: var(--uui-color-interactive-emphasis);\n --uui-button-border-color-disabled: var(--uui-color-border-standalone);\n }\n\n uui-button:hover {\n z-index: 1;\n }\n\n .page {\n min-width: 36px;\n max-width: 72px;\n }\n .page.active {\n z-index: 1;\n }\n\n .nav {\n min-width: 72px;\n }\n\n .dots {\n pointer-events: none;\n }\n\n .active {\n pointer-events: none;\n --uui-button-font-weight: 700;\n --uui-button-contrast: var(--uui-color-selected);\n --uui-button-border-color: var(--uui-color-selected);\n --uui-button-border-width: 2px;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAUA,MAAM,wBAAwB;AAE9B,MAAM,QAAQ,CAAC,KAAa,KAAa,QAAgB;AACvD,SAAO,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,GAAG,GAAG;AACzC;AAEA,MAAM,iBAAiB,CAAC,OAAe,SAAiB;AACtD,SAAO,MAAM,KAAK,EAAE,QAAQ,OAAO,QAAQ,EAAA,GAAK,CAAC,GAAG,MAAM,QAAQ,CAAC;AACrE;AAOO,MAAM,wBAAN,MAAM,8BAA6B,WAAW;AAAA,EAA9C,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAiB,YAAY,IAAI;AAAA,MAC/B,KAAK,gBAAgB,KAAK,IAAI;AAAA,IAAA;AA4FhC,SAAA,QAAQ;AAQR,SAAA,YAAY;AAQZ,SAAA,aAAqB;AAQrB,SAAA,gBAAwB;AAQxB,SAAA,YAAoB;AAOpB,SAAA,YAAoB;AAEpB,SA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AA;AAAA,EADC,SAAA;AAAS,GA7HC,qBA8HX,WAAA,aAAA,CAAA;AAOA,gBAAA;AAAA,EADC,SAAA;AAAS,GApIC,qBAqIX,WAAA,aAAA,CAAA;AAWI,gBAAA;AAAA,EADH,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/If,qBAgJP,WAAA,SAAA,CAAA;AAUI,gBAAA;AAAA,EADP,MAAA;AAAM,GAzJI,qBA0JH,WAAA,UAAA,CAAA;AAGA,gBAAA;AAAA,EADP,MAAA;AAAM,GA5JI,qBA6JH,WAAA,iBAAA,CAAA;AAUJ,gBAAA;AAAA,EADH,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAtKf,qBAuKP,WAAA,WAAA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"pagination.element.js","sources":["../../../src/components/pagination/pagination.element.ts"],"sourcesContent":["import type { UUIButtonElement } from '../button/button.js';\nimport { css, html, LitElement } from 'lit';\nimport { property, query, queryAll, state } from 'lit/decorators.js';\n\nimport { UUIPaginationEvent } from './UUIPaginationEvent.js';\n\nimport '../button/button.js';\nimport '../button-group/button-group.js';\n\n//this is how wide the button gets when it has 3 digits inside.\nconst PAGE_BUTTON_MAX_WIDTH = 45;\n\nconst limit = (val: number, min: number, max: number) => {\n return Math.min(Math.max(val, min), max);\n};\n\nconst arrayOfNumbers = (start: number, stop: number) => {\n return Array.from({ length: stop - start + 1 }, (_, i) => start + i);\n};\n\n/**\n * @element uui-pagination\n * @description Jump to a certain page and navigate to the next, last, previous or first page. The amount of visible page-buttons are adjusted to the available space.\n * @fires change - When clicked on the page button fires change event\n */\nexport class UUIPaginationElement extends LitElement {\n private readonly _observer = new ResizeObserver(\n this._calculateRange.bind(this),\n );\n\n connectedCallback() {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'navigation');\n this._visiblePages = this._generateVisiblePages(this.current);\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n firstUpdated() {\n this._observer.observe(this._pagesGroup);\n\n this.updateLabel();\n this._calculateRange();\n }\n\n willUpdate(changedProperties: Map<string | number | symbol, unknown>) {\n if (changedProperties.has('current') || changedProperties.has('label')) {\n this.updateLabel();\n }\n }\n\n protected updateLabel() {\n this.ariaLabel = `${this.label || 'Pagination navigation'}. Current page: ${\n this.current\n }.`;\n }\n\n private _calculateRange() {\n const containerWidth = this.offsetWidth;\n\n // get all the buttons with .nav-button class and sum up their widths\n const navButtonsWidth = Array.from(this._navButtons).reduce(\n (totalWidth, button) => {\n return totalWidth + button.getBoundingClientRect().width;\n },\n 0,\n );\n\n // subtract width of nav-buttons from the pagination container\n const rangeBaseWidth = containerWidth - navButtonsWidth;\n\n // divide remaining width by max-width of page button (when it has 3 digits), then divide by 2 to get the range.\n // Range is number of buttons visible on either \"side\" of current pag button. So, if range === 5 we shall see 11 buttons in total - 5 before the current page and 5 after. This is why we divide by 2.\n const range = rangeBaseWidth / PAGE_BUTTON_MAX_WIDTH / 2;\n this._range = Math.max(0, Math.floor(range));\n this._visiblePages = this._generateVisiblePages(this.current);\n }\n\n private _generateVisiblePages(current: number) {\n let start: number;\n if (current < this._range) {\n start = 1;\n } else if (current < this.total - this._range) {\n start = current - this._range;\n } else {\n start = this.total - this._range * 2;\n }\n\n let stop: number;\n if (current <= this._range) {\n stop = this._range * 2 + 1;\n } else if (current < this.total - this._range) {\n stop = current + this._range;\n } else {\n stop = this.total;\n }\n\n const pages = arrayOfNumbers(\n limit(start, 1, this.total),\n limit(stop, 1, this.total),\n );\n\n return pages;\n }\n\n @queryAll('uui-button.nav')\n private readonly _navButtons!: Array<UUIButtonElement>;\n\n @query('#pages')\n private readonly _pagesGroup!: any;\n\n /**\n * This property is used to generate a proper `aria-label`. It will be announced by screen reader as: \"<<this.label>>. Current page: <<this.current>>\"\n * @type {string}\n * @attr\n */\n @property()\n label = '';\n\n /**\n * With this property you can overwrite aria-label.\n * @type {string}\n * @attr\n */\n @property({ reflect: true, attribute: 'aria-label' })\n ariaLabel = '';\n\n /**\n * This property is used to generate the name of the first button\n * @type {string}\n * @attr\n */\n @property()\n firstLabel: string = 'First';\n\n /**\n * This property is used to generate the name of the previous button\n * @type {string}\n * @attr\n */\n @property()\n previousLabel: string = 'Previous';\n\n /**\n * This property is used to generate the name of the next button\n * @type {string}\n * @attr\n */\n @property()\n nextLabel: string = 'Next';\n /**\n * This property is used to generate the name of the last button\n * @type {string}\n * @attr\n */\n @property()\n lastLabel: string = 'Last';\n\n private _total = 100;\n\n /**\n * Set the amount of pages to navigate.\n * @type {number}\n * @attr\n * @default: 1\n */\n @property({ type: Number })\n get total() {\n return this._total;\n }\n set total(newValue: number) {\n this._total = newValue;\n this._visiblePages = this._generateVisiblePages(this._current);\n this.requestUpdate('total', newValue);\n }\n\n @state()\n private _range = 0;\n\n @state()\n private _visiblePages: number[] = [];\n\n private _current = 1;\n\n /**\n * Define the current active page.\n * @type {number}\n * @attr\n */\n @property({ type: Number })\n get current() {\n return this._current;\n }\n set current(newValue: number) {\n const oldValue = this._current;\n this._current = limit(newValue, 1, this.total);\n this._visiblePages = this._generateVisiblePages(this._current);\n this.requestUpdate('current', oldValue);\n }\n\n /**\n * This method will change the page to a next one.\n * @memberof UUIPaginationElement\n */\n goToNextPage() {\n this.current++;\n this.dispatchEvent(new UUIPaginationEvent(UUIPaginationEvent.CHANGE));\n }\n\n /**\n * Change the page to a previous one.\n * @memberof UUIPaginationElement\n */\n goToPreviousPage() {\n this.current--;\n this.dispatchEvent(new UUIPaginationEvent(UUIPaginationEvent.CHANGE));\n }\n\n /**\n * Change the page to the one passed as an argument to this method.\n * @param {number} page\n * @memberof UUIPaginationElement\n */\n goToPage(page: number) {\n this.current = page;\n this.dispatchEvent(new UUIPaginationEvent(UUIPaginationEvent.CHANGE));\n }\n\n /** When having limited display of page-buttons and clicking a page-button that changes the current range, the focus stays on the position of the clicked button which is not anymore representing the number clicked, therefore we move focus to the button that represents the current page. */\n protected focusActivePage() {\n requestAnimationFrame(() => {\n // for none range changing clicks we need to ensure a rendering before querying.\n const activeButtonElement =\n this.renderRoot.querySelector<HTMLElement>('.active');\n if (activeButtonElement) {\n activeButtonElement.focus();\n }\n });\n }\n\n protected renderFirst() {\n return html`<uui-button\n compact\n class=\"nav\"\n label=${this.firstLabel}\n ?disabled=${this._current === 1}\n @click=${() => this.goToPage(1)}></uui-button>`;\n }\n\n protected renderPrevious() {\n return html`<uui-button\n compact\n class=\"nav\"\n label=${this.previousLabel}\n ?disabled=${this._current === 1}\n @click=${this.goToPreviousPage}></uui-button>`;\n }\n\n protected renderNext() {\n return html`<uui-button\n compact\n class=\"nav\"\n label=${this.nextLabel}\n ?disabled=${this._current === this.total}\n @click=${this.goToNextPage}></uui-button>`;\n }\n\n protected renderLast() {\n return html`\n <uui-button\n compact\n class=\"nav\"\n label=${this.lastLabel}\n ?disabled=${this.total === this._current}\n @click=${() => this.goToPage(this.total)}></uui-button>\n `;\n }\n\n protected renderDots() {\n return html`<uui-button\n compact\n look=\"outline\"\n role=\"listitem\"\n tabindex=\"-1\"\n class=\"dots\"\n label=\"More pages\"\n >...</uui-button\n >`;\n }\n\n protected renderPage(page: number) {\n return html`<uui-button\n compact\n look=\"outline\"\n role=\"listitem\"\n label=\"Go to page ${page}\"\n class=${'page' + (page === this._current ? ' active' : '')}\n tabindex=${page === this._current ? '-1' : ''}\n @click=${() => {\n if (page === this._current) return;\n this.goToPage(page);\n this.focusActivePage();\n }}>\n ${page}\n </uui-button>`;\n }\n\n protected renderLeftDots() {\n return html` ${this._visiblePages.includes(1) ? '' : this.renderDots()}`;\n }\n protected renderRightDots() {\n return html`${this._visiblePages.includes(this.total)\n ? ''\n : this.renderDots()}`;\n }\n\n protected renderNavigationLeft() {\n return html` ${this.renderFirst()} ${this.renderPrevious()}`;\n }\n protected renderNavigationRight() {\n return html` ${this.renderNext()} ${this.renderLast()}`;\n }\n\n render() {\n // prettier-ignore\n return html`\n ${this.renderNavigationLeft()}\n <uui-button-group role=\"list\" id=\"pages\">\n ${this.renderLeftDots()}\n ${this._visiblePages.map(\n page =>\n this.renderPage(page)\n )}\n ${this.renderRightDots()}\n </uui-button-group>\n ${this.renderNavigationRight()}\n `;\n }\n\n static override readonly styles = [\n css`\n :host {\n display: inline-flex;\n width: 100%;\n gap: 1px;\n }\n uui-button-group {\n flex-grow: 1;\n }\n\n uui-button-group uui-button {\n --uui-button-border-color: var(--uui-color-border-standalone);\n --uui-button-border-color-hover: var(--uui-color-interactive-emphasis);\n --uui-button-border-color-disabled: var(--uui-color-border-standalone);\n }\n\n uui-button-group uui-button:hover {\n z-index: 1;\n }\n\n .page {\n min-width: 36px;\n max-width: 72px;\n }\n .page.active {\n z-index: 1;\n }\n\n .nav {\n min-width: 72px;\n }\n\n .dots {\n pointer-events: none;\n min-width: 36px;\n max-width: 72px;\n }\n\n .active {\n pointer-events: none;\n --uui-button-font-weight: 700;\n --uui-button-contrast: var(--uui-color-selected);\n --uui-button-border-color: var(--uui-color-selected);\n --uui-button-border-width: 2px;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAUA,MAAM,wBAAwB;AAE9B,MAAM,QAAQ,CAAC,KAAa,KAAa,QAAgB;AACvD,SAAO,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,GAAG,GAAG;AACzC;AAEA,MAAM,iBAAiB,CAAC,OAAe,SAAiB;AACtD,SAAO,MAAM,KAAK,EAAE,QAAQ,OAAO,QAAQ,EAAA,GAAK,CAAC,GAAG,MAAM,QAAQ,CAAC;AACrE;AAOO,MAAM,wBAAN,MAAM,8BAA6B,WAAW;AAAA,EAA9C,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAiB,YAAY,IAAI;AAAA,MAC/B,KAAK,gBAAgB,KAAK,IAAI;AAAA,IAAA;AA4FhC,SAAA,QAAQ;AAQR,SAAA,YAAY;AAQZ,SAAA,aAAqB;AAQrB,SAAA,gBAAwB;AAQxB,SAAA,YAAoB;AAOpB,SAAA,YAAoB;AAEpB,SAAQ,SAAS;AA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A;AAAS,GA7GC,qBA8GX,WAAA,cAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAA;AAAS,GArHC,qBAsHX,WAAA,iBAAA,CAAA;AAQA,gBAAA;AAAA,EADC,SAAA;AAAS,GA7HC,qBA8HX,WAAA,aAAA,CAAA;AAOA,gBAAA;AAAA,EADC,SAAA;AAAS,GApIC,qBAqIX,WAAA,aAAA,CAAA;AAWI,gBAAA;AAAA,EADH,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA/If,qBAgJP,WAAA,SAAA,CAAA;AAUI,gBAAA;AAAA,EADP,MAAA;AAAM,GAzJI,qBA0JH,WAAA,UAAA,CAAA;AAGA,gBAAA;AAAA,EADP,MAAA;AAAM,GA5JI,qBA6JH,WAAA,iBAAA,CAAA;AAUJ,gBAAA;AAAA,EADH,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAtKf,qBAuKP,WAAA,WAAA,CAAA;"}
|
|
@@ -37,19 +37,20 @@ const _UUIProgressBarElement = class _UUIProgressBarElement extends LitElement {
|
|
|
37
37
|
_UUIProgressBarElement.styles = [
|
|
38
38
|
css`
|
|
39
39
|
:host {
|
|
40
|
-
width: 100%;
|
|
41
|
-
height: 4px;
|
|
42
40
|
position: relative;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
background: var(--uui-color-surface-alt);
|
|
45
|
-
border-radius: 100px;
|
|
46
41
|
display: inline-block;
|
|
42
|
+
width: 100%;
|
|
43
|
+
height: 3px;
|
|
44
|
+
overflow: clip;
|
|
45
|
+
background: var(--uui-color-surface-alt);
|
|
46
|
+
border-radius: 2px;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
#bar {
|
|
50
50
|
transition: width 250ms ease;
|
|
51
51
|
background: var(--uui-color-positive);
|
|
52
52
|
height: 100%;
|
|
53
|
+
border-radius: 2px;
|
|
53
54
|
width: 0%;
|
|
54
55
|
}
|
|
55
56
|
`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress-bar.element.js","sources":["../../../src/components/progress-bar/progress-bar.element.ts"],"sourcesContent":["import { LitElement, html, css } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\n\nconst clamp = (num: number, min: number, max: number) =>\n Math.min(Math.max(num, min), max);\n\n/**\n * @element uui-progress-bar\n */\nexport class UUIProgressBarElement extends LitElement {\n private _progress = 0;\n /**\n * Set this to a number between 0 and 100 to reflect the progress of some operation.\n * @type {number}\n * @attr\n * @default 0\n */\n @property({ type: Number })\n get progress() {\n return this._progress;\n }\n\n set progress(newVal) {\n const oldVal = this._progress;\n this._progress = clamp(newVal, 0, 100);\n this.requestUpdate('progress', oldVal);\n }\n\n private _getProgressStyle() {\n return { width: `${this._progress}%` };\n }\n\n render() {\n return html`\n <div id=\"bar\" style=${styleMap(this._getProgressStyle())}></div>\n `;\n }\n\n static override readonly styles = [\n css`\n :host {\n
|
|
1
|
+
{"version":3,"file":"progress-bar.element.js","sources":["../../../src/components/progress-bar/progress-bar.element.ts"],"sourcesContent":["import { LitElement, html, css } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\n\nconst clamp = (num: number, min: number, max: number) =>\n Math.min(Math.max(num, min), max);\n\n/**\n * @element uui-progress-bar\n */\nexport class UUIProgressBarElement extends LitElement {\n private _progress = 0;\n /**\n * Set this to a number between 0 and 100 to reflect the progress of some operation.\n * @type {number}\n * @attr\n * @default 0\n */\n @property({ type: Number })\n get progress() {\n return this._progress;\n }\n\n set progress(newVal) {\n const oldVal = this._progress;\n this._progress = clamp(newVal, 0, 100);\n this.requestUpdate('progress', oldVal);\n }\n\n private _getProgressStyle() {\n return { width: `${this._progress}%` };\n }\n\n render() {\n return html`\n <div id=\"bar\" style=${styleMap(this._getProgressStyle())}></div>\n `;\n }\n\n static override readonly styles = [\n css`\n :host {\n position: relative;\n display: inline-block;\n width: 100%;\n height: 3px;\n overflow: clip;\n background: var(--uui-color-surface-alt);\n border-radius: 2px;\n }\n\n #bar {\n transition: width 250ms ease;\n background: var(--uui-color-positive);\n height: 100%;\n border-radius: 2px;\n width: 0%;\n }\n `,\n ];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAIA,MAAM,QAAQ,CAAC,KAAa,KAAa,QACvC,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,GAAG,GAAG;AAK3B,MAAM,yBAAN,MAAM,+BAA8B,WAAW;AAAA,EAA/C,cAAA;AAAA,UAAA,GAAA,SAAA;AACL,SAAQ,YAAY;AAAA,EAAA;AAAA,EAQpB,IAAI,WAAW;AACb,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,SAAS,QAAQ;AACnB,UAAM,SAAS,KAAK;AACpB,SAAK,YAAY,MAAM,QAAQ,GAAG,GAAG;AACrC,SAAK,cAAc,YAAY,MAAM;AAAA,EACvC;AAAA,EAEQ,oBAAoB;AAC1B,WAAO,EAAE,OAAO,GAAG,KAAK,SAAS,IAAA;AAAA,EACnC;AAAA,EAEA,SAAS;AACP,WAAO;AAAA,4BACiB,SAAS,KAAK,kBAAA,CAAmB,CAAC;AAAA;AAAA,EAE5D;AAuBF;AArBE,uBAAyB,SAAS;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA9BG,IAAM,wBAAN;AASD,gBAAA;AAAA,EADH,SAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GARf,sBASP,WAAA,UAAA;"}
|