input-date-picker.js 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.82
  5. */
  6. import { Component, h, Prop, Element, Host, State, Listen, Watch, Method, Event, Build } from "@stencil/core";
  7. import { getLocaleData } from "../date-picker/utils";
  8. import { dateFromRange, inRange, dateFromISO, dateToISO, parseDateString, sameDate } from "../../utils/date";
  9. import { TEXT } from "../date-picker/resources";
  10. import { connectLabel, disconnectLabel, getLabelText } from "../../utils/label";
  11. import { connectForm, disconnectForm, HiddenFormInputSlot, submitForm } from "../../utils/form";
  12. import { createPopper, updatePopper, CSS as PopperCSS, popperMenuComputedPlacements, defaultMenuPlacement, filterComputedPlacements } from "../../utils/popper";
  13. import { updateHostInteraction } from "../../utils/interactive";
  14. import { toAriaBoolean } from "../../utils/dom";
  15. export class InputDatePicker {
  16. constructor() {
  17. //--------------------------------------------------------------------------
  18. //
  19. // Public Properties
  20. //
  21. //--------------------------------------------------------------------------
  22. /**
  23. * When false, the component won't be interactive.
  24. */
  25. this.disabled = false;
  26. /** Expand or collapse when calendar does not have input */
  27. this.active = false;
  28. /** Localized string for "previous month" (used for aria label)
  29. * @default "Previous month"
  30. */
  31. this.intlPrevMonth = TEXT.prevMonth;
  32. /** Localized string for "next month" (used for aria label)
  33. * @default "Next month"
  34. */
  35. this.intlNextMonth = TEXT.nextMonth;
  36. /** Localized string for "year" (used for aria label)
  37. * @default "Year"
  38. */
  39. this.intlYear = TEXT.year;
  40. /** BCP 47 language tag for desired language and country format */
  41. this.locale = document.documentElement.lang || "en";
  42. /** specify the scale of the date picker */
  43. this.scale = "m";
  44. /**
  45. * Determines where the date-picker component will be positioned relative to the input.
  46. * @default "bottom-leading"
  47. */
  48. this.placement = defaultMenuPlacement;
  49. /** Range mode activation */
  50. this.range = false;
  51. /**
  52. * When true, makes the component required for form-submission.
  53. *
  54. * @internal
  55. */
  56. this.required = false;
  57. /** Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value. */
  58. this.overlayPositioning = "absolute";
  59. /** Disables the default behaviour on the third click of narrowing or extending the range and instead starts a new range. */
  60. this.proximitySelectionDisabled = false;
  61. /** Layout */
  62. this.layout = "horizontal";
  63. this.focusedInput = "start";
  64. this.activeTransitionProp = "opacity";
  65. //--------------------------------------------------------------------------
  66. //
  67. // Private Methods
  68. //
  69. //--------------------------------------------------------------------------
  70. this.setFilteredPlacements = () => {
  71. const { el, flipPlacements } = this;
  72. this.filteredFlipPlacements = flipPlacements
  73. ? filterComputedPlacements(flipPlacements, el)
  74. : null;
  75. };
  76. this.transitionEnd = (event) => {
  77. if (event.propertyName === this.activeTransitionProp) {
  78. this.active
  79. ? this.calciteInputDatePickerOpen.emit()
  80. : this.calciteInputDatePickerClose.emit();
  81. }
  82. };
  83. this.setStartInput = (el) => {
  84. this.startInput = el;
  85. };
  86. this.setEndInput = (el) => {
  87. this.endInput = el;
  88. };
  89. this.deactivate = () => {
  90. this.active = false;
  91. };
  92. this.keyDownHandler = (event) => {
  93. if (event.key === "Enter" && !event.defaultPrevented) {
  94. submitForm(this);
  95. }
  96. };
  97. this.keyUpHandler = (e) => {
  98. if (e.key === "Escape") {
  99. this.active = false;
  100. }
  101. };
  102. this.inputBlur = (e) => {
  103. this.blur(e.detail);
  104. };
  105. this.startInputFocus = () => {
  106. this.active = true;
  107. this.focusedInput = "start";
  108. };
  109. this.endInputFocus = () => {
  110. this.active = true;
  111. this.focusedInput = "end";
  112. };
  113. this.inputInput = (e) => {
  114. this.input(e.detail.value);
  115. };
  116. this.setMenuEl = (el) => {
  117. if (el) {
  118. this.menuEl = el;
  119. this.createPopper();
  120. }
  121. };
  122. this.setStartWrapper = (el) => {
  123. this.startWrapper = el;
  124. this.setReferenceEl();
  125. };
  126. this.setEndWrapper = (el) => {
  127. this.endWrapper = el;
  128. this.setReferenceEl();
  129. };
  130. /**
  131. * Event handler for when the selected date changes
  132. */
  133. this.handleDateChange = (event) => {
  134. if (this.range) {
  135. return;
  136. }
  137. this.value = dateToISO(event.detail);
  138. };
  139. this.handleDateRangeChange = (event) => {
  140. var _a, _b;
  141. if (!this.range || !event.detail) {
  142. return;
  143. }
  144. const { startDate, endDate } = event.detail;
  145. this.start = dateToISO(startDate);
  146. this.end = dateToISO(endDate);
  147. this.value = [this.start, this.end];
  148. if (this.shouldFocusRangeEnd()) {
  149. (_a = this.endInput) === null || _a === void 0 ? void 0 : _a.setFocus();
  150. }
  151. else if (this.shouldFocusRangeStart()) {
  152. (_b = this.startInput) === null || _b === void 0 ? void 0 : _b.setFocus();
  153. }
  154. };
  155. }
  156. handleDisabledChange(value) {
  157. if (!value) {
  158. this.active = false;
  159. }
  160. }
  161. valueHandler(value) {
  162. if (Array.isArray(value)) {
  163. this.valueAsDate = value.map((v) => dateFromISO(v));
  164. this.start = value[0];
  165. this.end = value[1];
  166. }
  167. else if (value) {
  168. this.valueAsDate = dateFromISO(value);
  169. this.start = "";
  170. this.end = "";
  171. }
  172. else {
  173. this.valueAsDate = undefined;
  174. this.start = undefined;
  175. this.end = undefined;
  176. }
  177. }
  178. flipPlacementsHandler() {
  179. this.setFilteredPlacements();
  180. }
  181. onMinChanged(min) {
  182. if (min) {
  183. this.minAsDate = dateFromISO(min);
  184. }
  185. }
  186. onMaxChanged(max) {
  187. if (max) {
  188. this.maxAsDate = dateFromISO(max);
  189. }
  190. }
  191. activeHandler() {
  192. if (!this.disabled) {
  193. this.reposition();
  194. return;
  195. }
  196. this.active = false;
  197. }
  198. //--------------------------------------------------------------------------
  199. //
  200. // Event Listeners
  201. //
  202. //--------------------------------------------------------------------------
  203. handleDateOrRangeChange() {
  204. this.calciteInputDatePickerChange.emit();
  205. }
  206. calciteDaySelectHandler() {
  207. if (this.shouldFocusRangeStart() || this.shouldFocusRangeEnd()) {
  208. return;
  209. }
  210. this.active = false;
  211. }
  212. // --------------------------------------------------------------------------
  213. //
  214. // Public Methods
  215. //
  216. // --------------------------------------------------------------------------
  217. /** Updates the position of the component. */
  218. async setFocus() {
  219. var _a;
  220. (_a = this.startInput) === null || _a === void 0 ? void 0 : _a.setFocus();
  221. }
  222. /** Updates the position of the component. */
  223. async reposition() {
  224. const { placement, popper, menuEl } = this;
  225. const modifiers = this.getModifiers();
  226. popper
  227. ? await updatePopper({
  228. el: menuEl,
  229. modifiers,
  230. placement,
  231. popper
  232. })
  233. : this.createPopper();
  234. }
  235. // --------------------------------------------------------------------------
  236. //
  237. // Lifecycle
  238. //
  239. // --------------------------------------------------------------------------
  240. connectedCallback() {
  241. if (Array.isArray(this.value)) {
  242. this.valueAsDate = this.value.map((v) => dateFromISO(v));
  243. this.start = this.value[0];
  244. this.end = this.value[1];
  245. }
  246. else if (this.value) {
  247. this.valueAsDate = dateFromISO(this.value);
  248. this.start = "";
  249. this.end = "";
  250. }
  251. if (this.start) {
  252. this.startAsDate = dateFromISO(this.start);
  253. }
  254. if (this.end) {
  255. this.endAsDate = dateFromISO(this.end);
  256. }
  257. if (this.min) {
  258. this.minAsDate = dateFromISO(this.min);
  259. }
  260. if (this.max) {
  261. this.maxAsDate = dateFromISO(this.max);
  262. }
  263. this.createPopper();
  264. connectLabel(this);
  265. connectForm(this);
  266. this.setFilteredPlacements();
  267. }
  268. async componentWillLoad() {
  269. await this.loadLocaleData();
  270. this.onMinChanged(this.min);
  271. this.onMaxChanged(this.max);
  272. }
  273. disconnectedCallback() {
  274. this.destroyPopper();
  275. disconnectLabel(this);
  276. disconnectForm(this);
  277. }
  278. componentDidRender() {
  279. updateHostInteraction(this);
  280. }
  281. render() {
  282. var _a, _b;
  283. const { disabled } = this;
  284. const date = dateFromRange(this.range ? this.startAsDate : this.valueAsDate, this.minAsDate, this.maxAsDate);
  285. const endDate = this.range
  286. ? dateFromRange(this.endAsDate, this.minAsDate, this.maxAsDate)
  287. : null;
  288. const formattedEndDate = endDate ? endDate.toLocaleDateString(this.locale) : "";
  289. const formattedDate = date ? date.toLocaleDateString(this.locale) : "";
  290. return (h(Host, { onBlur: this.deactivate, onKeyDown: this.keyDownHandler, onKeyUp: this.keyUpHandler, role: "application" },
  291. this.localeData && (h("div", { "aria-expanded": toAriaBoolean(this.active), class: "input-container", role: "application" },
  292. h("div", { class: "input-wrapper", ref: this.setStartWrapper },
  293. h("calcite-input", { class: `input ${this.layout === "vertical" && this.range ? `no-bottom-border` : ``}`, disabled: disabled, icon: "calendar", label: getLabelText(this), "number-button-type": "none", onCalciteInputBlur: this.inputBlur, onCalciteInputFocus: this.startInputFocus, onCalciteInputInput: this.inputInput, placeholder: (_a = this.localeData) === null || _a === void 0 ? void 0 : _a.placeholder, ref: this.setStartInput, scale: this.scale, type: "text", value: formattedDate })),
  294. h("div", { "aria-hidden": toAriaBoolean(!this.active), class: {
  295. "menu-container": true,
  296. "menu-container--active": this.active
  297. }, ref: this.setMenuEl },
  298. h("div", { class: {
  299. ["calendar-picker-wrapper"]: true,
  300. ["calendar-picker-wrapper--end"]: this.focusedInput === "end",
  301. [PopperCSS.animation]: true,
  302. [PopperCSS.animationActive]: this.active
  303. }, onTransitionEnd: this.transitionEnd },
  304. h("calcite-date-picker", { activeRange: this.focusedInput, endAsDate: this.endAsDate, headingLevel: this.headingLevel, intlNextMonth: this.intlNextMonth, intlPrevMonth: this.intlPrevMonth, intlYear: this.intlYear, locale: this.locale, max: this.max, maxAsDate: this.maxAsDate, min: this.min, minAsDate: this.minAsDate, onCalciteDatePickerChange: this.handleDateChange, onCalciteDatePickerRangeChange: this.handleDateRangeChange, proximitySelectionDisabled: this.proximitySelectionDisabled, range: this.range, scale: this.scale, startAsDate: this.startAsDate, tabIndex: 0, valueAsDate: this.valueAsDate }))),
  305. this.range && this.layout === "horizontal" && (h("div", { class: "horizontal-arrow-container" },
  306. h("calcite-icon", { flipRtl: true, icon: "arrow-right", scale: "s" }))),
  307. this.range && this.layout === "vertical" && this.scale !== "s" && (h("div", { class: "vertical-arrow-container" },
  308. h("calcite-icon", { icon: "arrow-down", scale: "s" }))),
  309. this.range && (h("div", { class: "input-wrapper", ref: this.setEndWrapper },
  310. h("calcite-input", { class: {
  311. input: true,
  312. "border-top-color-one": this.layout === "vertical" && this.range
  313. }, disabled: disabled, icon: "calendar", "number-button-type": "none", onCalciteInputBlur: this.inputBlur, onCalciteInputFocus: this.endInputFocus, onCalciteInputInput: this.inputInput, placeholder: (_b = this.localeData) === null || _b === void 0 ? void 0 : _b.placeholder, ref: this.setEndInput, scale: this.scale, type: "text", value: formattedEndDate }))))),
  314. h(HiddenFormInputSlot, { component: this })));
  315. }
  316. setReferenceEl() {
  317. const { focusedInput, layout, endWrapper, startWrapper } = this;
  318. this.referenceEl =
  319. focusedInput === "end" || layout === "vertical"
  320. ? endWrapper || startWrapper
  321. : startWrapper || endWrapper;
  322. this.createPopper();
  323. }
  324. onLabelClick() {
  325. this.setFocus();
  326. }
  327. getModifiers() {
  328. const flipModifier = {
  329. name: "flip",
  330. enabled: true
  331. };
  332. flipModifier.options = {
  333. fallbackPlacements: this.filteredFlipPlacements || popperMenuComputedPlacements
  334. };
  335. const eventListenerModifier = {
  336. name: "eventListeners",
  337. enabled: this.active
  338. };
  339. return [flipModifier, eventListenerModifier];
  340. }
  341. createPopper() {
  342. this.destroyPopper();
  343. const { menuEl, placement, referenceEl, overlayPositioning } = this;
  344. if (!menuEl || !referenceEl) {
  345. return;
  346. }
  347. const modifiers = this.getModifiers();
  348. this.popper = createPopper({
  349. el: menuEl,
  350. modifiers,
  351. overlayPositioning,
  352. placement,
  353. referenceEl
  354. });
  355. }
  356. destroyPopper() {
  357. const { popper } = this;
  358. if (popper) {
  359. popper.destroy();
  360. }
  361. this.popper = null;
  362. }
  363. startWatcher(start) {
  364. this.startAsDate = dateFromISO(start);
  365. }
  366. endWatcher(end) {
  367. this.endAsDate = dateFromISO(end);
  368. }
  369. async loadLocaleData() {
  370. if (!Build.isBrowser) {
  371. return;
  372. }
  373. const { locale } = this;
  374. this.localeData = await getLocaleData(locale);
  375. }
  376. clearCurrentValue() {
  377. if (!this.range) {
  378. if (typeof this.value === "string" && this.value) {
  379. this.calciteDatePickerChange.emit();
  380. }
  381. this.value = "";
  382. return;
  383. }
  384. const { focusedInput } = this;
  385. if (focusedInput === "start") {
  386. if (this.start) {
  387. this.calciteDatePickerRangeChange.emit();
  388. }
  389. this.value = Array.isArray(this.value) ? ["", this.value[1] || ""] : [""];
  390. this.start = undefined;
  391. }
  392. else if (focusedInput === "end") {
  393. if (this.end) {
  394. this.calciteDatePickerRangeChange.emit();
  395. }
  396. this.value = Array.isArray(this.value) ? [this.value[0] || "", ""] : ["", ""];
  397. this.end = undefined;
  398. }
  399. }
  400. /**
  401. * If inputted string is a valid date, update value/active
  402. */
  403. input(value) {
  404. const date = this.getDateFromInput(value);
  405. if (!date) {
  406. this.clearCurrentValue();
  407. return;
  408. }
  409. if (!this.range) {
  410. this.value = dateToISO(date);
  411. this.calciteDatePickerChange.emit(date);
  412. return;
  413. }
  414. const { focusedInput } = this;
  415. if (focusedInput === "start") {
  416. if (!this.startAsDate || !sameDate(date, this.startAsDate)) {
  417. const startDateISO = dateToISO(date);
  418. this.value = Array.isArray(this.value)
  419. ? [startDateISO, this.value[1] || ""]
  420. : [startDateISO];
  421. this.start = startDateISO;
  422. this.calciteDatePickerRangeChange.emit({
  423. startDate: date,
  424. endDate: this.endAsDate
  425. });
  426. }
  427. }
  428. else if (focusedInput === "end") {
  429. if (!this.endAsDate || !sameDate(date, this.endAsDate)) {
  430. const endDateISO = dateToISO(date);
  431. this.value = Array.isArray(this.value)
  432. ? [this.value[0] || "", endDateISO]
  433. : ["", endDateISO];
  434. this.end = endDateISO;
  435. this.calciteDatePickerRangeChange.emit({
  436. startDate: this.startAsDate,
  437. endDate: date
  438. });
  439. }
  440. }
  441. }
  442. /**
  443. * Clean up invalid date from input on blur
  444. */
  445. blur(target) {
  446. const { locale, focusedInput, endAsDate, range, startAsDate, valueAsDate } = this;
  447. const date = this.getDateFromInput(target.value);
  448. if (!date) {
  449. if (!range && valueAsDate) {
  450. target.value = Array.isArray(valueAsDate)
  451. ? valueAsDate[focusedInput === "end" ? 1 : 0].toLocaleDateString(locale)
  452. : valueAsDate.toLocaleDateString(locale);
  453. }
  454. else if (focusedInput === "start" && startAsDate) {
  455. target.value = startAsDate.toLocaleDateString(locale);
  456. }
  457. else if (focusedInput === "end" && endAsDate) {
  458. target.value = endAsDate.toLocaleDateString(locale);
  459. }
  460. }
  461. }
  462. shouldFocusRangeStart() {
  463. return !!(this.endAsDate &&
  464. !this.startAsDate &&
  465. this.focusedInput === "end" &&
  466. this.startInput);
  467. }
  468. shouldFocusRangeEnd() {
  469. return !!(this.startAsDate &&
  470. !this.endAsDate &&
  471. this.focusedInput === "start" &&
  472. this.endInput);
  473. }
  474. /**
  475. * Find a date from input string
  476. * return false if date is invalid, or out of range
  477. */
  478. getDateFromInput(value) {
  479. if (!this.localeData) {
  480. return false;
  481. }
  482. const { separator } = this.localeData;
  483. const { day, month, year } = parseDateString(value, this.localeData);
  484. const validDay = day > 0;
  485. const validMonth = month > -1;
  486. const date = new Date(year, month, day);
  487. date.setFullYear(year);
  488. const validDate = !isNaN(date.getTime());
  489. const validLength = value.split(separator).filter((c) => c).length > 2;
  490. const validYear = year.toString().length > 0;
  491. if (validDay &&
  492. validMonth &&
  493. validDate &&
  494. validLength &&
  495. validYear &&
  496. inRange(date, this.min, this.max)) {
  497. return date;
  498. }
  499. return false;
  500. }
  501. static get is() { return "calcite-input-date-picker"; }
  502. static get encapsulation() { return "shadow"; }
  503. static get originalStyleUrls() { return {
  504. "$": ["input-date-picker.scss"]
  505. }; }
  506. static get styleUrls() { return {
  507. "$": ["input-date-picker.css"]
  508. }; }
  509. static get properties() { return {
  510. "disabled": {
  511. "type": "boolean",
  512. "mutable": false,
  513. "complexType": {
  514. "original": "boolean",
  515. "resolved": "boolean",
  516. "references": {}
  517. },
  518. "required": false,
  519. "optional": false,
  520. "docs": {
  521. "tags": [],
  522. "text": "When false, the component won't be interactive."
  523. },
  524. "attribute": "disabled",
  525. "reflect": true,
  526. "defaultValue": "false"
  527. },
  528. "value": {
  529. "type": "string",
  530. "mutable": true,
  531. "complexType": {
  532. "original": "string | string[]",
  533. "resolved": "string | string[]",
  534. "references": {}
  535. },
  536. "required": false,
  537. "optional": false,
  538. "docs": {
  539. "tags": [],
  540. "text": "Selected date"
  541. },
  542. "attribute": "value",
  543. "reflect": false
  544. },
  545. "flipPlacements": {
  546. "type": "unknown",
  547. "mutable": false,
  548. "complexType": {
  549. "original": "ComputedPlacement[]",
  550. "resolved": "ComputedPlacement[]",
  551. "references": {
  552. "ComputedPlacement": {
  553. "location": "import",
  554. "path": "../../utils/popper"
  555. }
  556. }
  557. },
  558. "required": false,
  559. "optional": true,
  560. "docs": {
  561. "tags": [],
  562. "text": "Defines the available placements that can be used when a flip occurs."
  563. }
  564. },
  565. "headingLevel": {
  566. "type": "number",
  567. "mutable": false,
  568. "complexType": {
  569. "original": "HeadingLevel",
  570. "resolved": "1 | 2 | 3 | 4 | 5 | 6",
  571. "references": {
  572. "HeadingLevel": {
  573. "location": "import",
  574. "path": "../functional/Heading"
  575. }
  576. }
  577. },
  578. "required": false,
  579. "optional": false,
  580. "docs": {
  581. "tags": [],
  582. "text": "Number at which section headings should start for this component."
  583. },
  584. "attribute": "heading-level",
  585. "reflect": false
  586. },
  587. "valueAsDate": {
  588. "type": "unknown",
  589. "mutable": true,
  590. "complexType": {
  591. "original": "Date | Date[]",
  592. "resolved": "Date | Date[]",
  593. "references": {
  594. "Date": {
  595. "location": "global"
  596. }
  597. }
  598. },
  599. "required": false,
  600. "optional": true,
  601. "docs": {
  602. "tags": [],
  603. "text": "Selected date as full date object"
  604. }
  605. },
  606. "startAsDate": {
  607. "type": "unknown",
  608. "mutable": true,
  609. "complexType": {
  610. "original": "Date",
  611. "resolved": "Date",
  612. "references": {
  613. "Date": {
  614. "location": "global"
  615. }
  616. }
  617. },
  618. "required": false,
  619. "optional": true,
  620. "docs": {
  621. "tags": [{
  622. "name": "deprecated",
  623. "text": "use valueAsDate instead"
  624. }],
  625. "text": "Selected start date as full date object"
  626. }
  627. },
  628. "endAsDate": {
  629. "type": "unknown",
  630. "mutable": true,
  631. "complexType": {
  632. "original": "Date",
  633. "resolved": "Date",
  634. "references": {
  635. "Date": {
  636. "location": "global"
  637. }
  638. }
  639. },
  640. "required": false,
  641. "optional": true,
  642. "docs": {
  643. "tags": [{
  644. "name": "deprecated",
  645. "text": "use valueAsDate instead"
  646. }],
  647. "text": "Selected end date as full date object"
  648. }
  649. },
  650. "minAsDate": {
  651. "type": "unknown",
  652. "mutable": true,
  653. "complexType": {
  654. "original": "Date",
  655. "resolved": "Date",
  656. "references": {
  657. "Date": {
  658. "location": "global"
  659. }
  660. }
  661. },
  662. "required": false,
  663. "optional": true,
  664. "docs": {
  665. "tags": [],
  666. "text": "Earliest allowed date as full date object"
  667. }
  668. },
  669. "maxAsDate": {
  670. "type": "unknown",
  671. "mutable": true,
  672. "complexType": {
  673. "original": "Date",
  674. "resolved": "Date",
  675. "references": {
  676. "Date": {
  677. "location": "global"
  678. }
  679. }
  680. },
  681. "required": false,
  682. "optional": true,
  683. "docs": {
  684. "tags": [],
  685. "text": "Latest allowed date as full date object"
  686. }
  687. },
  688. "min": {
  689. "type": "string",
  690. "mutable": true,
  691. "complexType": {
  692. "original": "string",
  693. "resolved": "string",
  694. "references": {}
  695. },
  696. "required": false,
  697. "optional": true,
  698. "docs": {
  699. "tags": [],
  700. "text": "Earliest allowed date (\"yyyy-mm-dd\")"
  701. },
  702. "attribute": "min",
  703. "reflect": false
  704. },
  705. "max": {
  706. "type": "string",
  707. "mutable": true,
  708. "complexType": {
  709. "original": "string",
  710. "resolved": "string",
  711. "references": {}
  712. },
  713. "required": false,
  714. "optional": true,
  715. "docs": {
  716. "tags": [],
  717. "text": "Latest allowed date (\"yyyy-mm-dd\")"
  718. },
  719. "attribute": "max",
  720. "reflect": false
  721. },
  722. "active": {
  723. "type": "boolean",
  724. "mutable": true,
  725. "complexType": {
  726. "original": "boolean",
  727. "resolved": "boolean",
  728. "references": {}
  729. },
  730. "required": false,
  731. "optional": false,
  732. "docs": {
  733. "tags": [],
  734. "text": "Expand or collapse when calendar does not have input"
  735. },
  736. "attribute": "active",
  737. "reflect": true,
  738. "defaultValue": "false"
  739. },
  740. "name": {
  741. "type": "string",
  742. "mutable": false,
  743. "complexType": {
  744. "original": "string",
  745. "resolved": "string",
  746. "references": {}
  747. },
  748. "required": false,
  749. "optional": false,
  750. "docs": {
  751. "tags": [],
  752. "text": "The picker's name. Gets submitted with the form."
  753. },
  754. "attribute": "name",
  755. "reflect": false
  756. },
  757. "intlPrevMonth": {
  758. "type": "string",
  759. "mutable": false,
  760. "complexType": {
  761. "original": "string",
  762. "resolved": "string",
  763. "references": {}
  764. },
  765. "required": false,
  766. "optional": true,
  767. "docs": {
  768. "tags": [{
  769. "name": "default",
  770. "text": "\"Previous month\""
  771. }],
  772. "text": "Localized string for \"previous month\" (used for aria label)"
  773. },
  774. "attribute": "intl-prev-month",
  775. "reflect": false,
  776. "defaultValue": "TEXT.prevMonth"
  777. },
  778. "intlNextMonth": {
  779. "type": "string",
  780. "mutable": false,
  781. "complexType": {
  782. "original": "string",
  783. "resolved": "string",
  784. "references": {}
  785. },
  786. "required": false,
  787. "optional": true,
  788. "docs": {
  789. "tags": [{
  790. "name": "default",
  791. "text": "\"Next month\""
  792. }],
  793. "text": "Localized string for \"next month\" (used for aria label)"
  794. },
  795. "attribute": "intl-next-month",
  796. "reflect": false,
  797. "defaultValue": "TEXT.nextMonth"
  798. },
  799. "intlYear": {
  800. "type": "string",
  801. "mutable": false,
  802. "complexType": {
  803. "original": "string",
  804. "resolved": "string",
  805. "references": {}
  806. },
  807. "required": false,
  808. "optional": true,
  809. "docs": {
  810. "tags": [{
  811. "name": "default",
  812. "text": "\"Year\""
  813. }],
  814. "text": "Localized string for \"year\" (used for aria label)"
  815. },
  816. "attribute": "intl-year",
  817. "reflect": false,
  818. "defaultValue": "TEXT.year"
  819. },
  820. "locale": {
  821. "type": "string",
  822. "mutable": false,
  823. "complexType": {
  824. "original": "string",
  825. "resolved": "string",
  826. "references": {}
  827. },
  828. "required": false,
  829. "optional": true,
  830. "docs": {
  831. "tags": [],
  832. "text": "BCP 47 language tag for desired language and country format"
  833. },
  834. "attribute": "locale",
  835. "reflect": false,
  836. "defaultValue": "document.documentElement.lang || \"en\""
  837. },
  838. "scale": {
  839. "type": "string",
  840. "mutable": false,
  841. "complexType": {
  842. "original": "\"s\" | \"m\" | \"l\"",
  843. "resolved": "\"l\" | \"m\" | \"s\"",
  844. "references": {}
  845. },
  846. "required": false,
  847. "optional": false,
  848. "docs": {
  849. "tags": [],
  850. "text": "specify the scale of the date picker"
  851. },
  852. "attribute": "scale",
  853. "reflect": true,
  854. "defaultValue": "\"m\""
  855. },
  856. "placement": {
  857. "type": "string",
  858. "mutable": false,
  859. "complexType": {
  860. "original": "MenuPlacement",
  861. "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-leading\" | \"bottom-start\" | \"bottom-trailing\" | \"top\" | \"top-end\" | \"top-leading\" | \"top-start\" | \"top-trailing\"",
  862. "references": {
  863. "MenuPlacement": {
  864. "location": "import",
  865. "path": "../../utils/popper"
  866. }
  867. }
  868. },
  869. "required": false,
  870. "optional": false,
  871. "docs": {
  872. "tags": [{
  873. "name": "default",
  874. "text": "\"bottom-leading\""
  875. }],
  876. "text": "Determines where the date-picker component will be positioned relative to the input."
  877. },
  878. "attribute": "placement",
  879. "reflect": true,
  880. "defaultValue": "defaultMenuPlacement"
  881. },
  882. "range": {
  883. "type": "boolean",
  884. "mutable": false,
  885. "complexType": {
  886. "original": "boolean",
  887. "resolved": "boolean",
  888. "references": {}
  889. },
  890. "required": false,
  891. "optional": false,
  892. "docs": {
  893. "tags": [],
  894. "text": "Range mode activation"
  895. },
  896. "attribute": "range",
  897. "reflect": true,
  898. "defaultValue": "false"
  899. },
  900. "required": {
  901. "type": "boolean",
  902. "mutable": false,
  903. "complexType": {
  904. "original": "boolean",
  905. "resolved": "boolean",
  906. "references": {}
  907. },
  908. "required": false,
  909. "optional": false,
  910. "docs": {
  911. "tags": [{
  912. "name": "internal",
  913. "text": undefined
  914. }],
  915. "text": "When true, makes the component required for form-submission."
  916. },
  917. "attribute": "required",
  918. "reflect": true,
  919. "defaultValue": "false"
  920. },
  921. "start": {
  922. "type": "string",
  923. "mutable": true,
  924. "complexType": {
  925. "original": "string",
  926. "resolved": "string",
  927. "references": {}
  928. },
  929. "required": false,
  930. "optional": true,
  931. "docs": {
  932. "tags": [{
  933. "name": "deprecated",
  934. "text": "use value instead"
  935. }],
  936. "text": "Selected start date"
  937. },
  938. "attribute": "start",
  939. "reflect": false
  940. },
  941. "end": {
  942. "type": "string",
  943. "mutable": true,
  944. "complexType": {
  945. "original": "string",
  946. "resolved": "string",
  947. "references": {}
  948. },
  949. "required": false,
  950. "optional": true,
  951. "docs": {
  952. "tags": [{
  953. "name": "deprecated",
  954. "text": "use value instead"
  955. }],
  956. "text": "Selected end date"
  957. },
  958. "attribute": "end",
  959. "reflect": false
  960. },
  961. "overlayPositioning": {
  962. "type": "string",
  963. "mutable": false,
  964. "complexType": {
  965. "original": "OverlayPositioning",
  966. "resolved": "\"absolute\" | \"fixed\"",
  967. "references": {
  968. "OverlayPositioning": {
  969. "location": "import",
  970. "path": "../../utils/popper"
  971. }
  972. }
  973. },
  974. "required": false,
  975. "optional": false,
  976. "docs": {
  977. "tags": [],
  978. "text": "Describes the type of positioning to use for the overlaid content. If your element is in a fixed container, use the 'fixed' value."
  979. },
  980. "attribute": "overlay-positioning",
  981. "reflect": false,
  982. "defaultValue": "\"absolute\""
  983. },
  984. "proximitySelectionDisabled": {
  985. "type": "boolean",
  986. "mutable": false,
  987. "complexType": {
  988. "original": "boolean",
  989. "resolved": "boolean",
  990. "references": {}
  991. },
  992. "required": false,
  993. "optional": false,
  994. "docs": {
  995. "tags": [],
  996. "text": "Disables the default behaviour on the third click of narrowing or extending the range and instead starts a new range."
  997. },
  998. "attribute": "proximity-selection-disabled",
  999. "reflect": false,
  1000. "defaultValue": "false"
  1001. },
  1002. "layout": {
  1003. "type": "string",
  1004. "mutable": false,
  1005. "complexType": {
  1006. "original": "\"horizontal\" | \"vertical\"",
  1007. "resolved": "\"horizontal\" | \"vertical\"",
  1008. "references": {}
  1009. },
  1010. "required": false,
  1011. "optional": false,
  1012. "docs": {
  1013. "tags": [],
  1014. "text": "Layout"
  1015. },
  1016. "attribute": "layout",
  1017. "reflect": true,
  1018. "defaultValue": "\"horizontal\""
  1019. }
  1020. }; }
  1021. static get states() { return {
  1022. "focusedInput": {},
  1023. "localeData": {}
  1024. }; }
  1025. static get events() { return [{
  1026. "method": "calciteDatePickerChange",
  1027. "name": "calciteDatePickerChange",
  1028. "bubbles": true,
  1029. "cancelable": true,
  1030. "composed": true,
  1031. "docs": {
  1032. "tags": [{
  1033. "name": "deprecated",
  1034. "text": "use `calciteInputDatePickerChange` instead."
  1035. }],
  1036. "text": "Trigger calcite date change when a user changes the date."
  1037. },
  1038. "complexType": {
  1039. "original": "Date",
  1040. "resolved": "Date",
  1041. "references": {
  1042. "Date": {
  1043. "location": "global"
  1044. }
  1045. }
  1046. }
  1047. }, {
  1048. "method": "calciteDatePickerRangeChange",
  1049. "name": "calciteDatePickerRangeChange",
  1050. "bubbles": true,
  1051. "cancelable": true,
  1052. "composed": true,
  1053. "docs": {
  1054. "tags": [{
  1055. "name": "see",
  1056. "text": "[DateRangeChange](https://github.com/Esri/calcite-components/blob/master/src/components/calcite-date-picker/interfaces.ts#L1)"
  1057. }, {
  1058. "name": "deprecated",
  1059. "text": "use `calciteInputDatePickerChange` instead."
  1060. }],
  1061. "text": "Trigger calcite date change when a user changes the date range."
  1062. },
  1063. "complexType": {
  1064. "original": "DateRangeChange",
  1065. "resolved": "DateRangeChange",
  1066. "references": {
  1067. "DateRangeChange": {
  1068. "location": "import",
  1069. "path": "../date-picker/interfaces"
  1070. }
  1071. }
  1072. }
  1073. }, {
  1074. "method": "calciteInputDatePickerChange",
  1075. "name": "calciteInputDatePickerChange",
  1076. "bubbles": true,
  1077. "cancelable": true,
  1078. "composed": true,
  1079. "docs": {
  1080. "tags": [],
  1081. "text": "This event fires when the input date picker value changes."
  1082. },
  1083. "complexType": {
  1084. "original": "void",
  1085. "resolved": "void",
  1086. "references": {}
  1087. }
  1088. }, {
  1089. "method": "calciteInputDatePickerOpen",
  1090. "name": "calciteInputDatePickerOpen",
  1091. "bubbles": true,
  1092. "cancelable": true,
  1093. "composed": true,
  1094. "docs": {
  1095. "tags": [{
  1096. "name": "internal",
  1097. "text": undefined
  1098. }],
  1099. "text": ""
  1100. },
  1101. "complexType": {
  1102. "original": "any",
  1103. "resolved": "any",
  1104. "references": {}
  1105. }
  1106. }, {
  1107. "method": "calciteInputDatePickerClose",
  1108. "name": "calciteInputDatePickerClose",
  1109. "bubbles": true,
  1110. "cancelable": true,
  1111. "composed": true,
  1112. "docs": {
  1113. "tags": [{
  1114. "name": "internal",
  1115. "text": undefined
  1116. }],
  1117. "text": ""
  1118. },
  1119. "complexType": {
  1120. "original": "any",
  1121. "resolved": "any",
  1122. "references": {}
  1123. }
  1124. }]; }
  1125. static get methods() { return {
  1126. "setFocus": {
  1127. "complexType": {
  1128. "signature": "() => Promise<void>",
  1129. "parameters": [],
  1130. "references": {
  1131. "Promise": {
  1132. "location": "global"
  1133. }
  1134. },
  1135. "return": "Promise<void>"
  1136. },
  1137. "docs": {
  1138. "text": "Updates the position of the component.",
  1139. "tags": []
  1140. }
  1141. },
  1142. "reposition": {
  1143. "complexType": {
  1144. "signature": "() => Promise<void>",
  1145. "parameters": [],
  1146. "references": {
  1147. "Promise": {
  1148. "location": "global"
  1149. }
  1150. },
  1151. "return": "Promise<void>"
  1152. },
  1153. "docs": {
  1154. "text": "Updates the position of the component.",
  1155. "tags": []
  1156. }
  1157. }
  1158. }; }
  1159. static get elementRef() { return "el"; }
  1160. static get watchers() { return [{
  1161. "propName": "disabled",
  1162. "methodName": "handleDisabledChange"
  1163. }, {
  1164. "propName": "value",
  1165. "methodName": "valueHandler"
  1166. }, {
  1167. "propName": "flipPlacements",
  1168. "methodName": "flipPlacementsHandler"
  1169. }, {
  1170. "propName": "min",
  1171. "methodName": "onMinChanged"
  1172. }, {
  1173. "propName": "max",
  1174. "methodName": "onMaxChanged"
  1175. }, {
  1176. "propName": "active",
  1177. "methodName": "activeHandler"
  1178. }, {
  1179. "propName": "layout",
  1180. "methodName": "setReferenceEl"
  1181. }, {
  1182. "propName": "focusedInput",
  1183. "methodName": "setReferenceEl"
  1184. }, {
  1185. "propName": "start",
  1186. "methodName": "startWatcher"
  1187. }, {
  1188. "propName": "end",
  1189. "methodName": "endWatcher"
  1190. }, {
  1191. "propName": "locale",
  1192. "methodName": "loadLocaleData"
  1193. }]; }
  1194. static get listeners() { return [{
  1195. "name": "calciteDatePickerChange",
  1196. "method": "handleDateOrRangeChange",
  1197. "target": undefined,
  1198. "capture": false,
  1199. "passive": false
  1200. }, {
  1201. "name": "calciteDatePickerRangeChange",
  1202. "method": "handleDateOrRangeChange",
  1203. "target": undefined,
  1204. "capture": false,
  1205. "passive": false
  1206. }, {
  1207. "name": "calciteDaySelect",
  1208. "method": "calciteDaySelectHandler",
  1209. "target": undefined,
  1210. "capture": false,
  1211. "passive": false
  1212. }]; }
  1213. }