@esri/solutions-components 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/deduct-calculator.cjs.entry.js +1 -1
- package/dist/cjs/pci-calculator.cjs.entry.js +1 -1
- package/dist/cjs/{pciUtils-6a806ba4.js → pciUtils-423cfc68.js} +25 -7
- package/dist/collection/demos/deduct-calculator.html +2 -5
- package/dist/collection/demos/new-public-notification.html +6 -4
- package/dist/collection/utils/pciUtils.js +25 -7
- package/dist/collection/utils/pciUtils.ts +30 -7
- package/dist/components/ExpandToggle.js +110 -0
- package/dist/components/Heading.js +22 -0
- package/dist/components/_commonjsHelpers.js +22 -0
- package/dist/components/action-bar.js +276 -0
- package/dist/components/action-group.js +149 -0
- package/dist/components/action-menu.js +356 -0
- package/dist/components/action.js +214 -0
- package/dist/components/add-record-modal.d.ts +11 -0
- package/dist/components/add-record-modal.js +171 -0
- package/dist/components/array.js +15 -0
- package/dist/components/block.js +272 -0
- package/dist/components/buffer-tools.d.ts +11 -0
- package/dist/components/buffer-tools.js +11 -0
- package/dist/components/buffer-tools2.js +262 -0
- package/dist/components/button.js +263 -0
- package/dist/components/calcite-accordion-item.js +244 -0
- package/dist/components/calcite-accordion.js +180 -0
- package/dist/components/calcite-action-bar.js +11 -0
- package/dist/components/calcite-action-group.js +11 -0
- package/dist/components/calcite-action-menu.js +11 -0
- package/dist/components/calcite-action-pad.js +197 -0
- package/dist/components/calcite-action.js +11 -0
- package/dist/components/calcite-alert.js +297 -0
- package/dist/components/calcite-avatar.js +182 -0
- package/dist/components/calcite-block-section.js +155 -0
- package/dist/components/calcite-block.js +11 -0
- package/dist/components/calcite-button.js +11 -0
- package/dist/components/calcite-card.js +187 -0
- package/dist/components/calcite-checkbox.js +11 -0
- package/dist/components/calcite-chip.js +11 -0
- package/dist/components/calcite-color-picker-hex-input.js +11 -0
- package/dist/components/calcite-color-picker-swatch.js +11 -0
- package/dist/components/calcite-color-picker.js +1036 -0
- package/dist/components/calcite-combobox-item-group.js +75 -0
- package/dist/components/calcite-combobox-item.js +11 -0
- package/dist/components/calcite-combobox.js +11 -0
- package/dist/components/calcite-date-picker-day.js +11 -0
- package/dist/components/calcite-date-picker-month-header.js +11 -0
- package/dist/components/calcite-date-picker-month.js +11 -0
- package/dist/components/calcite-date-picker.js +11 -0
- package/dist/components/calcite-dropdown-group.js +11 -0
- package/dist/components/calcite-dropdown-item.js +11 -0
- package/dist/components/calcite-dropdown.js +11 -0
- package/dist/components/calcite-fab.js +144 -0
- package/dist/components/calcite-filter.js +195 -0
- package/dist/components/calcite-flow-item.js +243 -0
- package/dist/components/calcite-flow.js +147 -0
- package/dist/components/calcite-graph.js +11 -0
- package/dist/components/calcite-handle.js +11 -0
- package/dist/components/calcite-icon.js +11 -0
- package/dist/components/calcite-inline-editable.js +294 -0
- package/dist/components/calcite-input-date-picker.js +713 -0
- package/dist/components/calcite-input-message.js +11 -0
- package/dist/components/calcite-input-number.js +637 -0
- package/dist/components/calcite-input-text.js +400 -0
- package/dist/components/calcite-input-time-picker.js +434 -0
- package/dist/components/calcite-input.js +11 -0
- package/dist/components/calcite-label.js +11 -0
- package/dist/components/calcite-link.js +11 -0
- package/dist/components/calcite-list-item-group.js +65 -0
- package/dist/components/calcite-list-item.js +11 -0
- package/dist/components/calcite-list.js +11 -0
- package/dist/components/calcite-loader.js +11 -0
- package/dist/components/calcite-modal.js +11 -0
- package/dist/components/calcite-notice.js +11 -0
- package/dist/components/calcite-option-group.js +64 -0
- package/dist/components/calcite-option.js +11 -0
- package/dist/components/calcite-pagination.js +258 -0
- package/dist/components/calcite-panel.js +11 -0
- package/dist/components/calcite-pick-list-group.js +74 -0
- package/dist/components/calcite-pick-list-item.js +11 -0
- package/dist/components/calcite-pick-list.js +11 -0
- package/dist/components/calcite-popover-manager.js +94 -0
- package/dist/components/calcite-popover.js +11 -0
- package/dist/components/calcite-progress.js +11 -0
- package/dist/components/calcite-radio-button-group.js +132 -0
- package/dist/components/calcite-radio-button.js +310 -0
- package/dist/components/calcite-radio-group-item.js +11 -0
- package/dist/components/calcite-radio-group.js +11 -0
- package/dist/components/calcite-rating.js +201 -0
- package/dist/components/calcite-scrim.js +11 -0
- package/dist/components/calcite-select.js +11 -0
- package/dist/components/calcite-shell-center-row.js +100 -0
- package/dist/components/calcite-shell-panel.js +11 -0
- package/dist/components/calcite-shell.js +11 -0
- package/dist/components/calcite-slider.js +11 -0
- package/dist/components/calcite-sortable-list.js +202 -0
- package/dist/components/calcite-split-button.js +11 -0
- package/dist/components/calcite-stepper-item.js +271 -0
- package/dist/components/calcite-stepper.js +256 -0
- package/dist/components/calcite-switch.js +11 -0
- package/dist/components/calcite-tab-nav.js +11 -0
- package/dist/components/calcite-tab-title.js +11 -0
- package/dist/components/calcite-tab.js +11 -0
- package/dist/components/calcite-tabs.js +11 -0
- package/dist/components/calcite-tile-select-group.js +65 -0
- package/dist/components/calcite-tile-select.js +266 -0
- package/dist/components/calcite-tile.js +11 -0
- package/dist/components/calcite-time-picker.js +11 -0
- package/dist/components/calcite-tip-group.js +41 -0
- package/dist/components/calcite-tip-manager.js +223 -0
- package/dist/components/calcite-tip.js +162 -0
- package/dist/components/calcite-tooltip-manager.js +57 -0
- package/dist/components/calcite-tooltip.js +11 -0
- package/dist/components/calcite-tree-item.js +11 -0
- package/dist/components/calcite-tree.js +11 -0
- package/dist/components/calcite-value-list-item.js +11 -0
- package/dist/components/calcite-value-list.js +11 -0
- package/dist/components/card-manager.d.ts +11 -0
- package/dist/components/card-manager.js +143 -0
- package/dist/components/check-list.d.ts +11 -0
- package/dist/components/check-list.js +11 -0
- package/dist/components/check-list2.js +131 -0
- package/dist/components/checkbox.js +165 -0
- package/dist/components/chip.js +170 -0
- package/dist/components/color-picker-hex-input.js +363 -0
- package/dist/components/color-picker-swatch.js +2034 -0
- package/dist/components/combobox-item.js +182 -0
- package/dist/components/combobox.js +912 -0
- package/dist/components/comment-card.d.ts +11 -0
- package/dist/components/comment-card.js +90 -0
- package/dist/components/conditionalSlot.js +50 -0
- package/dist/components/config-buffer-tools.d.ts +11 -0
- package/dist/components/config-buffer-tools.js +187 -0
- package/dist/components/config-draw-tools.d.ts +11 -0
- package/dist/components/config-draw-tools.js +121 -0
- package/dist/components/config-layer-picker.d.ts +11 -0
- package/dist/components/config-layer-picker.js +163 -0
- package/dist/components/config-pdf-download.d.ts +11 -0
- package/dist/components/config-pdf-download.js +154 -0
- package/dist/components/crowdsource-manager.d.ts +11 -0
- package/dist/components/crowdsource-manager.js +90 -0
- package/dist/components/crowdsource-reporter.d.ts +11 -0
- package/dist/components/crowdsource-reporter.js +90 -0
- package/dist/components/csvUtils.js +74 -0
- package/dist/components/date-picker-day.js +111 -0
- package/dist/components/date-picker-month-header.js +224 -0
- package/dist/components/date-picker-month.js +344 -0
- package/dist/components/date-picker.js +575 -0
- package/dist/components/date.js +180 -0
- package/dist/components/debounce.js +487 -0
- package/dist/components/deduct-calculator.d.ts +11 -0
- package/dist/components/deduct-calculator.js +11 -0
- package/dist/components/deduct-calculator2.js +1002 -0
- package/dist/components/dom.js +231 -0
- package/dist/components/dropdown-group.js +96 -0
- package/dist/components/dropdown-item.js +232 -0
- package/dist/components/dropdown.js +505 -0
- package/dist/components/edit-record-modal.d.ts +11 -0
- package/dist/components/edit-record-modal.js +11 -0
- package/dist/components/edit-record-modal2.js +161 -0
- package/dist/components/filter.js +763 -0
- package/dist/components/floating-ui.js +1768 -0
- package/dist/components/form.js +228 -0
- package/dist/components/graph.js +254 -0
- package/dist/components/guid.js +24 -0
- package/dist/components/handle.js +119 -0
- package/dist/components/icon.js +202 -0
- package/dist/components/index.d.ts +61 -0
- package/dist/components/index.js +196 -0
- package/dist/components/index2.js +199 -0
- package/dist/components/info-card.d.ts +11 -0
- package/dist/components/info-card.js +11 -0
- package/dist/components/info-card2.js +97 -0
- package/dist/components/input-message.js +101 -0
- package/dist/components/input.js +740 -0
- package/dist/components/interactive.js +51 -0
- package/dist/components/interfaces.js +19 -0
- package/dist/components/interfaces2.js +21 -0
- package/dist/components/interfaces3.js +80 -0
- package/dist/components/json-editor.d.ts +11 -0
- package/dist/components/json-editor.js +11 -0
- package/dist/components/json-editor2.js +441 -0
- package/dist/components/key.js +16 -0
- package/dist/components/label.js +106 -0
- package/dist/components/label2.js +131 -0
- package/dist/components/labelFormats.js +210 -0
- package/dist/components/layer-table.d.ts +11 -0
- package/dist/components/layer-table.js +453 -0
- package/dist/components/link.js +123 -0
- package/dist/components/list-item.d.ts +11 -0
- package/dist/components/list-item.js +90 -0
- package/dist/components/list-item2.js +149 -0
- package/dist/components/list.js +83 -0
- package/dist/components/loadModules.js +28 -0
- package/dist/components/loader.js +116 -0
- package/dist/components/locale.js +412 -0
- package/dist/components/locale2.js +413 -0
- package/dist/components/map-card.d.ts +11 -0
- package/dist/components/map-card.js +354 -0
- package/dist/components/map-draw-tools.d.ts +11 -0
- package/dist/components/map-draw-tools.js +11 -0
- package/dist/components/map-draw-tools2.js +228 -0
- package/dist/components/map-layer-picker.d.ts +11 -0
- package/dist/components/map-layer-picker.js +11 -0
- package/dist/components/map-layer-picker2.js +188 -0
- package/dist/components/map-search.d.ts +11 -0
- package/dist/components/map-search.js +155 -0
- package/dist/components/map-select-tools.d.ts +11 -0
- package/dist/components/map-select-tools.js +11 -0
- package/dist/components/map-select-tools2.js +588 -0
- package/dist/components/mapViewUtils.js +129 -0
- package/dist/components/math.js +24 -0
- package/dist/components/media-card.d.ts +11 -0
- package/dist/components/media-card.js +11 -0
- package/dist/components/media-card2.js +177 -0
- package/dist/components/modal.js +495 -0
- package/dist/components/nonChromiumPlatformUtils.js +503 -0
- package/dist/components/notice.js +192 -0
- package/dist/components/observers.js +56 -0
- package/dist/components/openCloseComponent.js +56 -0
- package/dist/components/option.js +109 -0
- package/dist/components/panel.js +459 -0
- package/dist/components/pci-calculator.d.ts +11 -0
- package/dist/components/pci-calculator.js +193 -0
- package/dist/components/pdf-download.d.ts +11 -0
- package/dist/components/pdf-download.js +11 -0
- package/dist/components/pdf-download2.js +189 -0
- package/dist/components/pick-list-item.js +255 -0
- package/dist/components/pick-list.js +170 -0
- package/dist/components/popover.js +500 -0
- package/dist/components/progress.js +60 -0
- package/dist/components/public-notification.d.ts +11 -0
- package/dist/components/public-notification.js +825 -0
- package/dist/components/publicNotificationStore.js +38 -0
- package/dist/components/queryUtils.js +187 -0
- package/dist/components/radio-group-item.js +101 -0
- package/dist/components/radio-group.js +235 -0
- package/dist/components/refine-selection-tools.d.ts +11 -0
- package/dist/components/refine-selection-tools.js +11 -0
- package/dist/components/refine-selection-tools2.js +492 -0
- package/dist/components/refine-selection.d.ts +11 -0
- package/dist/components/refine-selection.js +11 -0
- package/dist/components/refine-selection2.js +376 -0
- package/dist/components/resources.js +24 -0
- package/dist/components/resources2.js +21 -0
- package/dist/components/resources3.js +38 -0
- package/dist/components/scrim.js +83 -0
- package/dist/components/select.js +259 -0
- package/dist/components/shared-list-render.js +319 -0
- package/dist/components/shell-panel.js +281 -0
- package/dist/components/shell.js +121 -0
- package/dist/components/slider.js +896 -0
- package/dist/components/solution-configuration.d.ts +11 -0
- package/dist/components/solution-configuration.js +2233 -0
- package/dist/components/solution-contents.d.ts +11 -0
- package/dist/components/solution-contents.js +11 -0
- package/dist/components/solution-contents2.js +128 -0
- package/dist/components/solution-item-details.d.ts +11 -0
- package/dist/components/solution-item-details.js +11 -0
- package/dist/components/solution-item-details2.js +234 -0
- package/dist/components/solution-item-icon.d.ts +11 -0
- package/dist/components/solution-item-icon.js +11 -0
- package/dist/components/solution-item-icon2.js +342 -0
- package/dist/components/solution-item-sharing.d.ts +11 -0
- package/dist/components/solution-item-sharing.js +11 -0
- package/dist/components/solution-item-sharing2.js +167 -0
- package/dist/components/solution-item.d.ts +11 -0
- package/dist/components/solution-item.js +11 -0
- package/dist/components/solution-item2.js +315 -0
- package/dist/components/solution-organization-variables.d.ts +11 -0
- package/dist/components/solution-organization-variables.js +11 -0
- package/dist/components/solution-organization-variables2.js +132 -0
- package/dist/components/solution-resource-item.d.ts +11 -0
- package/dist/components/solution-resource-item.js +11 -0
- package/dist/components/solution-resource-item2.js +356 -0
- package/dist/components/solution-spatial-ref.d.ts +11 -0
- package/dist/components/solution-spatial-ref.js +11 -0
- package/dist/components/solution-spatial-ref2.js +21446 -0
- package/dist/components/solution-store.js +4092 -0
- package/dist/components/solution-template-data.d.ts +11 -0
- package/dist/components/solution-template-data.js +11 -0
- package/dist/components/solution-template-data2.js +233 -0
- package/dist/components/solution-variables.d.ts +11 -0
- package/dist/components/solution-variables.js +11 -0
- package/dist/components/solution-variables2.js +150 -0
- package/dist/components/sortable.esm.js +3026 -0
- package/dist/components/split-button.js +165 -0
- package/dist/components/store-manager.d.ts +11 -0
- package/dist/components/store-manager.js +83 -0
- package/dist/components/switch.js +139 -0
- package/dist/components/tab-nav.js +241 -0
- package/dist/components/tab-title.js +276 -0
- package/dist/components/tab.js +154 -0
- package/dist/components/tabs.js +188 -0
- package/dist/components/tile.js +129 -0
- package/dist/components/time-picker.js +943 -0
- package/dist/components/tooltip.js +399 -0
- package/dist/components/tree-item.js +294 -0
- package/dist/components/tree.js +327 -0
- package/dist/components/utils.js +119 -0
- package/dist/components/utils2.js +51 -0
- package/dist/components/value-list-item.js +204 -0
- package/dist/components/value-list.js +333 -0
- package/dist/esm/deduct-calculator.entry.js +1 -1
- package/dist/esm/pci-calculator.entry.js +1 -1
- package/dist/esm/{pciUtils-e3007a1c.js → pciUtils-ecda46e5.js} +25 -7
- package/dist/solutions-components/demos/deduct-calculator.html +2 -5
- package/dist/solutions-components/demos/new-public-notification.html +6 -4
- package/dist/solutions-components/{p-ff80ffbb.entry.js → p-0512635b.entry.js} +1 -1
- package/dist/solutions-components/{p-5ec407c2.entry.js → p-0c088725.entry.js} +1 -1
- package/dist/solutions-components/p-cc815aca.js +21 -0
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/pciUtils.ts +30 -7
- package/dist/types/utils/pciUtils.d.ts +2 -1
- package/package.json +4 -3
- package/dist/solutions-components/p-647bbd18.js +0 -21
@@ -0,0 +1,294 @@
|
|
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 { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
7
|
+
import { T as TreeSelectionMode } from './interfaces2.js';
|
8
|
+
import { b as getSlotted, c as getElementDir, C as CSS_UTILITY, t as toAriaBoolean, m as filterDirectChildren, n as nodeListToArray } from './dom.js';
|
9
|
+
import { c as connectConditionalSlotComponent, d as disconnectConditionalSlotComponent } from './conditionalSlot.js';
|
10
|
+
import { u as updateHostInteraction } from './interactive.js';
|
11
|
+
import { d as defineCustomElement$2 } from './checkbox.js';
|
12
|
+
import { d as defineCustomElement$1 } from './icon.js';
|
13
|
+
|
14
|
+
/*!
|
15
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
16
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
17
|
+
* v1.0.0-beta.97
|
18
|
+
*/
|
19
|
+
const CSS = {
|
20
|
+
checkboxLabel: "checkbox-label",
|
21
|
+
checkbox: "checkbox",
|
22
|
+
chevron: "chevron",
|
23
|
+
nodeContainer: "node-container",
|
24
|
+
childrenContainer: "children-container",
|
25
|
+
bulletPointIcon: "bullet-point",
|
26
|
+
checkmarkIcon: "checkmark"
|
27
|
+
};
|
28
|
+
const SLOTS = {
|
29
|
+
children: "children"
|
30
|
+
};
|
31
|
+
const ICONS = {
|
32
|
+
bulletPoint: "bullet-point",
|
33
|
+
checkmark: "check",
|
34
|
+
chevronRight: "chevron-right",
|
35
|
+
blank: "blank"
|
36
|
+
};
|
37
|
+
|
38
|
+
const treeItemCss = "@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;max-inline-size:100%;cursor:pointer;color:var(--calcite-ui-text-3)}:host([calcite-hydrated-hidden]){visibility:hidden !important;pointer-events:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([scale=s]){font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=s]) .node-container{--calcite-tree-padding-y:0.25rem}:host([scale=s]) .node-container .checkbox,:host([scale=s]) .node-container .chevron,:host([scale=s]) .node-container .checkmark,:host([scale=s]) .node-container .bullet-point{margin-inline:0.25rem}:host([scale=m]){font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=m]) .node-container{--calcite-tree-padding-y:0.5rem}:host([scale=m]) .node-container .checkbox,:host([scale=m]) .node-container .chevron,:host([scale=m]) .node-container .checkmark,:host([scale=m]) .node-container .bullet-point{margin-inline:0.5rem}:host([scale=l]){font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=l]) .node-container{--calcite-tree-padding-y:0.75rem}:host([scale=l]) .node-container .checkbox,:host([scale=l]) .node-container .chevron,:host([scale=l]) .node-container .checkmark,:host([scale=l]) .node-container .bullet-point{margin-inline:0.75rem}:host([lines]) .children-container:after{position:absolute;inset-block-start:0px;z-index:1;inline-size:1px;transition-property:color, background-color, border-color, fill, stroke, -webkit-text-decoration-color;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-property:color, background-color, border-color, text-decoration-color, fill, stroke, -webkit-text-decoration-color;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;block-size:96%;content:\"\";background-color:var(--calcite-ui-border-2)}:host(:not([lines])) .node-container:after{display:none}::slotted(*){min-inline-size:0px;max-inline-size:100%;overflow-wrap:break-word;color:inherit;text-decoration:none !important}::slotted(*):hover{text-decoration:none !important}::slotted(a){inline-size:100%;-webkit-text-decoration-line:none;text-decoration-line:none}:host{outline-color:transparent}:host(:focus:not([disabled])){outline:2px solid transparent;outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.checkbox{line-height:0}.checkbox-label{pointer-events:none;display:flex;align-items:center}.checkbox:focus{outline:2px solid transparent;outline-offset:2px}.children-container{position:relative;block-size:0px;overflow:hidden;-webkit-margin-start:1.25rem;margin-inline-start:1.25rem;transform:scaleY(0);opacity:0;transition:var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), opacity var(--calcite-animation-timing) cubic-bezier(0.215, 0.44, 0.42, 0.88), all var(--calcite-animation-timing) ease-in-out;transform-origin:top}:host([expanded])>.children-container{transform:scaleY(1);opacity:1;block-size:auto}.node-container{position:relative;display:flex;align-items:center;padding-block:var(--calcite-tree-padding-y);padding-inline:0}.node-container .checkmark,.node-container .bullet-point{opacity:0;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;color:var(--calcite-ui-border-1)}.node-container:hover .checkmark,.node-container:hover .bullet-point,:host([selected]) .node-container:hover .checkmark,:host([selected]) .node-container:hover .bullet-point,:host(:focus:not([disabled])) .node-container .checkmark,:host(:focus:not([disabled])) .node-container .bullet-point{opacity:1}:host([selected])>.node-container,:host([selected])>.node-container:hover{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}:host([selected])>.node-container .bullet-point,:host([selected])>.node-container .checkmark,:host([selected])>.node-container:hover .bullet-point,:host([selected])>.node-container:hover .checkmark{opacity:1;color:var(--calcite-ui-brand)}:host([selection-mode=none]:not([has-children])):host([scale=s])>.node-container{-webkit-padding-start:0.5rem;padding-inline-start:0.5rem}:host([selection-mode=none]:not([has-children])):host([scale=m])>.node-container{-webkit-padding-start:1rem;padding-inline-start:1rem}:host([selection-mode=none]:not([has-children])):host([scale=l])>.node-container{-webkit-padding-start:1.5rem;padding-inline-start:1.5rem}:host(:not([has-children])):host([scale=s])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-padding-start:1.25rem;padding-inline-start:1.25rem}:host(:not([has-children])):host([scale=m])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-padding-start:1.5rem;padding-inline-start:1.5rem}:host(:not([has-children])):host([scale=l])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-padding-start:1.75rem;padding-inline-start:1.75rem}:host([has-children])>.node-container[data-selection-mode=ancestors] .checkbox{-webkit-margin-start:0;margin-inline-start:0}:host([has-children])>.node-container .bullet-point,:host([has-children])>.node-container .checkmark{display:none}:host([has-children][expanded]:not([selected]):not([selection-mode=none]))>.node-container ::slotted(*){font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}:host([has-children][selected])>.node-container[data-selection-mode=children],:host([has-children][selected])>.node-container[data-selection-mode=multi-children]{color:var(--calcite-ui-brand)}.chevron{position:relative;align-self:center;color:var(--calcite-ui-text-3);transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;flex:0 0 auto;transform:rotate(0deg)}.calcite--rtl .chevron{transform:rotate(180deg)}:host([expanded])>.node-container>.chevron{transform:rotate(90deg)}:host([selected]) .checkmark,:host([selected]) .bullet-point{color:var(--calcite-ui-brand)}";
|
39
|
+
|
40
|
+
const TreeItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
41
|
+
constructor() {
|
42
|
+
super();
|
43
|
+
this.__registerHost();
|
44
|
+
this.__attachShadow();
|
45
|
+
this.calciteInternalTreeItemSelect = createEvent(this, "calciteInternalTreeItemSelect", 6);
|
46
|
+
//--------------------------------------------------------------------------
|
47
|
+
//
|
48
|
+
// Properties
|
49
|
+
//
|
50
|
+
//--------------------------------------------------------------------------
|
51
|
+
/**
|
52
|
+
* When `true`, interaction is prevented and the component is displayed with lower opacity.
|
53
|
+
*/
|
54
|
+
this.disabled = false;
|
55
|
+
/** When `true`, the component is selected. */
|
56
|
+
this.selected = false;
|
57
|
+
/** When `true`, the component is expanded. */
|
58
|
+
this.expanded = false;
|
59
|
+
/**
|
60
|
+
* @internal
|
61
|
+
*/
|
62
|
+
this.parentExpanded = false;
|
63
|
+
/**
|
64
|
+
* @internal
|
65
|
+
*/
|
66
|
+
this.depth = -1;
|
67
|
+
/**
|
68
|
+
* @internal
|
69
|
+
*/
|
70
|
+
this.hasChildren = null;
|
71
|
+
this.iconClickHandler = (event) => {
|
72
|
+
event.stopPropagation();
|
73
|
+
this.expanded = !this.expanded;
|
74
|
+
};
|
75
|
+
this.childrenClickHandler = (event) => event.stopPropagation();
|
76
|
+
//--------------------------------------------------------------------------
|
77
|
+
//
|
78
|
+
// Private Methods
|
79
|
+
//
|
80
|
+
//--------------------------------------------------------------------------
|
81
|
+
this.updateParentIsExpanded = (el, expanded) => {
|
82
|
+
const items = getSlotted(el, SLOTS.children, {
|
83
|
+
all: true,
|
84
|
+
selector: "calcite-tree-item"
|
85
|
+
});
|
86
|
+
items.forEach((item) => (item.parentExpanded = expanded));
|
87
|
+
};
|
88
|
+
this.updateAncestorTree = () => {
|
89
|
+
var _a;
|
90
|
+
if (this.selected && this.selectionMode === TreeSelectionMode.Ancestors) {
|
91
|
+
const ancestors = [];
|
92
|
+
let parent = this.parentTreeItem;
|
93
|
+
while (parent) {
|
94
|
+
ancestors.push(parent);
|
95
|
+
parent = (_a = parent.parentElement) === null || _a === void 0 ? void 0 : _a.closest("calcite-tree-item");
|
96
|
+
}
|
97
|
+
ancestors.forEach((item) => (item.indeterminate = true));
|
98
|
+
return;
|
99
|
+
}
|
100
|
+
};
|
101
|
+
}
|
102
|
+
expandedHandler(newValue) {
|
103
|
+
this.updateParentIsExpanded(this.el, newValue);
|
104
|
+
}
|
105
|
+
getselectionMode() {
|
106
|
+
this.isSelectionMultiLike =
|
107
|
+
this.selectionMode === TreeSelectionMode.Multi ||
|
108
|
+
this.selectionMode === TreeSelectionMode.MultiChildren;
|
109
|
+
}
|
110
|
+
//--------------------------------------------------------------------------
|
111
|
+
//
|
112
|
+
// Lifecycle
|
113
|
+
//
|
114
|
+
//--------------------------------------------------------------------------
|
115
|
+
connectedCallback() {
|
116
|
+
var _a;
|
117
|
+
this.parentTreeItem = (_a = this.el.parentElement) === null || _a === void 0 ? void 0 : _a.closest("calcite-tree-item");
|
118
|
+
if (this.parentTreeItem) {
|
119
|
+
const { expanded } = this.parentTreeItem;
|
120
|
+
this.updateParentIsExpanded(this.parentTreeItem, expanded);
|
121
|
+
}
|
122
|
+
connectConditionalSlotComponent(this);
|
123
|
+
}
|
124
|
+
disconnectedCallback() {
|
125
|
+
disconnectConditionalSlotComponent(this);
|
126
|
+
}
|
127
|
+
componentWillRender() {
|
128
|
+
var _a;
|
129
|
+
this.hasChildren = !!this.el.querySelector("calcite-tree");
|
130
|
+
this.depth = 0;
|
131
|
+
let parentTree = this.el.closest("calcite-tree");
|
132
|
+
if (!parentTree) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
this.selectionMode = parentTree.selectionMode;
|
136
|
+
this.scale = parentTree.scale || "m";
|
137
|
+
this.lines = parentTree.lines;
|
138
|
+
let nextParentTree;
|
139
|
+
while (parentTree) {
|
140
|
+
nextParentTree = (_a = parentTree.parentElement) === null || _a === void 0 ? void 0 : _a.closest("calcite-tree");
|
141
|
+
if (nextParentTree === parentTree) {
|
142
|
+
break;
|
143
|
+
}
|
144
|
+
else {
|
145
|
+
parentTree = nextParentTree;
|
146
|
+
this.depth = this.depth + 1;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
componentDidLoad() {
|
151
|
+
this.updateAncestorTree();
|
152
|
+
}
|
153
|
+
componentDidRender() {
|
154
|
+
updateHostInteraction(this, () => this.parentExpanded || this.depth === 1);
|
155
|
+
}
|
156
|
+
render() {
|
157
|
+
const rtl = getElementDir(this.el) === "rtl";
|
158
|
+
const showBulletPoint = this.selectionMode === TreeSelectionMode.Single ||
|
159
|
+
this.selectionMode === TreeSelectionMode.Children;
|
160
|
+
const showCheckmark = this.selectionMode === TreeSelectionMode.Multi ||
|
161
|
+
this.selectionMode === TreeSelectionMode.MultiChildren;
|
162
|
+
const showBlank = this.selectionMode === TreeSelectionMode.None && !this.hasChildren;
|
163
|
+
const chevron = this.hasChildren ? (h("calcite-icon", { class: {
|
164
|
+
[CSS.chevron]: true,
|
165
|
+
[CSS_UTILITY.rtl]: rtl
|
166
|
+
}, "data-test-id": "icon", icon: ICONS.chevronRight, onClick: this.iconClickHandler, scale: "s" })) : null;
|
167
|
+
const defaultSlotNode = h("slot", { key: "default-slot" });
|
168
|
+
const checkbox = this.selectionMode === TreeSelectionMode.Ancestors ? (h("label", { class: CSS.checkboxLabel, key: "checkbox-label" }, h("calcite-checkbox", { checked: this.selected, class: CSS.checkbox, "data-test-id": "checkbox", indeterminate: this.hasChildren && this.indeterminate, scale: this.scale, tabIndex: -1 }), defaultSlotNode)) : null;
|
169
|
+
const selectedIcon = showBulletPoint
|
170
|
+
? ICONS.bulletPoint
|
171
|
+
: showCheckmark
|
172
|
+
? ICONS.checkmark
|
173
|
+
: showBlank
|
174
|
+
? ICONS.blank
|
175
|
+
: null;
|
176
|
+
const itemIndicator = selectedIcon ? (h("calcite-icon", { class: {
|
177
|
+
[CSS.bulletPointIcon]: selectedIcon === ICONS.bulletPoint,
|
178
|
+
[CSS.checkmarkIcon]: selectedIcon === ICONS.checkmark,
|
179
|
+
[CSS_UTILITY.rtl]: rtl
|
180
|
+
}, icon: selectedIcon, scale: "s" })) : null;
|
181
|
+
const hidden = !(this.parentExpanded || this.depth === 1);
|
182
|
+
return (h(Host, { "aria-expanded": this.hasChildren ? toAriaBoolean(this.expanded) : undefined, "aria-hidden": toAriaBoolean(hidden), "aria-selected": this.selected ? "true" : showCheckmark ? "false" : undefined, "calcite-hydrated-hidden": hidden, role: "treeitem" }, h("div", { class: {
|
183
|
+
[CSS.nodeContainer]: true,
|
184
|
+
[CSS_UTILITY.rtl]: rtl
|
185
|
+
}, "data-selection-mode": this.selectionMode, ref: (el) => (this.defaultSlotWrapper = el) }, chevron, itemIndicator, checkbox ? checkbox : defaultSlotNode), h("div", { class: {
|
186
|
+
[CSS.childrenContainer]: true,
|
187
|
+
[CSS_UTILITY.rtl]: rtl
|
188
|
+
}, "data-test-id": "calcite-tree-children", onClick: this.childrenClickHandler, ref: (el) => (this.childrenSlotWrapper = el), role: this.hasChildren ? "group" : undefined }, h("slot", { name: SLOTS.children }))));
|
189
|
+
}
|
190
|
+
//--------------------------------------------------------------------------
|
191
|
+
//
|
192
|
+
// Event Listeners
|
193
|
+
//
|
194
|
+
//--------------------------------------------------------------------------
|
195
|
+
onClick(event) {
|
196
|
+
// Solve for if the item is clicked somewhere outside the slotted anchor.
|
197
|
+
// Anchor is triggered anywhere you click
|
198
|
+
const [link] = filterDirectChildren(this.el, "a");
|
199
|
+
if (link && event.composedPath()[0].tagName.toLowerCase() !== "a") {
|
200
|
+
const target = link.target === "" ? "_self" : link.target;
|
201
|
+
window.open(link.href, target);
|
202
|
+
}
|
203
|
+
this.calciteInternalTreeItemSelect.emit({
|
204
|
+
modifyCurrentSelection: this.selectionMode === TreeSelectionMode.Ancestors || this.isSelectionMultiLike,
|
205
|
+
forceToggle: false
|
206
|
+
});
|
207
|
+
}
|
208
|
+
keyDownHandler(event) {
|
209
|
+
let root;
|
210
|
+
switch (event.key) {
|
211
|
+
case " ":
|
212
|
+
this.calciteInternalTreeItemSelect.emit({
|
213
|
+
modifyCurrentSelection: this.isSelectionMultiLike,
|
214
|
+
forceToggle: false
|
215
|
+
});
|
216
|
+
event.preventDefault();
|
217
|
+
break;
|
218
|
+
case "Enter":
|
219
|
+
// activates a node, i.e., performs its default action. For parent nodes, one possible default action is to open or close the node. In single-select trees where selection does not follow focus (see note below), the default action is typically to select the focused node.
|
220
|
+
const link = nodeListToArray(this.el.children).find((el) => el.matches("a"));
|
221
|
+
if (link) {
|
222
|
+
link.click();
|
223
|
+
this.selected = true;
|
224
|
+
}
|
225
|
+
else {
|
226
|
+
this.calciteInternalTreeItemSelect.emit({
|
227
|
+
modifyCurrentSelection: this.isSelectionMultiLike,
|
228
|
+
forceToggle: false
|
229
|
+
});
|
230
|
+
}
|
231
|
+
event.preventDefault();
|
232
|
+
break;
|
233
|
+
case "Home":
|
234
|
+
root = this.el.closest("calcite-tree:not([child])");
|
235
|
+
const firstNode = root.querySelector("calcite-tree-item");
|
236
|
+
firstNode === null || firstNode === void 0 ? void 0 : firstNode.focus();
|
237
|
+
break;
|
238
|
+
case "End":
|
239
|
+
root = this.el.closest("calcite-tree:not([child])");
|
240
|
+
let currentNode = root.children[root.children.length - 1]; // last child
|
241
|
+
let currentTree = nodeListToArray(currentNode.children).find((el) => el.matches("calcite-tree"));
|
242
|
+
while (currentTree) {
|
243
|
+
currentNode = currentTree.children[root.children.length - 1];
|
244
|
+
currentTree = nodeListToArray(currentNode.children).find((el) => el.matches("calcite-tree"));
|
245
|
+
}
|
246
|
+
currentNode === null || currentNode === void 0 ? void 0 : currentNode.focus();
|
247
|
+
break;
|
248
|
+
}
|
249
|
+
}
|
250
|
+
get el() { return this; }
|
251
|
+
static get watchers() { return {
|
252
|
+
"expanded": ["expandedHandler"],
|
253
|
+
"selectionMode": ["getselectionMode"]
|
254
|
+
}; }
|
255
|
+
static get style() { return treeItemCss; }
|
256
|
+
}, [1, "calcite-tree-item", {
|
257
|
+
"disabled": [516],
|
258
|
+
"selected": [1540],
|
259
|
+
"expanded": [1540],
|
260
|
+
"parentExpanded": [4, "parent-expanded"],
|
261
|
+
"depth": [1538],
|
262
|
+
"hasChildren": [1540, "has-children"],
|
263
|
+
"lines": [1540],
|
264
|
+
"inputEnabled": [4, "input-enabled"],
|
265
|
+
"scale": [1537],
|
266
|
+
"indeterminate": [516],
|
267
|
+
"selectionMode": [1537, "selection-mode"]
|
268
|
+
}, [[0, "click", "onClick"], [0, "keydown", "keyDownHandler"]]]);
|
269
|
+
function defineCustomElement() {
|
270
|
+
if (typeof customElements === "undefined") {
|
271
|
+
return;
|
272
|
+
}
|
273
|
+
const components = ["calcite-tree-item", "calcite-checkbox", "calcite-icon"];
|
274
|
+
components.forEach(tagName => { switch (tagName) {
|
275
|
+
case "calcite-tree-item":
|
276
|
+
if (!customElements.get(tagName)) {
|
277
|
+
customElements.define(tagName, TreeItem);
|
278
|
+
}
|
279
|
+
break;
|
280
|
+
case "calcite-checkbox":
|
281
|
+
if (!customElements.get(tagName)) {
|
282
|
+
defineCustomElement$2();
|
283
|
+
}
|
284
|
+
break;
|
285
|
+
case "calcite-icon":
|
286
|
+
if (!customElements.get(tagName)) {
|
287
|
+
defineCustomElement$1();
|
288
|
+
}
|
289
|
+
break;
|
290
|
+
} });
|
291
|
+
}
|
292
|
+
defineCustomElement();
|
293
|
+
|
294
|
+
export { TreeItem as T, defineCustomElement as d };
|
@@ -0,0 +1,327 @@
|
|
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 { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
7
|
+
import { f as focusElement, n as nodeListToArray, o as getRootNode } from './dom.js';
|
8
|
+
import { T as TreeSelectionMode } from './interfaces2.js';
|
9
|
+
|
10
|
+
/*!
|
11
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
12
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
13
|
+
* v1.0.0-beta.97
|
14
|
+
*/
|
15
|
+
function isTreeItem(element) {
|
16
|
+
return element === null || element === void 0 ? void 0 : element.matches("calcite-tree-item");
|
17
|
+
}
|
18
|
+
function getEnabledSiblingItem(el, direction) {
|
19
|
+
const directionProp = direction === "down" ? "nextElementSibling" : "previousElementSibling";
|
20
|
+
let currentEl = el;
|
21
|
+
let enabledEl = null;
|
22
|
+
while (isTreeItem(currentEl)) {
|
23
|
+
if (!currentEl.disabled) {
|
24
|
+
enabledEl = currentEl;
|
25
|
+
break;
|
26
|
+
}
|
27
|
+
currentEl = currentEl[directionProp];
|
28
|
+
}
|
29
|
+
return enabledEl;
|
30
|
+
}
|
31
|
+
|
32
|
+
const treeCss = "@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:block}:host(:focus){outline:2px solid transparent;outline-offset:2px}";
|
33
|
+
|
34
|
+
const Tree = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
35
|
+
constructor() {
|
36
|
+
super();
|
37
|
+
this.__registerHost();
|
38
|
+
this.__attachShadow();
|
39
|
+
this.calciteTreeSelect = createEvent(this, "calciteTreeSelect", 6);
|
40
|
+
//--------------------------------------------------------------------------
|
41
|
+
//
|
42
|
+
// Properties
|
43
|
+
//
|
44
|
+
//--------------------------------------------------------------------------
|
45
|
+
/** Displays indentation guide lines. */
|
46
|
+
this.lines = false;
|
47
|
+
/**
|
48
|
+
* Display input
|
49
|
+
*
|
50
|
+
* @deprecated Use `selectionMode="ancestors"` for checkbox input.
|
51
|
+
*/
|
52
|
+
this.inputEnabled = false;
|
53
|
+
/** Specifies the size of the component. */
|
54
|
+
this.scale = "m";
|
55
|
+
/**
|
56
|
+
* Customize how the component's selection works.
|
57
|
+
*
|
58
|
+
* @default "single"
|
59
|
+
* @see [TreeSelectionMode](https://github.com/Esri/calcite-components/blob/master/src/components/tree/interfaces.ts#L5)
|
60
|
+
*/
|
61
|
+
this.selectionMode = TreeSelectionMode.Single;
|
62
|
+
}
|
63
|
+
//--------------------------------------------------------------------------
|
64
|
+
//
|
65
|
+
// Lifecycle
|
66
|
+
//
|
67
|
+
//--------------------------------------------------------------------------
|
68
|
+
componentWillRender() {
|
69
|
+
var _a;
|
70
|
+
const parent = (_a = this.el.parentElement) === null || _a === void 0 ? void 0 : _a.closest("calcite-tree");
|
71
|
+
this.lines = parent ? parent.lines : this.lines;
|
72
|
+
this.scale = parent ? parent.scale : this.scale;
|
73
|
+
this.selectionMode = parent ? parent.selectionMode : this.selectionMode;
|
74
|
+
this.child = !!parent;
|
75
|
+
}
|
76
|
+
render() {
|
77
|
+
return (h(Host, { "aria-multiselectable": this.child
|
78
|
+
? undefined
|
79
|
+
: (this.selectionMode === TreeSelectionMode.Multi ||
|
80
|
+
this.selectionMode === TreeSelectionMode.MultiChildren).toString(), role: !this.child ? "tree" : undefined, tabIndex: this.getRootTabIndex() }, h("slot", null)));
|
81
|
+
}
|
82
|
+
//--------------------------------------------------------------------------
|
83
|
+
//
|
84
|
+
// Event Listeners
|
85
|
+
//
|
86
|
+
//--------------------------------------------------------------------------
|
87
|
+
onFocus() {
|
88
|
+
if (!this.child) {
|
89
|
+
const focusTarget = this.el.querySelector("calcite-tree-item[selected]:not([disabled])") || this.el.querySelector("calcite-tree-item:not([disabled])");
|
90
|
+
focusElement(focusTarget);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
onFocusIn(event) {
|
94
|
+
const focusedFromRootOrOutsideTree = event.relatedTarget === this.el || !this.el.contains(event.relatedTarget);
|
95
|
+
if (focusedFromRootOrOutsideTree) {
|
96
|
+
// gives user the ability to tab into external elements (modifying tabindex property will not work in firefox)
|
97
|
+
this.el.removeAttribute("tabindex");
|
98
|
+
}
|
99
|
+
}
|
100
|
+
onFocusOut(event) {
|
101
|
+
const willFocusOutsideTree = !this.el.contains(event.relatedTarget);
|
102
|
+
if (willFocusOutsideTree) {
|
103
|
+
this.el.tabIndex = this.getRootTabIndex();
|
104
|
+
}
|
105
|
+
}
|
106
|
+
onClick(event) {
|
107
|
+
const target = event.target;
|
108
|
+
const childItems = nodeListToArray(target.querySelectorAll("calcite-tree-item"));
|
109
|
+
if (this.child) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
if (!this.child) {
|
113
|
+
event.preventDefault();
|
114
|
+
event.stopPropagation();
|
115
|
+
}
|
116
|
+
if (this.selectionMode === TreeSelectionMode.Ancestors && !this.child) {
|
117
|
+
this.updateAncestorTree(event);
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
const isNoneSelectionMode = this.selectionMode === TreeSelectionMode.None;
|
121
|
+
const shouldSelect = this.selectionMode !== null &&
|
122
|
+
(!target.hasChildren ||
|
123
|
+
(target.hasChildren &&
|
124
|
+
(this.selectionMode === TreeSelectionMode.Children ||
|
125
|
+
this.selectionMode === TreeSelectionMode.MultiChildren)));
|
126
|
+
const shouldModifyToCurrentSelection = !isNoneSelectionMode &&
|
127
|
+
event.detail.modifyCurrentSelection &&
|
128
|
+
(this.selectionMode === TreeSelectionMode.Multi ||
|
129
|
+
this.selectionMode === TreeSelectionMode.MultiChildren);
|
130
|
+
const shouldSelectChildren = this.selectionMode === TreeSelectionMode.MultiChildren ||
|
131
|
+
this.selectionMode === TreeSelectionMode.Children;
|
132
|
+
const shouldClearCurrentSelection = !shouldModifyToCurrentSelection &&
|
133
|
+
(((this.selectionMode === TreeSelectionMode.Single ||
|
134
|
+
this.selectionMode === TreeSelectionMode.Multi) &&
|
135
|
+
childItems.length <= 0) ||
|
136
|
+
this.selectionMode === TreeSelectionMode.Children ||
|
137
|
+
this.selectionMode === TreeSelectionMode.MultiChildren);
|
138
|
+
const shouldExpandTarget = this.selectionMode === TreeSelectionMode.Children ||
|
139
|
+
this.selectionMode === TreeSelectionMode.MultiChildren;
|
140
|
+
if (!this.child) {
|
141
|
+
const targetItems = [];
|
142
|
+
if (shouldSelect) {
|
143
|
+
targetItems.push(target);
|
144
|
+
}
|
145
|
+
if (shouldSelectChildren) {
|
146
|
+
childItems.forEach((treeItem) => {
|
147
|
+
targetItems.push(treeItem);
|
148
|
+
});
|
149
|
+
}
|
150
|
+
if (shouldClearCurrentSelection) {
|
151
|
+
const selectedItems = nodeListToArray(this.el.querySelectorAll("calcite-tree-item[selected]"));
|
152
|
+
selectedItems.forEach((treeItem) => {
|
153
|
+
if (!targetItems.includes(treeItem)) {
|
154
|
+
treeItem.selected = false;
|
155
|
+
}
|
156
|
+
});
|
157
|
+
}
|
158
|
+
if (shouldExpandTarget && !event.detail.forceToggle) {
|
159
|
+
target.expanded = true;
|
160
|
+
}
|
161
|
+
if (shouldModifyToCurrentSelection) {
|
162
|
+
window.getSelection().removeAllRanges();
|
163
|
+
}
|
164
|
+
if ((shouldModifyToCurrentSelection && target.selected) ||
|
165
|
+
(shouldSelectChildren && event.detail.forceToggle)) {
|
166
|
+
targetItems.forEach((treeItem) => {
|
167
|
+
if (!treeItem.disabled) {
|
168
|
+
treeItem.selected = false;
|
169
|
+
}
|
170
|
+
});
|
171
|
+
}
|
172
|
+
else if (!isNoneSelectionMode) {
|
173
|
+
targetItems.forEach((treeItem) => {
|
174
|
+
if (!treeItem.disabled) {
|
175
|
+
treeItem.selected = true;
|
176
|
+
}
|
177
|
+
});
|
178
|
+
}
|
179
|
+
}
|
180
|
+
const selected = isNoneSelectionMode
|
181
|
+
? [target]
|
182
|
+
: nodeListToArray(this.el.querySelectorAll("calcite-tree-item")).filter((i) => i.selected);
|
183
|
+
this.calciteTreeSelect.emit({ selected });
|
184
|
+
event.stopPropagation();
|
185
|
+
}
|
186
|
+
keyDownHandler(event) {
|
187
|
+
var _a;
|
188
|
+
const root = this.el.closest("calcite-tree:not([child])");
|
189
|
+
const target = event.target;
|
190
|
+
if (!(root === this.el && target.tagName === "CALCITE-TREE-ITEM" && this.el.contains(target))) {
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
if (event.key === "ArrowDown") {
|
194
|
+
const next = getEnabledSiblingItem(target.nextElementSibling, "down");
|
195
|
+
if (next) {
|
196
|
+
next.focus();
|
197
|
+
event.preventDefault();
|
198
|
+
}
|
199
|
+
return;
|
200
|
+
}
|
201
|
+
if (event.key === "ArrowUp") {
|
202
|
+
const previous = getEnabledSiblingItem(target.previousElementSibling, "up");
|
203
|
+
if (previous) {
|
204
|
+
previous.focus();
|
205
|
+
event.preventDefault();
|
206
|
+
}
|
207
|
+
}
|
208
|
+
if (event.key === "ArrowLeft" && !target.disabled) {
|
209
|
+
// When focus is on an open node, closes the node.
|
210
|
+
if (target.hasChildren && target.expanded) {
|
211
|
+
target.expanded = false;
|
212
|
+
event.preventDefault();
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
// When focus is on a child node that is also either an end node or a closed node, moves focus to its parent node.
|
216
|
+
const parentItem = target.parentElement.closest("calcite-tree-item");
|
217
|
+
if (parentItem && (!target.hasChildren || target.expanded === false)) {
|
218
|
+
parentItem.focus();
|
219
|
+
event.preventDefault();
|
220
|
+
return;
|
221
|
+
}
|
222
|
+
// When focus is on a root node that is also either an end node or a closed node, does nothing.
|
223
|
+
return;
|
224
|
+
}
|
225
|
+
if (event.key === "ArrowRight" && !target.disabled) {
|
226
|
+
if (target.hasChildren) {
|
227
|
+
if (target.expanded && getRootNode(this.el).activeElement === target) {
|
228
|
+
// When focus is on an open node, moves focus to the first child node.
|
229
|
+
(_a = getEnabledSiblingItem(target.querySelector("calcite-tree-item"), "down")) === null || _a === void 0 ? void 0 : _a.focus();
|
230
|
+
event.preventDefault();
|
231
|
+
}
|
232
|
+
else {
|
233
|
+
// When focus is on a closed node, opens the node; focus does not move.
|
234
|
+
target.expanded = true;
|
235
|
+
event.preventDefault();
|
236
|
+
}
|
237
|
+
}
|
238
|
+
return;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
updateAncestorTree(event) {
|
242
|
+
const item = event.target;
|
243
|
+
if (item.disabled) {
|
244
|
+
return;
|
245
|
+
}
|
246
|
+
const ancestors = [];
|
247
|
+
let parent = item.parentElement.closest("calcite-tree-item");
|
248
|
+
while (parent) {
|
249
|
+
ancestors.push(parent);
|
250
|
+
parent = parent.parentElement.closest("calcite-tree-item");
|
251
|
+
}
|
252
|
+
const childItems = Array.from(item.querySelectorAll("calcite-tree-item:not([disabled])"));
|
253
|
+
const childItemsWithNoChildren = childItems.filter((child) => !child.hasChildren);
|
254
|
+
const childItemsWithChildren = childItems.filter((child) => child.hasChildren);
|
255
|
+
const futureSelected = item.hasChildren
|
256
|
+
? !(item.selected || item.indeterminate)
|
257
|
+
: !item.selected;
|
258
|
+
childItemsWithNoChildren.forEach((el) => {
|
259
|
+
el.selected = futureSelected;
|
260
|
+
el.indeterminate = false;
|
261
|
+
});
|
262
|
+
function updateItemState(childItems, item) {
|
263
|
+
const selected = childItems.filter((child) => child.selected);
|
264
|
+
const unselected = childItems.filter((child) => !child.selected);
|
265
|
+
item.selected = selected.length === childItems.length;
|
266
|
+
item.indeterminate = selected.length > 0 && unselected.length > 0;
|
267
|
+
}
|
268
|
+
childItemsWithChildren.forEach((el) => {
|
269
|
+
const directChildItems = Array.from(el.querySelectorAll(":scope > calcite-tree > calcite-tree-item"));
|
270
|
+
updateItemState(directChildItems, el);
|
271
|
+
});
|
272
|
+
if (item.hasChildren) {
|
273
|
+
updateItemState(childItems, item);
|
274
|
+
}
|
275
|
+
else {
|
276
|
+
item.selected = futureSelected;
|
277
|
+
item.indeterminate = false;
|
278
|
+
}
|
279
|
+
ancestors.forEach((ancestor) => {
|
280
|
+
const descendants = nodeListToArray(ancestor.querySelectorAll("calcite-tree-item"));
|
281
|
+
const activeDescendants = descendants.filter((el) => el.selected);
|
282
|
+
if (activeDescendants.length === 0) {
|
283
|
+
ancestor.selected = false;
|
284
|
+
ancestor.indeterminate = false;
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
const indeterminate = activeDescendants.length < descendants.length;
|
288
|
+
ancestor.indeterminate = indeterminate;
|
289
|
+
ancestor.selected = !indeterminate;
|
290
|
+
});
|
291
|
+
this.calciteTreeSelect.emit({
|
292
|
+
selected: nodeListToArray(this.el.querySelectorAll("calcite-tree-item")).filter((i) => i.selected)
|
293
|
+
});
|
294
|
+
}
|
295
|
+
// --------------------------------------------------------------------------
|
296
|
+
//
|
297
|
+
// Private Methods
|
298
|
+
//
|
299
|
+
//--------------------------------------------------------------------------
|
300
|
+
getRootTabIndex() {
|
301
|
+
return !this.child ? 0 : -1;
|
302
|
+
}
|
303
|
+
get el() { return this; }
|
304
|
+
static get style() { return treeCss; }
|
305
|
+
}, [1, "calcite-tree", {
|
306
|
+
"lines": [1540],
|
307
|
+
"inputEnabled": [4, "input-enabled"],
|
308
|
+
"child": [1540],
|
309
|
+
"scale": [1537],
|
310
|
+
"selectionMode": [1537, "selection-mode"]
|
311
|
+
}, [[0, "focus", "onFocus"], [0, "focusin", "onFocusIn"], [0, "focusout", "onFocusOut"], [0, "calciteInternalTreeItemSelect", "onClick"], [0, "keydown", "keyDownHandler"]]]);
|
312
|
+
function defineCustomElement() {
|
313
|
+
if (typeof customElements === "undefined") {
|
314
|
+
return;
|
315
|
+
}
|
316
|
+
const components = ["calcite-tree"];
|
317
|
+
components.forEach(tagName => { switch (tagName) {
|
318
|
+
case "calcite-tree":
|
319
|
+
if (!customElements.get(tagName)) {
|
320
|
+
customElements.define(tagName, Tree);
|
321
|
+
}
|
322
|
+
break;
|
323
|
+
} });
|
324
|
+
}
|
325
|
+
defineCustomElement();
|
326
|
+
|
327
|
+
export { Tree as T, defineCustomElement as d };
|