@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,896 @@
|
|
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 { g as guid } from './guid.js';
|
8
|
+
import { i as isPrimaryPointerButton, l as intersects } from './dom.js';
|
9
|
+
import { d as decimalPlaces, c as clamp } from './math.js';
|
10
|
+
import { c as connectLabel, d as disconnectLabel } from './label2.js';
|
11
|
+
import { c as connectForm, d as disconnectForm, a as afterConnectDefaultValueSet, H as HiddenFormInputSlot } from './form.js';
|
12
|
+
import { u as updateHostInteraction } from './interactive.js';
|
13
|
+
import { i as isActivationKey } from './key.js';
|
14
|
+
import { n as numberStringFormatter, c as connectLocalized, d as disconnectLocalized } from './locale2.js';
|
15
|
+
import { d as defineCustomElement$1 } from './graph.js';
|
16
|
+
|
17
|
+
/*!
|
18
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
19
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
20
|
+
* v1.0.0-beta.97
|
21
|
+
*/
|
22
|
+
const CSS = {
|
23
|
+
handleLabel: "handle__label",
|
24
|
+
handleLabelMinValue: "handle__label--minValue",
|
25
|
+
handleLabelValue: "handle__label--value",
|
26
|
+
tickMin: "tick__label--min",
|
27
|
+
tickMax: "tick__label--max"
|
28
|
+
};
|
29
|
+
|
30
|
+
const sliderCss = "@charset \"UTF-8\";@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)}.scale--s{--calcite-slider-handle-size:10px;--calcite-slider-handle-extension-height:6.5px;--calcite-slider-container-font-size:var(--calcite-font-size--3)}.scale--s .handle__label,.scale--s .tick__label{line-height:.75rem}.scale--m{--calcite-slider-handle-size:14px;--calcite-slider-handle-extension-height:8px;--calcite-slider-container-font-size:var(--calcite-font-size--2)}.scale--m .handle__label,.scale--m .tick__label{line-height:1rem}.scale--l{--calcite-slider-handle-size:16px;--calcite-slider-handle-extension-height:10.5px;--calcite-slider-container-font-size:var(--calcite-font-size--1)}.scale--l .handle__label,.scale--l .tick__label{line-height:1rem}.handle__label,.tick__label{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2);font-size:var(--calcite-slider-container-font-size)}:host{display:block}.container{position:relative;display:block;overflow-wrap:normal;word-break:normal;padding-inline:calc(var(--calcite-slider-handle-size) * 0.5);padding-block:calc(var(--calcite-slider-handle-size) * 0.5);margin-block:calc(var(--calcite-slider-handle-size) * 0.5);margin-inline:0;--calcite-slider-full-handle-height:calc(\n var(--calcite-slider-handle-size) + var(--calcite-slider-handle-extension-height)\n )}:host([disabled]) .track__range,:host([disabled]) .tick--active{background-color:var(--calcite-ui-text-3)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.scale--s .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-6px}.scale--m .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-8px}.scale--l .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-9px}:host([precise]:not([has-histogram])) .container .thumb--value{--calcite-slider-thumb-y-offset:calc(var(--calcite-slider-full-handle-height) * -1)}.thumb-container{position:relative;max-inline-size:100%}.thumb{--calcite-slider-thumb-x-offset:calc(var(--calcite-slider-handle-size) * 0.5);position:absolute;margin:0px;display:flex;cursor:pointer;flex-direction:column;align-items:center;border-style:none;background-color:transparent;padding:0px;font-family:inherit;outline:2px solid transparent;outline-offset:2px;transform:translate(var(--calcite-slider-thumb-x-offset), var(--calcite-slider-thumb-y-offset))}.thumb .handle__label.static,.thumb .handle__label.transformed{position:absolute;inset-block:0px;opacity:0}.thumb .handle__label.hyphen::after{content:\"—\";display:inline-block;inline-size:1em}.thumb .handle__label.hyphen--wrap{display:flex}.thumb .handle{box-sizing:border-box;border-radius:9999px;background-color:var(--calcite-ui-foreground-1);outline-color:transparent;block-size:var(--calcite-slider-handle-size);inline-size:var(--calcite-slider-handle-size);box-shadow:0 0 0 2px var(--calcite-ui-text-3) inset;transition:border var(--calcite-internal-animation-timing-medium) ease, background-color var(--calcite-internal-animation-timing-medium) ease, box-shadow var(--calcite-animation-timing) ease}.thumb .handle-extension{inline-size:0.125rem;block-size:var(--calcite-slider-handle-extension-height);background-color:var(--calcite-ui-text-3)}.thumb:hover .handle{box-shadow:0 0 0 3px var(--calcite-ui-brand) inset}.thumb:hover .handle-extension{background-color:var(--calcite-ui-brand)}.thumb:focus .handle{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.thumb:focus .handle-extension{background-color:var(--calcite-ui-brand)}.thumb.thumb--minValue{transform:translate(calc(var(--calcite-slider-thumb-x-offset) * -1), var(--calcite-slider-thumb-y-offset))}.thumb.thumb--precise{--calcite-slider-thumb-y-offset:-2px}:host([label-handles]) .thumb{--calcite-slider-thumb-x-offset:50%}:host([label-handles]):host(:not([has-histogram])) .scale--s .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-23px}:host([label-handles]):host(:not([has-histogram])) .scale--m .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-30px}:host([label-handles]):host(:not([has-histogram])) .scale--l .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-32px}:host([has-histogram][label-handles]) .handle__label,:host([label-handles]:not([has-histogram])) .thumb--minValue.thumb--precise .handle__label{-webkit-margin-before:0.5em;margin-block-start:0.5em}:host(:not([has-histogram]):not([precise])) .handle__label,:host([label-handles]:not([has-histogram])) .thumb--value .handle__label{-webkit-margin-after:0.5em;margin-block-end:0.5em}:host([label-handles][precise]):host(:not([has-histogram])) .scale--s .thumb--value{--calcite-slider-thumb-y-offset:-33px}:host([label-handles][precise]):host(:not([has-histogram])) .scale--m .thumb--value{--calcite-slider-thumb-y-offset:-44px}:host([label-handles][precise]):host(:not([has-histogram])) .scale--l .thumb--value{--calcite-slider-thumb-y-offset:-49px}.thumb:focus .handle,.thumb--active .handle{background-color:var(--calcite-ui-brand);box-shadow:0 0 8px 0 rgba(0, 0, 0, 0.16)}.thumb:hover.thumb--precise:after,.thumb:focus.thumb--precise:after,.thumb--active.thumb--precise:after{background-color:var(--calcite-ui-brand)}.track{position:relative;block-size:0.125rem;border-radius:0px;background-color:var(--calcite-ui-border-2);transition:all var(--calcite-internal-animation-timing-medium) ease-in}.track__range{position:absolute;inset-block-start:0px;block-size:0.125rem;background-color:var(--calcite-ui-brand)}.container--range .track__range:hover{cursor:ew-resize}.container--range .track__range:after{position:absolute;inline-size:100%;content:\"\";inset-block-start:calc(var(--calcite-slider-full-handle-height) * 0.5 * -1);block-size:calc(var(--calcite-slider-handle-size) + var(--calcite-slider-handle-extension-height))}@media (forced-colors: active){.thumb{outline-width:0;outline-offset:0}.handle{outline:2px solid transparent;outline-offset:2px}.thumb:focus .handle,.thumb .handle-extension,.thumb:hover .handle-extension,.thumb:focus .handle-extension,.thumb:active .handle-extension{background-color:canvasText}.track{background-color:canvasText}.track__range{background-color:highlight}}.tick{position:absolute;block-size:0.25rem;inline-size:0.125rem;border-width:1px;border-style:solid;background-color:var(--calcite-ui-border-input);border-color:var(--calcite-ui-foreground-1);inset-block-start:-2px;pointer-events:none;-webkit-margin-start:calc(-1 * 0.125rem);margin-inline-start:calc(-1 * 0.125rem)}.tick--active{background-color:var(--calcite-ui-brand)}.tick__label{pointer-events:none;-webkit-margin-before:0.875rem;margin-block-start:0.875rem;display:flex;justify-content:center}.tick__label--min{transition:opacity var(--calcite-animation-timing)}.tick__label--max{transition:opacity var(--calcite-internal-animation-timing-fast)}:host([has-histogram][label-handles]) .tick__label--min,:host([has-histogram][label-handles]) .tick__label--max,:host([has-histogram][precise]) .tick__label--min,:host([has-histogram][precise]) .tick__label--max{font-weight:var(--calcite-font-weight-normal);color:var(--calcite-ui-text-3)}.graph{color:var(--calcite-ui-foreground-3);block-size:48px}:host([label-ticks][ticks]) .container{-webkit-padding-after:calc(0.875rem + var(--calcite-slider-container-font-size));padding-block-end:calc(0.875rem + var(--calcite-slider-container-font-size))}:host([has-histogram]):host([precise][label-handles]) .container{-webkit-padding-after:calc(var(--calcite-slider-full-handle-height) + 1em);padding-block-end:calc(var(--calcite-slider-full-handle-height) + 1em)}:host([has-histogram]):host([label-handles]:not([precise])) .container{-webkit-padding-after:calc(var(--calcite-slider-handle-size) * 0.5 + 1em);padding-block-end:calc(var(--calcite-slider-handle-size) * 0.5 + 1em)}:host([has-histogram]):host([precise]:not([label-handles])) .container{-webkit-padding-after:var(--calcite-slider-full-handle-height);padding-block-end:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([precise]:not([label-handles])) .container{-webkit-padding-before:var(--calcite-slider-full-handle-height);padding-block-start:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([precise]:not([label-handles])) .container--range{-webkit-padding-after:var(--calcite-slider-full-handle-height);padding-block-end:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([label-handles]:not([precise])) .container{-webkit-padding-before:calc(var(--calcite-slider-full-handle-height) + 4px);padding-block-start:calc(var(--calcite-slider-full-handle-height) + 4px)}:host(:not([has-histogram])):host([label-handles][precise]) .container{-webkit-padding-before:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px);padding-block-start:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px)}:host(:not([has-histogram])):host([label-handles][precise]) .container--range{-webkit-padding-after:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px);padding-block-end:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px)}::slotted(input[slot=hidden-form-input]){margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;inset:0 !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
|
31
|
+
|
32
|
+
function isRange(value) {
|
33
|
+
return Array.isArray(value);
|
34
|
+
}
|
35
|
+
const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
36
|
+
constructor() {
|
37
|
+
super();
|
38
|
+
this.__registerHost();
|
39
|
+
this.__attachShadow();
|
40
|
+
this.calciteSliderInput = createEvent(this, "calciteSliderInput", 6);
|
41
|
+
this.calciteSliderChange = createEvent(this, "calciteSliderChange", 6);
|
42
|
+
this.calciteSliderUpdate = createEvent(this, "calciteSliderUpdate", 6);
|
43
|
+
//--------------------------------------------------------------------------
|
44
|
+
//
|
45
|
+
// Properties
|
46
|
+
//
|
47
|
+
//--------------------------------------------------------------------------
|
48
|
+
/** When `true`, interaction is prevented and the component is displayed with lower opacity. */
|
49
|
+
this.disabled = false;
|
50
|
+
/**
|
51
|
+
* When `true`, number values are displayed with a group separator corresponding to the language and country format.
|
52
|
+
*/
|
53
|
+
this.groupSeparator = false;
|
54
|
+
/** When `true`, indicates a histogram is present. */
|
55
|
+
this.hasHistogram = false;
|
56
|
+
/** When `true`, displays label handles with their numeric value. */
|
57
|
+
this.labelHandles = false;
|
58
|
+
/** When `true` and `ticks` is specified, displays label tick marks with their numeric value. */
|
59
|
+
this.labelTicks = false;
|
60
|
+
/** The component's maximum selectable value. */
|
61
|
+
this.max = 100;
|
62
|
+
/** The component's minimum selectable value. */
|
63
|
+
this.min = 0;
|
64
|
+
/**
|
65
|
+
* When `true`, the slider will display values from high to low.
|
66
|
+
*
|
67
|
+
* Note that this value will be ignored if the slider has an associated histogram.
|
68
|
+
*/
|
69
|
+
this.mirrored = false;
|
70
|
+
/** When `true`, sets a finer point for handles. */
|
71
|
+
this.precise = false;
|
72
|
+
/**
|
73
|
+
* When `true`, the component must have a value in order for the form to submit.
|
74
|
+
*/
|
75
|
+
this.required = false;
|
76
|
+
/** When `true`, enables snap selection in coordination with `step` via a mouse. */
|
77
|
+
this.snap = false;
|
78
|
+
/** Specifies the interval to move with the up, or down keys. */
|
79
|
+
this.step = 1;
|
80
|
+
/** The component's value. */
|
81
|
+
this.value = 0;
|
82
|
+
/**
|
83
|
+
* Specifies the size of the component.
|
84
|
+
*/
|
85
|
+
this.scale = "m";
|
86
|
+
this.activeProp = "value";
|
87
|
+
this.guid = `calcite-slider-${guid()}`;
|
88
|
+
this.effectiveLocale = "";
|
89
|
+
this.minMaxValueRange = null;
|
90
|
+
this.minValueDragRange = null;
|
91
|
+
this.maxValueDragRange = null;
|
92
|
+
this.tickValues = [];
|
93
|
+
this.dragUpdate = (event) => {
|
94
|
+
event.preventDefault();
|
95
|
+
if (this.dragProp) {
|
96
|
+
const value = this.translate(event.clientX || event.pageX);
|
97
|
+
if (isRange(this.value) && this.dragProp === "minMaxValue") {
|
98
|
+
if (this.minValueDragRange && this.maxValueDragRange && this.minMaxValueRange) {
|
99
|
+
const newMinValue = value - this.minValueDragRange;
|
100
|
+
const newMaxValue = value + this.maxValueDragRange;
|
101
|
+
if (newMaxValue <= this.max &&
|
102
|
+
newMinValue >= this.min &&
|
103
|
+
newMaxValue - newMinValue === this.minMaxValueRange) {
|
104
|
+
this.setValue({
|
105
|
+
minValue: this.clamp(newMinValue, "minValue"),
|
106
|
+
maxValue: this.clamp(newMaxValue, "maxValue")
|
107
|
+
});
|
108
|
+
}
|
109
|
+
}
|
110
|
+
else {
|
111
|
+
this.minValueDragRange = value - this.minValue;
|
112
|
+
this.maxValueDragRange = this.maxValue - value;
|
113
|
+
this.minMaxValueRange = this.maxValue - this.minValue;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
else {
|
117
|
+
this.setValue({ [this.dragProp]: this.clamp(value, this.dragProp) });
|
118
|
+
}
|
119
|
+
}
|
120
|
+
};
|
121
|
+
this.pointerUpDragEnd = (event) => {
|
122
|
+
if (!isPrimaryPointerButton(event)) {
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
this.dragEnd(event);
|
126
|
+
};
|
127
|
+
this.dragEnd = (event) => {
|
128
|
+
this.removeDragListeners();
|
129
|
+
this.focusActiveHandle(event.clientX);
|
130
|
+
if (this.lastDragPropValue != this[this.dragProp]) {
|
131
|
+
this.emitChange();
|
132
|
+
}
|
133
|
+
this.dragProp = null;
|
134
|
+
this.lastDragPropValue = null;
|
135
|
+
this.minValueDragRange = null;
|
136
|
+
this.maxValueDragRange = null;
|
137
|
+
this.minMaxValueRange = null;
|
138
|
+
};
|
139
|
+
/**
|
140
|
+
* Set the reference of the track Element
|
141
|
+
*
|
142
|
+
* @internal
|
143
|
+
* @param node
|
144
|
+
*/
|
145
|
+
this.storeTrackRef = (node) => {
|
146
|
+
this.trackEl = node;
|
147
|
+
};
|
148
|
+
/**
|
149
|
+
* Returns a string representing the localized label value based if the groupSeparator prop is parsed.
|
150
|
+
*
|
151
|
+
* @param value
|
152
|
+
*/
|
153
|
+
this.determineGroupSeparator = (value) => {
|
154
|
+
if (typeof value === "number") {
|
155
|
+
numberStringFormatter.numberFormatOptions = {
|
156
|
+
locale: this.effectiveLocale,
|
157
|
+
numberingSystem: this.numberingSystem,
|
158
|
+
useGrouping: this.groupSeparator
|
159
|
+
};
|
160
|
+
return numberStringFormatter.localize(value.toString());
|
161
|
+
}
|
162
|
+
};
|
163
|
+
}
|
164
|
+
histogramWatcher(newHistogram) {
|
165
|
+
this.hasHistogram = !!newHistogram;
|
166
|
+
}
|
167
|
+
valueHandler() {
|
168
|
+
this.setMinMaxFromValue();
|
169
|
+
}
|
170
|
+
minMaxValueHandler() {
|
171
|
+
this.setValueFromMinMax();
|
172
|
+
}
|
173
|
+
//--------------------------------------------------------------------------
|
174
|
+
//
|
175
|
+
// Lifecycle
|
176
|
+
//
|
177
|
+
//--------------------------------------------------------------------------
|
178
|
+
connectedCallback() {
|
179
|
+
connectLocalized(this);
|
180
|
+
this.setMinMaxFromValue();
|
181
|
+
this.setValueFromMinMax();
|
182
|
+
connectLabel(this);
|
183
|
+
connectForm(this);
|
184
|
+
}
|
185
|
+
disconnectedCallback() {
|
186
|
+
disconnectLabel(this);
|
187
|
+
disconnectForm(this);
|
188
|
+
disconnectLocalized(this);
|
189
|
+
this.removeDragListeners();
|
190
|
+
}
|
191
|
+
componentWillLoad() {
|
192
|
+
this.tickValues = this.generateTickValues();
|
193
|
+
if (!isRange(this.value)) {
|
194
|
+
this.value = this.clamp(this.value);
|
195
|
+
}
|
196
|
+
afterConnectDefaultValueSet(this, this.value);
|
197
|
+
if (this.snap && !isRange(this.value)) {
|
198
|
+
this.value = this.getClosestStep(this.value);
|
199
|
+
}
|
200
|
+
if (this.histogram) {
|
201
|
+
this.hasHistogram = true;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
componentDidRender() {
|
205
|
+
if (this.labelHandles) {
|
206
|
+
this.adjustHostObscuredHandleLabel("value");
|
207
|
+
if (isRange(this.value)) {
|
208
|
+
this.adjustHostObscuredHandleLabel("minValue");
|
209
|
+
if (!(this.precise && !this.hasHistogram)) {
|
210
|
+
this.hyphenateCollidingRangeHandleLabels();
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}
|
214
|
+
this.hideObscuredBoundingTickLabels();
|
215
|
+
updateHostInteraction(this);
|
216
|
+
}
|
217
|
+
render() {
|
218
|
+
const id = this.el.id || this.guid;
|
219
|
+
const maxProp = isRange(this.value) ? "maxValue" : "value";
|
220
|
+
const value = isRange(this.value) ? this.maxValue : this.value;
|
221
|
+
const displayedValue = this.determineGroupSeparator(value);
|
222
|
+
const displayedMinValue = this.determineGroupSeparator(this.minValue);
|
223
|
+
const min = this.minValue || this.min;
|
224
|
+
const useMinValue = this.shouldUseMinValue();
|
225
|
+
const minInterval = this.getUnitInterval(useMinValue ? this.minValue : min) * 100;
|
226
|
+
const maxInterval = this.getUnitInterval(value) * 100;
|
227
|
+
const mirror = this.shouldMirror();
|
228
|
+
const leftThumbOffset = `${mirror ? 100 - minInterval : minInterval}%`;
|
229
|
+
const rightThumbOffset = `${mirror ? maxInterval : 100 - maxInterval}%`;
|
230
|
+
const valueIsRange = isRange(this.value);
|
231
|
+
const handleLabelMinValueClasses = `${CSS.handleLabel} ${CSS.handleLabelMinValue}`;
|
232
|
+
const handleLabelValueClasses = `${CSS.handleLabel} ${CSS.handleLabelValue}`;
|
233
|
+
const handle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
|
234
|
+
thumb: true,
|
235
|
+
"thumb--value": true,
|
236
|
+
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
|
237
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: (event) => this.pointerDownDragStart(event, maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" })));
|
238
|
+
const labeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
|
239
|
+
thumb: true,
|
240
|
+
"thumb--value": true,
|
241
|
+
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
|
242
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: (event) => this.pointerDownDragStart(event, maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("span", { "aria-hidden": "true", class: handleLabelValueClasses }, displayedValue), h("span", { "aria-hidden": "true", class: `${handleLabelValueClasses} static` }, displayedValue), h("span", { "aria-hidden": "true", class: `${handleLabelValueClasses} transformed` }, displayedValue), h("div", { class: "handle" })));
|
243
|
+
const histogramLabeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
|
244
|
+
thumb: true,
|
245
|
+
"thumb--value": true,
|
246
|
+
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
|
247
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: (event) => this.pointerDownDragStart(event, maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" }), h("span", { "aria-hidden": "true", class: handleLabelValueClasses }, displayedValue), h("span", { "aria-hidden": "true", class: `${handleLabelValueClasses} static` }, displayedValue), h("span", { "aria-hidden": "true", class: `${handleLabelValueClasses} transformed` }, displayedValue)));
|
248
|
+
const preciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
|
249
|
+
thumb: true,
|
250
|
+
"thumb--value": true,
|
251
|
+
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
252
|
+
"thumb--precise": true
|
253
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: (event) => this.pointerDownDragStart(event, maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" }), h("div", { class: "handle-extension" })));
|
254
|
+
const histogramPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
|
255
|
+
thumb: true,
|
256
|
+
"thumb--value": true,
|
257
|
+
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
258
|
+
"thumb--precise": true
|
259
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: (event) => this.pointerDownDragStart(event, maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle-extension" }), h("div", { class: "handle" })));
|
260
|
+
const labeledPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
|
261
|
+
thumb: true,
|
262
|
+
"thumb--value": true,
|
263
|
+
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
264
|
+
"thumb--precise": true
|
265
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: (event) => this.pointerDownDragStart(event, maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("span", { "aria-hidden": "true", class: handleLabelValueClasses }, displayedValue), h("span", { "aria-hidden": "true", class: `${handleLabelValueClasses} static` }, displayedValue), h("span", { "aria-hidden": "true", class: `${handleLabelValueClasses} transformed` }, displayedValue), h("div", { class: "handle" }), h("div", { class: "handle-extension" })));
|
266
|
+
const histogramLabeledPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": valueIsRange ? this.maxLabel : this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": value, class: {
|
267
|
+
thumb: true,
|
268
|
+
"thumb--value": true,
|
269
|
+
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
270
|
+
"thumb--precise": true
|
271
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: (event) => this.pointerDownDragStart(event, maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle-extension" }), h("div", { class: "handle" }), h("span", { "aria-hidden": "true", class: handleLabelValueClasses }, displayedValue), h("span", { "aria-hidden": "true", class: `${handleLabelValueClasses} static` }, displayedValue), h("span", { "aria-hidden": "true", class: `${handleLabelValueClasses} transformed` }, displayedValue)));
|
272
|
+
const minHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
|
273
|
+
thumb: true,
|
274
|
+
"thumb--minValue": true,
|
275
|
+
"thumb--active": this.dragProp === "minValue"
|
276
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: (event) => this.pointerDownDragStart(event, "minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" })));
|
277
|
+
const minLabeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
|
278
|
+
thumb: true,
|
279
|
+
"thumb--minValue": true,
|
280
|
+
"thumb--active": this.dragProp === "minValue"
|
281
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: (event) => this.pointerDownDragStart(event, "minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("span", { "aria-hidden": "true", class: handleLabelMinValueClasses }, displayedMinValue), h("span", { "aria-hidden": "true", class: `${handleLabelMinValueClasses} static` }, displayedMinValue), h("span", { "aria-hidden": "true", class: `${handleLabelMinValueClasses} transformed` }, displayedMinValue), h("div", { class: "handle" })));
|
282
|
+
const minHistogramLabeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
|
283
|
+
thumb: true,
|
284
|
+
"thumb--minValue": true,
|
285
|
+
"thumb--active": this.dragProp === "minValue"
|
286
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: (event) => this.pointerDownDragStart(event, "minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" }), h("span", { "aria-hidden": "true", class: handleLabelMinValueClasses }, displayedMinValue), h("span", { "aria-hidden": "true", class: `${handleLabelMinValueClasses} static` }, displayedMinValue), h("span", { "aria-hidden": "true", class: `${handleLabelMinValueClasses} transformed` }, displayedMinValue)));
|
287
|
+
const minPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
|
288
|
+
thumb: true,
|
289
|
+
"thumb--minValue": true,
|
290
|
+
"thumb--active": this.dragProp === "minValue",
|
291
|
+
"thumb--precise": true
|
292
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: (event) => this.pointerDownDragStart(event, "minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("div", { class: "handle-extension" }), h("div", { class: "handle" })));
|
293
|
+
const minLabeledPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label": this.minLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": this.minValue, class: {
|
294
|
+
thumb: true,
|
295
|
+
"thumb--minValue": true,
|
296
|
+
"thumb--active": this.dragProp === "minValue",
|
297
|
+
"thumb--precise": true
|
298
|
+
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: (event) => this.pointerDownDragStart(event, "minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, h("div", { class: "handle-extension" }), h("div", { class: "handle" }), h("span", { "aria-hidden": "true", class: handleLabelMinValueClasses }, displayedMinValue), h("span", { "aria-hidden": "true", class: `${handleLabelMinValueClasses} static` }, displayedMinValue), h("span", { "aria-hidden": "true", class: `${handleLabelMinValueClasses} transformed` }, displayedMinValue)));
|
299
|
+
return (h(Host, { id: id, onTouchStart: this.handleTouchStart }, h("div", { class: {
|
300
|
+
["container"]: true,
|
301
|
+
["container--range"]: valueIsRange,
|
302
|
+
[`scale--${this.scale}`]: true
|
303
|
+
} }, this.renderGraph(), h("div", { class: "track", ref: this.storeTrackRef }, h("div", { class: "track__range", onPointerDown: (event) => this.pointerDownDragStart(event, "minMaxValue"), style: {
|
304
|
+
left: `${mirror ? 100 - maxInterval : minInterval}%`,
|
305
|
+
right: `${mirror ? minInterval : 100 - maxInterval}%`
|
306
|
+
} }), h("div", { class: "ticks" }, this.tickValues.map((tick) => {
|
307
|
+
const tickOffset = `${this.getUnitInterval(tick) * 100}%`;
|
308
|
+
let activeTicks = tick >= min && tick <= value;
|
309
|
+
if (useMinValue) {
|
310
|
+
activeTicks = tick >= this.minValue && tick <= this.maxValue;
|
311
|
+
}
|
312
|
+
return (h("span", { class: {
|
313
|
+
tick: true,
|
314
|
+
"tick--active": activeTicks
|
315
|
+
}, style: {
|
316
|
+
left: mirror ? "" : tickOffset,
|
317
|
+
right: mirror ? tickOffset : ""
|
318
|
+
} }, this.renderTickLabel(tick)));
|
319
|
+
}))), h("div", { class: "thumb-container" }, !this.precise && !this.labelHandles && valueIsRange && minHandle, !this.hasHistogram &&
|
320
|
+
!this.precise &&
|
321
|
+
this.labelHandles &&
|
322
|
+
valueIsRange &&
|
323
|
+
minLabeledHandle, this.precise && !this.labelHandles && valueIsRange && minPreciseHandle, this.precise && this.labelHandles && valueIsRange && minLabeledPreciseHandle, this.hasHistogram &&
|
324
|
+
!this.precise &&
|
325
|
+
this.labelHandles &&
|
326
|
+
valueIsRange &&
|
327
|
+
minHistogramLabeledHandle, !this.precise && !this.labelHandles && handle, !this.hasHistogram && !this.precise && this.labelHandles && labeledHandle, !this.hasHistogram && this.precise && !this.labelHandles && preciseHandle, this.hasHistogram && this.precise && !this.labelHandles && histogramPreciseHandle, !this.hasHistogram && this.precise && this.labelHandles && labeledPreciseHandle, this.hasHistogram && !this.precise && this.labelHandles && histogramLabeledHandle, this.hasHistogram &&
|
328
|
+
this.precise &&
|
329
|
+
this.labelHandles &&
|
330
|
+
histogramLabeledPreciseHandle, h(HiddenFormInputSlot, { component: this })))));
|
331
|
+
}
|
332
|
+
renderGraph() {
|
333
|
+
return this.histogram ? (h("calcite-graph", { class: "graph", colorStops: this.histogramStops, data: this.histogram, highlightMax: isRange(this.value) ? this.maxValue : this.value, highlightMin: isRange(this.value) ? this.minValue : this.min, max: this.max, min: this.min })) : null;
|
334
|
+
}
|
335
|
+
renderTickLabel(tick) {
|
336
|
+
const valueIsRange = isRange(this.value);
|
337
|
+
const isMinTickLabel = tick === this.min;
|
338
|
+
const isMaxTickLabel = tick === this.max;
|
339
|
+
const displayedTickValue = this.determineGroupSeparator(tick);
|
340
|
+
const tickLabel = (h("span", { class: {
|
341
|
+
tick__label: true,
|
342
|
+
[CSS.tickMin]: isMinTickLabel,
|
343
|
+
[CSS.tickMax]: isMaxTickLabel
|
344
|
+
} }, displayedTickValue));
|
345
|
+
if (this.labelTicks && !this.hasHistogram && !valueIsRange) {
|
346
|
+
return tickLabel;
|
347
|
+
}
|
348
|
+
if (this.labelTicks &&
|
349
|
+
!this.hasHistogram &&
|
350
|
+
valueIsRange &&
|
351
|
+
!this.precise &&
|
352
|
+
!this.labelHandles) {
|
353
|
+
return tickLabel;
|
354
|
+
}
|
355
|
+
if (this.labelTicks &&
|
356
|
+
!this.hasHistogram &&
|
357
|
+
valueIsRange &&
|
358
|
+
!this.precise &&
|
359
|
+
this.labelHandles) {
|
360
|
+
return tickLabel;
|
361
|
+
}
|
362
|
+
if (this.labelTicks &&
|
363
|
+
!this.hasHistogram &&
|
364
|
+
valueIsRange &&
|
365
|
+
this.precise &&
|
366
|
+
(isMinTickLabel || isMaxTickLabel)) {
|
367
|
+
return tickLabel;
|
368
|
+
}
|
369
|
+
if (this.labelTicks && this.hasHistogram && !this.precise && !this.labelHandles) {
|
370
|
+
return tickLabel;
|
371
|
+
}
|
372
|
+
if (this.labelTicks &&
|
373
|
+
this.hasHistogram &&
|
374
|
+
this.precise &&
|
375
|
+
!this.labelHandles &&
|
376
|
+
(isMinTickLabel || isMaxTickLabel)) {
|
377
|
+
return tickLabel;
|
378
|
+
}
|
379
|
+
if (this.labelTicks &&
|
380
|
+
this.hasHistogram &&
|
381
|
+
!this.precise &&
|
382
|
+
this.labelHandles &&
|
383
|
+
(isMinTickLabel || isMaxTickLabel)) {
|
384
|
+
return tickLabel;
|
385
|
+
}
|
386
|
+
if (this.labelTicks &&
|
387
|
+
this.hasHistogram &&
|
388
|
+
this.precise &&
|
389
|
+
this.labelHandles &&
|
390
|
+
(isMinTickLabel || isMaxTickLabel)) {
|
391
|
+
return tickLabel;
|
392
|
+
}
|
393
|
+
return null;
|
394
|
+
}
|
395
|
+
//--------------------------------------------------------------------------
|
396
|
+
//
|
397
|
+
// Event Listeners
|
398
|
+
//
|
399
|
+
//--------------------------------------------------------------------------
|
400
|
+
keyDownHandler(event) {
|
401
|
+
const mirror = this.shouldMirror();
|
402
|
+
const { activeProp, max, min, pageStep, step } = this;
|
403
|
+
const value = this[activeProp];
|
404
|
+
const { key } = event;
|
405
|
+
if (isActivationKey(key)) {
|
406
|
+
event.preventDefault();
|
407
|
+
return;
|
408
|
+
}
|
409
|
+
let adjustment;
|
410
|
+
if (key === "ArrowUp" || key === "ArrowRight") {
|
411
|
+
const directionFactor = mirror && key === "ArrowRight" ? -1 : 1;
|
412
|
+
adjustment = value + step * directionFactor;
|
413
|
+
}
|
414
|
+
else if (key === "ArrowDown" || key === "ArrowLeft") {
|
415
|
+
const directionFactor = mirror && key === "ArrowLeft" ? -1 : 1;
|
416
|
+
adjustment = value - step * directionFactor;
|
417
|
+
}
|
418
|
+
else if (key === "PageUp") {
|
419
|
+
if (pageStep) {
|
420
|
+
adjustment = value + pageStep;
|
421
|
+
}
|
422
|
+
}
|
423
|
+
else if (key === "PageDown") {
|
424
|
+
if (pageStep) {
|
425
|
+
adjustment = value - pageStep;
|
426
|
+
}
|
427
|
+
}
|
428
|
+
else if (key === "Home") {
|
429
|
+
adjustment = min;
|
430
|
+
}
|
431
|
+
else if (key === "End") {
|
432
|
+
adjustment = max;
|
433
|
+
}
|
434
|
+
if (isNaN(adjustment)) {
|
435
|
+
return;
|
436
|
+
}
|
437
|
+
event.preventDefault();
|
438
|
+
const fixedDecimalAdjustment = Number(adjustment.toFixed(decimalPlaces(step)));
|
439
|
+
this.setValue({
|
440
|
+
[activeProp]: this.clamp(fixedDecimalAdjustment, activeProp)
|
441
|
+
});
|
442
|
+
}
|
443
|
+
pointerDownHandler(event) {
|
444
|
+
if (!isPrimaryPointerButton(event)) {
|
445
|
+
return;
|
446
|
+
}
|
447
|
+
const x = event.clientX || event.pageX;
|
448
|
+
const position = this.translate(x);
|
449
|
+
let prop = "value";
|
450
|
+
if (isRange(this.value)) {
|
451
|
+
const inRange = position >= this.minValue && position <= this.maxValue;
|
452
|
+
if (inRange && this.lastDragProp === "minMaxValue") {
|
453
|
+
prop = "minMaxValue";
|
454
|
+
}
|
455
|
+
else {
|
456
|
+
const closerToMax = Math.abs(this.maxValue - position) < Math.abs(this.minValue - position);
|
457
|
+
prop = closerToMax || position > this.maxValue ? "maxValue" : "minValue";
|
458
|
+
}
|
459
|
+
}
|
460
|
+
this.lastDragPropValue = this[prop];
|
461
|
+
this.dragStart(prop);
|
462
|
+
const isThumbActive = this.el.shadowRoot.querySelector(".thumb:active");
|
463
|
+
if (!isThumbActive) {
|
464
|
+
this.setValue({ [prop]: this.clamp(position, prop) });
|
465
|
+
}
|
466
|
+
this.focusActiveHandle(x);
|
467
|
+
}
|
468
|
+
handleTouchStart(event) {
|
469
|
+
// needed to prevent extra click at the end of a handle drag
|
470
|
+
event.preventDefault();
|
471
|
+
}
|
472
|
+
//--------------------------------------------------------------------------
|
473
|
+
//
|
474
|
+
// Public Methods
|
475
|
+
//
|
476
|
+
//--------------------------------------------------------------------------
|
477
|
+
/** Sets focus on the component. */
|
478
|
+
async setFocus() {
|
479
|
+
const handle = this.minHandle ? this.minHandle : this.maxHandle;
|
480
|
+
handle === null || handle === void 0 ? void 0 : handle.focus();
|
481
|
+
}
|
482
|
+
//--------------------------------------------------------------------------
|
483
|
+
//
|
484
|
+
// Private Methods
|
485
|
+
//
|
486
|
+
//--------------------------------------------------------------------------
|
487
|
+
setValueFromMinMax() {
|
488
|
+
const { minValue, maxValue } = this;
|
489
|
+
if (typeof minValue === "number" && typeof maxValue === "number") {
|
490
|
+
this.value = [minValue, maxValue];
|
491
|
+
}
|
492
|
+
}
|
493
|
+
setMinMaxFromValue() {
|
494
|
+
const { value } = this;
|
495
|
+
if (isRange(value)) {
|
496
|
+
this.minValue = value[0];
|
497
|
+
this.maxValue = value[1];
|
498
|
+
}
|
499
|
+
}
|
500
|
+
onLabelClick() {
|
501
|
+
this.setFocus();
|
502
|
+
}
|
503
|
+
shouldMirror() {
|
504
|
+
return this.mirrored && !this.hasHistogram;
|
505
|
+
}
|
506
|
+
shouldUseMinValue() {
|
507
|
+
if (!isRange(this.value)) {
|
508
|
+
return false;
|
509
|
+
}
|
510
|
+
return ((this.hasHistogram && this.maxValue === 0) || (!this.hasHistogram && this.minValue === 0));
|
511
|
+
}
|
512
|
+
generateTickValues() {
|
513
|
+
const ticks = [];
|
514
|
+
let current = this.min;
|
515
|
+
while (this.ticks && current < this.max + this.ticks) {
|
516
|
+
ticks.push(Math.min(current, this.max));
|
517
|
+
current = current + this.ticks;
|
518
|
+
}
|
519
|
+
return ticks;
|
520
|
+
}
|
521
|
+
pointerDownDragStart(event, prop) {
|
522
|
+
if (!isPrimaryPointerButton(event)) {
|
523
|
+
return;
|
524
|
+
}
|
525
|
+
this.dragStart(prop);
|
526
|
+
}
|
527
|
+
dragStart(prop) {
|
528
|
+
this.dragProp = prop;
|
529
|
+
this.lastDragProp = this.dragProp;
|
530
|
+
this.activeProp = prop;
|
531
|
+
document.addEventListener("pointermove", this.dragUpdate);
|
532
|
+
document.addEventListener("pointerup", this.pointerUpDragEnd);
|
533
|
+
document.addEventListener("pointercancel", this.dragEnd);
|
534
|
+
}
|
535
|
+
focusActiveHandle(valueX) {
|
536
|
+
switch (this.dragProp) {
|
537
|
+
case "minValue":
|
538
|
+
this.minHandle.focus();
|
539
|
+
break;
|
540
|
+
case "maxValue":
|
541
|
+
case "value":
|
542
|
+
this.maxHandle.focus();
|
543
|
+
break;
|
544
|
+
case "minMaxValue":
|
545
|
+
this.getClosestHandle(valueX).focus();
|
546
|
+
break;
|
547
|
+
}
|
548
|
+
}
|
549
|
+
emitInput() {
|
550
|
+
this.calciteSliderInput.emit();
|
551
|
+
this.calciteSliderUpdate.emit();
|
552
|
+
}
|
553
|
+
emitChange() {
|
554
|
+
this.calciteSliderChange.emit();
|
555
|
+
}
|
556
|
+
removeDragListeners() {
|
557
|
+
document.removeEventListener("pointermove", this.dragUpdate);
|
558
|
+
document.removeEventListener("pointerup", this.pointerUpDragEnd);
|
559
|
+
document.removeEventListener("pointercancel", this.dragEnd);
|
560
|
+
}
|
561
|
+
/**
|
562
|
+
* Set prop value(s) if changed at the component level
|
563
|
+
*
|
564
|
+
* @param {object} values - a set of key/value pairs delineating what properties in the component to update
|
565
|
+
*/
|
566
|
+
setValue(values) {
|
567
|
+
let valueChanged;
|
568
|
+
Object.keys(values).forEach((propName) => {
|
569
|
+
const newValue = values[propName];
|
570
|
+
if (!valueChanged) {
|
571
|
+
const oldValue = this[propName];
|
572
|
+
valueChanged = oldValue !== newValue;
|
573
|
+
}
|
574
|
+
this[propName] = newValue;
|
575
|
+
});
|
576
|
+
if (!valueChanged) {
|
577
|
+
return;
|
578
|
+
}
|
579
|
+
const dragging = this.dragProp;
|
580
|
+
if (!dragging) {
|
581
|
+
this.emitChange();
|
582
|
+
}
|
583
|
+
this.emitInput();
|
584
|
+
}
|
585
|
+
/**
|
586
|
+
* If number is outside range, constrain to min or max
|
587
|
+
*
|
588
|
+
* @param value
|
589
|
+
* @param prop
|
590
|
+
* @internal
|
591
|
+
*/
|
592
|
+
clamp(value, prop) {
|
593
|
+
value = clamp(value, this.min, this.max);
|
594
|
+
// ensure that maxValue and minValue don't swap positions
|
595
|
+
if (prop === "maxValue") {
|
596
|
+
value = Math.max(value, this.minValue);
|
597
|
+
}
|
598
|
+
if (prop === "minValue") {
|
599
|
+
value = Math.min(value, this.maxValue);
|
600
|
+
}
|
601
|
+
return value;
|
602
|
+
}
|
603
|
+
/**
|
604
|
+
* Translate a pixel position to value along the range
|
605
|
+
*
|
606
|
+
* @param x
|
607
|
+
* @internal
|
608
|
+
*/
|
609
|
+
translate(x) {
|
610
|
+
const range = this.max - this.min;
|
611
|
+
const { left, width } = this.trackEl.getBoundingClientRect();
|
612
|
+
const percent = (x - left) / width;
|
613
|
+
const mirror = this.shouldMirror();
|
614
|
+
const clampedValue = this.clamp(this.min + range * (mirror ? 1 - percent : percent));
|
615
|
+
let value = Number(clampedValue.toFixed(decimalPlaces(this.step)));
|
616
|
+
if (this.snap && this.step) {
|
617
|
+
value = this.getClosestStep(value);
|
618
|
+
}
|
619
|
+
return value;
|
620
|
+
}
|
621
|
+
/**
|
622
|
+
* Get closest allowed value along stepped values
|
623
|
+
*
|
624
|
+
* @param num
|
625
|
+
* @internal
|
626
|
+
*/
|
627
|
+
getClosestStep(num) {
|
628
|
+
num = Number(this.clamp(num).toFixed(decimalPlaces(this.step)));
|
629
|
+
if (this.step) {
|
630
|
+
const step = Math.round(num / this.step) * this.step;
|
631
|
+
num = Number(this.clamp(step).toFixed(decimalPlaces(this.step)));
|
632
|
+
}
|
633
|
+
return num;
|
634
|
+
}
|
635
|
+
getClosestHandle(valueX) {
|
636
|
+
return this.getDistanceX(this.maxHandle, valueX) > this.getDistanceX(this.minHandle, valueX)
|
637
|
+
? this.minHandle
|
638
|
+
: this.maxHandle;
|
639
|
+
}
|
640
|
+
getDistanceX(el, valueX) {
|
641
|
+
return Math.abs(el.getBoundingClientRect().left - valueX);
|
642
|
+
}
|
643
|
+
getFontSizeForElement(element) {
|
644
|
+
return Number(window.getComputedStyle(element).getPropertyValue("font-size").match(/\d+/)[0]);
|
645
|
+
}
|
646
|
+
/**
|
647
|
+
* Get position of value along range as fractional value
|
648
|
+
*
|
649
|
+
* @param num
|
650
|
+
* @return {number} number in the unit interval [0,1]
|
651
|
+
* @internal
|
652
|
+
*/
|
653
|
+
getUnitInterval(num) {
|
654
|
+
num = this.clamp(num);
|
655
|
+
const range = this.max - this.min;
|
656
|
+
return (num - this.min) / range;
|
657
|
+
}
|
658
|
+
adjustHostObscuredHandleLabel(name) {
|
659
|
+
const label = this.el.shadowRoot.querySelector(`.handle__label--${name}`);
|
660
|
+
const labelStatic = this.el.shadowRoot.querySelector(`.handle__label--${name}.static`);
|
661
|
+
const labelTransformed = this.el.shadowRoot.querySelector(`.handle__label--${name}.transformed`);
|
662
|
+
const labelStaticBounds = labelStatic.getBoundingClientRect();
|
663
|
+
const labelStaticOffset = this.getHostOffset(labelStaticBounds.left, labelStaticBounds.right);
|
664
|
+
label.style.transform = `translateX(${labelStaticOffset}px)`;
|
665
|
+
labelTransformed.style.transform = `translateX(${labelStaticOffset}px)`;
|
666
|
+
}
|
667
|
+
hyphenateCollidingRangeHandleLabels() {
|
668
|
+
const { shadowRoot } = this.el;
|
669
|
+
const mirror = this.shouldMirror();
|
670
|
+
const leftModifier = mirror ? "value" : "minValue";
|
671
|
+
const rightModifier = mirror ? "minValue" : "value";
|
672
|
+
const leftValueLabel = shadowRoot.querySelector(`.handle__label--${leftModifier}`);
|
673
|
+
const leftValueLabelStatic = shadowRoot.querySelector(`.handle__label--${leftModifier}.static`);
|
674
|
+
const leftValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${leftModifier}.transformed`);
|
675
|
+
const leftValueLabelStaticHostOffset = this.getHostOffset(leftValueLabelStatic.getBoundingClientRect().left, leftValueLabelStatic.getBoundingClientRect().right);
|
676
|
+
const rightValueLabel = shadowRoot.querySelector(`.handle__label--${rightModifier}`);
|
677
|
+
const rightValueLabelStatic = shadowRoot.querySelector(`.handle__label--${rightModifier}.static`);
|
678
|
+
const rightValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${rightModifier}.transformed`);
|
679
|
+
const rightValueLabelStaticHostOffset = this.getHostOffset(rightValueLabelStatic.getBoundingClientRect().left, rightValueLabelStatic.getBoundingClientRect().right);
|
680
|
+
const labelFontSize = this.getFontSizeForElement(leftValueLabel);
|
681
|
+
const labelTransformedOverlap = this.getRangeLabelOverlap(leftValueLabelTransformed, rightValueLabelTransformed);
|
682
|
+
const hyphenLabel = leftValueLabel;
|
683
|
+
const labelOffset = labelFontSize / 2;
|
684
|
+
if (labelTransformedOverlap > 0) {
|
685
|
+
hyphenLabel.classList.add("hyphen", "hyphen--wrap");
|
686
|
+
if (rightValueLabelStaticHostOffset === 0 && leftValueLabelStaticHostOffset === 0) {
|
687
|
+
// Neither handle overlaps the host boundary
|
688
|
+
let leftValueLabelTranslate = labelTransformedOverlap / 2 - labelOffset;
|
689
|
+
leftValueLabelTranslate =
|
690
|
+
Math.sign(leftValueLabelTranslate) === -1
|
691
|
+
? Math.abs(leftValueLabelTranslate)
|
692
|
+
: -leftValueLabelTranslate;
|
693
|
+
const leftValueLabelTransformedHostOffset = this.getHostOffset(leftValueLabelTransformed.getBoundingClientRect().left +
|
694
|
+
leftValueLabelTranslate -
|
695
|
+
labelOffset, leftValueLabelTransformed.getBoundingClientRect().right +
|
696
|
+
leftValueLabelTranslate -
|
697
|
+
labelOffset);
|
698
|
+
let rightValueLabelTranslate = labelTransformedOverlap / 2;
|
699
|
+
const rightValueLabelTransformedHostOffset = this.getHostOffset(rightValueLabelTransformed.getBoundingClientRect().left + rightValueLabelTranslate, rightValueLabelTransformed.getBoundingClientRect().right + rightValueLabelTranslate);
|
700
|
+
if (leftValueLabelTransformedHostOffset !== 0) {
|
701
|
+
leftValueLabelTranslate += leftValueLabelTransformedHostOffset;
|
702
|
+
rightValueLabelTranslate += leftValueLabelTransformedHostOffset;
|
703
|
+
}
|
704
|
+
if (rightValueLabelTransformedHostOffset !== 0) {
|
705
|
+
leftValueLabelTranslate += rightValueLabelTransformedHostOffset;
|
706
|
+
rightValueLabelTranslate += rightValueLabelTransformedHostOffset;
|
707
|
+
}
|
708
|
+
leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
|
709
|
+
leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
|
710
|
+
rightValueLabel.style.transform = `translateX(${rightValueLabelTranslate}px)`;
|
711
|
+
rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelTranslate}px)`;
|
712
|
+
}
|
713
|
+
else if (leftValueLabelStaticHostOffset > 0 || rightValueLabelStaticHostOffset > 0) {
|
714
|
+
// labels overlap host boundary on the left side
|
715
|
+
leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset + labelOffset}px)`;
|
716
|
+
rightValueLabel.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
|
717
|
+
rightValueLabelTransformed.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
|
718
|
+
}
|
719
|
+
else if (leftValueLabelStaticHostOffset < 0 || rightValueLabelStaticHostOffset < 0) {
|
720
|
+
// labels overlap host boundary on the right side
|
721
|
+
let leftValueLabelTranslate = Math.abs(leftValueLabelStaticHostOffset) + labelTransformedOverlap - labelOffset;
|
722
|
+
leftValueLabelTranslate =
|
723
|
+
Math.sign(leftValueLabelTranslate) === -1
|
724
|
+
? Math.abs(leftValueLabelTranslate)
|
725
|
+
: -leftValueLabelTranslate;
|
726
|
+
leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
|
727
|
+
leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
|
728
|
+
}
|
729
|
+
}
|
730
|
+
else {
|
731
|
+
hyphenLabel.classList.remove("hyphen", "hyphen--wrap");
|
732
|
+
leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
|
733
|
+
leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
|
734
|
+
rightValueLabel.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
|
735
|
+
rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
|
736
|
+
}
|
737
|
+
}
|
738
|
+
/**
|
739
|
+
* Hides bounding tick labels that are obscured by either handle.
|
740
|
+
*/
|
741
|
+
hideObscuredBoundingTickLabels() {
|
742
|
+
const valueIsRange = isRange(this.value);
|
743
|
+
if (!this.hasHistogram && !valueIsRange && !this.labelHandles && !this.precise) {
|
744
|
+
return;
|
745
|
+
}
|
746
|
+
if (!this.hasHistogram && !valueIsRange && this.labelHandles && !this.precise) {
|
747
|
+
return;
|
748
|
+
}
|
749
|
+
if (!this.hasHistogram && !valueIsRange && !this.labelHandles && this.precise) {
|
750
|
+
return;
|
751
|
+
}
|
752
|
+
if (!this.hasHistogram && !valueIsRange && this.labelHandles && this.precise) {
|
753
|
+
return;
|
754
|
+
}
|
755
|
+
if (!this.hasHistogram && valueIsRange && !this.precise) {
|
756
|
+
return;
|
757
|
+
}
|
758
|
+
if (this.hasHistogram && !this.precise && !this.labelHandles) {
|
759
|
+
return;
|
760
|
+
}
|
761
|
+
const minHandle = this.el.shadowRoot.querySelector(".thumb--minValue");
|
762
|
+
const maxHandle = this.el.shadowRoot.querySelector(".thumb--value");
|
763
|
+
const minTickLabel = this.el.shadowRoot.querySelector(".tick__label--min");
|
764
|
+
const maxTickLabel = this.el.shadowRoot.querySelector(".tick__label--max");
|
765
|
+
if (!minHandle && maxHandle && minTickLabel && maxTickLabel) {
|
766
|
+
minTickLabel.style.opacity = this.isMinTickLabelObscured(minTickLabel, maxHandle) ? "0" : "1";
|
767
|
+
maxTickLabel.style.opacity = this.isMaxTickLabelObscured(maxTickLabel, maxHandle) ? "0" : "1";
|
768
|
+
}
|
769
|
+
if (minHandle && maxHandle && minTickLabel && maxTickLabel) {
|
770
|
+
minTickLabel.style.opacity =
|
771
|
+
this.isMinTickLabelObscured(minTickLabel, minHandle) ||
|
772
|
+
this.isMinTickLabelObscured(minTickLabel, maxHandle)
|
773
|
+
? "0"
|
774
|
+
: "1";
|
775
|
+
maxTickLabel.style.opacity =
|
776
|
+
this.isMaxTickLabelObscured(maxTickLabel, minHandle) ||
|
777
|
+
(this.isMaxTickLabelObscured(maxTickLabel, maxHandle) && this.hasHistogram)
|
778
|
+
? "0"
|
779
|
+
: "1";
|
780
|
+
}
|
781
|
+
}
|
782
|
+
/**
|
783
|
+
* Returns an integer representing the number of pixels to offset on the left or right side based on desired position behavior.
|
784
|
+
*
|
785
|
+
* @param leftBounds
|
786
|
+
* @param rightBounds
|
787
|
+
* @internal
|
788
|
+
*/
|
789
|
+
getHostOffset(leftBounds, rightBounds) {
|
790
|
+
const hostBounds = this.el.getBoundingClientRect();
|
791
|
+
const buffer = 7;
|
792
|
+
if (leftBounds + buffer < hostBounds.left) {
|
793
|
+
return hostBounds.left - leftBounds - buffer;
|
794
|
+
}
|
795
|
+
if (rightBounds - buffer > hostBounds.right) {
|
796
|
+
return -(rightBounds - hostBounds.right) + buffer;
|
797
|
+
}
|
798
|
+
return 0;
|
799
|
+
}
|
800
|
+
/**
|
801
|
+
* Returns an integer representing the number of pixels that the two given span elements are overlapping, taking into account
|
802
|
+
* a space in between the two spans equal to the font-size set on them to account for the space needed to render a hyphen.
|
803
|
+
*
|
804
|
+
* @param leftLabel
|
805
|
+
* @param rightLabel
|
806
|
+
*/
|
807
|
+
getRangeLabelOverlap(leftLabel, rightLabel) {
|
808
|
+
const leftLabelBounds = leftLabel.getBoundingClientRect();
|
809
|
+
const rightLabelBounds = rightLabel.getBoundingClientRect();
|
810
|
+
const leftLabelFontSize = this.getFontSizeForElement(leftLabel);
|
811
|
+
const rangeLabelOverlap = leftLabelBounds.right + leftLabelFontSize - rightLabelBounds.left;
|
812
|
+
return Math.max(rangeLabelOverlap, 0);
|
813
|
+
}
|
814
|
+
/**
|
815
|
+
* Returns a boolean value representing if the minLabel span element is obscured (being overlapped) by the given handle div element.
|
816
|
+
*
|
817
|
+
* @param minLabel
|
818
|
+
* @param handle
|
819
|
+
*/
|
820
|
+
isMinTickLabelObscured(minLabel, handle) {
|
821
|
+
const minLabelBounds = minLabel.getBoundingClientRect();
|
822
|
+
const handleBounds = handle.getBoundingClientRect();
|
823
|
+
return intersects(minLabelBounds, handleBounds);
|
824
|
+
}
|
825
|
+
/**
|
826
|
+
* Returns a boolean value representing if the maxLabel span element is obscured (being overlapped) by the given handle div element.
|
827
|
+
*
|
828
|
+
* @param maxLabel
|
829
|
+
* @param handle
|
830
|
+
*/
|
831
|
+
isMaxTickLabelObscured(maxLabel, handle) {
|
832
|
+
const maxLabelBounds = maxLabel.getBoundingClientRect();
|
833
|
+
const handleBounds = handle.getBoundingClientRect();
|
834
|
+
return intersects(maxLabelBounds, handleBounds);
|
835
|
+
}
|
836
|
+
get el() { return this; }
|
837
|
+
static get watchers() { return {
|
838
|
+
"histogram": ["histogramWatcher"],
|
839
|
+
"value": ["valueHandler"],
|
840
|
+
"minValue": ["minMaxValueHandler"],
|
841
|
+
"maxValue": ["minMaxValueHandler"]
|
842
|
+
}; }
|
843
|
+
static get style() { return sliderCss; }
|
844
|
+
}, [1, "calcite-slider", {
|
845
|
+
"disabled": [516],
|
846
|
+
"groupSeparator": [516, "group-separator"],
|
847
|
+
"hasHistogram": [1540, "has-histogram"],
|
848
|
+
"histogram": [16],
|
849
|
+
"histogramStops": [16],
|
850
|
+
"labelHandles": [516, "label-handles"],
|
851
|
+
"labelTicks": [516, "label-ticks"],
|
852
|
+
"max": [514],
|
853
|
+
"maxLabel": [1, "max-label"],
|
854
|
+
"maxValue": [1026, "max-value"],
|
855
|
+
"min": [514],
|
856
|
+
"minLabel": [1, "min-label"],
|
857
|
+
"minValue": [1026, "min-value"],
|
858
|
+
"mirrored": [516],
|
859
|
+
"name": [513],
|
860
|
+
"numberingSystem": [1, "numbering-system"],
|
861
|
+
"pageStep": [514, "page-step"],
|
862
|
+
"precise": [516],
|
863
|
+
"required": [516],
|
864
|
+
"snap": [516],
|
865
|
+
"step": [514],
|
866
|
+
"ticks": [514],
|
867
|
+
"value": [1538],
|
868
|
+
"scale": [513],
|
869
|
+
"effectiveLocale": [32],
|
870
|
+
"minMaxValueRange": [32],
|
871
|
+
"minValueDragRange": [32],
|
872
|
+
"maxValueDragRange": [32],
|
873
|
+
"tickValues": [32],
|
874
|
+
"setFocus": [64]
|
875
|
+
}, [[0, "keydown", "keyDownHandler"], [1, "pointerdown", "pointerDownHandler"]]]);
|
876
|
+
function defineCustomElement() {
|
877
|
+
if (typeof customElements === "undefined") {
|
878
|
+
return;
|
879
|
+
}
|
880
|
+
const components = ["calcite-slider", "calcite-graph"];
|
881
|
+
components.forEach(tagName => { switch (tagName) {
|
882
|
+
case "calcite-slider":
|
883
|
+
if (!customElements.get(tagName)) {
|
884
|
+
customElements.define(tagName, Slider);
|
885
|
+
}
|
886
|
+
break;
|
887
|
+
case "calcite-graph":
|
888
|
+
if (!customElements.get(tagName)) {
|
889
|
+
defineCustomElement$1();
|
890
|
+
}
|
891
|
+
break;
|
892
|
+
} });
|
893
|
+
}
|
894
|
+
defineCustomElement();
|
895
|
+
|
896
|
+
export { Slider as S, defineCustomElement as d };
|