@daikin-oss/design-system-web-components 2.0.1-next.1 → 2.1.0-next.3
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/CHANGELOG.md +27 -0
- package/custom-elements.json +570 -383
- package/dist/cjs/base/dds-element.cjs +1 -1
- package/dist/cjs/components/carousel/daikin-carousel.cjs +298 -57
- package/dist/cjs/components/carousel/daikin-carousel.d.cts +50 -7
- package/dist/cjs/components/carousel-item/daikin-carousel-item.cjs +18 -2
- package/dist/cjs/components/carousel-item/daikin-carousel-item.d.cts +1 -5
- package/dist/cjs/components/chip/daikin-chip.cjs +24 -6
- package/dist/cjs/components/chip/daikin-chip.d.cts +2 -0
- package/dist/cjs/components/combobox/daikin-combobox.cjs +14 -4
- package/dist/cjs/components/combobox/daikin-combobox.d.cts +8 -0
- package/dist/cjs/components/icon-button/daikin-icon-button.cjs +42 -7
- package/dist/cjs/components/tag/daikin-tag.cjs +3 -1
- package/dist/cjs/components/text-field/daikin-text-field.cjs +12 -12
- package/dist/cjs/controllers/click-outside.cjs +6 -8
- package/dist/cjs/controllers/click-outside.d.cts +3 -3
- package/dist/cjs/tailwind.css.cjs +1 -1
- package/dist/cjs-dev/base/dds-element.cjs +1 -1
- package/dist/cjs-dev/components/carousel/daikin-carousel.cjs +300 -59
- package/dist/cjs-dev/components/carousel/daikin-carousel.d.cts +50 -7
- package/dist/cjs-dev/components/carousel-item/daikin-carousel-item.cjs +18 -2
- package/dist/cjs-dev/components/carousel-item/daikin-carousel-item.d.cts +1 -5
- package/dist/cjs-dev/components/chip/daikin-chip.cjs +24 -6
- package/dist/cjs-dev/components/chip/daikin-chip.d.cts +2 -0
- package/dist/cjs-dev/components/combobox/daikin-combobox.cjs +14 -4
- package/dist/cjs-dev/components/combobox/daikin-combobox.d.cts +8 -0
- package/dist/cjs-dev/components/icon-button/daikin-icon-button.cjs +42 -7
- package/dist/cjs-dev/components/tag/daikin-tag.cjs +3 -1
- package/dist/cjs-dev/components/text-field/daikin-text-field.cjs +12 -12
- package/dist/cjs-dev/controllers/click-outside.cjs +6 -8
- package/dist/cjs-dev/controllers/click-outside.d.cts +3 -3
- package/dist/cjs-dev/tailwind.css.cjs +1 -1
- package/dist/es/base/dds-element.js +1 -1
- package/dist/es/components/carousel/daikin-carousel.d.ts +50 -7
- package/dist/es/components/carousel/daikin-carousel.js +297 -58
- package/dist/es/components/carousel-item/daikin-carousel-item.d.ts +1 -5
- package/dist/es/components/carousel-item/daikin-carousel-item.js +18 -2
- package/dist/es/components/chip/daikin-chip.d.ts +2 -0
- package/dist/es/components/chip/daikin-chip.js +25 -7
- package/dist/es/components/combobox/daikin-combobox.d.ts +8 -0
- package/dist/es/components/combobox/daikin-combobox.js +14 -4
- package/dist/es/components/icon-button/daikin-icon-button.js +42 -7
- package/dist/es/components/tag/daikin-tag.js +3 -1
- package/dist/es/components/text-field/daikin-text-field.js +12 -12
- package/dist/es/controllers/click-outside.d.ts +3 -3
- package/dist/es/controllers/click-outside.js +6 -8
- package/dist/es/tailwind.css.js +1 -1
- package/dist/es-dev/base/dds-element.js +1 -1
- package/dist/es-dev/components/carousel/daikin-carousel.d.ts +50 -7
- package/dist/es-dev/components/carousel/daikin-carousel.js +299 -60
- package/dist/es-dev/components/carousel-item/daikin-carousel-item.d.ts +1 -5
- package/dist/es-dev/components/carousel-item/daikin-carousel-item.js +18 -2
- package/dist/es-dev/components/chip/daikin-chip.d.ts +2 -0
- package/dist/es-dev/components/chip/daikin-chip.js +25 -7
- package/dist/es-dev/components/combobox/daikin-combobox.d.ts +8 -0
- package/dist/es-dev/components/combobox/daikin-combobox.js +14 -4
- package/dist/es-dev/components/icon-button/daikin-icon-button.js +42 -7
- package/dist/es-dev/components/tag/daikin-tag.js +3 -1
- package/dist/es-dev/components/text-field/daikin-text-field.js +12 -12
- package/dist/es-dev/controllers/click-outside.d.ts +3 -3
- package/dist/es-dev/controllers/click-outside.js +6 -8
- package/dist/es-dev/tailwind.css.js +1 -1
- package/package.json +2 -1
|
@@ -5,7 +5,7 @@ import { ddsElement } from "../../base/decorators.js";
|
|
|
5
5
|
import "../../base/index.js";
|
|
6
6
|
import tailwind_default from "../../tailwind.css.js";
|
|
7
7
|
import { css, html, nothing, unsafeCSS } from "lit";
|
|
8
|
-
import { query } from "lit/decorators.js";
|
|
8
|
+
import { query, state } from "lit/decorators.js";
|
|
9
9
|
import { cva } from "class-variance-authority";
|
|
10
10
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
11
11
|
//#region src/components/chip/daikin-chip.ts
|
|
@@ -16,7 +16,9 @@ var cvaInputChipWrapper = cva([
|
|
|
16
16
|
"size-full",
|
|
17
17
|
"border",
|
|
18
18
|
"py-0.5",
|
|
19
|
-
"px-1"
|
|
19
|
+
"px-1",
|
|
20
|
+
"min-h-6",
|
|
21
|
+
"min-w-12"
|
|
20
22
|
], {
|
|
21
23
|
variants: {
|
|
22
24
|
variant: {
|
|
@@ -42,12 +44,15 @@ var cvaInputChipIcon = cva([
|
|
|
42
44
|
var cvaInputChipText = cva([
|
|
43
45
|
"text-(length:--dds-font-size-350)",
|
|
44
46
|
"px-1",
|
|
45
|
-
"mr-0.5",
|
|
46
47
|
"overflow-hidden",
|
|
47
48
|
"whitespace-nowrap",
|
|
48
49
|
"flex-1",
|
|
50
|
+
"text-center",
|
|
49
51
|
"text-ddt-color-common-text-primary"
|
|
50
|
-
]
|
|
52
|
+
], { variants: { hasLeftIcon: {
|
|
53
|
+
true: ["pl-0.5"],
|
|
54
|
+
false: []
|
|
55
|
+
} } });
|
|
51
56
|
var cvaRemoveButton = cva([
|
|
52
57
|
"flex-none",
|
|
53
58
|
"relative",
|
|
@@ -77,6 +82,7 @@ var cvaRemoveButton = cva([
|
|
|
77
82
|
var cvaFilterChipWrapper = cva([
|
|
78
83
|
"flex",
|
|
79
84
|
"items-center",
|
|
85
|
+
"justify-center",
|
|
80
86
|
"rounded-full",
|
|
81
87
|
"overflow-hidden",
|
|
82
88
|
"size-full",
|
|
@@ -84,6 +90,7 @@ var cvaFilterChipWrapper = cva([
|
|
|
84
90
|
"py-0.5",
|
|
85
91
|
"px-1",
|
|
86
92
|
"min-h-6",
|
|
93
|
+
"min-w-12",
|
|
87
94
|
"focus-visible:outline",
|
|
88
95
|
"focus-visible:outline-2",
|
|
89
96
|
"focus-visible:outline-offset-2",
|
|
@@ -142,7 +149,7 @@ var cvaFilterChipWrapper = cva([
|
|
|
142
149
|
var cvaFilterChipText = cva([
|
|
143
150
|
"text-(length:--dds-font-size-350)",
|
|
144
151
|
"px-1",
|
|
145
|
-
"
|
|
152
|
+
"text-center"
|
|
146
153
|
], { variants: { checked: {
|
|
147
154
|
true: ["text-ddt-color-common-text-inverse"],
|
|
148
155
|
false: ["text-(--color-primary)"]
|
|
@@ -156,6 +163,7 @@ var DaikinChip = class DaikinChip extends DDSElement {
|
|
|
156
163
|
this.disabled = false;
|
|
157
164
|
this.withCheckedIcon = false;
|
|
158
165
|
this.chipAriaLabel = null;
|
|
166
|
+
this._hasLeftIcon = false;
|
|
159
167
|
}
|
|
160
168
|
static {
|
|
161
169
|
this.styles = css`
|
|
@@ -245,6 +253,9 @@ var DaikinChip = class DaikinChip extends DDSElement {
|
|
|
245
253
|
}
|
|
246
254
|
`;
|
|
247
255
|
}
|
|
256
|
+
_handleLeftIconSlotChange(event) {
|
|
257
|
+
this._hasLeftIcon = event.target.assignedElements().length > 0;
|
|
258
|
+
}
|
|
248
259
|
_handleRemoveClick(event) {
|
|
249
260
|
event.stopPropagation();
|
|
250
261
|
this.dispatchEvent(new Event("remove", {
|
|
@@ -291,8 +302,14 @@ var DaikinChip = class DaikinChip extends DDSElement {
|
|
|
291
302
|
})}
|
|
292
303
|
aria-label=${ifDefined(this.chipAriaLabel)}
|
|
293
304
|
>
|
|
294
|
-
<slot
|
|
295
|
-
|
|
305
|
+
<slot
|
|
306
|
+
name="left-icon"
|
|
307
|
+
class=${cvaInputChipIcon()}
|
|
308
|
+
@slotchange=${this._handleLeftIconSlotChange}
|
|
309
|
+
></slot>
|
|
310
|
+
<span
|
|
311
|
+
class=${cvaInputChipText({ hasLeftIcon: this._hasLeftIcon })}
|
|
312
|
+
>
|
|
296
313
|
<slot></slot>
|
|
297
314
|
</span>
|
|
298
315
|
${this.hideRemoveButton ? nothing : html`<button
|
|
@@ -389,6 +406,7 @@ __decorate([property$1({
|
|
|
389
406
|
attribute: "chip-aria-label"
|
|
390
407
|
})], DaikinChip.prototype, "chipAriaLabel", void 0);
|
|
391
408
|
__decorate([query("button")], DaikinChip.prototype, "_focusableElement", void 0);
|
|
409
|
+
__decorate([state()], DaikinChip.prototype, "_hasLeftIcon", void 0);
|
|
392
410
|
DaikinChip = __decorate([ddsElement("daikin-chip")], DaikinChip);
|
|
393
411
|
//#endregion
|
|
394
412
|
export { DaikinChip };
|
|
@@ -100,6 +100,14 @@ export declare class DaikinCombobox extends DDSFormElement {
|
|
|
100
100
|
private _moveFocusByKeydown;
|
|
101
101
|
private _updateFormValue;
|
|
102
102
|
private _closePopup;
|
|
103
|
+
/**
|
|
104
|
+
* Whether focus should be restored to the input the next time the popup closes.
|
|
105
|
+
* This is only `true` right before selecting an option, where hiding the popover blurs the
|
|
106
|
+
* clicked option button to `document.body`. It must stay `false` for closes caused by the
|
|
107
|
+
* focus/click moving to something else (outside click, focusout), otherwise we would steal
|
|
108
|
+
* focus back from whatever the user actually clicked.
|
|
109
|
+
*/
|
|
110
|
+
private _shouldRestoreFocusOnClose;
|
|
103
111
|
private _handleLeftIconSlotChange;
|
|
104
112
|
private _handleFocusOut;
|
|
105
113
|
private _handleClick;
|
|
@@ -171,6 +171,7 @@ var DaikinCombobox = class DaikinCombobox extends DDSFormElement {
|
|
|
171
171
|
this._hasLeftIcon = false;
|
|
172
172
|
this._autoUpdateController = new FloatingUIAutoUpdateController(this);
|
|
173
173
|
this._clickOutsideController = new ClickOutsideController(this, this._onClickOutside);
|
|
174
|
+
this._shouldRestoreFocusOnClose = false;
|
|
174
175
|
}
|
|
175
176
|
static {
|
|
176
177
|
this.styles = css`
|
|
@@ -255,8 +256,10 @@ var DaikinCombobox = class DaikinCombobox extends DDSFormElement {
|
|
|
255
256
|
_handleFocusOut(event) {
|
|
256
257
|
if (this.open && (!event.relatedTarget || !this.renderRoot.contains(event.relatedTarget))) this._closePopup();
|
|
257
258
|
}
|
|
258
|
-
_handleClick() {
|
|
259
|
-
if (this.disabled
|
|
259
|
+
_handleClick(shouldFocusInput = false) {
|
|
260
|
+
if (this.disabled) return;
|
|
261
|
+
if (shouldFocusInput) this.focus();
|
|
262
|
+
if (this.readonly) return;
|
|
260
263
|
this._autoUpdateController.setTriggerContext({ trigger: "mouse" });
|
|
261
264
|
this._synchronizeShowItems();
|
|
262
265
|
this.open = !this.open;
|
|
@@ -266,12 +269,16 @@ var DaikinCombobox = class DaikinCombobox extends DDSFormElement {
|
|
|
266
269
|
event.preventDefault();
|
|
267
270
|
event.stopPropagation();
|
|
268
271
|
event.stopImmediatePropagation();
|
|
272
|
+
setTimeout(() => {
|
|
273
|
+
this.focus();
|
|
274
|
+
}, 0);
|
|
269
275
|
this._handleClick();
|
|
270
276
|
}
|
|
271
277
|
_handleClickItem(item) {
|
|
272
278
|
if (this.disabled || this.readonly) return;
|
|
273
279
|
const value = getItemValue(item);
|
|
274
280
|
this.value = value;
|
|
281
|
+
this._shouldRestoreFocusOnClose = true;
|
|
275
282
|
this.open = false;
|
|
276
283
|
this._currentFocusItemIndex = null;
|
|
277
284
|
this.dispatchEvent(new Event("input", {
|
|
@@ -413,7 +420,7 @@ var DaikinCombobox = class DaikinCombobox extends DDSFormElement {
|
|
|
413
420
|
aria-activedescendant=${this._currentFocusItemIndex !== null ? `combobox-item-${this._currentFocusItemIndex}` : nothing}
|
|
414
421
|
@input=${this._handleInput}
|
|
415
422
|
@change=${this._handleChange}
|
|
416
|
-
@click=${this._handleClick}
|
|
423
|
+
@click=${() => this._handleClick(true)}
|
|
417
424
|
@focusout=${this._handleFocusOut}
|
|
418
425
|
${this._autoUpdateController.refReference()}
|
|
419
426
|
/>
|
|
@@ -502,7 +509,10 @@ var DaikinCombobox = class DaikinCombobox extends DDSFormElement {
|
|
|
502
509
|
if (changedProperties.has("value")) this._updateFormValue();
|
|
503
510
|
if (changedProperties.has("open") || changedProperties.has("disabled") || changedProperties.has("readonly")) {
|
|
504
511
|
this._autoUpdateController.floatingElement?.togglePopover(this._isPopupOpen);
|
|
505
|
-
if (changedProperties.get("open") && !this.open && !this.disabled)
|
|
512
|
+
if (changedProperties.get("open") && !this.open && !this.disabled) {
|
|
513
|
+
if (this._shouldRestoreFocusOnClose) this.focus();
|
|
514
|
+
this._shouldRestoreFocusOnClose = false;
|
|
515
|
+
}
|
|
506
516
|
}
|
|
507
517
|
if (changedProperties.has("open")) {
|
|
508
518
|
const wasOpen = changedProperties.get("open");
|
|
@@ -24,30 +24,34 @@ var cvaIconButton = cva([
|
|
|
24
24
|
"focus-visible:outline-offset-2",
|
|
25
25
|
"focus-visible:outline-ddt-color-common-border-focus",
|
|
26
26
|
"[--color-secondary:transparent]",
|
|
27
|
-
"link-disabled:[--color-primary:var(--
|
|
27
|
+
"link-disabled:[--color-primary:var(--ddc-color-common-disabled)]",
|
|
28
|
+
"link-disabled:[--color-secondary:var(--ddc-color-common-surface-disabled)]"
|
|
28
29
|
], {
|
|
29
30
|
variants: {
|
|
30
31
|
color: {
|
|
31
32
|
default: [
|
|
32
33
|
"link-enabled:[--color-primary:var(--dds-color-common-brand-default)]",
|
|
34
|
+
"link-enabled:[--color-secondary:var(--ddc-color-common-surface-brand-default)]",
|
|
33
35
|
"hover:link-enabled:[--color-primary:var(--dds-color-common-brand-hover)]",
|
|
34
|
-
"hover:link-enabled:[--color-secondary:var(--
|
|
36
|
+
"hover:link-enabled:[--color-secondary:var(--ddc-color-common-surface-brand-hover)]",
|
|
35
37
|
"active:link-enabled:[--color-primary:var(--dds-color-common-brand-press)]",
|
|
36
|
-
"active:link-enabled:[--color-secondary:var(--
|
|
38
|
+
"active:link-enabled:[--color-secondary:var(--ddc-color-common-surface-brand-press)]"
|
|
37
39
|
],
|
|
38
40
|
neutral: [
|
|
39
41
|
"link-enabled:[--color-primary:var(--dds-color-common-neutral-default)]",
|
|
42
|
+
"link-enabled:[--color-secondary:var(--ddc-color-common-surface-neutral-default)]",
|
|
40
43
|
"hover:link-enabled:[--color-primary:var(--dds-color-common-neutral-hover)]",
|
|
41
|
-
"hover:link-enabled:[--color-secondary:var(--
|
|
44
|
+
"hover:link-enabled:[--color-secondary:var(--ddc-color-common-surface-neutral-hover)]",
|
|
42
45
|
"active:link-enabled:[--color-primary:var(--dds-color-common-neutral-press)]",
|
|
43
|
-
"active:link-enabled:[--color-secondary:var(--
|
|
46
|
+
"active:link-enabled:[--color-secondary:var(--ddc-color-common-surface-neutral-press)]"
|
|
44
47
|
],
|
|
45
48
|
danger: [
|
|
46
49
|
"link-enabled:[--color-primary:var(--dds-color-common-danger-default)]",
|
|
50
|
+
"link-enabled:[--color-secondary:var(--ddc-color-common-surface-danger-default)]",
|
|
47
51
|
"hover:link-enabled:[--color-primary:var(--dds-color-common-danger-hover)]",
|
|
48
|
-
"hover:link-enabled:[--color-secondary:var(--
|
|
52
|
+
"hover:link-enabled:[--color-secondary:var(--ddc-color-common-surface-danger-hover)]",
|
|
49
53
|
"active:link-enabled:[--color-primary:var(--dds-color-common-danger-press)]",
|
|
50
|
-
"active:link-enabled:[--color-secondary:var(--
|
|
54
|
+
"active:link-enabled:[--color-secondary:var(--ddc-color-common-surface-danger-press)]"
|
|
51
55
|
]
|
|
52
56
|
},
|
|
53
57
|
variant: {
|
|
@@ -107,6 +111,8 @@ var DaikinIconButton = class DaikinIconButton extends DDSFormSubmitElement {
|
|
|
107
111
|
display: inline-block;
|
|
108
112
|
width: var(--ddc-icon-button-size, 2rem);
|
|
109
113
|
height: var(--ddc-icon-button-size, 2rem);
|
|
114
|
+
--ddc-color-common-disabled: var(--dds-color-common-disabled);
|
|
115
|
+
--ddc-color-common-surface-disabled: transparent;
|
|
110
116
|
}
|
|
111
117
|
|
|
112
118
|
:host([size="s"]) {
|
|
@@ -116,6 +122,35 @@ var DaikinIconButton = class DaikinIconButton extends DDSFormSubmitElement {
|
|
|
116
122
|
:host([size="m"]) {
|
|
117
123
|
--ddc-icon-button-size: 3rem; /* 48px */
|
|
118
124
|
}
|
|
125
|
+
|
|
126
|
+
:host(:not([color])),
|
|
127
|
+
:host([color="default"]) {
|
|
128
|
+
--ddc-color-common-surface-brand-default: none;
|
|
129
|
+
--ddc-color-common-surface-brand-hover: var(
|
|
130
|
+
--dds-color-common-surface-brand-hover
|
|
131
|
+
);
|
|
132
|
+
--ddc-color-common-surface-brand-press: var(
|
|
133
|
+
--dds-color-common-surface-brand-press
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
:host([color="neutral"]) {
|
|
137
|
+
--ddc-color-common-surface-neutral-default: none;
|
|
138
|
+
--ddc-color-common-surface-neutral-hover: var(
|
|
139
|
+
--dds-color-common-surface-neutral-hover
|
|
140
|
+
);
|
|
141
|
+
--ddc-color-common-surface-neutral-press: var(
|
|
142
|
+
--dds-color-common-surface-neutral-press
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
:host([color="danger"]) {
|
|
146
|
+
--ddc-color-common-surface-danger-default: none;
|
|
147
|
+
--ddc-color-common-surface-danger-hover: var(
|
|
148
|
+
--dds-color-common-surface-danger-hover
|
|
149
|
+
);
|
|
150
|
+
--ddc-color-common-surface-danger-press: var(
|
|
151
|
+
--dds-color-common-surface-danger-press
|
|
152
|
+
);
|
|
153
|
+
}
|
|
119
154
|
`;
|
|
120
155
|
}
|
|
121
156
|
constructor() {
|
|
@@ -17,7 +17,9 @@ var cvaWrapper = cva([
|
|
|
17
17
|
"overflow-hidden",
|
|
18
18
|
"size-full",
|
|
19
19
|
"gap-1",
|
|
20
|
-
"bg-(--bg-color-base)"
|
|
20
|
+
"bg-(--bg-color-base)",
|
|
21
|
+
"min-h-[2.125rem]",
|
|
22
|
+
"min-w-12"
|
|
21
23
|
], { variants: { elevated: {
|
|
22
24
|
true: ["shadow-[0px_1px_2px_1px_var(--dds-color-common-background-overlay)]"],
|
|
23
25
|
false: []
|
|
@@ -296,18 +296,18 @@ var DaikinTextField = class DaikinTextField extends DDSFormElement {
|
|
|
296
296
|
></span>
|
|
297
297
|
</daikin-icon-button>
|
|
298
298
|
</span>`}`;
|
|
299
|
-
case "password": return html`${leftIconSlot}${
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
299
|
+
case "password": return html`${leftIconSlot}${html`<daikin-icon-button
|
|
300
|
+
color="neutral"
|
|
301
|
+
variant="ghost"
|
|
302
|
+
?disabled=${this.disabled}
|
|
303
|
+
button-aria-label=${this.showPassword ? "Hide password" : "Show password"}
|
|
304
|
+
class="absolute right-(--dds-padding-20) size-(--dds-icon-button)"
|
|
305
|
+
@click=${this._handleShowPasswordClick}
|
|
306
|
+
>
|
|
307
|
+
<span
|
|
308
|
+
class=${cvaShowPasswordIcon({ showPassword: this.showPassword })}
|
|
309
|
+
></span>
|
|
310
|
+
</daikin-icon-button>`}`;
|
|
311
311
|
case "search": return html`<span
|
|
312
312
|
class=${cvaIcon({
|
|
313
313
|
icon: "left",
|
|
@@ -13,8 +13,8 @@ import { ReactiveControllerHost } from 'lit';
|
|
|
13
13
|
* this._onClickOutside
|
|
14
14
|
* );
|
|
15
15
|
*
|
|
16
|
-
* private _onClickOutside(event:
|
|
17
|
-
* console.debug("
|
|
16
|
+
* private _onClickOutside(event: PointerEvent): void {
|
|
17
|
+
* console.debug("Pointer outside", event);
|
|
18
18
|
* this.open = false;
|
|
19
19
|
* }
|
|
20
20
|
*
|
|
@@ -32,6 +32,6 @@ import { ReactiveControllerHost } from 'lit';
|
|
|
32
32
|
export declare class ClickOutsideController<T extends ReactiveControllerHost & HTMLElement> {
|
|
33
33
|
private readonly _host;
|
|
34
34
|
private readonly _callback;
|
|
35
|
-
constructor(_host: T, _callback: (this: T, event:
|
|
35
|
+
constructor(_host: T, _callback: (this: T, event: PointerEvent) => void);
|
|
36
36
|
directive(enabled?: boolean): import('lit-html/directive.js').DirectiveResult<import('lit-html/directive.js').DirectiveClass>;
|
|
37
37
|
}
|
|
@@ -2,21 +2,19 @@ import { createControllerDirective } from "./helpers/controller-directive.js";
|
|
|
2
2
|
import { nothing } from "lit";
|
|
3
3
|
//#region src/controllers/click-outside.ts
|
|
4
4
|
/**
|
|
5
|
-
* An async directive that listens for outside
|
|
5
|
+
* An async directive that listens for pointer presses outside an element.
|
|
6
6
|
* This directive takes the target HTMLElement and a callback function as arguments.
|
|
7
7
|
* When the directive is connected to the DOM, an event listener is registered, and when it is disconnected from or removed from the DOM, the event listener will be unregistered.
|
|
8
8
|
* Also, when the directive arguments are updated, the event listener is re-registered.
|
|
9
9
|
*/
|
|
10
10
|
var clickOutsideDirective = createControllerDirective((element, callback) => {
|
|
11
11
|
const listener = (event) => {
|
|
12
|
-
if (
|
|
12
|
+
if (event.composedPath().includes(element)) return;
|
|
13
13
|
callback.call(element, event);
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
window.addEventListener("click", listener);
|
|
17
|
-
}, 0);
|
|
15
|
+
window.addEventListener("pointerdown", listener, true);
|
|
18
16
|
return () => {
|
|
19
|
-
window.removeEventListener("
|
|
17
|
+
window.removeEventListener("pointerdown", listener, true);
|
|
20
18
|
};
|
|
21
19
|
});
|
|
22
20
|
/**
|
|
@@ -33,8 +31,8 @@ var clickOutsideDirective = createControllerDirective((element, callback) => {
|
|
|
33
31
|
* this._onClickOutside
|
|
34
32
|
* );
|
|
35
33
|
*
|
|
36
|
-
* private _onClickOutside(event:
|
|
37
|
-
* console.debug("
|
|
34
|
+
* private _onClickOutside(event: PointerEvent): void {
|
|
35
|
+
* console.debug("Pointer outside", event);
|
|
38
36
|
* this.open = false;
|
|
39
37
|
* }
|
|
40
38
|
*
|