@nordhealth/components 1.0.0-beta.21 → 1.0.0-beta.24
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 +999 -731
- package/lib/Avatar.js +1 -1
- package/lib/Avatar.js.map +1 -1
- package/lib/Button.js +1 -1
- package/lib/Button.js.map +1 -1
- package/lib/Calendar-72e99fb9.js +13 -0
- package/lib/Calendar-72e99fb9.js.map +1 -0
- package/lib/Calendar.js +1 -1
- package/lib/Card.js +1 -1
- package/lib/Card.js.map +1 -1
- package/lib/Checkbox.js +1 -1
- package/lib/Checkbox.js.map +1 -1
- package/lib/CommandMenu.js +1 -1
- package/lib/CommandMenu.js.map +1 -1
- package/lib/DatePicker.js +1 -1
- package/lib/DatePicker.js.map +1 -1
- package/lib/EventController-d99ebeef.js +2 -0
- package/lib/EventController-d99ebeef.js.map +1 -0
- package/lib/Fieldset.js +1 -1
- package/lib/Fieldset.js.map +1 -1
- package/lib/FormAssociatedMixin-1f97ed66.js +2 -0
- package/lib/FormAssociatedMixin-1f97ed66.js.map +1 -0
- package/lib/Header.js +1 -1
- package/lib/Header.js.map +1 -1
- package/lib/Input.js +1 -1
- package/lib/Input.js.map +1 -1
- package/lib/LightDismissController-a35d0f66.js +2 -0
- package/lib/LightDismissController-a35d0f66.js.map +1 -0
- package/lib/NavItem.js +1 -1
- package/lib/NavItem.js.map +1 -1
- package/lib/Radio.js +1 -1
- package/lib/Radio.js.map +1 -1
- package/lib/Select.js +1 -1
- package/lib/Select.js.map +1 -1
- package/lib/SlotController-683d0e7c.js +2 -0
- package/lib/SlotController-683d0e7c.js.map +1 -0
- package/lib/Textarea.js +1 -1
- package/lib/Textarea.js.map +1 -1
- package/lib/Tooltip.js +1 -1
- package/lib/Tooltip.js.map +1 -1
- package/lib/bundle.js +8 -8
- package/lib/bundle.js.map +1 -1
- package/lib/fsm-50373df9.js +2 -0
- package/lib/fsm-50373df9.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/src/button/Button.d.ts +1 -1
- package/lib/src/common/controllers/EventController.d.ts +14 -0
- package/lib/src/common/controllers/FormDataController.d.ts +1 -1
- package/lib/src/common/controllers/LightDismissController.d.ts +1 -1
- package/lib/src/common/controllers/SlotController.d.ts +1 -1
- package/lib/src/common/controllers/SwipeController.d.ts +3 -5
- package/lib/src/common/fsm.d.ts +2 -0
- package/lib/src/tooltip/Tooltip.d.ts +16 -18
- package/lib/src/tooltip/Tooltip.test.d.ts +1 -0
- package/package.json +12 -3
- package/lib/Calendar-600fd148.js +0 -13
- package/lib/Calendar-600fd148.js.map +0 -1
- package/lib/FormAssociatedMixin-ccae91fd.js +0 -2
- package/lib/FormAssociatedMixin-ccae91fd.js.map +0 -1
- package/lib/LightDismissController-cc5b4bf2.js +0 -2
- package/lib/LightDismissController-cc5b4bf2.js.map +0 -1
- package/lib/SlotController-5bfc47d1.js +0 -2
- package/lib/SlotController-5bfc47d1.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fsm-50373df9.js","sources":["../src/common/fsm.ts"],"sourcesContent":["type MemberUnion<T> = T extends any ? keyof T : never\n\nexport function fsm<TStates extends keyof TTransitions, TTransitions extends Record<TStates, Record<string, TStates>>>(\n config: TTransitions\n) {\n return {\n transition(currentState: TStates, event: MemberUnion<TTransitions[TStates]>) {\n const nextState = config[currentState][event]\n return nextState || currentState\n },\n }\n}\n\nexport type Machine = ReturnType<typeof fsm>\n\nexport type States<T extends Machine | Machine[\"transition\"]> = T extends Machine\n ? Parameters<T[\"transition\"]>[0]\n : T extends Machine[\"transition\"]\n ? Parameters<T>[0]\n : never\n"],"names":["fsm","config","transition","currentState","event"],"mappings":"SAEgBA,EACdC,GAEA,MAAO,CACLC,WAAU,CAACC,EAAuBC,IACdH,EAAOE,GAAcC,IACnBD"}
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{default as Badge}from"./Badge.js";export{default as Button}from"./Button.js";export{default as Card}from"./Card.js";export{default as Input}from"./Input.js";export{default as Icon}from"./Icon.js";export{default as CommandMenu}from"./CommandMenu.js";export{default as CommandMenuAction}from"./CommandMenuAction.js";export{default as Select}from"./Select.js";export{default as Stack}from"./Stack.js";export{default as Spinner}from"./Spinner.js";export{default as Table}from"./Table.js";export{default as VisuallyHidden}from"./VisuallyHidden.js";export{default as Textarea}from"./Textarea.js";export{C as Calendar}from"./Calendar-
|
|
1
|
+
export{default as Badge}from"./Badge.js";export{default as Button}from"./Button.js";export{default as Card}from"./Card.js";export{default as Input}from"./Input.js";export{default as Icon}from"./Icon.js";export{default as CommandMenu}from"./CommandMenu.js";export{default as CommandMenuAction}from"./CommandMenuAction.js";export{default as Select}from"./Select.js";export{default as Stack}from"./Stack.js";export{default as Spinner}from"./Spinner.js";export{default as Table}from"./Table.js";export{default as VisuallyHidden}from"./VisuallyHidden.js";export{default as Textarea}from"./Textarea.js";export{C as Calendar}from"./Calendar-72e99fb9.js";export{default as DatePicker}from"./DatePicker.js";export{default as Checkbox}from"./Checkbox.js";export{default as Tooltip}from"./Tooltip.js";export{default as Fieldset}from"./Fieldset.js";export{default as Radio}from"./Radio.js";export{default as Header}from"./Header.js";export{default as NavGroup}from"./NavGroup.js";export{default as NavItem}from"./NavItem.js";export{default as Navigation}from"./Navigation.js";export{default as Layout}from"./Layout.js";export{default as EmptyState}from"./EmptyState.js";export{default as Banner}from"./Banner.js";export{default as Avatar}from"./Avatar.js";export{default as ProgressBar}from"./ProgressBar.js";import"./query-assigned-elements-37b095c4.js";import"./lit-element-74b6bb4b.js";import"./property-03f59dce.js";import"./Component-9d373ef3.js";import"./if-defined-fe657a02.js";import"./ref-7d028e3a.js";import"./directive-de55b00a.js";import"./EventController-d99ebeef.js";import"./LightDomController-011334da.js";import"./FocusableMixin-ebb67709.js";import"./InputMixin-94d15730.js";import"./SlotController-683d0e7c.js";import"./unsafe-html-989a642b.js";import"./FormAssociatedMixin-1f97ed66.js";import"./events-731d0007.js";import"./FormField-50bd73d5.js";import"./TextField-ece1c786.js";import"./state-70f38ceb.js";import"./number-3a8ef88a.js";import"./class-map-87423405.js";import"./collection-f3631dc8.js";import"./LightDismissController-a35d0f66.js";import"./ShortcutController-93173ff4.js";import"./tinykeys.module-84e6cc41.js";import"./KeyboardController.js";import"./SelectEvent.js";import"./DirectionController-82794ee9.js";import"./dates-ccf5a897.js";import"./calendar-localization.js";import"./month-view.js";import"./DateSelectEvent.js";import"./date-adapter.js";import"./date-localization.js";import"./fsm-50373df9.js";import"./DraftComponentMixin-9e4b7b34.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -14,6 +14,7 @@ declare const Button_base: (new (...args: any[]) => import("../common/mixins/Inp
|
|
|
14
14
|
export default class Button extends Button_base {
|
|
15
15
|
static styles: import("lit").CSSResult[];
|
|
16
16
|
private buttonRef;
|
|
17
|
+
private events;
|
|
17
18
|
private lightDom;
|
|
18
19
|
/**
|
|
19
20
|
* The style variant of the button.
|
|
@@ -53,7 +54,6 @@ export default class Button extends Button_base {
|
|
|
53
54
|
*/
|
|
54
55
|
expand: boolean;
|
|
55
56
|
connectedCallback(): void;
|
|
56
|
-
disconnectedCallback(): void;
|
|
57
57
|
render(): TemplateResult<1>;
|
|
58
58
|
/**
|
|
59
59
|
* We jump through some hoops here to ensure the link is treated correctly when "disabled".
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ReactiveController, ReactiveControllerHost } from "lit";
|
|
2
|
+
interface ShadowRootEventMap {
|
|
3
|
+
slotchange: Event;
|
|
4
|
+
}
|
|
5
|
+
export declare class EventController implements ReactiveController {
|
|
6
|
+
private listeners;
|
|
7
|
+
constructor(host: ReactiveControllerHost);
|
|
8
|
+
hostDisconnected(): void;
|
|
9
|
+
listen<K extends keyof WindowEventMap>(window: Window, type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
10
|
+
listen<K extends keyof DocumentEventMap>(document: Document, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
11
|
+
listen<K extends keyof HTMLElementEventMap>(element: HTMLElement, type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
12
|
+
listen<K extends keyof ShadowRootEventMap>(element: ShadowRoot, type: K, listener: (this: ShadowRoot, ev: ShadowRootEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -6,9 +6,9 @@ declare type FormDataOptions = {
|
|
|
6
6
|
export declare class FormDataController implements ReactiveController {
|
|
7
7
|
private host;
|
|
8
8
|
private options;
|
|
9
|
+
private events;
|
|
9
10
|
constructor(host: ReactiveControllerHost & InputMixinInterface, options: FormDataOptions);
|
|
10
11
|
hostConnected(): void;
|
|
11
|
-
hostDisconnected(): void;
|
|
12
12
|
private handleFormData;
|
|
13
13
|
}
|
|
14
14
|
export {};
|
|
@@ -8,9 +8,9 @@ export declare class LightDismissController implements ReactiveController {
|
|
|
8
8
|
private host;
|
|
9
9
|
private options;
|
|
10
10
|
private shortcut;
|
|
11
|
+
private events;
|
|
11
12
|
constructor(host: ReactiveControllerHost & Element, options: LightDismissOptions);
|
|
12
13
|
hostConnected(): void;
|
|
13
|
-
hostDisconnected(): void;
|
|
14
14
|
private handleEsc;
|
|
15
15
|
private handleClickOut;
|
|
16
16
|
}
|
|
@@ -2,9 +2,9 @@ import { ReactiveController, ReactiveControllerHost } from "lit";
|
|
|
2
2
|
export declare class SlotController implements ReactiveController {
|
|
3
3
|
protected host: ReactiveControllerHost & HTMLElement;
|
|
4
4
|
slotName: string;
|
|
5
|
+
private events;
|
|
5
6
|
constructor(host: ReactiveControllerHost & HTMLElement, slotName?: string);
|
|
6
7
|
hostConnected(): void;
|
|
7
|
-
hostDisconnected(): void;
|
|
8
8
|
get hasContent(): boolean;
|
|
9
9
|
get isEmpty(): boolean;
|
|
10
10
|
get content(): Element | null;
|
|
@@ -13,13 +13,11 @@ declare type SwipeControllerOptions = {
|
|
|
13
13
|
onSwipeEnd: (details: SwipeDetails) => void;
|
|
14
14
|
};
|
|
15
15
|
export declare class SwipeController implements ReactiveController {
|
|
16
|
-
private
|
|
17
|
-
private
|
|
16
|
+
private events;
|
|
17
|
+
private hadFirstUpdate;
|
|
18
18
|
private initialTouchX;
|
|
19
19
|
private initialTouchY;
|
|
20
|
-
private
|
|
21
|
-
private onSwipeEnd;
|
|
22
|
-
matchesGesture: SwipeControllerOptions["matchesGesture"];
|
|
20
|
+
private options;
|
|
23
21
|
constructor(host: ReactiveElement, options: SwipeControllerOptions);
|
|
24
22
|
hostUpdated(): void;
|
|
25
23
|
hostDisconnected(): void;
|
package/lib/src/common/fsm.d.ts
CHANGED
|
@@ -2,4 +2,6 @@ declare type MemberUnion<T> = T extends any ? keyof T : never;
|
|
|
2
2
|
export declare function fsm<TStates extends keyof TTransitions, TTransitions extends Record<TStates, Record<string, TStates>>>(config: TTransitions): {
|
|
3
3
|
transition(currentState: TStates, event: MemberUnion<TTransitions[TStates]>): TStates;
|
|
4
4
|
};
|
|
5
|
+
export declare type Machine = ReturnType<typeof fsm>;
|
|
6
|
+
export declare type States<T extends Machine | Machine["transition"]> = T extends Machine ? Parameters<T["transition"]>[0] : T extends Machine["transition"] ? Parameters<T>[0] : never;
|
|
5
7
|
export {};
|
|
@@ -13,7 +13,9 @@ export default class Tooltip extends LitElement {
|
|
|
13
13
|
static styles: import("lit").CSSResult[];
|
|
14
14
|
static lastOpened?: Tooltip;
|
|
15
15
|
private shortcutSlot;
|
|
16
|
-
private
|
|
16
|
+
private events;
|
|
17
|
+
private currentElement?;
|
|
18
|
+
private timeoutId?;
|
|
17
19
|
/**
|
|
18
20
|
* the proxy element is for cases where the targetElement is a web component,
|
|
19
21
|
* and the WC has a focusable child in its shadow root e.g. a button component.
|
|
@@ -23,9 +25,10 @@ export default class Tooltip extends LitElement {
|
|
|
23
25
|
*/
|
|
24
26
|
private proxy;
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
28
|
+
* The current state of the tooltip, dependent on the state machine
|
|
27
29
|
*/
|
|
28
|
-
|
|
30
|
+
private state;
|
|
31
|
+
private coords;
|
|
29
32
|
/**
|
|
30
33
|
* Control the position of the tooltip component.
|
|
31
34
|
* When set to "none", the tooltip will be shown above
|
|
@@ -44,29 +47,24 @@ export default class Tooltip extends LitElement {
|
|
|
44
47
|
* The delay in milliseconds before the tooltip is opened.
|
|
45
48
|
*/
|
|
46
49
|
delay: number;
|
|
47
|
-
/**
|
|
48
|
-
* Setting and updating the position of the tooltip
|
|
49
|
-
*/
|
|
50
|
-
private updatePosition;
|
|
51
|
-
private handleScroll;
|
|
52
|
-
/**
|
|
53
|
-
* Show and hide the tooltip using inline styles
|
|
54
|
-
*/
|
|
55
|
-
private showTooltip;
|
|
56
|
-
private hideTooltip;
|
|
57
50
|
/**
|
|
58
51
|
* Apply all event listeners
|
|
59
52
|
*/
|
|
60
53
|
connectedCallback(): void;
|
|
61
|
-
/**
|
|
62
|
-
* Remove all the event listeners
|
|
63
|
-
*/
|
|
64
|
-
disconnectedCallback(): void;
|
|
65
54
|
/**
|
|
66
55
|
* Check if the tooltip has an id, warn them if not
|
|
67
56
|
*/
|
|
68
|
-
willUpdate(changedProperties: PropertyValues
|
|
57
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
69
58
|
render(): import("lit-html").TemplateResult<1>;
|
|
59
|
+
private handleTransition;
|
|
60
|
+
/**
|
|
61
|
+
* Setting and updating the position of the tooltip
|
|
62
|
+
*/
|
|
63
|
+
private updatePosition;
|
|
64
|
+
private hideTooltip;
|
|
65
|
+
private reposition;
|
|
66
|
+
private handleShow;
|
|
67
|
+
private handleHide;
|
|
70
68
|
private hideOnEscape;
|
|
71
69
|
private addDescribedBy;
|
|
72
70
|
private removeDescribedBy;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nordhealth/components",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.24",
|
|
4
4
|
"description": "This package includes Nord Design System web components",
|
|
5
5
|
"author": "Nordhealth <support@nordhealth.design>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@custom-elements-manifest/analyzer": "^0.5.5",
|
|
39
|
-
"@nordhealth/css": "^1.0.0
|
|
39
|
+
"@nordhealth/css": "^1.0.0",
|
|
40
40
|
"@nordhealth/fonts": "^2.0.13",
|
|
41
41
|
"@nordhealth/themes": "^5.1.1",
|
|
42
42
|
"@nordhealth/tokens": "^4.2.0",
|
|
@@ -78,6 +78,11 @@
|
|
|
78
78
|
"demo/index.html"
|
|
79
79
|
],
|
|
80
80
|
"parser": "@typescript-eslint/parser",
|
|
81
|
+
"parserOptions": {
|
|
82
|
+
"project": [
|
|
83
|
+
"packages/components/tsconfig.json"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
81
86
|
"extends": [
|
|
82
87
|
"@open-wc/eslint-config",
|
|
83
88
|
"eslint-config-prettier"
|
|
@@ -138,6 +143,10 @@
|
|
|
138
143
|
"no-use-before-define": "off",
|
|
139
144
|
"@typescript-eslint/no-use-before-define": [
|
|
140
145
|
"error"
|
|
146
|
+
],
|
|
147
|
+
"default-case": "off",
|
|
148
|
+
"@typescript-eslint/switch-exhaustiveness-check": [
|
|
149
|
+
"error"
|
|
141
150
|
]
|
|
142
151
|
},
|
|
143
152
|
"overrides": [
|
|
@@ -159,5 +168,5 @@
|
|
|
159
168
|
}
|
|
160
169
|
]
|
|
161
170
|
},
|
|
162
|
-
"gitHead": "
|
|
171
|
+
"gitHead": "6362d878d4b238cb35cf7a55f15d936c8cf020f4"
|
|
163
172
|
}
|
package/lib/Calendar-600fd148.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import{_ as e,n as t}from"./query-assigned-elements-37b095c4.js";import{r as a,s as n,$ as i}from"./lit-element-74b6bb4b.js";import{e as o}from"./property-03f59dce.js";import{t as s}from"./state-70f38ceb.js";import{c as r,r as l}from"./number-3a8ef88a.js";import{o as d}from"./tinykeys.module-84e6cc41.js";import"./Button.js";import"./VisuallyHidden.js";import c from"./Icon.js";import{D as h}from"./DirectionController-82794ee9.js";import{i as u,p as v,a as p,s as f,e as m,b as y,c as g,d as b,f as w,g as x,h as D,j as z}from"./dates-ccf5a897.js";import k from"./calendar-localization.js";import{monthView as F}from"./month-view.js";import{DateSelectEvent as S}from"./DateSelectEvent.js";import{s as $}from"./Component-9d373ef3.js";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright 2017 Google LLC
|
|
5
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* @license
|
|
9
|
-
* Copyright 2017 Google LLC
|
|
10
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
11
|
-
*/
|
|
12
|
-
function M(e,t){return(({finisher:e,descriptor:t})=>(a,n)=>{var i;if(void 0===n){const n=null!==(i=a.originalKey)&&void 0!==i?i:a.key,o=null!=t?{kind:"method",placement:"prototype",key:n,descriptor:t(a.key)}:{...a,key:n};return null!=e&&(o.finisher=function(t){e(t,n)}),o}{const i=a.constructor;void 0!==t&&Object.defineProperty(a,n,t(n)),null==e||e(i,n)}})({descriptor:a=>{const n={get(){var t,a;return null!==(a=null===(t=this.renderRoot)||void 0===t?void 0:t.querySelector(e))&&void 0!==a?a:null},enumerable:!0,configurable:!0};if(t){const t="symbol"==typeof a?Symbol():"__"+a;n.get=function(){var a,n;return void 0===this[t]&&(this[t]=null!==(n=null===(a=this.renderRoot)||void 0===a?void 0:a.querySelector(e))&&void 0!==n?n:null),this[t]}}return n}})}var Y=Object.freeze({__proto__:null,default:'<svg viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M105 57.4 47.6 2.8a10.566 10.566 0 1 0-14.56 15.316l51.968 49.35a3.486 3.486 0 0 1 0 5.068l-51.968 49.35a10.502 10.502 0 0 0 14.462 15.232l57.638-54.74A17.584 17.584 0 0 0 105 57.4z"/></svg>',title:"arrow-right-small",tags:"nordicon arrow right small caret pointing triangle chevron"});var j=Object.freeze({__proto__:null,default:'<svg viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M99.736 140a10.486 10.486 0 0 1-7.238-2.884L35 82.6a17.598 17.598 0 0 1-.14-24.976l57.638-54.74a10.502 10.502 0 1 1 14.462 15.232l-51.968 49.35a3.486 3.486 0 0 0 0 5.068l51.968 49.35A10.5 10.5 0 0 1 99.736 140z"/></svg>',title:"arrow-left-small",tags:"nordicon arrow left small caret pointing triangle chevron"});var L=Object.freeze({__proto__:null,default:'<svg viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M70 110.236a17.332 17.332 0 0 1-12.306-5.096L2.884 47.502A10.502 10.502 0 1 1 18.116 33.04l49.35 51.968a3.486 3.486 0 0 0 5.068 0l49.35-51.968a10.502 10.502 0 1 1 15.232 14.462L82.6 105a17.766 17.766 0 0 1-12.6 5.236z"/></svg>',title:"arrow-down-small",tags:"nordicon arrow down small caret pointing triangle chevron"});const T=e=>e.preventDefault();class E{constructor(e,t){var a;this.attached=!1,this.initialTouchX=0,this.initialTouchY=0,this.handleTouchStart=e=>{const[{pageX:t,pageY:a}]=e.changedTouches;this.initialTouchX=t,this.initialTouchY=a},this.handleTouchEnd=e=>{const[{pageX:t,pageY:a}]=e.changedTouches,n=t-this.initialTouchX,i=a-this.initialTouchY,o={initialX:this.initialTouchX,initialY:this.initialTouchY,pageX:t,pageY:a,distX:n,distY:i};this.matchesGesture(o)&&(e.preventDefault(),this.onSwipeEnd(o))},this.host=e,e.addController(this),this.target=null!==(a=null==t?void 0:t.target)&&void 0!==a?a:()=>e,this.matchesGesture=t.matchesGesture,this.onSwipeEnd=t.onSwipeEnd}hostUpdated(){if(!this.attached){this.attached=!0;const e=this.target();e.addEventListener("touchstart",this.handleTouchStart),e.addEventListener("touchmove",T),e.addEventListener("touchend",this.handleTouchEnd)}}hostDisconnected(){this.attached=!1;const e=this.target();e.removeEventListener("touchstart",this.handleTouchStart),e.removeEventListener("touchmove",T),e.removeEventListener("touchend",this.handleTouchEnd)}}const O=({distX:e,distY:t})=>Math.abs(e)>=70&&Math.abs(t)<=70,_=({distX:e,distY:t})=>Math.abs(t)>=70&&Math.abs(e)<=70&&t>0,I=a`:host{font-feature-settings:var(--n-font-features-reduced)}.n-calendar{-webkit-user-select:none;user-select:none;background:var(--n-color-surface);box-shadow:var(--n-calendar-box-shadow,var(--n-box-shadow-popout));border-radius:var(--n-border-radius-s);max-inline-size:310px;min-inline-size:290px;padding:var(--n-calendar-padding,16px 16px 20px)}@media (max-width:35.9375em){.n-calendar{max-inline-size:100%}}.n-calendar-table{border-collapse:collapse;border-spacing:0;color:var(--n-color-text);font-size:var(--n-font-size-m);font-weight:var(--n-font-weight);line-height:var(--n-date-picker-line-height);text-align:center;inline-size:100%}.n-calendar-table-header{font-size:var(--n-font-size-s);font-weight:var(--n-font-weight-active);letter-spacing:1px;line-height:var(--n-date-picker-line-height);padding-block-end:8px;text-decoration:none;text-transform:uppercase}.n-calendar-cell{text-align:center}.n-calendar-day{-moz-appearance:none;-webkit-appearance:none;appearance:none;background:0 0;border:0;border-radius:var(--n-border-radius-s);color:var(--n-color-text);cursor:pointer;display:inline-block;font-family:var(--n-font-family);font-size:var(--n-font-size-m);font-variant-numeric:tabular-nums;font-weight:var(--n-font-weight);block-size:36px;padding:0 0 1px;position:relative;text-align:center;vertical-align:middle;inline-size:36px;z-index:1}.n-calendar-day[aria-current=date]{box-shadow:0 0 0 1px var(--n-color-accent);color:var(--n-color-text-link);position:relative;z-index:200}.n-calendar-day:hover{background:var(--n-color-active)}.n-calendar-day:focus,.n-calendar-day[aria-pressed=true]{background:var(--n-color-accent);box-shadow:none;color:var(--n-color-text-on-accent);outline:0}.n-calendar-day:active{background:var(--n-color-accent);box-shadow:none!important;color:var(--n-color-text-on-accent);z-index:200}.n-calendar-day:focus{box-shadow:0 0 5px var(--n-color-accent);z-index:200}.n-calendar-day:not(.is-month){box-shadow:none}.n-calendar-day:not(.is-month),.n-calendar-day[aria-disabled=true]{background:0 0;color:var(--n-color-text-weakest);cursor:default}.n-calendar-day[aria-disabled=true][aria-current=date]{box-shadow:0 0 0 1px var(--n-color-accent)}.n-calendar-day[aria-disabled=true][aria-current=date]:focus{box-shadow:0 0 5px var(--n-color-accent);background:var(--n-color-accent);color:var(--n-color-text-on-accent)}.n-calendar-day[aria-disabled=true]:not([aria-current=date])::before{display:none}.n-calendar-day.is-outside{background:0 0;box-shadow:none;color:var(--n-color-text-weakest);cursor:default;pointer-events:none}.n-calendar-day.is-outside::before{display:none}.n-calendar-header{align-items:center;display:flex;justify-content:space-between;margin-block-end:16px;inline-size:100%}.n-calendar-nav{white-space:nowrap}.n-calendar-nav nord-button{--n-button-padding-x:11px;margin-inline-start:calc(var(--n-space-s)/ 2)}.n-calendar-select{display:inline-flex;margin-block-start:4px;position:relative;line-height:var(--n-line-height-heading)}.n-calendar-select span{margin-inline-end:var(--n-space-s)}.n-calendar-select select{cursor:pointer;font-size:var(--n-font-size-l);block-size:100%;inset-inline-start:0;opacity:0;position:absolute;inset-block-start:0;inline-size:100%;z-index:2}.n-calendar-select select:focus+.n-calendar-select-label{box-shadow:0 0 0 2px var(--n-color-accent)}.n-calendar-select-label{align-items:center;border-radius:var(--n-border-radius-s);color:var(--n-color-text);display:flex;font-size:var(--n-font-size-xl);font-weight:var(--n-font-weight-active);line-height:var(--n-date-picker-line-height);padding:0 4px 0 8px;pointer-events:none;position:relative;inline-size:100%;z-index:1}`;c.registerIcon(Y),c.registerIcon(j),c.registerIcon(L);const N=e=>t=>{t.preventDefault(),e(t)},X=()=>!1;let A=class extends n{constructor(){super(...arguments),this.dialogLabelId="dialog-header",this.direction=new h(this),this.swipe=new E(this,{matchesGesture:O,onSwipeEnd:({distX:e})=>this.addMonths(e<0?1:-1)}),this.shortcuts=d({ArrowRight:N((()=>this.addDays(this.direction.isLTR?1:-1))),ArrowLeft:N((()=>this.addDays(this.direction.isLTR?-1:1))),ArrowDown:N((()=>this.addDays(7))),ArrowUp:N((()=>this.addDays(-7))),Home:N((()=>this.startOfWeek())),End:N((()=>this.endOfWeek())),PageUp:N((()=>this.addMonths(-1))),PageDown:N((()=>this.addMonths(1))),"Shift+PageUp":N((()=>this.addYears(-1))),"Shift+PageDown":N((()=>this.addYears(1)))}),this.localization=k,this.value="",this.firstDayOfWeek=1,this.min="",this.max="",this.isDateDisabled=X,this.activeFocus=!1,this.focusedDay=new Date,this.handleDaySelect=e=>{const t=u(e,v(this.min),v(this.max)),a=!this.isDateDisabled(e);t&&a&&(this.value=p(e),this.dispatchEvent(new S("change",e)))},this.handleMonthSelect=e=>{this.setMonth(parseInt(e.target.value,10))},this.handleYearSelect=e=>{this.setYear(parseInt(e.target.value,10))},this.handleNextMonthClick=e=>{e.preventDefault(),this.addMonths(1)},this.handlePreviousMonthClick=e=>{e.preventDefault(),this.addMonths(-1)},this.enableActiveFocus=()=>{this.activeFocus=!0},this.disableActiveFocus=()=>{this.activeFocus=!1}}focus(e){var t;const a=null!==(t=null==e?void 0:e.target)&&void 0!==t?t:"day";"day"===a?this.focusedDayNode.focus():"month"===a&&this.monthSelectNode.focus()}willUpdate(e){e.has("value")&&this.setFocusedDay(v(this.value)||new Date),e.has("localization")&&this.createDateFormatter()}updated(e){e.has("focusedDay")&&this.activeFocus&&this.focusedDayNode.focus()}render(){const e=v(this.value),t=this.focusedDay.getMonth(),a=this.focusedDay.getFullYear(),n=v(this.min),o=v(this.max),s=n?f(n):void 0,d=o?m(o):void 0,c=(e||this.focusedDay).getFullYear(),h=n?n.getFullYear():c-10,p=o?o.getFullYear():c+10;return i`<div class="n-calendar"><div class="n-calendar-header"><div><nord-visually-hidden><h2 id="${this.dialogLabelId}" aria-live="polite" aria-atomic="true">${this.localization.monthNames[t]}, ${this.focusedDay.getFullYear()}</h2></nord-visually-hidden><div class="n-calendar-select"><select aria-label="${this.localization.monthSelectLabel}" class="n-calendar-select-month" @input="${this.handleMonthSelect}">${this.localization.monthNames.map(((e,n)=>i`<option key="${e}" value="${n}" ?selected="${n===t}" ?disabled="${!u(new Date(a,n,1),s,d)}">${e}</option>`))}</select><div class="n-calendar-select-label" aria-hidden="true"><span>${this.localization.monthNamesShort[t]}</span><nord-icon color="var(--n-color-icon)" name="arrow-down-small" size="xs"></nord-icon></div></div><div class="n-calendar-select"><select aria-label="${this.localization.yearSelectLabel}" class="n-calendar-select-year" @input="${this.handleYearSelect}">${r(l(h,p),(e=>e),(e=>i`<option key="${e}" ?selected="${e===a}">${e}</option>`))}</select><div class="n-calendar-select-label" aria-hidden="true"><span>${this.focusedDay.getFullYear()}</span><nord-icon color="var(--n-color-icon)" name="arrow-down-small" size="xs"></nord-icon></div></div></div><div class="n-calendar-nav"><nord-button class="n-calendar-prev" @click="${this.handlePreviousMonthClick}" ?disabled="${y(n,this.focusedDay)}" type="button"><nord-visually-hidden>${this.localization.prevMonthLabel}</nord-visually-hidden><nord-icon color="var(--n-color-icon)" name="${this.direction.isLTR?"arrow-left-small":"arrow-right-small"}" size="s"></nord-icon></nord-button><nord-button class="n-calendar-next" @click="${this.handleNextMonthClick}" ?disabled="${y(o,this.focusedDay)}" type="button"><nord-visually-hidden>${this.localization.nextMonthLabel}</nord-visually-hidden><nord-icon color="var(--n-color-icon)" name="${this.direction.isLTR?"arrow-right-small":"arrow-left-small"}" size="s"></nord-icon></nord-button></div></div>${F({onFocusOut:this.disableActiveFocus,onFocusIn:this.enableActiveFocus,dateFormatter:this.dateFormatShort,selectedDate:e,focusedDate:this.focusedDay,onDateSelect:this.handleDaySelect,onKeyboardNavigation:this.shortcuts,labelledById:this.dialogLabelId,localization:this.localization,firstDayOfWeek:this.firstDayOfWeek,min:n,max:o,isDateDisabled:this.isDateDisabled})}</div>`}createDateFormatter(){this.dateFormatShort=new Intl.DateTimeFormat(this.localization.locale,{day:"numeric",month:"long"})}addDays(e){this.setFocusedDay(g(this.focusedDay,e))}addMonths(e){this.setMonth(this.focusedDay.getMonth()+e)}addYears(e){this.setYear(this.focusedDay.getFullYear()+e)}startOfWeek(){this.setFocusedDay(b(this.focusedDay,this.firstDayOfWeek))}endOfWeek(){this.setFocusedDay(w(this.focusedDay,this.firstDayOfWeek))}setMonth(e){const t=x(f(this.focusedDay),e),a=m(t),n=x(this.focusedDay,e);this.setFocusedDay(D(n,t,a))}setYear(e){const t=z(f(this.focusedDay),e),a=m(t),n=z(this.focusedDay,e);this.setFocusedDay(D(n,t,a))}setFocusedDay(e){this.focusedDay=D(e,v(this.min),v(this.max)),this.dispatchEvent(new S("nord-focus-date",this.focusedDay))}};A.styles=[$,I],e([M(".n-calendar-select-month",!0)],A.prototype,"monthSelectNode",void 0),e([M('button[tabindex="0"]')],A.prototype,"focusedDayNode",void 0),e([o({attribute:!1})],A.prototype,"localization",void 0),e([o()],A.prototype,"value",void 0),e([o({type:Number})],A.prototype,"firstDayOfWeek",void 0),e([o()],A.prototype,"min",void 0),e([o()],A.prototype,"max",void 0),e([o({attribute:!1})],A.prototype,"isDateDisabled",void 0),e([s()],A.prototype,"activeFocus",void 0),e([s()],A.prototype,"focusedDay",void 0),A=e([t("nord-calendar")],A);var C=A;export{C,E as S,M as a,_ as i};
|
|
13
|
-
//# sourceMappingURL=Calendar-600fd148.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar-600fd148.js","sources":["../node_modules/@lit/reactive-element/decorators/query.js","../node_modules/@lit/reactive-element/decorators/base.js","../../icons/lib/assets/arrow-right-small.js","../../icons/lib/assets/arrow-left-small.js","../../icons/lib/assets/arrow-down-small.js","../src/common/controllers/SwipeController.ts","../src/calendar/Calendar.ts"],"sourcesContent":["import{decorateProperty as o}from\"./base.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */function i(i,n){return o({descriptor:o=>{const t={get(){var o,n;return null!==(n=null===(o=this.renderRoot)||void 0===o?void 0:o.querySelector(i))&&void 0!==n?n:null},enumerable:!0,configurable:!0};if(n){const n=\"symbol\"==typeof o?Symbol():\"__\"+o;t.get=function(){var o,t;return void 0===this[n]&&(this[n]=null!==(t=null===(o=this.renderRoot)||void 0===o?void 0:o.querySelector(i))&&void 0!==t?t:null),this[n]}}return t}})}export{i as query};\n//# sourceMappingURL=query.js.map\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst e=(e,t,o)=>{Object.defineProperty(t,o,e)},t=(e,t)=>({kind:\"method\",placement:\"prototype\",key:t.key,descriptor:e}),o=({finisher:e,descriptor:t})=>(o,n)=>{var r;if(void 0===n){const n=null!==(r=o.originalKey)&&void 0!==r?r:o.key,i=null!=t?{kind:\"method\",placement:\"prototype\",key:n,descriptor:t(o.key)}:{...o,key:n};return null!=e&&(i.finisher=function(t){e(t,n)}),i}{const r=o.constructor;void 0!==t&&Object.defineProperty(o,n,t(n)),null==e||e(r,n)}};export{o as decorateProperty,e as legacyPrototypeMethod,t as standardPrototypeMethod};\n//# sourceMappingURL=base.js.map\n","export default '<svg viewBox=\"0 0 140 140\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"currentColor\" d=\"M105 57.4 47.6 2.8a10.566 10.566 0 1 0-14.56 15.316l51.968 49.35a3.486 3.486 0 0 1 0 5.068l-51.968 49.35a10.502 10.502 0 0 0 14.462 15.232l57.638-54.74A17.584 17.584 0 0 0 105 57.4z\"/></svg>'\nexport const title = \"arrow-right-small\"\nexport const tags = \"nordicon arrow right small caret pointing triangle chevron\"\n","export default '<svg viewBox=\"0 0 140 140\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"currentColor\" d=\"M99.736 140a10.486 10.486 0 0 1-7.238-2.884L35 82.6a17.598 17.598 0 0 1-.14-24.976l57.638-54.74a10.502 10.502 0 1 1 14.462 15.232l-51.968 49.35a3.486 3.486 0 0 0 0 5.068l51.968 49.35A10.5 10.5 0 0 1 99.736 140z\"/></svg>'\nexport const title = \"arrow-left-small\"\nexport const tags = \"nordicon arrow left small caret pointing triangle chevron\"\n","export default '<svg viewBox=\"0 0 140 140\" xmlns=\"http://www.w3.org/2000/svg\"><path fill=\"currentColor\" d=\"M70 110.236a17.332 17.332 0 0 1-12.306-5.096L2.884 47.502A10.502 10.502 0 1 1 18.116 33.04l49.35 51.968a3.486 3.486 0 0 0 5.068 0l49.35-51.968a10.502 10.502 0 1 1 15.232 14.462L82.6 105a17.766 17.766 0 0 1-12.6 5.236z\"/></svg>'\nexport const title = \"arrow-down-small\"\nexport const tags = \"nordicon arrow down small caret pointing triangle chevron\"\n","import { ReactiveController, ReactiveElement } from \"lit\"\n\nexport type SwipeDetails = {\n initialX: number\n initialY: number\n pageX: number\n pageY: number\n distX: number\n distY: number\n}\n\nconst preventDefault = (e: Event) => e.preventDefault()\n\ntype SwipeControllerOptions = {\n target?: () => HTMLElement\n matchesGesture: (details: SwipeDetails) => boolean\n onSwipeEnd: (details: SwipeDetails) => void\n}\n\nexport class SwipeController implements ReactiveController {\n private host: ReactiveElement\n private attached = false\n\n private initialTouchX: number = 0\n private initialTouchY: number = 0\n private target: () => HTMLElement\n private onSwipeEnd: SwipeControllerOptions[\"onSwipeEnd\"]\n matchesGesture: SwipeControllerOptions[\"matchesGesture\"]\n\n constructor(host: ReactiveElement, options: SwipeControllerOptions) {\n this.host = host\n host.addController(this)\n this.target = options?.target ?? (() => host)\n this.matchesGesture = options.matchesGesture\n this.onSwipeEnd = options.onSwipeEnd\n }\n\n hostUpdated() {\n if (!this.attached) {\n this.attached = true\n\n const target = this.target()\n target.addEventListener(\"touchstart\", this.handleTouchStart)\n target.addEventListener(\"touchmove\", preventDefault)\n target.addEventListener(\"touchend\", this.handleTouchEnd)\n }\n }\n\n hostDisconnected() {\n this.attached = false\n\n const target = this.target()\n target.removeEventListener(\"touchstart\", this.handleTouchStart)\n target.removeEventListener(\"touchmove\", preventDefault)\n target.removeEventListener(\"touchend\", this.handleTouchEnd)\n }\n\n private handleTouchStart = (event: TouchEvent) => {\n const [{ pageX, pageY }] = event.changedTouches\n this.initialTouchX = pageX\n this.initialTouchY = pageY\n }\n\n private handleTouchEnd = (event: TouchEvent) => {\n const [{ pageX, pageY }] = event.changedTouches\n\n const distX = pageX - this.initialTouchX\n const distY = pageY - this.initialTouchY\n const details = { initialX: this.initialTouchX, initialY: this.initialTouchY, pageX, pageY, distX, distY }\n\n if (this.matchesGesture(details)) {\n event.preventDefault()\n this.onSwipeEnd(details)\n }\n }\n}\n\nconst THRESHOLD = 70\n\nexport const isHorizontalSwipe = ({ distX, distY }: SwipeDetails) =>\n Math.abs(distX) >= THRESHOLD && Math.abs(distY) <= THRESHOLD\n\nexport const isDownwardsSwipe = ({ distX, distY }: SwipeDetails) =>\n Math.abs(distY) >= THRESHOLD && Math.abs(distX) <= THRESHOLD && distY > 0\n","import { html, LitElement, PropertyValues } from \"lit\"\nimport { customElement, property, query, state } from \"lit/decorators.js\"\nimport { repeat } from \"lit/directives/repeat.js\"\nimport { createKeybindingsHandler } from \"tinykeys\"\nimport * as arrowRightIcon from \"@nordhealth/icons/lib/assets/arrow-right-small.js\"\nimport * as arrowLeftIcon from \"@nordhealth/icons/lib/assets/arrow-left-small.js\"\nimport * as arrowDownIcon from \"@nordhealth/icons/lib/assets/arrow-down-small.js\"\n\nimport \"../button/Button.js\"\nimport \"../visually-hidden/VisuallyHidden.js\"\nimport Icon from \"../icon/Icon.js\"\n\nimport { isHorizontalSwipe, SwipeController } from \"../common/controllers/SwipeController.js\"\nimport { DirectionController } from \"../common/controllers/DirectionController.js\"\nimport { range } from \"../common/number.js\"\nimport {\n addDays,\n clamp,\n DaysOfWeek,\n endOfMonth,\n endOfWeek,\n inRange,\n isEqualMonth,\n parseISODate,\n printISODate,\n setMonth,\n setYear,\n startOfMonth,\n startOfWeek,\n} from \"../common/dates.js\"\n\nimport localization, { CalendarLocalizedText } from \"./calendar-localization.js\"\nimport { monthView } from \"./month-view.js\"\nimport { DateSelectEvent } from \"./DateSelectEvent.js\"\nimport componentStyle from \"../common/styles/Component.css\"\nimport style from \"./Calendar.css\"\n\nexport type DateDisabledPredicate = (date: Date) => boolean\n\nIcon.registerIcon(arrowRightIcon)\nIcon.registerIcon(arrowLeftIcon)\nIcon.registerIcon(arrowDownIcon)\n\nconst preventDefault = (fn: EventListener) => (e: Event) => {\n e.preventDefault()\n fn(e)\n}\n\nconst isDateDisabled = () => false\n\n/**\n * Calendar allows user to pick a date. It comes with built-in\n * functionality that allows you to set a minimum and a maximum allowed date.\n * Please note that the date must be passed in ISO-8601 format.\n *\n * @status ready\n * @category list\n * @fires {DateSelectEvent} change - Dispatched when a date is selected and the value changes.\n * @fires {DateSelectEvent} nord-focus-date - Dispatched when the calendar's focused date changes.\n */\n@customElement(\"nord-calendar\")\nexport default class Calendar extends LitElement {\n static styles = [componentStyle, style]\n\n private dialogLabelId = \"dialog-header\"\n\n @query(\".n-calendar-select-month\", true) private monthSelectNode!: HTMLElement\n @query(`button[tabindex=\"0\"]`) private focusedDayNode!: HTMLButtonElement\n\n private direction = new DirectionController(this)\n private swipe = new SwipeController(this, {\n matchesGesture: isHorizontalSwipe,\n onSwipeEnd: ({ distX }) => this.addMonths(distX < 0 ? 1 : -1),\n })\n\n private shortcuts = createKeybindingsHandler({\n ArrowRight: preventDefault(() => this.addDays(this.direction.isLTR ? 1 : -1)),\n ArrowLeft: preventDefault(() => this.addDays(this.direction.isLTR ? -1 : 1)),\n ArrowDown: preventDefault(() => this.addDays(7)),\n ArrowUp: preventDefault(() => this.addDays(-7)),\n Home: preventDefault(() => this.startOfWeek()),\n End: preventDefault(() => this.endOfWeek()),\n PageUp: preventDefault(() => this.addMonths(-1)),\n PageDown: preventDefault(() => this.addMonths(1)),\n \"Shift+PageUp\": preventDefault(() => this.addYears(-1)),\n \"Shift+PageDown\": preventDefault(() => this.addYears(1)),\n })\n\n /**\n * Whilst dateAdapter is used for handling the formatting/parsing dates in the input,\n * these are used to format dates exclusively for the benefit of screen readers.\n *\n * We prefer DateTimeFormat over date.toLocaleDateString, as the former has\n * better performance when formatting large number of dates. See:\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString#Performance\n */\n private dateFormatShort!: Intl.DateTimeFormat\n\n @property({ attribute: false }) localization: CalendarLocalizedText = localization\n\n /**\n * The selected date on the calendar. Must be in IS0-8601 format: YYYY-MM-DD.\n */\n @property() value: string = \"\"\n\n /**\n * Which day is considered first day of the week? `0` for Sunday, `1` for Monday, etc.\n * Default is Monday.\n */\n @property({ type: Number }) firstDayOfWeek: DaysOfWeek = DaysOfWeek.Monday\n\n /**\n * Minimum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD.\n * This setting can be used alone or together with the max property.\n */\n @property() min: string = \"\"\n\n /**\n * Maximum date allowed to be picked. Must be in IS0-8601 format: YYYY-MM-DD.\n * This setting can be used alone or together with the min property.\n */\n @property() max: string = \"\"\n\n /**\n * Controls which days are disabled and therefore disallowed.\n * For example, this can be used to disallow selection of weekends.\n */\n @property({ attribute: false }) isDateDisabled: DateDisabledPredicate = isDateDisabled\n\n @state() private activeFocus = false\n @state() private focusedDay = new Date()\n\n /**\n * Programmatically move focus to the calendar.\n * @param options An object which controls aspects of the focusing process.\n */\n focus(options?: FocusOptions & { target: \"day\" | \"month\" }) {\n const target = options?.target ?? \"day\"\n\n if (target === \"day\") {\n this.focusedDayNode.focus()\n } else if (target === \"month\") {\n this.monthSelectNode.focus()\n }\n }\n\n willUpdate(changedProperties: PropertyValues<this>) {\n if (changedProperties.has(\"value\")) {\n this.setFocusedDay(parseISODate(this.value) || new Date())\n }\n if (changedProperties.has(\"localization\")) {\n this.createDateFormatter()\n }\n }\n\n protected updated(changedProperties: PropertyValues<this>): void {\n // @ts-expect-error focusedDay is private so TS complains, but we don't want to loosen the param type\n if (changedProperties.has(\"focusedDay\") && this.activeFocus) {\n this.focusedDayNode.focus()\n }\n }\n\n render() {\n const valueAsDate = parseISODate(this.value)\n const focusedMonth = this.focusedDay.getMonth()\n const focusedYear = this.focusedDay.getFullYear()\n\n const minDate = parseISODate(this.min)\n const maxDate = parseISODate(this.max)\n const minDateStartOfMonth = minDate ? startOfMonth(minDate) : undefined\n const maxDateEndOfMonth = maxDate ? endOfMonth(maxDate) : undefined\n\n const selectedYear = (valueAsDate || this.focusedDay).getFullYear()\n const minYear = minDate ? minDate.getFullYear() : selectedYear - 10\n const maxYear = maxDate ? maxDate.getFullYear() : selectedYear + 10\n\n return html`\n <div class=\"n-calendar\">\n <div class=\"n-calendar-header\">\n <div>\n <nord-visually-hidden>\n <h2 id=${this.dialogLabelId} aria-live=\"polite\" aria-atomic=\"true\">\n ${this.localization.monthNames[focusedMonth]}, ${this.focusedDay.getFullYear()}\n </h2>\n </nord-visually-hidden>\n\n <div class=\"n-calendar-select\">\n <select\n aria-label=${this.localization.monthSelectLabel}\n class=\"n-calendar-select-month\"\n @input=${this.handleMonthSelect}\n >\n ${this.localization.monthNames.map(\n (month, i) =>\n html`<option\n key=${month}\n value=${i}\n ?selected=${i === focusedMonth}\n ?disabled=${!inRange(new Date(focusedYear, i, 1), minDateStartOfMonth, maxDateEndOfMonth)}\n >\n ${month}\n </option>`\n )}\n </select>\n <div class=\"n-calendar-select-label\" aria-hidden=\"true\">\n <span>${this.localization.monthNamesShort[focusedMonth]}</span>\n <nord-icon color=\"var(--n-color-icon)\" name=\"arrow-down-small\" size=\"xs\"></nord-icon>\n </div>\n </div>\n\n <div class=\"n-calendar-select\">\n <select\n aria-label=${this.localization.yearSelectLabel}\n class=\"n-calendar-select-year\"\n @input=${this.handleYearSelect}\n >\n ${repeat(\n range(minYear, maxYear),\n year => year,\n year => html`<option key=${year} ?selected=${year === focusedYear}>${year}</option>`\n )}\n </select>\n <div class=\"n-calendar-select-label\" aria-hidden=\"true\">\n <span>${this.focusedDay.getFullYear()}</span>\n <nord-icon color=\"var(--n-color-icon)\" name=\"arrow-down-small\" size=\"xs\"></nord-icon>\n </div>\n </div>\n </div>\n\n <div class=\"n-calendar-nav\">\n <nord-button\n class=\"n-calendar-prev\"\n @click=${this.handlePreviousMonthClick}\n ?disabled=${isEqualMonth(minDate, this.focusedDay)}\n type=\"button\"\n >\n <nord-visually-hidden>${this.localization.prevMonthLabel}</nord-visually-hidden>\n <nord-icon\n color=\"var(--n-color-icon)\"\n name=${this.direction.isLTR ? \"arrow-left-small\" : \"arrow-right-small\"}\n size=\"s\"\n ></nord-icon>\n </nord-button>\n\n <nord-button\n class=\"n-calendar-next\"\n @click=${this.handleNextMonthClick}\n ?disabled=${isEqualMonth(maxDate, this.focusedDay)}\n type=\"button\"\n >\n <nord-visually-hidden>${this.localization.nextMonthLabel}</nord-visually-hidden>\n <nord-icon\n color=\"var(--n-color-icon)\"\n name=${this.direction.isLTR ? \"arrow-right-small\" : \"arrow-left-small\"}\n size=\"s\"\n ></nord-icon>\n </nord-button>\n </div>\n </div>\n\n ${monthView({\n onFocusOut: this.disableActiveFocus,\n onFocusIn: this.enableActiveFocus,\n dateFormatter: this.dateFormatShort,\n selectedDate: valueAsDate,\n focusedDate: this.focusedDay,\n onDateSelect: this.handleDaySelect,\n onKeyboardNavigation: this.shortcuts,\n labelledById: this.dialogLabelId,\n localization: this.localization,\n firstDayOfWeek: this.firstDayOfWeek,\n min: minDate,\n max: maxDate,\n isDateDisabled: this.isDateDisabled,\n })}\n </div>\n `\n }\n\n private createDateFormatter() {\n this.dateFormatShort = new Intl.DateTimeFormat(this.localization.locale, { day: \"numeric\", month: \"long\" })\n }\n\n private handleDaySelect = (day: Date) => {\n const isInRange = inRange(day, parseISODate(this.min), parseISODate(this.max))\n const isAllowed = !this.isDateDisabled(day)\n\n if (isInRange && isAllowed) {\n this.value = printISODate(day)\n this.dispatchEvent(new DateSelectEvent(\"change\", day))\n }\n }\n\n private addDays(days: number) {\n this.setFocusedDay(addDays(this.focusedDay, days))\n }\n\n private addMonths(months: number) {\n this.setMonth(this.focusedDay.getMonth() + months)\n }\n\n private addYears(years: number) {\n this.setYear(this.focusedDay.getFullYear() + years)\n }\n\n private startOfWeek() {\n this.setFocusedDay(startOfWeek(this.focusedDay, this.firstDayOfWeek))\n }\n\n private endOfWeek() {\n this.setFocusedDay(endOfWeek(this.focusedDay, this.firstDayOfWeek))\n }\n\n private setMonth(month: number) {\n const min = setMonth(startOfMonth(this.focusedDay), month)\n const max = endOfMonth(min)\n const date = setMonth(this.focusedDay, month)\n\n this.setFocusedDay(clamp(date, min, max))\n }\n\n private setYear(year: number) {\n const min = setYear(startOfMonth(this.focusedDay), year)\n const max = endOfMonth(min)\n const date = setYear(this.focusedDay, year)\n\n this.setFocusedDay(clamp(date, min, max))\n }\n\n private setFocusedDay(day: Date) {\n this.focusedDay = clamp(day, parseISODate(this.min), parseISODate(this.max))\n this.dispatchEvent(new DateSelectEvent(\"nord-focus-date\", this.focusedDay))\n }\n\n private handleMonthSelect = (e: any) => {\n this.setMonth(parseInt(e.target.value, 10))\n }\n\n private handleYearSelect = (e: any) => {\n this.setYear(parseInt(e.target.value, 10))\n }\n\n private handleNextMonthClick = (event: MouseEvent) => {\n event.preventDefault()\n this.addMonths(1)\n }\n\n private handlePreviousMonthClick = (event: MouseEvent) => {\n event.preventDefault()\n this.addMonths(-1)\n }\n\n private enableActiveFocus = () => {\n this.activeFocus = true\n }\n\n private disableActiveFocus = () => {\n this.activeFocus = false\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"nord-calendar\": Calendar\n }\n}\n"],"names":["i","n","finisher","e","descriptor","t","o","r","originalKey","key","kind","placement","constructor","Object","defineProperty","get","this","renderRoot","querySelector","enumerable","configurable","Symbol","preventDefault","SwipeController","host","options","event","pageX","pageY","changedTouches","initialTouchX","initialTouchY","distX","distY","details","initialX","initialY","matchesGesture","onSwipeEnd","addController","target","hostUpdated","attached","addEventListener","handleTouchStart","handleTouchEnd","hostDisconnected","removeEventListener","isHorizontalSwipe","Math","abs","isDownwardsSwipe","Icon","registerIcon","arrowRightIcon","arrowLeftIcon","arrowDownIcon","fn","isDateDisabled","Calendar","LitElement","DirectionController","addMonths","createKeybindingsHandler","ArrowRight","addDays","direction","isLTR","ArrowLeft","ArrowDown","ArrowUp","Home","startOfWeek","End","endOfWeek","PageUp","PageDown","addYears","localization","Date","day","isInRange","inRange","parseISODate","min","max","isAllowed","value","printISODate","dispatchEvent","DateSelectEvent","setMonth","parseInt","setYear","activeFocus","focus","focusedDayNode","monthSelectNode","willUpdate","changedProperties","has","setFocusedDay","createDateFormatter","updated","render","valueAsDate","focusedMonth","focusedDay","getMonth","focusedYear","getFullYear","minDate","maxDate","minDateStartOfMonth","startOfMonth","undefined","maxDateEndOfMonth","endOfMonth","selectedYear","minYear","maxYear","html","dialogLabelId","monthNames","monthSelectLabel","handleMonthSelect","map","month","monthNamesShort","yearSelectLabel","handleYearSelect","repeat","range","year","handlePreviousMonthClick","isEqualMonth","prevMonthLabel","handleNextMonthClick","nextMonthLabel","monthView","onFocusOut","disableActiveFocus","onFocusIn","enableActiveFocus","dateFormatter","dateFormatShort","selectedDate","focusedDate","onDateSelect","handleDaySelect","onKeyboardNavigation","shortcuts","labelledById","firstDayOfWeek","Intl","DateTimeFormat","locale","days","months","years","date","clamp","componentStyle","style","__decorate","query","property","attribute","type","Number","state","customElement"],"mappings":";;;;;;;;;;;AAKG,SAASA,EAAEA,EAAEC,GAAG,MCAuG,GAAEC,SAASC,EAAEC,WAAWC,KAAK,CAACC,EAAEL,KAAK,IAAIM,EAAE,QAAG,IAASN,EAAE,CAAC,MAAMA,EAAE,QAAQM,EAAED,EAAEE,mBAAc,IAASD,EAAEA,EAAED,EAAEG,IAAIT,EAAE,MAAMK,EAAE,CAACK,KAAK,SAASC,UAAU,YAAYF,IAAIR,EAAEG,WAAWC,EAAEC,EAAEG,MAAM,IAAIH,E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AAQqB,EAAalG,KAAK2F,YAAa0B,GAC7ChD,EAAMgC,EAAWjC,GACjB4E,EAAOnE,EAAQ7E,KAAK2F,WAAY0B,GAEtCrH,KAAKqF,cAAc4D,EAAMD,EAAM5E,EAAKC,IAG9BgB,cAAcrB,GACpBhE,KAAK2F,WAAasD,EAAMjF,EAAKG,EAAanE,KAAKoE,KAAMD,EAAanE,KAAKqE,MACvErE,KAAKyE,cAAc,IAAIC,EAAgB,kBAAmB1E,KAAK2F,eA7Q1DhD,SAAS,CAACuG,EAAgBC,GAIQC,GAAxCC,EAAM,4BAA4B,0CACJD,GAA9BC,EAAM,8DA+ByBD,GAA/BE,EAAS,CAAEC,WAAW,wCAKXH,GAAXE,iCAM2BF,GAA3BE,EAAS,CAAEE,KAAMC,+CAMNL,GAAXE,+BAMWF,GAAXE,+BAM+BF,GAA/BE,EAAS,CAAEC,WAAW,0CAEdH,GAARM,uCACQN,GAARM,sCArEkB/G,KADpBgH,EAAc,kBACMhH,SAAAA"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{_ as t}from"./query-assigned-elements-37b095c4.js";import{$ as e}from"./lit-element-74b6bb4b.js";import{e as r}from"./property-03f59dce.js";import{S as o}from"./SlotController-5bfc47d1.js";import{N as i}from"./events-731d0007.js";import"./VisuallyHidden.js";class s{constructor(t,e){this.host=t,this.options=e,this.handleFormData=t=>{const{disabled:e,name:r}=this.host;if(e)return;const o=this.options.value();r&&null!=o&&t.formData.append(r,o)},this.host=t,t.addController(this),this.options=e}hostConnected(){var t;null===(t=this.host.form)||void 0===t||t.addEventListener("formdata",this.handleFormData)}hostDisconnected(){var t;null===(t=this.host.form)||void 0===t||t.removeEventListener("formdata",this.handleFormData)}}function n(n){class h extends n{constructor(){super(...arguments),this.labelSlot=new o(this,"label"),this.errorSlot=new o(this,"error"),this.hintSlot=new o(this,"hint"),this.formData=new s(this,{value:()=>this.formValue}),this.inputId="input",this.errorId="error",this.hintId="hint",this.label="",this.hideLabel=!1,this.required=!1,this.expand=!1}get formValue(){return this.value}handleInput(t){t.stopPropagation();const e=t.target;this.value=e.value,this.dispatchEvent(new i("input"))}handleChange(t){t.stopPropagation(),this.dispatchEvent(new i("change"))}renderLabel(){const t=e`<label for="${this.inputId}"><slot name="label">${this.label}</slot></label><div class="n-caption n-hint" id="${this.hintId}" ?hidden="${!this.hasHint}"><slot name="hint">${this.hint}</slot></div>`;return this.hideLabel?e`<nord-visually-hidden>${t}</nord-visually-hidden>`:e`<div class="n-label-container">${t}</div>`}renderError(){return e`<div class="n-caption n-error" id="${this.errorId}" role="alert" ?hidden="${!this.hasError}"><slot name="error">${this.error}</slot></div>`}getDescribedBy(){const{hasHint:t,hasError:e}=this;return t&&e?`${this.hintId} ${this.errorId}`:t?this.hintId:e?this.errorId:void 0}getInvalid(){return this.hasError?"true":void 0}get hasHint(){return Boolean(this.hint)||this.hintSlot.hasContent}get hasError(){return Boolean(this.error)||this.errorSlot.hasContent}}return t([r()],h.prototype,"label",void 0),t([r()],h.prototype,"hint",void 0),t([r({type:Boolean,attribute:"hide-label"})],h.prototype,"hideLabel",void 0),t([r()],h.prototype,"placeholder",void 0),t([r()],h.prototype,"error",void 0),t([r({type:Boolean})],h.prototype,"required",void 0),t([r({reflect:!0,type:Boolean})],h.prototype,"expand",void 0),h}export{n as F};
|
|
2
|
-
//# sourceMappingURL=FormAssociatedMixin-ccae91fd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormAssociatedMixin-ccae91fd.js","sources":["../src/common/controllers/FormDataController.ts","../src/common/mixins/FormAssociatedMixin.ts"],"sourcesContent":["import { ReactiveController, ReactiveControllerHost } from \"lit\"\nimport { InputMixinInterface } from \"../mixins/InputMixin.js\"\n\ntype FormDataOptions = {\n value: () => string | undefined\n}\n\nexport class FormDataController implements ReactiveController {\n constructor(private host: ReactiveControllerHost & InputMixinInterface, private options: FormDataOptions) {\n this.host = host\n host.addController(this)\n this.options = options\n }\n\n hostConnected() {\n this.host.form?.addEventListener(\"formdata\", this.handleFormData)\n }\n\n hostDisconnected() {\n this.host.form?.removeEventListener(\"formdata\", this.handleFormData)\n }\n\n private handleFormData = (e: FormDataEvent) => {\n const { disabled, name } = this.host\n\n if (disabled) {\n return\n }\n\n const value = this.options.value()\n\n if (name && value != null) {\n e.formData.append(name, value)\n }\n }\n}\n","/* eslint-disable max-classes-per-file */\nimport { html, LitElement, TemplateResult } from \"lit\"\nimport { property } from \"lit/decorators.js\"\nimport { FormDataController } from \"../controllers/FormDataController.js\"\nimport { SlotController } from \"../controllers/SlotController.js\"\nimport { NordEvent } from \"../events.js\"\nimport { InputMixinInterface } from \"./InputMixin.js\"\nimport \"../../visually-hidden/VisuallyHidden.js\"\n\ntype Constructor<T = Record<string, unknown>> = new (...args: any[]) => T\ntype NativeInputElement = HTMLSelectElement | HTMLInputElement | HTMLTextAreaElement\n\nexport declare class FormAssociatedMixinInterface {\n label: string\n required: boolean\n hint?: string\n hideLabel: boolean\n placeholder?: string\n error?: string\n expand: boolean\n\n protected inputId: string\n protected errorId: string\n protected hintId: string\n protected labelSlot: SlotController\n protected hintSlot: SlotController\n protected errorSlot: SlotController\n protected formData: FormDataController\n\n protected get formValue(): string | undefined\n protected get hasError(): boolean\n protected get hasHint(): boolean\n\n protected handleChange(e: Event): void\n protected handleInput(e: Event): void\n protected renderLabel(): TemplateResult\n protected renderError(): TemplateResult\n protected getDescribedBy(): string | undefined\n protected getInvalid(): \"true\" | undefined\n}\n\nexport function FormAssociatedMixin<T extends Constructor<InputMixinInterface & LitElement>>(superClass: T) {\n // TODO: would be nice if custom elements analyzer could pick up the slot docs from the mixin\n\n /**\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Use when a hint requires more than plain text.\n * @slot error - Optional slot that holds error text for the input.\n */\n class FormAssociatedElement extends superClass {\n protected labelSlot = new SlotController(this, \"label\")\n protected errorSlot = new SlotController(this, \"error\")\n protected hintSlot = new SlotController(this, \"hint\")\n protected formData = new FormDataController(this, { value: () => this.formValue })\n\n protected get formValue() {\n return this.value\n }\n\n protected inputId = \"input\"\n protected errorId = \"error\"\n protected hintId = \"hint\"\n\n /**\n * Label for the input.\n */\n @property() label: string = \"\"\n\n /**\n * Optional hint text to be displayed with the input. Alternatively use the hint slot.\n */\n @property() hint?: string\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @property({ type: Boolean, attribute: \"hide-label\" }) hideLabel = false\n\n /**\n * Placeholder text to display within the input.\n */\n @property() placeholder?: string\n\n /**\n * Optional error to be shown with the input. Alternatively use the error slot.\n */\n @property() error?: string\n\n /**\n * Determines whether the input is required or not.\n * An input marked as required will be announced as such to users of assistive technology.\n * When using this property you need to also set “novalidate” attribute on a form element to prevent browser from displaying its own validation errors.\n */\n @property({ type: Boolean }) required = false\n\n /**\n * Controls whether the input expands to fill the width of its container.\n */\n @property({ reflect: true, type: Boolean }) expand = false\n\n protected handleInput(e: Event) {\n e.stopPropagation()\n const target = e.target as NativeInputElement\n this.value = target.value\n\n /**\n * Fired as the user types into the input.\n */\n this.dispatchEvent(new NordEvent(\"input\"))\n }\n\n protected handleChange(e: Event) {\n e.stopPropagation()\n\n /**\n * Fired whenever the input's value is changed via user interaction.\n */\n this.dispatchEvent(new NordEvent(\"change\"))\n }\n\n protected renderLabel() {\n const label = html`\n <label for=${this.inputId}>\n <slot name=\"label\">${this.label}</slot>\n </label>\n\n <div class=\"n-caption n-hint\" id=${this.hintId} ?hidden=${!this.hasHint}>\n <slot name=\"hint\">${this.hint}</slot>\n </div>\n `\n\n return this.hideLabel\n ? html`<nord-visually-hidden>${label}</nord-visually-hidden>`\n : html`<div class=\"n-label-container\">${label}</div>`\n }\n\n protected renderError() {\n return html`\n <div class=\"n-caption n-error\" id=${this.errorId} role=\"alert\" ?hidden=${!this.hasError}>\n <slot name=\"error\">${this.error}</slot>\n </div>\n `\n }\n\n protected getDescribedBy() {\n const { hasHint, hasError } = this\n\n if (hasHint && hasError) {\n return `${this.hintId} ${this.errorId}`\n }\n if (hasHint) {\n return this.hintId\n }\n if (hasError) {\n return this.errorId\n }\n\n return undefined\n }\n\n protected getInvalid() {\n return this.hasError ? \"true\" : undefined\n }\n\n protected get hasHint() {\n return Boolean(this.hint) || this.hintSlot.hasContent\n }\n\n protected get hasError() {\n return Boolean(this.error) || this.errorSlot.hasContent\n }\n }\n\n return FormAssociatedElement as unknown as Constructor<FormAssociatedMixinInterface> & T\n}\n"],"names":["FormDataController","constructor","host","options","this","e","disabled","name","value","formData","append","addController","hostConnected","form","addEventListener","handleFormData","hostDisconnected","removeEventListener","FormAssociatedMixin","superClass","FormAssociatedElement","SlotController","formValue","handleInput","stopPropagation","target","dispatchEvent","NordEvent","handleChange","renderLabel","label","html","inputId","hintId","hasHint","hint","hideLabel","renderError","errorId","hasError","error","getDescribedBy","getInvalid","undefined","Boolean","hintSlot","hasContent","errorSlot","__decorate","property","type","attribute","reflect"],"mappings":"+QAOaA,EACXC,YAAoBC,EAA4DC,GAA5DC,UAAAF,EAA4DE,aAAAD,EAcxEC,oBAAkBC,IACxB,MAAMC,SAAEA,EAAQC,KAAEA,GAASH,KAAKF,KAEhC,GAAII,EACF,OAGF,MAAME,EAAQJ,KAAKD,QAAQK,QAEvBD,GAAiB,MAATC,GACVH,EAAEI,SAASC,OAAOH,EAAMC,IAvB1BJ,KAAKF,KAAOA,EACZA,EAAKS,cAAcP,MACnBA,KAAKD,QAAUA,EAGjBS,gCACER,KAAKF,KAAKW,qBAAMC,iBAAiB,WAAYV,KAAKW,gBAGpDC,mCACEZ,KAAKF,KAAKW,qBAAMI,oBAAoB,WAAYb,KAAKW,0BCsBzCG,EAA6EC,GAQ3F,MAAMC,UAA8BD,EAApClB,kCACYG,eAAY,IAAIiB,EAAejB,KAAM,SACrCA,eAAY,IAAIiB,EAAejB,KAAM,SACrCA,cAAW,IAAIiB,EAAejB,KAAM,QACpCA,cAAW,IAAIJ,EAAmBI,KAAM,CAAEI,MAAO,IAAMJ,KAAKkB,YAM5DlB,aAAU,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=t,this.options=i,this.handleEsc=s=>{this.options.isOpen()&&this.options.onDismiss(s)},this.handleClickOut=s=>{var t;if(!this.options.isOpen())return;const i=null!==(t=this.options.isDismissible)&&void 0!==t?t:s=>s!==this.host;s.composedPath().every(i)&&this.options.onDismiss(s)},this.host=t,t.addController(this),this.options=i,this.shortcut=new s(this.host,{Escape:this.handleEsc})}hostConnected(){document.addEventListener("click",this.handleClickOut,!0)}hostDisconnected(){document.removeEventListener("click",this.handleClickOut,!0)}}export{t as L};
|
|
2
|
-
//# sourceMappingURL=LightDismissController-cc5b4bf2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LightDismissController-cc5b4bf2.js","sources":["../src/common/controllers/LightDismissController.ts"],"sourcesContent":["import { ReactiveController, ReactiveControllerHost } from \"lit\"\nimport { ShortcutController } from \"./ShortcutController.js\"\n\ntype LightDismissOptions = {\n isOpen: () => boolean\n onDismiss: EventListener\n isDismissible?: (node: EventTarget) => boolean\n}\n\nexport class LightDismissController implements ReactiveController {\n private shortcut: ShortcutController\n\n constructor(private host: ReactiveControllerHost & Element, private options: LightDismissOptions) {\n this.host = host\n host.addController(this)\n\n this.options = options\n this.shortcut = new ShortcutController(this.host, { Escape: this.handleEsc })\n }\n\n hostConnected() {\n document.addEventListener(\"click\", this.handleClickOut, true)\n }\n\n hostDisconnected() {\n document.removeEventListener(\"click\", this.handleClickOut, true)\n }\n\n private handleEsc = (e: KeyboardEvent) => {\n if (!this.options.isOpen()) {\n return\n }\n\n this.options.onDismiss(e)\n }\n\n private handleClickOut = (e: MouseEvent) => {\n if (!this.options.isOpen()) {\n return\n }\n\n const predicate: LightDismissOptions[\"isDismissible\"] = this.options.isDismissible ?? (node => node !== this.host)\n const isClickOutside = e.composedPath().every(predicate)\n\n if (isClickOutside) {\n this.options.onDismiss(e)\n }\n }\n}\n"],"names":["LightDismissController","constructor","host","options","this","e","isOpen","onDismiss","predicate","isDismissible","node","composedPath","every","addController","shortcut","ShortcutController","Escape","handleEsc","hostConnected","document","addEventListener","handleClickOut","hostDisconnected","removeEventListener"],"mappings":"2DASaA,EAGXC,YAAoBC,EAAgDC,GAAhDC,UAAAF,EAAgDE,aAAAD,EAgB5DC,eAAaC,IACdD,KAAKD,QAAQG,UAIlBF,KAAKD,QAAQI,UAAUF,IAGjBD,oBAAkBC,UACxB,IAAKD,KAAKD,QAAQG,SAChB,OAGF,MAAME,YAAkDJ,KAAKD,QAAQM,6BAAkBC,GAAQA,IAASN,KAAKF,KACtFG,EAAEM,eAAeC,MAAMJ,IAG5CJ,KAAKD,QAAQI,UAAUF,IAhCzBD,KAAKF,KAAOA,EACZA,EAAKW,cAAcT,MAEnBA,KAAKD,QAAUA,EACfC,KAAKU,SAAW,IAAIC,EAAmBX,KAAKF,KAAM,CAAEc,OAAQZ,KAAKa,YAGnEC,gBACEC,SAASC,iBAAiB,QAAShB,KAAKiB,gBAAgB,GAG1DC,mBACEH,SAASI,oBAAoB,QAASnB,KAAKiB,gBAAgB"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
class t{constructor(t,s=""){this.host=t,this.slotName=s,this.handleSlotChange=t=>{t.target.name===this.slotName&&this.onChange(t)},this.host=t,t.addController(this),this.slotName=s}hostConnected(){var t;null===(t=this.host.shadowRoot)||void 0===t||t.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){var t;null===(t=this.host.shadowRoot)||void 0===t||t.removeEventListener("slotchange",this.handleSlotChange)}get hasContent(){return null!=this.content}get isEmpty(){return!this.hasContent}get content(){const t=this.slotName?`[slot="${this.slotName}"]`:":not([slot])";return this.host.querySelector(t)}onChange(t){this.host.requestUpdate()}}export{t as S};
|
|
2
|
-
//# sourceMappingURL=SlotController-5bfc47d1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SlotController-5bfc47d1.js","sources":["../src/common/controllers/SlotController.ts"],"sourcesContent":["import { ReactiveController, ReactiveControllerHost } from \"lit\"\n\nexport class SlotController implements ReactiveController {\n constructor(protected host: ReactiveControllerHost & HTMLElement, public slotName: string = \"\") {\n this.host = host\n host.addController(this)\n this.slotName = slotName\n }\n\n hostConnected() {\n this.host.shadowRoot?.addEventListener(\"slotchange\", this.handleSlotChange)\n }\n\n hostDisconnected() {\n this.host.shadowRoot?.removeEventListener(\"slotchange\", this.handleSlotChange)\n }\n\n get hasContent() {\n return this.content != null\n }\n\n get isEmpty() {\n return !this.hasContent\n }\n\n get content() {\n const selector = this.slotName ? `[slot=\"${this.slotName}\"]` : `:not([slot])`\n return this.host.querySelector(selector)\n }\n\n private handleSlotChange = (e: Event) => {\n const slot = e.target as HTMLSlotElement\n\n if (slot.name === this.slotName) {\n this.onChange(e)\n }\n }\n\n protected onChange(_e: Event) {\n this.host.requestUpdate()\n }\n}\n"],"names":["SlotController","constructor","host","slotName","this","e","target","name","onChange","addController","hostConnected","shadowRoot","addEventListener","handleSlotChange","hostDisconnected","removeEventListener","hasContent","content","isEmpty","selector","querySelector","_e","requestUpdate"],"mappings":"MAEaA,EACXC,YAAsBC,EAAmDC,EAAmB,IAAtEC,UAAAF,EAAmDE,cAAAD,EA2BjEC,sBAAoBC,IACbA,EAAEC,OAENC,OAASH,KAAKD,UACrBC,KAAKI,SAASH,IA9BhBD,KAAKF,KAAOA,EACZA,EAAKO,cAAcL,MACnBA,KAAKD,SAAWA,EAGlBO,gCACEN,KAAKF,KAAKS,2BAAYC,iBAAiB,aAAcR,KAAKS,kBAG5DC,mCACEV,KAAKF,KAAKS,2BAAYI,oBAAoB,aAAcX,KAAKS,kBAG3DG,iBACF,OAAuB,MAAhBZ,KAAKa,QAGVC,cACF,OAAQd,KAAKY,WAGXC,cACF,MAAME,EAAWf,KAAKD,SAAW,UAAUC,KAAKD,aAAe,eAC/D,OAAOC,KAAKF,KAAKkB,cAAcD,GAWvBX,SAASa,GACjBjB,KAAKF,KAAKoB"}
|