@ionic/core 7.6.6-dev.11705528328.1ef5e17b → 7.6.6-dev.11705595500.109bc77e

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.
@@ -689,22 +689,41 @@ const Datetime = /*@__PURE__*/ proxyCustomElement(class Datetime extends HTMLEle
689
689
  const didChangeMonth = (month !== undefined && month !== workingParts.month) || (year !== undefined && year !== workingParts.year);
690
690
  const bodyIsVisible = el.classList.contains('datetime-ready');
691
691
  const { isGridStyle, showMonthAndYear } = this;
692
- if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
693
- this.animateToDate(targetValue);
692
+ let areAllSelectedDatesInSameMonth = true;
693
+ if (Array.isArray(valueToProcess)) {
694
+ const firstMonth = valueToProcess[0].month;
695
+ for (const date of valueToProcess) {
696
+ if (date.month !== firstMonth) {
697
+ areAllSelectedDatesInSameMonth = false;
698
+ break;
699
+ }
700
+ }
694
701
  }
695
- else {
696
- /**
697
- * We only need to do this if we didn't just animate to a new month,
698
- * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
699
- */
700
- this.setWorkingParts({
701
- month,
702
- day,
703
- year,
704
- hour,
705
- minute,
706
- ampm,
707
- });
702
+ /**
703
+ * If there is more than one date selected
704
+ * and the dates aren't all in the same month,
705
+ * then we should neither animate to the date
706
+ * nor update the working parts because we do
707
+ * not know which date the user wants to view.
708
+ */
709
+ if (areAllSelectedDatesInSameMonth) {
710
+ if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
711
+ this.animateToDate(targetValue);
712
+ }
713
+ else {
714
+ /**
715
+ * We only need to do this if we didn't just animate to a new month,
716
+ * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
717
+ */
718
+ this.setWorkingParts({
719
+ month,
720
+ day,
721
+ year,
722
+ hour,
723
+ minute,
724
+ ampm,
725
+ });
726
+ }
708
727
  }
709
728
  };
