@esri/solutions-components 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/buffer-tools_6.cjs.entry.js +26 -8
- package/dist/cjs/calcite-combobox_3.cjs.entry.js +2 -2
- package/dist/cjs/calcite-input-message_5.cjs.entry.js +6 -4
- package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
- package/dist/cjs/{csvUtils-83af7ae1.js → csvUtils-34666909.js} +1 -1
- package/dist/cjs/{interfaces-772edf61.js → interfaces-17c631bf.js} +1 -1
- package/dist/cjs/layer-table.cjs.entry.js +3 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/map-card.cjs.entry.js +1 -1
- package/dist/cjs/{mapViewUtils-55ac76cb.js → mapViewUtils-24d1d859.js} +1 -1
- package/dist/cjs/public-notification.cjs.entry.js +41 -7
- package/dist/cjs/solution-configuration.cjs.entry.js +2 -2
- package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
- package/dist/cjs/{solution-store-39726b81.js → solution-store-2dbab624.js} +1 -1
- package/dist/cjs/solutions-components.cjs.js +1 -1
- package/dist/collection/components/buffer-tools/buffer-tools.js +48 -0
- package/dist/collection/components/map-draw-tools/map-draw-tools.js +10 -4
- package/dist/collection/components/public-notification/public-notification.css +12 -12
- package/dist/collection/components/public-notification/public-notification.js +50 -4
- package/dist/collection/components/refine-selection/refine-selection.js +4 -2
- package/dist/collection/components/refine-selection-tools/refine-selection-tools.css +1 -0
- package/dist/collection/components/refine-selection-tools/refine-selection-tools.js +3 -1
- package/dist/collection/demos/new-public-notification.html +7 -6
- package/dist/collection/utils/interfaces.js +1 -1
- package/dist/collection/utils/interfaces.ts +7 -2
- package/dist/components/buffer-tools2.js +10 -0
- package/dist/components/interfaces3.js +1 -1
- package/dist/components/map-draw-tools2.js +10 -4
- package/dist/components/public-notification.js +40 -6
- package/dist/components/refine-selection-tools2.js +4 -2
- package/dist/components/refine-selection2.js +4 -2
- package/dist/esm/buffer-tools_6.entry.js +26 -8
- package/dist/esm/calcite-combobox_3.entry.js +2 -2
- package/dist/esm/calcite-input-message_5.entry.js +6 -4
- package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
- package/dist/esm/{csvUtils-eb231cfb.js → csvUtils-ae3004b9.js} +1 -1
- package/dist/esm/{interfaces-3b23a5f9.js → interfaces-d0d83efa.js} +1 -1
- package/dist/esm/layer-table.entry.js +3 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/map-card.entry.js +1 -1
- package/dist/esm/{mapViewUtils-e5d8a1e1.js → mapViewUtils-541e7a3c.js} +1 -1
- package/dist/esm/public-notification.entry.js +41 -7
- package/dist/esm/solution-configuration.entry.js +2 -2
- package/dist/esm/solution-contents_3.entry.js +2 -2
- package/dist/esm/{solution-store-c0bf9200.js → solution-store-41e15f1c.js} +1 -1
- package/dist/esm/solutions-components.js +1 -1
- package/dist/solutions-components/demos/new-public-notification.html +7 -6
- package/dist/solutions-components/p-05e64bd1.js +498 -2
- package/dist/solutions-components/p-08a95b33.entry.js +138 -0
- package/dist/solutions-components/p-0da5bbdf.entry.js +91 -0
- package/dist/solutions-components/p-0ef91144.entry.js +913 -0
- package/dist/solutions-components/p-0f523243.entry.js +1916 -0
- package/dist/solutions-components/p-11b9510e.entry.js +173 -0
- package/dist/solutions-components/p-1b875d94.entry.js +58 -0
- package/dist/solutions-components/p-1c567f3a.js +23 -16
- package/dist/solutions-components/p-1c883db9.entry.js +43 -0
- package/dist/solutions-components/p-1f225056.js +322 -0
- package/dist/solutions-components/p-1f499e67.entry.js +72 -0
- package/dist/solutions-components/p-20d3d758.entry.js +881 -0
- package/dist/solutions-components/p-2274ac9e.entry.js +160 -0
- package/dist/solutions-components/p-23ec5ac5.entry.js +93 -0
- package/dist/solutions-components/p-2447798c.entry.js +155 -0
- package/dist/solutions-components/p-2525e691.entry.js +432 -0
- package/dist/solutions-components/p-2561f5b5.js +4092 -0
- package/dist/solutions-components/p-29f887c0.entry.js +234 -0
- package/dist/solutions-components/p-2a0d8047.entry.js +345 -0
- package/dist/solutions-components/p-2c177e6a.entry.js +101 -0
- package/dist/solutions-components/p-2e9ed892.js +46 -1
- package/dist/solutions-components/p-316f56db.js +219 -2
- package/dist/solutions-components/p-327f3ebf.entry.js +98 -0
- package/dist/solutions-components/p-356f8b54.entry.js +138 -0
- package/dist/solutions-components/p-359c58de.entry.js +172 -0
- package/dist/solutions-components/p-37336c0d.entry.js +116 -0
- package/dist/solutions-components/p-374a5031.js +105 -2
- package/dist/solutions-components/p-39ea6ef4.entry.js +71 -0
- package/dist/solutions-components/p-3b010ce1.js +17 -1
- package/dist/solutions-components/p-4307dacd.js +194 -1
- package/dist/solutions-components/p-44da2507.js +405 -14
- package/dist/solutions-components/p-46bdffe8.entry.js +54 -0
- package/dist/solutions-components/p-4894bbeb.js +53 -2
- package/dist/solutions-components/p-4cd569f1.entry.js +1298 -0
- package/dist/solutions-components/p-4d4160f9.entry.js +121 -0
- package/dist/solutions-components/p-4e32bf8c.js +482 -1
- package/dist/solutions-components/p-4e9cbd32.entry.js +184 -0
- package/dist/solutions-components/p-508317b3.js +13 -2
- package/dist/solutions-components/p-54697d58.entry.js +198 -0
- package/dist/solutions-components/p-55c79103.entry.js +311 -0
- package/dist/solutions-components/p-57fd19c0.entry.js +706 -0
- package/dist/solutions-components/p-59b48fde.entry.js +443 -0
- package/dist/solutions-components/p-60e0e6a0.entry.js +214 -0
- package/dist/solutions-components/p-621d0534.entry.js +123 -0
- package/dist/solutions-components/p-63f6e8f1.js +14 -1
- package/dist/solutions-components/p-66aeec57.entry.js +61 -0
- package/dist/solutions-components/p-69834f46.entry.js +618 -0
- package/dist/solutions-components/p-6d9da8e5.entry.js +21530 -0
- package/dist/solutions-components/p-6e0da576.js +13 -1
- package/dist/solutions-components/p-6ec3f294.entry.js +106 -0
- package/dist/solutions-components/p-6fe17794.js +9 -1
- package/dist/solutions-components/p-7024cb16.entry.js +72 -0
- package/dist/solutions-components/p-70535506.entry.js +226 -0
- package/dist/solutions-components/p-708a63a8.js +12 -1
- package/dist/solutions-components/p-729708a3.js +14 -1
- package/dist/solutions-components/p-73e23995.js +6 -1
- package/dist/solutions-components/p-74b29d75.entry.js +231 -0
- package/dist/solutions-components/p-74b7ee25.entry.js +711 -0
- package/dist/solutions-components/p-77182c3a.js +3015 -1
- package/dist/solutions-components/p-78b3ef80.entry.js +456 -0
- package/dist/solutions-components/p-79709c19.js +60 -3
- package/dist/solutions-components/p-7a46ef97.js +181 -2
- package/dist/solutions-components/p-7be159e6.entry.js +175 -0
- package/dist/solutions-components/p-7d4451c2.entry.js +71 -0
- package/dist/solutions-components/p-7daea1df.js +41 -1
- package/dist/solutions-components/p-7e39e5ad.entry.js +102 -0
- package/dist/solutions-components/p-7fb45059.entry.js +43 -0
- package/dist/solutions-components/p-815533de.js +306 -3
- package/dist/solutions-components/p-816622ca.entry.js +248 -0
- package/dist/solutions-components/p-83166522.js +205 -2
- package/dist/solutions-components/p-83bd1991.entry.js +36 -0
- package/dist/solutions-components/p-856464d7.entry.js +572 -0
- package/dist/solutions-components/p-8c349bad.entry.js +347 -0
- package/dist/solutions-components/p-8dccb390.entry.js +1986 -0
- package/dist/solutions-components/p-904c185a.entry.js +228 -0
- package/dist/solutions-components/p-9092f8b3.entry.js +156 -0
- package/dist/solutions-components/p-9371145a.entry.js +477 -0
- package/dist/solutions-components/p-93d3119d.js +1948 -1
- package/dist/solutions-components/p-95ec8062.entry.js +173 -0
- package/dist/solutions-components/p-991ee695.js +109 -1
- package/dist/solutions-components/p-9a57dab7.entry.js +213 -0
- package/dist/solutions-components/p-9a9955db.js +41 -1
- package/dist/solutions-components/p-9c1ebc90.js +35 -16
- package/dist/solutions-components/p-9eba5c66.js +399 -3
- package/dist/solutions-components/p-a033a507.entry.js +252 -0
- package/dist/solutions-components/p-a3773415.entry.js +1132 -0
- package/dist/solutions-components/p-a44fe40f.entry.js +94 -0
- package/dist/solutions-components/p-a5b1ab03.js +33 -3
- package/dist/solutions-components/p-a5b2c13d.entry.js +723 -0
- package/dist/solutions-components/p-a6d729b7.entry.js +85 -0
- package/dist/solutions-components/p-a8005026.entry.js +565 -0
- package/dist/solutions-components/p-a80b3880.js +14 -1
- package/dist/solutions-components/p-a89198a3.entry.js +2620 -0
- package/dist/solutions-components/p-aa04bd1f.entry.js +95 -0
- package/dist/solutions-components/p-aa0a0922.entry.js +80 -0
- package/dist/solutions-components/p-ae1fd76b.js +11 -1
- package/dist/solutions-components/p-b2cf435e.entry.js +87 -0
- package/dist/solutions-components/p-b359dc78.js +41 -1
- package/dist/solutions-components/p-b57bc4eb.entry.js +71 -0
- package/dist/solutions-components/p-b75cc407.entry.js +145 -0
- package/dist/solutions-components/p-b911cb75.entry.js +71 -0
- package/dist/solutions-components/p-b965e177.entry.js +335 -0
- package/dist/solutions-components/p-b978636e.js +14 -1
- package/dist/solutions-components/p-ba10a5c8.entry.js +42 -0
- package/dist/solutions-components/p-bd67334c.js +122 -2
- package/dist/solutions-components/p-bde20dba.entry.js +212 -0
- package/dist/solutions-components/p-be0b5a94.entry.js +248 -0
- package/dist/solutions-components/p-c023e6a1.js +2028 -2
- package/dist/solutions-components/p-c27b0c2d.entry.js +150 -0
- package/dist/solutions-components/p-c579ed60.entry.js +447 -0
- package/dist/solutions-components/p-c92bc231.js +101 -2
- package/dist/solutions-components/p-cc815aca.js +839 -16
- package/dist/solutions-components/p-cc8beabb.entry.js +695 -0
- package/dist/solutions-components/p-cdc46c0c.js +1751 -2
- package/dist/solutions-components/p-d12e6992.entry.js +118 -0
- package/dist/solutions-components/p-d1dfed6b.entry.js +179 -0
- package/dist/solutions-components/p-d48a24e6.js +754 -2
- package/dist/solutions-components/p-d96ee3ef.entry.js +579 -0
- package/dist/solutions-components/p-dbc9a5a8.js +80 -0
- package/dist/solutions-components/p-dcdbe712.entry.js +278 -0
- package/dist/solutions-components/p-de39206f.entry.js +113 -0
- package/dist/solutions-components/p-de5416e8.js +28 -1
- package/dist/solutions-components/p-df420d54.entry.js +213 -0
- package/dist/solutions-components/p-e3138cf0.entry.js +20 -0
- package/dist/solutions-components/p-e4845fec.entry.js +152 -0
- package/dist/solutions-components/p-e611d8c8.js +28 -1
- package/dist/solutions-components/p-e947d3b0.js +5 -1
- package/dist/solutions-components/p-ea534300.js +41 -2
- package/dist/solutions-components/p-ec84ee85.entry.js +55 -0
- package/dist/solutions-components/p-ed36c637.entry.js +85 -0
- package/dist/solutions-components/p-f0add71c.js +74 -0
- package/dist/solutions-components/p-f42e014b.js +171 -2
- package/dist/solutions-components/p-fc02e7de.entry.js +308 -0
- package/dist/solutions-components/p-fc884dd6.js +28 -16
- package/dist/solutions-components/p-fcbfa59c.entry.js +181 -0
- package/dist/solutions-components/p-fdc5cf5f.entry.js +138 -0
- package/dist/solutions-components/solutions-components.esm.js +20 -1
- package/dist/solutions-components/utils/interfaces.ts +7 -2
- package/dist/types/components/buffer-tools/buffer-tools.d.ts +9 -1
- package/dist/types/components/public-notification/public-notification.d.ts +26 -0
- package/dist/types/components.d.ts +9 -1
- package/dist/types/preact.d.ts +3 -1
- package/dist/types/utils/interfaces.d.ts +4 -0
- package/package.json +1 -1
- package/dist/solutions-components/p-021432b8.entry.js +0 -12
- package/dist/solutions-components/p-03440b1e.entry.js +0 -11
- package/dist/solutions-components/p-0512635b.entry.js +0 -6
- package/dist/solutions-components/p-086ef115.entry.js +0 -29
- package/dist/solutions-components/p-0b4bf57f.entry.js +0 -6
- package/dist/solutions-components/p-0c088725.entry.js +0 -6
- package/dist/solutions-components/p-0f820c08.entry.js +0 -6
- package/dist/solutions-components/p-164780a0.entry.js +0 -6
- package/dist/solutions-components/p-179a68a0.entry.js +0 -6
- package/dist/solutions-components/p-184b5005.entry.js +0 -11
- package/dist/solutions-components/p-1d082fee.entry.js +0 -11
- package/dist/solutions-components/p-1e6c02a2.entry.js +0 -11
- package/dist/solutions-components/p-20a58e62.entry.js +0 -17
- package/dist/solutions-components/p-20b2458c.entry.js +0 -11
- package/dist/solutions-components/p-245d47c1.entry.js +0 -6
- package/dist/solutions-components/p-2cb057a9.entry.js +0 -11
- package/dist/solutions-components/p-2cc72806.entry.js +0 -23
- package/dist/solutions-components/p-2de1db9c.entry.js +0 -11
- package/dist/solutions-components/p-2e9c7055.entry.js +0 -11
- package/dist/solutions-components/p-2ed5e6c8.entry.js +0 -11
- package/dist/solutions-components/p-3109d940.entry.js +0 -6
- package/dist/solutions-components/p-31a8bcfa.entry.js +0 -6
- package/dist/solutions-components/p-3f88ba73.entry.js +0 -6
- package/dist/solutions-components/p-3fa9b3c8.js +0 -36
- package/dist/solutions-components/p-40c41709.entry.js +0 -6
- package/dist/solutions-components/p-40e963c7.entry.js +0 -11
- package/dist/solutions-components/p-40f480da.entry.js +0 -11
- package/dist/solutions-components/p-49d5d2d3.entry.js +0 -11
- package/dist/solutions-components/p-4f7049a4.entry.js +0 -11
- package/dist/solutions-components/p-506e4d78.entry.js +0 -6
- package/dist/solutions-components/p-576fdcab.entry.js +0 -6
- package/dist/solutions-components/p-5bd0cf34.entry.js +0 -23
- package/dist/solutions-components/p-65e177f1.entry.js +0 -6
- package/dist/solutions-components/p-67d710c2.entry.js +0 -6
- package/dist/solutions-components/p-7268b445.entry.js +0 -11
- package/dist/solutions-components/p-75ea4667.entry.js +0 -6
- package/dist/solutions-components/p-778c0a36.entry.js +0 -17
- package/dist/solutions-components/p-7a22509b.entry.js +0 -12
- package/dist/solutions-components/p-7bff51db.entry.js +0 -6
- package/dist/solutions-components/p-7d2d0d5d.entry.js +0 -6
- package/dist/solutions-components/p-7f0036f1.entry.js +0 -11
- package/dist/solutions-components/p-8060fb94.entry.js +0 -6
- package/dist/solutions-components/p-80a1b305.entry.js +0 -6
- package/dist/solutions-components/p-81eae877.entry.js +0 -12
- package/dist/solutions-components/p-84e86b8b.entry.js +0 -6
- package/dist/solutions-components/p-877dd0dc.entry.js +0 -18
- package/dist/solutions-components/p-9106950a.entry.js +0 -11
- package/dist/solutions-components/p-979804a4.entry.js +0 -11
- package/dist/solutions-components/p-9862baa8.entry.js +0 -11
- package/dist/solutions-components/p-9b5a9117.entry.js +0 -12
- package/dist/solutions-components/p-9deff0c2.entry.js +0 -6
- package/dist/solutions-components/p-9f400eeb.entry.js +0 -6
- package/dist/solutions-components/p-a0639ad1.entry.js +0 -11
- package/dist/solutions-components/p-a33c044e.entry.js +0 -6
- package/dist/solutions-components/p-a516c658.entry.js +0 -6
- package/dist/solutions-components/p-aa0ef36d.entry.js +0 -11
- package/dist/solutions-components/p-aaccbdf3.entry.js +0 -18
- package/dist/solutions-components/p-ab03a5c9.entry.js +0 -11
- package/dist/solutions-components/p-ad469b92.entry.js +0 -11
- package/dist/solutions-components/p-adc86ac3.entry.js +0 -6
- package/dist/solutions-components/p-addc1156.entry.js +0 -11
- package/dist/solutions-components/p-ae846934.entry.js +0 -11
- package/dist/solutions-components/p-b0572fc4.entry.js +0 -37
- package/dist/solutions-components/p-b4e476b7.js +0 -257
- package/dist/solutions-components/p-b668daf8.js +0 -21
- package/dist/solutions-components/p-b6e6eae1.entry.js +0 -6
- package/dist/solutions-components/p-bc317a7f.entry.js +0 -6
- package/dist/solutions-components/p-bd4d0773.entry.js +0 -6
- package/dist/solutions-components/p-be41429f.js +0 -21
- package/dist/solutions-components/p-bf6b6353.entry.js +0 -11
- package/dist/solutions-components/p-c2e3dfbb.entry.js +0 -11
- package/dist/solutions-components/p-c4afae53.entry.js +0 -12
- package/dist/solutions-components/p-c9da1c26.entry.js +0 -6
- package/dist/solutions-components/p-cbf8cd49.entry.js +0 -6
- package/dist/solutions-components/p-cc1a064a.entry.js +0 -11
- package/dist/solutions-components/p-d09a168c.entry.js +0 -6
- package/dist/solutions-components/p-d377f913.entry.js +0 -11
- package/dist/solutions-components/p-d4cefead.entry.js +0 -37
- package/dist/solutions-components/p-d7bc0baf.entry.js +0 -16
- package/dist/solutions-components/p-d8968487.entry.js +0 -11
- package/dist/solutions-components/p-e00a0b86.entry.js +0 -11
- package/dist/solutions-components/p-e9a7ed49.entry.js +0 -11
- package/dist/solutions-components/p-ec27e493.entry.js +0 -11
- package/dist/solutions-components/p-ed6404eb.entry.js +0 -6
- package/dist/solutions-components/p-ef21e195.entry.js +0 -23
- package/dist/solutions-components/p-f6068a2d.entry.js +0 -11
- package/dist/solutions-components/p-f6c4cff3.entry.js +0 -11
- package/dist/solutions-components/p-f847291f.entry.js +0 -6
- package/dist/solutions-components/p-f90fd262.entry.js +0 -11
- package/dist/solutions-components/p-fc973005.entry.js +0 -6
- package/dist/solutions-components/p-ff9fb6bc.entry.js +0 -11
@@ -0,0 +1,2620 @@
|
|
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
|
+
import { r as registerInstance, c as createEvent, h, f as forceUpdate, g as getElement, H as Host, F as Fragment } from './p-c023e6a1.js';
|
7
|
+
import { b as getElementDir, i as isPrimaryPointerButton, a as getSlotted, n as nodeListToArray, j as filterDirectChildren, g as getElementProp, t as toAriaBoolean } from './p-83166522.js';
|
8
|
+
import { c as clamp } from './p-63f6e8f1.js';
|
9
|
+
import { c as connectConditionalSlotComponent, d as disconnectConditionalSlotComponent } from './p-ea534300.js';
|
10
|
+
import { g as guid } from './p-a80b3880.js';
|
11
|
+
import { c as createObserver } from './p-9a9955db.js';
|
12
|
+
import { u as updateHostInteraction } from './p-7daea1df.js';
|
13
|
+
import { S as Sortable } from './p-77182c3a.js';
|
14
|
+
import { o as getItemIndex, m as mutationObserverCallback, d as deselectRemovedItems, a as deselectSiblingItems, s as selectSiblings, h as handleFilter, g as getItemData, k as keyDownHandler, p as moveItemIndex, i as initialize, b as initializeObserver, c as cleanUpObserver, j as calciteListFocusOutHandler, r as removeItem, e as calciteListItemChangeHandler, f as calciteInternalListItemValueChangeHandler, l as setUpItems, n as setFocus, L as List } from './p-815533de.js';
|
15
|
+
import { I as ICON_TYPES$1 } from './p-b978636e.js';
|
16
|
+
import { C as CSS$2, S as SLOTS$3 } from './p-de5416e8.js';
|
17
|
+
import { g as getLocaleComponentStrings } from './p-44da2507.js';
|
18
|
+
import { s as state, E as EFileType } from './p-2561f5b5.js';
|
19
|
+
import { e as EUpdateType } from './p-dbc9a5a8.js';
|
20
|
+
import './p-729708a3.js';
|
21
|
+
import './p-e947d3b0.js';
|
22
|
+
import './p-ae1fd76b.js';
|
23
|
+
import './p-4e32bf8c.js';
|
24
|
+
import './p-3b010ce1.js';
|
25
|
+
import './p-4307dacd.js';
|
26
|
+
|
27
|
+
/*!
|
28
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
29
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
30
|
+
* v1.0.0-beta.97
|
31
|
+
*/
|
32
|
+
const CSS$1 = {
|
33
|
+
container: "container",
|
34
|
+
content: "content",
|
35
|
+
contentHeader: "content__header",
|
36
|
+
contentBody: "content__body",
|
37
|
+
contentDetached: "content--detached",
|
38
|
+
separator: "separator"
|
39
|
+
};
|
40
|
+
const SLOTS$2 = {
|
41
|
+
actionBar: "action-bar",
|
42
|
+
header: "header"
|
43
|
+
};
|
44
|
+
const TEXT = {
|
45
|
+
resize: "Resize"
|
46
|
+
};
|
47
|
+
|
48
|
+
const shellPanelCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{pointer-events:none;display:flex;flex:0 1 auto;align-items:stretch;--calcite-shell-panel-detached-max-height:unset}.container{pointer-events:none;box-sizing:border-box;display:flex;flex:1 1 auto;align-items:stretch;background-color:transparent;font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2)}.container *{box-sizing:border-box}:host(:hover) .separator:not(:hover):not(:focus),:host(:focus-within) .separator:not(:hover):not(:focus){opacity:1;background-color:var(--calcite-ui-border-3)}.separator{pointer-events:auto;position:absolute;inset-block:0px;display:flex;block-size:100%;inline-size:0.125rem;background-color:transparent;opacity:0;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;cursor:col-resize;outline:none}.separator:hover{opacity:1;background-color:var(--calcite-ui-border-2)}.separator:focus{background-color:var(--calcite-ui-brand);opacity:1}:host([position=start]) .separator{inset-inline-end:-2px}:host([position=end]) .separator{inset-inline-start:-2px}::slotted(calcite-panel),::slotted(calcite-flow){block-size:100%;inline-size:100%;flex:1 1 auto;max-block-size:unset;max-inline-size:unset}::slotted(.calcite-match-height){display:flex;flex:1 1 auto;overflow:hidden}.content{pointer-events:auto;display:flex;flex-direction:column;flex-wrap:nowrap;align-items:stretch;align-self:stretch;background-color:var(--calcite-ui-background);padding:0px;inline-size:var(--calcite-shell-panel-width);max-inline-size:var(--calcite-shell-panel-max-width);min-inline-size:var(--calcite-shell-panel-min-width);transition:max-block-size var(--calcite-animation-timing), max-inline-size var(--calcite-animation-timing)}.content__header{display:flex;flex:0 1 auto;flex-direction:column;flex-wrap:nowrap;align-items:stretch}.content__body{display:flex;flex:1 1 auto;flex-direction:column;overflow:hidden}:host([width-scale=s]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 12vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 300px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 150px)}:host([width-scale=m]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 20vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 420px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 240px)}:host([width-scale=l]) .content{--calcite-shell-panel-width:calc(var(--calcite-panel-width-multiplier) * 45vw);--calcite-shell-panel-max-width:calc(var(--calcite-panel-width-multiplier) * 680px);--calcite-shell-panel-min-width:calc(var(--calcite-panel-width-multiplier) * 340px)}:host([detached-height-scale=s]) .content--detached{--calcite-shell-panel-detached-max-height:40vh}:host([detached-height-scale=m]) .content--detached{--calcite-shell-panel-detached-max-height:60vh}:host([detached-height-scale=l]) .content--detached{--calcite-shell-panel-detached-max-height:80vh}.content--detached{margin-inline:0.5rem;margin-block:0.5rem auto;block-size:auto;overflow:hidden;border-radius:0.25rem;--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);max-block-size:var(--calcite-shell-panel-detached-max-height)}.content--detached ::slotted(calcite-panel),.content--detached ::slotted(calcite-flow){max-block-size:unset}:host([position=start]) .content--detached ::slotted(calcite-panel),:host([position=start]) .content--detached ::slotted(calcite-flow),:host([position=end]) .content--detached ::slotted(calcite-panel),:host([position=end]) .content--detached ::slotted(calcite-flow){border-style:none}.content[hidden]{display:none}slot[name=action-bar]::slotted(calcite-action-bar),.content ::slotted(calcite-flow),.content ::slotted(calcite-panel:not([dismissed])){border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3)}:host([position=start]) slot[name=action-bar]::slotted(calcite-action-bar),:host([position=start]) .content ::slotted(calcite-flow),:host([position=start]) .content ::slotted(calcite-panel){-webkit-border-start:none;border-inline-start:none}:host([position=end]) slot[name=action-bar]::slotted(calcite-action-bar),:host([position=end]) .content ::slotted(calcite-flow),:host([position=end]) .content ::slotted(calcite-panel){-webkit-border-end:none;border-inline-end:none}";
|
49
|
+
|
50
|
+
const ShellPanel = class {
|
51
|
+
constructor(hostRef) {
|
52
|
+
registerInstance(this, hostRef);
|
53
|
+
this.calciteShellPanelToggle = createEvent(this, "calciteShellPanelToggle", 6);
|
54
|
+
// --------------------------------------------------------------------------
|
55
|
+
//
|
56
|
+
// Properties
|
57
|
+
//
|
58
|
+
// --------------------------------------------------------------------------
|
59
|
+
/**
|
60
|
+
* When `true`, hides the component's content area.
|
61
|
+
*/
|
62
|
+
this.collapsed = false;
|
63
|
+
/**
|
64
|
+
* When `true`, the content area displays like a floating panel.
|
65
|
+
*/
|
66
|
+
this.detached = false;
|
67
|
+
/**
|
68
|
+
* When `detached`, specifies the maximum height of the component.
|
69
|
+
*/
|
70
|
+
this.detachedHeightScale = "l";
|
71
|
+
/**
|
72
|
+
* Specifies the width of the component's content area.
|
73
|
+
*/
|
74
|
+
this.widthScale = "m";
|
75
|
+
/**
|
76
|
+
* Accessible name for the resize separator.
|
77
|
+
*
|
78
|
+
* @default "Resize"
|
79
|
+
*/
|
80
|
+
this.intlResize = TEXT.resize;
|
81
|
+
/**
|
82
|
+
* When `true` and not `detached`, the component's content area is resizable.
|
83
|
+
*/
|
84
|
+
this.resizable = false;
|
85
|
+
this.contentWidth = null;
|
86
|
+
this.initialContentWidth = null;
|
87
|
+
this.initialClientX = null;
|
88
|
+
this.contentWidthMax = null;
|
89
|
+
this.contentWidthMin = null;
|
90
|
+
this.step = 1;
|
91
|
+
this.stepMultiplier = 10;
|
92
|
+
this.storeContentEl = (contentEl) => {
|
93
|
+
this.contentEl = contentEl;
|
94
|
+
};
|
95
|
+
this.getKeyAdjustedWidth = (event) => {
|
96
|
+
const { key } = event;
|
97
|
+
const { el, step, stepMultiplier, contentWidthMin, contentWidthMax, initialContentWidth, position } = this;
|
98
|
+
const multipliedStep = step * stepMultiplier;
|
99
|
+
const MOVEMENT_KEYS = [
|
100
|
+
"ArrowUp",
|
101
|
+
"ArrowDown",
|
102
|
+
"ArrowLeft",
|
103
|
+
"ArrowRight",
|
104
|
+
"Home",
|
105
|
+
"End",
|
106
|
+
"PageUp",
|
107
|
+
"PageDown"
|
108
|
+
];
|
109
|
+
if (MOVEMENT_KEYS.indexOf(key) > -1) {
|
110
|
+
event.preventDefault();
|
111
|
+
}
|
112
|
+
const dir = getElementDir(el);
|
113
|
+
const directionKeys = ["ArrowLeft", "ArrowRight"];
|
114
|
+
const directionFactor = dir === "rtl" && directionKeys.includes(key) ? -1 : 1;
|
115
|
+
const increaseKeys = key === "ArrowUp" ||
|
116
|
+
(position === "end" ? key === directionKeys[0] : key === directionKeys[1]);
|
117
|
+
if (increaseKeys) {
|
118
|
+
const stepValue = event.shiftKey ? multipliedStep : step;
|
119
|
+
return initialContentWidth + directionFactor * stepValue;
|
120
|
+
}
|
121
|
+
const decreaseKeys = key === "ArrowDown" ||
|
122
|
+
(position === "end" ? key === directionKeys[1] : key === directionKeys[0]);
|
123
|
+
if (decreaseKeys) {
|
124
|
+
const stepValue = event.shiftKey ? multipliedStep : step;
|
125
|
+
return initialContentWidth - directionFactor * stepValue;
|
126
|
+
}
|
127
|
+
if (typeof contentWidthMin === "number" && key === "Home") {
|
128
|
+
return contentWidthMin;
|
129
|
+
}
|
130
|
+
if (typeof contentWidthMax === "number" && key === "End") {
|
131
|
+
return contentWidthMax;
|
132
|
+
}
|
133
|
+
if (key === "PageDown") {
|
134
|
+
return initialContentWidth - multipliedStep;
|
135
|
+
}
|
136
|
+
if (key === "PageUp") {
|
137
|
+
return initialContentWidth + multipliedStep;
|
138
|
+
}
|
139
|
+
return null;
|
140
|
+
};
|
141
|
+
this.separatorKeyDown = (event) => {
|
142
|
+
this.setInitialContentWidth();
|
143
|
+
const width = this.getKeyAdjustedWidth(event);
|
144
|
+
if (typeof width === "number") {
|
145
|
+
this.setContentWidth(width);
|
146
|
+
}
|
147
|
+
};
|
148
|
+
this.separatorPointerMove = (event) => {
|
149
|
+
event.preventDefault();
|
150
|
+
const { el, initialContentWidth, position, initialClientX } = this;
|
151
|
+
const offset = event.clientX - initialClientX;
|
152
|
+
const dir = getElementDir(el);
|
153
|
+
const adjustmentDirection = dir === "rtl" ? -1 : 1;
|
154
|
+
const adjustedOffset = position === "end" ? -adjustmentDirection * offset : adjustmentDirection * offset;
|
155
|
+
const width = initialContentWidth + adjustedOffset;
|
156
|
+
this.setContentWidth(width);
|
157
|
+
};
|
158
|
+
this.separatorPointerUp = (event) => {
|
159
|
+
if (!isPrimaryPointerButton(event)) {
|
160
|
+
return;
|
161
|
+
}
|
162
|
+
event.preventDefault();
|
163
|
+
document.removeEventListener("pointerup", this.separatorPointerUp);
|
164
|
+
document.removeEventListener("pointermove", this.separatorPointerMove);
|
165
|
+
};
|
166
|
+
this.setInitialContentWidth = () => {
|
167
|
+
var _a;
|
168
|
+
this.initialContentWidth = (_a = this.contentEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
|
169
|
+
};
|
170
|
+
this.separatorPointerDown = (event) => {
|
171
|
+
if (!isPrimaryPointerButton(event)) {
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
event.preventDefault();
|
175
|
+
const { separatorEl } = this;
|
176
|
+
separatorEl && document.activeElement !== separatorEl && separatorEl.focus();
|
177
|
+
this.setInitialContentWidth();
|
178
|
+
this.initialClientX = event.clientX;
|
179
|
+
document.addEventListener("pointerup", this.separatorPointerUp);
|
180
|
+
document.addEventListener("pointermove", this.separatorPointerMove);
|
181
|
+
};
|
182
|
+
this.connectSeparator = (separatorEl) => {
|
183
|
+
this.disconnectSeparator();
|
184
|
+
this.separatorEl = separatorEl;
|
185
|
+
separatorEl.addEventListener("pointerdown", this.separatorPointerDown);
|
186
|
+
};
|
187
|
+
this.disconnectSeparator = () => {
|
188
|
+
var _a;
|
189
|
+
(_a = this.separatorEl) === null || _a === void 0 ? void 0 : _a.removeEventListener("pointerdown", this.separatorPointerDown);
|
190
|
+
};
|
191
|
+
}
|
192
|
+
watchHandler() {
|
193
|
+
this.calciteShellPanelToggle.emit();
|
194
|
+
}
|
195
|
+
//--------------------------------------------------------------------------
|
196
|
+
//
|
197
|
+
// Lifecycle
|
198
|
+
//
|
199
|
+
//--------------------------------------------------------------------------
|
200
|
+
connectedCallback() {
|
201
|
+
connectConditionalSlotComponent(this);
|
202
|
+
}
|
203
|
+
disconnectedCallback() {
|
204
|
+
disconnectConditionalSlotComponent(this);
|
205
|
+
this.disconnectSeparator();
|
206
|
+
}
|
207
|
+
componentDidLoad() {
|
208
|
+
this.updateAriaValues();
|
209
|
+
}
|
210
|
+
// --------------------------------------------------------------------------
|
211
|
+
//
|
212
|
+
// Render Methods
|
213
|
+
//
|
214
|
+
// --------------------------------------------------------------------------
|
215
|
+
renderHeader() {
|
216
|
+
const { el } = this;
|
217
|
+
const hasHeader = getSlotted(el, SLOTS$2.header);
|
218
|
+
return hasHeader ? (h("div", { class: CSS$1.contentHeader, key: "header" }, h("slot", { name: SLOTS$2.header }))) : null;
|
219
|
+
}
|
220
|
+
render() {
|
221
|
+
const { collapsed, detached, position, initialContentWidth, contentWidth, contentWidthMax, contentWidthMin, intlResize, resizable } = this;
|
222
|
+
const allowResizing = !detached && resizable;
|
223
|
+
const contentNode = (h("div", { class: { [CSS$1.content]: true, [CSS$1.contentDetached]: detached }, hidden: collapsed, key: "content", ref: this.storeContentEl, style: allowResizing && contentWidth ? { width: `${contentWidth}px` } : null }, this.renderHeader(), h("div", { class: CSS$1.contentBody }, h("slot", null))));
|
224
|
+
const separatorNode = allowResizing ? (h("div", { "aria-label": intlResize, "aria-orientation": "horizontal", "aria-valuemax": contentWidthMax, "aria-valuemin": contentWidthMin, "aria-valuenow": contentWidth !== null && contentWidth !== void 0 ? contentWidth : initialContentWidth, class: CSS$1.separator, key: "separator", onKeyDown: this.separatorKeyDown, ref: this.connectSeparator, role: "separator", tabIndex: 0, "touch-action": "none" })) : null;
|
225
|
+
const actionBarNode = h("slot", { key: "action-bar", name: SLOTS$2.actionBar });
|
226
|
+
const mainNodes = [actionBarNode, contentNode, separatorNode];
|
227
|
+
if (position === "end") {
|
228
|
+
mainNodes.reverse();
|
229
|
+
}
|
230
|
+
return h("div", { class: { [CSS$1.container]: true } }, mainNodes);
|
231
|
+
}
|
232
|
+
// --------------------------------------------------------------------------
|
233
|
+
//
|
234
|
+
// private Methods
|
235
|
+
//
|
236
|
+
// --------------------------------------------------------------------------
|
237
|
+
setContentWidth(width) {
|
238
|
+
const { contentWidthMax, contentWidthMin } = this;
|
239
|
+
const roundedWidth = Math.round(width);
|
240
|
+
this.contentWidth =
|
241
|
+
typeof contentWidthMax === "number" && typeof contentWidthMin === "number"
|
242
|
+
? clamp(roundedWidth, contentWidthMin, contentWidthMax)
|
243
|
+
: roundedWidth;
|
244
|
+
}
|
245
|
+
updateAriaValues() {
|
246
|
+
const { contentEl } = this;
|
247
|
+
const computedStyle = contentEl && getComputedStyle(contentEl);
|
248
|
+
if (!computedStyle) {
|
249
|
+
return;
|
250
|
+
}
|
251
|
+
const max = parseInt(computedStyle.getPropertyValue("max-width"), 10);
|
252
|
+
const min = parseInt(computedStyle.getPropertyValue("min-width"), 10);
|
253
|
+
const valueNow = parseInt(computedStyle.getPropertyValue("width"), 10);
|
254
|
+
if (typeof valueNow === "number" && !isNaN(valueNow)) {
|
255
|
+
this.initialContentWidth = valueNow;
|
256
|
+
}
|
257
|
+
if (typeof max === "number" && !isNaN(max)) {
|
258
|
+
this.contentWidthMax = max;
|
259
|
+
}
|
260
|
+
if (typeof min === "number" && !isNaN(min)) {
|
261
|
+
this.contentWidthMin = min;
|
262
|
+
}
|
263
|
+
forceUpdate(this);
|
264
|
+
}
|
265
|
+
get el() { return getElement(this); }
|
266
|
+
static get watchers() { return {
|
267
|
+
"collapsed": ["watchHandler"]
|
268
|
+
}; }
|
269
|
+
};
|
270
|
+
ShellPanel.style = shellPanelCss;
|
271
|
+
|
272
|
+
const tabCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([selected]) section,:host([selected]) .container{display:block}:host{display:none;block-size:100%;inline-size:100%}:host([selected]){display:block;block-size:100%;inline-size:100%;overflow:auto}section,.container{display:none;block-size:100%;inline-size:100%}:host([scale=s]){padding-block:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]){padding-block:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]){padding-block:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}";
|
273
|
+
|
274
|
+
const Tab = class {
|
275
|
+
constructor(hostRef) {
|
276
|
+
registerInstance(this, hostRef);
|
277
|
+
this.calciteInternalTabRegister = createEvent(this, "calciteInternalTabRegister", 6);
|
278
|
+
/**
|
279
|
+
* When `true`, the component's contents are selected.
|
280
|
+
*
|
281
|
+
* Only one tab can be selected within the `calcite-tabs` parent.
|
282
|
+
*
|
283
|
+
* @deprecated Use `selected` instead.
|
284
|
+
*/
|
285
|
+
this.active = false;
|
286
|
+
/**
|
287
|
+
* When `true`, the component's contents are selected.
|
288
|
+
*
|
289
|
+
* Only one tab can be selected within the `calcite-tabs` parent.
|
290
|
+
*/
|
291
|
+
this.selected = false;
|
292
|
+
/**
|
293
|
+
* @internal
|
294
|
+
*/
|
295
|
+
this.scale = "m";
|
296
|
+
this.guid = `calcite-tab-title-${guid()}`;
|
297
|
+
}
|
298
|
+
activeHandler(value) {
|
299
|
+
this.selected = value;
|
300
|
+
}
|
301
|
+
selectedHandler(value) {
|
302
|
+
this.active = value;
|
303
|
+
}
|
304
|
+
//--------------------------------------------------------------------------
|
305
|
+
//
|
306
|
+
// Lifecycle
|
307
|
+
//
|
308
|
+
//--------------------------------------------------------------------------
|
309
|
+
render() {
|
310
|
+
const id = this.el.id || this.guid;
|
311
|
+
return (h(Host, { "aria-labelledby": this.labeledBy, id: id }, h("div", { class: "container", role: "tabpanel", tabIndex: this.selected ? 0 : -1 }, h("section", null, h("slot", null)))));
|
312
|
+
}
|
313
|
+
connectedCallback() {
|
314
|
+
this.parentTabsEl = this.el.closest("calcite-tabs");
|
315
|
+
const isSelected = this.selected || this.active;
|
316
|
+
if (isSelected) {
|
317
|
+
this.activeHandler(isSelected);
|
318
|
+
this.selectedHandler(isSelected);
|
319
|
+
}
|
320
|
+
}
|
321
|
+
componentDidLoad() {
|
322
|
+
this.calciteInternalTabRegister.emit();
|
323
|
+
}
|
324
|
+
componentWillRender() {
|
325
|
+
var _a;
|
326
|
+
this.scale = (_a = this.parentTabsEl) === null || _a === void 0 ? void 0 : _a.scale;
|
327
|
+
}
|
328
|
+
disconnectedCallback() {
|
329
|
+
var _a;
|
330
|
+
// Dispatching to body in order to be listened by other elements that are still connected to the DOM.
|
331
|
+
(_a = document.body) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new CustomEvent("calciteTabUnregister", {
|
332
|
+
detail: this.el
|
333
|
+
}));
|
334
|
+
}
|
335
|
+
//--------------------------------------------------------------------------
|
336
|
+
//
|
337
|
+
// Event Listeners
|
338
|
+
//
|
339
|
+
//--------------------------------------------------------------------------
|
340
|
+
internalTabChangeHandler(event) {
|
341
|
+
const targetTabsEl = event
|
342
|
+
.composedPath()
|
343
|
+
.find((el) => el.tagName === "CALCITE-TABS");
|
344
|
+
// to allow `<calcite-tabs>` to be nested we need to make sure this
|
345
|
+
// `calciteTabChange` event was actually fired from a within the same
|
346
|
+
// `<calcite-tabs>` that is the a parent of this tab.
|
347
|
+
if (targetTabsEl !== this.parentTabsEl) {
|
348
|
+
return;
|
349
|
+
}
|
350
|
+
if (this.tab) {
|
351
|
+
this.selected = this.tab === event.detail.tab;
|
352
|
+
}
|
353
|
+
else {
|
354
|
+
this.getTabIndex().then((index) => {
|
355
|
+
this.selected = index === event.detail.tab;
|
356
|
+
});
|
357
|
+
}
|
358
|
+
event.stopPropagation();
|
359
|
+
}
|
360
|
+
//--------------------------------------------------------------------------
|
361
|
+
//
|
362
|
+
// Public Methods
|
363
|
+
//
|
364
|
+
//--------------------------------------------------------------------------
|
365
|
+
/**
|
366
|
+
* Returns the index of the component item within the tab array.
|
367
|
+
*/
|
368
|
+
async getTabIndex() {
|
369
|
+
return Array.prototype.indexOf.call(nodeListToArray(this.el.parentElement.children).filter((el) => el.matches("calcite-tab")), this.el);
|
370
|
+
}
|
371
|
+
//--------------------------------------------------------------------------
|
372
|
+
//
|
373
|
+
// Private Methods
|
374
|
+
//
|
375
|
+
//--------------------------------------------------------------------------
|
376
|
+
/**
|
377
|
+
* @param tabIds
|
378
|
+
* @param titleIds
|
379
|
+
* @internal
|
380
|
+
*/
|
381
|
+
async updateAriaInfo(tabIds = [], titleIds = []) {
|
382
|
+
this.labeledBy = titleIds[tabIds.indexOf(this.el.id)] || null;
|
383
|
+
}
|
384
|
+
get el() { return getElement(this); }
|
385
|
+
static get watchers() { return {
|
386
|
+
"active": ["activeHandler"],
|
387
|
+
"selected": ["selectedHandler"]
|
388
|
+
}; }
|
389
|
+
};
|
390
|
+
Tab.style = tabCss;
|
391
|
+
|
392
|
+
const tabNavCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:flex}:host([scale=s]){min-block-size:1.5rem}:host([scale=m]){min-block-size:2rem}:host([scale=l]){min-block-size:2.75rem}.tab-nav{display:flex;inline-size:100%;justify-content:flex-start;overflow:auto}.tab-nav-active-indicator-container{position:absolute;inset-inline:0px;inset-block-end:0px;block-size:0.125rem;inline-size:100%;overflow:hidden}.tab-nav-active-indicator{position:absolute;inset-block-end:0px;display:block;block-size:0.125rem;background-color:var(--calcite-ui-brand);transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;transition-timing-function:cubic-bezier(0, 0, 0.2, 1)}:host([position=below]) .tab-nav-active-indicator{inset-block-end:unset;inset-block-start:0px}:host([position=bottom]) .tab-nav-active-indicator{inset-block-end:unset;inset-block-start:0px}:host([position=below]) .tab-nav-active-indicator-container{inset-block-start:0px;inset-block-end:unset}:host([position=bottom]) .tab-nav-active-indicator-container{inset-block-end:unset;inset-block-start:0px}:host([bordered]) .tab-nav-active-indicator-container{inset-block-end:unset}:host([bordered][position=below]) .tab-nav-active-indicator-container{inset-block-end:0;inset-block-start:unset}:host([bordered][position=bottom]) .tab-nav-active-indicator-container{inset-block-end:0;inset-block-start:unset}@media (forced-colors: active){.tab-nav-active-indicator{background-color:highlight}}";
|
393
|
+
|
394
|
+
const TabNav = class {
|
395
|
+
constructor(hostRef) {
|
396
|
+
registerInstance(this, hostRef);
|
397
|
+
this.calciteTabChange = createEvent(this, "calciteTabChange", 6);
|
398
|
+
this.calciteInternalTabChange = createEvent(this, "calciteInternalTabChange", 6);
|
399
|
+
/**
|
400
|
+
* @internal
|
401
|
+
*/
|
402
|
+
this.scale = "m";
|
403
|
+
/**
|
404
|
+
* @internal
|
405
|
+
*/
|
406
|
+
this.layout = "inline";
|
407
|
+
/**
|
408
|
+
* @internal
|
409
|
+
*/
|
410
|
+
this.position = "bottom";
|
411
|
+
/**
|
412
|
+
* @internal
|
413
|
+
*/
|
414
|
+
this.bordered = false;
|
415
|
+
this.animationActiveDuration = 0.3;
|
416
|
+
this.resizeObserver = createObserver("resize", () => {
|
417
|
+
// remove active indicator transition duration during resize to prevent wobble
|
418
|
+
this.activeIndicatorEl.style.transitionDuration = "0s";
|
419
|
+
this.updateActiveWidth();
|
420
|
+
this.updateOffsetPosition();
|
421
|
+
});
|
422
|
+
//--------------------------------------------------------------------------
|
423
|
+
//
|
424
|
+
// Private Methods
|
425
|
+
//
|
426
|
+
//--------------------------------------------------------------------------
|
427
|
+
this.handleContainerScroll = () => {
|
428
|
+
// remove active indicator transition duration while container is scrolling to prevent wobble
|
429
|
+
this.activeIndicatorEl.style.transitionDuration = "0s";
|
430
|
+
this.updateOffsetPosition();
|
431
|
+
};
|
432
|
+
}
|
433
|
+
async selectedTabChanged() {
|
434
|
+
if (localStorage &&
|
435
|
+
this.storageId &&
|
436
|
+
this.selectedTab !== undefined &&
|
437
|
+
this.selectedTab !== null) {
|
438
|
+
localStorage.setItem(`calcite-tab-nav-${this.storageId}`, JSON.stringify(this.selectedTab));
|
439
|
+
}
|
440
|
+
this.calciteInternalTabChange.emit({
|
441
|
+
tab: this.selectedTab
|
442
|
+
});
|
443
|
+
this.selectedTabEl = await this.getTabTitleById(this.selectedTab);
|
444
|
+
}
|
445
|
+
selectedTabElChanged() {
|
446
|
+
this.updateOffsetPosition();
|
447
|
+
this.updateActiveWidth();
|
448
|
+
// reset the animation time on tab selection
|
449
|
+
this.activeIndicatorEl.style.transitionDuration = `${this.animationActiveDuration}s`;
|
450
|
+
}
|
451
|
+
//--------------------------------------------------------------------------
|
452
|
+
//
|
453
|
+
// Lifecycle
|
454
|
+
//
|
455
|
+
//--------------------------------------------------------------------------
|
456
|
+
connectedCallback() {
|
457
|
+
var _a;
|
458
|
+
this.parentTabsEl = this.el.closest("calcite-tabs");
|
459
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el);
|
460
|
+
}
|
461
|
+
disconnectedCallback() {
|
462
|
+
var _a;
|
463
|
+
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
464
|
+
}
|
465
|
+
componentWillLoad() {
|
466
|
+
const storageKey = `calcite-tab-nav-${this.storageId}`;
|
467
|
+
if (localStorage && this.storageId && localStorage.getItem(storageKey)) {
|
468
|
+
const storedTab = JSON.parse(localStorage.getItem(storageKey));
|
469
|
+
this.selectedTab = storedTab;
|
470
|
+
}
|
471
|
+
}
|
472
|
+
componentWillRender() {
|
473
|
+
const { parentTabsEl } = this;
|
474
|
+
this.layout = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.layout;
|
475
|
+
this.position = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.position;
|
476
|
+
this.scale = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.scale;
|
477
|
+
this.bordered = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.bordered;
|
478
|
+
// fix issue with active tab-title not lining up with blue indicator
|
479
|
+
if (this.selectedTabEl) {
|
480
|
+
this.updateOffsetPosition();
|
481
|
+
}
|
482
|
+
}
|
483
|
+
componentDidRender() {
|
484
|
+
// if every tab title is active select the first tab.
|
485
|
+
if (this.tabTitles.length &&
|
486
|
+
this.tabTitles.every((title) => !title.active) &&
|
487
|
+
!this.selectedTab) {
|
488
|
+
this.tabTitles[0].getTabIdentifier().then((tab) => {
|
489
|
+
this.calciteInternalTabChange.emit({
|
490
|
+
tab
|
491
|
+
});
|
492
|
+
});
|
493
|
+
}
|
494
|
+
}
|
495
|
+
render() {
|
496
|
+
const dir = getElementDir(this.el);
|
497
|
+
const width = `${this.indicatorWidth}px`;
|
498
|
+
const offset = `${this.indicatorOffset}px`;
|
499
|
+
const indicatorStyle = dir !== "rtl" ? { width, left: offset } : { width, right: offset };
|
500
|
+
return (h(Host, { role: "tablist" }, h("div", { class: "tab-nav", onScroll: this.handleContainerScroll, ref: (el) => (this.tabNavEl = el) }, h("div", { class: "tab-nav-active-indicator-container", ref: (el) => (this.activeIndicatorContainerEl = el) }, h("div", { class: "tab-nav-active-indicator", ref: (el) => (this.activeIndicatorEl = el), style: indicatorStyle })), h("slot", null))));
|
501
|
+
}
|
502
|
+
//--------------------------------------------------------------------------
|
503
|
+
//
|
504
|
+
// Event Listeners
|
505
|
+
//
|
506
|
+
//--------------------------------------------------------------------------
|
507
|
+
focusPreviousTabHandler(event) {
|
508
|
+
const currentIndex = this.getIndexOfTabTitle(event.target, this.enabledTabTitles);
|
509
|
+
const previousTab = this.enabledTabTitles[currentIndex - 1] ||
|
510
|
+
this.enabledTabTitles[this.enabledTabTitles.length - 1];
|
511
|
+
previousTab === null || previousTab === void 0 ? void 0 : previousTab.focus();
|
512
|
+
event.stopPropagation();
|
513
|
+
event.preventDefault();
|
514
|
+
}
|
515
|
+
focusNextTabHandler(event) {
|
516
|
+
const currentIndex = this.getIndexOfTabTitle(event.target, this.enabledTabTitles);
|
517
|
+
const nextTab = this.enabledTabTitles[currentIndex + 1] || this.enabledTabTitles[0];
|
518
|
+
nextTab === null || nextTab === void 0 ? void 0 : nextTab.focus();
|
519
|
+
event.stopPropagation();
|
520
|
+
event.preventDefault();
|
521
|
+
}
|
522
|
+
internalActivateTabHandler(event) {
|
523
|
+
this.selectedTab = event.detail.tab
|
524
|
+
? event.detail.tab
|
525
|
+
: this.getIndexOfTabTitle(event.target);
|
526
|
+
event.stopPropagation();
|
527
|
+
event.preventDefault();
|
528
|
+
}
|
529
|
+
activateTabHandler(event) {
|
530
|
+
this.calciteTabChange.emit({
|
531
|
+
tab: this.selectedTab
|
532
|
+
});
|
533
|
+
event.stopPropagation();
|
534
|
+
event.preventDefault();
|
535
|
+
}
|
536
|
+
/**
|
537
|
+
* Check for active tabs on register and update selected
|
538
|
+
*
|
539
|
+
* @param event
|
540
|
+
*/
|
541
|
+
updateTabTitles(event) {
|
542
|
+
if (event.target.active) {
|
543
|
+
this.selectedTab = event.detail;
|
544
|
+
}
|
545
|
+
}
|
546
|
+
globalInternalTabChangeHandler(event) {
|
547
|
+
if (this.syncId &&
|
548
|
+
event.target !== this.el &&
|
549
|
+
event.target.syncId === this.syncId &&
|
550
|
+
this.selectedTab !== event.detail.tab) {
|
551
|
+
this.selectedTab = event.detail.tab;
|
552
|
+
}
|
553
|
+
event.stopPropagation();
|
554
|
+
}
|
555
|
+
iconStartChangeHandler() {
|
556
|
+
this.updateActiveWidth();
|
557
|
+
}
|
558
|
+
updateOffsetPosition() {
|
559
|
+
var _a, _b, _c, _d, _e;
|
560
|
+
const dir = getElementDir(this.el);
|
561
|
+
const navWidth = (_a = this.activeIndicatorContainerEl) === null || _a === void 0 ? void 0 : _a.offsetWidth;
|
562
|
+
const tabLeft = (_b = this.selectedTabEl) === null || _b === void 0 ? void 0 : _b.offsetLeft;
|
563
|
+
const tabWidth = (_c = this.selectedTabEl) === null || _c === void 0 ? void 0 : _c.offsetWidth;
|
564
|
+
const offsetRight = navWidth - (tabLeft + tabWidth);
|
565
|
+
this.indicatorOffset =
|
566
|
+
dir !== "rtl" ? tabLeft - ((_d = this.tabNavEl) === null || _d === void 0 ? void 0 : _d.scrollLeft) : offsetRight + ((_e = this.tabNavEl) === null || _e === void 0 ? void 0 : _e.scrollLeft);
|
567
|
+
}
|
568
|
+
updateActiveWidth() {
|
569
|
+
var _a;
|
570
|
+
this.indicatorWidth = (_a = this.selectedTabEl) === null || _a === void 0 ? void 0 : _a.offsetWidth;
|
571
|
+
}
|
572
|
+
getIndexOfTabTitle(el, tabTitles = this.tabTitles) {
|
573
|
+
// In most cases, since these indexes correlate with tab contents, we want to consider all tab titles.
|
574
|
+
// However, when doing relative index operations, it makes sense to pass in this.enabledTabTitles as the 2nd arg.
|
575
|
+
return tabTitles.indexOf(el);
|
576
|
+
}
|
577
|
+
async getTabTitleById(id) {
|
578
|
+
return Promise.all(this.tabTitles.map((el) => el.getTabIdentifier())).then((ids) => {
|
579
|
+
return this.tabTitles[ids.indexOf(id)];
|
580
|
+
});
|
581
|
+
}
|
582
|
+
get tabTitles() {
|
583
|
+
return filterDirectChildren(this.el, "calcite-tab-title");
|
584
|
+
}
|
585
|
+
get enabledTabTitles() {
|
586
|
+
return filterDirectChildren(this.el, "calcite-tab-title:not([disabled])");
|
587
|
+
}
|
588
|
+
get el() { return getElement(this); }
|
589
|
+
static get watchers() { return {
|
590
|
+
"selectedTab": ["selectedTabChanged"],
|
591
|
+
"selectedTabEl": ["selectedTabElChanged"]
|
592
|
+
}; }
|
593
|
+
};
|
594
|
+
TabNav.style = tabNavCss;
|
595
|
+
|
596
|
+
const tabTitleCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{display:block;flex:0 1 auto;outline:2px solid transparent;outline-offset:2px;-webkit-margin-start:0px;margin-inline-start:0px;-webkit-margin-end:1.25rem;margin-inline-end:1.25rem}:host([layout=center]){margin-block:0px;margin-inline:1.25rem;text-align:center;flex-basis:12rem;margin:auto}:host([position=below]) .container{border-block-end-width:0px;border-block-start-width:2px;border-block-start-color:transparent;border-block-start-style:solid}:host([position=bottom]) .container{border-block-end-width:0px;border-block-start-width:2px;border-block-start-color:transparent;border-block-start-style:solid}:host .container{outline-color:transparent}:host(:focus) .container{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}:host(:active) a,:host(:focus) a,:host(:hover) a{border-color:var(--calcite-ui-border-2);color:var(--calcite-ui-text-1);-webkit-text-decoration-line:none;text-decoration-line:none}:host([selected]) .container{border-color:transparent;color:var(--calcite-ui-text-1)}:host([disabled]) .container{pointer-events:none;opacity:0.5}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]){-webkit-margin-end:1rem;margin-inline-end:1rem}:host([scale=s]) .container{padding-block:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]) .container{padding-block:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=l]){-webkit-margin-end:1.5rem;margin-inline-end:1.5rem}:host([scale=l]) .container{padding-block:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}.container{box-sizing:border-box;display:flex;block-size:100%;inline-size:100%;cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;justify-content:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-block-end-width:2px;padding-inline:0px;padding-block:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-3);transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;border-block-end-color:transparent;border-block-end-style:solid}.calcite-tab-title--icon{position:relative;margin:0px;display:inline-flex;align-self:center}.calcite-tab-title--icon svg{transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s}.container--has-text{padding:0.25rem}.container--has-text .calcite-tab-title--icon.icon-start{-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}.container--has-text .calcite-tab-title--icon.icon-end{-webkit-margin-start:0.5rem;margin-inline-start:0.5rem}:host([icon-start][icon-end]) .calcite-tab-title--icon:first-child{-webkit-margin-end:0.5rem;margin-inline-end:0.5rem}:host([bordered]){-webkit-margin-end:0;margin-inline-end:0}:host([bordered][selected]){box-shadow:inset 0px -2px var(--calcite-ui-foreground-1)}:host([bordered][selected][position=below]){box-shadow:inset 0 2px 0 var(--calcite-ui-foreground-1)}:host([bordered][selected][position=bottom]){box-shadow:inset 0 2px 0 var(--calcite-ui-foreground-1)}:host([bordered]:hover) .container,:host([bordered]:focus) .container,:host([bordered]:active) .container{position:relative}:host([bordered]:hover) .container{background-color:var(--calcite-button-transparent-hover)}:host([bordered]) .container{border-block-end-style:unset;-webkit-border-start:1px solid transparent;border-inline-start:1px solid transparent;-webkit-border-end:1px solid transparent;border-inline-end:1px solid transparent}:host([bordered][position=below]) .container{border-block-start-style:unset}:host([bordered][position=bottom]) .container{border-block-start-style:unset}:host([selected][bordered]) .container{border-inline-start-color:var(--calcite-ui-border-1);border-inline-end-color:var(--calcite-ui-border-1)}:host([bordered]) .container{padding-inline:0.75rem}:host([bordered][scale=s]) .container{padding-inline:0.5rem}:host([bordered][scale=l]) .container{padding-inline:1rem}@media (forced-colors: active){:host{outline-width:0;outline-offset:0}:host(:focus) .container{outline-color:highlight}:host([bordered]) .container{border-block-end-style:solid}:host([bordered][position=below]) .container{border-block-start-style:solid}:host([bordered][position=bottom]) .container{border-block-start-style:solid}:host([bordered][selected]) .container{border-block-end-style:none}:host([bordered][position=below][selected]) .container{border-block-start-style:none}:host([bordered][position=bottom][selected]) .container{border-block-start-style:none}}";
|
597
|
+
|
598
|
+
const TabTitle = class {
|
599
|
+
constructor(hostRef) {
|
600
|
+
registerInstance(this, hostRef);
|
601
|
+
this.calciteTabsActivate = createEvent(this, "calciteTabsActivate", 6);
|
602
|
+
this.calciteInternalTabsActivate = createEvent(this, "calciteInternalTabsActivate", 6);
|
603
|
+
this.calciteInternalTabsFocusNext = createEvent(this, "calciteInternalTabsFocusNext", 6);
|
604
|
+
this.calciteInternalTabsFocusPrevious = createEvent(this, "calciteInternalTabsFocusPrevious", 6);
|
605
|
+
this.calciteInternalTabTitleRegister = createEvent(this, "calciteInternalTabTitleRegister", 6);
|
606
|
+
this.calciteInternalTabIconChanged = createEvent(this, "calciteInternalTabIconChanged", 6);
|
607
|
+
//--------------------------------------------------------------------------
|
608
|
+
//
|
609
|
+
// Properties
|
610
|
+
//
|
611
|
+
//--------------------------------------------------------------------------
|
612
|
+
/**
|
613
|
+
* When `true`, the component and its respective `calcite-tab` contents are selected.
|
614
|
+
*
|
615
|
+
* Only one tab can be selected within the `calcite-tabs` parent.
|
616
|
+
*
|
617
|
+
* @deprecated Use `selected` instead.
|
618
|
+
*/
|
619
|
+
this.active = false;
|
620
|
+
/**
|
621
|
+
* When `true`, the component and its respective `calcite-tab` contents are selected.
|
622
|
+
*
|
623
|
+
* Only one tab can be selected within the `calcite-tabs` parent.
|
624
|
+
*/
|
625
|
+
this.selected = false;
|
626
|
+
/** When `true`, interaction is prevented and the component is displayed with lower opacity. */
|
627
|
+
this.disabled = false;
|
628
|
+
/**
|
629
|
+
* @internal
|
630
|
+
*/
|
631
|
+
this.bordered = false;
|
632
|
+
//--------------------------------------------------------------------------
|
633
|
+
//
|
634
|
+
// Private State/Props
|
635
|
+
//
|
636
|
+
//--------------------------------------------------------------------------
|
637
|
+
/** watches for changing text content */
|
638
|
+
this.mutationObserver = createObserver("mutation", () => this.updateHasText());
|
639
|
+
/** determine if there is slotted text for styling purposes */
|
640
|
+
this.hasText = false;
|
641
|
+
this.resizeObserver = createObserver("resize", () => {
|
642
|
+
this.calciteInternalTabIconChanged.emit();
|
643
|
+
});
|
644
|
+
this.guid = `calcite-tab-title-${guid()}`;
|
645
|
+
}
|
646
|
+
activeHandler(value) {
|
647
|
+
this.selected = value;
|
648
|
+
}
|
649
|
+
selectedHandler(value) {
|
650
|
+
this.active = value;
|
651
|
+
if (this.selected) {
|
652
|
+
this.emitActiveTab(false);
|
653
|
+
}
|
654
|
+
}
|
655
|
+
//--------------------------------------------------------------------------
|
656
|
+
//
|
657
|
+
// Lifecycle
|
658
|
+
//
|
659
|
+
//--------------------------------------------------------------------------
|
660
|
+
connectedCallback() {
|
661
|
+
const { selected, active } = this;
|
662
|
+
if (selected) {
|
663
|
+
this.active = selected;
|
664
|
+
}
|
665
|
+
else if (active) {
|
666
|
+
this.activeHandler(active);
|
667
|
+
}
|
668
|
+
this.setupTextContentObserver();
|
669
|
+
this.parentTabNavEl = this.el.closest("calcite-tab-nav");
|
670
|
+
this.parentTabsEl = this.el.closest("calcite-tabs");
|
671
|
+
}
|
672
|
+
disconnectedCallback() {
|
673
|
+
var _a, _b, _c;
|
674
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
675
|
+
// Dispatching to body in order to be listened by other elements that are still connected to the DOM.
|
676
|
+
(_b = document.body) === null || _b === void 0 ? void 0 : _b.dispatchEvent(new CustomEvent("calciteTabTitleUnregister", {
|
677
|
+
detail: this.el
|
678
|
+
}));
|
679
|
+
(_c = this.resizeObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
|
680
|
+
}
|
681
|
+
componentWillLoad() {
|
682
|
+
{
|
683
|
+
this.updateHasText();
|
684
|
+
}
|
685
|
+
if (this.tab && this.selected) {
|
686
|
+
this.emitActiveTab(false);
|
687
|
+
}
|
688
|
+
}
|
689
|
+
componentWillRender() {
|
690
|
+
if (this.parentTabsEl) {
|
691
|
+
this.layout = this.parentTabsEl.layout;
|
692
|
+
this.position = this.parentTabsEl.position;
|
693
|
+
this.scale = this.parentTabsEl.scale;
|
694
|
+
this.bordered = this.parentTabsEl.bordered;
|
695
|
+
}
|
696
|
+
// handle case when tab-nav is only parent
|
697
|
+
if (!this.parentTabsEl && this.parentTabNavEl) {
|
698
|
+
this.position = getElementProp(this.parentTabNavEl, "position", this.position);
|
699
|
+
this.scale = getElementProp(this.parentTabNavEl, "scale", this.scale);
|
700
|
+
}
|
701
|
+
}
|
702
|
+
render() {
|
703
|
+
const id = this.el.id || this.guid;
|
704
|
+
const iconStartEl = (h("calcite-icon", { class: "calcite-tab-title--icon icon-start", flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
|
705
|
+
const iconEndEl = (h("calcite-icon", { class: "calcite-tab-title--icon icon-end", flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
|
706
|
+
return (h(Host, { "aria-controls": this.controls, "aria-selected": toAriaBoolean(this.selected), id: id, role: "tab", tabIndex: this.selected ? 0 : -1 }, h("div", { class: {
|
707
|
+
container: true,
|
708
|
+
"container--has-text": this.hasText
|
709
|
+
}, ref: (el) => { var _a; return (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(el); } }, this.iconStart ? iconStartEl : null, h("slot", null), this.iconEnd ? iconEndEl : null)));
|
710
|
+
}
|
711
|
+
async componentDidLoad() {
|
712
|
+
this.calciteInternalTabTitleRegister.emit(await this.getTabIdentifier());
|
713
|
+
}
|
714
|
+
componentDidRender() {
|
715
|
+
updateHostInteraction(this, () => {
|
716
|
+
return this.selected;
|
717
|
+
});
|
718
|
+
}
|
719
|
+
//--------------------------------------------------------------------------
|
720
|
+
//
|
721
|
+
// Event Listeners
|
722
|
+
//
|
723
|
+
//--------------------------------------------------------------------------
|
724
|
+
internalTabChangeHandler(event) {
|
725
|
+
const targetTabsEl = event
|
726
|
+
.composedPath()
|
727
|
+
.find((el) => el.tagName === "CALCITE-TABS");
|
728
|
+
if (targetTabsEl !== this.parentTabsEl) {
|
729
|
+
return;
|
730
|
+
}
|
731
|
+
if (this.tab) {
|
732
|
+
this.selected = this.tab === event.detail.tab;
|
733
|
+
}
|
734
|
+
else {
|
735
|
+
this.getTabIndex().then((index) => {
|
736
|
+
this.selected = index === event.detail.tab;
|
737
|
+
});
|
738
|
+
}
|
739
|
+
event.stopPropagation();
|
740
|
+
}
|
741
|
+
onClick() {
|
742
|
+
this.emitActiveTab();
|
743
|
+
}
|
744
|
+
keyDownHandler(event) {
|
745
|
+
switch (event.key) {
|
746
|
+
case " ":
|
747
|
+
case "Enter":
|
748
|
+
this.emitActiveTab();
|
749
|
+
event.preventDefault();
|
750
|
+
break;
|
751
|
+
case "ArrowRight":
|
752
|
+
event.preventDefault();
|
753
|
+
if (getElementDir(this.el) === "ltr") {
|
754
|
+
this.calciteInternalTabsFocusNext.emit();
|
755
|
+
}
|
756
|
+
else {
|
757
|
+
this.calciteInternalTabsFocusPrevious.emit();
|
758
|
+
}
|
759
|
+
break;
|
760
|
+
case "ArrowLeft":
|
761
|
+
event.preventDefault();
|
762
|
+
if (getElementDir(this.el) === "ltr") {
|
763
|
+
this.calciteInternalTabsFocusPrevious.emit();
|
764
|
+
}
|
765
|
+
else {
|
766
|
+
this.calciteInternalTabsFocusNext.emit();
|
767
|
+
}
|
768
|
+
break;
|
769
|
+
}
|
770
|
+
}
|
771
|
+
//--------------------------------------------------------------------------
|
772
|
+
//
|
773
|
+
// Public Methods
|
774
|
+
//
|
775
|
+
//--------------------------------------------------------------------------
|
776
|
+
/**
|
777
|
+
* Returns the index of the title within the `calcite-tab-nav`.
|
778
|
+
*/
|
779
|
+
async getTabIndex() {
|
780
|
+
return Array.prototype.indexOf.call(this.el.parentElement.querySelectorAll("calcite-tab-title"), this.el);
|
781
|
+
}
|
782
|
+
/**
|
783
|
+
* @internal
|
784
|
+
*/
|
785
|
+
async getTabIdentifier() {
|
786
|
+
return this.tab ? this.tab : this.getTabIndex();
|
787
|
+
}
|
788
|
+
/**
|
789
|
+
* @param tabIds
|
790
|
+
* @param titleIds
|
791
|
+
* @internal
|
792
|
+
*/
|
793
|
+
async updateAriaInfo(tabIds = [], titleIds = []) {
|
794
|
+
this.controls = tabIds[titleIds.indexOf(this.el.id)] || null;
|
795
|
+
}
|
796
|
+
updateHasText() {
|
797
|
+
this.hasText = this.el.textContent.trim().length > 0;
|
798
|
+
}
|
799
|
+
setupTextContentObserver() {
|
800
|
+
var _a;
|
801
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
|
802
|
+
}
|
803
|
+
emitActiveTab(userTriggered = true) {
|
804
|
+
if (this.disabled) {
|
805
|
+
return;
|
806
|
+
}
|
807
|
+
const payload = { tab: this.tab };
|
808
|
+
this.calciteInternalTabsActivate.emit(payload);
|
809
|
+
if (userTriggered) {
|
810
|
+
this.calciteTabsActivate.emit(payload);
|
811
|
+
}
|
812
|
+
}
|
813
|
+
get el() { return getElement(this); }
|
814
|
+
static get watchers() { return {
|
815
|
+
"active": ["activeHandler"],
|
816
|
+
"selected": ["selectedHandler"]
|
817
|
+
}; }
|
818
|
+
};
|
819
|
+
TabTitle.style = tabTitleCss;
|
820
|
+
|
821
|
+
/*!
|
822
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
823
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
824
|
+
* v1.0.0-beta.97
|
825
|
+
*/
|
826
|
+
const SLOTS$1 = {
|
827
|
+
tabNav: "tab-nav"
|
828
|
+
};
|
829
|
+
|
830
|
+
const tabsCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:flex;flex-direction:column}:host([bordered]){box-shadow:inset 0 1px 0 var(--calcite-ui-border-1);background-color:var(--calcite-ui-foreground-1)}:host([bordered]:not([position=below])) ::slotted(calcite-tab-nav){-webkit-margin-after:-1px;margin-block-end:-1px}:host([bordered]:not([position=bottom])) ::slotted(calcite-tab-nav){-webkit-margin-after:-1px;margin-block-end:-1px}:host([bordered][position=below]) ::slotted(calcite-tab-nav){-webkit-margin-before:-1px;margin-block-start:-1px}:host([bordered][position=below]){box-shadow:inset 0 1px 0 var(--calcite-ui-border-1), inset 0 -1px 0 var(--calcite-ui-border-1)}:host([bordered][position=bottom]){box-shadow:inset 0 1px 0 var(--calcite-ui-border-1), inset 0 -1px 0 var(--calcite-ui-border-1)}:host([bordered]) section{border-width:1px;border-style:solid;border-color:var(--calcite-ui-border-1)}:host([bordered][scale=s]) section{padding:0.75rem}:host([bordered][scale=m]) section{padding:0.5rem}:host([bordered][scale=l]) section{padding:1rem}:host([position=below]){flex-direction:column-reverse}:host([position=bottom]){flex-direction:column-reverse}section{display:flex;flex-grow:1;overflow:hidden;border-block-start-width:1px;border-block-start-color:var(--calcite-ui-border-1);border-block-start-style:solid}:host([position=below]) section{flex-direction:column-reverse;border-block-start-width:0px;border-block-end-width:1px;border-block-end-color:var(--calcite-ui-border-1)}:host([position=bottom]) section{flex-direction:column-reverse;border-block-start-width:0px;border-block-end-width:1px;border-block-end-color:var(--calcite-ui-border-1)}:host([position=below]:not([bordered])) section{border-block-end-style:solid}:host([position=bottom]:not([bordered])) section{border-block-end-style:solid}@media (forced-colors: active){:host([bordered]) section{border-block-start-width:0px;border-block-end-width:1px}:host([position=below][bordered]) section{border-block-start-width:1px;border-block-end-width:0px}:host([position=bottom][bordered]) section{border-block-start-width:1px;border-block-end-width:0px}}";
|
831
|
+
|
832
|
+
const Tabs = class {
|
833
|
+
constructor(hostRef) {
|
834
|
+
registerInstance(this, hostRef);
|
835
|
+
//--------------------------------------------------------------------------
|
836
|
+
//
|
837
|
+
// Public Properties
|
838
|
+
//
|
839
|
+
//--------------------------------------------------------------------------
|
840
|
+
/**
|
841
|
+
* Specifies the layout of the `calcite-tab-nav`, justifying the `calcite-tab-title`s to the start (`"inline"`), or across and centered (`"center"`).
|
842
|
+
*/
|
843
|
+
this.layout = "inline";
|
844
|
+
/**
|
845
|
+
* Specifies the position of the component in relation to the `calcite-tab`s. The `"above"` and `"below"` values are deprecated.
|
846
|
+
*
|
847
|
+
*/
|
848
|
+
this.position = "top";
|
849
|
+
/**
|
850
|
+
* Specifies the size of the component.
|
851
|
+
*/
|
852
|
+
this.scale = "m";
|
853
|
+
/**
|
854
|
+
* When `true`, the component will display with a folder style menu.
|
855
|
+
*/
|
856
|
+
this.bordered = false;
|
857
|
+
//--------------------------------------------------------------------------
|
858
|
+
//
|
859
|
+
// Events
|
860
|
+
//
|
861
|
+
//--------------------------------------------------------------------------
|
862
|
+
//--------------------------------------------------------------------------
|
863
|
+
//
|
864
|
+
// Private State/Props
|
865
|
+
//
|
866
|
+
//--------------------------------------------------------------------------
|
867
|
+
/**
|
868
|
+
*
|
869
|
+
* Stores an array of ids of `<calcite-tab-titles>`s to match up ARIA
|
870
|
+
* attributes.
|
871
|
+
*/
|
872
|
+
this.titles = [];
|
873
|
+
/**
|
874
|
+
*
|
875
|
+
* Stores an array of ids of `<calcite-tab>`s to match up ARIA attributes.
|
876
|
+
*/
|
877
|
+
this.tabs = [];
|
878
|
+
}
|
879
|
+
//--------------------------------------------------------------------------
|
880
|
+
//
|
881
|
+
// Lifecycle
|
882
|
+
//
|
883
|
+
//--------------------------------------------------------------------------
|
884
|
+
render() {
|
885
|
+
return (h(Fragment, null, h("slot", { name: SLOTS$1.tabNav }), h("section", null, h("slot", null))));
|
886
|
+
}
|
887
|
+
//--------------------------------------------------------------------------
|
888
|
+
//
|
889
|
+
// Event Listeners
|
890
|
+
//
|
891
|
+
//--------------------------------------------------------------------------
|
892
|
+
/**
|
893
|
+
* @param event
|
894
|
+
* @internal
|
895
|
+
*/
|
896
|
+
calciteInternalTabTitleRegister(event) {
|
897
|
+
this.titles = [...this.titles, event.target];
|
898
|
+
this.registryHandler();
|
899
|
+
event.stopPropagation();
|
900
|
+
}
|
901
|
+
/**
|
902
|
+
* @param event
|
903
|
+
* @internal
|
904
|
+
*/
|
905
|
+
calciteTabTitleUnregister(event) {
|
906
|
+
this.titles = this.titles.filter((el) => el !== event.detail);
|
907
|
+
this.registryHandler();
|
908
|
+
event.stopPropagation();
|
909
|
+
}
|
910
|
+
/**
|
911
|
+
* @param event
|
912
|
+
* @internal
|
913
|
+
*/
|
914
|
+
calciteInternalTabRegister(event) {
|
915
|
+
this.tabs = [...this.tabs, event.target];
|
916
|
+
this.registryHandler();
|
917
|
+
event.stopPropagation();
|
918
|
+
}
|
919
|
+
/**
|
920
|
+
* @param event
|
921
|
+
* @internal
|
922
|
+
*/
|
923
|
+
calciteTabUnregister(event) {
|
924
|
+
this.tabs = this.tabs.filter((el) => el !== event.detail);
|
925
|
+
this.registryHandler();
|
926
|
+
event.stopPropagation();
|
927
|
+
}
|
928
|
+
//--------------------------------------------------------------------------
|
929
|
+
//
|
930
|
+
// Private Methods
|
931
|
+
//
|
932
|
+
//--------------------------------------------------------------------------
|
933
|
+
/**
|
934
|
+
*
|
935
|
+
* Matches up elements from the internal `tabs` and `titles` to automatically
|
936
|
+
* update the ARIA attributes and link `<calcite-tab>` and
|
937
|
+
* `<calcite-tab-title>` components.
|
938
|
+
*/
|
939
|
+
async registryHandler() {
|
940
|
+
let tabIds;
|
941
|
+
let titleIds;
|
942
|
+
// determine if we are using `tab` based or `index` based tab identifiers.
|
943
|
+
if (this.tabs.some((el) => el.tab) || this.titles.some((el) => el.tab)) {
|
944
|
+
// if we are using `tab` based identifiers sort by `tab` to account for
|
945
|
+
// possible out of order tabs and get the id of each tab
|
946
|
+
tabIds = this.tabs.sort((a, b) => a.tab.localeCompare(b.tab)).map((el) => el.id);
|
947
|
+
titleIds = this.titles.sort((a, b) => a.tab.localeCompare(b.tab)).map((el) => el.id);
|
948
|
+
}
|
949
|
+
else {
|
950
|
+
// if we are using index based tabs then the `<calcite-tab>` and
|
951
|
+
// `<calcite-tab-title>` might have been rendered out of order so the
|
952
|
+
// order of `this.tabs` and `this.titles` might not reflect the DOM state,
|
953
|
+
// and might not match each other so we need to get the index of all the
|
954
|
+
// tabs and titles in the DOM order to match them up as a source of truth
|
955
|
+
const tabDomIndexes = await Promise.all(this.tabs.map((el) => el.getTabIndex()));
|
956
|
+
const titleDomIndexes = await Promise.all(this.titles.map((el) => el.getTabIndex()));
|
957
|
+
// once we have the DOM order as a source of truth we can build the
|
958
|
+
// matching tabIds and titleIds arrays
|
959
|
+
tabIds = tabDomIndexes.reduce((ids, indexInDOM, registryIndex) => {
|
960
|
+
ids[indexInDOM] = this.tabs[registryIndex].id;
|
961
|
+
return ids;
|
962
|
+
}, []);
|
963
|
+
titleIds = titleDomIndexes.reduce((ids, indexInDOM, registryIndex) => {
|
964
|
+
ids[indexInDOM] = this.titles[registryIndex].id;
|
965
|
+
return ids;
|
966
|
+
}, []);
|
967
|
+
}
|
968
|
+
// pass all our new aria information to each `<calcite-tab>` and
|
969
|
+
// `<calcite-tab-title>` which will check if they can update their internal
|
970
|
+
// `controlled` or `labeledBy` states and re-render if necessary
|
971
|
+
this.tabs.forEach((el) => el.updateAriaInfo(tabIds, titleIds));
|
972
|
+
this.titles.forEach((el) => el.updateAriaInfo(tabIds, titleIds));
|
973
|
+
}
|
974
|
+
get el() { return getElement(this); }
|
975
|
+
};
|
976
|
+
Tabs.style = tabsCss;
|
977
|
+
|
978
|
+
/*!
|
979
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
980
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
981
|
+
* v1.0.0-beta.97
|
982
|
+
*/
|
983
|
+
const CSS = {
|
984
|
+
container: "container",
|
985
|
+
handle: "handle"
|
986
|
+
};
|
987
|
+
var ICON_TYPES;
|
988
|
+
(function (ICON_TYPES) {
|
989
|
+
ICON_TYPES["grip"] = "grip";
|
990
|
+
})(ICON_TYPES || (ICON_TYPES = {}));
|
991
|
+
|
992
|
+
/*!
|
993
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
994
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
995
|
+
* v1.0.0-beta.97
|
996
|
+
*/
|
997
|
+
function getScreenReaderText(item, status, valueList) {
|
998
|
+
const { items, intlDragHandleIdle, intlDragHandleActive, intlDragHandleChange, intlDragHandleCommit } = valueList;
|
999
|
+
const total = items.length;
|
1000
|
+
const position = getItemIndex(valueList, item) + 1;
|
1001
|
+
if (status === "idle") {
|
1002
|
+
const idleText = intlDragHandleIdle
|
1003
|
+
? replacePlaceholders(intlDragHandleIdle, item.label, position, total)
|
1004
|
+
: `${item.label}, press space and use arrow keys to reorder content. Current position ${position} of ${total}.`;
|
1005
|
+
return idleText;
|
1006
|
+
}
|
1007
|
+
else if (status === "active") {
|
1008
|
+
const activeText = intlDragHandleActive
|
1009
|
+
? replacePlaceholders(intlDragHandleActive, item.label, position, total)
|
1010
|
+
: `Reordering ${item.label}, current position ${position} of ${total}.`;
|
1011
|
+
return activeText;
|
1012
|
+
}
|
1013
|
+
else if (status === "change") {
|
1014
|
+
const changeText = intlDragHandleChange
|
1015
|
+
? replacePlaceholders(intlDragHandleChange, item.label, position, total)
|
1016
|
+
: `${item.label}, new position ${position} of ${total}. Press space to confirm.`;
|
1017
|
+
return changeText;
|
1018
|
+
}
|
1019
|
+
else {
|
1020
|
+
const commitText = intlDragHandleCommit
|
1021
|
+
? replacePlaceholders(intlDragHandleCommit, item.label, position, total)
|
1022
|
+
: `${item.label}, current position ${position} of ${total}.`;
|
1023
|
+
return commitText;
|
1024
|
+
}
|
1025
|
+
}
|
1026
|
+
function getHandleAndItemElement(event) {
|
1027
|
+
const handle = event
|
1028
|
+
.composedPath()
|
1029
|
+
.find((item) => { var _a; return ((_a = item.dataset) === null || _a === void 0 ? void 0 : _a.jsHandle) !== undefined; });
|
1030
|
+
const item = event
|
1031
|
+
.composedPath()
|
1032
|
+
.find((item) => { var _a; return ((_a = item.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "calcite-value-list-item"; });
|
1033
|
+
return { handle, item };
|
1034
|
+
}
|
1035
|
+
function replacePlaceholders(text, label, position, total) {
|
1036
|
+
const replacePosition = text.replace("${position}", position.toString());
|
1037
|
+
const replaceLabel = replacePosition.replace("${item.label}", label);
|
1038
|
+
return replaceLabel.replace("${total}", total.toString());
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
const valueListCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{position:relative;box-sizing:border-box;display:flex;flex-shrink:0;flex-grow:0;flex-direction:column;align-items:stretch;background-color:transparent;font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2)}:host *{box-sizing:border-box}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}calcite-value-list-item:last-of-type{--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([filter-enabled]) header{-webkit-margin-after:0.25rem;margin-block-end:0.25rem;display:flex;align-items:center;justify-content:flex-end;background-color:var(--calcite-ui-foreground-1);--tw-shadow:0 1px 0 var(--calcite-ui-border-3);--tw-shadow-colored:0 1px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([filter-enabled]) header.sticky-pos{position:sticky;inset-block-start:0px;z-index:300}calcite-filter{-webkit-margin-after:1px;margin-block-end:1px}";
|
1042
|
+
|
1043
|
+
const ValueList = class {
|
1044
|
+
constructor(hostRef) {
|
1045
|
+
registerInstance(this, hostRef);
|
1046
|
+
this.calciteListChange = createEvent(this, "calciteListChange", 6);
|
1047
|
+
this.calciteListOrderChange = createEvent(this, "calciteListOrderChange", 6);
|
1048
|
+
// --------------------------------------------------------------------------
|
1049
|
+
//
|
1050
|
+
// Properties
|
1051
|
+
//
|
1052
|
+
// --------------------------------------------------------------------------
|
1053
|
+
/**
|
1054
|
+
* When `true`, interaction is prevented and the component is displayed with lower opacity.
|
1055
|
+
*/
|
1056
|
+
this.disabled = false;
|
1057
|
+
/**
|
1058
|
+
* When `true`, `calcite-value-list-item`s are sortable via a draggable button.
|
1059
|
+
*/
|
1060
|
+
this.dragEnabled = false;
|
1061
|
+
/**
|
1062
|
+
* When `true`, an input appears at the top of the component that can be used by end users to filter list items.
|
1063
|
+
*/
|
1064
|
+
this.filterEnabled = false;
|
1065
|
+
/**
|
1066
|
+
* When `true`, a busy indicator is displayed.
|
1067
|
+
*/
|
1068
|
+
this.loading = false;
|
1069
|
+
/**
|
1070
|
+
* Similar to standard radio buttons and checkboxes.
|
1071
|
+
* When `true`, a user can select multiple `calcite-value-list-item`s at a time.
|
1072
|
+
* When `false`, only a single `calcite-value-list-item` can be selected at a time,
|
1073
|
+
* and a new selection will deselect previous selections.
|
1074
|
+
*/
|
1075
|
+
this.multiple = false;
|
1076
|
+
/**
|
1077
|
+
* When `true` and single-selection is enabled, the selection changes when navigating `calcite-value-list-item`s via keyboard.
|
1078
|
+
*/
|
1079
|
+
this.selectionFollowsFocus = false;
|
1080
|
+
// --------------------------------------------------------------------------
|
1081
|
+
//
|
1082
|
+
// Private Properties
|
1083
|
+
//
|
1084
|
+
// --------------------------------------------------------------------------
|
1085
|
+
this.selectedValues = new Map();
|
1086
|
+
this.dataForFilter = [];
|
1087
|
+
this.lastSelectedItem = null;
|
1088
|
+
this.mutationObserver = createObserver("mutation", mutationObserverCallback.bind(this));
|
1089
|
+
this.setFilterEl = (el) => {
|
1090
|
+
this.filterEl = el;
|
1091
|
+
};
|
1092
|
+
this.deselectRemovedItems = deselectRemovedItems.bind(this);
|
1093
|
+
this.deselectSiblingItems = deselectSiblingItems.bind(this);
|
1094
|
+
this.selectSiblings = selectSiblings.bind(this);
|
1095
|
+
this.handleFilter = handleFilter.bind(this);
|
1096
|
+
this.getItemData = getItemData.bind(this);
|
1097
|
+
this.keyDownHandler = (event) => {
|
1098
|
+
if (event.defaultPrevented) {
|
1099
|
+
return;
|
1100
|
+
}
|
1101
|
+
const { handle, item } = getHandleAndItemElement(event);
|
1102
|
+
if (handle && !item.handleActivated && event.key === " ") {
|
1103
|
+
this.updateScreenReaderText(getScreenReaderText(item, "commit", this));
|
1104
|
+
}
|
1105
|
+
if (!handle || !item.handleActivated) {
|
1106
|
+
keyDownHandler.call(this, event);
|
1107
|
+
return;
|
1108
|
+
}
|
1109
|
+
const { items } = this;
|
1110
|
+
if (event.key === " ") {
|
1111
|
+
this.updateScreenReaderText(getScreenReaderText(item, "active", this));
|
1112
|
+
}
|
1113
|
+
if ((event.key !== "ArrowUp" && event.key !== "ArrowDown") || items.length <= 1) {
|
1114
|
+
return;
|
1115
|
+
}
|
1116
|
+
event.preventDefault();
|
1117
|
+
const { el } = this;
|
1118
|
+
const nextIndex = moveItemIndex(this, item, event.key === "ArrowUp" ? "up" : "down");
|
1119
|
+
if (nextIndex === items.length - 1) {
|
1120
|
+
el.appendChild(item);
|
1121
|
+
}
|
1122
|
+
else {
|
1123
|
+
const itemAtNextIndex = el.children[nextIndex];
|
1124
|
+
const insertionReferenceItem = itemAtNextIndex === item.nextElementSibling
|
1125
|
+
? itemAtNextIndex.nextElementSibling
|
1126
|
+
: itemAtNextIndex;
|
1127
|
+
el.insertBefore(item, insertionReferenceItem);
|
1128
|
+
}
|
1129
|
+
this.items = this.getItems();
|
1130
|
+
this.calciteListOrderChange.emit(this.items.map(({ value }) => value));
|
1131
|
+
requestAnimationFrame(() => handle === null || handle === void 0 ? void 0 : handle.focus());
|
1132
|
+
item.handleActivated = true;
|
1133
|
+
this.updateHandleAriaLabel(handle, getScreenReaderText(item, "change", this));
|
1134
|
+
};
|
1135
|
+
this.storeAssistiveEl = (el) => {
|
1136
|
+
this.assistiveTextEl = el;
|
1137
|
+
};
|
1138
|
+
this.handleFocusIn = (event) => {
|
1139
|
+
const { handle, item } = getHandleAndItemElement(event);
|
1140
|
+
if (!(item === null || item === void 0 ? void 0 : item.handleActivated) && item && handle) {
|
1141
|
+
this.updateHandleAriaLabel(handle, getScreenReaderText(item, "idle", this));
|
1142
|
+
}
|
1143
|
+
};
|
1144
|
+
}
|
1145
|
+
// --------------------------------------------------------------------------
|
1146
|
+
//
|
1147
|
+
// Lifecycle
|
1148
|
+
//
|
1149
|
+
// --------------------------------------------------------------------------
|
1150
|
+
connectedCallback() {
|
1151
|
+
initialize.call(this);
|
1152
|
+
initializeObserver.call(this);
|
1153
|
+
}
|
1154
|
+
componentDidLoad() {
|
1155
|
+
this.setUpDragAndDrop();
|
1156
|
+
}
|
1157
|
+
componentDidRender() {
|
1158
|
+
updateHostInteraction(this);
|
1159
|
+
}
|
1160
|
+
disconnectedCallback() {
|
1161
|
+
cleanUpObserver.call(this);
|
1162
|
+
this.cleanUpDragAndDrop();
|
1163
|
+
}
|
1164
|
+
calciteListFocusOutHandler(event) {
|
1165
|
+
calciteListFocusOutHandler.call(this, event);
|
1166
|
+
}
|
1167
|
+
calciteListItemRemoveHandler(event) {
|
1168
|
+
removeItem.call(this, event);
|
1169
|
+
}
|
1170
|
+
calciteListItemChangeHandler(event) {
|
1171
|
+
calciteListItemChangeHandler.call(this, event);
|
1172
|
+
}
|
1173
|
+
calciteInternalListItemPropsChangeHandler(event) {
|
1174
|
+
event.stopPropagation();
|
1175
|
+
this.setUpFilter();
|
1176
|
+
}
|
1177
|
+
calciteInternalListItemValueChangeHandler(event) {
|
1178
|
+
calciteInternalListItemValueChangeHandler.call(this, event);
|
1179
|
+
event.stopPropagation();
|
1180
|
+
}
|
1181
|
+
// --------------------------------------------------------------------------
|
1182
|
+
//
|
1183
|
+
// Private Methods
|
1184
|
+
//
|
1185
|
+
// --------------------------------------------------------------------------
|
1186
|
+
getItems() {
|
1187
|
+
return Array.from(this.el.querySelectorAll("calcite-value-list-item"));
|
1188
|
+
}
|
1189
|
+
setUpItems() {
|
1190
|
+
setUpItems.call(this, "calcite-value-list-item");
|
1191
|
+
}
|
1192
|
+
setUpFilter() {
|
1193
|
+
if (this.filterEnabled) {
|
1194
|
+
this.dataForFilter = this.getItemData();
|
1195
|
+
}
|
1196
|
+
}
|
1197
|
+
setUpDragAndDrop() {
|
1198
|
+
this.cleanUpDragAndDrop();
|
1199
|
+
if (!this.dragEnabled) {
|
1200
|
+
return;
|
1201
|
+
}
|
1202
|
+
this.sortable = Sortable.create(this.el, {
|
1203
|
+
dataIdAttr: "id",
|
1204
|
+
handle: `.${CSS.handle}`,
|
1205
|
+
draggable: "calcite-value-list-item",
|
1206
|
+
group: this.group,
|
1207
|
+
onSort: () => {
|
1208
|
+
this.items = Array.from(this.el.querySelectorAll("calcite-value-list-item"));
|
1209
|
+
const values = this.items.map((item) => item.value);
|
1210
|
+
this.calciteListOrderChange.emit(values);
|
1211
|
+
}
|
1212
|
+
});
|
1213
|
+
}
|
1214
|
+
cleanUpDragAndDrop() {
|
1215
|
+
var _a;
|
1216
|
+
(_a = this.sortable) === null || _a === void 0 ? void 0 : _a.destroy();
|
1217
|
+
this.sortable = null;
|
1218
|
+
}
|
1219
|
+
handleBlur() {
|
1220
|
+
if (this.dragEnabled) {
|
1221
|
+
this.updateScreenReaderText("");
|
1222
|
+
}
|
1223
|
+
}
|
1224
|
+
// --------------------------------------------------------------------------
|
1225
|
+
//
|
1226
|
+
// Public Methods
|
1227
|
+
//
|
1228
|
+
// --------------------------------------------------------------------------
|
1229
|
+
/** Returns the currently selected items */
|
1230
|
+
async getSelectedItems() {
|
1231
|
+
return this.selectedValues;
|
1232
|
+
}
|
1233
|
+
/**
|
1234
|
+
* Sets focus on the component.
|
1235
|
+
*
|
1236
|
+
* @param focusId
|
1237
|
+
*/
|
1238
|
+
async setFocus(focusId) {
|
1239
|
+
return setFocus.call(this, focusId);
|
1240
|
+
}
|
1241
|
+
// --------------------------------------------------------------------------
|
1242
|
+
//
|
1243
|
+
// Render Methods
|
1244
|
+
//
|
1245
|
+
// --------------------------------------------------------------------------
|
1246
|
+
getIconType() {
|
1247
|
+
let type = null;
|
1248
|
+
if (this.dragEnabled) {
|
1249
|
+
type = ICON_TYPES.grip;
|
1250
|
+
}
|
1251
|
+
return type;
|
1252
|
+
}
|
1253
|
+
updateScreenReaderText(text) {
|
1254
|
+
this.assistiveTextEl.textContent = text;
|
1255
|
+
}
|
1256
|
+
updateHandleAriaLabel(handleElement, text) {
|
1257
|
+
handleElement.ariaLabel = text;
|
1258
|
+
}
|
1259
|
+
render() {
|
1260
|
+
return (h(List, { onBlur: this.handleBlur, onFocusin: this.handleFocusIn, onKeyDown: this.keyDownHandler, props: this }));
|
1261
|
+
}
|
1262
|
+
get el() { return getElement(this); }
|
1263
|
+
};
|
1264
|
+
ValueList.style = valueListCss;
|
1265
|
+
|
1266
|
+
/*!
|
1267
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
1268
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
1269
|
+
* v1.0.0-beta.97
|
1270
|
+
*/
|
1271
|
+
const ICONS = {
|
1272
|
+
drag: "drag"
|
1273
|
+
};
|
1274
|
+
const SLOTS = {
|
1275
|
+
actionsEnd: "actions-end",
|
1276
|
+
actionsStart: "actions-start"
|
1277
|
+
};
|
1278
|
+
|
1279
|
+
const valueListItemCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{-webkit-margin-after:1px;margin-block-end:1px;box-sizing:border-box;display:flex;background-color:var(--calcite-ui-foreground-1);font-size:var(--calcite-font-size--1);color:var(--calcite-ui-text-2);--tw-shadow:0 1px 0 var(--calcite-ui-border-3);--tw-shadow-colored:0 1px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);transition:background-color var(--calcite-animation-timing), box-shadow var(--calcite-animation-timing)}:host *{box-sizing:border-box}calcite-pick-list-item{position:relative;margin:0px;flex-grow:1;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([active]),:host([selected]){--tw-shadow:0 0 0 1px var(--calcite-ui-brand);--tw-shadow-colored:0 0 0 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)}.handle{display:flex;cursor:move;align-items:center;justify-content:center;border-style:none;background-color:transparent;padding-block:0px;padding-inline:0.25rem;color:var(--calcite-ui-border-input);outline-color:transparent}.handle:hover{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1)}.handle:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.handle--activated{background-color:var(--calcite-ui-foreground-3);color:var(--calcite-ui-text-1)}.handle calcite-icon{color:inherit}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}";
|
1280
|
+
|
1281
|
+
const ValueListItem = class {
|
1282
|
+
constructor(hostRef) {
|
1283
|
+
registerInstance(this, hostRef);
|
1284
|
+
this.calciteListItemRemove = createEvent(this, "calciteListItemRemove", 7);
|
1285
|
+
/**
|
1286
|
+
* When `true`, interaction is prevented and the component is displayed with lower opacity.
|
1287
|
+
*/
|
1288
|
+
this.disabled = false;
|
1289
|
+
/**
|
1290
|
+
* @internal
|
1291
|
+
*/
|
1292
|
+
this.disableDeselect = false;
|
1293
|
+
/**
|
1294
|
+
* When `true`, prevents the content of the component from user interaction.
|
1295
|
+
*/
|
1296
|
+
this.nonInteractive = false;
|
1297
|
+
/**
|
1298
|
+
* @internal
|
1299
|
+
*/
|
1300
|
+
this.handleActivated = false;
|
1301
|
+
/**
|
1302
|
+
* Determines the icon SVG symbol that will be shown. Options are circle, square, grip or null.
|
1303
|
+
*
|
1304
|
+
* @see [ICON_TYPES](https://github.com/Esri/calcite-components/blob/master/src/components/pick-list/resources.ts#L5)
|
1305
|
+
*/
|
1306
|
+
this.icon = null;
|
1307
|
+
/**
|
1308
|
+
* When `true`, adds an action to remove the component.
|
1309
|
+
*/
|
1310
|
+
this.removable = false;
|
1311
|
+
/**
|
1312
|
+
* When `true`, the component is selected.
|
1313
|
+
*/
|
1314
|
+
this.selected = false;
|
1315
|
+
this.pickListItem = null;
|
1316
|
+
this.guid = `calcite-value-list-item-${guid()}`;
|
1317
|
+
// --------------------------------------------------------------------------
|
1318
|
+
//
|
1319
|
+
// Private Methods
|
1320
|
+
//
|
1321
|
+
// --------------------------------------------------------------------------
|
1322
|
+
this.getPickListRef = (el) => (this.pickListItem = el);
|
1323
|
+
this.handleKeyDown = (event) => {
|
1324
|
+
if (event.key === " ") {
|
1325
|
+
this.handleActivated = !this.handleActivated;
|
1326
|
+
}
|
1327
|
+
};
|
1328
|
+
this.handleBlur = () => {
|
1329
|
+
this.handleActivated = false;
|
1330
|
+
};
|
1331
|
+
this.handleSelectChange = (event) => {
|
1332
|
+
this.selected = event.detail.selected;
|
1333
|
+
};
|
1334
|
+
}
|
1335
|
+
// --------------------------------------------------------------------------
|
1336
|
+
//
|
1337
|
+
// Lifecycle
|
1338
|
+
//
|
1339
|
+
// --------------------------------------------------------------------------
|
1340
|
+
connectedCallback() {
|
1341
|
+
connectConditionalSlotComponent(this);
|
1342
|
+
}
|
1343
|
+
disconnectedCallback() {
|
1344
|
+
disconnectConditionalSlotComponent(this);
|
1345
|
+
}
|
1346
|
+
componentDidRender() {
|
1347
|
+
updateHostInteraction(this, this.el.closest("calcite-value-list") ? "managed" : false);
|
1348
|
+
}
|
1349
|
+
// --------------------------------------------------------------------------
|
1350
|
+
//
|
1351
|
+
// Public Methods
|
1352
|
+
//
|
1353
|
+
// --------------------------------------------------------------------------
|
1354
|
+
/**
|
1355
|
+
* Toggle the selection state. By default this won't trigger an event.
|
1356
|
+
* The first argument allows the value to be coerced, rather than swapping values.
|
1357
|
+
*
|
1358
|
+
* @param coerce
|
1359
|
+
*/
|
1360
|
+
async toggleSelected(coerce) {
|
1361
|
+
this.pickListItem.toggleSelected(coerce);
|
1362
|
+
}
|
1363
|
+
/** Set focus on the component. */
|
1364
|
+
async setFocus() {
|
1365
|
+
var _a;
|
1366
|
+
(_a = this.pickListItem) === null || _a === void 0 ? void 0 : _a.setFocus();
|
1367
|
+
}
|
1368
|
+
calciteListItemChangeHandler(event) {
|
1369
|
+
// adjust item payload from wrapped item before bubbling
|
1370
|
+
event.detail.item = this.el;
|
1371
|
+
}
|
1372
|
+
// --------------------------------------------------------------------------
|
1373
|
+
//
|
1374
|
+
// Render Methods
|
1375
|
+
//
|
1376
|
+
// --------------------------------------------------------------------------
|
1377
|
+
renderActionsEnd() {
|
1378
|
+
const { el } = this;
|
1379
|
+
const hasActionsEnd = getSlotted(el, SLOTS.actionsEnd);
|
1380
|
+
return hasActionsEnd ? (h("slot", { name: SLOTS.actionsEnd, slot: SLOTS$3.actionsEnd })) : null;
|
1381
|
+
}
|
1382
|
+
renderActionsStart() {
|
1383
|
+
const { el } = this;
|
1384
|
+
const hasActionsStart = getSlotted(el, SLOTS.actionsStart);
|
1385
|
+
return hasActionsStart ? (h("slot", { name: SLOTS.actionsStart, slot: SLOTS$3.actionsStart })) : null;
|
1386
|
+
}
|
1387
|
+
renderHandle() {
|
1388
|
+
const { icon } = this;
|
1389
|
+
if (icon === ICON_TYPES$1.grip) {
|
1390
|
+
return (h("span", { class: {
|
1391
|
+
[CSS$2.handle]: true,
|
1392
|
+
[CSS$2.handleActivated]: this.handleActivated
|
1393
|
+
}, "data-js-handle": true, onBlur: this.handleBlur, onKeyDown: this.handleKeyDown, role: "button", tabindex: "0" }, h("calcite-icon", { icon: ICONS.drag, scale: "s" })));
|
1394
|
+
}
|
1395
|
+
}
|
1396
|
+
render() {
|
1397
|
+
return (h(Host, { id: this.el.id || this.guid }, this.renderHandle(), h("calcite-pick-list-item", { description: this.description, disableDeselect: this.disableDeselect, disabled: this.disabled, label: this.label, metadata: this.metadata, nonInteractive: this.nonInteractive, onCalciteListItemChange: this.handleSelectChange, ref: this.getPickListRef, removable: this.removable, selected: this.selected, value: this.value }, this.renderActionsStart(), this.renderActionsEnd())));
|
1398
|
+
}
|
1399
|
+
get el() { return getElement(this); }
|
1400
|
+
};
|
1401
|
+
ValueListItem.style = valueListItemCss;
|
1402
|
+
|
1403
|
+
const jsonEditorCss = ":host{display:block;box-sizing:border-box;margin-left:0.75rem;margin-right:0.75rem;min-width:0;flex-grow:0;flex-shrink:1}:host-group-1-up>.block{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}:host-group-2-up>.block{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}:host-group-3-up>.block{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}:host-group-4-up>.block{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}:host-group-5-up>.block{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}:host-group-6-up>.block{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}:host-group-7-up>.block{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}:host-group-8-up>.block{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.tablet-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.tablet-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.tablet-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.tablet-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.tablet-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.tablet-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.tablet-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.tablet-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.phone-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.phone-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.phone-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.phone-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.phone-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.phone-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.phone-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.phone-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.code-face :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:normal}.code-face :host b,.code-face :host strong{font-weight:400}.code-italic :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:italic}.code-italic :host b,.code-italic :host strong{font-weight:400}.editor-container{position:relative;height:100%}.editor-controls{height:2.75rem;padding-right:0.5rem;background-color:#F4F4F4}.editor-buttons{float:right}html[dir=rtl] .editor-buttons{float:left}.edit-error-flag{padding-top:0.5rem;color:red;visibility:hidden}.edit-button{-webkit-padding-start:0.5rem;padding-inline-start:0.5rem}.editor-text{width:100%;overflow-y:auto;background-color:#FFFFFF}.edit-width{width:100%}.edit-parent{box-sizing:border-box;width:100%;height:calc(100% - 46px)}.json-edit-container{height:100%;width:100%;border:1px #808080 solid}.padding-right{-webkit-padding-end:0.125rem;padding-inline-end:0.125rem}.btn{margin-bottom:1rem;display:flex;align-content:center;height:25px;width:120px}.select-ctrl{margin-bottom:1rem}.all-edits{margin-top:4rem}.floating-title{font-size:2rem;z-index:100;position:absolute;left:0.5rem;pointer-events:none}.floating-title-button{pointer-events:auto}.json-editor-position1{position:absolute;left:0px;top:0px;margin:0px;height:100%;width:100%;padding:0px;overflow:hidden;max-height:100% !important}.json-editor-position2a{position:absolute;left:0px;top:0px;margin:0px;height:100%;width:50%;padding:0px;overflow:hidden;max-height:100% !important}.json-editor-position2b{position:absolute;right:0px;top:0px;margin:0px;height:100%;width:50%;padding:0px;overflow:hidden;max-height:100% !important}";
|
1404
|
+
|
1405
|
+
const JsonEditor = class {
|
1406
|
+
constructor(hostRef) {
|
1407
|
+
registerInstance(this, hostRef);
|
1408
|
+
this._loaded = false;
|
1409
|
+
this._useDiffEditor = false;
|
1410
|
+
this.hasChanges = false;
|
1411
|
+
this.hasErrors = false;
|
1412
|
+
this.instanceid = "";
|
1413
|
+
this.value = "";
|
1414
|
+
}
|
1415
|
+
//--------------------------------------------------------------------------
|
1416
|
+
//
|
1417
|
+
// Lifecycle
|
1418
|
+
//
|
1419
|
+
//--------------------------------------------------------------------------
|
1420
|
+
/**
|
1421
|
+
* StencilJS: Called once just after the component is fully loaded and the first render() occurs.
|
1422
|
+
*/
|
1423
|
+
componentDidLoad() {
|
1424
|
+
const editorContainer = document.getElementById(`${this.instanceid}-container`);
|
1425
|
+
if (editorContainer) {
|
1426
|
+
this._editor = monaco.editor.create(editorContainer, {
|
1427
|
+
value: this.value,
|
1428
|
+
language: "json",
|
1429
|
+
theme: "vs",
|
1430
|
+
minimap: {
|
1431
|
+
enabled: false
|
1432
|
+
},
|
1433
|
+
automaticLayout: true,
|
1434
|
+
scrollBeyondLastLine: false
|
1435
|
+
});
|
1436
|
+
this._currentModel = this._editor.getModel();
|
1437
|
+
this._contentChanged = this._currentModel.onDidChangeContent(this._onEditorChange.bind(this));
|
1438
|
+
// Intercept the monaco function call that shows error markers to see if our content has errors
|
1439
|
+
const setModelMarkers = monaco.editor.setModelMarkers;
|
1440
|
+
const self = this;
|
1441
|
+
monaco.editor.setModelMarkers = function (model, owner, markers) {
|
1442
|
+
var _a, _b;
|
1443
|
+
// If this call was for our model, it acts like an onEditorChange event
|
1444
|
+
// but gives us access to the error state as well
|
1445
|
+
if (model.id === self._currentModel.id) {
|
1446
|
+
// Set the error state & dispatch event if state has changed
|
1447
|
+
self._flagEditorHasErrors(markers.length > 0);
|
1448
|
+
// Set the changed state & dispatch event if state has changed, but only if there are no errors
|
1449
|
+
if (!self.hasErrors) {
|
1450
|
+
self._flagEditorHasChanges((_a = self._currentModel) === null || _a === void 0 ? void 0 : _a.canUndo());
|
1451
|
+
if ((_b = self._currentModel) === null || _b === void 0 ? void 0 : _b.canUndo()) {
|
1452
|
+
self._flagEditorContentChanged();
|
1453
|
+
}
|
1454
|
+
}
|
1455
|
+
// Show the error flag if there are errors
|
1456
|
+
const errorFlag = document.getElementById(`${self.instanceid}-errorFlag`);
|
1457
|
+
errorFlag.style.visibility = self.hasErrors ? "visible" : "hidden";
|
1458
|
+
}
|
1459
|
+
// Pass on the call to the next editor in a chain of intercepts or, finally, to monaco
|
1460
|
+
setModelMarkers.call(monaco.editor, model, owner, markers);
|
1461
|
+
};
|
1462
|
+
this._diffEditor = monaco.editor.createDiffEditor(document.getElementById(`${this.instanceid}-diff-container`), {
|
1463
|
+
automaticLayout: true
|
1464
|
+
});
|
1465
|
+
this._setDiffModel();
|
1466
|
+
this._loaded = true;
|
1467
|
+
this._toggleUndoRedo();
|
1468
|
+
}
|
1469
|
+
}
|
1470
|
+
/**
|
1471
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
1472
|
+
*
|
1473
|
+
* @returns Promise when complete
|
1474
|
+
*/
|
1475
|
+
async componentWillLoad() {
|
1476
|
+
this._initValueObserver();
|
1477
|
+
await this._getTranslations();
|
1478
|
+
return;
|
1479
|
+
}
|
1480
|
+
/**
|
1481
|
+
* Renders the component.
|
1482
|
+
*/
|
1483
|
+
render() {
|
1484
|
+
return (h(Host, null, h("div", { id: `${this.instanceid}-editor-container`, class: "editor-container padding-right" }, h("div", { class: "editor-controls" }, h("div", { class: "editor-buttons" }, h("calcite-icon", { id: `${this.instanceid}-errorFlag`, icon: "exclamation-mark-triangle", title: this._translations.errorFlag, scale: "s", class: "edit-error-flag" }), h("calcite-button", { id: `${this.instanceid}-undo`, color: "blue", appearance: "solid", title: this._translations.undo, onClick: () => this._undo(), scale: "s", class: "edit-button" }, h("calcite-icon", { icon: "undo", scale: "s" })), h("calcite-button", { id: `${this.instanceid}-redo`, color: "blue", appearance: "solid", title: this._translations.redo, onClick: () => this._redo(), scale: "s", class: "edit-button" }, h("calcite-icon", { icon: "redo", scale: "s" })), h("calcite-button", { id: `${this.instanceid}-diff`, color: "blue", appearance: "solid", title: this._translations.diff, onClick: () => this._toggleEditor(), scale: "s", class: "edit-button" }, h("calcite-icon", { icon: "compare", scale: "s" })), h("calcite-button", { id: `${this.instanceid}-search`, appearance: "outline", color: "blue", title: this._translations.search, onClick: () => this._search(), scale: "s", class: "edit-button" }, h("calcite-icon", { icon: "search", scale: "s" })), h("calcite-button", { id: `${this.instanceid}-reset`, color: "blue", appearance: "solid", disabled: true, title: this._translations.cancelEdits, onClick: () => this._reset(), scale: "s", class: "edit-button" }, h("calcite-icon", { icon: "reset", scale: "s" })))), h("div", { class: "edit-parent" }, h("div", { id: `${this.instanceid}-container`, class: "json-edit-container" }), h("div", { id: `${this.instanceid}-diff-container`, class: "json-edit-container display-none" })))));
|
1485
|
+
}
|
1486
|
+
//--------------------------------------------------------------------------
|
1487
|
+
//
|
1488
|
+
// Event Listeners
|
1489
|
+
//
|
1490
|
+
//--------------------------------------------------------------------------
|
1491
|
+
//--------------------------------------------------------------------------
|
1492
|
+
//
|
1493
|
+
// Events
|
1494
|
+
//
|
1495
|
+
//--------------------------------------------------------------------------
|
1496
|
+
//--------------------------------------------------------------------------
|
1497
|
+
//
|
1498
|
+
// Public Methods (async)
|
1499
|
+
//
|
1500
|
+
//--------------------------------------------------------------------------
|
1501
|
+
/**
|
1502
|
+
* Gets the contents of the editor.
|
1503
|
+
*
|
1504
|
+
* @returns Promise resolving with the current contents of the editor
|
1505
|
+
*/
|
1506
|
+
async getEditorContents() {
|
1507
|
+
return new Promise((resolve, reject) => {
|
1508
|
+
try {
|
1509
|
+
const currentValue = this._currentModel.getValue();
|
1510
|
+
resolve(currentValue);
|
1511
|
+
}
|
1512
|
+
catch (e) {
|
1513
|
+
reject(e);
|
1514
|
+
}
|
1515
|
+
});
|
1516
|
+
}
|
1517
|
+
/**
|
1518
|
+
* Frees the editor events and memory; to be called when the web component is no longer needed.
|
1519
|
+
*
|
1520
|
+
* Because the component lifecycle doesn't include an "onDestroy" event
|
1521
|
+
* (@see https://stenciljs.com/docs/component-lifecycle#disconnectedcallback)
|
1522
|
+
* and TypeScript/JavaScript does automatic garbage collection without a callback
|
1523
|
+
* hook until ES2021
|
1524
|
+
* (@see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry),
|
1525
|
+
* this cleanup call needs to be called manually.
|
1526
|
+
*/
|
1527
|
+
async prepareForDeletion() {
|
1528
|
+
var _a, _b, _c, _d, _e;
|
1529
|
+
(_a = this._searchBtnHandler) === null || _a === void 0 ? void 0 : _a.removeEventListener("click", this._search);
|
1530
|
+
(_b = this._cancelEditsBtnHandler) === null || _b === void 0 ? void 0 : _b.removeEventListener("click", this._reset);
|
1531
|
+
(_c = this._valueObserver) === null || _c === void 0 ? void 0 : _c.disconnect();
|
1532
|
+
(_d = this._contentChanged) === null || _d === void 0 ? void 0 : _d.dispose();
|
1533
|
+
(_e = this._editor) === null || _e === void 0 ? void 0 : _e.dispose();
|
1534
|
+
}
|
1535
|
+
/**
|
1536
|
+
* Replaces the current selection with the supplied text, inserting if nothing is selected.
|
1537
|
+
*
|
1538
|
+
* @param replacement Text to use for replacement or insertion
|
1539
|
+
* @returns Promise resolving when function is done
|
1540
|
+
*/
|
1541
|
+
async replaceCurrentSelection(replacement) {
|
1542
|
+
const currentSelection = this._editor.getSelection();
|
1543
|
+
this._editor.executeEdits("", [
|
1544
|
+
{ range: currentSelection, text: replacement }
|
1545
|
+
]);
|
1546
|
+
}
|
1547
|
+
/**
|
1548
|
+
* Resets the contents of the editor with the current `value`.
|
1549
|
+
*
|
1550
|
+
* @returns Promise resolving when function is done
|
1551
|
+
*/
|
1552
|
+
async reset() {
|
1553
|
+
return new Promise((resolve, reject) => {
|
1554
|
+
try {
|
1555
|
+
this._reset();
|
1556
|
+
resolve({ success: true });
|
1557
|
+
}
|
1558
|
+
catch (e) {
|
1559
|
+
reject(e);
|
1560
|
+
}
|
1561
|
+
});
|
1562
|
+
}
|
1563
|
+
//--------------------------------------------------------------------------
|
1564
|
+
//
|
1565
|
+
// Private Methods
|
1566
|
+
//
|
1567
|
+
//--------------------------------------------------------------------------
|
1568
|
+
/**
|
1569
|
+
* Disables a button.
|
1570
|
+
*
|
1571
|
+
* @param buttonId Id of button to disable
|
1572
|
+
*
|
1573
|
+
* @protected
|
1574
|
+
*/
|
1575
|
+
_disableButton(buttonId) {
|
1576
|
+
var _a;
|
1577
|
+
(_a = document.getElementById(buttonId)) === null || _a === void 0 ? void 0 : _a.setAttribute("disabled", "");
|
1578
|
+
}
|
1579
|
+
/**
|
1580
|
+
* Enables a button.
|
1581
|
+
*
|
1582
|
+
* @param buttonId Id of button to enable
|
1583
|
+
*
|
1584
|
+
* @protected
|
1585
|
+
*/
|
1586
|
+
_enableButton(buttonId) {
|
1587
|
+
var _a;
|
1588
|
+
(_a = document.getElementById(buttonId)) === null || _a === void 0 ? void 0 : _a.removeAttribute("disabled");
|
1589
|
+
}
|
1590
|
+
/**
|
1591
|
+
* Dispatches an event that the editor's content has changed.
|
1592
|
+
*
|
1593
|
+
* @protected
|
1594
|
+
*/
|
1595
|
+
_flagEditorContentChanged() {
|
1596
|
+
// Event for notifying that the editor contents have changed
|
1597
|
+
window.dispatchEvent(new CustomEvent("solutionEditorContentChanged", {
|
1598
|
+
detail: {
|
1599
|
+
id: this.instanceid,
|
1600
|
+
contents: this._currentModel.getValue()
|
1601
|
+
},
|
1602
|
+
bubbles: true,
|
1603
|
+
cancelable: false,
|
1604
|
+
composed: true
|
1605
|
+
}));
|
1606
|
+
}
|
1607
|
+
/**
|
1608
|
+
* Sets the editor's flag indicating if it has changes and dispatches an event when
|
1609
|
+
* the flag value changes.
|
1610
|
+
*
|
1611
|
+
* @param flagHasChanges Current state of change in the editor; if it doesn't match the value saved in this
|
1612
|
+
* object, an event is dispatched with the new value and the saved value is updated
|
1613
|
+
*
|
1614
|
+
* @protected
|
1615
|
+
*/
|
1616
|
+
_flagEditorHasChanges(flagHasChanges) {
|
1617
|
+
// Event for notifying if the editor has updated the value of its hasChanges property
|
1618
|
+
if (this.hasChanges !== flagHasChanges) {
|
1619
|
+
window.dispatchEvent(new CustomEvent("solutionEditorHasChanges", {
|
1620
|
+
detail: flagHasChanges,
|
1621
|
+
bubbles: true,
|
1622
|
+
cancelable: false,
|
1623
|
+
composed: true
|
1624
|
+
}));
|
1625
|
+
this.hasChanges = flagHasChanges;
|
1626
|
+
}
|
1627
|
+
}
|
1628
|
+
/**
|
1629
|
+
* Sets the editor's flag indicating if it has errors and dispatches an event when
|
1630
|
+
* the flag value changes.
|
1631
|
+
*
|
1632
|
+
* @param flagHasErrors Current state of errors in the editor; if it doesn't match the value saved in this
|
1633
|
+
* object, an event is dispatched with the new value and the saved value is updated
|
1634
|
+
*
|
1635
|
+
* @protected
|
1636
|
+
*/
|
1637
|
+
_flagEditorHasErrors(flagHasErrors) {
|
1638
|
+
// Event for notifying if the editor has updated the value of its hasErrors property
|
1639
|
+
if (this.hasErrors !== flagHasErrors) {
|
1640
|
+
window.dispatchEvent(new CustomEvent("solutionEditorHasErrors", {
|
1641
|
+
detail: flagHasErrors,
|
1642
|
+
bubbles: true,
|
1643
|
+
cancelable: false,
|
1644
|
+
composed: true
|
1645
|
+
}));
|
1646
|
+
this.hasErrors = flagHasErrors;
|
1647
|
+
}
|
1648
|
+
}
|
1649
|
+
/**
|
1650
|
+
* Fetches the component's translations
|
1651
|
+
*
|
1652
|
+
* @protected
|
1653
|
+
*/
|
1654
|
+
async _getTranslations() {
|
1655
|
+
const translations = await getLocaleComponentStrings(this.el);
|
1656
|
+
this._translations = translations[0];
|
1657
|
+
}
|
1658
|
+
/**
|
1659
|
+
* Initializes the observer that will monitor and respond to changes of the value.
|
1660
|
+
*
|
1661
|
+
* @protected
|
1662
|
+
*/
|
1663
|
+
_initValueObserver() {
|
1664
|
+
this._valueObserver = new MutationObserver(ml => {
|
1665
|
+
ml.forEach(mutation => {
|
1666
|
+
if (mutation.type === 'attributes' && mutation.attributeName === "value") {
|
1667
|
+
const newValue = mutation.target[mutation.attributeName];
|
1668
|
+
if ((newValue !== mutation.oldValue && this._loaded)) {
|
1669
|
+
this._currentModel.setValue(this.value);
|
1670
|
+
}
|
1671
|
+
}
|
1672
|
+
});
|
1673
|
+
});
|
1674
|
+
this._valueObserver.observe(this.el, { attributes: true, attributeOldValue: true });
|
1675
|
+
}
|
1676
|
+
/**
|
1677
|
+
* Handles activites appropriate to changes in the editor.
|
1678
|
+
*
|
1679
|
+
* @protected
|
1680
|
+
*/
|
1681
|
+
_onEditorChange() {
|
1682
|
+
// Note: we're not flagging that the editor has changes here because this event
|
1683
|
+
// arrives before the model markers event, which indicates errors. We don't want
|
1684
|
+
// to notify about changes if there are errors.
|
1685
|
+
this._toggleUndoRedo();
|
1686
|
+
}
|
1687
|
+
/**
|
1688
|
+
* Redoes the previous edit operation.
|
1689
|
+
*
|
1690
|
+
* @protected
|
1691
|
+
*/
|
1692
|
+
_redo() {
|
1693
|
+
var _a;
|
1694
|
+
if ((_a = this._currentModel) === null || _a === void 0 ? void 0 : _a.canRedo()) {
|
1695
|
+
this._currentModel.redo();
|
1696
|
+
this._toggleUndoRedo();
|
1697
|
+
}
|
1698
|
+
}
|
1699
|
+
/**
|
1700
|
+
* Resets the stored model to the original value.
|
1701
|
+
*
|
1702
|
+
* @protected
|
1703
|
+
*/
|
1704
|
+
_reset() {
|
1705
|
+
// Restore the original value
|
1706
|
+
this._currentModel.setValue(this.value);
|
1707
|
+
// update the ui
|
1708
|
+
this._toggleUndoRedo();
|
1709
|
+
}
|
1710
|
+
/**
|
1711
|
+
* Handles click on "Search" button.
|
1712
|
+
*
|
1713
|
+
* @protected
|
1714
|
+
*/
|
1715
|
+
_search() {
|
1716
|
+
this._editor.trigger('toggleFind', 'actions.find');
|
1717
|
+
}
|
1718
|
+
/**
|
1719
|
+
* Sets the models for the diff editor.
|
1720
|
+
*
|
1721
|
+
* @protected
|
1722
|
+
*/
|
1723
|
+
_setDiffModel() {
|
1724
|
+
if (this._diffEditor) {
|
1725
|
+
this._diffEditor.setModel({
|
1726
|
+
original: monaco.editor.createModel(this.value, "json"),
|
1727
|
+
modified: this._editor.getModel()
|
1728
|
+
});
|
1729
|
+
}
|
1730
|
+
}
|
1731
|
+
/**
|
1732
|
+
* Shows/Hides the appropriate editor: regular or diff.
|
1733
|
+
*
|
1734
|
+
* @protected
|
1735
|
+
*/
|
1736
|
+
_toggleEditor() {
|
1737
|
+
this._useDiffEditor = !this._useDiffEditor;
|
1738
|
+
let diffContainer = document.getElementById(`${this.instanceid}-diff-container`);
|
1739
|
+
let container = document.getElementById(`${this.instanceid}-container`);
|
1740
|
+
if (this._useDiffEditor) {
|
1741
|
+
this._setDiffModel();
|
1742
|
+
diffContainer.classList.remove("display-none");
|
1743
|
+
container.classList.add("display-none");
|
1744
|
+
}
|
1745
|
+
else {
|
1746
|
+
diffContainer.classList.add("display-none");
|
1747
|
+
container.classList.remove("display-none");
|
1748
|
+
}
|
1749
|
+
}
|
1750
|
+
/**
|
1751
|
+
* Toggles the undo and redo buttons.
|
1752
|
+
*
|
1753
|
+
* @protected
|
1754
|
+
*/
|
1755
|
+
_toggleUndoRedo() {
|
1756
|
+
var _a, _b, _c, _d;
|
1757
|
+
if ((_a = this._currentModel) === null || _a === void 0 ? void 0 : _a.canUndo()) {
|
1758
|
+
this._enableButton(`${this.instanceid}-undo`);
|
1759
|
+
}
|
1760
|
+
else {
|
1761
|
+
this._disableButton(`${this.instanceid}-undo`);
|
1762
|
+
}
|
1763
|
+
if ((_b = this._currentModel) === null || _b === void 0 ? void 0 : _b.canRedo()) {
|
1764
|
+
this._enableButton(`${this.instanceid}-redo`);
|
1765
|
+
}
|
1766
|
+
else {
|
1767
|
+
this._disableButton(`${this.instanceid}-redo`);
|
1768
|
+
}
|
1769
|
+
if (((_c = this._currentModel) === null || _c === void 0 ? void 0 : _c.canUndo()) || ((_d = this._currentModel) === null || _d === void 0 ? void 0 : _d.canRedo())) {
|
1770
|
+
this._enableButton(`${this.instanceid}-reset`);
|
1771
|
+
}
|
1772
|
+
else {
|
1773
|
+
this._disableButton(`${this.instanceid}-reset`);
|
1774
|
+
}
|
1775
|
+
}
|
1776
|
+
/**
|
1777
|
+
* Undoes the current edit operation.
|
1778
|
+
*
|
1779
|
+
* @protected
|
1780
|
+
*/
|
1781
|
+
_undo() {
|
1782
|
+
var _a;
|
1783
|
+
if ((_a = this._currentModel) === null || _a === void 0 ? void 0 : _a.canUndo()) {
|
1784
|
+
this._currentModel.undo();
|
1785
|
+
this._toggleUndoRedo();
|
1786
|
+
}
|
1787
|
+
}
|
1788
|
+
static get assetsDirs() { return ["assets"]; }
|
1789
|
+
get el() { return getElement(this); }
|
1790
|
+
};
|
1791
|
+
JsonEditor.style = jsonEditorCss;
|
1792
|
+
|
1793
|
+
const solutionItemDetailsCss = ".inputBottomSeparation{margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:1.5rem}.icon-inline--on-left,.icon-inline--on-right{display:inline;vertical-align:middle;-webkit-margin-end:0.375rem;margin-inline-end:0.375rem;fill:#0079c1}.scale-down{-o-object-fit:scale-down;object-fit:scale-down}.img-container{display:inline;-webkit-margin-end:1rem;margin-inline-end:1rem;max-width:363px}.summary-count-container{display:inline;flex-grow:1;-webkit-margin-start:0.75rem;margin-inline-start:0.75rem}.snippet-count-container{width:calc(100vw - 363px)}.parent-container{max-width:100%;padding:1rem}label{position:relative;margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:1.5rem;display:block;min-width:-moz-min-content;min-width:min-content;box-sizing:border-box;margin-left:0.75rem;margin-right:0.75rem;min-width:0;flex-grow:0;flex-shrink:1}label-group-1-up>.block{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}label-group-2-up>.block{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}label-group-3-up>.block{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}label-group-4-up>.block{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}label-group-5-up>.block{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}label-group-6-up>.block{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}label-group-7-up>.block{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}label-group-8-up>.block{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.tablet-block-group-1-up>label{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.tablet-block-group-2-up>label{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.tablet-block-group-3-up>label{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.tablet-block-group-4-up>label{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.tablet-block-group-5-up>label{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.tablet-block-group-6-up>label{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.tablet-block-group-7-up>label{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.tablet-block-group-8-up>label{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.phone-block-group-1-up>label{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.phone-block-group-2-up>label{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.phone-block-group-3-up>label{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.phone-block-group-4-up>label{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.phone-block-group-5-up>label{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.phone-block-group-6-up>label{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.phone-block-group-7-up>label{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.phone-block-group-8-up>label{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.code-face label{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:normal}.code-face label b,.code-face label strong{font-weight:400}.code-italic label{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:italic}.code-italic label b,.code-italic label strong{font-weight:400}";
|
1794
|
+
|
1795
|
+
const SolutionItemDetails = class {
|
1796
|
+
constructor(hostRef) {
|
1797
|
+
registerInstance(this, hostRef);
|
1798
|
+
this.itemId = "";
|
1799
|
+
this.itemDetails = {
|
1800
|
+
accessInformation: "",
|
1801
|
+
description: "",
|
1802
|
+
licenseInfo: "",
|
1803
|
+
snippet: "",
|
1804
|
+
tags: [],
|
1805
|
+
title: ""
|
1806
|
+
};
|
1807
|
+
this.itemEdit = undefined;
|
1808
|
+
this._translations = undefined;
|
1809
|
+
this.thumbnail = undefined;
|
1810
|
+
this.thumbnailContainer = undefined;
|
1811
|
+
}
|
1812
|
+
//--------------------------------------------------------------------------
|
1813
|
+
//
|
1814
|
+
// Lifecycle
|
1815
|
+
//
|
1816
|
+
//--------------------------------------------------------------------------
|
1817
|
+
/**
|
1818
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
1819
|
+
*/
|
1820
|
+
async componentWillLoad() {
|
1821
|
+
return this._getTranslations();
|
1822
|
+
}
|
1823
|
+
async componentWillRender() {
|
1824
|
+
this.itemEdit = state.getItemInfo(this.itemId);
|
1825
|
+
if (this.itemEdit) {
|
1826
|
+
this.itemDetails = this.itemEdit.item;
|
1827
|
+
this.itemType = this.itemDetails.type;
|
1828
|
+
}
|
1829
|
+
return Promise.resolve();
|
1830
|
+
}
|
1831
|
+
/**
|
1832
|
+
* Renders the component.
|
1833
|
+
*/
|
1834
|
+
render() {
|
1835
|
+
return (h(Host, null, h("div", { class: "parent-container" }, h("div", { class: "inputBottomSeparation" }, h("calcite-input", { id: "item-title", value: this.itemDetails.title })), h("div", { class: "inputBottomSeparation" }, h("input", { accept: ".jpg,.gif,.png,image/jpg,image/gif,image/png", class: "display-none", onChange: (event) => (this._updateThumbnail(event)), ref: (el) => (this.browseForThumbnail = el), type: "file" }), h("button", { class: "font-size--3 btn-link inline-block trailer-quarter", onClick: () => this._getThumbnail() }, h("svg", { class: "icon-inline icon-inline--on-left", height: "16", viewBox: "0 0 16 16", width: "16" }, h("path", { d: "M14.792 2.666l-1.414-1.413a.965.965 0 0 0-1.385-.03l-1.444 1.444-8.763 8.72L.03 15.481a.371.371 0 0 0 .488.488l4.096-1.756 8.763-8.72-.001-.001.002.002 1.443-1.444a.965.965 0 0 0-.03-1.385zM1.569 14.431l.554-1.293.74.739zm2.338-.924l-1.414-1.414 7.963-7.92 1.414 1.415zm8.67-8.626l-1.413-1.414 1.29-1.29a.306.306 0 0 1 .433 0l.981.98a.306.306 0 0 1 0 .433z" })), this._translations.editThumbnail), h("div", { class: "flex" }, h("div", { class: "img-container", ref: (el) => (this.thumbnailContainer = el) }, h("img", { class: "scale-down", height: "133", id: "item-thumbnail", ref: (el) => (this.thumbnail = el), width: "200" })), h("div", { class: "snippet-count-container" }, h("calcite-input", { id: "item-snippet", maxLength: 250, type: "textarea", value: this.itemDetails.snippet }), h("label", { class: "font-size--3", id: "item-snippet-count", ref: (el) => (this.itemSnippetCount = el) })))), h("calcite-label", null, this._translations.description, h("label", { id: "item-description-label" }, h("calcite-input", { id: "item-description", type: "textarea", value: this.itemDetails.description }))), h("calcite-label", null, this._translations.tags, h("label", { id: "item-tags-label" }, h("calcite-input", { id: "item-tags", value: (this.itemDetails.tags && Array.isArray(this.itemDetails.tags) ? this.itemDetails.tags : [this.itemDetails.tags]).join(",") }))), this.itemType !== "Group" ? h("calcite-label", null, this._translations.credits, h("label", { id: "item-credits-label" }, h("calcite-input", { id: "item-credits", value: this.itemDetails.accessInformation }))) : null, this.itemType !== "Group" ? h("calcite-label", null, h("label", { id: "item-terms-label" }, this._translations.termsOfUse, h("calcite-input", { id: "item-terms", type: "textarea", value: this.itemDetails.licenseInfo }))) : null)));
|
1836
|
+
}
|
1837
|
+
componentDidRender() {
|
1838
|
+
this._loadThumb();
|
1839
|
+
}
|
1840
|
+
//--------------------------------------------------------------------------
|
1841
|
+
//
|
1842
|
+
// Event Listeners
|
1843
|
+
//
|
1844
|
+
//--------------------------------------------------------------------------
|
1845
|
+
/**
|
1846
|
+
* Updates the component's value with changes to the input fields.
|
1847
|
+
*/
|
1848
|
+
inputReceivedHandler(event) {
|
1849
|
+
switch (event.target.id) {
|
1850
|
+
case "item-title":
|
1851
|
+
this.itemDetails.title = event.target.value;
|
1852
|
+
this._updateStore();
|
1853
|
+
break;
|
1854
|
+
case "item-snippet":
|
1855
|
+
if (event.target.value.length > 250) {
|
1856
|
+
event.target.value = event.target.value.substring(0, 250);
|
1857
|
+
}
|
1858
|
+
this.itemDetails.snippet = event.target.value;
|
1859
|
+
this._updateLengthLabel(this.itemDetails.snippet);
|
1860
|
+
this._updateStore();
|
1861
|
+
break;
|
1862
|
+
case "item-description":
|
1863
|
+
this.itemDetails.description = event.target.value;
|
1864
|
+
this._updateStore();
|
1865
|
+
break;
|
1866
|
+
case "item-tags":
|
1867
|
+
this.itemDetails.tags = event.target.value;
|
1868
|
+
this._updateStore();
|
1869
|
+
break;
|
1870
|
+
case "item-credits":
|
1871
|
+
this.itemDetails.accessInformation = event.target.value;
|
1872
|
+
this._updateStore();
|
1873
|
+
break;
|
1874
|
+
case "item-terms":
|
1875
|
+
this.itemDetails.licenseInfo = event.target.value;
|
1876
|
+
this._updateStore();
|
1877
|
+
break;
|
1878
|
+
}
|
1879
|
+
}
|
1880
|
+
//--------------------------------------------------------------------------
|
1881
|
+
//
|
1882
|
+
// Events
|
1883
|
+
//
|
1884
|
+
//--------------------------------------------------------------------------
|
1885
|
+
//--------------------------------------------------------------------------
|
1886
|
+
//
|
1887
|
+
// Public Methods (async)
|
1888
|
+
//
|
1889
|
+
//--------------------------------------------------------------------------
|
1890
|
+
//--------------------------------------------------------------------------
|
1891
|
+
//
|
1892
|
+
// Private Methods
|
1893
|
+
//
|
1894
|
+
//--------------------------------------------------------------------------
|
1895
|
+
/**
|
1896
|
+
* Opens image file browse dialog.
|
1897
|
+
*
|
1898
|
+
*/
|
1899
|
+
_getThumbnail() {
|
1900
|
+
this.browseForThumbnail.click();
|
1901
|
+
}
|
1902
|
+
/**
|
1903
|
+
* Load the templates thumbnail
|
1904
|
+
*
|
1905
|
+
*/
|
1906
|
+
_loadThumb() {
|
1907
|
+
var _a;
|
1908
|
+
if (this.thumbnail && ((_a = this.itemEdit) === null || _a === void 0 ? void 0 : _a.thumbnail)) {
|
1909
|
+
// Show the thumbnail
|
1910
|
+
this.thumbnail.src = URL.createObjectURL(this.itemEdit.thumbnail);
|
1911
|
+
this.thumbnailContainer.classList.remove("empty-box");
|
1912
|
+
this.thumbnail.classList.remove("display-none");
|
1913
|
+
}
|
1914
|
+
else {
|
1915
|
+
// Replace the thumbnail with an empty box
|
1916
|
+
this.thumbnailContainer.classList.add("empty-box");
|
1917
|
+
this.thumbnail.classList.add("display-none");
|
1918
|
+
}
|
1919
|
+
}
|
1920
|
+
/**
|
1921
|
+
* Updates the length label to reflect the current number of characters
|
1922
|
+
* relative to the max number of characters supported.
|
1923
|
+
*
|
1924
|
+
* @param phrase the current phrase from the control
|
1925
|
+
*/
|
1926
|
+
_updateLengthLabel(phrase) {
|
1927
|
+
this.itemSnippetCount.innerText =
|
1928
|
+
this._translations.snippetCountPattern.replace("{{n}}", phrase.length.toString());
|
1929
|
+
}
|
1930
|
+
/**
|
1931
|
+
* Add or remove the value from the store
|
1932
|
+
*/
|
1933
|
+
_updateStore() {
|
1934
|
+
this.itemEdit = state.getItemInfo(this.itemId);
|
1935
|
+
this.itemEdit.item = this.itemDetails;
|
1936
|
+
state.setItemInfo(this.itemEdit);
|
1937
|
+
}
|
1938
|
+
/**
|
1939
|
+
* Gets and displays image result from browse and updates the item in the store.
|
1940
|
+
*
|
1941
|
+
* @param event The input controls event that contains the new file
|
1942
|
+
* @param updateStore boolean that controls if the new value is written to the store
|
1943
|
+
* should be false on the initial load but true the rest of the time
|
1944
|
+
*/
|
1945
|
+
_updateThumbnail(event) {
|
1946
|
+
const files = event.target.files;
|
1947
|
+
if (files && files[0]) {
|
1948
|
+
if (this.thumbnail) {
|
1949
|
+
// Update UI
|
1950
|
+
this.thumbnail.src = URL.createObjectURL(files[0]);
|
1951
|
+
// Update info in store
|
1952
|
+
this.itemEdit = state.getItemInfo(this.itemId);
|
1953
|
+
this.itemEdit.thumbnail = files[0];
|
1954
|
+
state.replaceItemThumbnail(this.itemEdit);
|
1955
|
+
}
|
1956
|
+
}
|
1957
|
+
}
|
1958
|
+
/**
|
1959
|
+
* Fetches the component's translations
|
1960
|
+
*
|
1961
|
+
* @protected
|
1962
|
+
*/
|
1963
|
+
async _getTranslations() {
|
1964
|
+
const translations = await getLocaleComponentStrings(this.el);
|
1965
|
+
this._translations = translations[0];
|
1966
|
+
}
|
1967
|
+
get el() { return getElement(this); }
|
1968
|
+
};
|
1969
|
+
SolutionItemDetails.style = solutionItemDetailsCss;
|
1970
|
+
|
1971
|
+
const solutionItemSharingCss = ":host{display:block;box-sizing:border-box;margin-left:0.75rem;margin-right:0.75rem;min-width:0;flex-grow:0;flex-shrink:1}:host-group-1-up>.block{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}:host-group-2-up>.block{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}:host-group-3-up>.block{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}:host-group-4-up>.block{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}:host-group-5-up>.block{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}:host-group-6-up>.block{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}:host-group-7-up>.block{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}:host-group-8-up>.block{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.tablet-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.tablet-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.tablet-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.tablet-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.tablet-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.tablet-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.tablet-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.tablet-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.phone-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.phone-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.phone-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.phone-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.phone-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.phone-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.phone-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.phone-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.code-face :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:normal}.code-face :host b,.code-face :host strong{font-weight:400}.code-italic :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:italic}.code-italic :host b,.code-italic :host strong{font-weight:400}.container-border{padding:1rem}.icon-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";
|
1972
|
+
|
1973
|
+
const SolutionItemSharing = class {
|
1974
|
+
constructor(hostRef) {
|
1975
|
+
registerInstance(this, hostRef);
|
1976
|
+
this.groupId = "";
|
1977
|
+
this._translations = undefined;
|
1978
|
+
this.sharing = [];
|
1979
|
+
}
|
1980
|
+
itemIdWatchHandler() {
|
1981
|
+
const itemEdit = state.getItemInfo(this.groupId);
|
1982
|
+
this.sharing = itemEdit.groupDetails;
|
1983
|
+
}
|
1984
|
+
//--------------------------------------------------------------------------
|
1985
|
+
//
|
1986
|
+
// Lifecycle
|
1987
|
+
//
|
1988
|
+
//--------------------------------------------------------------------------
|
1989
|
+
/**
|
1990
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
1991
|
+
*/
|
1992
|
+
async componentWillLoad() {
|
1993
|
+
return this._getTranslations();
|
1994
|
+
}
|
1995
|
+
/**
|
1996
|
+
* Renders the component.
|
1997
|
+
*/
|
1998
|
+
render() {
|
1999
|
+
return (h(Host, null, h("div", { class: "container-border" }, h("calcite-label", null, this._translations.groupInfo), this._renderItems(this.sharing))));
|
2000
|
+
}
|
2001
|
+
//--------------------------------------------------------------------------
|
2002
|
+
//
|
2003
|
+
// Event Listeners
|
2004
|
+
//
|
2005
|
+
//--------------------------------------------------------------------------
|
2006
|
+
//--------------------------------------------------------------------------
|
2007
|
+
//
|
2008
|
+
// Events
|
2009
|
+
//
|
2010
|
+
//--------------------------------------------------------------------------
|
2011
|
+
//--------------------------------------------------------------------------
|
2012
|
+
//
|
2013
|
+
// Public Methods (async)
|
2014
|
+
//
|
2015
|
+
//--------------------------------------------------------------------------
|
2016
|
+
async getShareInfo() {
|
2017
|
+
return this.sharing;
|
2018
|
+
}
|
2019
|
+
//--------------------------------------------------------------------------
|
2020
|
+
//
|
2021
|
+
// Private Methods
|
2022
|
+
//
|
2023
|
+
//--------------------------------------------------------------------------
|
2024
|
+
/**
|
2025
|
+
* Render share options based on the list of share details
|
2026
|
+
*
|
2027
|
+
* @param objs list of IItemShare objects that are used to expose and store share info for the solutions items
|
2028
|
+
*/
|
2029
|
+
_renderItems(objs) {
|
2030
|
+
return objs && objs.length > 0
|
2031
|
+
? objs.map(item => {
|
2032
|
+
return (h("calcite-label", { layout: "inline" }, h("calcite-switch", { checked: item.shareItem, id: item.id, name: "setting", onCalciteSwitchChange: (event) => this._updateItem(event), scale: "m", value: "enabled" }), h("solution-item-icon", { type: item.type, typeKeywords: item.typeKeywords }), h("span", { class: "icon-text", title: item.title }, item.title)));
|
2033
|
+
})
|
2034
|
+
: null;
|
2035
|
+
}
|
2036
|
+
/**
|
2037
|
+
* Update the items share prop based on the switch state
|
2038
|
+
*
|
2039
|
+
* @param event onCalciteSwitchChange event
|
2040
|
+
*/
|
2041
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
2042
|
+
_updateItem(event) {
|
2043
|
+
const id = event.target.id;
|
2044
|
+
this.sharing = this.sharing.map((itemShare) => {
|
2045
|
+
if (itemShare.id === id) {
|
2046
|
+
// update the item
|
2047
|
+
itemShare.shareItem = event.detail.switched;
|
2048
|
+
// update the item in the store
|
2049
|
+
const itemEdit = state.getItemInfo(id);
|
2050
|
+
if (itemShare.shareItem) {
|
2051
|
+
// Add the group to the item if it's not already there
|
2052
|
+
if (!itemEdit.groups) {
|
2053
|
+
itemEdit.groups = [this.groupId];
|
2054
|
+
}
|
2055
|
+
else if (itemEdit.groups.indexOf(this.groupId) < 0) {
|
2056
|
+
itemEdit.groups.push(this.groupId);
|
2057
|
+
}
|
2058
|
+
}
|
2059
|
+
else {
|
2060
|
+
// Remove the group from the item if it's there
|
2061
|
+
if (itemEdit.groups) {
|
2062
|
+
const i = itemEdit.groups.indexOf(this.groupId);
|
2063
|
+
if (i > -1) {
|
2064
|
+
itemEdit.groups.splice(i, 1);
|
2065
|
+
}
|
2066
|
+
}
|
2067
|
+
}
|
2068
|
+
state.setItemInfo(itemEdit);
|
2069
|
+
}
|
2070
|
+
return itemShare;
|
2071
|
+
});
|
2072
|
+
}
|
2073
|
+
/**
|
2074
|
+
* Fetches the component's translations
|
2075
|
+
*
|
2076
|
+
* @protected
|
2077
|
+
*/
|
2078
|
+
async _getTranslations() {
|
2079
|
+
const translations = await getLocaleComponentStrings(this.el);
|
2080
|
+
this._translations = translations[0];
|
2081
|
+
}
|
2082
|
+
get el() { return getElement(this); }
|
2083
|
+
static get watchers() { return {
|
2084
|
+
"groupId": ["itemIdWatchHandler"]
|
2085
|
+
}; }
|
2086
|
+
};
|
2087
|
+
SolutionItemSharing.style = solutionItemSharingCss;
|
2088
|
+
|
2089
|
+
const solutionOrganizationVariablesCss = ":host{display:block;box-sizing:border-box;margin-left:0.75rem;margin-right:0.75rem;min-width:0;flex-grow:0;flex-shrink:1}:host-group-1-up>.block{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}:host-group-2-up>.block{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}:host-group-3-up>.block{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}:host-group-4-up>.block{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}:host-group-5-up>.block{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}:host-group-6-up>.block{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}:host-group-7-up>.block{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}:host-group-8-up>.block{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.tablet-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.tablet-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.tablet-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.tablet-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.tablet-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.tablet-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.tablet-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.tablet-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.phone-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.phone-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.phone-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.phone-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.phone-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.phone-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.phone-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.phone-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.code-face :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:normal}.code-face :host b,.code-face :host strong{font-weight:400}.code-italic :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:italic}.code-italic :host b,.code-italic :host strong{font-weight:400}.container-border{overflow-y:auto}.org-var-header{margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:1rem}";
|
2090
|
+
|
2091
|
+
const SolutionOrganizationVariables = class {
|
2092
|
+
constructor(hostRef) {
|
2093
|
+
registerInstance(this, hostRef);
|
2094
|
+
this.organizationVariableSelected = createEvent(this, "organizationVariableSelected", 7);
|
2095
|
+
this.value = "";
|
2096
|
+
this._organizationVariables = [];
|
2097
|
+
this._translations = undefined;
|
2098
|
+
}
|
2099
|
+
valueWatchHandler() {
|
2100
|
+
this._organizationVariables = JSON.parse(this.value);
|
2101
|
+
}
|
2102
|
+
//--------------------------------------------------------------------------
|
2103
|
+
//
|
2104
|
+
// Lifecycle
|
2105
|
+
//
|
2106
|
+
//--------------------------------------------------------------------------
|
2107
|
+
/**
|
2108
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
2109
|
+
*/
|
2110
|
+
async componentWillLoad() {
|
2111
|
+
return this._getTranslations();
|
2112
|
+
}
|
2113
|
+
/**
|
2114
|
+
* Renders the component.
|
2115
|
+
*/
|
2116
|
+
render() {
|
2117
|
+
return (h(Host, null, h("div", null, h("h4", { class: "org-var-header" }, this._translations.orgVariables)), h("div", { class: "container-border" }, h("calcite-tree", { id: "variable-label" }, this._renderHierarchy(this._organizationVariables)))));
|
2118
|
+
}
|
2119
|
+
//--------------------------------------------------------------------------
|
2120
|
+
//
|
2121
|
+
// Public Methods (async)
|
2122
|
+
//
|
2123
|
+
//--------------------------------------------------------------------------
|
2124
|
+
//--------------------------------------------------------------------------
|
2125
|
+
//
|
2126
|
+
// Private Methods
|
2127
|
+
//
|
2128
|
+
//--------------------------------------------------------------------------
|
2129
|
+
/**
|
2130
|
+
* Renders the organization based variable items the user can insert at runtime
|
2131
|
+
*
|
2132
|
+
* @param objs a list of organization variables to render
|
2133
|
+
*/
|
2134
|
+
_renderHierarchy(objs) {
|
2135
|
+
const hierarchy = objs.map(obj => {
|
2136
|
+
return (h("calcite-tree-item", { onClick: () => this._treeItemSelected(obj.id, obj.value) }, obj.title));
|
2137
|
+
});
|
2138
|
+
return hierarchy;
|
2139
|
+
}
|
2140
|
+
/**
|
2141
|
+
* Publishes the `organizationVariableSelected` event containing `itemId`, the id of the selected variable and the value of the variable.
|
2142
|
+
*
|
2143
|
+
* @param itemId Item id as reported by click event
|
2144
|
+
* @param value Variable id as reported by click event
|
2145
|
+
*/
|
2146
|
+
_treeItemSelected(itemId, value) {
|
2147
|
+
this.organizationVariableSelected.emit({
|
2148
|
+
itemId,
|
2149
|
+
value
|
2150
|
+
});
|
2151
|
+
}
|
2152
|
+
/**
|
2153
|
+
* Fetches the component's translations
|
2154
|
+
*
|
2155
|
+
* @protected
|
2156
|
+
*/
|
2157
|
+
async _getTranslations() {
|
2158
|
+
const translations = await getLocaleComponentStrings(this.el);
|
2159
|
+
this._translations = translations[0];
|
2160
|
+
}
|
2161
|
+
get el() { return getElement(this); }
|
2162
|
+
static get watchers() { return {
|
2163
|
+
"value": ["valueWatchHandler"]
|
2164
|
+
}; }
|
2165
|
+
};
|
2166
|
+
SolutionOrganizationVariables.style = solutionOrganizationVariablesCss;
|
2167
|
+
|
2168
|
+
const solutionResourceItemCss = ":host{display:block;box-sizing:border-box;margin-left:0.75rem;margin-right:0.75rem;min-width:0;flex-grow:0;flex-shrink:1}:host-group-1-up>.block{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}:host-group-2-up>.block{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}:host-group-3-up>.block{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}:host-group-4-up>.block{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}:host-group-5-up>.block{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}:host-group-6-up>.block{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}:host-group-7-up>.block{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}:host-group-8-up>.block{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.tablet-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.tablet-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.tablet-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.tablet-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.tablet-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.tablet-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.tablet-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.tablet-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.phone-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.phone-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.phone-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.phone-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.phone-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.phone-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.phone-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.phone-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.code-face :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:normal}.code-face :host b,.code-face :host strong{font-weight:400}.code-italic :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:italic}.code-italic :host b,.code-italic :host strong{font-weight:400}.resource-item{padding:1rem}.resource-button{-webkit-margin-end:1rem;margin-inline-end:1rem}.resource-progress{padding-top:1rem}.resources-container{border:1px #808080 solid}.margin-bottom-1{margin-bottom:1rem}";
|
2169
|
+
|
2170
|
+
const SolutionResourceItem = class {
|
2171
|
+
constructor(hostRef) {
|
2172
|
+
registerInstance(this, hostRef);
|
2173
|
+
this._removedResources = {};
|
2174
|
+
this.authentication = undefined;
|
2175
|
+
this.itemId = "";
|
2176
|
+
this.resourceFilePaths = [];
|
2177
|
+
this.resources = [];
|
2178
|
+
this._translations = undefined;
|
2179
|
+
}
|
2180
|
+
itemIdWatchHandler() {
|
2181
|
+
const item = state.getItemInfo(this.itemId);
|
2182
|
+
this.resourceFilePaths = item.resourceFilePaths;
|
2183
|
+
this.resources = item.resources.map(
|
2184
|
+
// False linting error
|
2185
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
2186
|
+
(path) => path.substring(path.lastIndexOf("/") + 1));
|
2187
|
+
}
|
2188
|
+
//--------------------------------------------------------------------------
|
2189
|
+
//
|
2190
|
+
// Lifecycle
|
2191
|
+
//
|
2192
|
+
//--------------------------------------------------------------------------
|
2193
|
+
/**
|
2194
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
2195
|
+
*/
|
2196
|
+
componentWillLoad() {
|
2197
|
+
return this._getTranslations();
|
2198
|
+
}
|
2199
|
+
/**
|
2200
|
+
* Renders the component.
|
2201
|
+
*/
|
2202
|
+
render() {
|
2203
|
+
const hasValidResources = this._hasValidResources();
|
2204
|
+
return (h(Host, null, h("div", { class: "resource-item" }, h("div", { class: "margin-bottom-1" }, h("calcite-button", { appearance: "solid", class: "resource-button", color: "blue", onClick: () => this._addNewResource() }, this._translations.addResource), h("calcite-button", { appearance: "solid", color: "blue", disabled: !hasValidResources, onClick: () => this._downloadAll() }, this._translations.downloadAll)), h("div", { class: "resources-container", style: { display: hasValidResources ? "inherit" : "none" } }, this._renderResourceList()))));
|
2205
|
+
}
|
2206
|
+
//--------------------------------------------------------------------------
|
2207
|
+
//
|
2208
|
+
// Event Listeners
|
2209
|
+
//
|
2210
|
+
//--------------------------------------------------------------------------
|
2211
|
+
//--------------------------------------------------------------------------
|
2212
|
+
//
|
2213
|
+
// Events
|
2214
|
+
//
|
2215
|
+
//--------------------------------------------------------------------------
|
2216
|
+
//--------------------------------------------------------------------------
|
2217
|
+
//
|
2218
|
+
// Public Methods (async)
|
2219
|
+
//
|
2220
|
+
//--------------------------------------------------------------------------
|
2221
|
+
//--------------------------------------------------------------------------
|
2222
|
+
//
|
2223
|
+
// Private Methods
|
2224
|
+
//
|
2225
|
+
//--------------------------------------------------------------------------
|
2226
|
+
/**
|
2227
|
+
* Render resources while avoiding thumbnail resoures that are managed by solution-item
|
2228
|
+
*
|
2229
|
+
*/
|
2230
|
+
_renderResourceList() {
|
2231
|
+
return (h("calcite-value-list", { multiple: true }, this.resourceFilePaths.reduce((prev, cur) => {
|
2232
|
+
if (cur.type !== EFileType.Thumbnail) {
|
2233
|
+
prev.push(this._renderResource(cur));
|
2234
|
+
}
|
2235
|
+
return prev;
|
2236
|
+
}, [])));
|
2237
|
+
}
|
2238
|
+
/**
|
2239
|
+
* Render the resource and supporting actions for download/update/delete/(reset..if deleted)
|
2240
|
+
*
|
2241
|
+
* @param resource the filename and url used to interact with the resource
|
2242
|
+
*/
|
2243
|
+
_renderResource(resource) {
|
2244
|
+
const resettable = resource.updateType === EUpdateType.Remove;
|
2245
|
+
const fullname = resource.folder ? resource.folder + "/" + resource.filename : resource.filename;
|
2246
|
+
return (h("calcite-value-list-item", { class: resettable ? "disabled" : "", label: fullname, nonInteractive: true, value: resource.url }, h("calcite-action-group", { "expand-disabled": "true", layout: "horizontal", slot: "actions-end" }, h("calcite-action", { disabled: resettable, icon: "download", label: this._translations.download, onClick: () => this._download(resource.url, resource.filename), scale: "m", text: this._translations.download, title: this._translations.download }), h("calcite-action", { disabled: resettable, icon: "upload-to", label: this._translations.update, onClick: () => this._upload(resource), scale: "m", text: this._translations.update, title: this._translations.update }), h("calcite-action", { disabled: resettable, icon: "trash", label: this._translations.delete, onClick: () => this._delete(resource), scale: "m", text: this._translations.delete, title: this._translations.delete }), resettable ? h("calcite-action", { icon: "reset", label: this._translations.reset, onClick: () => this._reset(resource.filename), scale: "m", text: this._translations.reset, title: this._translations.reset }) : h("div", { class: "display-none" }))));
|
2247
|
+
}
|
2248
|
+
/**
|
2249
|
+
* Adds the name to the deleted array so it will be skipped while rendering
|
2250
|
+
* but still exist if the user chooses to reset
|
2251
|
+
*
|
2252
|
+
* @param resource the resource to be updated
|
2253
|
+
*/
|
2254
|
+
_delete(resource) {
|
2255
|
+
resource.updateType = EUpdateType.Remove;
|
2256
|
+
this.resourceFilePaths = [...this.resourceFilePaths]; // to trigger refresh
|
2257
|
+
this._updateStore();
|
2258
|
+
}
|
2259
|
+
/**
|
2260
|
+
* Remove the name from the deleted array so it will again be rendered
|
2261
|
+
*
|
2262
|
+
* @param name the name to be added to the deleted array
|
2263
|
+
*/
|
2264
|
+
_reset(name) {
|
2265
|
+
// need to make sure I know if this reset is from the source or a new one
|
2266
|
+
// Because the item's `resources` array is not updated until (and if) the solution is saved,
|
2267
|
+
// we can use it for the reset info
|
2268
|
+
this.resources.some(resourceName => resourceName === name) ?
|
2269
|
+
// Undo removing an existing resource
|
2270
|
+
this.resourceFilePaths = this.resourceFilePaths.map(p => {
|
2271
|
+
if (p.filename === name) {
|
2272
|
+
p.updateType = EUpdateType.None;
|
2273
|
+
}
|
2274
|
+
return p;
|
2275
|
+
}) :
|
2276
|
+
// Undo cancelling the adding of a resource
|
2277
|
+
this.resourceFilePaths = this.resourceFilePaths.map(p => {
|
2278
|
+
if (p.filename === name) {
|
2279
|
+
p.updateType = EUpdateType.Add;
|
2280
|
+
}
|
2281
|
+
return p;
|
2282
|
+
});
|
2283
|
+
this._updateStore();
|
2284
|
+
}
|
2285
|
+
/**
|
2286
|
+
* Download all of the templates resources
|
2287
|
+
*
|
2288
|
+
*/
|
2289
|
+
_downloadAll() {
|
2290
|
+
this.resourceFilePaths.forEach((resource) => {
|
2291
|
+
this._download(resource.url, resource.filename);
|
2292
|
+
});
|
2293
|
+
}
|
2294
|
+
/**
|
2295
|
+
* Download the current resource
|
2296
|
+
*
|
2297
|
+
* @param url the resource url
|
2298
|
+
* @param name the resource name
|
2299
|
+
*/
|
2300
|
+
_download(url, name) {
|
2301
|
+
// files that have been added manually do not need to be requested from the item
|
2302
|
+
if (url.startsWith("blob")) {
|
2303
|
+
this.downloadFile(url, name);
|
2304
|
+
}
|
2305
|
+
else {
|
2306
|
+
const _url = `${url}?token=${this.authentication.token}`;
|
2307
|
+
void this.fetchAndDownload(_url, name);
|
2308
|
+
}
|
2309
|
+
}
|
2310
|
+
/**
|
2311
|
+
* Dynamically creates an anchor and downloads the file
|
2312
|
+
*
|
2313
|
+
* @param url the url of the resource
|
2314
|
+
* @param name the name of the resource
|
2315
|
+
*/
|
2316
|
+
downloadFile(url, name) {
|
2317
|
+
const link = document.createElement("a");
|
2318
|
+
link.href = url;
|
2319
|
+
link.download = name;
|
2320
|
+
link.target = "_blank";
|
2321
|
+
link.click();
|
2322
|
+
}
|
2323
|
+
/**
|
2324
|
+
* Check if the template resources have any non-thumbnail resources
|
2325
|
+
*
|
2326
|
+
* @returns true if we have data resources and false if only thumbnail
|
2327
|
+
*/
|
2328
|
+
_hasValidResources() {
|
2329
|
+
return this.resourceFilePaths.some(r => r.url.indexOf("_info_thumbnail") < 0);
|
2330
|
+
}
|
2331
|
+
/**
|
2332
|
+
* Fetches and downloads the resource from the solution
|
2333
|
+
*
|
2334
|
+
* @param url the url of the resource
|
2335
|
+
* @param name the name of the resource
|
2336
|
+
*/
|
2337
|
+
async fetchAndDownload(url, name) {
|
2338
|
+
const image = await fetch(url);
|
2339
|
+
const b = await image.blob();
|
2340
|
+
const bURL = URL.createObjectURL(b);
|
2341
|
+
this.downloadFile(bURL, name);
|
2342
|
+
}
|
2343
|
+
/**
|
2344
|
+
* Create an input element to support the uploading of the resource and upload the resource
|
2345
|
+
*
|
2346
|
+
* @param resource the resource to be updated
|
2347
|
+
*/
|
2348
|
+
_upload(resource) {
|
2349
|
+
const _input = document.createElement("input");
|
2350
|
+
_input.classList.add("display-none");
|
2351
|
+
_input.onchange = this._updateResource.bind(this, resource);
|
2352
|
+
_input.type = "file";
|
2353
|
+
_input.click();
|
2354
|
+
}
|
2355
|
+
/**
|
2356
|
+
* Create an input element to support the uploading of a resource and add the new resource
|
2357
|
+
*
|
2358
|
+
*/
|
2359
|
+
_addNewResource() {
|
2360
|
+
const _input = document.createElement("input");
|
2361
|
+
_input.classList.add("display-none");
|
2362
|
+
_input.onchange = this._add.bind(this);
|
2363
|
+
_input.type = "file";
|
2364
|
+
_input.click();
|
2365
|
+
}
|
2366
|
+
/**
|
2367
|
+
* Replace the resource file path when update action is used
|
2368
|
+
*
|
2369
|
+
* @param resourcePath the resource to be updated
|
2370
|
+
* @param event the input event that contains the file
|
2371
|
+
*/
|
2372
|
+
_updateResource(resourcePath, event) {
|
2373
|
+
const files = event.target.files;
|
2374
|
+
if (files && files[0]) {
|
2375
|
+
resourcePath.blob = files[0];
|
2376
|
+
resourcePath.updateType = EUpdateType.Update;
|
2377
|
+
this._updateStore();
|
2378
|
+
}
|
2379
|
+
}
|
2380
|
+
/**
|
2381
|
+
* Add the new resource to the resource file paths
|
2382
|
+
*
|
2383
|
+
* @param event the inputs event that contains the new file
|
2384
|
+
*/
|
2385
|
+
_add(event) {
|
2386
|
+
const files = event.target.files;
|
2387
|
+
if (files && files[0]) {
|
2388
|
+
const url = URL.createObjectURL(files[0]);
|
2389
|
+
const filename = files[0].name;
|
2390
|
+
// Add the item if it's not already in the resource file paths list
|
2391
|
+
if (!this.resourceFilePaths.some(r => r.filename === filename && r.url === url)) {
|
2392
|
+
this.resourceFilePaths = [
|
2393
|
+
...this.resourceFilePaths,
|
2394
|
+
{
|
2395
|
+
url,
|
2396
|
+
type: EFileType.Data,
|
2397
|
+
folder: undefined,
|
2398
|
+
filename,
|
2399
|
+
blob: files[0],
|
2400
|
+
updateType: EUpdateType.Add
|
2401
|
+
}
|
2402
|
+
];
|
2403
|
+
this._updateStore();
|
2404
|
+
}
|
2405
|
+
}
|
2406
|
+
}
|
2407
|
+
/**
|
2408
|
+
* Add or remove the value from the store
|
2409
|
+
*/
|
2410
|
+
_updateStore() {
|
2411
|
+
const item = state.getItemInfo(this.itemId);
|
2412
|
+
item.resourceFilePaths = this.resourceFilePaths;
|
2413
|
+
state.setItemInfo(item);
|
2414
|
+
}
|
2415
|
+
/**
|
2416
|
+
* Fetches the component's translations
|
2417
|
+
*
|
2418
|
+
* @protected
|
2419
|
+
*/
|
2420
|
+
async _getTranslations() {
|
2421
|
+
const translations = await getLocaleComponentStrings(this.el);
|
2422
|
+
this._translations = translations[0];
|
2423
|
+
}
|
2424
|
+
get el() { return getElement(this); }
|
2425
|
+
static get watchers() { return {
|
2426
|
+
"itemId": ["itemIdWatchHandler"]
|
2427
|
+
}; }
|
2428
|
+
};
|
2429
|
+
SolutionResourceItem.style = solutionResourceItemCss;
|
2430
|
+
|
2431
|
+
const solutionTemplateDataCss = ":host{display:flexbox}.solution-data-container{position:absolute;height:-moz-available;height:calc(100% - 48px);height:-webkit-fill-available;height:stretch;width:-moz-available;width:100%;width:-webkit-fill-available;width:stretch}.solution-data-child-container{display:flex;height:100%;width:100%;flex-direction:column;overflow-y:auto}.solution-data-editor-container{height:100%}.solution-data-child-container-collapsed{display:flex;height:100%;flex-direction:column;overflow:auto;width:50px}.inputBottomSeparation{margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:1.5rem}.json-editor{margin:1rem;width:auto;width:-webkit-fill-available -moz-available}.collapse-btn{padding-left:1rem;padding-right:1rem;padding-top:1rem;padding-bottom:0px}.org-vars{padding-left:1rem;padding-right:1rem;padding-top:1rem;padding-bottom:0px}.sol-vars{padding-top:0px;padding-bottom:0px;padding-left:1rem;padding-right:1rem;min-height:45%}.padding-1{padding:1rem}.light{background-color:#F4F4F4}";
|
2432
|
+
|
2433
|
+
const SolutionTemplateData = class {
|
2434
|
+
itemIdWatchHandler() {
|
2435
|
+
this._initializing = true;
|
2436
|
+
this.value = JSON.stringify(this.instanceid === "data"
|
2437
|
+
? state.getItemInfo(this.itemId).data
|
2438
|
+
: state.getItemInfo(this.itemId).properties, null, 2);
|
2439
|
+
}
|
2440
|
+
//--------------------------------------------------------------------------
|
2441
|
+
//
|
2442
|
+
// Lifecycle
|
2443
|
+
//
|
2444
|
+
//--------------------------------------------------------------------------
|
2445
|
+
constructor(hostRef) {
|
2446
|
+
registerInstance(this, hostRef);
|
2447
|
+
this._initializing = false;
|
2448
|
+
this.instanceid = "";
|
2449
|
+
this.itemId = "";
|
2450
|
+
this.organizationVariables = "";
|
2451
|
+
this.solutionVariables = "";
|
2452
|
+
this.varsOpen = true;
|
2453
|
+
this._translations = undefined;
|
2454
|
+
this.value = "";
|
2455
|
+
window.addEventListener("solutionEditorContentChanged", (evt) => {
|
2456
|
+
if (this.itemId) {
|
2457
|
+
const { id, contents } = evt.detail;
|
2458
|
+
const [itemId, instanceId] = id.split("|");
|
2459
|
+
if (itemId == this.itemId && instanceId === this.instanceid) {
|
2460
|
+
if (!this._initializing && contents.length > 0) {
|
2461
|
+
const itemEdit = state.getItemInfo(itemId);
|
2462
|
+
if (instanceId === "data") {
|
2463
|
+
itemEdit.data = JSON.parse(contents);
|
2464
|
+
}
|
2465
|
+
else {
|
2466
|
+
itemEdit.properties = JSON.parse(contents);
|
2467
|
+
}
|
2468
|
+
state.setItemInfo(itemEdit);
|
2469
|
+
}
|
2470
|
+
this._initializing = false;
|
2471
|
+
}
|
2472
|
+
}
|
2473
|
+
});
|
2474
|
+
}
|
2475
|
+
/**
|
2476
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
2477
|
+
*/
|
2478
|
+
componentWillLoad() {
|
2479
|
+
return this._getTranslations();
|
2480
|
+
}
|
2481
|
+
/**
|
2482
|
+
* Renders the component.
|
2483
|
+
*/
|
2484
|
+
render() {
|
2485
|
+
return (h(Host, null, h("div", { class: "solution-data-container" }, h("calcite-shell", { class: "light var-container", dir: "ltr" }, h("calcite-panel", { class: "json-editor" }, h("div", { class: "solution-data-child-container calcite-match-height" }, h("json-editor", { class: "solution-data-editor-container", instanceid: this.itemId + "|" + this.instanceid, value: this.value }))), h("calcite-shell-panel", { "height-scale": "l", position: "end", slot: "contextual-panel", "width-scale": "xs" }, h("div", { class: this.varsOpen ? "solution-data-child-container" : "solution-data-child-container-collapsed" }, h("calcite-button", { appearance: "transparent", class: "collapse-btn", "icon-start": this.varsOpen ? "chevrons-right" : "chevrons-left", id: "collapse-vars", onClick: () => this._toggleVars(), scale: "s", title: this.varsOpen ? this._translations.collapse : this._translations.expand }), h("div", { class: this.varsOpen ? "org-vars" : "org-vars display-none", id: "orgVars" }, h("solution-organization-variables", { value: this.organizationVariables })), h("div", { class: this.varsOpen ? "sol-vars" : "sol-vars display-none", id: "solVars" }, h("solution-variables", { value: this.solutionVariables }))))))));
|
2486
|
+
}
|
2487
|
+
//--------------------------------------------------------------------------
|
2488
|
+
//
|
2489
|
+
// Event Listeners
|
2490
|
+
//
|
2491
|
+
//--------------------------------------------------------------------------
|
2492
|
+
//--------------------------------------------------------------------------
|
2493
|
+
//
|
2494
|
+
// Events
|
2495
|
+
//
|
2496
|
+
//--------------------------------------------------------------------------
|
2497
|
+
//--------------------------------------------------------------------------
|
2498
|
+
//
|
2499
|
+
// Public Methods (async)
|
2500
|
+
//
|
2501
|
+
//--------------------------------------------------------------------------
|
2502
|
+
//--------------------------------------------------------------------------
|
2503
|
+
//
|
2504
|
+
// Private Methods
|
2505
|
+
//
|
2506
|
+
//--------------------------------------------------------------------------
|
2507
|
+
/**
|
2508
|
+
* Toggle varsOpen prop to show/hide variable containers
|
2509
|
+
*/
|
2510
|
+
_toggleVars() {
|
2511
|
+
this.varsOpen = !this.varsOpen;
|
2512
|
+
}
|
2513
|
+
/**
|
2514
|
+
* Fetches the component's translations
|
2515
|
+
*
|
2516
|
+
* @protected
|
2517
|
+
*/
|
2518
|
+
async _getTranslations() {
|
2519
|
+
const translations = await getLocaleComponentStrings(this.el);
|
2520
|
+
this._translations = translations[0];
|
2521
|
+
}
|
2522
|
+
get el() { return getElement(this); }
|
2523
|
+
static get watchers() { return {
|
2524
|
+
"itemId": ["itemIdWatchHandler"]
|
2525
|
+
}; }
|
2526
|
+
};
|
2527
|
+
SolutionTemplateData.style = solutionTemplateDataCss;
|
2528
|
+
|
2529
|
+
const solutionVariablesCss = ":host{display:block;box-sizing:border-box;margin-left:0.75rem;margin-right:0.75rem;min-width:0;flex-grow:0;flex-shrink:1}:host-group-1-up>.block{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}:host-group-2-up>.block{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}:host-group-3-up>.block{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}:host-group-4-up>.block{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}:host-group-5-up>.block{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}:host-group-6-up>.block{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}:host-group-7-up>.block{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}:host-group-8-up>.block{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.tablet-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.tablet-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.tablet-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.tablet-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.tablet-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.tablet-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.tablet-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.tablet-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.phone-block-group-1-up>:host{flex-basis:calc(100% - 1.5rem);width:calc(100% - 1.5rem)}.phone-block-group-2-up>:host{flex-basis:calc(50% - 1.5rem);width:calc(50% - 1.5rem)}.phone-block-group-3-up>:host{flex-basis:calc(33.33333% - 1.5rem);width:calc(33.33333% - 1.5rem)}.phone-block-group-4-up>:host{flex-basis:calc(25% - 1.5rem);width:calc(25% - 1.5rem)}.phone-block-group-5-up>:host{flex-basis:calc(20% - 1.5rem);width:calc(20% - 1.5rem)}.phone-block-group-6-up>:host{flex-basis:calc(16.66666% - 1.5rem);width:calc(16.66666% - 1.5rem)}.phone-block-group-7-up>:host{flex-basis:calc(14.2857% - 1.5rem);width:calc(14.2857% - 1.5rem)}.phone-block-group-8-up>:host{flex-basis:calc(12.5% - 1.5rem);width:calc(12.5% - 1.5rem)}.code-face :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:normal}.code-face :host b,.code-face :host strong{font-weight:400}.code-italic :host{letter-spacing:0em;font-family:\"Consolas\", \"Andale Mono\", \"Lucida Console\", \"Monaco\", monospace;font-weight:400;font-style:italic}.code-italic :host b,.code-italic :host strong{font-weight:400}.container-border{overflow-y:hidden}.org-var-header{margin-top:1rem;margin-bottom:1rem;margin-left:0px;margin-right:0px}.icon-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";
|
2530
|
+
|
2531
|
+
const SolutionVariables = class {
|
2532
|
+
constructor(hostRef) {
|
2533
|
+
registerInstance(this, hostRef);
|
2534
|
+
this.solutionVariableSelected = createEvent(this, "solutionVariableSelected", 7);
|
2535
|
+
this.value = "";
|
2536
|
+
this._solutionVariables = [];
|
2537
|
+
this._translations = undefined;
|
2538
|
+
}
|
2539
|
+
valueWatchHandler() {
|
2540
|
+
this._solutionVariables = JSON.parse(this.value);
|
2541
|
+
}
|
2542
|
+
//--------------------------------------------------------------------------
|
2543
|
+
//
|
2544
|
+
// Lifecycle
|
2545
|
+
//
|
2546
|
+
//--------------------------------------------------------------------------
|
2547
|
+
/**
|
2548
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
2549
|
+
*/
|
2550
|
+
componentWillLoad() {
|
2551
|
+
return this._getTranslations();
|
2552
|
+
}
|
2553
|
+
/**
|
2554
|
+
* Renders the component.
|
2555
|
+
*/
|
2556
|
+
render() {
|
2557
|
+
return (h(Host, null, h("div", null, h("h4", { class: "org-var-header" }, this._translations.solVariables)), h("div", { class: "container-border" }, h("calcite-tree", { id: "variable-label" }, this._renderHierarchy(this._solutionVariables)))));
|
2558
|
+
}
|
2559
|
+
//--------------------------------------------------------------------------
|
2560
|
+
//
|
2561
|
+
// Public Methods (async)
|
2562
|
+
//
|
2563
|
+
//--------------------------------------------------------------------------
|
2564
|
+
//--------------------------------------------------------------------------
|
2565
|
+
//
|
2566
|
+
// Private Methods
|
2567
|
+
//
|
2568
|
+
//--------------------------------------------------------------------------
|
2569
|
+
/**
|
2570
|
+
* Render the solution item variables that the user can insert into temaplates at runtime.
|
2571
|
+
*
|
2572
|
+
* @param objs a list of variable items that have been gathered from the solutions templates
|
2573
|
+
*/
|
2574
|
+
_renderHierarchy(objs) {
|
2575
|
+
const hierarchy = objs.map(obj => {
|
2576
|
+
return obj.dependencies && obj.dependencies.length > 0 ? (h("calcite-tree-item", { onClick: (evt) => this._toggleExpand(evt) }, h("solution-item-icon", { type: obj.type }), h("span", { class: "icon-text", title: obj.title }, obj.title), h("calcite-tree", { slot: "children" }, this._renderHierarchy(obj.dependencies)))) : (h("calcite-tree-item", { onClick: () => this._treeItemSelected(obj.id, obj.value) }, obj.title));
|
2577
|
+
});
|
2578
|
+
return hierarchy;
|
2579
|
+
}
|
2580
|
+
/**
|
2581
|
+
* Publishes the `solutionVariableSelected` event containing `itemId`, the id of the selected variable and the value of the variable.
|
2582
|
+
*
|
2583
|
+
* @param id Item id as reported by click event
|
2584
|
+
* @param value Variable id as reported by click event
|
2585
|
+
*/
|
2586
|
+
_treeItemSelected(id, value) {
|
2587
|
+
this.solutionVariableSelected.emit({
|
2588
|
+
itemId: id,
|
2589
|
+
value
|
2590
|
+
});
|
2591
|
+
}
|
2592
|
+
/**
|
2593
|
+
* Toggle the tree item that was clicked
|
2594
|
+
*
|
2595
|
+
* @param evt the clicks mouse event
|
2596
|
+
*/
|
2597
|
+
_toggleExpand(evt = undefined) {
|
2598
|
+
var _a;
|
2599
|
+
const treeItem = (_a = evt === null || evt === void 0 ? void 0 : evt.target) === null || _a === void 0 ? void 0 : _a.closest("calcite-tree-item");
|
2600
|
+
if (treeItem) {
|
2601
|
+
treeItem.expanded = !treeItem.expanded;
|
2602
|
+
}
|
2603
|
+
}
|
2604
|
+
/**
|
2605
|
+
* Fetches the component's translations
|
2606
|
+
*
|
2607
|
+
* @protected
|
2608
|
+
*/
|
2609
|
+
async _getTranslations() {
|
2610
|
+
const translations = await getLocaleComponentStrings(this.el);
|
2611
|
+
this._translations = translations[0];
|
2612
|
+
}
|
2613
|
+
get el() { return getElement(this); }
|
2614
|
+
static get watchers() { return {
|
2615
|
+
"value": ["valueWatchHandler"]
|
2616
|
+
}; }
|
2617
|
+
};
|
2618
|
+
SolutionVariables.style = solutionVariablesCss;
|
2619
|
+
|
2620
|
+
export { ShellPanel as calcite_shell_panel, Tab as calcite_tab, TabNav as calcite_tab_nav, TabTitle as calcite_tab_title, Tabs as calcite_tabs, ValueList as calcite_value_list, ValueListItem as calcite_value_list_item, JsonEditor as json_editor, SolutionItemDetails as solution_item_details, SolutionItemSharing as solution_item_sharing, SolutionOrganizationVariables as solution_organization_variables, SolutionResourceItem as solution_resource_item, SolutionTemplateData as solution_template_data, SolutionVariables as solution_variables };
|