@esri/solutions-components 0.6.13 → 0.6.15
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/assets/t9n/layer-table/resources.json +1 -1
- package/dist/assets/t9n/layer-table/resources_en.json +1 -1
- package/dist/assets/t9n/map-layer-picker/resources.json +4 -0
- package/dist/assets/t9n/map-layer-picker/resources_en.json +4 -0
- package/dist/cjs/basemap-gallery_6.cjs.entry.js +20 -5
- package/dist/cjs/buffer-tools_4.cjs.entry.js +1 -1
- package/dist/cjs/calcite-chip_3.cjs.entry.js +803 -0
- package/dist/cjs/calcite-combobox_6.cjs.entry.js +76 -28
- package/dist/cjs/card-manager_3.cjs.entry.js +112 -54
- package/dist/cjs/crowdsource-manager.cjs.entry.js +18 -5
- package/dist/cjs/{downloadUtils-fb4744e0.js → downloadUtils-34a515ad.js} +2 -2
- package/dist/cjs/edit-card_2.cjs.entry.js +29 -18
- package/dist/cjs/{index.es-372e33de.js → index.es-0ba11065.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/map-select-tools_3.cjs.entry.js +3 -3
- package/dist/cjs/{mapViewUtils-a4dd36ec.js → mapViewUtils-a2884698.js} +39 -55
- package/dist/cjs/public-notification.cjs.entry.js +3 -3
- package/dist/cjs/{publicNotificationStore-b69862af.js → publicNotificationStore-610bd880.js} +0 -4
- package/dist/cjs/solutions-components.cjs.js +1 -1
- package/dist/collection/components/basemap-gallery/basemap-gallery.js +23 -1
- package/dist/collection/components/card-manager/card-manager.js +2 -2
- package/dist/collection/components/crowdsource-manager/crowdsource-manager.js +171 -5
- package/dist/collection/components/edit-card/edit-card.js +44 -21
- package/dist/collection/components/layer-table/layer-table.js +127 -47
- package/dist/collection/components/map-card/map-card.js +115 -5
- package/dist/collection/components/map-layer-picker/map-layer-picker.css +6 -0
- package/dist/collection/components/map-layer-picker/map-layer-picker.js +107 -27
- package/dist/collection/components/map-picker/map-picker.css +5 -1
- package/dist/collection/components/map-picker/map-picker.js +3 -3
- package/dist/collection/components/map-tools/map-tools.js +104 -1
- package/dist/collection/demos/crowdsource-manager.html +2 -2
- package/dist/collection/demos/new-public-notification.html +3 -3
- package/dist/collection/utils/interfaces.ts +12 -1
- package/dist/collection/utils/mapViewUtils.js +38 -52
- package/dist/collection/utils/mapViewUtils.ts +41 -57
- package/dist/collection/utils/publicNotificationStore.js +0 -4
- package/dist/collection/utils/publicNotificationStore.ts +0 -4
- package/dist/components/basemap-gallery2.js +2 -0
- package/dist/components/card-manager2.js +2 -2
- package/dist/components/crowdsource-manager.js +27 -6
- package/dist/components/edit-card2.js +29 -18
- package/dist/components/layer-table2.js +136 -78
- package/dist/components/map-card2.js +17 -5
- package/dist/components/map-layer-picker2.js +114 -52
- package/dist/components/map-picker2.js +4 -4
- package/dist/components/map-select-tools2.js +55 -43
- package/dist/components/map-tools2.js +20 -1
- package/dist/components/mapViewUtils.js +39 -53
- package/dist/components/public-notification.js +1 -1
- package/dist/components/publicNotificationStore.js +0 -4
- package/dist/components/refine-selection2.js +61 -49
- package/dist/esm/basemap-gallery_6.entry.js +20 -5
- package/dist/esm/buffer-tools_4.entry.js +1 -1
- package/dist/esm/calcite-chip_3.entry.js +797 -0
- package/dist/esm/calcite-combobox_6.entry.js +76 -28
- package/dist/esm/card-manager_3.entry.js +112 -54
- package/dist/esm/crowdsource-manager.entry.js +18 -5
- package/dist/esm/{downloadUtils-67c7a6c8.js → downloadUtils-ac67a786.js} +2 -2
- package/dist/esm/edit-card_2.entry.js +29 -18
- package/dist/esm/{index.es-59a67d3d.js → index.es-f553598f.js} +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/map-select-tools_3.entry.js +3 -3
- package/dist/esm/{mapViewUtils-00a04d52.js → mapViewUtils-8141d8c1.js} +39 -53
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/public-notification.entry.js +3 -3
- package/dist/esm/{publicNotificationStore-90a6a274.js → publicNotificationStore-dcf39a55.js} +0 -4
- package/dist/esm/solutions-components.js +1 -1
- package/dist/solutions-components/demos/crowdsource-manager.html +2 -2
- package/dist/solutions-components/demos/new-public-notification.html +3 -3
- package/dist/solutions-components/p-08b52ed8.entry.js +6 -0
- package/dist/solutions-components/p-16362eb4.js +36 -0
- package/dist/solutions-components/{p-3691a072.js → p-1ab414e0.js} +2 -2
- package/dist/solutions-components/{p-73ab9d9a.entry.js → p-3d7aa1b2.entry.js} +1 -1
- package/dist/solutions-components/{p-9a8c51bf.entry.js → p-57cf6784.entry.js} +1 -1
- package/dist/solutions-components/p-64b22d57.entry.js +6 -0
- package/dist/solutions-components/p-654dd5df.entry.js +6 -0
- package/dist/solutions-components/{p-0219a1a9.entry.js → p-83a52f9e.entry.js} +6 -6
- package/dist/solutions-components/{p-f9166fcb.js → p-a26711e8.js} +1 -1
- package/dist/solutions-components/{p-b892e595.entry.js → p-b9d29f30.entry.js} +1 -1
- package/dist/solutions-components/{p-1b41181b.js → p-c8d0ce92.js} +2 -2
- package/dist/solutions-components/p-ee7e2f00.entry.js +34 -0
- package/dist/solutions-components/p-ef6ec812.entry.js +6 -0
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/interfaces.ts +12 -1
- package/dist/solutions-components/utils/mapViewUtils.ts +41 -57
- package/dist/solutions-components/utils/publicNotificationStore.ts +0 -4
- package/dist/types/components/basemap-gallery/basemap-gallery.d.ts +5 -0
- package/dist/types/components/crowdsource-manager/crowdsource-manager.d.ts +37 -1
- package/dist/types/components/edit-card/edit-card.d.ts +10 -9
- package/dist/types/components/layer-table/layer-table.d.ts +40 -0
- package/dist/types/components/map-card/map-card.d.ts +25 -1
- package/dist/types/components/map-layer-picker/map-layer-picker.d.ts +50 -3
- package/dist/types/components/map-picker/map-picker.d.ts +2 -2
- package/dist/types/components/map-tools/map-tools.d.ts +21 -1
- package/dist/types/components.d.ts +182 -2
- package/dist/types/preact.d.ts +6 -3
- package/dist/types/utils/interfaces.d.ts +10 -1
- package/dist/types/utils/mapViewUtils.d.ts +8 -24
- package/dist/types/utils/publicNotificationStore.d.ts +0 -2
- package/package.json +1 -1
- package/dist/cjs/calcite-chip.cjs.entry.js +0 -259
- package/dist/cjs/calcite-notice.cjs.entry.js +0 -139
- package/dist/cjs/calcite-tooltip.cjs.entry.js +0 -439
- package/dist/esm/calcite-chip.entry.js +0 -255
- package/dist/esm/calcite-notice.entry.js +0 -135
- package/dist/esm/calcite-tooltip.entry.js +0 -435
- package/dist/solutions-components/p-2cff8331.entry.js +0 -6
- package/dist/solutions-components/p-3a6c8fc3.entry.js +0 -6
- package/dist/solutions-components/p-3b1fc7a2.entry.js +0 -6
- package/dist/solutions-components/p-767002cd.js +0 -36
- package/dist/solutions-components/p-a776b7e6.entry.js +0 -6
- package/dist/solutions-components/p-be36d5ed.entry.js +0 -22
- package/dist/solutions-components/p-c644edf5.entry.js +0 -11
- package/dist/solutions-components/p-cfd88a2f.entry.js +0 -11
@@ -0,0 +1,803 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
'use strict';
|
7
|
+
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
9
|
+
|
10
|
+
const index = require('./index-ee37804b.js');
|
11
|
+
const dom = require('./dom-456f9f13.js');
|
12
|
+
const conditionalSlot = require('./conditionalSlot-f10611d3.js');
|
13
|
+
const loadable = require('./loadable-13605f73.js');
|
14
|
+
const t9n = require('./t9n-58d20225.js');
|
15
|
+
const interactive = require('./interactive-48299817.js');
|
16
|
+
const locale = require('./locale-79c3d30e.js');
|
17
|
+
const observers = require('./observers-9912f013.js');
|
18
|
+
const key = require('./key-8de93212.js');
|
19
|
+
const resources = require('./resources-acf9a7ea.js');
|
20
|
+
const floatingUi = require('./floating-ui-2b0fbba0.js');
|
21
|
+
const guid = require('./guid-d1123d5e.js');
|
22
|
+
const openCloseComponent = require('./openCloseComponent-359d855c.js');
|
23
|
+
const FloatingArrow = require('./FloatingArrow-88e3f797.js');
|
24
|
+
require('./resources-993f6faf.js');
|
25
|
+
require('./debounce-30afab47.js');
|
26
|
+
|
27
|
+
/*!
|
28
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
29
|
+
* See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
|
30
|
+
* v1.6.1
|
31
|
+
*/
|
32
|
+
const CSS$2 = {
|
33
|
+
title: "title",
|
34
|
+
close: "close",
|
35
|
+
imageContainer: "image-container",
|
36
|
+
chipIcon: "chip-icon",
|
37
|
+
textSlotted: "text--slotted",
|
38
|
+
container: "container",
|
39
|
+
imageSlotted: "image--slotted",
|
40
|
+
closable: "closable",
|
41
|
+
multiple: "multiple",
|
42
|
+
selectable: "selectable",
|
43
|
+
selectIcon: "select-icon",
|
44
|
+
selectIconActive: "select-icon--active",
|
45
|
+
nonInteractive: "non-interactive",
|
46
|
+
isCircle: "is-circle",
|
47
|
+
};
|
48
|
+
const SLOTS$1 = {
|
49
|
+
image: "image",
|
50
|
+
};
|
51
|
+
const ICONS = {
|
52
|
+
close: "x",
|
53
|
+
unchecked: "circle",
|
54
|
+
checkedSingle: "circle-f",
|
55
|
+
checked: "check-circle-f",
|
56
|
+
};
|
57
|
+
|
58
|
+
const chipCss = ":host([disabled]){cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}:host([scale=s]){block-size:1.5rem;font-size:var(--calcite-font-size--2);--calcite-chip-spacing-s-internal:0.25rem;--calcite-chip-spacing-l-internal:0.5rem}:host([scale=s]) .close,:host([scale=s]) .select-icon--active{block-size:1rem;inline-size:1rem}:host([scale=s]) .image-container{block-size:1.25rem;inline-size:1.25rem}:host([scale=s]) .container.is-circle{block-size:1.5rem;inline-size:1.5rem}:host([scale=m]){block-size:2rem;font-size:var(--calcite-font-size--1);--calcite-chip-spacing-s-internal:0.375rem;--calcite-chip-spacing-l-internal:0.5rem}:host([scale=m]) .close,:host([scale=m]) .image-container,:host([scale=m]) .select-icon--active{block-size:1.5rem;inline-size:1.5rem}:host([scale=m]) .container.is-circle{block-size:2rem;inline-size:2rem}:host([scale=l]){block-size:2.75rem;font-size:var(--calcite-font-size-0);--calcite-chip-spacing-s-internal:0.5rem;--calcite-chip-spacing-l-internal:0.75rem}:host([scale=l]) .image-container,:host([scale=l]) .close,:host([scale=l]) .select-icon--active{block-size:2rem;inline-size:2rem}:host([scale=l]) .container.is-circle{block-size:2.75rem;inline-size:2.75rem}:host{display:inline-flex;cursor:default;border-radius:9999px}.container{box-sizing:border-box;display:inline-flex;block-size:100%;max-inline-size:100%;align-items:center;justify-content:center;border-radius:9999px;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-1);font-weight:var(--calcite-font-weight-medium);outline-color:transparent}.container:not(.is-circle){padding-inline:var(--calcite-chip-spacing-s-internal)}.container.selectable{cursor:pointer}.container:not(.non-interactive):focus{outline:2px solid var(--calcite-ui-focus-color, var(--calcite-ui-brand));outline-offset:calc(\n 2px *\n calc(\n 1 -\n 2 * clamp(\n 0,\n var(--calcite-ui-focus-offset-invert),\n 1\n )\n )\n )}:host([scale=s]) .container.image--slotted{padding-inline-start:calc(0.125rem / 2)}:host([scale=s]) .container.is-circle{padding-inline:0}.container.text--slotted .title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-inline:var(--calcite-chip-spacing-s-internal)}.container:not(.text--slotted) .title{display:none}.container:not(.image--slotted) .image-container{display:none}.container.closable{padding-inline-end:calc(var(--calcite-chip-spacing-l-internal) / 2)}.container:not(.is-circle).image--slotted{padding-inline-start:calc(var(--calcite-chip-spacing-l-internal) / 2)}.container:not(.is-circle).image--slotted .image-container{margin-inline-end:var(--calcite-chip-spacing-s-internal)}.container:not(.is-circle).image--slotted .image-container~.chip-icon{margin-inline-start:var(--calcite-chip-spacing-s-internal)}.container:not(.is-circle).selectable:not(.text--slotted) .chip-icon{margin-inline-end:var(--calcite-chip-spacing-s-internal)}.container:not(.is-circle):not(.selectable):not(.text--slotted) .chip-icon{margin-inline-start:var(--calcite-chip-spacing-s-internal)}.container:not(.is-circle):not(.text--slotted) .chip-icon{margin-inline-end:var(--calcite-chip-spacing-s-internal)}.container:not(.is-circle):not(.text-slotted).image--slotted .image-container{margin-inline-end:var(--calcite-chip-spacing-s-internal)}.container:not(.is-circle):not(.closable):not(.text--slotted).image--slotted.selectable .image-container{margin-inline-end:0}.container:not(.is-circle):not(.closable):not(.text--slotted).image--slotted.selectable .image-container~.chip-icon{margin-inline-start:calc(var(--calcite-chip-spacing-s-internal) * 2)}.chip-icon{position:relative;margin-block:0px;display:inline-flex;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);margin-inline:var(--calcite-chip-spacing-s-internal)}.image-container{display:inline-flex;overflow:hidden;align-items:center;justify-content:center;pointer-events:none}.close{margin:0px;cursor:pointer;align-items:center;border-style:none;background-color:transparent;color:var(--calcite-ui-text-1);outline-color:transparent;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;-webkit-appearance:none;display:flex;border-radius:50%;align-content:center;justify-content:center;--calcite-chip-transparent-hover:var(--calcite-button-transparent-hover);--calcite-chip-transparent-press:var(--calcite-button-transparent-press)}.close:hover{background-color:var(--calcite-chip-transparent-hover)}.close:focus{background-color:var(--calcite-chip-transparent-hover);outline:2px solid var(--calcite-ui-focus-color, var(--calcite-ui-brand));outline-offset:calc(\n -2px *\n calc(\n 1 -\n 2 * clamp(\n 0,\n var(--calcite-ui-focus-offset-invert),\n 1\n )\n )\n )}.close:active{background-color:var(--calcite-chip-transparent-press)}.close calcite-icon{color:inherit}.select-icon{align-self:center;justify-content:center;align-items:center;display:flex;inset-block-start:-1px;position:relative;visibility:hidden;inline-size:0;opacity:0;transition:opacity 0.15s ease-in-out, inline-size 0.15s ease-in-out}.select-icon.select-icon--active{visibility:visible;opacity:0.5}.container:not(.is-circle).image--slotted .select-icon.select-icon--active{margin-inline-end:var(--calcite-chip-spacing-s-internal)}:host([selected]) .select-icon{opacity:1}.container:hover .select-icon--active{opacity:1}slot[name=image]::slotted(*){display:flex;block-size:100%;inline-size:100%;overflow:hidden;border-radius:50%}:host([kind=neutral]){background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}:host([kind=neutral]) .container{border-color:transparent}:host([kind=neutral]) .close{color:var(--calcite-ui-text-3)}:host([kind=neutral]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-text-3))}:host([kind=inverse]){background-color:var(--calcite-ui-inverse);color:var(--calcite-ui-text-inverse)}:host([kind=inverse]) .container{border-color:transparent}:host([kind=inverse]) .close{color:var(--calcite-ui-text-inverse)}:host([kind=inverse]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-text-inverse))}:host([kind=brand]){background-color:var(--calcite-ui-brand);color:var(--calcite-ui-text-inverse)}:host([kind=brand]) .container{border-color:transparent}:host([kind=brand]) .close{color:var(--calcite-ui-text-inverse)}:host([kind=brand]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-text-inverse))}:host([appearance=outline-fill]),:host([appearance=outline]){background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-1)}:host([appearance=outline-fill]) .close,:host([appearance=outline]) .close{color:var(--calcite-ui-text-3)}:host([appearance=outline-fill]) .chip-icon,:host([appearance=outline]) .chip-icon{color:var(--calcite-ui-icon-color, var(--calcite-ui-text-3))}:host([appearance=outline-fill]){background-color:var(--calcite-ui-foreground-1)}:host([appearance=outline]){background-color:transparent}:host([kind=neutral][appearance=outline-fill]) .container,:host([kind=neutral][appearance=outline]) .container{border-color:var(--calcite-ui-border-1)}:host([kind=inverse][appearance=outline-fill]) .container,:host([kind=inverse][appearance=outline]) .container{border-color:var(--calcite-ui-border-inverse)}:host([kind=brand][appearance=outline-fill]) .container,:host([kind=brand][appearance=outline]) .container{border-color:var(--calcite-ui-brand)}:host([kind=brand][appearance=solid]) button,:host([kind=inverse][appearance=solid]) button{outline-color:var(--calcite-ui-text-inverse)}:host([closed]){display:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([hidden]){display:none}[hidden]{display:none}";
|
59
|
+
|
60
|
+
const Chip = class {
|
61
|
+
constructor(hostRef) {
|
62
|
+
index.registerInstance(this, hostRef);
|
63
|
+
this.calciteChipClose = index.createEvent(this, "calciteChipClose", 6);
|
64
|
+
this.calciteChipSelect = index.createEvent(this, "calciteChipSelect", 6);
|
65
|
+
this.calciteInternalChipKeyEvent = index.createEvent(this, "calciteInternalChipKeyEvent", 6);
|
66
|
+
this.mutationObserver = observers.createObserver("mutation", () => this.updateHasText());
|
67
|
+
// --------------------------------------------------------------------------
|
68
|
+
//
|
69
|
+
// Private Methods
|
70
|
+
//
|
71
|
+
// --------------------------------------------------------------------------
|
72
|
+
this.close = () => {
|
73
|
+
this.calciteChipClose.emit();
|
74
|
+
this.selected = false;
|
75
|
+
this.closed = true;
|
76
|
+
};
|
77
|
+
this.closeButtonKeyDownHandler = (event) => {
|
78
|
+
if (key.isActivationKey(event.key)) {
|
79
|
+
event.preventDefault();
|
80
|
+
this.close();
|
81
|
+
}
|
82
|
+
};
|
83
|
+
this.handleSlotImageChange = (event) => {
|
84
|
+
this.hasImage = dom.slotChangeHasAssignedElement(event);
|
85
|
+
};
|
86
|
+
this.handleEmittingEvent = () => {
|
87
|
+
if (this.interactive) {
|
88
|
+
this.calciteChipSelect.emit();
|
89
|
+
}
|
90
|
+
};
|
91
|
+
this.disabled = false;
|
92
|
+
this.appearance = "solid";
|
93
|
+
this.kind = "neutral";
|
94
|
+
this.closable = false;
|
95
|
+
this.icon = undefined;
|
96
|
+
this.iconFlipRtl = false;
|
97
|
+
this.scale = "m";
|
98
|
+
this.label = undefined;
|
99
|
+
this.value = undefined;
|
100
|
+
this.closed = false;
|
101
|
+
this.selectionMode = "none";
|
102
|
+
this.selected = false;
|
103
|
+
this.messageOverrides = undefined;
|
104
|
+
this.messages = undefined;
|
105
|
+
this.interactive = false;
|
106
|
+
this.defaultMessages = undefined;
|
107
|
+
this.effectiveLocale = undefined;
|
108
|
+
this.hasText = false;
|
109
|
+
this.hasImage = false;
|
110
|
+
}
|
111
|
+
onMessagesChange() {
|
112
|
+
/* wired up by t9n util */
|
113
|
+
}
|
114
|
+
effectiveLocaleChange() {
|
115
|
+
t9n.updateMessages(this, this.effectiveLocale);
|
116
|
+
}
|
117
|
+
// --------------------------------------------------------------------------
|
118
|
+
//
|
119
|
+
// Lifecycle
|
120
|
+
//
|
121
|
+
// --------------------------------------------------------------------------
|
122
|
+
connectedCallback() {
|
123
|
+
var _a;
|
124
|
+
conditionalSlot.connectConditionalSlotComponent(this);
|
125
|
+
interactive.connectInteractive(this);
|
126
|
+
locale.connectLocalized(this);
|
127
|
+
t9n.connectMessages(this);
|
128
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
|
129
|
+
}
|
130
|
+
componentDidLoad() {
|
131
|
+
loadable.setComponentLoaded(this);
|
132
|
+
}
|
133
|
+
componentDidRender() {
|
134
|
+
interactive.updateHostInteraction(this);
|
135
|
+
}
|
136
|
+
disconnectedCallback() {
|
137
|
+
var _a;
|
138
|
+
conditionalSlot.disconnectConditionalSlotComponent(this);
|
139
|
+
interactive.disconnectInteractive(this);
|
140
|
+
locale.disconnectLocalized(this);
|
141
|
+
t9n.disconnectMessages(this);
|
142
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
143
|
+
}
|
144
|
+
async componentWillLoad() {
|
145
|
+
loadable.setUpLoadableComponent(this);
|
146
|
+
{
|
147
|
+
await t9n.setUpMessages(this);
|
148
|
+
this.updateHasText();
|
149
|
+
}
|
150
|
+
}
|
151
|
+
//--------------------------------------------------------------------------
|
152
|
+
//
|
153
|
+
// Event Listeners
|
154
|
+
//
|
155
|
+
//--------------------------------------------------------------------------
|
156
|
+
keyDownHandler(event) {
|
157
|
+
if (event.target === this.el) {
|
158
|
+
switch (event.key) {
|
159
|
+
case " ":
|
160
|
+
case "Enter":
|
161
|
+
this.handleEmittingEvent();
|
162
|
+
event.preventDefault();
|
163
|
+
break;
|
164
|
+
case "ArrowRight":
|
165
|
+
case "ArrowLeft":
|
166
|
+
case "Home":
|
167
|
+
case "End":
|
168
|
+
this.calciteInternalChipKeyEvent.emit(event);
|
169
|
+
event.preventDefault();
|
170
|
+
break;
|
171
|
+
}
|
172
|
+
}
|
173
|
+
}
|
174
|
+
clickHandler() {
|
175
|
+
if (!this.interactive && this.closable) {
|
176
|
+
this.closeButtonEl.focus();
|
177
|
+
}
|
178
|
+
}
|
179
|
+
//--------------------------------------------------------------------------
|
180
|
+
//
|
181
|
+
// Public Methods
|
182
|
+
//
|
183
|
+
//--------------------------------------------------------------------------
|
184
|
+
/** Sets focus on the component. */
|
185
|
+
async setFocus() {
|
186
|
+
var _a, _b;
|
187
|
+
await loadable.componentFocusable(this);
|
188
|
+
if (!this.disabled && this.interactive) {
|
189
|
+
(_a = this.containerEl) === null || _a === void 0 ? void 0 : _a.focus();
|
190
|
+
}
|
191
|
+
else if (!this.disabled && this.closable) {
|
192
|
+
(_b = this.closeButtonEl) === null || _b === void 0 ? void 0 : _b.focus();
|
193
|
+
}
|
194
|
+
}
|
195
|
+
updateHasText() {
|
196
|
+
this.hasText = this.el.textContent.trim().length > 0;
|
197
|
+
}
|
198
|
+
//--------------------------------------------------------------------------
|
199
|
+
//
|
200
|
+
// Render Methods
|
201
|
+
//
|
202
|
+
//--------------------------------------------------------------------------
|
203
|
+
renderChipImage() {
|
204
|
+
return (index.h("div", { class: CSS$2.imageContainer }, index.h("slot", { name: SLOTS$1.image, onSlotchange: this.handleSlotImageChange })));
|
205
|
+
}
|
206
|
+
renderSelectionIcon() {
|
207
|
+
const icon = this.selectionMode === "multiple" && this.selected
|
208
|
+
? ICONS.checked
|
209
|
+
: this.selectionMode === "multiple"
|
210
|
+
? ICONS.unchecked
|
211
|
+
: this.selected
|
212
|
+
? ICONS.checkedSingle
|
213
|
+
: undefined;
|
214
|
+
return (index.h("div", { class: {
|
215
|
+
[CSS$2.selectIcon]: true,
|
216
|
+
[CSS$2.selectIconActive]: this.selectionMode === "multiple" || this.selected,
|
217
|
+
} }, index.h("calcite-icon", { icon: icon, scale: this.scale === "l" ? "m" : "s" })));
|
218
|
+
}
|
219
|
+
renderCloseButton() {
|
220
|
+
return (index.h("button", { "aria-label": this.messages.dismissLabel, class: CSS$2.close, onClick: this.close, onKeyDown: this.closeButtonKeyDownHandler, tabIndex: this.disabled ? -1 : 0,
|
221
|
+
// eslint-disable-next-line react/jsx-sort-props
|
222
|
+
ref: (el) => (this.closeButtonEl = el) }, index.h("calcite-icon", { icon: ICONS.close, scale: this.scale === "l" ? "m" : "s" })));
|
223
|
+
}
|
224
|
+
renderIcon() {
|
225
|
+
return (index.h("calcite-icon", { class: CSS$2.chipIcon, flipRtl: this.iconFlipRtl, icon: this.icon, scale: this.scale === "l" ? "m" : "s" }));
|
226
|
+
}
|
227
|
+
render() {
|
228
|
+
const disableInteraction = this.disabled || (!this.disabled && !this.interactive);
|
229
|
+
const role = this.selectionMode === "multiple" && this.interactive
|
230
|
+
? "checkbox"
|
231
|
+
: this.selectionMode !== "none" && this.interactive
|
232
|
+
? "radio"
|
233
|
+
: this.interactive
|
234
|
+
? "button"
|
235
|
+
: undefined;
|
236
|
+
return (index.h(index.Host, null, index.h("div", { "aria-checked": this.selectionMode !== "none" && this.interactive
|
237
|
+
? dom.toAriaBoolean(this.selected)
|
238
|
+
: undefined, "aria-disabled": disableInteraction ? dom.toAriaBoolean(this.disabled) : undefined, "aria-label": this.label, class: {
|
239
|
+
[CSS$2.container]: true,
|
240
|
+
[CSS$2.textSlotted]: this.hasText,
|
241
|
+
[CSS$2.imageSlotted]: this.hasImage,
|
242
|
+
[CSS$2.selectable]: this.selectionMode !== "none",
|
243
|
+
[CSS$2.multiple]: this.selectionMode === "multiple",
|
244
|
+
[CSS$2.closable]: this.closable,
|
245
|
+
[CSS$2.nonInteractive]: !this.interactive,
|
246
|
+
[CSS$2.isCircle]: !this.closable &&
|
247
|
+
!this.hasText &&
|
248
|
+
(!this.icon || !this.hasImage) &&
|
249
|
+
(this.selectionMode === "none" ||
|
250
|
+
(!!this.selectionMode && this.selectionMode !== "multiple" && !this.selected)),
|
251
|
+
}, onClick: this.handleEmittingEvent, role: role, tabIndex: disableInteraction ? -1 : 0,
|
252
|
+
// eslint-disable-next-line react/jsx-sort-props
|
253
|
+
ref: (el) => (this.containerEl = el) }, this.selectionMode !== "none" && this.renderSelectionIcon(), this.renderChipImage(), this.icon && this.renderIcon(), index.h("span", { class: CSS$2.title }, index.h("slot", null)), this.closable && this.renderCloseButton())));
|
254
|
+
}
|
255
|
+
static get assetsDirs() { return ["assets"]; }
|
256
|
+
get el() { return index.getElement(this); }
|
257
|
+
static get watchers() { return {
|
258
|
+
"messageOverrides": ["onMessagesChange"],
|
259
|
+
"effectiveLocale": ["effectiveLocaleChange"]
|
260
|
+
}; }
|
261
|
+
};
|
262
|
+
Chip.style = chipCss;
|
263
|
+
|
264
|
+
/*!
|
265
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
266
|
+
* See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
|
267
|
+
* v1.6.1
|
268
|
+
*/
|
269
|
+
const SLOTS = {
|
270
|
+
title: "title",
|
271
|
+
message: "message",
|
272
|
+
link: "link",
|
273
|
+
actionsEnd: "actions-end",
|
274
|
+
};
|
275
|
+
const CSS$1 = {
|
276
|
+
actionsEnd: "actions-end",
|
277
|
+
close: "notice-close",
|
278
|
+
container: "container",
|
279
|
+
content: "notice-content",
|
280
|
+
icon: "notice-icon",
|
281
|
+
};
|
282
|
+
|
283
|
+
const noticeCss = ":host([scale=s]){--calcite-notice-spacing-token-small:0.5rem;--calcite-notice-spacing-token-large:0.75rem}:host([scale=s]) .container slot[name=title]::slotted(*),:host([scale=s]) .container *::slotted([slot=title]){margin-block:0.125rem;font-size:var(--calcite-font-size--1);line-height:1.375}:host([scale=s]) .container slot[name=message]::slotted(*),:host([scale=s]) .container *::slotted([slot=message]){margin-block:0.125rem;font-size:var(--calcite-font-size--2);line-height:1.375}:host([scale=s]) ::slotted(calcite-link){margin-block:0.125rem;font-size:var(--calcite-font-size--2);line-height:1.375}:host([scale=s]) .notice-close{padding:0.5rem}:host([scale=m]){--calcite-notice-spacing-token-small:0.75rem;--calcite-notice-spacing-token-large:1rem}:host([scale=m]) .container slot[name=title]::slotted(*),:host([scale=m]) .container *::slotted([slot=title]){margin-block:0.125rem;font-size:var(--calcite-font-size-0);line-height:1.375}:host([scale=m]) .container slot[name=message]::slotted(*),:host([scale=m]) .container *::slotted([slot=message]){margin-block:0.125rem;font-size:var(--calcite-font-size--1);line-height:1.375}:host([scale=m]) ::slotted(calcite-link){margin-block:0.125rem;font-size:var(--calcite-font-size--1);line-height:1.375}:host([scale=l]){--calcite-notice-spacing-token-small:1rem;--calcite-notice-spacing-token-large:1.25rem}:host([scale=l]) .container slot[name=title]::slotted(*),:host([scale=l]) .container *::slotted([slot=title]){margin-block:0.125rem;font-size:var(--calcite-font-size-1);line-height:1.375}:host([scale=l]) .container slot[name=message]::slotted(*),:host([scale=l]) .container *::slotted([slot=message]){margin-block:0.125rem;font-size:var(--calcite-font-size-0);line-height:1.375}:host([scale=l]) ::slotted(calcite-link){margin-block:0.125rem;font-size:var(--calcite-font-size-0);line-height:1.375}:host([width=auto]){--calcite-notice-width:auto}:host([width=half]){--calcite-notice-width:50%}:host([width=full]){--calcite-notice-width:100%}:host{margin-inline:auto;display:none;max-inline-size:100%;align-items:center;inline-size:var(--calcite-notice-width)}.container{pointer-events:none;margin-block:0px;box-sizing:border-box;display:none;inline-size:100%;background-color:var(--calcite-ui-foreground-1);opacity:0;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;max-block-size:0;text-align:start;border-inline-start:0px solid;box-shadow:0 0 0 0 transparent}.notice-close{outline-color:transparent}.notice-close:focus{outline:2px solid var(--calcite-ui-focus-color, var(--calcite-ui-brand));outline-offset:calc(\n -2px *\n calc(\n 1 -\n 2 * clamp(\n 0,\n var(--calcite-ui-focus-offset-invert),\n 1\n )\n )\n )}:host{display:flex}:host([open]) .container{pointer-events:auto;display:flex;max-block-size:100%;align-items:center;border-width:2px;opacity:1;--tw-shadow:0 4px 8px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);--tw-shadow-colored:0 4px 8px -1px var(--tw-shadow-color), 0 2px 4px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.container slot[name=title]::slotted(*),.container *::slotted([slot=title]){margin:0px;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}.container slot[name=message]::slotted(*),.container *::slotted([slot=message]){margin:0px;display:inline;font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-2);margin-inline-end:var(--calcite-notice-spacing-token-small)}.notice-content{box-sizing:border-box;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;padding-inline:var(--calcite-notice-spacing-token-large);flex:0 0 auto;display:flex;min-inline-size:0px;flex-direction:column;overflow-wrap:break-word;flex:1 1 0;padding-block:var(--calcite-notice-spacing-token-small);padding-inline:0 var(--calcite-notice-spacing-token-small)}.notice-content:first-of-type:not(:only-child){padding-inline-start:var(--calcite-notice-spacing-token-large)}.notice-content:only-of-type{padding-block:var(--calcite-notice-spacing-token-small);padding-inline:var(--calcite-notice-spacing-token-large)}.notice-icon{display:flex;align-items:center;box-sizing:border-box;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;padding-block:var(--calcite-notice-spacing-token-small);padding-inline:var(--calcite-notice-spacing-token-large);flex:0 0 auto}.notice-close{display:flex;cursor:pointer;align-items:center;align-self:stretch;border-style:none;background-color:transparent;color:var(--calcite-ui-text-3);outline:2px solid transparent;outline-offset:2px;box-sizing:border-box;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;padding-block:var(--calcite-notice-spacing-token-small);padding-inline:var(--calcite-notice-spacing-token-large);flex:0 0 auto;-webkit-appearance:none}.notice-close:hover,.notice-close:focus{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}.notice-close:active{background-color:var(--calcite-ui-foreground-3)}.actions-end{display:flex;align-self:stretch}:host([kind=brand]) .container{border-color:var(--calcite-ui-brand)}:host([kind=brand]) .container .notice-icon{color:var(--calcite-ui-brand)}:host([kind=info]) .container{border-color:var(--calcite-ui-info)}:host([kind=info]) .container .notice-icon{color:var(--calcite-ui-info)}:host([kind=danger]) .container{border-color:var(--calcite-ui-danger)}:host([kind=danger]) .container .notice-icon{color:var(--calcite-ui-danger)}:host([kind=success]) .container{border-color:var(--calcite-ui-success)}:host([kind=success]) .container .notice-icon{color:var(--calcite-ui-success)}:host([kind=warning]) .container{border-color:var(--calcite-ui-warning)}:host([kind=warning]) .container .notice-icon{color:var(--calcite-ui-warning)}:host([hidden]){display:none}[hidden]{display:none}";
|
284
|
+
|
285
|
+
const Notice = class {
|
286
|
+
constructor(hostRef) {
|
287
|
+
index.registerInstance(this, hostRef);
|
288
|
+
this.calciteNoticeClose = index.createEvent(this, "calciteNoticeClose", 6);
|
289
|
+
this.calciteNoticeOpen = index.createEvent(this, "calciteNoticeOpen", 6);
|
290
|
+
//--------------------------------------------------------------------------
|
291
|
+
//
|
292
|
+
// Private Methods
|
293
|
+
//
|
294
|
+
//--------------------------------------------------------------------------
|
295
|
+
this.close = () => {
|
296
|
+
this.open = false;
|
297
|
+
this.calciteNoticeClose.emit();
|
298
|
+
};
|
299
|
+
this.open = false;
|
300
|
+
this.kind = "brand";
|
301
|
+
this.closable = false;
|
302
|
+
this.icon = undefined;
|
303
|
+
this.iconFlipRtl = false;
|
304
|
+
this.scale = "m";
|
305
|
+
this.width = "auto";
|
306
|
+
this.messages = undefined;
|
307
|
+
this.messageOverrides = undefined;
|
308
|
+
this.effectiveLocale = undefined;
|
309
|
+
this.defaultMessages = undefined;
|
310
|
+
}
|
311
|
+
onMessagesChange() {
|
312
|
+
/* wired up by t9n util */
|
313
|
+
}
|
314
|
+
updateRequestedIcon() {
|
315
|
+
this.requestedIcon = dom.setRequestedIcon(resources.KindIcons, this.icon, this.kind);
|
316
|
+
}
|
317
|
+
//--------------------------------------------------------------------------
|
318
|
+
//
|
319
|
+
// Lifecycle
|
320
|
+
//
|
321
|
+
//--------------------------------------------------------------------------
|
322
|
+
connectedCallback() {
|
323
|
+
conditionalSlot.connectConditionalSlotComponent(this);
|
324
|
+
locale.connectLocalized(this);
|
325
|
+
t9n.connectMessages(this);
|
326
|
+
}
|
327
|
+
disconnectedCallback() {
|
328
|
+
conditionalSlot.disconnectConditionalSlotComponent(this);
|
329
|
+
locale.disconnectLocalized(this);
|
330
|
+
t9n.disconnectMessages(this);
|
331
|
+
}
|
332
|
+
async componentWillLoad() {
|
333
|
+
loadable.setUpLoadableComponent(this);
|
334
|
+
this.requestedIcon = dom.setRequestedIcon(resources.KindIcons, this.icon, this.kind);
|
335
|
+
await t9n.setUpMessages(this);
|
336
|
+
}
|
337
|
+
componentDidLoad() {
|
338
|
+
loadable.setComponentLoaded(this);
|
339
|
+
}
|
340
|
+
render() {
|
341
|
+
const { el } = this;
|
342
|
+
const closeButton = (index.h("button", { "aria-label": this.messages.close, class: CSS$1.close, onClick: this.close,
|
343
|
+
// eslint-disable-next-line react/jsx-sort-props
|
344
|
+
ref: (el) => (this.closeButton = el) }, index.h("calcite-icon", { icon: "x", scale: this.scale === "l" ? "m" : "s" })));
|
345
|
+
const hasActionEnd = dom.getSlotted(el, SLOTS.actionsEnd);
|
346
|
+
return (index.h("div", { class: CSS$1.container }, this.requestedIcon ? (index.h("div", { class: CSS$1.icon }, index.h("calcite-icon", { flipRtl: this.iconFlipRtl, icon: this.requestedIcon, scale: this.scale === "l" ? "m" : "s" }))) : null, index.h("div", { class: CSS$1.content }, index.h("slot", { name: SLOTS.title }), index.h("slot", { name: SLOTS.message }), index.h("slot", { name: SLOTS.link })), hasActionEnd ? (index.h("div", { class: CSS$1.actionsEnd }, index.h("slot", { name: SLOTS.actionsEnd }))) : null, this.closable ? closeButton : null));
|
347
|
+
}
|
348
|
+
//--------------------------------------------------------------------------
|
349
|
+
//
|
350
|
+
// Public Methods
|
351
|
+
//
|
352
|
+
//--------------------------------------------------------------------------
|
353
|
+
/** Sets focus on the component's first focusable element. */
|
354
|
+
async setFocus() {
|
355
|
+
await loadable.componentFocusable(this);
|
356
|
+
const noticeLinkEl = this.el.querySelector("calcite-link");
|
357
|
+
if (!this.closeButton && !noticeLinkEl) {
|
358
|
+
return;
|
359
|
+
}
|
360
|
+
if (noticeLinkEl) {
|
361
|
+
return noticeLinkEl.setFocus();
|
362
|
+
}
|
363
|
+
else if (this.closeButton) {
|
364
|
+
this.closeButton.focus();
|
365
|
+
}
|
366
|
+
}
|
367
|
+
effectiveLocaleChange() {
|
368
|
+
t9n.updateMessages(this, this.effectiveLocale);
|
369
|
+
}
|
370
|
+
static get assetsDirs() { return ["assets"]; }
|
371
|
+
get el() { return index.getElement(this); }
|
372
|
+
static get watchers() { return {
|
373
|
+
"messageOverrides": ["onMessagesChange"],
|
374
|
+
"icon": ["updateRequestedIcon"],
|
375
|
+
"kind": ["updateRequestedIcon"],
|
376
|
+
"effectiveLocale": ["effectiveLocaleChange"]
|
377
|
+
}; }
|
378
|
+
};
|
379
|
+
Notice.style = noticeCss;
|
380
|
+
|
381
|
+
/*!
|
382
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
383
|
+
* See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
|
384
|
+
* v1.6.1
|
385
|
+
*/
|
386
|
+
const CSS = {
|
387
|
+
container: "container",
|
388
|
+
};
|
389
|
+
const TOOLTIP_OPEN_DELAY_MS = 300;
|
390
|
+
const TOOLTIP_CLOSE_DELAY_MS = 500;
|
391
|
+
const ARIA_DESCRIBED_BY = "aria-describedby";
|
392
|
+
|
393
|
+
/*!
|
394
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
395
|
+
* See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
|
396
|
+
* v1.6.1
|
397
|
+
*/
|
398
|
+
function getEffectiveReferenceElement(tooltip) {
|
399
|
+
const { referenceElement } = tooltip;
|
400
|
+
return ((typeof referenceElement === "string" ? dom.queryElementRoots(tooltip, { id: referenceElement }) : referenceElement) ||
|
401
|
+
null);
|
402
|
+
}
|
403
|
+
|
404
|
+
/*!
|
405
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
406
|
+
* See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
|
407
|
+
* v1.6.1
|
408
|
+
*/
|
409
|
+
class TooltipManager {
|
410
|
+
constructor() {
|
411
|
+
// --------------------------------------------------------------------------
|
412
|
+
//
|
413
|
+
// Private Properties
|
414
|
+
//
|
415
|
+
// --------------------------------------------------------------------------
|
416
|
+
this.registeredElements = new WeakMap();
|
417
|
+
this.registeredShadowRootCounts = new WeakMap();
|
418
|
+
this.hoverOpenTimeout = null;
|
419
|
+
this.hoverCloseTimeout = null;
|
420
|
+
this.hoveredTooltip = null;
|
421
|
+
this.clickedTooltip = null;
|
422
|
+
this.activeTooltip = null;
|
423
|
+
this.registeredElementCount = 0;
|
424
|
+
// --------------------------------------------------------------------------
|
425
|
+
//
|
426
|
+
// Private Methods
|
427
|
+
//
|
428
|
+
// --------------------------------------------------------------------------
|
429
|
+
this.queryTooltip = (composedPath) => {
|
430
|
+
const { registeredElements } = this;
|
431
|
+
const registeredElement = composedPath.find((pathEl) => registeredElements.has(pathEl));
|
432
|
+
return registeredElements.get(registeredElement);
|
433
|
+
};
|
434
|
+
this.keyDownHandler = (event) => {
|
435
|
+
if (event.key === "Escape" && !event.defaultPrevented) {
|
436
|
+
const { activeTooltip } = this;
|
437
|
+
if (activeTooltip?.open) {
|
438
|
+
this.clearHoverTimeout();
|
439
|
+
this.closeActiveTooltip();
|
440
|
+
const referenceElement = getEffectiveReferenceElement(activeTooltip);
|
441
|
+
if (referenceElement instanceof Element && referenceElement.contains(event.target)) {
|
442
|
+
event.preventDefault();
|
443
|
+
}
|
444
|
+
}
|
445
|
+
}
|
446
|
+
};
|
447
|
+
this.pointerMoveHandler = (event) => {
|
448
|
+
const composedPath = event.composedPath();
|
449
|
+
const { activeTooltip } = this;
|
450
|
+
const hoveringActiveTooltip = activeTooltip?.open && composedPath.includes(activeTooltip);
|
451
|
+
if (hoveringActiveTooltip) {
|
452
|
+
this.clearHoverTimeout();
|
453
|
+
return;
|
454
|
+
}
|
455
|
+
const tooltip = this.queryTooltip(composedPath);
|
456
|
+
this.hoveredTooltip = tooltip;
|
457
|
+
if (this.isClosableClickedTooltip(tooltip)) {
|
458
|
+
return;
|
459
|
+
}
|
460
|
+
this.clickedTooltip = null;
|
461
|
+
if (tooltip) {
|
462
|
+
this.openHoveredTooltip(tooltip);
|
463
|
+
}
|
464
|
+
else if (activeTooltip) {
|
465
|
+
this.closeHoveredTooltip();
|
466
|
+
}
|
467
|
+
};
|
468
|
+
this.pointerDownHandler = (event) => {
|
469
|
+
if (!dom.isPrimaryPointerButton(event)) {
|
470
|
+
return;
|
471
|
+
}
|
472
|
+
const clickedTooltip = this.queryTooltip(event.composedPath());
|
473
|
+
this.clickedTooltip = clickedTooltip;
|
474
|
+
if (clickedTooltip?.closeOnClick) {
|
475
|
+
this.toggleTooltip(clickedTooltip, false);
|
476
|
+
this.clearHoverTimeout();
|
477
|
+
}
|
478
|
+
};
|
479
|
+
this.focusInHandler = (event) => {
|
480
|
+
this.queryFocusedTooltip(event, true);
|
481
|
+
};
|
482
|
+
this.focusOutHandler = (event) => {
|
483
|
+
this.queryFocusedTooltip(event, false);
|
484
|
+
};
|
485
|
+
this.openHoveredTooltip = (tooltip) => {
|
486
|
+
this.hoverOpenTimeout = window.setTimeout(() => {
|
487
|
+
if (this.hoverOpenTimeout === null) {
|
488
|
+
return;
|
489
|
+
}
|
490
|
+
this.clearHoverCloseTimeout();
|
491
|
+
if (this.activeTooltip === this.hoveredTooltip) {
|
492
|
+
return;
|
493
|
+
}
|
494
|
+
this.closeActiveTooltip();
|
495
|
+
if (tooltip !== this.hoveredTooltip) {
|
496
|
+
return;
|
497
|
+
}
|
498
|
+
this.toggleTooltip(tooltip, true);
|
499
|
+
}, this.activeTooltip ? 0 : TOOLTIP_OPEN_DELAY_MS);
|
500
|
+
};
|
501
|
+
this.closeHoveredTooltip = () => {
|
502
|
+
this.hoverCloseTimeout = window.setTimeout(() => {
|
503
|
+
if (this.hoverCloseTimeout === null) {
|
504
|
+
return;
|
505
|
+
}
|
506
|
+
this.closeActiveTooltip();
|
507
|
+
}, TOOLTIP_CLOSE_DELAY_MS);
|
508
|
+
};
|
509
|
+
}
|
510
|
+
// --------------------------------------------------------------------------
|
511
|
+
//
|
512
|
+
// Public Methods
|
513
|
+
//
|
514
|
+
// --------------------------------------------------------------------------
|
515
|
+
registerElement(referenceEl, tooltip) {
|
516
|
+
this.registeredElementCount++;
|
517
|
+
this.registeredElements.set(referenceEl, tooltip);
|
518
|
+
const shadowRoot = this.getReferenceElShadowRootNode(referenceEl);
|
519
|
+
if (shadowRoot) {
|
520
|
+
this.registerShadowRoot(shadowRoot);
|
521
|
+
}
|
522
|
+
if (this.registeredElementCount === 1) {
|
523
|
+
this.addListeners();
|
524
|
+
}
|
525
|
+
}
|
526
|
+
unregisterElement(referenceEl) {
|
527
|
+
const shadowRoot = this.getReferenceElShadowRootNode(referenceEl);
|
528
|
+
if (shadowRoot) {
|
529
|
+
this.unregisterShadowRoot(shadowRoot);
|
530
|
+
}
|
531
|
+
if (this.registeredElements.delete(referenceEl)) {
|
532
|
+
this.registeredElementCount--;
|
533
|
+
}
|
534
|
+
if (this.registeredElementCount === 0) {
|
535
|
+
this.removeListeners();
|
536
|
+
}
|
537
|
+
}
|
538
|
+
addShadowListeners(shadowRoot) {
|
539
|
+
shadowRoot.addEventListener("focusin", this.focusInHandler, { capture: true });
|
540
|
+
shadowRoot.addEventListener("focusout", this.focusOutHandler, { capture: true });
|
541
|
+
}
|
542
|
+
removeShadowListeners(shadowRoot) {
|
543
|
+
shadowRoot.removeEventListener("focusin", this.focusInHandler, { capture: true });
|
544
|
+
shadowRoot.removeEventListener("focusout", this.focusOutHandler, { capture: true });
|
545
|
+
}
|
546
|
+
addListeners() {
|
547
|
+
document.addEventListener("keydown", this.keyDownHandler, { capture: true });
|
548
|
+
document.addEventListener("pointermove", this.pointerMoveHandler, { capture: true });
|
549
|
+
document.addEventListener("pointerdown", this.pointerDownHandler, { capture: true });
|
550
|
+
document.addEventListener("focusin", this.focusInHandler, { capture: true });
|
551
|
+
document.addEventListener("focusout", this.focusOutHandler, { capture: true });
|
552
|
+
}
|
553
|
+
removeListeners() {
|
554
|
+
document.removeEventListener("keydown", this.keyDownHandler, { capture: true });
|
555
|
+
document.removeEventListener("pointermove", this.pointerMoveHandler, { capture: true });
|
556
|
+
document.removeEventListener("pointerdown", this.pointerDownHandler, { capture: true });
|
557
|
+
document.removeEventListener("focusin", this.focusInHandler, { capture: true });
|
558
|
+
document.removeEventListener("focusout", this.focusOutHandler, { capture: true });
|
559
|
+
}
|
560
|
+
clearHoverOpenTimeout() {
|
561
|
+
window.clearTimeout(this.hoverOpenTimeout);
|
562
|
+
this.hoverOpenTimeout = null;
|
563
|
+
}
|
564
|
+
clearHoverCloseTimeout() {
|
565
|
+
window.clearTimeout(this.hoverCloseTimeout);
|
566
|
+
this.hoverCloseTimeout = null;
|
567
|
+
}
|
568
|
+
clearHoverTimeout() {
|
569
|
+
this.clearHoverOpenTimeout();
|
570
|
+
this.clearHoverCloseTimeout();
|
571
|
+
}
|
572
|
+
closeActiveTooltip() {
|
573
|
+
const { activeTooltip } = this;
|
574
|
+
if (activeTooltip?.open) {
|
575
|
+
this.toggleTooltip(activeTooltip, false);
|
576
|
+
}
|
577
|
+
}
|
578
|
+
toggleFocusedTooltip(tooltip, open) {
|
579
|
+
this.closeActiveTooltip();
|
580
|
+
if (open) {
|
581
|
+
this.clearHoverTimeout();
|
582
|
+
}
|
583
|
+
this.toggleTooltip(tooltip, open);
|
584
|
+
}
|
585
|
+
toggleTooltip(tooltip, open) {
|
586
|
+
tooltip.open = open;
|
587
|
+
this.activeTooltip = open ? tooltip : null;
|
588
|
+
}
|
589
|
+
queryFocusedTooltip(event, open) {
|
590
|
+
const tooltip = this.queryTooltip(event.composedPath());
|
591
|
+
if (!tooltip || this.isClosableClickedTooltip(tooltip)) {
|
592
|
+
return;
|
593
|
+
}
|
594
|
+
this.toggleFocusedTooltip(tooltip, open);
|
595
|
+
}
|
596
|
+
isClosableClickedTooltip(tooltip) {
|
597
|
+
return tooltip?.closeOnClick && tooltip === this.clickedTooltip;
|
598
|
+
}
|
599
|
+
registerShadowRoot(shadowRoot) {
|
600
|
+
const { registeredShadowRootCounts } = this;
|
601
|
+
const newCount = (registeredShadowRootCounts.get(shadowRoot) ?? 0) + 1;
|
602
|
+
if (newCount === 1) {
|
603
|
+
this.addShadowListeners(shadowRoot);
|
604
|
+
}
|
605
|
+
registeredShadowRootCounts.set(shadowRoot, newCount);
|
606
|
+
}
|
607
|
+
unregisterShadowRoot(shadowRoot) {
|
608
|
+
const { registeredShadowRootCounts } = this;
|
609
|
+
const newCount = registeredShadowRootCounts.get(shadowRoot) - 1;
|
610
|
+
if (newCount === 0) {
|
611
|
+
this.removeShadowListeners(shadowRoot);
|
612
|
+
}
|
613
|
+
registeredShadowRootCounts.set(shadowRoot, newCount);
|
614
|
+
}
|
615
|
+
getReferenceElShadowRootNode(referenceEl) {
|
616
|
+
return referenceEl instanceof Element ? dom.getShadowRootNode(referenceEl) : null;
|
617
|
+
}
|
618
|
+
}
|
619
|
+
|
620
|
+
const tooltipCss = ":host{--calcite-floating-ui-z-index:var(--calcite-tooltip-z-index, var(--calcite-app-z-index-tooltip));display:block;position:absolute;z-index:var(--calcite-floating-ui-z-index)}.calcite-floating-ui-anim{position:relative;transition:var(--calcite-floating-ui-transition);transition-property:transform, visibility, opacity;opacity:0;box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);z-index:var(--calcite-app-z-index);border-radius:0.25rem}:host([data-placement^=bottom]) .calcite-floating-ui-anim{transform:translateY(-5px)}:host([data-placement^=top]) .calcite-floating-ui-anim{transform:translateY(5px)}:host([data-placement^=left]) .calcite-floating-ui-anim{transform:translateX(5px)}:host([data-placement^=right]) .calcite-floating-ui-anim{transform:translateX(-5px)}:host([data-placement]) .calcite-floating-ui-anim--active{opacity:1;transform:translate(0)}:host([calcite-hydrated-hidden]){visibility:hidden !important;pointer-events:none}.calcite-floating-ui-arrow{pointer-events:none;position:absolute;z-index:calc(var(--calcite-app-z-index) * -1);fill:var(--calcite-ui-foreground-1)}.calcite-floating-ui-arrow__stroke{stroke:var(--calcite-ui-border-3)}.container{position:relative;overflow:hidden;border-radius:0.25rem;padding-block:0.75rem;padding-inline:1rem;font-size:var(--calcite-font-size--2);line-height:1.375;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1);max-inline-size:20rem;max-block-size:20rem;text-align:start}.calcite-floating-ui-anim{border-radius:0.25rem;border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);background-color:var(--calcite-ui-foreground-1)}.arrow::before{outline:1px solid var(--calcite-ui-border-3)}:host([hidden]){display:none}[hidden]{display:none}";
|
621
|
+
|
622
|
+
const manager = new TooltipManager();
|
623
|
+
const Tooltip = class {
|
624
|
+
constructor(hostRef) {
|
625
|
+
index.registerInstance(this, hostRef);
|
626
|
+
this.calciteTooltipBeforeClose = index.createEvent(this, "calciteTooltipBeforeClose", 6);
|
627
|
+
this.calciteTooltipClose = index.createEvent(this, "calciteTooltipClose", 6);
|
628
|
+
this.calciteTooltipBeforeOpen = index.createEvent(this, "calciteTooltipBeforeOpen", 6);
|
629
|
+
this.calciteTooltipOpen = index.createEvent(this, "calciteTooltipOpen", 6);
|
630
|
+
this.guid = `calcite-tooltip-${guid.guid()}`;
|
631
|
+
this.hasLoaded = false;
|
632
|
+
this.openTransitionProp = "opacity";
|
633
|
+
this.setTransitionEl = (el) => {
|
634
|
+
this.transitionEl = el;
|
635
|
+
};
|
636
|
+
this.setUpReferenceElement = (warn = true) => {
|
637
|
+
this.removeReferences();
|
638
|
+
this.effectiveReferenceElement = getEffectiveReferenceElement(this.el);
|
639
|
+
floatingUi.connectFloatingUI(this, this.effectiveReferenceElement, this.el);
|
640
|
+
const { el, referenceElement, effectiveReferenceElement } = this;
|
641
|
+
if (warn && referenceElement && !effectiveReferenceElement) {
|
642
|
+
console.warn(`${el.tagName}: reference-element id "${referenceElement}" was not found.`, {
|
643
|
+
el,
|
644
|
+
});
|
645
|
+
}
|
646
|
+
this.addReferences();
|
647
|
+
};
|
648
|
+
this.getId = () => {
|
649
|
+
return this.el.id || this.guid;
|
650
|
+
};
|
651
|
+
this.addReferences = () => {
|
652
|
+
const { effectiveReferenceElement } = this;
|
653
|
+
if (!effectiveReferenceElement) {
|
654
|
+
return;
|
655
|
+
}
|
656
|
+
const id = this.getId();
|
657
|
+
if ("setAttribute" in effectiveReferenceElement) {
|
658
|
+
effectiveReferenceElement.setAttribute(ARIA_DESCRIBED_BY, id);
|
659
|
+
}
|
660
|
+
manager.registerElement(effectiveReferenceElement, this.el);
|
661
|
+
};
|
662
|
+
this.removeReferences = () => {
|
663
|
+
const { effectiveReferenceElement } = this;
|
664
|
+
if (!effectiveReferenceElement) {
|
665
|
+
return;
|
666
|
+
}
|
667
|
+
if ("removeAttribute" in effectiveReferenceElement) {
|
668
|
+
effectiveReferenceElement.removeAttribute(ARIA_DESCRIBED_BY);
|
669
|
+
}
|
670
|
+
manager.unregisterElement(effectiveReferenceElement);
|
671
|
+
};
|
672
|
+
this.closeOnClick = false;
|
673
|
+
this.label = undefined;
|
674
|
+
this.offsetDistance = floatingUi.defaultOffsetDistance;
|
675
|
+
this.offsetSkidding = 0;
|
676
|
+
this.open = false;
|
677
|
+
this.overlayPositioning = "absolute";
|
678
|
+
this.placement = "auto";
|
679
|
+
this.referenceElement = undefined;
|
680
|
+
this.effectiveReferenceElement = undefined;
|
681
|
+
this.floatingLayout = "vertical";
|
682
|
+
}
|
683
|
+
offsetDistanceOffsetHandler() {
|
684
|
+
this.reposition(true);
|
685
|
+
}
|
686
|
+
offsetSkiddingHandler() {
|
687
|
+
this.reposition(true);
|
688
|
+
}
|
689
|
+
openHandler(value) {
|
690
|
+
openCloseComponent.onToggleOpenCloseComponent(this);
|
691
|
+
if (value) {
|
692
|
+
this.reposition(true);
|
693
|
+
}
|
694
|
+
}
|
695
|
+
overlayPositioningHandler() {
|
696
|
+
this.reposition(true);
|
697
|
+
}
|
698
|
+
placementHandler() {
|
699
|
+
this.reposition(true);
|
700
|
+
}
|
701
|
+
referenceElementHandler() {
|
702
|
+
this.setUpReferenceElement();
|
703
|
+
}
|
704
|
+
// --------------------------------------------------------------------------
|
705
|
+
//
|
706
|
+
// Lifecycle
|
707
|
+
//
|
708
|
+
// --------------------------------------------------------------------------
|
709
|
+
connectedCallback() {
|
710
|
+
this.setUpReferenceElement(this.hasLoaded);
|
711
|
+
if (this.open) {
|
712
|
+
openCloseComponent.onToggleOpenCloseComponent(this);
|
713
|
+
}
|
714
|
+
}
|
715
|
+
async componentWillLoad() {
|
716
|
+
if (this.open) {
|
717
|
+
openCloseComponent.onToggleOpenCloseComponent(this);
|
718
|
+
}
|
719
|
+
}
|
720
|
+
componentDidLoad() {
|
721
|
+
if (this.referenceElement && !this.effectiveReferenceElement) {
|
722
|
+
this.setUpReferenceElement();
|
723
|
+
}
|
724
|
+
this.reposition(true);
|
725
|
+
this.hasLoaded = true;
|
726
|
+
}
|
727
|
+
disconnectedCallback() {
|
728
|
+
this.removeReferences();
|
729
|
+
floatingUi.disconnectFloatingUI(this, this.effectiveReferenceElement, this.el);
|
730
|
+
}
|
731
|
+
// --------------------------------------------------------------------------
|
732
|
+
//
|
733
|
+
// Public Methods
|
734
|
+
//
|
735
|
+
// --------------------------------------------------------------------------
|
736
|
+
/**
|
737
|
+
* Updates the position of the component.
|
738
|
+
*
|
739
|
+
* @param delayed
|
740
|
+
*/
|
741
|
+
async reposition(delayed = false) {
|
742
|
+
const { el, effectiveReferenceElement, placement, overlayPositioning, offsetDistance, offsetSkidding, arrowEl, } = this;
|
743
|
+
return floatingUi.reposition(this, {
|
744
|
+
floatingEl: el,
|
745
|
+
referenceEl: effectiveReferenceElement,
|
746
|
+
overlayPositioning,
|
747
|
+
placement,
|
748
|
+
offsetDistance,
|
749
|
+
offsetSkidding,
|
750
|
+
arrowEl,
|
751
|
+
type: "tooltip",
|
752
|
+
}, delayed);
|
753
|
+
}
|
754
|
+
// --------------------------------------------------------------------------
|
755
|
+
//
|
756
|
+
// Private Methods
|
757
|
+
//
|
758
|
+
// --------------------------------------------------------------------------
|
759
|
+
onBeforeOpen() {
|
760
|
+
this.calciteTooltipBeforeOpen.emit();
|
761
|
+
}
|
762
|
+
onOpen() {
|
763
|
+
this.calciteTooltipOpen.emit();
|
764
|
+
}
|
765
|
+
onBeforeClose() {
|
766
|
+
this.calciteTooltipBeforeClose.emit();
|
767
|
+
}
|
768
|
+
onClose() {
|
769
|
+
this.calciteTooltipClose.emit();
|
770
|
+
}
|
771
|
+
// --------------------------------------------------------------------------
|
772
|
+
//
|
773
|
+
// Render Methods
|
774
|
+
//
|
775
|
+
// --------------------------------------------------------------------------
|
776
|
+
render() {
|
777
|
+
const { effectiveReferenceElement, label, open, floatingLayout } = this;
|
778
|
+
const displayed = effectiveReferenceElement && open;
|
779
|
+
const hidden = !displayed;
|
780
|
+
return (index.h(index.Host, { "aria-hidden": dom.toAriaBoolean(hidden), "aria-label": label, "aria-live": "polite", "calcite-hydrated-hidden": hidden, id: this.getId(), role: "tooltip" }, index.h("div", { class: {
|
781
|
+
[floatingUi.FloatingCSS.animation]: true,
|
782
|
+
[floatingUi.FloatingCSS.animationActive]: displayed,
|
783
|
+
},
|
784
|
+
// eslint-disable-next-line react/jsx-sort-props
|
785
|
+
ref: this.setTransitionEl }, index.h(FloatingArrow.FloatingArrow, { floatingLayout: floatingLayout,
|
786
|
+
// eslint-disable-next-line react/jsx-sort-props
|
787
|
+
ref: (arrowEl) => (this.arrowEl = arrowEl) }), index.h("div", { class: CSS.container }, index.h("slot", null)))));
|
788
|
+
}
|
789
|
+
get el() { return index.getElement(this); }
|
790
|
+
static get watchers() { return {
|
791
|
+
"offsetDistance": ["offsetDistanceOffsetHandler"],
|
792
|
+
"offsetSkidding": ["offsetSkiddingHandler"],
|
793
|
+
"open": ["openHandler"],
|
794
|
+
"overlayPositioning": ["overlayPositioningHandler"],
|
795
|
+
"placement": ["placementHandler"],
|
796
|
+
"referenceElement": ["referenceElementHandler"]
|
797
|
+
}; }
|
798
|
+
};
|
799
|
+
Tooltip.style = tooltipCss;
|
800
|
+
|
801
|
+
exports.calcite_chip = Chip;
|
802
|
+
exports.calcite_notice = Notice;
|
803
|
+
exports.calcite_tooltip = Tooltip;
|