@esri/calcite-components 1.0.0-next.421 → 1.0.0-next.424
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/calcite/calcite.esm.js +1 -1
- package/dist/calcite/calcite.js +1 -1
- package/dist/calcite/p-0ba91238.system.entry.js +5 -0
- package/dist/calcite/{p-afe59546.entry.js → p-2139226c.entry.js} +1 -1
- package/dist/calcite/p-2692ac43.entry.js +5 -0
- package/dist/calcite/p-58392046.system.entry.js +5 -0
- package/dist/calcite/p-62afcb36.system.js +5 -0
- package/dist/calcite/p-69d5736f.entry.js +5 -0
- package/dist/calcite/p-7fb5fec5.entry.js +5 -0
- package/dist/calcite/p-958600ba.system.entry.js +5 -0
- package/dist/calcite/{p-9ad8c7c5.system.entry.js → p-fe3f4e0e.system.entry.js} +1 -1
- package/dist/cjs/calcite-date-picker_4.cjs.entry.js +27 -19
- package/dist/cjs/calcite-graph_2.cjs.entry.js +67 -38
- package/dist/cjs/calcite-input-date-picker.cjs.entry.js +10 -5
- package/dist/cjs/calcite-input-time-picker_2.cjs.entry.js +6 -1
- package/dist/cjs/calcite.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/date-picker-month-header/date-picker-month-header.js +27 -19
- package/dist/collection/components/input-date-picker/input-date-picker.css +5 -0
- package/dist/collection/components/input-date-picker/input-date-picker.js +35 -4
- package/dist/collection/components/input-time-picker/input-time-picker.js +32 -1
- package/dist/collection/components/slider/slider.js +76 -41
- package/dist/components/calcite-input-date-picker.js +12 -6
- package/dist/components/calcite-input-time-picker.js +7 -1
- package/dist/components/calcite-slider.js +67 -38
- package/dist/components/date-picker-month-header.js +27 -19
- package/dist/custom-elements/index.js +112 -65
- package/dist/esm/calcite-date-picker_4.entry.js +27 -19
- package/dist/esm/calcite-graph_2.entry.js +67 -38
- package/dist/esm/calcite-input-date-picker.entry.js +11 -6
- package/dist/esm/calcite-input-time-picker_2.entry.js +6 -1
- package/dist/esm/calcite.js +2 -2
- package/dist/esm/loader.js +2 -2
- package/dist/esm-es5/calcite-date-picker_4.entry.js +1 -1
- package/dist/esm-es5/calcite-graph_2.entry.js +1 -1
- package/dist/esm-es5/calcite-input-date-picker.entry.js +1 -1
- package/dist/esm-es5/calcite-input-time-picker_2.entry.js +1 -1
- package/dist/esm-es5/calcite.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/extras/docs-json.json +94 -4
- package/dist/types/components/date-picker-month-header/date-picker-month-header.d.ts +3 -1
- package/dist/types/components/input-date-picker/input-date-picker.d.ts +6 -1
- package/dist/types/components/input-time-picker/input-time-picker.d.ts +6 -0
- package/dist/types/components/slider/slider.d.ts +5 -2
- package/dist/types/components.d.ts +22 -2
- package/hydrate/index.js +115 -66
- package/package.json +14 -14
- package/readme.md +2 -2
- package/dist/calcite/p-872e82a6.system.entry.js +0 -5
- package/dist/calcite/p-a3527241.system.entry.js +0 -5
- package/dist/calcite/p-a38fe099.entry.js +0 -5
- package/dist/calcite/p-c4cb35ba.system.entry.js +0 -5
- package/dist/calcite/p-cb847074.entry.js +0 -5
- package/dist/calcite/p-e22ab8fa.entry.js +0 -5
- package/dist/calcite/p-fe9380a0.system.js +0 -5
|
@@ -13,6 +13,9 @@ import { d as defineCustomElement$2 } from './graph.js';
|
|
|
13
13
|
|
|
14
14
|
const sliderCss = "@charset \"UTF-8\";@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 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;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}.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;padding:calc(var(--calcite-slider-handle-size) * 0.5);margin:calc(var(--calcite-slider-handle-size) * 0.5) 0;--calcite-slider-full-handle-height:calc(\n var(--calcite-slider-handle-size) + var(--calcite-slider-handle-extension-height)\n )}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}: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-width:100%}.thumb{--calcite-slider-thumb-x-offset:calc(var(--calcite-slider-handle-size) * 0.5);position:absolute;margin:0px;display:-ms-flexbox;display:flex;cursor:pointer;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;border-style:none;background-color:transparent;padding:0px;font-family:inherit;outline:2px solid transparent;outline-offset:2px;-webkit-transform:translate(var(--calcite-slider-thumb-x-offset), var(--calcite-slider-thumb-y-offset));transform:translate(var(--calcite-slider-thumb-x-offset), var(--calcite-slider-thumb-y-offset))}.thumb .handle__label.static,.thumb .handle__label.transformed{position:absolute;top:0px;bottom:0px;opacity:0}.thumb .handle__label.hyphen::after{content:\"—\";display:inline-block;width:1em}.thumb .handle__label.hyphen--wrap{display:-ms-flexbox;display:flex}.thumb .handle{-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:9999px;background-color:var(--calcite-ui-foreground-1);outline-offset:0;outline-color:transparent;-webkit-transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;transition:outline-offset 100ms ease-in-out, outline-color 100ms ease-in-out;height:var(--calcite-slider-handle-size);width:var(--calcite-slider-handle-size);-webkit-box-shadow:0 0 0 2px var(--calcite-ui-text-3) inset;box-shadow:0 0 0 2px var(--calcite-ui-text-3) inset;-webkit-transition:border var(--calcite-internal-animation-timing-medium) ease, background-color var(--calcite-internal-animation-timing-medium) ease, -webkit-box-shadow var(--calcite-animation-timing) ease;transition:border var(--calcite-internal-animation-timing-medium) ease, background-color var(--calcite-internal-animation-timing-medium) ease, -webkit-box-shadow var(--calcite-animation-timing) ease;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;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, -webkit-box-shadow var(--calcite-animation-timing) ease}.thumb .handle-extension{width:0.125rem;height:var(--calcite-slider-handle-extension-height);background-color:var(--calcite-ui-text-3)}.thumb:hover .handle{-webkit-box-shadow:0 0 0 3px var(--calcite-ui-brand) inset;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{-webkit-transform:translate(calc(var(--calcite-slider-thumb-x-offset) * -1), var(--calcite-slider-thumb-y-offset));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{margin-top:0.5em}:host(:not([has-histogram]):not([precise])) .handle__label,:host([label-handles]:not([has-histogram])) .thumb--value .handle__label{margin-bottom: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);-webkit-box-shadow:0 0 8px 0 rgba(0, 0, 0, 0.16);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;height:0.125rem;border-radius:0px;background-color:var(--calcite-ui-border-2);-webkit-transition:all var(--calcite-internal-animation-timing-medium) ease-in;transition:all var(--calcite-internal-animation-timing-medium) ease-in}.track__range{position:absolute;top:0px;height:0.125rem;background-color:var(--calcite-ui-brand)}.container--range .track__range:hover{cursor:ew-resize}.container--range .track__range:after{position:absolute;width:100%;content:\"\";top:calc(var(--calcite-slider-full-handle-height) * 0.5 * -1);height:calc(var(--calcite-slider-handle-size) + var(--calcite-slider-handle-extension-height))}.tick{position:absolute;height:0.25rem;width:0.125rem;border-width:1px;border-style:solid;background-color:var(--calcite-ui-border-input);border-color:var(--calcite-ui-foreground-1);top:-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;margin-top:0.875rem;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}.tick__label--min{-webkit-transition:opacity var(--calcite-animation-timing);transition:opacity var(--calcite-animation-timing)}.tick__label--max{-webkit-transition:opacity var(--calcite-internal-animation-timing-fast);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);height:48px}:host([label-ticks][ticks]) .container{padding-bottom:calc(0.875rem + var(--calcite-slider-container-font-size))}:host([has-histogram]):host([precise][label-handles]) .container{padding-bottom:calc(var(--calcite-slider-full-handle-height) + 1em)}:host([has-histogram]):host([label-handles]:not([precise])) .container{padding-bottom:calc(var(--calcite-slider-handle-size) * 0.5 + 1em)}:host([has-histogram]):host([precise]:not([label-handles])) .container{padding-bottom:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([precise]:not([label-handles])) .container{padding-top:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([precise]:not([label-handles])) .container--range{padding-bottom:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([label-handles]:not([precise])) .container{padding-top:calc(var(--calcite-slider-full-handle-height) + 4px)}:host(:not([has-histogram])):host([label-handles][precise]) .container{padding-top:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px)}:host(:not([has-histogram])):host([label-handles][precise]) .container--range{padding-bottom:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px)}::slotted(input[slot=hidden-form-input]){bottom:0 !important;left:0 !important;margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;right:0 !important;top:0 !important;-webkit-transform:none !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}";
|
|
15
15
|
|
|
16
|
+
function isRange(value) {
|
|
17
|
+
return Array.isArray(value);
|
|
18
|
+
}
|
|
16
19
|
const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
17
20
|
constructor() {
|
|
18
21
|
super();
|
|
@@ -55,13 +58,12 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
55
58
|
/** Interval to move on up/down keys */
|
|
56
59
|
this.step = 1;
|
|
57
60
|
/** Currently selected number (if single select) */
|
|
58
|
-
this.value =
|
|
61
|
+
this.value = 0;
|
|
59
62
|
/**
|
|
60
63
|
* Specify the scale of the slider, defaults to m
|
|
61
64
|
*/
|
|
62
65
|
this.scale = "m";
|
|
63
66
|
this.guid = `calcite-slider-${guid()}`;
|
|
64
|
-
this.isRange = false;
|
|
65
67
|
this.activeProp = "value";
|
|
66
68
|
this.minMaxValueRange = null;
|
|
67
69
|
this.minValueDragRange = null;
|
|
@@ -71,7 +73,7 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
71
73
|
event.preventDefault();
|
|
72
74
|
if (this.dragProp) {
|
|
73
75
|
const value = this.translate(event.clientX || event.pageX);
|
|
74
|
-
if (this.
|
|
76
|
+
if (isRange(this.value) && this.dragProp === "minMaxValue") {
|
|
75
77
|
if (this.minValueDragRange && this.maxValueDragRange && this.minMaxValueRange) {
|
|
76
78
|
const newMinValue = value - this.minValueDragRange;
|
|
77
79
|
const newMaxValue = value + this.maxValueDragRange;
|
|
@@ -117,12 +119,20 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
117
119
|
histogramWatcher(newHistogram) {
|
|
118
120
|
this.hasHistogram = !!newHistogram;
|
|
119
121
|
}
|
|
122
|
+
valueHandler() {
|
|
123
|
+
this.setMinMaxFromValue();
|
|
124
|
+
}
|
|
125
|
+
minMaxValueHandler() {
|
|
126
|
+
this.setValueFromMinMax();
|
|
127
|
+
}
|
|
120
128
|
//--------------------------------------------------------------------------
|
|
121
129
|
//
|
|
122
130
|
// Lifecycle
|
|
123
131
|
//
|
|
124
132
|
//--------------------------------------------------------------------------
|
|
125
133
|
connectedCallback() {
|
|
134
|
+
this.setMinMaxFromValue();
|
|
135
|
+
this.setValueFromMinMax();
|
|
126
136
|
connectLabel(this);
|
|
127
137
|
connectForm(this);
|
|
128
138
|
}
|
|
@@ -132,11 +142,12 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
132
142
|
this.removeDragListeners();
|
|
133
143
|
}
|
|
134
144
|
componentWillLoad() {
|
|
135
|
-
this.isRange = !!(this.maxValue || this.maxValue === 0);
|
|
136
145
|
this.tickValues = this.generateTickValues();
|
|
137
|
-
|
|
146
|
+
if (!isRange(this.value)) {
|
|
147
|
+
this.value = this.clamp(this.value);
|
|
148
|
+
}
|
|
138
149
|
afterConnectDefaultValueSet(this, this.value);
|
|
139
|
-
if (this.snap) {
|
|
150
|
+
if (this.snap && !isRange(this.value)) {
|
|
140
151
|
this.value = this.getClosestStep(this.value);
|
|
141
152
|
}
|
|
142
153
|
if (this.histogram) {
|
|
@@ -146,9 +157,9 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
146
157
|
componentDidRender() {
|
|
147
158
|
if (this.labelHandles) {
|
|
148
159
|
this.adjustHostObscuredHandleLabel("value");
|
|
149
|
-
if (this.
|
|
160
|
+
if (isRange(this.value)) {
|
|
150
161
|
this.adjustHostObscuredHandleLabel("minValue");
|
|
151
|
-
if (!(this.precise &&
|
|
162
|
+
if (!(this.precise && !this.hasHistogram)) {
|
|
152
163
|
this.hyphenateCollidingRangeHandleLabels();
|
|
153
164
|
}
|
|
154
165
|
}
|
|
@@ -158,50 +169,50 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
158
169
|
}
|
|
159
170
|
render() {
|
|
160
171
|
const id = this.el.id || this.guid;
|
|
172
|
+
const maxProp = isRange(this.value) ? "maxValue" : "value";
|
|
173
|
+
const value = isRange(this.value) ? this.maxValue : this.value;
|
|
161
174
|
const min = this.minValue || this.min;
|
|
162
|
-
const max = this.maxValue || this.value;
|
|
163
|
-
const maxProp = this.isRange ? "maxValue" : "value";
|
|
164
|
-
const value = this[maxProp];
|
|
165
175
|
const useMinValue = this.shouldUseMinValue();
|
|
166
176
|
const minInterval = this.getUnitInterval(useMinValue ? this.minValue : min) * 100;
|
|
167
|
-
const maxInterval = this.getUnitInterval(
|
|
177
|
+
const maxInterval = this.getUnitInterval(value) * 100;
|
|
168
178
|
const mirror = this.shouldMirror();
|
|
169
179
|
const leftThumbOffset = `${mirror ? 100 - minInterval : minInterval}%`;
|
|
170
180
|
const rightThumbOffset = `${mirror ? maxInterval : 100 - maxInterval}%`;
|
|
171
|
-
const
|
|
181
|
+
const valueIsRange = isRange(this.value);
|
|
182
|
+
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: {
|
|
172
183
|
thumb: true,
|
|
173
184
|
"thumb--value": true,
|
|
174
185
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
|
|
175
186
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" })));
|
|
176
|
-
const labeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
187
|
+
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: {
|
|
177
188
|
thumb: true,
|
|
178
189
|
"thumb--value": true,
|
|
179
190
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
|
|
180
191
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value), h("div", { class: "handle" })));
|
|
181
|
-
const histogramLabeledHandle = (h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
192
|
+
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: {
|
|
182
193
|
thumb: true,
|
|
183
194
|
"thumb--value": true,
|
|
184
195
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
|
|
185
196
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" }), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value)));
|
|
186
|
-
const preciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
197
|
+
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: {
|
|
187
198
|
thumb: true,
|
|
188
199
|
"thumb--value": true,
|
|
189
200
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
|
190
201
|
"thumb--precise": true
|
|
191
202
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle" }), h("div", { class: "handle-extension" })));
|
|
192
|
-
const histogramPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
203
|
+
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: {
|
|
193
204
|
thumb: true,
|
|
194
205
|
"thumb--value": true,
|
|
195
206
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
|
196
207
|
"thumb--precise": true
|
|
197
208
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("div", { class: "handle-extension" }), h("div", { class: "handle" })));
|
|
198
|
-
const labeledPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
209
|
+
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: {
|
|
199
210
|
thumb: true,
|
|
200
211
|
"thumb--value": true,
|
|
201
212
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
|
202
213
|
"thumb--precise": true
|
|
203
214
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value), h("div", { class: "handle" }), h("div", { class: "handle-extension" })));
|
|
204
|
-
const histogramLabeledPreciseHandle = (h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
215
|
+
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: {
|
|
205
216
|
thumb: true,
|
|
206
217
|
"thumb--value": true,
|
|
207
218
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
|
@@ -236,14 +247,14 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
236
247
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: () => this.dragStart("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: "handle__label handle__label--minValue" }, this.minValue && this.minValue.toLocaleString()), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue static" }, this.minValue && this.minValue.toLocaleString()), h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue transformed" }, this.minValue && this.minValue.toLocaleString())));
|
|
237
248
|
return (h(Host, { id: id, onTouchStart: this.handleTouchStart }, h("div", { class: {
|
|
238
249
|
["container"]: true,
|
|
239
|
-
["container--range"]:
|
|
250
|
+
["container--range"]: valueIsRange,
|
|
240
251
|
[`scale--${this.scale}`]: true
|
|
241
252
|
} }, this.renderGraph(), h("div", { class: "track", ref: this.storeTrackRef }, h("div", { class: "track__range", onPointerDown: () => this.dragStart("minMaxValue"), style: {
|
|
242
253
|
left: `${mirror ? 100 - maxInterval : minInterval}%`,
|
|
243
254
|
right: `${mirror ? minInterval : 100 - maxInterval}%`
|
|
244
255
|
} }), h("div", { class: "ticks" }, this.tickValues.map((tick) => {
|
|
245
256
|
const tickOffset = `${this.getUnitInterval(tick) * 100}%`;
|
|
246
|
-
let activeTicks = tick >= min && tick <=
|
|
257
|
+
let activeTicks = tick >= min && tick <= value;
|
|
247
258
|
if (useMinValue) {
|
|
248
259
|
activeTicks = tick >= this.minValue && tick <= this.maxValue;
|
|
249
260
|
}
|
|
@@ -254,23 +265,24 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
254
265
|
left: mirror ? "" : tickOffset,
|
|
255
266
|
right: mirror ? tickOffset : ""
|
|
256
267
|
} }, this.renderTickLabel(tick)));
|
|
257
|
-
}))), h("div", { class: "thumb-container" }, !this.precise && !this.labelHandles &&
|
|
268
|
+
}))), h("div", { class: "thumb-container" }, !this.precise && !this.labelHandles && valueIsRange && minHandle, !this.hasHistogram &&
|
|
258
269
|
!this.precise &&
|
|
259
270
|
this.labelHandles &&
|
|
260
|
-
|
|
261
|
-
minLabeledHandle, this.precise && !this.labelHandles &&
|
|
271
|
+
valueIsRange &&
|
|
272
|
+
minLabeledHandle, this.precise && !this.labelHandles && valueIsRange && minPreciseHandle, this.precise && this.labelHandles && valueIsRange && minLabeledPreciseHandle, this.hasHistogram &&
|
|
262
273
|
!this.precise &&
|
|
263
274
|
this.labelHandles &&
|
|
264
|
-
|
|
275
|
+
valueIsRange &&
|
|
265
276
|
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 &&
|
|
266
277
|
this.precise &&
|
|
267
278
|
this.labelHandles &&
|
|
268
279
|
histogramLabeledPreciseHandle, h(HiddenFormInputSlot, { component: this })))));
|
|
269
280
|
}
|
|
270
281
|
renderGraph() {
|
|
271
|
-
return this.histogram ? (h("calcite-graph", { class: "graph", colorStops: this.histogramStops, data: this.histogram, highlightMax: this.
|
|
282
|
+
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;
|
|
272
283
|
}
|
|
273
284
|
renderTickLabel(tick) {
|
|
285
|
+
const valueIsRange = isRange(this.value);
|
|
274
286
|
const isMinTickLabel = tick === this.min;
|
|
275
287
|
const isMaxTickLabel = tick === this.max;
|
|
276
288
|
const tickLabel = (h("span", { class: {
|
|
@@ -278,26 +290,26 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
278
290
|
"tick__label--min": isMinTickLabel,
|
|
279
291
|
"tick__label--max": isMaxTickLabel
|
|
280
292
|
} }, tick.toLocaleString()));
|
|
281
|
-
if (this.labelTicks && !this.hasHistogram && !
|
|
293
|
+
if (this.labelTicks && !this.hasHistogram && !valueIsRange) {
|
|
282
294
|
return tickLabel;
|
|
283
295
|
}
|
|
284
296
|
if (this.labelTicks &&
|
|
285
297
|
!this.hasHistogram &&
|
|
286
|
-
|
|
298
|
+
valueIsRange &&
|
|
287
299
|
!this.precise &&
|
|
288
300
|
!this.labelHandles) {
|
|
289
301
|
return tickLabel;
|
|
290
302
|
}
|
|
291
303
|
if (this.labelTicks &&
|
|
292
304
|
!this.hasHistogram &&
|
|
293
|
-
|
|
305
|
+
valueIsRange &&
|
|
294
306
|
!this.precise &&
|
|
295
307
|
this.labelHandles) {
|
|
296
308
|
return tickLabel;
|
|
297
309
|
}
|
|
298
310
|
if (this.labelTicks &&
|
|
299
311
|
!this.hasHistogram &&
|
|
300
|
-
|
|
312
|
+
valueIsRange &&
|
|
301
313
|
this.precise &&
|
|
302
314
|
(isMinTickLabel || isMaxTickLabel)) {
|
|
303
315
|
return tickLabel;
|
|
@@ -381,7 +393,7 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
381
393
|
const x = event.clientX || event.pageX;
|
|
382
394
|
const position = this.translate(x);
|
|
383
395
|
let prop = "value";
|
|
384
|
-
if (this.
|
|
396
|
+
if (isRange(this.value)) {
|
|
385
397
|
const inRange = position >= this.minValue && position <= this.maxValue;
|
|
386
398
|
if (inRange && this.lastDragProp === "minMaxValue") {
|
|
387
399
|
prop = "minMaxValue";
|
|
@@ -417,6 +429,19 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
417
429
|
// Private Methods
|
|
418
430
|
//
|
|
419
431
|
//--------------------------------------------------------------------------
|
|
432
|
+
setValueFromMinMax() {
|
|
433
|
+
const { minValue, maxValue } = this;
|
|
434
|
+
if (typeof minValue === "number" && typeof maxValue === "number") {
|
|
435
|
+
this.value = [minValue, maxValue];
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
setMinMaxFromValue() {
|
|
439
|
+
const { value } = this;
|
|
440
|
+
if (isRange(value)) {
|
|
441
|
+
this.minValue = value[0];
|
|
442
|
+
this.maxValue = value[1];
|
|
443
|
+
}
|
|
444
|
+
}
|
|
420
445
|
onLabelClick() {
|
|
421
446
|
this.setFocus();
|
|
422
447
|
}
|
|
@@ -424,7 +449,7 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
424
449
|
return this.mirrored && !this.hasHistogram;
|
|
425
450
|
}
|
|
426
451
|
shouldUseMinValue() {
|
|
427
|
-
if (!this.
|
|
452
|
+
if (!isRange(this.value)) {
|
|
428
453
|
return false;
|
|
429
454
|
}
|
|
430
455
|
return ((this.hasHistogram && this.maxValue === 0) || (!this.hasHistogram && this.minValue === 0));
|
|
@@ -637,19 +662,20 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
637
662
|
* Hides bounding tick labels that are obscured by either handle.
|
|
638
663
|
*/
|
|
639
664
|
hideObscuredBoundingTickLabels() {
|
|
640
|
-
|
|
665
|
+
const valueIsRange = isRange(this.value);
|
|
666
|
+
if (!this.hasHistogram && !valueIsRange && !this.labelHandles && !this.precise) {
|
|
641
667
|
return;
|
|
642
668
|
}
|
|
643
|
-
if (!this.hasHistogram && !
|
|
669
|
+
if (!this.hasHistogram && !valueIsRange && this.labelHandles && !this.precise) {
|
|
644
670
|
return;
|
|
645
671
|
}
|
|
646
|
-
if (!this.hasHistogram && !
|
|
672
|
+
if (!this.hasHistogram && !valueIsRange && !this.labelHandles && this.precise) {
|
|
647
673
|
return;
|
|
648
674
|
}
|
|
649
|
-
if (!this.hasHistogram && !
|
|
675
|
+
if (!this.hasHistogram && !valueIsRange && this.labelHandles && this.precise) {
|
|
650
676
|
return;
|
|
651
677
|
}
|
|
652
|
-
if (!this.hasHistogram &&
|
|
678
|
+
if (!this.hasHistogram && valueIsRange && !this.precise) {
|
|
653
679
|
return;
|
|
654
680
|
}
|
|
655
681
|
if (this.hasHistogram && !this.precise && !this.labelHandles) {
|
|
@@ -726,7 +752,10 @@ const Slider = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
726
752
|
}
|
|
727
753
|
get el() { return this; }
|
|
728
754
|
static get watchers() { return {
|
|
729
|
-
"histogram": ["histogramWatcher"]
|
|
755
|
+
"histogram": ["histogramWatcher"],
|
|
756
|
+
"value": ["valueHandler"],
|
|
757
|
+
"minValue": ["minMaxValueHandler"],
|
|
758
|
+
"maxValue": ["minMaxValueHandler"]
|
|
730
759
|
}; }
|
|
731
760
|
static get style() { return sliderCss; }
|
|
732
761
|
}, [1, "calcite-slider", {
|
|
@@ -24,20 +24,23 @@ const DatePickerMonthHeader = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
24
24
|
* Increment year on UP/DOWN keys
|
|
25
25
|
*/
|
|
26
26
|
this.onYearKey = (e) => {
|
|
27
|
-
const
|
|
27
|
+
const localizedYear = e.target.value;
|
|
28
28
|
switch (e.key) {
|
|
29
29
|
case "ArrowDown":
|
|
30
30
|
e.preventDefault();
|
|
31
|
-
this.setYear(
|
|
31
|
+
this.setYear({ localizedYear, offset: -1 });
|
|
32
32
|
break;
|
|
33
33
|
case "ArrowUp":
|
|
34
34
|
e.preventDefault();
|
|
35
|
-
this.setYear(
|
|
35
|
+
this.setYear({ localizedYear, offset: 1 });
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
this.
|
|
40
|
-
this.setYear(event.target.value);
|
|
39
|
+
this.onYearChange = (event) => {
|
|
40
|
+
this.setYear({ localizedYear: event.target.value });
|
|
41
|
+
};
|
|
42
|
+
this.onYearInput = (event) => {
|
|
43
|
+
this.setYear({ localizedYear: event.target.value, commit: false });
|
|
41
44
|
};
|
|
42
45
|
this.prevMonthClick = (e) => {
|
|
43
46
|
this.handleArrowClick(e, this.prevMonthDate);
|
|
@@ -93,7 +96,7 @@ const DatePickerMonthHeader = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
93
96
|
return (h(Fragment, null, h("a", { "aria-disabled": (this.prevMonthDate.getMonth() === activeMonth).toString(), "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: {
|
|
94
97
|
year: true,
|
|
95
98
|
"year--suffix": !!suffix
|
|
96
|
-
}, inputmode: "numeric", maxlength: "4", minlength: "1", onInput: this.
|
|
99
|
+
}, 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" }, h("span", { "aria-hidden": "true", class: "suffix__invisible" }, localizedYear), " " + suffix)))), h("a", { "aria-disabled": (this.nextMonthDate.getMonth() === activeMonth).toString(), "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 }))));
|
|
97
100
|
}
|
|
98
101
|
setNextPrevMonthDates() {
|
|
99
102
|
if (!this.activeDate) {
|
|
@@ -102,27 +105,32 @@ const DatePickerMonthHeader = /*@__PURE__*/ proxyCustomElement(class extends HTM
|
|
|
102
105
|
this.nextMonthDate = dateFromRange(nextMonth(this.activeDate), this.min, this.max);
|
|
103
106
|
this.prevMonthDate = dateFromRange(prevMonth(this.activeDate), this.min, this.max);
|
|
104
107
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
* set to active if in range
|
|
108
|
-
*/
|
|
109
|
-
setYear(localizedYear, increment = 0) {
|
|
110
|
-
const { min, max, activeDate, localeData, yearInput } = this;
|
|
108
|
+
getInRangeDate({ localizedYear, offset = 0 }) {
|
|
109
|
+
const { min, max, activeDate, localeData } = this;
|
|
111
110
|
const parsedYear = parseNumber(localizedYear, localeData);
|
|
112
111
|
const length = parsedYear.toString().length;
|
|
113
|
-
const year = isNaN(parsedYear) ? false : parsedYear +
|
|
112
|
+
const year = isNaN(parsedYear) ? false : parsedYear + offset;
|
|
114
113
|
const inRange = year && (!min || min.getFullYear() <= year) && (!max || max.getFullYear() >= year);
|
|
115
|
-
// if you've supplied a year and it's in range
|
|
114
|
+
// if you've supplied a year and it's in range
|
|
116
115
|
if (year && inRange && length === localizedYear.length) {
|
|
117
116
|
const nextDate = new Date(activeDate);
|
|
118
117
|
nextDate.setFullYear(year);
|
|
119
|
-
|
|
118
|
+
return dateFromRange(nextDate, min, max);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Parse localized year string from input,
|
|
123
|
+
* set to active if in range
|
|
124
|
+
*/
|
|
125
|
+
setYear({ localizedYear, commit = true, offset = 0 }) {
|
|
126
|
+
const { yearInput, activeDate, localeData } = this;
|
|
127
|
+
const inRangeDate = this.getInRangeDate({ localizedYear, offset });
|
|
128
|
+
// if you've supplied a year and it's in range, update active date
|
|
129
|
+
if (inRangeDate) {
|
|
120
130
|
this.calciteDatePickerSelect.emit(inRangeDate);
|
|
121
|
-
yearInput.value = localizeNumber(inRangeDate.getFullYear(), localeData);
|
|
122
131
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
yearInput.value = localizeNumber(activeDate.getFullYear(), localeData);
|
|
132
|
+
if (commit) {
|
|
133
|
+
yearInput.value = localizeNumber((inRangeDate || activeDate).getFullYear(), localeData);
|
|
126
134
|
}
|
|
127
135
|
}
|
|
128
136
|
get el() { return this; }
|