710
729
  this.animateToDate = async (targetValue) => {
@@ -472,22 +472,7 @@ const PickerInternal = /*@__PURE__*/ proxyCustomElement(class PickerInternal ext
472
472
  this.emitInputModeChange();
473
473
  }
474
474
  render() {
475
- return (h(Host, { onPointerDown: (ev) => this.onPointerDown(ev), onClick: () => this.onClick() }, h("input", { "aria-hidden": "true", tabindex: -1, inputmode: "numeric", type: "number", onKeyDown: (ev) => {
476
- var _a;
477
- /**
478
- * The "Enter" key represents
479
- * the user submitting their time
480
- * selection, so we should blur the
481
- * input (and therefore close the keyboard)
482
- *
483
- * Updating the picker's state to no longer
484
- * be in input mode is handled in the onBlur
485
- * callback below.
486
- */
487
- if (ev.key === 'Enter') {
488
- (_a = this.inputEl) === null || _a === void 0 ? void 0 : _a.blur();
489
- }
490
- }, ref: (el) => (this.inputEl = el), onInput: () => this.onInputChange(), onBlur: () => this.exitInputMode() }), h("div", { class: "picker-before" }), h("div", { class: "picker-after" }), h("div", { class: "picker-highlight", ref: (el) => (this.highlightEl = el) }), h("slot", null)));
475
+ return (h(Host, { onPointerDown: (ev) => this.onPointerDown(ev), onClick: () => this.onClick() }, h("input", { "aria-hidden": "true", tabindex: -1, inputmode: "numeric", type: "number", ref: (el) => (this.inputEl = el), onInput: () => this.onInputChange(), onBlur: () => this.exitInputMode() }), h("div", { class: "picker-before" }), h("div", { class: "picker-after" }), h("div", { class: "picker-highlight", ref: (el) => (this.highlightEl = el) }), h("slot", null)));
491
476
  }
492
477
  get el() { return this; }
493
478
  static get style() { return {
@@ -688,22 +688,41 @@ const Datetime = class {
688
688
  const didChangeMonth = (month !== undefined && month !== workingParts.month) || (year !== undefined && year !== workingParts.year);
689
689
  const bodyIsVisible = el.classList.contains('datetime-ready');
690
690
  const { isGridStyle, showMonthAndYear } = this;
691
- if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
692
- this.animateToDate(targetValue);
691
+ let areAllSelectedDatesInSameMonth = true;
692
+ if (Array.isArray(valueToProcess)) {
693
+ const firstMonth = valueToProcess[0].month;
694
+ for (const date of valueToProcess) {
695
+ if (date.month !== firstMonth) {
696
+ areAllSelectedDatesInSameMonth = false;
697
+ break;
698
+ }
699
+ }
693
700
  }
694
- else {
695
- /**
696
- * We only need to do this if we didn't just animate to a new month,
697
- * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
698
- */
699
- this.setWorkingParts({
700
- month,
701
- day,
702
- year,
703
- hour,
704
- minute,
705
- ampm,
706
- });
701
+ /**
702
+ * If there is more than one date selected
703
+ * and the dates aren't all in the same month,
704
+ * then we should neither animate to the date
705
+ * nor update the working parts because we do
706
+ * not know which date the user wants to view.
707
+ */
708
+ if (areAllSelectedDatesInSameMonth) {
709
+ if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
710
+ this.animateToDate(targetValue);
711
+ }
712
+ else {
713
+ /**
714
+ * We only need to do this if we didn't just animate to a new month,
715
+ * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
716
+ */
717
+ this.setWorkingParts({
718
+ month,
719
+ day,
720
+ year,
721
+ hour,
722
+ minute,
723
+ ampm,
724
+ });
725
+ }
707
726
  }
708
727
  };
709
728
  this.animateToDate = async (targetValue) => {
@@ -474,22 +474,7 @@ const PickerInternal = class {
474
474
  this.emitInputModeChange();
475
475
  }
476
476
  render() {
477
- return (index.h(index.Host, { onPointerDown: (ev) => this.onPointerDown(ev), onClick: () => this.onClick() }, index.h("input", { "aria-hidden": "true", tabindex: -1, inputmode: "numeric", type: "number", onKeyDown: (ev) => {
478
- var _a;
479
- /**
480
- * The "Enter" key represents
481
- * the user submitting their time
482
- * selection, so we should blur the
483
- * input (and therefore close the keyboard)
484
- *
485
- * Updating the picker's state to no longer
486
- * be in input mode is handled in the onBlur
487
- * callback below.
488
- */
489
- if (ev.key === 'Enter') {
490
- (_a = this.inputEl) === null || _a === void 0 ? void 0 : _a.blur();
491
- }
492
- }, ref: (el) => (this.inputEl = el), onInput: () => this.onInputChange(), onBlur: () => this.exitInputMode() }), index.h("div", { class: "picker-before" }), index.h("div", { class: "picker-after" }), index.h("div", { class: "picker-highlight", ref: (el) => (this.highlightEl = el) }), index.h("slot", null)));
477
+ return (index.h(index.Host, { onPointerDown: (ev) => this.onPointerDown(ev), onClick: () => this.onClick() }, index.h("input", { "aria-hidden": "true", tabindex: -1, inputmode: "numeric", type: "number", ref: (el) => (this.inputEl = el), onInput: () => this.onInputChange(), onBlur: () => this.exitInputMode() }), index.h("div", { class: "picker-before" }), index.h("div", { class: "picker-after" }), index.h("div", { class: "picker-highlight", ref: (el) => (this.highlightEl = el) }), index.h("slot", null)));
493
478
  }
494
479
  get el() { return index.getElement(this); }
495
480
  };
@@ -526,22 +526,41 @@ export class Datetime {
526
526
  const didChangeMonth = (month !== undefined && month !== workingParts.month) || (year !== undefined && year !== workingParts.year);
527
527
  const bodyIsVisible = el.classList.contains('datetime-ready');
528
528
  const { isGridStyle, showMonthAndYear } = this;
529
- if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
530
- this.animateToDate(targetValue);
529
+ let areAllSelectedDatesInSameMonth = true;
530
+ if (Array.isArray(valueToProcess)) {
531
+ const firstMonth = valueToProcess[0].month;
532
+ for (const date of valueToProcess) {
533
+ if (date.month !== firstMonth) {
534
+ areAllSelectedDatesInSameMonth = false;
535
+ break;
536
+ }
537
+ }
531
538
  }
532
- else {
533
- /**
534
- * We only need to do this if we didn't just animate to a new month,
535
- * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
536
- */
537
- this.setWorkingParts({
538
- month,
539
- day,
540
- year,
541
- hour,
542
- minute,
543
- ampm,
544
- });
539
+ /**
540
+ * If there is more than one date selected
541
+ * and the dates aren't all in the same month,
542
+ * then we should neither animate to the date
543
+ * nor update the working parts because we do
544
+ * not know which date the user wants to view.
545
+ */
546
+ if (areAllSelectedDatesInSameMonth) {
547
+ if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
548
+ this.animateToDate(targetValue);
549
+ }
550
+ else {
551
+ /**
552
+ * We only need to do this if we didn't just animate to a new month,
553
+ * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
554
+ */
555
+ this.setWorkingParts({
556
+ month,
557
+ day,
558
+ year,
559
+ hour,
560
+ minute,
561
+ ampm,
562
+ });
563
+ }
545
564
  }
546
565
  };
547
566
  this.animateToDate = async (targetValue) => {
@@ -5,7 +5,7 @@ import { expect } from "@playwright/test";
5
5
  import { configs, test } from "../../../../utils/test/playwright/index";
6
6
  const SINGLE_DATE = '2022-06-01';
7
7
  const MULTIPLE_DATES = ['2022-06-01', '2022-06-02', '2022-06-03'];
8
- const MULTIPLE_DATES_SEPARATE_MONTHS = ['2022-04-01', '2022-05-01', '2022-06-01'];
8
+ const MULTIPLE_DATES_SEPARATE_MONTHS = ['2022-03-01', '2022-04-01', '2022-05-01'];
9
9
  class DatetimeMultipleFixture {
10
10
  constructor(page) {
11
11
  this.page = page;
@@ -118,10 +118,14 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
118
118
  value: ['2022-06-01', '2022-06-02'],
119
119
  });
120
120
  });
121
- test('multiple default values across months should display at least one value', async () => {
122
- const datetime = await datetimeFixture.goto(config, MULTIPLE_DATES_SEPARATE_MONTHS);
121
+ test('should not scroll to new month when value is updated with dates in different months', async ({ page }) => {
122
+ const datetime = await datetimeFixture.goto(config, MULTIPLE_DATES);
123
+ await datetime.evaluate((el, dates) => {
124
+ el.value = dates;
125
+ }, MULTIPLE_DATES_SEPARATE_MONTHS);
126
+ await page.waitForChanges();
123
127
  const monthYear = datetime.locator('.calendar-month-year');
124
- await expect(monthYear).toHaveText(/April 2022/);
128
+ await expect(monthYear).toHaveText(/June 2022/);
125
129
  });
126
130
  test('with buttons, should only update value when confirm is called', async ({ page }) => {
127
131
  const datetime = await datetimeFixture.goto(config, SINGLE_DATE, { showDefaultButtons: true });
@@ -467,22 +467,7 @@ export class PickerInternal {
467
467
  this.emitInputModeChange();
468
468
  }
469
469
  render() {
470
- return (h(Host, { onPointerDown: (ev) => this.onPointerDown(ev), onClick: () => this.onClick() }, h("input", { "aria-hidden": "true", tabindex: -1, inputmode: "numeric", type: "number", onKeyDown: (ev) => {
471
- var _a;
472
- /**
473
- * The "Enter" key represents
474
- * the user submitting their time
475
- * selection, so we should blur the
476
- * input (and therefore close the keyboard)
477
- *
478
- * Updating the picker's state to no longer
479
- * be in input mode is handled in the onBlur
480
- * callback below.
481
- */
482
- if (ev.key === 'Enter') {
483
- (_a = this.inputEl) === null || _a === void 0 ? void 0 : _a.blur();
484
- }
485
- }, ref: (el) => (this.inputEl = el), onInput: () => this.onInputChange(), onBlur: () => this.exitInputMode() }), h("div", { class: "picker-before" }), h("div", { class: "picker-after" }), h("div", { class: "picker-highlight", ref: (el) => (this.highlightEl = el) }), h("slot", null)));
470
+ return (h(Host, { onPointerDown: (ev) => this.onPointerDown(ev), onClick: () => this.onClick() }, h("input", { "aria-hidden": "true", tabindex: -1, inputmode: "numeric", type: "number", ref: (el) => (this.inputEl = el), onInput: () => this.onInputChange(), onBlur: () => this.exitInputMode() }), h("div", { class: "picker-before" }), h("div", { class: "picker-after" }), h("div", { class: "picker-highlight", ref: (el) => (this.highlightEl = el) }), h("slot", null)));
486
471
  }
487
472
  static get is() { return "ion-picker-internal"; }
488
473
  static get encapsulation() { return "shadow"; }
@@ -110,37 +110,5 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
110
110
  await expect(ionChange).toHaveReceivedEventDetail({ text: '00', value: 12 });
111
111
  await expect(column).toHaveJSProperty('value', 12);
112
112
  });
113
- test('pressing Enter should dismiss the keyboard', async ({ page }) => {
114
- test.info().annotations.push({
115
- type: 'issue',
116
- description: 'https://github.com/ionic-team/ionic-framework/issues/28325',
117
- });
118
- await page.setContent(`
119
- <ion-picker-internal>
120
- <ion-picker-column-internal></ion-picker-column-internal>
121
- </ion-picker-internal>
122
-
123
- <script>
124
- const column = document.querySelector('ion-picker-column-internal');
125
- column.items = [
126
- { text: '00', value: 12 },
127
- { text: '01', value: 1 },
128
- { text: '02', value: 2 },
129
- { text: '03', value: 3 },
130
- { text: '04', value: 4 },
131
- { text: '05', value: 5 }
132
- ];
133
- column.value = 5;
134
- column.numericInput = true;
135
- </script>
136
- `, config);
137
- const column = page.locator('ion-picker-column-internal');
138
- await column.click();
139
- const input = page.locator('ion-picker-internal input');
140
- await expect(input).toBeFocused();
141
- // pressing Enter should blur the input and therefore close the keyboard
142
- await page.keyboard.press('Enter');
143
- await expect(input).not.toBeFocused();
144
- });
145
113
  });
146
114
  });
