@skf-design-system/ui-components 1.0.0-alpha.38 → 1.0.0-alpha.39
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/README.md +18 -0
- package/dist/components/alert/alert.component.d.ts +3 -2
- package/dist/components/alert/alert.component.js +39 -33
- package/dist/components/breadcrumb/breadcrumb-item.component.js +11 -12
- package/dist/components/button/button.component.js +32 -36
- package/dist/components/button/button.styles.js +3 -3
- package/dist/components/checkbox/checkbox.component.d.ts +6 -5
- package/dist/components/checkbox/checkbox.component.js +67 -69
- package/dist/components/checkbox/checkbox.styles.js +1 -1
- package/dist/components/datepicker/datepicker-calendar.component.d.ts +1 -0
- package/dist/components/datepicker/datepicker-calendar.component.js +107 -116
- package/dist/components/datepicker/datepicker-popup.component.d.ts +4 -0
- package/dist/components/datepicker/datepicker-popup.component.js +112 -100
- package/dist/components/datepicker/datepicker-popup.helpers.js +1 -1
- package/dist/components/datepicker/datepicker.component.d.ts +4 -2
- package/dist/components/datepicker/datepicker.component.js +159 -160
- package/dist/components/dialog/dialog.component.d.ts +3 -2
- package/dist/components/dialog/dialog.component.js +48 -48
- package/dist/components/divider/divider.component.d.ts +3 -0
- package/dist/components/divider/divider.component.js +43 -22
- package/dist/components/divider/divider.styles.js +9 -9
- package/dist/components/drawer/drawer.component.d.ts +12 -4
- package/dist/components/drawer/drawer.component.js +84 -61
- package/dist/components/drawer/drawer.styles.js +47 -40
- package/dist/components/header/header.component.d.ts +4 -2
- package/dist/components/header/header.component.js +64 -57
- package/dist/components/header/header.styles.js +2 -2
- package/dist/components/icon/icon.component.js +26 -16
- package/dist/components/icon/icon.styles.js +4 -4
- package/dist/components/input/input.component.d.ts +11 -10
- package/dist/components/input/input.component.js +115 -111
- package/dist/components/input/input.controllers.d.ts +0 -1
- package/dist/components/input/input.controllers.js +14 -19
- package/dist/components/link/link.component.d.ts +1 -0
- package/dist/components/link/link.component.js +86 -74
- package/dist/components/link/link.styles.js +7 -3
- package/dist/components/loader/loader.component.d.ts +0 -2
- package/dist/components/loader/loader.component.js +27 -30
- package/dist/components/loader/loader.styles.js +1 -1
- package/dist/components/menu/menu-item.styles.js +8 -7
- package/dist/components/menu/menu.component.d.ts +5 -2
- package/dist/components/menu/menu.component.js +7 -7
- package/dist/components/nav/nav.component.d.ts +3 -0
- package/dist/components/nav/nav.component.js +38 -33
- package/dist/components/popover/popover.component.d.ts +6 -7
- package/dist/components/popover/popover.component.js +23 -31
- package/dist/components/progress/progress.styles.js +3 -3
- package/dist/components/radio/radio.component.d.ts +4 -2
- package/dist/components/radio/radio.component.js +96 -91
- package/dist/components/radio/radio.styles.js +1 -1
- package/dist/components/segmented-button/segmented-button-item.component.js +1 -1
- package/dist/components/segmented-button/segmented-button-item.styles.js +1 -1
- package/dist/components/segmented-button/segmented-button.component.js +22 -24
- package/dist/components/select/select-option.component.d.ts +2 -1
- package/dist/components/select/select-option.component.js +31 -36
- package/dist/components/select/select.component.d.ts +20 -10
- package/dist/components/select/select.component.js +139 -104
- package/dist/components/select/select.controllers.js +14 -17
- package/dist/components/select/select.styles.js +8 -3
- package/dist/components/stepper/stepper-item.component.d.ts +1 -1
- package/dist/components/stepper/stepper-item.component.js +26 -23
- package/dist/components/stepper/stepper-item.styles.js +4 -4
- package/dist/components/stepper/stepper.component.js +2 -3
- package/dist/components/stepper/stepper.helpers.js +6 -7
- package/dist/components/switch/switch.component.d.ts +4 -2
- package/dist/components/switch/switch.component.js +64 -58
- package/dist/components/switch/switch.styles.js +1 -1
- package/dist/components/tabs/tab-panel.component.d.ts +1 -1
- package/dist/components/tabs/tab-panel.component.js +19 -16
- package/dist/components/tabs/tab.component.d.ts +1 -1
- package/dist/components/tabs/tab.component.js +17 -14
- package/dist/components/tabs/tab.styles.js +2 -2
- package/dist/components/tabs/tabs.component.js +6 -6
- package/dist/components/tag/tag.component.d.ts +9 -6
- package/dist/components/tag/tag.component.js +78 -72
- package/dist/components/tag/tag.styles.js +5 -0
- package/dist/components/textarea/textarea.component.d.ts +4 -2
- package/dist/components/textarea/textarea.component.js +101 -95
- package/dist/components/toast/toast-item.styles.js +13 -10
- package/dist/components/toast/toast.singleton.js +6 -7
- package/dist/components/tooltip/tooltip.component.d.ts +7 -4
- package/dist/components/tooltip/tooltip.component.js +22 -14
- package/dist/custom-elements.json +835 -422
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -20
- package/dist/internal/base-classes/popover/popover.base.d.ts +28 -8
- package/dist/internal/base-classes/popover/popover.base.js +78 -74
- package/dist/internal/components/formBase.d.ts +1 -0
- package/dist/internal/components/formBase.js +11 -19
- package/dist/internal/controllers/popover.controller.d.ts +2 -0
- package/dist/internal/controllers/popover.controller.js +11 -14
- package/dist/internal/helpers/stateMap.js +3 -3
- package/dist/internal/helpers/uuid.d.ts +8 -10
- package/dist/internal/helpers/uuid.js +4 -11
- package/dist/internal/helpers/watch.d.ts +1 -1
- package/dist/internal/templates/asterisk.d.ts +1 -1
- package/dist/internal/templates/asterisk.js +4 -4
- package/dist/internal/types.d.ts +4 -0
- package/dist/styles/global-alt.css +1 -1
- package/dist/styles/global.css +1 -1
- package/dist/translations/en.d.ts +3 -0
- package/dist/translations/en.js +27 -0
- package/dist/translations/es.d.ts +3 -0
- package/dist/translations/es.js +27 -0
- package/dist/translations/index.d.ts +4 -0
- package/dist/translations/pt.d.ts +3 -0
- package/dist/translations/pt.js +27 -0
- package/dist/translations/sv.d.ts +3 -0
- package/dist/translations/sv.js +27 -0
- package/dist/types/jsx/custom-element-jsx.d.ts +1840 -858
- package/dist/types/vue/index.d.ts +69 -64
- package/dist/utilities/localize.d.ts +28 -0
- package/dist/utilities/localize.js +13 -0
- package/dist/vscode.html-custom-data.json +75 -83
- package/dist/web-types.json +229 -190
- package/package.json +29 -35
- package/custom-elements.json +0 -25490
package/dist/index.d.ts
CHANGED
@@ -28,8 +28,8 @@ export { default as SkfProgress } from './components/progress/progress.js';
|
|
28
28
|
export { default as SkfRadio } from './components/radio/radio.js';
|
29
29
|
export { default as SkfSegmentedButtonItem } from './components/segmented-button/segmented-button-item.js';
|
30
30
|
export { default as SkfSegmentedButton } from './components/segmented-button/segmented-button.js';
|
31
|
-
export { default as
|
32
|
-
export { default as
|
31
|
+
export { default as SkfSelectOptionGroup } from './components/select/select-option-group.js';
|
32
|
+
export { default as SkfSelectOption } from './components/select/select-option.js';
|
33
33
|
export { default as SkfSelect } from './components/select/select.js';
|
34
34
|
export { default as SkfStepperItem } from './components/stepper/stepper-item.js';
|
35
35
|
export { default as SkfStepper } from './components/stepper/stepper.js';
|
package/dist/index.js
CHANGED
@@ -56,14 +56,14 @@ import { SkfDatepickerPopup as ao } from "./components/datepicker/datepicker-pop
|
|
56
56
|
import { SkfDatepicker as co } from "./components/datepicker/datepicker.component.js";
|
57
57
|
import { SkfDialog as Io } from "./components/dialog/dialog.component.js";
|
58
58
|
import { SkfDivider as lo } from "./components/divider/divider.component.js";
|
59
|
-
import { SkfDrawer as
|
59
|
+
import { SkfDrawer as bo } from "./components/drawer/drawer.component.js";
|
60
60
|
import { SkfHeader as Do } from "./components/header/header.component.js";
|
61
61
|
import { SkfHeading as vo } from "./components/heading/heading.component.js";
|
62
|
-
import { SkfIcon as
|
63
|
-
import { SkfInput as
|
64
|
-
import { SkfLink as
|
65
|
-
import { SkfLoader as
|
66
|
-
import { SkfLogo as
|
62
|
+
import { SkfIcon as Po } from "./components/icon/icon.component.js";
|
63
|
+
import { SkfInput as Lo } from "./components/input/input.component.js";
|
64
|
+
import { SkfLink as wo } from "./components/link/link.component.js";
|
65
|
+
import { SkfLoader as Mo } from "./components/loader/loader.component.js";
|
66
|
+
import { SkfLogo as Oo } from "./components/logo/logo.component.js";
|
67
67
|
import { SkfMenuItem as Ro } from "./components/menu/menu-item.component.js";
|
68
68
|
import { SkfMenu as jo } from "./components/menu/menu.component.js";
|
69
69
|
import { SkfNavItem as yo } from "./components/nav/nav-item.component.js";
|
@@ -83,11 +83,11 @@ import { SkfTabPanel as nr } from "./components/tabs/tab-panel.component.js";
|
|
83
83
|
import { SkfTab as dr } from "./components/tabs/tab.component.js";
|
84
84
|
import { SkfTabs as Ir } from "./components/tabs/tabs.component.js";
|
85
85
|
import { SkfTag as lr } from "./components/tag/tag.component.js";
|
86
|
-
import { SkfTextArea as
|
86
|
+
import { SkfTextArea as br } from "./components/textarea/textarea.component.js";
|
87
87
|
import { SkfToastItem as Dr } from "./components/toast/toast-item.component.js";
|
88
88
|
import { SkfToastWrapper as vr } from "./components/toast/toast-wrapper.component.js";
|
89
|
-
import { SkfToast as
|
90
|
-
import { SkfTooltip as
|
89
|
+
import { SkfToast as Pr } from "./components/toast/toast.component.js";
|
90
|
+
import { SkfTooltip as Lr } from "./components/tooltip/tooltip.component.js";
|
91
91
|
export {
|
92
92
|
X as SkfAccordion,
|
93
93
|
U as SkfAccordionItem,
|
@@ -102,26 +102,26 @@ export {
|
|
102
102
|
ao as SkfDatepickerPopup,
|
103
103
|
Io as SkfDialog,
|
104
104
|
lo as SkfDivider,
|
105
|
-
|
105
|
+
bo as SkfDrawer,
|
106
106
|
Do as SkfHeader,
|
107
107
|
vo as SkfHeading,
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
108
|
+
Po as SkfIcon,
|
109
|
+
Lo as SkfInput,
|
110
|
+
wo as SkfLink,
|
111
|
+
Mo as SkfLoader,
|
112
|
+
Oo as SkfLogo,
|
113
113
|
jo as SkfMenu,
|
114
114
|
Ro as SkfMenuItem,
|
115
115
|
Eo as SkfNav,
|
116
116
|
yo as SkfNavItem,
|
117
|
-
tr as SkfOption,
|
118
|
-
or as SkfOptionGroup,
|
119
117
|
Jo as SkfPopover,
|
120
118
|
Qo as SkfProgress,
|
121
119
|
Vo as SkfRadio,
|
122
120
|
_o as SkfSegmentedButton,
|
123
121
|
Yo as SkfSegmentedButtonItem,
|
124
122
|
mr as SkfSelect,
|
123
|
+
tr as SkfSelectOption,
|
124
|
+
or as SkfSelectOptionGroup,
|
125
125
|
Sr as SkfStepper,
|
126
126
|
fr as SkfStepperItem,
|
127
127
|
xr as SkfSwitch,
|
@@ -129,9 +129,9 @@ export {
|
|
129
129
|
nr as SkfTabPanel,
|
130
130
|
Ir as SkfTabs,
|
131
131
|
lr as SkfTag,
|
132
|
-
|
133
|
-
|
132
|
+
br as SkfTextArea,
|
133
|
+
Pr as SkfToast,
|
134
134
|
Dr as SkfToastItem,
|
135
135
|
vr as SkfToastWrapper,
|
136
|
-
|
136
|
+
Lr as SkfTooltip
|
137
137
|
};
|
@@ -2,38 +2,58 @@ import { type Placement } from '@floating-ui/dom';
|
|
2
2
|
import { SkfElement } from '../../components/skf-element.js';
|
3
3
|
import { PopoverController } from '../../controllers/popover.controller.js';
|
4
4
|
import { type CSSResultGroup } from 'lit';
|
5
|
+
/**
|
6
|
+
* @description - Base class for popover components.
|
7
|
+
* This class provides common functionality for popovers, such as handling open/close states, positioning, and event management.
|
8
|
+
* It should be extended by specific popover components like `SkfPopover`, `SkfTooltip`, etc.
|
9
|
+
*
|
10
|
+
* @event {CustomEvent} skf-opened - Fired when the popover is opened
|
11
|
+
* @event {CustomEvent} skf-closed - Fired when the popover is closed
|
12
|
+
*
|
13
|
+
* @slot - The popover content
|
14
|
+
*/
|
5
15
|
export declare class SkfPopoverBase extends SkfElement {
|
6
16
|
static styles: CSSResultGroup;
|
7
17
|
static classMap: {};
|
18
|
+
_skipClosingThisTick: boolean;
|
19
|
+
/** @internal - The popover element, aka `this` */
|
8
20
|
$popover: this;
|
21
|
+
/** Where the popover is positioned relative to the anchor element if it fits */
|
9
22
|
placement: Placement;
|
23
|
+
/** The variant of the popover extending this base class */
|
10
24
|
variant: 'menu' | 'popup' | 'tooltip';
|
25
|
+
/** The id of the element the popover will be anchored to */
|
11
26
|
anchor?: string;
|
27
|
+
/** Whether the popover is currently open */
|
12
28
|
isOpen: boolean;
|
29
|
+
/** @internal - Gap between popover and anchor */
|
13
30
|
offset: number;
|
31
|
+
/** @internal - Element that triggered the popover */
|
14
32
|
$anchor?: Element | HTMLElement | null;
|
33
|
+
/** If true, displays an arrow on the popover */
|
15
34
|
arrow: boolean;
|
16
|
-
/** @internal */
|
35
|
+
/** @internal - the event that triggers the popover */
|
17
36
|
triggerEvent: 'mouseenter' | 'click';
|
37
|
+
/** @internal - Reference to the arrow element */
|
18
38
|
$arrow: HTMLElement;
|
39
|
+
/**
|
40
|
+
* Used to store the outside click listener reference for cleanup and to avoid duplicates
|
41
|
+
*/
|
42
|
+
_skfPopoverOutsideClickListener?: (e: MouseEvent) => void;
|
19
43
|
protected abortEventsController: AbortController;
|
20
44
|
protected signal: AbortSignal;
|
21
45
|
protected popoverController: PopoverController;
|
22
|
-
|
46
|
+
connectedCallback(): void;
|
23
47
|
disconnectedCallback(): void;
|
24
48
|
protected _toggleOpen: (newValue?: boolean) => void;
|
25
49
|
private _handleToggle;
|
26
50
|
handleToggleOpen: () => Promise<void>;
|
27
|
-
handleAnchorEl(): void
|
51
|
+
handleAnchorEl(): Promise<void>;
|
28
52
|
handleAnchorChange: () => Promise<void>;
|
29
53
|
reposition: () => Promise<void>;
|
30
54
|
handleEscapeKey: (e: KeyboardEvent) => void;
|
31
55
|
open: (e: Event) => void;
|
32
|
-
|
33
|
-
openExtended(): void;
|
34
|
-
close(): void;
|
35
|
-
/** @internal add additional close tasks here in UI component */
|
36
|
-
closeExtended(): void;
|
56
|
+
close: (reason?: string) => void;
|
37
57
|
/** @internal eventlisteners here should implement abort signal */
|
38
58
|
addEventListeners($element: HTMLElement | Element): void;
|
39
59
|
/** @internal */
|
@@ -1,95 +1,104 @@
|
|
1
|
-
import { flip as
|
2
|
-
import { SkfElement as
|
3
|
-
import { PopoverController as
|
4
|
-
import { uuid as
|
1
|
+
import { flip as y, offset as $, arrow as E, computePosition as O } from "@floating-ui/dom";
|
2
|
+
import { SkfElement as C } from "../../components/skf-element.js";
|
3
|
+
import { PopoverController as T } from "../../controllers/popover.controller.js";
|
4
|
+
import { uuid as k } from "../../helpers/uuid.js";
|
5
5
|
import { watch as f } from "../../helpers/watch.js";
|
6
|
-
import { componentStyles as
|
7
|
-
import { nothing as
|
8
|
-
import { property as u, state as c, query as
|
9
|
-
import { classMap as
|
10
|
-
import { styles as
|
11
|
-
var
|
12
|
-
for (var e =
|
13
|
-
(a =
|
14
|
-
return
|
15
|
-
},
|
16
|
-
const
|
6
|
+
import { componentStyles as P } from "../../../styles/component.styles.js";
|
7
|
+
import { nothing as _, html as m } from "lit";
|
8
|
+
import { property as u, state as c, query as A } from "lit/decorators.js";
|
9
|
+
import { classMap as S } from "lit/directives/class-map.js";
|
10
|
+
import { styles as L } from "./popover.styles.js";
|
11
|
+
var x = Object.defineProperty, F = Object.getOwnPropertyDescriptor, r = (g, t, s, o) => {
|
12
|
+
for (var e = o > 1 ? void 0 : o ? F(t, s) : t, n = g.length - 1, a; n >= 0; n--)
|
13
|
+
(a = g[n]) && (e = (o ? a(t, s, e) : a(e)) || e);
|
14
|
+
return o && e && x(t, s, e), e;
|
15
|
+
}, h;
|
16
|
+
const i = (h = class extends C {
|
17
17
|
constructor() {
|
18
|
-
super(), this.$popover = this, this.placement = "top", this.variant = "popup", this.isOpen = !1, this.offset = 0, this.arrow = !1, this.triggerEvent = "mouseenter", this.abortEventsController = new AbortController(), this.signal = this.abortEventsController.signal, this.popoverController = new
|
18
|
+
super(...arguments), this._skipClosingThisTick = !1, this.$popover = this, this.placement = "top", this.variant = "popup", this.isOpen = !1, this.offset = 0, this.arrow = !1, this.triggerEvent = "mouseenter", this.abortEventsController = new AbortController(), this.signal = this.abortEventsController.signal, this.popoverController = new T(this), this._toggleOpen = (t) => {
|
19
19
|
this.isOpen = t ?? !this.isOpen;
|
20
20
|
}, this._handleToggle = (t) => {
|
21
|
-
const
|
22
|
-
this.isOpen =
|
21
|
+
const s = t.newState === "open";
|
22
|
+
this.isOpen = s, this.emit(s ? "skf-opened" : "skf-closed");
|
23
23
|
}, this.handleToggleOpen = async () => {
|
24
|
-
this.$anchor && (this.isOpen ? (this.$popover.togglePopover(!0), this.$popover.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250, fill: "forwards" })) : (await this.$popover.animate([{ opacity: 0 }], { duration: 150, fill: "forwards" }).finished, this.$popover.togglePopover(this.isOpen)));
|
24
|
+
this.$anchor && (this.isOpen ? (this.$popover.togglePopover(!0), this.$popover.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250, fill: "forwards" })) : (await this.$popover.animate([{ opacity: 0 }], { duration: 150, fill: "forwards" }).finished, this.$popover && this.$popover.togglePopover(this.isOpen)));
|
25
25
|
}, this.handleAnchorChange = async () => {
|
26
26
|
if (!this.anchor) return;
|
27
27
|
await this.popoverController.stop(), this.$anchor && this.removeEventListeners();
|
28
28
|
const t = this.getRootNode();
|
29
29
|
this.$anchor = t.getElementById(this.anchor), this.$anchor && (this.addEventListeners(this.$anchor), this.popoverController.start());
|
30
30
|
}, this.reposition = async () => {
|
31
|
-
var n, a, h;
|
32
31
|
if (!this.$anchor) return;
|
33
|
-
const t = [
|
34
|
-
this.arrow && t.push(
|
35
|
-
const { x:
|
32
|
+
const t = [y(), $(this.offset)];
|
33
|
+
this.arrow && t.push(E({ element: this.$arrow }));
|
34
|
+
const { x: s, y: o, middlewareData: e } = await O(this.$anchor, this.$popover, {
|
36
35
|
placement: this.placement,
|
37
36
|
middleware: t,
|
38
37
|
strategy: "fixed"
|
39
38
|
});
|
40
39
|
if (Object.assign(this.$popover.style, {
|
41
|
-
left: `${String(
|
42
|
-
top: `${String(
|
40
|
+
left: `${String(s)}px`,
|
41
|
+
top: `${String(o)}px`
|
43
42
|
}), this.arrow) {
|
44
|
-
const
|
43
|
+
const n = this.placement.split("-")[0], a = { top: "bottom", right: "left", bottom: "top", left: "right" }[n] ?? "", p = e.flip?.index, d = e.arrow?.x, l = e.arrow?.y, v = typeof d == "number" ? `${String(d)}px` : "", b = typeof l == "number" ? `${String(l)}px` : "", w = {
|
45
44
|
bottom: 45,
|
46
45
|
right: 135,
|
47
46
|
top: 225,
|
48
47
|
left: 315
|
49
48
|
};
|
50
49
|
Object.assign(this.$arrow.style, {
|
51
|
-
top:
|
52
|
-
[this.placement.includes("left") ? "right" : "left"]:
|
53
|
-
[
|
54
|
-
rotate: `${(
|
50
|
+
top: b,
|
51
|
+
[this.placement.includes("left") ? "right" : "left"]: v,
|
52
|
+
[p ? n : a]: "calc(var(--_skf-popover-arrow-size) * -1)",
|
53
|
+
rotate: `${(w[a] + (p ? 180 : 0)).toString()}deg`
|
55
54
|
});
|
56
55
|
}
|
57
56
|
}, this.handleEscapeKey = (t) => {
|
58
57
|
t.key === "Escape" && this.close();
|
59
58
|
}, this.open = (t) => {
|
60
|
-
t.stopPropagation()
|
61
|
-
|
59
|
+
t.stopPropagation();
|
60
|
+
const o = this.tagName === "SKF-MENU" ? void 0 : !0;
|
61
|
+
this._toggleOpen(o), this.abortEventsController = new AbortController(), this.signal = this.abortEventsController.signal, document.addEventListener("keydown", this.handleEscapeKey, { signal: this.signal }), this.tagName === "SKF-TOOLTIP" && this.$anchor?.setAttribute("aria-describedby", this.id);
|
62
|
+
}, this.close = (t = "") => {
|
63
|
+
console.log("Popover closing", t), this._toggleOpen(!1), this.abortEventsController.abort(), this.tagName === "SKF-TOOLTIP" && this.$anchor?.removeAttribute("aria-describedby");
|
64
|
+
};
|
65
|
+
}
|
66
|
+
connectedCallback() {
|
67
|
+
super.connectedCallback(), this.setAttribute("popover", ""), this.addEventListener("toggle", (t) => {
|
68
|
+
this._handleToggle(t);
|
69
|
+
});
|
62
70
|
}
|
63
71
|
disconnectedCallback() {
|
64
72
|
super.disconnectedCallback(), this.abortEventsController.abort();
|
65
73
|
}
|
66
|
-
handleAnchorEl() {
|
74
|
+
async handleAnchorEl() {
|
67
75
|
if (!this.$anchor) return;
|
68
76
|
const t = this._containsFocusableElement(this);
|
69
77
|
this.$anchor.addEventListener(
|
70
78
|
"focusout",
|
71
79
|
(o) => {
|
72
|
-
const
|
73
|
-
t &&
|
80
|
+
const e = this.contains(o.relatedTarget);
|
81
|
+
t && e || this._skipClosingThisTick || this.close("anchor focus out");
|
74
82
|
},
|
75
83
|
{ signal: this.signal }
|
76
84
|
), this.addEventListener(
|
77
85
|
"focusout",
|
78
86
|
(o) => {
|
79
|
-
const
|
80
|
-
t &&
|
87
|
+
const e = this.contains(o.relatedTarget);
|
88
|
+
t && e || this.close("popover focusout");
|
81
89
|
},
|
82
90
|
{ signal: this.signal }
|
83
|
-
), this
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
91
|
+
), this._skfPopoverOutsideClickListener ??= (o) => {
|
92
|
+
this.isOpen && this.$anchor && !this.contains(o.target) && !this.$anchor.contains(o.target) ? this.close("outside click") : (this._skipClosingThisTick = !0, setTimeout(() => {
|
93
|
+
this._skipClosingThisTick = !1;
|
94
|
+
}, 0));
|
95
|
+
}, document.addEventListener("mousedown", this._skfPopoverOutsideClickListener, {
|
96
|
+
signal: this.signal
|
97
|
+
});
|
98
|
+
const s = window.top && window.self !== window.top;
|
99
|
+
console.log("contains frames", s), s && window.top && !this._skipClosingThisTick && window.top.addEventListener("mousedown", this._skfPopoverOutsideClickListener, {
|
100
|
+
signal: this.signal
|
101
|
+
}), this.$popover.id = await k(this.$anchor.id), ["popup", "menu"].includes(this.variant) && (this.$anchor.setAttribute("aria-haspopup", "true"), this.setAttribute("aria-labelledby", this.$anchor.id)), ["menu"].includes(this.variant) && this.$anchor.setAttribute("aria-controls", this.$popover.id), ["popup"].includes(this.variant) && t && (this.role = "dialog"), ["tooltip"].includes(this.variant) && this.$anchor.addEventListener("focusin", this.open, { signal: this.signal });
|
93
102
|
}
|
94
103
|
/** @internal eventlisteners here should implement abort signal */
|
95
104
|
addEventListeners(t) {
|
@@ -100,15 +109,10 @@ const s = (p = class extends S {
|
|
100
109
|
this.abortEventsController.abort();
|
101
110
|
}
|
102
111
|
render() {
|
103
|
-
|
104
|
-
|
105
|
-
<div
|
106
|
-
@toggle=${this._handleToggle}
|
107
|
-
class=${j({ popover: !0, ...p.classMap })}
|
108
|
-
id="root"
|
109
|
-
>
|
112
|
+
return ["popup", "menu"].includes(this.variant) && this.$anchor?.setAttribute("aria-expanded", this.isOpen ? "true" : "false"), m`
|
113
|
+
<div class=${S({ popover: !0, ...h.classMap })} id="root">
|
110
114
|
<slot></slot>
|
111
|
-
${this.arrow ?
|
115
|
+
${this.arrow ? m`<div id="arrow"></div>` : _}
|
112
116
|
</div>
|
113
117
|
`;
|
114
118
|
}
|
@@ -123,54 +127,54 @@ const s = (p = class extends S {
|
|
123
127
|
'[tabindex]:not([tabindex="-1"])'
|
124
128
|
]).length > 0;
|
125
129
|
function e(n, a) {
|
126
|
-
const
|
130
|
+
const p = Array.from(
|
127
131
|
n.querySelectorAll(a.join(", "))
|
128
132
|
), d = Array.from(n.querySelectorAll("*")).map((l) => l.shadowRoot).filter((l) => l !== null);
|
129
133
|
for (const l of d)
|
130
|
-
|
134
|
+
p.push(
|
131
135
|
...e(l, a)
|
132
136
|
);
|
133
|
-
return
|
137
|
+
return p;
|
134
138
|
}
|
135
139
|
}
|
136
|
-
},
|
140
|
+
}, h.styles = [P, L], h.classMap = {}, h);
|
137
141
|
r([
|
138
142
|
u()
|
139
|
-
],
|
143
|
+
], i.prototype, "placement", 2);
|
140
144
|
r([
|
141
145
|
u()
|
142
|
-
],
|
146
|
+
], i.prototype, "variant", 2);
|
143
147
|
r([
|
144
148
|
u()
|
145
|
-
],
|
149
|
+
], i.prototype, "anchor", 2);
|
146
150
|
r([
|
147
151
|
c()
|
148
|
-
],
|
152
|
+
], i.prototype, "isOpen", 2);
|
149
153
|
r([
|
150
154
|
c()
|
151
|
-
],
|
155
|
+
], i.prototype, "offset", 2);
|
152
156
|
r([
|
153
157
|
c()
|
154
|
-
],
|
158
|
+
], i.prototype, "$anchor", 2);
|
155
159
|
r([
|
156
160
|
c()
|
157
|
-
],
|
161
|
+
], i.prototype, "arrow", 2);
|
158
162
|
r([
|
159
163
|
c()
|
160
|
-
],
|
164
|
+
], i.prototype, "triggerEvent", 2);
|
161
165
|
r([
|
162
|
-
|
163
|
-
],
|
166
|
+
A("#arrow")
|
167
|
+
], i.prototype, "$arrow", 2);
|
164
168
|
r([
|
165
169
|
f("isOpen", { afterUpdate: !0 })
|
166
|
-
],
|
170
|
+
], i.prototype, "handleToggleOpen", 2);
|
167
171
|
r([
|
168
172
|
f("$anchor")
|
169
|
-
],
|
173
|
+
], i.prototype, "handleAnchorEl", 1);
|
170
174
|
r([
|
171
175
|
f("anchor")
|
172
|
-
],
|
173
|
-
let
|
176
|
+
], i.prototype, "handleAnchorChange", 2);
|
177
|
+
let z = i;
|
174
178
|
export {
|
175
|
-
|
179
|
+
z as SkfPopoverBase
|
176
180
|
};
|
@@ -37,6 +37,7 @@ export declare class FormBase extends SkfElement {
|
|
37
37
|
/** If true, sets disabled state */
|
38
38
|
set disabled(isDisabled: boolean);
|
39
39
|
get disabled(): boolean;
|
40
|
+
/** If true, sets disabled state */
|
40
41
|
set required(isRequired: boolean);
|
41
42
|
get required(): boolean;
|
42
43
|
set nativeValidation(nativeValidation: boolean);
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { LitElement as c } from "lit";
|
2
|
-
import { property as
|
2
|
+
import { property as l } from "lit/decorators.js";
|
3
3
|
import { SkfElement as u } from "./skf-element.js";
|
4
|
-
var p = Object.defineProperty, _ = Object.getOwnPropertyDescriptor,
|
5
|
-
for (var i = _(t, e), n =
|
6
|
-
(
|
4
|
+
var p = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, o = (d, t, e, r) => {
|
5
|
+
for (var i = _(t, e), n = d.length - 1, h; n >= 0; n--)
|
6
|
+
(h = d[n]) && (i = h(t, e, i) || i);
|
7
7
|
return i && p(t, e, i), i;
|
8
8
|
};
|
9
9
|
const a = class a extends u {
|
@@ -18,17 +18,6 @@ const a = class a extends u {
|
|
18
18
|
disconnectedCallback() {
|
19
19
|
super.disconnectedCallback(), this._internals.form && this._internals.form.removeEventListener("reset", this._dispatchResetEvent);
|
20
20
|
}
|
21
|
-
// @property()
|
22
|
-
// set autocomplete(value: string) {
|
23
|
-
// if (value) {
|
24
|
-
// this.autocomplete = value;
|
25
|
-
// this._internals.ariaAutoComplete = value;
|
26
|
-
// }
|
27
|
-
// }
|
28
|
-
// get autocomplete() {
|
29
|
-
// return this.autocomplete;
|
30
|
-
// }
|
31
|
-
/** If true, sets disabled state */
|
32
21
|
set disabled(t) {
|
33
22
|
this._disabled = t, this._internals.ariaDisabled = String(t);
|
34
23
|
}
|
@@ -96,11 +85,14 @@ const a = class a extends u {
|
|
96
85
|
};
|
97
86
|
a.formAssociated = !0, a.shadowRootOptions = { ...c.shadowRootOptions, delegatesFocus: !0 };
|
98
87
|
let s = a;
|
99
|
-
|
100
|
-
|
88
|
+
o([
|
89
|
+
l({ type: Boolean })
|
90
|
+
], s.prototype, "disabled");
|
91
|
+
o([
|
92
|
+
l({ type: Boolean })
|
101
93
|
], s.prototype, "required");
|
102
|
-
|
103
|
-
|
94
|
+
o([
|
95
|
+
l({ type: Boolean, attribute: "native-validation" })
|
104
96
|
], s.prototype, "nativeValidation");
|
105
97
|
export {
|
106
98
|
s as FormBase
|
@@ -7,9 +7,11 @@ interface ControllerHostProps {
|
|
7
7
|
$anchor?: Element | HTMLElement | null;
|
8
8
|
$popover?: Element | HTMLElement | null;
|
9
9
|
reposition: () => Promise<void>;
|
10
|
+
_toggleOpen: (open: boolean) => void;
|
10
11
|
}
|
11
12
|
export declare class PopoverController implements ReactiveController {
|
12
13
|
host?: ReactiveControllerHost & Partial<ControllerHostProps>;
|
14
|
+
intersectionObserver: IntersectionObserver | undefined;
|
13
15
|
private cleanup;
|
14
16
|
private active;
|
15
17
|
private autoStart;
|
@@ -1,15 +1,14 @@
|
|
1
|
-
import { autoUpdate as
|
2
|
-
class
|
1
|
+
import { autoUpdate as e } from "@floating-ui/dom";
|
2
|
+
class h {
|
3
3
|
constructor(t, o = !0) {
|
4
4
|
this.active = !1, this.autoStart = !0, (this.host = t).addController(this), this.autoStart = o;
|
5
5
|
}
|
6
6
|
hostConnected() {
|
7
|
-
|
8
|
-
this.autoStart && ((t = this.host) == null || t.updateComplete.then(() => {
|
7
|
+
this.autoStart && this.host?.updateComplete.then(() => {
|
9
8
|
this.start();
|
10
|
-
}).catch((
|
11
|
-
console.error(
|
12
|
-
})
|
9
|
+
}).catch((t) => {
|
10
|
+
console.error(t);
|
11
|
+
});
|
13
12
|
}
|
14
13
|
hostDisconnected() {
|
15
14
|
this.stop().catch((t) => {
|
@@ -17,12 +16,10 @@ class c {
|
|
17
16
|
});
|
18
17
|
}
|
19
18
|
start() {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
(r = this.host) != null && r.reposition && this.host.reposition().catch((i) => {
|
25
|
-
console.error(i);
|
19
|
+
const t = this.host?.$anchor, o = this.host?.$popover;
|
20
|
+
!t || !o || this.active || (o.popover = "manual", this.cleanup = e(t, o, () => {
|
21
|
+
this.host?.reposition && this.host.reposition().catch((s) => {
|
22
|
+
console.error(s);
|
26
23
|
});
|
27
24
|
}), this.active = !0);
|
28
25
|
}
|
@@ -35,5 +32,5 @@ class c {
|
|
35
32
|
}
|
36
33
|
}
|
37
34
|
export {
|
38
|
-
|
35
|
+
h as PopoverController
|
39
36
|
};
|
@@ -26,14 +26,14 @@ function w(o, u) {
|
|
26
26
|
}), o.add(n);
|
27
27
|
}
|
28
28
|
function c(n) {
|
29
|
-
if (n
|
29
|
+
if (n ??= r[0], typeof n == "boolean") {
|
30
30
|
n ? o.add(r[0]) : f();
|
31
31
|
return;
|
32
32
|
}
|
33
33
|
i(n), o.has(n) ? o.delete(n) : o.add(n);
|
34
34
|
}
|
35
35
|
function h(n) {
|
36
|
-
return n
|
36
|
+
return n ??= r[0], i(n), o.has(n);
|
37
37
|
}
|
38
38
|
function p(n) {
|
39
39
|
if (typeof n == "boolean")
|
@@ -47,7 +47,7 @@ function w(o, u) {
|
|
47
47
|
i(n), o.add(n);
|
48
48
|
}
|
49
49
|
function g(n) {
|
50
|
-
n
|
50
|
+
n ??= r[0], i(n), o.delete(n);
|
51
51
|
}
|
52
52
|
function i(n) {
|
53
53
|
if (!r.includes(n))
|
@@ -1,15 +1,13 @@
|
|
1
1
|
/**
|
2
|
-
* Generate a unique id based on a string
|
2
|
+
* Generate a unique id based on a string using the Crypto API
|
3
3
|
*
|
4
4
|
* @param str - string to base hash on
|
5
|
-
* @returns string - a unique prefixed id
|
6
|
-
*/
|
7
|
-
export declare function uuid(str: string): string;
|
8
|
-
/**
|
9
|
-
* @describe - cyrb53 - A simple hash function for strings
|
5
|
+
* @returns Promise<string> - a unique prefixed id
|
10
6
|
*
|
11
|
-
* @
|
12
|
-
*
|
13
|
-
*
|
7
|
+
* @usage
|
8
|
+
* ```typescript
|
9
|
+
* const uniqueId = await uuid('my-element-id');
|
10
|
+
* console.log(uniqueId); // skf-uuid-123456789abc
|
11
|
+
* ```
|
14
12
|
*/
|
15
|
-
export declare
|
13
|
+
export declare function uuid(str: string): Promise<string>;
|
@@ -1,14 +1,7 @@
|
|
1
|
-
function r
|
2
|
-
const
|
3
|
-
return `skf-uuid-${
|
1
|
+
async function c(r) {
|
2
|
+
const t = new TextEncoder().encode(r), e = await crypto.subtle.digest("SHA-256", t);
|
3
|
+
return `skf-uuid-${Array.from(new Uint8Array(e)).map((n) => n.toString(16).padStart(2, "0")).join("").slice(0, 12)}`;
|
4
4
|
}
|
5
|
-
const n = (u, i = 0) => {
|
6
|
-
let t = 3735928559 ^ i, h = 1103547991 ^ i;
|
7
|
-
for (let l = 0, a; l < u.length; l++)
|
8
|
-
a = u.charCodeAt(l), t = Math.imul(t ^ a, 2654435761), h = Math.imul(h ^ a, 1597334677);
|
9
|
-
return t = Math.imul(t ^ t >>> 16, 2246822507), t ^= Math.imul(h ^ h >>> 13, 3266489909), h = Math.imul(h ^ h >>> 16, 2246822507), h ^= Math.imul(t ^ t >>> 13, 3266489909), 4294967296 * (2097151 & h) + (t >>> 0);
|
10
|
-
};
|
11
5
|
export {
|
12
|
-
|
13
|
-
r as uuid
|
6
|
+
c as uuid
|
14
7
|
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { LitElement } from 'lit';
|
2
|
-
type UpdateHandler = (property: string, prev?: unknown, next?: unknown) => void
|
2
|
+
type UpdateHandler = (property: string, prev?: unknown, next?: unknown) => void | Promise<void>;
|
3
3
|
type NonUndefined<A> = A extends undefined ? never : A;
|
4
4
|
type UpdateHandlerFunctionKeys<T extends object> = {
|
5
5
|
[K in keyof T]-?: NonUndefined<T[K]> extends UpdateHandler ? K : never;
|
@@ -1 +1 @@
|
|
1
|
-
export declare function Asterisk(label
|
1
|
+
export declare function Asterisk(label: string, className?: string): import("lit").TemplateResult<1>;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { html as r } from "lit";
|
2
|
-
import { ifDefined as
|
3
|
-
function t(
|
2
|
+
import { ifDefined as a } from "lit/directives/if-defined.js";
|
3
|
+
function t(s, i) {
|
4
4
|
return r`
|
5
|
-
<span class="visually-hidden">(${
|
6
|
-
<span aria-hidden="true" class=${
|
5
|
+
<span class="visually-hidden">(${s})</span>
|
6
|
+
<span aria-hidden="true" class=${a(i)} id="asterisk">*</span>
|
7
7
|
`;
|
8
8
|
}
|
9
9
|
export {
|
package/dist/internal/types.d.ts
CHANGED