@esri/calcite-components 1.0.0-next.422 → 1.0.0-next.425
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/{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 +1 -1
- package/dist/calcite/p-7b238036.entry.js +5 -0
- package/dist/calcite/p-cedd48fe.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-tab_4.cjs.entry.js +31 -32
- package/dist/collection/components/date-picker-month-header/date-picker-month-header.js +27 -19
- package/dist/collection/components/slider/slider.js +76 -41
- package/dist/collection/components/tab/tab.js +10 -12
- package/dist/collection/components/tab-nav/tab-nav.js +8 -5
- package/dist/collection/components/tab-title/tab-title.js +13 -12
- package/dist/collection/components/tabs/tabs.js +0 -3
- package/dist/components/calcite-slider.js +67 -38
- package/dist/components/date-picker-month-header.js +27 -19
- package/dist/components/tab-nav.js +8 -5
- package/dist/components/tab-title.js +13 -12
- package/dist/components/tab.js +10 -12
- package/dist/components/tabs.js +0 -3
- package/dist/custom-elements/index.js +125 -89
- 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-tab_4.entry.js +31 -32
- 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-tab_4.entry.js +1 -1
- package/dist/extras/docs-json.json +6 -3
- package/dist/types/components/date-picker-month-header/date-picker-month-header.d.ts +3 -1
- package/dist/types/components/slider/slider.d.ts +5 -2
- package/dist/types/components/tab/tab.d.ts +4 -5
- package/dist/types/components/tab-nav/tab-nav.d.ts +15 -19
- package/dist/types/components/tab-title/tab-title.d.ts +9 -18
- package/dist/types/components/tabs/tabs.d.ts +1 -4
- package/dist/types/components.d.ts +2 -2
- package/hydrate/index.js +125 -89
- package/package.json +2 -2
- package/dist/calcite/p-1aeca42a.system.entry.js +0 -5
- package/dist/calcite/p-3915705c.entry.js +0 -5
- package/dist/calcite/p-872e82a6.system.entry.js +0 -5
- package/dist/calcite/p-e22ab8fa.entry.js +0 -5
|
@@ -205,6 +205,9 @@ Graph.style = graphCss;
|
|
|
205
205
|
|
|
206
206
|
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}";
|
|
207
207
|
|
|
208
|
+
function isRange(value) {
|
|
209
|
+
return Array.isArray(value);
|
|
210
|
+
}
|
|
208
211
|
const Slider = class {
|
|
209
212
|
constructor(hostRef) {
|
|
210
213
|
index.registerInstance(this, hostRef);
|
|
@@ -245,13 +248,12 @@ const Slider = class {
|
|
|
245
248
|
/** Interval to move on up/down keys */
|
|
246
249
|
this.step = 1;
|
|
247
250
|
/** Currently selected number (if single select) */
|
|
248
|
-
this.value =
|
|
251
|
+
this.value = 0;
|
|
249
252
|
/**
|
|
250
253
|
* Specify the scale of the slider, defaults to m
|
|
251
254
|
*/
|
|
252
255
|
this.scale = "m";
|
|
253
256
|
this.guid = `calcite-slider-${guid.guid()}`;
|
|
254
|
-
this.isRange = false;
|
|
255
257
|
this.activeProp = "value";
|
|
256
258
|
this.minMaxValueRange = null;
|
|
257
259
|
this.minValueDragRange = null;
|
|
@@ -261,7 +263,7 @@ const Slider = class {
|
|
|
261
263
|
event.preventDefault();
|
|
262
264
|
if (this.dragProp) {
|
|
263
265
|
const value = this.translate(event.clientX || event.pageX);
|
|
264
|
-
if (this.
|
|
266
|
+
if (isRange(this.value) && this.dragProp === "minMaxValue") {
|
|
265
267
|
if (this.minValueDragRange && this.maxValueDragRange && this.minMaxValueRange) {
|
|
266
268
|
const newMinValue = value - this.minValueDragRange;
|
|
267
269
|
const newMaxValue = value + this.maxValueDragRange;
|
|
@@ -307,12 +309,20 @@ const Slider = class {
|
|
|
307
309
|
histogramWatcher(newHistogram) {
|
|
308
310
|
this.hasHistogram = !!newHistogram;
|
|
309
311
|
}
|
|
312
|
+
valueHandler() {
|
|
313
|
+
this.setMinMaxFromValue();
|
|
314
|
+
}
|
|
315
|
+
minMaxValueHandler() {
|
|
316
|
+
this.setValueFromMinMax();
|
|
317
|
+
}
|
|
310
318
|
//--------------------------------------------------------------------------
|
|
311
319
|
//
|
|
312
320
|
// Lifecycle
|
|
313
321
|
//
|
|
314
322
|
//--------------------------------------------------------------------------
|
|
315
323
|
connectedCallback() {
|
|
324
|
+
this.setMinMaxFromValue();
|
|
325
|
+
this.setValueFromMinMax();
|
|
316
326
|
label.connectLabel(this);
|
|
317
327
|
form.connectForm(this);
|
|
318
328
|
}
|
|
@@ -322,11 +332,12 @@ const Slider = class {
|
|
|
322
332
|
this.removeDragListeners();
|
|
323
333
|
}
|
|
324
334
|
componentWillLoad() {
|
|
325
|
-
this.isRange = !!(this.maxValue || this.maxValue === 0);
|
|
326
335
|
this.tickValues = this.generateTickValues();
|
|
327
|
-
|
|
336
|
+
if (!isRange(this.value)) {
|
|
337
|
+
this.value = this.clamp(this.value);
|
|
338
|
+
}
|
|
328
339
|
form.afterConnectDefaultValueSet(this, this.value);
|
|
329
|
-
if (this.snap) {
|
|
340
|
+
if (this.snap && !isRange(this.value)) {
|
|
330
341
|
this.value = this.getClosestStep(this.value);
|
|
331
342
|
}
|
|
332
343
|
if (this.histogram) {
|
|
@@ -336,9 +347,9 @@ const Slider = class {
|
|
|
336
347
|
componentDidRender() {
|
|
337
348
|
if (this.labelHandles) {
|
|
338
349
|
this.adjustHostObscuredHandleLabel("value");
|
|
339
|
-
if (this.
|
|
350
|
+
if (isRange(this.value)) {
|
|
340
351
|
this.adjustHostObscuredHandleLabel("minValue");
|
|
341
|
-
if (!(this.precise &&
|
|
352
|
+
if (!(this.precise && !this.hasHistogram)) {
|
|
342
353
|
this.hyphenateCollidingRangeHandleLabels();
|
|
343
354
|
}
|
|
344
355
|
}
|
|
@@ -348,50 +359,50 @@ const Slider = class {
|
|
|
348
359
|
}
|
|
349
360
|
render() {
|
|
350
361
|
const id = this.el.id || this.guid;
|
|
362
|
+
const maxProp = isRange(this.value) ? "maxValue" : "value";
|
|
363
|
+
const value = isRange(this.value) ? this.maxValue : this.value;
|
|
351
364
|
const min = this.minValue || this.min;
|
|
352
|
-
const max = this.maxValue || this.value;
|
|
353
|
-
const maxProp = this.isRange ? "maxValue" : "value";
|
|
354
|
-
const value = this[maxProp];
|
|
355
365
|
const useMinValue = this.shouldUseMinValue();
|
|
356
366
|
const minInterval = this.getUnitInterval(useMinValue ? this.minValue : min) * 100;
|
|
357
|
-
const maxInterval = this.getUnitInterval(
|
|
367
|
+
const maxInterval = this.getUnitInterval(value) * 100;
|
|
358
368
|
const mirror = this.shouldMirror();
|
|
359
369
|
const leftThumbOffset = `${mirror ? 100 - minInterval : minInterval}%`;
|
|
360
370
|
const rightThumbOffset = `${mirror ? maxInterval : 100 - maxInterval}%`;
|
|
361
|
-
const
|
|
371
|
+
const valueIsRange = isRange(this.value);
|
|
372
|
+
const handle = (index.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: {
|
|
362
373
|
thumb: true,
|
|
363
374
|
"thumb--value": true,
|
|
364
375
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
|
|
365
376
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, index.h("div", { class: "handle" })));
|
|
366
|
-
const labeledHandle = (index.h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
377
|
+
const labeledHandle = (index.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: {
|
|
367
378
|
thumb: true,
|
|
368
379
|
"thumb--value": true,
|
|
369
380
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
|
|
370
381
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value), index.h("div", { class: "handle" })));
|
|
371
|
-
const histogramLabeledHandle = (index.h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
382
|
+
const histogramLabeledHandle = (index.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: {
|
|
372
383
|
thumb: true,
|
|
373
384
|
"thumb--value": true,
|
|
374
385
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp
|
|
375
386
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, index.h("div", { class: "handle" }), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value)));
|
|
376
|
-
const preciseHandle = (index.h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
387
|
+
const preciseHandle = (index.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: {
|
|
377
388
|
thumb: true,
|
|
378
389
|
"thumb--value": true,
|
|
379
390
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
|
380
391
|
"thumb--precise": true
|
|
381
392
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, index.h("div", { class: "handle" }), index.h("div", { class: "handle-extension" })));
|
|
382
|
-
const histogramPreciseHandle = (index.h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
393
|
+
const histogramPreciseHandle = (index.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: {
|
|
383
394
|
thumb: true,
|
|
384
395
|
"thumb--value": true,
|
|
385
396
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
|
386
397
|
"thumb--precise": true
|
|
387
398
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, index.h("div", { class: "handle-extension" }), index.h("div", { class: "handle" })));
|
|
388
|
-
const labeledPreciseHandle = (index.h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
399
|
+
const labeledPreciseHandle = (index.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: {
|
|
389
400
|
thumb: true,
|
|
390
401
|
"thumb--value": true,
|
|
391
402
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
|
392
403
|
"thumb--precise": true
|
|
393
404
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = maxProp), onPointerDown: () => this.dragStart(maxProp), ref: (el) => (this.maxHandle = el), role: "slider", style: { right: rightThumbOffset }, tabIndex: 0 }, index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--value" }, value ? value.toLocaleString() : value), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--value static" }, value ? value.toLocaleString() : value), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--value transformed" }, value ? value.toLocaleString() : value), index.h("div", { class: "handle" }), index.h("div", { class: "handle-extension" })));
|
|
394
|
-
const histogramLabeledPreciseHandle = (index.h("div", { "aria-disabled": this.disabled, "aria-label":
|
|
405
|
+
const histogramLabeledPreciseHandle = (index.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: {
|
|
395
406
|
thumb: true,
|
|
396
407
|
"thumb--value": true,
|
|
397
408
|
"thumb--active": this.lastDragProp !== "minMaxValue" && this.dragProp === maxProp,
|
|
@@ -426,14 +437,14 @@ const Slider = class {
|
|
|
426
437
|
}, onBlur: () => (this.activeProp = null), onFocus: () => (this.activeProp = "minValue"), onPointerDown: () => this.dragStart("minValue"), ref: (el) => (this.minHandle = el), role: "slider", style: { left: leftThumbOffset }, tabIndex: 0 }, index.h("div", { class: "handle-extension" }), index.h("div", { class: "handle" }), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue" }, this.minValue && this.minValue.toLocaleString()), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue static" }, this.minValue && this.minValue.toLocaleString()), index.h("span", { "aria-hidden": "true", class: "handle__label handle__label--minValue transformed" }, this.minValue && this.minValue.toLocaleString())));
|
|
427
438
|
return (index.h(index.Host, { id: id, onTouchStart: this.handleTouchStart }, index.h("div", { class: {
|
|
428
439
|
["container"]: true,
|
|
429
|
-
["container--range"]:
|
|
440
|
+
["container--range"]: valueIsRange,
|
|
430
441
|
[`scale--${this.scale}`]: true
|
|
431
442
|
} }, this.renderGraph(), index.h("div", { class: "track", ref: this.storeTrackRef }, index.h("div", { class: "track__range", onPointerDown: () => this.dragStart("minMaxValue"), style: {
|
|
432
443
|
left: `${mirror ? 100 - maxInterval : minInterval}%`,
|
|
433
444
|
right: `${mirror ? minInterval : 100 - maxInterval}%`
|
|
434
445
|
} }), index.h("div", { class: "ticks" }, this.tickValues.map((tick) => {
|
|
435
446
|
const tickOffset = `${this.getUnitInterval(tick) * 100}%`;
|
|
436
|
-
let activeTicks = tick >= min && tick <=
|
|
447
|
+
let activeTicks = tick >= min && tick <= value;
|
|
437
448
|
if (useMinValue) {
|
|
438
449
|
activeTicks = tick >= this.minValue && tick <= this.maxValue;
|
|
439
450
|
}
|
|
@@ -444,23 +455,24 @@ const Slider = class {
|
|
|
444
455
|
left: mirror ? "" : tickOffset,
|
|
445
456
|
right: mirror ? tickOffset : ""
|
|
446
457
|
} }, this.renderTickLabel(tick)));
|
|
447
|
-
}))), index.h("div", { class: "thumb-container" }, !this.precise && !this.labelHandles &&
|
|
458
|
+
}))), index.h("div", { class: "thumb-container" }, !this.precise && !this.labelHandles && valueIsRange && minHandle, !this.hasHistogram &&
|
|
448
459
|
!this.precise &&
|
|
449
460
|
this.labelHandles &&
|
|
450
|
-
|
|
451
|
-
minLabeledHandle, this.precise && !this.labelHandles &&
|
|
461
|
+
valueIsRange &&
|
|
462
|
+
minLabeledHandle, this.precise && !this.labelHandles && valueIsRange && minPreciseHandle, this.precise && this.labelHandles && valueIsRange && minLabeledPreciseHandle, this.hasHistogram &&
|
|
452
463
|
!this.precise &&
|
|
453
464
|
this.labelHandles &&
|
|
454
|
-
|
|
465
|
+
valueIsRange &&
|
|
455
466
|
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 &&
|
|
456
467
|
this.precise &&
|
|
457
468
|
this.labelHandles &&
|
|
458
469
|
histogramLabeledPreciseHandle, index.h(form.HiddenFormInputSlot, { component: this })))));
|
|
459
470
|
}
|
|
460
471
|
renderGraph() {
|
|
461
|
-
return this.histogram ? (index.h("calcite-graph", { class: "graph", colorStops: this.histogramStops, data: this.histogram, highlightMax: this.
|
|
472
|
+
return this.histogram ? (index.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;
|
|
462
473
|
}
|
|
463
474
|
renderTickLabel(tick) {
|
|
475
|
+
const valueIsRange = isRange(this.value);
|
|
464
476
|
const isMinTickLabel = tick === this.min;
|
|
465
477
|
const isMaxTickLabel = tick === this.max;
|
|
466
478
|
const tickLabel = (index.h("span", { class: {
|
|
@@ -468,26 +480,26 @@ const Slider = class {
|
|
|
468
480
|
"tick__label--min": isMinTickLabel,
|
|
469
481
|
"tick__label--max": isMaxTickLabel
|
|
470
482
|
} }, tick.toLocaleString()));
|
|
471
|
-
if (this.labelTicks && !this.hasHistogram && !
|
|
483
|
+
if (this.labelTicks && !this.hasHistogram && !valueIsRange) {
|
|
472
484
|
return tickLabel;
|
|
473
485
|
}
|
|
474
486
|
if (this.labelTicks &&
|
|
475
487
|
!this.hasHistogram &&
|
|
476
|
-
|
|
488
|
+
valueIsRange &&
|
|
477
489
|
!this.precise &&
|
|
478
490
|
!this.labelHandles) {
|
|
479
491
|
return tickLabel;
|
|
480
492
|
}
|
|
481
493
|
if (this.labelTicks &&
|
|
482
494
|
!this.hasHistogram &&
|
|
483
|
-
|
|
495
|
+
valueIsRange &&
|
|
484
496
|
!this.precise &&
|
|
485
497
|
this.labelHandles) {
|
|
486
498
|
return tickLabel;
|
|
487
499
|
}
|
|
488
500
|
if (this.labelTicks &&
|
|
489
501
|
!this.hasHistogram &&
|
|
490
|
-
|
|
502
|
+
valueIsRange &&
|
|
491
503
|
this.precise &&
|
|
492
504
|
(isMinTickLabel || isMaxTickLabel)) {
|
|
493
505
|
return tickLabel;
|
|
@@ -571,7 +583,7 @@ const Slider = class {
|
|
|
571
583
|
const x = event.clientX || event.pageX;
|
|
572
584
|
const position = this.translate(x);
|
|
573
585
|
let prop = "value";
|
|
574
|
-
if (this.
|
|
586
|
+
if (isRange(this.value)) {
|
|
575
587
|
const inRange = position >= this.minValue && position <= this.maxValue;
|
|
576
588
|
if (inRange && this.lastDragProp === "minMaxValue") {
|
|
577
589
|
prop = "minMaxValue";
|
|
@@ -607,6 +619,19 @@ const Slider = class {
|
|
|
607
619
|
// Private Methods
|
|
608
620
|
//
|
|
609
621
|
//--------------------------------------------------------------------------
|
|
622
|
+
setValueFromMinMax() {
|
|
623
|
+
const { minValue, maxValue } = this;
|
|
624
|
+
if (typeof minValue === "number" && typeof maxValue === "number") {
|
|
625
|
+
this.value = [minValue, maxValue];
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
setMinMaxFromValue() {
|
|
629
|
+
const { value } = this;
|
|
630
|
+
if (isRange(value)) {
|
|
631
|
+
this.minValue = value[0];
|
|
632
|
+
this.maxValue = value[1];
|
|
633
|
+
}
|
|
634
|
+
}
|
|
610
635
|
onLabelClick() {
|
|
611
636
|
this.setFocus();
|
|
612
637
|
}
|
|
@@ -614,7 +639,7 @@ const Slider = class {
|
|
|
614
639
|
return this.mirrored && !this.hasHistogram;
|
|
615
640
|
}
|
|
616
641
|
shouldUseMinValue() {
|
|
617
|
-
if (!this.
|
|
642
|
+
if (!isRange(this.value)) {
|
|
618
643
|
return false;
|
|
619
644
|
}
|
|
620
645
|
return ((this.hasHistogram && this.maxValue === 0) || (!this.hasHistogram && this.minValue === 0));
|
|
@@ -827,19 +852,20 @@ const Slider = class {
|
|
|
827
852
|
* Hides bounding tick labels that are obscured by either handle.
|
|
828
853
|
*/
|
|
829
854
|
hideObscuredBoundingTickLabels() {
|
|
830
|
-
|
|
855
|
+
const valueIsRange = isRange(this.value);
|
|
856
|
+
if (!this.hasHistogram && !valueIsRange && !this.labelHandles && !this.precise) {
|
|
831
857
|
return;
|
|
832
858
|
}
|
|
833
|
-
if (!this.hasHistogram && !
|
|
859
|
+
if (!this.hasHistogram && !valueIsRange && this.labelHandles && !this.precise) {
|
|
834
860
|
return;
|
|
835
861
|
}
|
|
836
|
-
if (!this.hasHistogram && !
|
|
862
|
+
if (!this.hasHistogram && !valueIsRange && !this.labelHandles && this.precise) {
|
|
837
863
|
return;
|
|
838
864
|
}
|
|
839
|
-
if (!this.hasHistogram && !
|
|
865
|
+
if (!this.hasHistogram && !valueIsRange && this.labelHandles && this.precise) {
|
|
840
866
|
return;
|
|
841
867
|
}
|
|
842
|
-
if (!this.hasHistogram &&
|
|
868
|
+
if (!this.hasHistogram && valueIsRange && !this.precise) {
|
|
843
869
|
return;
|
|
844
870
|
}
|
|
845
871
|
if (this.hasHistogram && !this.precise && !this.labelHandles) {
|
|
@@ -916,7 +942,10 @@ const Slider = class {
|
|
|
916
942
|
}
|
|
917
943
|
get el() { return index.getElement(this); }
|
|
918
944
|
static get watchers() { return {
|
|
919
|
-
"histogram": ["histogramWatcher"]
|
|
945
|
+
"histogram": ["histogramWatcher"],
|
|
946
|
+
"value": ["valueHandler"],
|
|
947
|
+
"minValue": ["minMaxValueHandler"],
|
|
948
|
+
"maxValue": ["minMaxValueHandler"]
|
|
920
949
|
}; }
|
|
921
950
|
};
|
|
922
951
|
Slider.style = sliderCss;
|
|
@@ -24,14 +24,6 @@ const Tab = class {
|
|
|
24
24
|
this.active = false;
|
|
25
25
|
/** @internal Parent tabs component scale value */
|
|
26
26
|
this.scale = "m";
|
|
27
|
-
//--------------------------------------------------------------------------
|
|
28
|
-
//
|
|
29
|
-
// Private State/Props
|
|
30
|
-
//
|
|
31
|
-
//--------------------------------------------------------------------------
|
|
32
|
-
/**
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
27
|
this.guid = `calcite-tab-title-${guid.guid()}`;
|
|
36
28
|
}
|
|
37
29
|
//--------------------------------------------------------------------------
|
|
@@ -43,12 +35,15 @@ const Tab = class {
|
|
|
43
35
|
const id = this.el.id || this.guid;
|
|
44
36
|
return (index.h(index.Host, { "aria-expanded": this.active.toString(), "aria-labelledby": this.labeledBy, id: id, role: "tabpanel" }, index.h("section", null, index.h("slot", null))));
|
|
45
37
|
}
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
this.parentTabsEl = this.el.closest("calcite-tabs");
|
|
40
|
+
}
|
|
46
41
|
componentDidLoad() {
|
|
47
42
|
this.calciteTabRegister.emit();
|
|
48
43
|
}
|
|
49
44
|
componentWillRender() {
|
|
50
45
|
var _a;
|
|
51
|
-
this.scale = (_a = this.
|
|
46
|
+
this.scale = (_a = this.parentTabsEl) === null || _a === void 0 ? void 0 : _a.scale;
|
|
52
47
|
}
|
|
53
48
|
disconnectedCallback() {
|
|
54
49
|
var _a;
|
|
@@ -63,10 +58,13 @@ const Tab = class {
|
|
|
63
58
|
//
|
|
64
59
|
//--------------------------------------------------------------------------
|
|
65
60
|
tabChangeHandler(event) {
|
|
61
|
+
const targetTabsEl = event
|
|
62
|
+
.composedPath()
|
|
63
|
+
.find((el) => el.tagName === "CALCITE-TABS");
|
|
66
64
|
// to allow `<calcite-tabs>` to be nested we need to make sure this
|
|
67
|
-
// `calciteTabChange` event was actually fired from a
|
|
68
|
-
//
|
|
69
|
-
if (
|
|
65
|
+
// `calciteTabChange` event was actually fired from a within the same
|
|
66
|
+
// `<calcite-tabs>` that is the a parent of this tab.
|
|
67
|
+
if (targetTabsEl !== this.parentTabsEl) {
|
|
70
68
|
return;
|
|
71
69
|
}
|
|
72
70
|
if (this.tab) {
|
|
@@ -153,6 +151,9 @@ const TabNav = class {
|
|
|
153
151
|
// Lifecycle
|
|
154
152
|
//
|
|
155
153
|
//--------------------------------------------------------------------------
|
|
154
|
+
connectedCallback() {
|
|
155
|
+
this.parentTabsEl = this.el.closest("calcite-tabs");
|
|
156
|
+
}
|
|
156
157
|
componentWillLoad() {
|
|
157
158
|
const storageKey = `calcite-tab-nav-${this.storageId}`;
|
|
158
159
|
if (localStorage && this.storageId && localStorage.getItem(storageKey)) {
|
|
@@ -164,11 +165,11 @@ const TabNav = class {
|
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
componentWillRender() {
|
|
167
|
-
|
|
168
|
-
this.layout =
|
|
169
|
-
this.position =
|
|
170
|
-
this.scale =
|
|
171
|
-
this.bordered =
|
|
168
|
+
const { parentTabsEl } = this;
|
|
169
|
+
this.layout = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.layout;
|
|
170
|
+
this.position = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.position;
|
|
171
|
+
this.scale = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.scale;
|
|
172
|
+
this.bordered = parentTabsEl === null || parentTabsEl === void 0 ? void 0 : parentTabsEl.bordered;
|
|
172
173
|
// fix issue with active tab-title not lining up with blue indicator
|
|
173
174
|
if (this.selectedTabEl) {
|
|
174
175
|
this.updateOffsetPosition();
|
|
@@ -309,9 +310,6 @@ const TabTitle = class {
|
|
|
309
310
|
this.mutationObserver = observers.createObserver("mutation", () => this.updateHasText());
|
|
310
311
|
/** determine if there is slotted text for styling purposes */
|
|
311
312
|
this.hasText = false;
|
|
312
|
-
/**
|
|
313
|
-
* @internal
|
|
314
|
-
*/
|
|
315
313
|
this.guid = `calcite-tab-title-${guid.guid()}`;
|
|
316
314
|
}
|
|
317
315
|
activeTabChanged() {
|
|
@@ -380,15 +378,19 @@ const TabTitle = class {
|
|
|
380
378
|
//
|
|
381
379
|
//--------------------------------------------------------------------------
|
|
382
380
|
tabChangeHandler(event) {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
381
|
+
const targetTabsEl = event
|
|
382
|
+
.composedPath()
|
|
383
|
+
.find((el) => el.tagName === "CALCITE-TABS");
|
|
384
|
+
if (targetTabsEl !== this.parentTabsEl) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (this.tab) {
|
|
388
|
+
this.active = this.tab === event.detail.tab;
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
this.getTabIndex().then((index) => {
|
|
392
|
+
this.active = index === event.detail.tab;
|
|
393
|
+
});
|
|
392
394
|
}
|
|
393
395
|
}
|
|
394
396
|
onClick() {
|
|
@@ -504,14 +506,12 @@ const Tabs = class {
|
|
|
504
506
|
//
|
|
505
507
|
//--------------------------------------------------------------------------
|
|
506
508
|
/**
|
|
507
|
-
* @internal
|
|
508
509
|
*
|
|
509
510
|
* Stores an array of ids of `<calcite-tab-titles>`s to match up ARIA
|
|
510
511
|
* attributes.
|
|
511
512
|
*/
|
|
512
513
|
this.titles = [];
|
|
513
514
|
/**
|
|
514
|
-
* @internal
|
|
515
515
|
*
|
|
516
516
|
* Stores an array of ids of `<calcite-tab>`s to match up ARIA attributes.
|
|
517
517
|
*/
|
|
@@ -573,7 +573,6 @@ const Tabs = class {
|
|
|
573
573
|
//
|
|
574
574
|
//--------------------------------------------------------------------------
|
|
575
575
|
/**
|
|
576
|
-
* @internal
|
|
577
576
|
*
|
|
578
577
|
* Matches up elements from the internal `tabs` and `titles` to automatically
|
|
579
578
|
* update the ARIA attributes and link `<calcite-tab>` and
|
|
@@ -16,20 +16,23 @@ export class DatePickerMonthHeader {
|
|
|
16
16
|
* Increment year on UP/DOWN keys
|
|
17
17
|
*/
|
|
18
18
|
this.onYearKey = (e) => {
|
|
19
|
-
const
|
|
19
|
+
const localizedYear = e.target.value;
|
|
20
20
|
switch (e.key) {
|
|
21
21
|
case "ArrowDown":
|
|
22
22
|
e.preventDefault();
|
|
23
|
-
this.setYear(
|
|
23
|
+
this.setYear({ localizedYear, offset: -1 });
|
|
24
24
|
break;
|
|
25
25
|
case "ArrowUp":
|
|
26
26
|
e.preventDefault();
|
|
27
|
-
this.setYear(
|
|
27
|
+
this.setYear({ localizedYear, offset: 1 });
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
this.
|
|
32
|
-
this.setYear(event.target.value);
|
|
31
|
+
this.onYearChange = (event) => {
|
|
32
|
+
this.setYear({ localizedYear: event.target.value });
|
|
33
|
+
};
|
|
34
|
+
this.onYearInput = (event) => {
|
|
35
|
+
this.setYear({ localizedYear: event.target.value, commit: false });
|
|
33
36
|
};
|
|
34
37
|
this.prevMonthClick = (e) => {
|
|
35
38
|
this.handleArrowClick(e, this.prevMonthDate);
|
|
@@ -91,7 +94,7 @@ export class DatePickerMonthHeader {
|
|
|
91
94
|
h("input", { "aria-label": this.intlYear, class: {
|
|
92
95
|
year: true,
|
|
93
96
|
"year--suffix": !!suffix
|
|
94
|
-
}, inputmode: "numeric", maxlength: "4", minlength: "1", onInput: this.
|
|
97
|
+
}, 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 }),
|
|
95
98
|
suffix && (h("span", { class: "suffix" },
|
|
96
99
|
h("span", { "aria-hidden": "true", class: "suffix__invisible" }, localizedYear),
|
|
97
100
|
" " + suffix)))),
|
|
@@ -105,27 +108,32 @@ export class DatePickerMonthHeader {
|
|
|
105
108
|
this.nextMonthDate = dateFromRange(nextMonth(this.activeDate), this.min, this.max);
|
|
106
109
|
this.prevMonthDate = dateFromRange(prevMonth(this.activeDate), this.min, this.max);
|
|
107
110
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* set to active if in range
|
|
111
|
-
*/
|
|
112
|
-
setYear(localizedYear, increment = 0) {
|
|
113
|
-
const { min, max, activeDate, localeData, yearInput } = this;
|
|
111
|
+
getInRangeDate({ localizedYear, offset = 0 }) {
|
|
112
|
+
const { min, max, activeDate, localeData } = this;
|
|
114
113
|
const parsedYear = parseNumber(localizedYear, localeData);
|
|
115
114
|
const length = parsedYear.toString().length;
|
|
116
|
-
const year = isNaN(parsedYear) ? false : parsedYear +
|
|
115
|
+
const year = isNaN(parsedYear) ? false : parsedYear + offset;
|
|
117
116
|
const inRange = year && (!min || min.getFullYear() <= year) && (!max || max.getFullYear() >= year);
|
|
118
|
-
// if you've supplied a year and it's in range
|
|
117
|
+
// if you've supplied a year and it's in range
|
|
119
118
|
if (year && inRange && length === localizedYear.length) {
|
|
120
119
|
const nextDate = new Date(activeDate);
|
|
121
120
|
nextDate.setFullYear(year);
|
|
122
|
-
|
|
121
|
+
return dateFromRange(nextDate, min, max);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Parse localized year string from input,
|
|
126
|
+
* set to active if in range
|
|
127
|
+
*/
|
|
128
|
+
setYear({ localizedYear, commit = true, offset = 0 }) {
|
|
129
|
+
const { yearInput, activeDate, localeData } = this;
|
|
130
|
+
const inRangeDate = this.getInRangeDate({ localizedYear, offset });
|
|
131
|
+
// if you've supplied a year and it's in range, update active date
|
|
132
|
+
if (inRangeDate) {
|
|
123
133
|
this.calciteDatePickerSelect.emit(inRangeDate);
|
|
124
|
-
yearInput.value = localizeNumber(inRangeDate.getFullYear(), localeData);
|
|
125
134
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
yearInput.value = localizeNumber(activeDate.getFullYear(), localeData);
|
|
135
|
+
if (commit) {
|
|
136
|
+
yearInput.value = localizeNumber((inRangeDate || activeDate).getFullYear(), localeData);
|
|
129
137
|
}
|
|
130
138
|
}
|
|
131
139
|
static get is() { return "calcite-date-picker-month-header"; }
|