package/dist/docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "timestamp": "2024-01-17T21:54:00",
2
+ "timestamp": "2024-01-18T16:33:41",
3
3
  "compiler": {
4
4
  "name": "@stencil/core",
5
5
  "version": "4.10.0",
@@ -684,22 +684,41 @@ const Datetime = class {
684
684
  const didChangeMonth = (month !== undefined && month !== workingParts.month) || (year !== undefined && year !== workingParts.year);
685
685
  const bodyIsVisible = el.classList.contains('datetime-ready');
686
686
  const { isGridStyle, showMonthAndYear } = this;
687
- if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
688
- this.animateToDate(targetValue);
687
+ let areAllSelectedDatesInSameMonth = true;
688
+ if (Array.isArray(valueToProcess)) {
689
+ const firstMonth = valueToProcess[0].month;
690
+ for (const date of valueToProcess) {
691
+ if (date.month !== firstMonth) {
692
+ areAllSelectedDatesInSameMonth = false;
693
+ break;
694
+ }
695
+ }
689
696
  }
690
- else {
691
- /**
692
- * We only need to do this if we didn't just animate to a new month,
693
- * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
694
- */
695
- this.setWorkingParts({
696
- month,
697
- day,
698
- year,
699
- hour,
700
- minute,
701
- ampm,
702
- });
697
+ /**
698
+ * If there is more than one date selected
699
+ * and the dates aren't all in the same month,
700
+ * then we should neither animate to the date
701
+ * nor update the working parts because we do
702
+ * not know which date the user wants to view.
703
+ */
704
+ if (areAllSelectedDatesInSameMonth) {
705
+ if (isGridStyle && didChangeMonth && bodyIsVisible && !showMonthAndYear) {
706
+ this.animateToDate(targetValue);
707
+ }
708
+ else {
709
+ /**
710
+ * We only need to do this if we didn't just animate to a new month,
711
+ * since that calls prevMonth/nextMonth which calls setWorkingParts for us.
712
+ */
713
+ this.setWorkingParts({
714
+ month,
715
+ day,
716
+ year,
717
+ hour,
718
+ minute,
719
+ ampm,
720
+ });
721
+ }
703
722
  }
704
723
  };
705
724
  this.animateToDate = async (targetValue) => {
@@ -470,22 +470,7 @@ const PickerInternal = class {
470
470
  this.emitInputModeChange();
471
471
  }
472
472
  render() {
473
- return (h(Host, { onPointerDown: (ev) => this.onPointerDown(ev), onClick: () => this.onClick() }, h("input", { "aria-hidden": "true", tabindex: -1, inputmode: "numeric", type: "number", onKeyDown: (ev) => {
474
- var _a;
475
- /**
476
- * The "Enter" key represents
477
- * the user submitting their time
478
- * selection, so we should blur the
479
- * input (and therefore close the keyboard)
480
- *
481
- * Updating the picker's state to no longer
482
- * be in input mode is handled in the onBlur
483
- * callback below.
484
- */
485
- if (ev.key === 'Enter') {
486
- (_a = this.inputEl) === null || _a === void 0 ? void 0 : _a.blur();
487
- }
488
- }, ref: (el) => (this.inputEl = el), onInput: () => this.onInputChange(), onBlur: () => this.exitInputMode() }), h("div", { class: "picker-before" }), h("div", { class: "picker-after" }), h("div", { class: "picker-highlight", ref: (el) => (this.highlightEl = el) }), h("slot", null)));
473
+ return (h(Host, { onPointerDown: (ev) => this.onPointerDown(ev), onClick: () => this.onClick() }, h("input", { "aria-hidden": "true", tabindex: -1, inputmode: "numeric", type: "number", ref: (el) => (this.inputEl = el), onInput: () => this.onInputChange(), onBlur: () => this.exitInputMode() }), h("div", { class: "picker-before" }), h("div", { class: "picker-after" }), h("div", { class: "picker-highlight", ref: (el) => (this.highlightEl = el) }), h("slot", null)));
489
474
  }
490
475
  get el() { return getElement(this); }
491
476
  };