@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,224 @@
|
|
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, Fragment } from '@stencil/core/internal/client';
|
7
|
+
import { e as getOrder, b as dateFromRange, n as nextMonth, f as prevMonth } from './date.js';
|
8
|
+
import { H as Heading } from './Heading.js';
|
9
|
+
import { i as isActivationKey } from './key.js';
|
10
|
+
import { n as numberStringFormatter } from './locale2.js';
|
11
|
+
import { h as closestElementCrossShadowBoundary } from './dom.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 BUDDHIST_CALENDAR_YEAR_OFFSET = 543;
|
20
|
+
|
21
|
+
const datePickerMonthHeaderCss = "@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}.header{display:flex;justify-content:space-between;padding-block:0px;padding-inline:0.25rem}:host([scale=s]) .text{margin-block:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem}:host([scale=s]) .chevron{block-size:2.25rem}:host([scale=m]) .text{margin-block:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem}:host([scale=m]) .chevron{block-size:3rem}:host([scale=l]) .text{margin-block:1rem;font-size:var(--calcite-font-size-1);line-height:1.5rem}:host([scale=l]) .chevron{block-size:3.5rem}.chevron{margin-inline:-0.25rem;box-sizing:content-box;display:flex;flex-grow:0;cursor:pointer;align-items:center;justify-content:center;border-style:none;background-color:var(--calcite-ui-foreground-1);padding-inline:0.25rem;color:var(--calcite-ui-text-3);outline:2px solid transparent;outline-offset:2px;outline-color:transparent;transition:all var(--calcite-animation-timing) ease-in-out 0s, outline 0s, outline-offset 0s;inline-size:14.2857142857%}.chevron:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.chevron:hover,.chevron:focus{background-color:var(--calcite-ui-foreground-2);fill:var(--calcite-ui-text-1);color:var(--calcite-ui-text-1)}.chevron:active{background-color:var(--calcite-ui-foreground-3)}.chevron[aria-disabled=true]{pointer-events:none;opacity:0}.text{margin-block:auto;display:flex;inline-size:100%;flex:1 1 auto;align-items:center;justify-content:center;text-align:center;line-height:1}.text--reverse{flex-direction:row-reverse}.month,.year,.suffix{margin-inline:0.25rem;margin-block:auto;display:inline-block;background-color:var(--calcite-ui-foreground-1);font-weight:var(--calcite-font-weight-medium);line-height:1.25;color:var(--calcite-ui-text-1);font-size:inherit}.year{position:relative;inline-size:2.5rem;border-style:none;background-color:transparent;text-align:center;font-family:inherit;outline-color:transparent}.year:hover{transition-duration:100ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-property:outline-color;outline:2px solid var(--calcite-ui-border-2);outline-offset:2px}.year:focus{outline:2px solid var(--calcite-ui-brand);outline-offset:2px}.year--suffix{text-align:start}.year-wrap{position:relative}.suffix{inset-block-start:0px;white-space:nowrap;text-align:start;inset-inline-start:0}";
|
22
|
+
|
23
|
+
const DatePickerMonthHeader = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
24
|
+
constructor() {
|
25
|
+
super();
|
26
|
+
this.__registerHost();
|
27
|
+
this.__attachShadow();
|
28
|
+
this.calciteDatePickerSelect = createEvent(this, "calciteDatePickerSelect", 6);
|
29
|
+
//--------------------------------------------------------------------------
|
30
|
+
//
|
31
|
+
// Private State/Props
|
32
|
+
//
|
33
|
+
//--------------------------------------------------------------------------
|
34
|
+
this.globalAttributes = {};
|
35
|
+
//--------------------------------------------------------------------------
|
36
|
+
//
|
37
|
+
// Private Methods
|
38
|
+
//
|
39
|
+
//--------------------------------------------------------------------------
|
40
|
+
/**
|
41
|
+
* Increment year on UP/DOWN keys
|
42
|
+
*
|
43
|
+
* @param event
|
44
|
+
*/
|
45
|
+
this.onYearKey = (event) => {
|
46
|
+
const localizedYear = this.parseCalendarYear(event.target.value);
|
47
|
+
switch (event.key) {
|
48
|
+
case "ArrowDown":
|
49
|
+
event.preventDefault();
|
50
|
+
this.setYear({ localizedYear, offset: -1 });
|
51
|
+
break;
|
52
|
+
case "ArrowUp":
|
53
|
+
event.preventDefault();
|
54
|
+
this.setYear({ localizedYear, offset: 1 });
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
};
|
58
|
+
this.onYearChange = (event) => {
|
59
|
+
this.setYear({
|
60
|
+
localizedYear: this.parseCalendarYear(event.target.value)
|
61
|
+
});
|
62
|
+
};
|
63
|
+
this.onYearInput = (event) => {
|
64
|
+
this.setYear({
|
65
|
+
localizedYear: this.parseCalendarYear(event.target.value),
|
66
|
+
commit: false
|
67
|
+
});
|
68
|
+
};
|
69
|
+
this.prevMonthClick = (event) => {
|
70
|
+
this.handleArrowClick(event, this.prevMonthDate);
|
71
|
+
};
|
72
|
+
this.prevMonthKeydown = (event) => {
|
73
|
+
if (isActivationKey(event.key)) {
|
74
|
+
this.prevMonthClick(event);
|
75
|
+
}
|
76
|
+
};
|
77
|
+
this.nextMonthClick = (event) => {
|
78
|
+
this.handleArrowClick(event, this.nextMonthDate);
|
79
|
+
};
|
80
|
+
this.nextMonthKeydown = (event) => {
|
81
|
+
if (isActivationKey(event.key)) {
|
82
|
+
this.nextMonthClick(event);
|
83
|
+
}
|
84
|
+
};
|
85
|
+
/*
|
86
|
+
* Update active month on clicks of left/right arrows
|
87
|
+
*/
|
88
|
+
this.handleArrowClick = (event, date) => {
|
89
|
+
event.preventDefault();
|
90
|
+
this.calciteDatePickerSelect.emit(date);
|
91
|
+
};
|
92
|
+
}
|
93
|
+
//--------------------------------------------------------------------------
|
94
|
+
//
|
95
|
+
// Lifecycle
|
96
|
+
//
|
97
|
+
//--------------------------------------------------------------------------
|
98
|
+
componentWillLoad() {
|
99
|
+
this.parentDatePickerEl = closestElementCrossShadowBoundary(this.el, "calcite-date-picker");
|
100
|
+
}
|
101
|
+
connectedCallback() {
|
102
|
+
this.setNextPrevMonthDates();
|
103
|
+
}
|
104
|
+
render() {
|
105
|
+
return h("div", { class: "header" }, this.renderContent());
|
106
|
+
}
|
107
|
+
renderContent() {
|
108
|
+
var _a;
|
109
|
+
if (!this.activeDate || !this.localeData) {
|
110
|
+
return null;
|
111
|
+
}
|
112
|
+
if (this.parentDatePickerEl) {
|
113
|
+
const { numberingSystem, lang: locale } = this.parentDatePickerEl;
|
114
|
+
numberStringFormatter.numberFormatOptions = Object.assign(Object.assign({ useGrouping: false }, (numberingSystem && { numberingSystem })), (locale && { locale }));
|
115
|
+
}
|
116
|
+
const activeMonth = this.activeDate.getMonth();
|
117
|
+
const { months, unitOrder } = this.localeData;
|
118
|
+
const localizedMonth = (months.wide || months.narrow || months.abbreviated)[activeMonth];
|
119
|
+
const localizedYear = this.formatCalendarYear(this.activeDate.getFullYear());
|
120
|
+
const iconScale = this.scale === "l" ? "m" : "s";
|
121
|
+
const order = getOrder(unitOrder);
|
122
|
+
const reverse = order.indexOf("y") < order.indexOf("m");
|
123
|
+
const suffix = (_a = this.localeData.year) === null || _a === void 0 ? void 0 : _a.suffix;
|
124
|
+
return (h(Fragment, null, h("a", { "aria-disabled": `${this.prevMonthDate.getMonth() === activeMonth}`, "aria-label": this.intlPrevMonth, class: "chevron", href: "#", onClick: this.prevMonthClick, onKeyDown: this.prevMonthKeydown, role: "button", tabindex: this.prevMonthDate.getMonth() === activeMonth ? -1 : 0 }, h("calcite-icon", { "flip-rtl": true, icon: "chevron-left", scale: iconScale })), h("div", { class: { text: true, "text--reverse": reverse } }, h(Heading, { class: "month", level: this.headingLevel }, localizedMonth), h("span", { class: "year-wrap" }, h("input", { "aria-label": this.intlYear, class: {
|
125
|
+
year: true,
|
126
|
+
"year--suffix": !!suffix
|
127
|
+
}, inputmode: "numeric", maxlength: "4", minlength: "1", onChange: this.onYearChange, onInput: this.onYearInput, onKeyDown: this.onYearKey, pattern: "\\d*", ref: (el) => (this.yearInput = el), type: "text", value: localizedYear }), suffix && h("span", { class: "suffix" }, suffix))), h("a", { "aria-disabled": `${this.nextMonthDate.getMonth() === activeMonth}`, "aria-label": this.intlNextMonth, class: "chevron", href: "#", onClick: this.nextMonthClick, onKeyDown: this.nextMonthKeydown, role: "button", tabindex: this.nextMonthDate.getMonth() === activeMonth ? -1 : 0 }, h("calcite-icon", { "flip-rtl": true, icon: "chevron-right", scale: iconScale }))));
|
128
|
+
}
|
129
|
+
setNextPrevMonthDates() {
|
130
|
+
if (!this.activeDate) {
|
131
|
+
return;
|
132
|
+
}
|
133
|
+
this.nextMonthDate = dateFromRange(nextMonth(this.activeDate), this.min, this.max);
|
134
|
+
this.prevMonthDate = dateFromRange(prevMonth(this.activeDate), this.min, this.max);
|
135
|
+
}
|
136
|
+
formatCalendarYear(year) {
|
137
|
+
const { localeData } = this;
|
138
|
+
const buddhistCalendar = localeData["default-calendar"] === "buddhist";
|
139
|
+
const yearOffset = buddhistCalendar ? BUDDHIST_CALENDAR_YEAR_OFFSET : 0;
|
140
|
+
return numberStringFormatter.localize(`${year + yearOffset}`);
|
141
|
+
}
|
142
|
+
parseCalendarYear(year) {
|
143
|
+
const { localeData } = this;
|
144
|
+
const buddhistCalendar = localeData["default-calendar"] === "buddhist";
|
145
|
+
const yearOffset = buddhistCalendar ? BUDDHIST_CALENDAR_YEAR_OFFSET : 0;
|
146
|
+
const parsedYear = Number(numberStringFormatter.delocalize(year)) - yearOffset;
|
147
|
+
return numberStringFormatter.localize(`${parsedYear}`);
|
148
|
+
}
|
149
|
+
getInRangeDate({ localizedYear, offset = 0 }) {
|
150
|
+
const { min, max, activeDate } = this;
|
151
|
+
const parsedYear = Number(numberStringFormatter.delocalize(localizedYear));
|
152
|
+
const length = parsedYear.toString().length;
|
153
|
+
const year = isNaN(parsedYear) ? false : parsedYear + offset;
|
154
|
+
const inRange = year && (!min || min.getFullYear() <= year) && (!max || max.getFullYear() >= year);
|
155
|
+
// if you've supplied a year and it's in range
|
156
|
+
if (year && inRange && length === localizedYear.length) {
|
157
|
+
const nextDate = new Date(activeDate);
|
158
|
+
nextDate.setFullYear(year);
|
159
|
+
return dateFromRange(nextDate, min, max);
|
160
|
+
}
|
161
|
+
}
|
162
|
+
/**
|
163
|
+
* Parse localized year string from input,
|
164
|
+
* set to active if in range
|
165
|
+
*
|
166
|
+
* @param root0
|
167
|
+
* @param root0.localizedYear
|
168
|
+
* @param root0.commit
|
169
|
+
* @param root0.offset
|
170
|
+
*/
|
171
|
+
setYear({ localizedYear, commit = true, offset = 0 }) {
|
172
|
+
const { yearInput, activeDate } = this;
|
173
|
+
const inRangeDate = this.getInRangeDate({ localizedYear, offset });
|
174
|
+
// if you've supplied a year and it's in range, update active date
|
175
|
+
if (inRangeDate) {
|
176
|
+
this.calciteDatePickerSelect.emit(inRangeDate);
|
177
|
+
}
|
178
|
+
if (commit) {
|
179
|
+
yearInput.value = this.formatCalendarYear((inRangeDate || activeDate).getFullYear());
|
180
|
+
}
|
181
|
+
}
|
182
|
+
get el() { return this; }
|
183
|
+
static get watchers() { return {
|
184
|
+
"min": ["setNextPrevMonthDates"],
|
185
|
+
"max": ["setNextPrevMonthDates"],
|
186
|
+
"activeDate": ["setNextPrevMonthDates"]
|
187
|
+
}; }
|
188
|
+
static get style() { return datePickerMonthHeaderCss; }
|
189
|
+
}, [1, "calcite-date-picker-month-header", {
|
190
|
+
"selectedDate": [16],
|
191
|
+
"activeDate": [16],
|
192
|
+
"headingLevel": [2, "heading-level"],
|
193
|
+
"min": [16],
|
194
|
+
"max": [16],
|
195
|
+
"intlPrevMonth": [1, "intl-prev-month"],
|
196
|
+
"intlNextMonth": [1, "intl-next-month"],
|
197
|
+
"intlYear": [1, "intl-year"],
|
198
|
+
"scale": [513],
|
199
|
+
"localeData": [16],
|
200
|
+
"globalAttributes": [32],
|
201
|
+
"nextMonthDate": [32],
|
202
|
+
"prevMonthDate": [32]
|
203
|
+
}]);
|
204
|
+
function defineCustomElement() {
|
205
|
+
if (typeof customElements === "undefined") {
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
const components = ["calcite-date-picker-month-header", "calcite-icon"];
|
209
|
+
components.forEach(tagName => { switch (tagName) {
|
210
|
+
case "calcite-date-picker-month-header":
|
211
|
+
if (!customElements.get(tagName)) {
|
212
|
+
customElements.define(tagName, DatePickerMonthHeader);
|
213
|
+
}
|
214
|
+
break;
|
215
|
+
case "calcite-icon":
|
216
|
+
if (!customElements.get(tagName)) {
|
217
|
+
defineCustomElement$1();
|
218
|
+
}
|
219
|
+
break;
|
220
|
+
} });
|
221
|
+
}
|
222
|
+
defineCustomElement();
|
223
|
+
|
224
|
+
export { DatePickerMonthHeader as D, defineCustomElement as d };
|
@@ -0,0 +1,344 @@
|
|
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 { c as sameDate, b as dateFromRange, i as inRange } from './date.js';
|
8
|
+
import { d as defineCustomElement$1 } from './date-picker-day.js';
|
9
|
+
|
10
|
+
const datePickerMonthCss = "@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}.calender{-webkit-margin-after:0.25rem;margin-block-end:0.25rem}.week-headers{display:flex;border-width:0px;border-block-start-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);padding-block:0px;padding-inline:0.25rem}.week-header{text-align:center;font-weight:var(--calcite-font-weight-bold);color:var(--calcite-ui-text-3);inline-size:14.2857142857%}:host([scale=s]) .week-header{padding-inline:0px;padding-block:0.5rem 0.75rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=m]) .week-header{padding-inline:0px;padding-block:0.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1rem}:host([scale=l]) .week-header{padding-inline:0px;padding-block:1rem 1.25rem;font-size:var(--calcite-font-size--1);line-height:1rem}.week-days{display:flex;flex-direction:row;padding-block:0px;padding-inline:6px}.week-days:focus{outline:2px solid transparent;outline-offset:2px}";
|
11
|
+
|
12
|
+
const DatePickerMonth = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
13
|
+
constructor() {
|
14
|
+
super();
|
15
|
+
this.__registerHost();
|
16
|
+
this.__attachShadow();
|
17
|
+
this.calciteDatePickerSelect = createEvent(this, "calciteDatePickerSelect", 6);
|
18
|
+
this.calciteInternalDatePickerHover = createEvent(this, "calciteInternalDatePickerHover", 6);
|
19
|
+
this.calciteDatePickerActiveDateChange = createEvent(this, "calciteDatePickerActiveDateChange", 6);
|
20
|
+
this.calciteInternalDatePickerMouseOut = createEvent(this, "calciteInternalDatePickerMouseOut", 6);
|
21
|
+
/** Date currently active.*/
|
22
|
+
this.activeDate = new Date();
|
23
|
+
//--------------------------------------------------------------------------
|
24
|
+
//
|
25
|
+
// Event Listeners
|
26
|
+
//
|
27
|
+
//--------------------------------------------------------------------------
|
28
|
+
this.keyDownHandler = (event) => {
|
29
|
+
if (event.defaultPrevented) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
const isRTL = this.el.dir === "rtl";
|
33
|
+
switch (event.key) {
|
34
|
+
case "ArrowUp":
|
35
|
+
event.preventDefault();
|
36
|
+
this.addDays(-7);
|
37
|
+
break;
|
38
|
+
case "ArrowRight":
|
39
|
+
event.preventDefault();
|
40
|
+
this.addDays(isRTL ? -1 : 1);
|
41
|
+
break;
|
42
|
+
case "ArrowDown":
|
43
|
+
event.preventDefault();
|
44
|
+
this.addDays(7);
|
45
|
+
break;
|
46
|
+
case "ArrowLeft":
|
47
|
+
event.preventDefault();
|
48
|
+
this.addDays(isRTL ? 1 : -1);
|
49
|
+
break;
|
50
|
+
case "PageUp":
|
51
|
+
event.preventDefault();
|
52
|
+
this.addMonths(-1);
|
53
|
+
break;
|
54
|
+
case "PageDown":
|
55
|
+
event.preventDefault();
|
56
|
+
this.addMonths(1);
|
57
|
+
break;
|
58
|
+
case "Home":
|
59
|
+
event.preventDefault();
|
60
|
+
this.activeDate.setDate(1);
|
61
|
+
this.addDays();
|
62
|
+
break;
|
63
|
+
case "End":
|
64
|
+
event.preventDefault();
|
65
|
+
this.activeDate.setDate(new Date(this.activeDate.getFullYear(), this.activeDate.getMonth() + 1, 0).getDate());
|
66
|
+
this.addDays();
|
67
|
+
break;
|
68
|
+
case "Enter":
|
69
|
+
case " ":
|
70
|
+
event.preventDefault();
|
71
|
+
break;
|
72
|
+
case "Tab":
|
73
|
+
this.activeFocus = false;
|
74
|
+
}
|
75
|
+
};
|
76
|
+
/**
|
77
|
+
* Once user is not interacting via keyboard,
|
78
|
+
* disable auto focusing of active date
|
79
|
+
*/
|
80
|
+
this.disableActiveFocus = () => {
|
81
|
+
this.activeFocus = false;
|
82
|
+
};
|
83
|
+
this.dayHover = (event) => {
|
84
|
+
const target = event.target;
|
85
|
+
if (target.disabled) {
|
86
|
+
this.calciteInternalDatePickerMouseOut.emit();
|
87
|
+
}
|
88
|
+
else {
|
89
|
+
this.calciteInternalDatePickerHover.emit(target.value);
|
90
|
+
}
|
91
|
+
event.stopPropagation();
|
92
|
+
};
|
93
|
+
this.daySelect = (event) => {
|
94
|
+
const target = event.target;
|
95
|
+
this.calciteDatePickerSelect.emit(target.value);
|
96
|
+
};
|
97
|
+
}
|
98
|
+
mouseoutHandler() {
|
99
|
+
this.calciteInternalDatePickerMouseOut.emit();
|
100
|
+
}
|
101
|
+
//--------------------------------------------------------------------------
|
102
|
+
//
|
103
|
+
// Lifecycle
|
104
|
+
//
|
105
|
+
//--------------------------------------------------------------------------
|
106
|
+
render() {
|
107
|
+
const month = this.activeDate.getMonth();
|
108
|
+
const year = this.activeDate.getFullYear();
|
109
|
+
const startOfWeek = this.localeData.weekStart % 7;
|
110
|
+
const { abbreviated, short, narrow } = this.localeData.days;
|
111
|
+
const weekDays = this.scale === "s" ? narrow || short || abbreviated : short || abbreviated || narrow;
|
112
|
+
const adjustedWeekDays = [...weekDays.slice(startOfWeek, 7), ...weekDays.slice(0, startOfWeek)];
|
113
|
+
const curMonDays = this.getCurrentMonthDays(month, year);
|
114
|
+
const prevMonDays = this.getPrevMonthdays(month, year, startOfWeek);
|
115
|
+
const nextMonDays = this.getNextMonthDays(month, year, startOfWeek);
|
116
|
+
const days = [
|
117
|
+
...prevMonDays.map((day) => {
|
118
|
+
const date = new Date(year, month - 1, day);
|
119
|
+
return this.renderDateDay(false, day, date);
|
120
|
+
}),
|
121
|
+
...curMonDays.map((day) => {
|
122
|
+
const date = new Date(year, month, day);
|
123
|
+
const active = sameDate(date, this.activeDate);
|
124
|
+
return this.renderDateDay(active, day, date, true, true);
|
125
|
+
}),
|
126
|
+
...nextMonDays.map((day) => {
|
127
|
+
const date = new Date(year, month + 1, day);
|
128
|
+
return this.renderDateDay(false, day, date);
|
129
|
+
})
|
130
|
+
];
|
131
|
+
const weeks = [];
|
132
|
+
for (let i = 0; i < days.length; i += 7) {
|
133
|
+
weeks.push(days.slice(i, i + 7));
|
134
|
+
}
|
135
|
+
return (h(Host, { onFocusOut: this.disableActiveFocus, onKeyDown: this.keyDownHandler }, h("div", { class: "calender", role: "grid" }, h("div", { class: "week-headers", role: "row" }, adjustedWeekDays.map((weekday) => (h("span", { class: "week-header", role: "columnheader" }, weekday)))), weeks.map((days) => (h("div", { class: "week-days", role: "row" }, days))))));
|
136
|
+
}
|
137
|
+
//--------------------------------------------------------------------------
|
138
|
+
//
|
139
|
+
// Private Methods
|
140
|
+
//
|
141
|
+
//--------------------------------------------------------------------------
|
142
|
+
/**
|
143
|
+
* Add n months to the current month
|
144
|
+
*
|
145
|
+
* @param step
|
146
|
+
*/
|
147
|
+
addMonths(step) {
|
148
|
+
const nextDate = new Date(this.activeDate);
|
149
|
+
nextDate.setMonth(this.activeDate.getMonth() + step);
|
150
|
+
this.calciteDatePickerActiveDateChange.emit(dateFromRange(nextDate, this.min, this.max));
|
151
|
+
this.activeFocus = true;
|
152
|
+
}
|
153
|
+
/**
|
154
|
+
* Add n days to the current date
|
155
|
+
*
|
156
|
+
* @param step
|
157
|
+
*/
|
158
|
+
addDays(step = 0) {
|
159
|
+
const nextDate = new Date(this.activeDate);
|
160
|
+
nextDate.setDate(this.activeDate.getDate() + step);
|
161
|
+
this.calciteDatePickerActiveDateChange.emit(dateFromRange(nextDate, this.min, this.max));
|
162
|
+
this.activeFocus = true;
|
163
|
+
}
|
164
|
+
/**
|
165
|
+
* Get dates for last days of the previous month
|
166
|
+
*
|
167
|
+
* @param month
|
168
|
+
* @param year
|
169
|
+
* @param startOfWeek
|
170
|
+
*/
|
171
|
+
getPrevMonthdays(month, year, startOfWeek) {
|
172
|
+
const lastDate = new Date(year, month, 0);
|
173
|
+
const date = lastDate.getDate();
|
174
|
+
const day = lastDate.getDay();
|
175
|
+
const days = [];
|
176
|
+
if (day - 6 === startOfWeek) {
|
177
|
+
return days;
|
178
|
+
}
|
179
|
+
for (let i = lastDate.getDay() - startOfWeek; i >= 0; i--) {
|
180
|
+
days.push(date - i);
|
181
|
+
}
|
182
|
+
return days;
|
183
|
+
}
|
184
|
+
/**
|
185
|
+
* Get dates for the current month
|
186
|
+
*
|
187
|
+
* @param month
|
188
|
+
* @param year
|
189
|
+
*/
|
190
|
+
getCurrentMonthDays(month, year) {
|
191
|
+
const num = new Date(year, month + 1, 0).getDate();
|
192
|
+
const days = [];
|
193
|
+
for (let i = 0; i < num; i++) {
|
194
|
+
days.push(i + 1);
|
195
|
+
}
|
196
|
+
return days;
|
197
|
+
}
|
198
|
+
/**
|
199
|
+
* Get dates for first days of the next month
|
200
|
+
*
|
201
|
+
* @param month
|
202
|
+
* @param year
|
203
|
+
* @param startOfWeek
|
204
|
+
*/
|
205
|
+
getNextMonthDays(month, year, startOfWeek) {
|
206
|
+
const endDay = new Date(year, month + 1, 0).getDay();
|
207
|
+
const days = [];
|
208
|
+
if (endDay === (startOfWeek + 6) % 7) {
|
209
|
+
return days;
|
210
|
+
}
|
211
|
+
for (let i = 0; i < (6 - (endDay - startOfWeek)) % 7; i++) {
|
212
|
+
days.push(i + 1);
|
213
|
+
}
|
214
|
+
return days;
|
215
|
+
}
|
216
|
+
/**
|
217
|
+
* Determine if the date is in between the start and end dates
|
218
|
+
*
|
219
|
+
* @param date
|
220
|
+
*/
|
221
|
+
betweenSelectedRange(date) {
|
222
|
+
return !!(this.startDate &&
|
223
|
+
this.endDate &&
|
224
|
+
date > this.startDate &&
|
225
|
+
date < this.endDate &&
|
226
|
+
!this.isRangeHover(date));
|
227
|
+
}
|
228
|
+
/**
|
229
|
+
* Determine if the date should be in selected state
|
230
|
+
*
|
231
|
+
* @param date
|
232
|
+
*/
|
233
|
+
isSelected(date) {
|
234
|
+
return !!(sameDate(date, this.selectedDate) ||
|
235
|
+
(this.startDate && sameDate(date, this.startDate)) ||
|
236
|
+
(this.endDate && sameDate(date, this.endDate)));
|
237
|
+
}
|
238
|
+
/**
|
239
|
+
* Determine if the date is the start of the date range
|
240
|
+
*
|
241
|
+
* @param date
|
242
|
+
*/
|
243
|
+
isStartOfRange(date) {
|
244
|
+
return !!(this.startDate &&
|
245
|
+
!sameDate(this.startDate, this.endDate) &&
|
246
|
+
sameDate(this.startDate, date) &&
|
247
|
+
!this.isEndOfRange(date));
|
248
|
+
}
|
249
|
+
isEndOfRange(date) {
|
250
|
+
return !!((this.endDate && !sameDate(this.startDate, this.endDate) && sameDate(this.endDate, date)) ||
|
251
|
+
(!this.endDate &&
|
252
|
+
this.hoverRange &&
|
253
|
+
sameDate(this.startDate, this.hoverRange.end) &&
|
254
|
+
sameDate(date, this.hoverRange.end)));
|
255
|
+
}
|
256
|
+
/**
|
257
|
+
* Render calcite-date-picker-day
|
258
|
+
*
|
259
|
+
* @param active
|
260
|
+
* @param day
|
261
|
+
* @param date
|
262
|
+
* @param currentMonth
|
263
|
+
* @param ref
|
264
|
+
*/
|
265
|
+
renderDateDay(active, day, date, currentMonth, ref) {
|
266
|
+
var _a;
|
267
|
+
const isFocusedOnStart = this.isFocusedOnStart();
|
268
|
+
const isHoverInRange = this.isHoverInRange() ||
|
269
|
+
(!this.endDate && this.hoverRange && sameDate((_a = this.hoverRange) === null || _a === void 0 ? void 0 : _a.end, this.startDate));
|
270
|
+
return (h("calcite-date-picker-day", { active: active, class: {
|
271
|
+
"hover--inside-range": this.startDate && isHoverInRange,
|
272
|
+
"hover--outside-range": this.startDate && !isHoverInRange,
|
273
|
+
"focused--start": isFocusedOnStart,
|
274
|
+
"focused--end": !isFocusedOnStart
|
275
|
+
}, currentMonth: currentMonth, day: day, disabled: !inRange(date, this.min, this.max), endOfRange: this.isEndOfRange(date), highlighted: this.betweenSelectedRange(date), key: date.toDateString(), onCalciteDaySelect: this.daySelect, onCalciteInternalDayHover: this.dayHover, range: !!this.startDate && !!this.endDate && !sameDate(this.startDate, this.endDate), rangeHover: this.isRangeHover(date), ref: (el) => {
|
276
|
+
// when moving via keyboard, focus must be updated on active date
|
277
|
+
if (ref && active && this.activeFocus) {
|
278
|
+
el === null || el === void 0 ? void 0 : el.focus();
|
279
|
+
}
|
280
|
+
}, scale: this.scale, selected: this.isSelected(date), startOfRange: this.isStartOfRange(date), value: date }));
|
281
|
+
}
|
282
|
+
isFocusedOnStart() {
|
283
|
+
var _a;
|
284
|
+
return ((_a = this.hoverRange) === null || _a === void 0 ? void 0 : _a.focused) === "start";
|
285
|
+
}
|
286
|
+
isHoverInRange() {
|
287
|
+
if (!this.hoverRange) {
|
288
|
+
return false;
|
289
|
+
}
|
290
|
+
const { start, end } = this.hoverRange;
|
291
|
+
return !!((!this.isFocusedOnStart() && this.startDate && (!this.endDate || end < this.endDate)) ||
|
292
|
+
(this.isFocusedOnStart() && this.startDate && start > this.startDate));
|
293
|
+
}
|
294
|
+
isRangeHover(date) {
|
295
|
+
if (!this.hoverRange) {
|
296
|
+
return false;
|
297
|
+
}
|
298
|
+
const { start, end } = this.hoverRange;
|
299
|
+
const isStart = this.isFocusedOnStart();
|
300
|
+
const insideRange = this.isHoverInRange();
|
301
|
+
const cond1 = insideRange &&
|
302
|
+
((!isStart && date > this.startDate && (date < end || sameDate(date, end))) ||
|
303
|
+
(isStart && date < this.endDate && (date > start || sameDate(date, start))));
|
304
|
+
const cond2 = !insideRange &&
|
305
|
+
((!isStart && date >= this.endDate && (date < end || sameDate(date, end))) ||
|
306
|
+
(isStart &&
|
307
|
+
(date < this.startDate || (this.endDate && sameDate(date, this.startDate))) &&
|
308
|
+
(date > start || sameDate(date, start))));
|
309
|
+
return cond1 || cond2;
|
310
|
+
}
|
311
|
+
get el() { return this; }
|
312
|
+
static get style() { return datePickerMonthCss; }
|
313
|
+
}, [1, "calcite-date-picker-month", {
|
314
|
+
"selectedDate": [16],
|
315
|
+
"activeDate": [16],
|
316
|
+
"startDate": [16],
|
317
|
+
"endDate": [16],
|
318
|
+
"min": [16],
|
319
|
+
"max": [16],
|
320
|
+
"scale": [513],
|
321
|
+
"localeData": [16],
|
322
|
+
"hoverRange": [16]
|
323
|
+
}, [[1, "pointerout", "mouseoutHandler"]]]);
|
324
|
+
function defineCustomElement() {
|
325
|
+
if (typeof customElements === "undefined") {
|
326
|
+
return;
|
327
|
+
}
|
328
|
+
const components = ["calcite-date-picker-month", "calcite-date-picker-day"];
|
329
|
+
components.forEach(tagName => { switch (tagName) {
|
330
|
+
case "calcite-date-picker-month":
|
331
|
+
if (!customElements.get(tagName)) {
|
332
|
+
customElements.define(tagName, DatePickerMonth);
|
333
|
+
}
|
334
|
+
break;
|
335
|
+
case "calcite-date-picker-day":
|
336
|
+
if (!customElements.get(tagName)) {
|
337
|
+
defineCustomElement$1();
|
338
|
+
}
|
339
|
+
break;
|
340
|
+
} });
|
341
|
+
}
|
342
|
+
defineCustomElement();
|
343
|
+
|
344
|
+
export { DatePickerMonth as D, defineCustomElement as d };
|