date-picker.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  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.97
  5. */
  6. import { h, Host, Build } from "@stencil/core";
  7. import { getLocaleData, getValueAsDateRange } from "./utils";
  8. import { dateFromRange, dateFromISO, dateToISO, getDaysDiff, setEndOfDay } from "../../utils/date";
  9. import { HEADING_LEVEL, TEXT } from "./resources";
  10. import { connectLocalized, disconnectLocalized, numberStringFormatter } from "../../utils/locale";
  11. export class DatePicker {
  12. constructor() {
  13. /**
  14. * Localized string for "previous month" (used for aria label)
  15. *
  16. * @default "Previous month"
  17. */
  18. this.intlPrevMonth = TEXT.prevMonth;
  19. /**
  20. * Localized string for "next month" (used for aria label)
  21. *
  22. * @default "Next month"
  23. */
  24. this.intlNextMonth = TEXT.nextMonth;
  25. /**
  26. * Localized string for "year" (used for aria label)
  27. *
  28. * @default "Year"
  29. */
  30. this.intlYear = TEXT.year;
  31. /** specify the scale of the date picker */
  32. this.scale = "m";
  33. /** Range mode activation */
  34. this.range = false;
  35. /** Disables the default behaviour on the third click of narrowing or extending the range and instead starts a new range. */
  36. this.proximitySelectionDisabled = false;
  37. this.globalAttributes = {};
  38. //--------------------------------------------------------------------------
  39. //
  40. // Private State/Props
  41. //
  42. //--------------------------------------------------------------------------
  43. this.effectiveLocale = "";
  44. //--------------------------------------------------------------------------
  45. //
  46. // Private Methods
  47. //
  48. //--------------------------------------------------------------------------
  49. this.keyDownHandler = (event) => {
  50. if (event.key === "Escape") {
  51. this.reset();
  52. }
  53. };
  54. this.monthHeaderSelectChange = (event) => {
  55. const date = new Date(event.detail);
  56. if (!this.range) {
  57. this.activeDate = date;
  58. }
  59. else {
  60. if (this.activeRange === "end") {
  61. this.activeEndDate = date;
  62. }
  63. else {
  64. this.activeStartDate = date;
  65. }
  66. this.mostRecentRangeValue = date;
  67. }
  68. };
  69. this.monthActiveDateChange = (event) => {
  70. const date = new Date(event.detail);
  71. if (!this.range) {
  72. this.activeDate = date;
  73. }
  74. else {
  75. if (this.activeRange === "end") {
  76. this.activeEndDate = date;
  77. }
  78. else {
  79. this.activeStartDate = date;
  80. }
  81. this.mostRecentRangeValue = date;
  82. }
  83. };
  84. this.monthHoverChange = (event) => {
  85. if (!this.startAsDate) {
  86. this.hoverRange = undefined;
  87. return;
  88. }
  89. const date = new Date(event.detail);
  90. this.hoverRange = {
  91. focused: this.activeRange || "start",
  92. start: this.startAsDate,
  93. end: this.endAsDate
  94. };
  95. if (!this.proximitySelectionDisabled) {
  96. if (this.endAsDate) {
  97. const startDiff = getDaysDiff(date, this.startAsDate);
  98. const endDiff = getDaysDiff(date, this.endAsDate);
  99. if (endDiff > 0) {
  100. this.hoverRange.end = date;
  101. this.hoverRange.focused = "end";
  102. }
  103. else if (startDiff < 0) {
  104. this.hoverRange.start = date;
  105. this.hoverRange.focused = "start";
  106. }
  107. else if (startDiff > endDiff) {
  108. this.hoverRange.start = date;
  109. this.hoverRange.focused = "start";
  110. }
  111. else {
  112. this.hoverRange.end = date;
  113. this.hoverRange.focused = "end";
  114. }
  115. }
  116. else {
  117. if (date < this.startAsDate) {
  118. this.hoverRange = {
  119. focused: "start",
  120. start: date,
  121. end: this.startAsDate
  122. };
  123. }
  124. else {
  125. this.hoverRange.end = date;
  126. this.hoverRange.focused = "end";
  127. }
  128. }
  129. }
  130. else {
  131. if (!this.endAsDate) {
  132. if (date < this.startAsDate) {
  133. this.hoverRange = {
  134. focused: "start",
  135. start: date,
  136. end: this.startAsDate
  137. };
  138. }
  139. else {
  140. this.hoverRange.end = date;
  141. this.hoverRange.focused = "end";
  142. }
  143. }
  144. else {
  145. this.hoverRange = undefined;
  146. }
  147. }
  148. event.stopPropagation();
  149. };
  150. this.monthMouseOutChange = () => {
  151. if (this.hoverRange) {
  152. this.hoverRange = undefined;
  153. }
  154. };
  155. /**
  156. * Reset active date and close
  157. */
  158. this.reset = () => {
  159. var _a, _b, _c, _d, _e, _f;
  160. if (!Array.isArray(this.valueAsDate) &&
  161. this.valueAsDate &&
  162. ((_a = this.valueAsDate) === null || _a === void 0 ? void 0 : _a.getTime()) !== ((_b = this.activeDate) === null || _b === void 0 ? void 0 : _b.getTime())) {
  163. this.activeDate = new Date(this.valueAsDate);
  164. }
  165. if (this.startAsDate && ((_c = this.startAsDate) === null || _c === void 0 ? void 0 : _c.getTime()) !== ((_d = this.activeStartDate) === null || _d === void 0 ? void 0 : _d.getTime())) {
  166. this.activeStartDate = new Date(this.startAsDate);
  167. }
  168. if (this.endAsDate && ((_e = this.endAsDate) === null || _e === void 0 ? void 0 : _e.getTime()) !== ((_f = this.activeEndDate) === null || _f === void 0 ? void 0 : _f.getTime())) {
  169. this.activeEndDate = new Date(this.endAsDate);
  170. }
  171. };
  172. /**
  173. * Event handler for when the selected date changes
  174. *
  175. * @param event
  176. */
  177. this.monthDateChange = (event) => {
  178. const date = new Date(event.detail);
  179. if (!this.range) {
  180. this.value = date ? dateToISO(date) : "";
  181. this.valueAsDate = date || null;
  182. this.activeDate = date || null;
  183. this.calciteDatePickerChange.emit(date);
  184. return;
  185. }
  186. if (!this.startAsDate || (!this.endAsDate && date < this.startAsDate)) {
  187. if (this.startAsDate) {
  188. this.setEndDate(new Date(this.startAsDate));
  189. }
  190. if (this.activeRange == "end") {
  191. this.setEndDate(date);
  192. }
  193. else {
  194. this.setStartDate(date);
  195. }
  196. }
  197. else if (!this.endAsDate) {
  198. this.setEndDate(date);
  199. }
  200. else {
  201. if (!this.proximitySelectionDisabled) {
  202. if (this.activeRange) {
  203. if (this.activeRange == "end") {
  204. this.setEndDate(date);
  205. }
  206. else {
  207. this.setStartDate(date);
  208. }
  209. }
  210. else {
  211. const startDiff = getDaysDiff(date, this.startAsDate);
  212. const endDiff = getDaysDiff(date, this.endAsDate);
  213. if (endDiff === 0 || startDiff < 0) {
  214. this.setStartDate(date);
  215. }
  216. else if (startDiff === 0 || endDiff < 0) {
  217. this.setEndDate(date);
  218. }
  219. else if (startDiff < endDiff) {
  220. this.setStartDate(date);
  221. }
  222. else {
  223. this.setEndDate(date);
  224. }
  225. }
  226. }
  227. else {
  228. this.setStartDate(date);
  229. this.endAsDate = this.activeEndDate = this.end = undefined;
  230. }
  231. }
  232. this.calciteDatePickerChange.emit(date);
  233. };
  234. }
  235. handleValueAsDate(date) {
  236. if (!Array.isArray(date) && date && date !== this.activeDate) {
  237. this.activeDate = date;
  238. }
  239. }
  240. handleRangeChange() {
  241. const { startAsDate: startDate, endAsDate: endDate } = this;
  242. this.activeEndDate = endDate;
  243. this.activeStartDate = startDate;
  244. }
  245. onMinChanged(min) {
  246. if (min) {
  247. this.minAsDate = dateFromISO(min);
  248. }
  249. }
  250. onMaxChanged(max) {
  251. if (max) {
  252. this.maxAsDate = dateFromISO(max);
  253. }
  254. }
  255. // --------------------------------------------------------------------------
  256. //
  257. // Lifecycle
  258. //
  259. // --------------------------------------------------------------------------
  260. connectedCallback() {
  261. connectLocalized(this);
  262. if (Array.isArray(this.value)) {
  263. this.valueAsDate = getValueAsDateRange(this.value);
  264. this.start = this.value[0];
  265. this.end = this.value[1];
  266. }
  267. else if (this.value) {
  268. this.valueAsDate = dateFromISO(this.value);
  269. }
  270. if (this.start) {
  271. this.setStartAsDate(dateFromISO(this.start));
  272. }
  273. if (this.end) {
  274. this.setEndAsDate(dateFromISO(this.end));
  275. }
  276. if (this.min) {
  277. this.minAsDate = dateFromISO(this.min);
  278. }
  279. if (this.max) {
  280. this.maxAsDate = dateFromISO(this.max);
  281. }
  282. }
  283. disconnectedCallback() {
  284. disconnectLocalized(this);
  285. }
  286. async componentWillLoad() {
  287. await this.loadLocaleData();
  288. this.onMinChanged(this.min);
  289. this.onMaxChanged(this.max);
  290. }
  291. render() {
  292. var _a;
  293. const date = dateFromRange(this.range ? this.startAsDate : this.valueAsDate, this.minAsDate, this.maxAsDate);
  294. const activeStartDate = this.range
  295. ? this.getActiveStartDate(date, this.minAsDate, this.maxAsDate)
  296. : this.getActiveDate(date, this.minAsDate, this.maxAsDate);
  297. let activeDate = activeStartDate;
  298. const endDate = this.range
  299. ? dateFromRange(this.endAsDate, this.minAsDate, this.maxAsDate)
  300. : null;
  301. const activeEndDate = this.getActiveEndDate(endDate, this.minAsDate, this.maxAsDate);
  302. if ((this.activeRange === "end" ||
  303. (((_a = this.hoverRange) === null || _a === void 0 ? void 0 : _a.focused) === "end" && (!this.proximitySelectionDisabled || endDate))) &&
  304. activeEndDate) {
  305. activeDate = activeEndDate;
  306. }
  307. if (this.range && this.mostRecentRangeValue) {
  308. activeDate = this.mostRecentRangeValue;
  309. }
  310. const minDate = this.range && this.activeRange
  311. ? this.activeRange === "start"
  312. ? this.minAsDate
  313. : date || this.minAsDate
  314. : this.minAsDate;
  315. const maxDate = this.range && this.activeRange
  316. ? this.activeRange === "start"
  317. ? endDate || this.maxAsDate
  318. : this.maxAsDate
  319. : this.maxAsDate;
  320. return (h(Host, { onBlur: this.reset, onKeyDown: this.keyDownHandler, role: "application" }, this.renderCalendar(activeDate, maxDate, minDate, date, endDate)));
  321. }
  322. valueHandler(value) {
  323. if (Array.isArray(value)) {
  324. this.valueAsDate = getValueAsDateRange(value);
  325. this.start = value[0];
  326. this.end = value[1];
  327. }
  328. else if (value) {
  329. this.valueAsDate = dateFromISO(value);
  330. this.start = "";
  331. this.end = "";
  332. }
  333. }
  334. startWatcher(start) {
  335. this.setStartAsDate(dateFromISO(start));
  336. }
  337. endWatcher(end) {
  338. this.setEndAsDate(dateFromISO(end));
  339. }
  340. async loadLocaleData() {
  341. if (!Build.isBrowser) {
  342. return;
  343. }
  344. numberStringFormatter.numberFormatOptions = {
  345. numberingSystem: this.numberingSystem,
  346. locale: this.effectiveLocale,
  347. useGrouping: false
  348. };
  349. this.localeData = await getLocaleData(this.effectiveLocale);
  350. }
  351. /**
  352. * Render calcite-date-picker-month-header and calcite-date-picker-month
  353. *
  354. * @param activeDate
  355. * @param maxDate
  356. * @param minDate
  357. * @param date
  358. * @param endDate
  359. */
  360. renderCalendar(activeDate, maxDate, minDate, date, endDate) {
  361. return (this.localeData && [
  362. h("calcite-date-picker-month-header", { activeDate: activeDate, headingLevel: this.headingLevel || HEADING_LEVEL, intlNextMonth: this.intlNextMonth, intlPrevMonth: this.intlPrevMonth, intlYear: this.intlYear, localeData: this.localeData, max: maxDate, min: minDate, onCalciteDatePickerSelect: this.monthHeaderSelectChange, scale: this.scale, selectedDate: this.activeRange === "end" ? endDate : date || new Date() }),
  363. h("calcite-date-picker-month", { activeDate: activeDate, endDate: this.range ? endDate : undefined, hoverRange: this.hoverRange, localeData: this.localeData, max: maxDate, min: minDate, onCalciteDatePickerActiveDateChange: this.monthActiveDateChange, onCalciteDatePickerSelect: this.monthDateChange, onCalciteInternalDatePickerHover: this.monthHoverChange, onCalciteInternalDatePickerMouseOut: this.monthMouseOutChange, scale: this.scale, selectedDate: this.activeRange === "end" ? endDate : date, startDate: this.range ? date : undefined })
  364. ]);
  365. }
  366. /**
  367. * Update date instance of start if valid
  368. *
  369. * @param startDate
  370. * @param emit
  371. */
  372. setStartAsDate(startDate, emit) {
  373. this.startAsDate = startDate;
  374. this.mostRecentRangeValue = this.startAsDate;
  375. if (emit) {
  376. this.calciteDatePickerRangeChange.emit({
  377. startDate,
  378. endDate: this.endAsDate
  379. });
  380. }
  381. }
  382. /**
  383. * Update date instance of end if valid
  384. *
  385. * @param endDate
  386. * @param emit
  387. */
  388. setEndAsDate(endDate, emit) {
  389. this.endAsDate = endDate ? setEndOfDay(endDate) : endDate;
  390. this.mostRecentRangeValue = this.endAsDate;
  391. if (emit) {
  392. this.calciteDatePickerRangeChange.emit({
  393. startDate: this.startAsDate,
  394. endDate
  395. });
  396. }
  397. }
  398. setEndDate(date) {
  399. this.end = date ? dateToISO(date) : "";
  400. this.setEndAsDate(date, true);
  401. this.activeEndDate = date || null;
  402. }
  403. setStartDate(date) {
  404. this.start = date ? dateToISO(date) : "";
  405. this.setStartAsDate(date, true);
  406. this.activeStartDate = date || null;
  407. }
  408. /**
  409. * Get an active date using the value, or current date as default
  410. *
  411. * @param value
  412. * @param min
  413. * @param max
  414. */
  415. getActiveDate(value, min, max) {
  416. return dateFromRange(this.activeDate, min, max) || value || dateFromRange(new Date(), min, max);
  417. }
  418. getActiveStartDate(value, min, max) {
  419. return (dateFromRange(this.activeStartDate, min, max) || value || dateFromRange(new Date(), min, max));
  420. }
  421. getActiveEndDate(value, min, max) {
  422. return (dateFromRange(this.activeEndDate, min, max) || value || dateFromRange(new Date(), min, max));
  423. }
  424. static get is() { return "calcite-date-picker"; }
  425. static get encapsulation() { return "shadow"; }
  426. static get originalStyleUrls() {
  427. return {
  428. "$": ["date-picker.scss"]
  429. };
  430. }
  431. static get styleUrls() {
  432. return {
  433. "$": ["date-picker.css"]
  434. };
  435. }
  436. static get assetsDirs() { return ["assets"]; }
  437. static get properties() {
  438. return {
  439. "activeRange": {
  440. "type": "string",
  441. "mutable": false,
  442. "complexType": {
  443. "original": "\"start\" | \"end\"",
  444. "resolved": "\"end\" | \"start\"",
  445. "references": {}
  446. },
  447. "required": false,
  448. "optional": true,
  449. "docs": {
  450. "tags": [],
  451. "text": "Active range"
  452. },
  453. "attribute": "active-range",
  454. "reflect": true
  455. },
  456. "value": {
  457. "type": "string",
  458. "mutable": true,
  459. "complexType": {
  460. "original": "string | string[]",
  461. "resolved": "string | string[]",
  462. "references": {}
  463. },
  464. "required": false,
  465. "optional": true,
  466. "docs": {
  467. "tags": [],
  468. "text": "Selected date"
  469. },
  470. "attribute": "value",
  471. "reflect": false
  472. },
  473. "headingLevel": {
  474. "type": "number",
  475. "mutable": false,
  476. "complexType": {
  477. "original": "HeadingLevel",
  478. "resolved": "1 | 2 | 3 | 4 | 5 | 6",
  479. "references": {
  480. "HeadingLevel": {
  481. "location": "import",
  482. "path": "../functional/Heading"
  483. }
  484. }
  485. },
  486. "required": false,
  487. "optional": false,
  488. "docs": {
  489. "tags": [],
  490. "text": "Number at which section headings should start for this component."
  491. },
  492. "attribute": "heading-level",
  493. "reflect": true
  494. },
  495. "valueAsDate": {
  496. "type": "unknown",
  497. "mutable": true,
  498. "complexType": {
  499. "original": "Date | Date[]",
  500. "resolved": "Date | Date[]",
  501. "references": {
  502. "Date": {
  503. "location": "global"
  504. }
  505. }
  506. },
  507. "required": false,
  508. "optional": true,
  509. "docs": {
  510. "tags": [],
  511. "text": "Selected date as full date object"
  512. }
  513. },
  514. "startAsDate": {
  515. "type": "unknown",
  516. "mutable": true,
  517. "complexType": {
  518. "original": "Date",
  519. "resolved": "Date",
  520. "references": {
  521. "Date": {
  522. "location": "global"
  523. }
  524. }
  525. },
  526. "required": false,
  527. "optional": true,
  528. "docs": {
  529. "tags": [{
  530. "name": "deprecated",
  531. "text": "use valueAsDate instead"
  532. }],
  533. "text": "Selected start date as full date object"
  534. }
  535. },
  536. "endAsDate": {
  537. "type": "unknown",
  538. "mutable": true,
  539. "complexType": {
  540. "original": "Date",
  541. "resolved": "Date",
  542. "references": {
  543. "Date": {
  544. "location": "global"
  545. }
  546. }
  547. },
  548. "required": false,
  549. "optional": true,
  550. "docs": {
  551. "tags": [{
  552. "name": "deprecated",
  553. "text": "use valueAsDate instead"
  554. }],
  555. "text": "Selected end date as full date object"
  556. }
  557. },
  558. "minAsDate": {
  559. "type": "unknown",
  560. "mutable": true,
  561. "complexType": {
  562. "original": "Date",
  563. "resolved": "Date",
  564. "references": {
  565. "Date": {
  566. "location": "global"
  567. }
  568. }
  569. },
  570. "required": false,
  571. "optional": true,
  572. "docs": {
  573. "tags": [],
  574. "text": "Earliest allowed date as full date object"
  575. }
  576. },
  577. "maxAsDate": {
  578. "type": "unknown",
  579. "mutable": true,
  580. "complexType": {
  581. "original": "Date",
  582. "resolved": "Date",
  583. "references": {
  584. "Date": {
  585. "location": "global"
  586. }
  587. }
  588. },
  589. "required": false,
  590. "optional": true,
  591. "docs": {
  592. "tags": [],
  593. "text": "Latest allowed date as full date object"
  594. }
  595. },
  596. "min": {
  597. "type": "string",
  598. "mutable": true,
  599. "complexType": {
  600. "original": "string",
  601. "resolved": "string",
  602. "references": {}
  603. },
  604. "required": false,
  605. "optional": true,
  606. "docs": {
  607. "tags": [],
  608. "text": "Earliest allowed date (\"yyyy-mm-dd\")"
  609. },
  610. "attribute": "min",
  611. "reflect": true
  612. },
  613. "max": {
  614. "type": "string",
  615. "mutable": true,
  616. "complexType": {
  617. "original": "string",
  618. "resolved": "string",
  619. "references": {}
  620. },
  621. "required": false,
  622. "optional": true,
  623. "docs": {
  624. "tags": [],
  625. "text": "Latest allowed date (\"yyyy-mm-dd\")"
  626. },
  627. "attribute": "max",
  628. "reflect": true
  629. },
  630. "intlPrevMonth": {
  631. "type": "string",
  632. "mutable": false,
  633. "complexType": {
  634. "original": "string",
  635. "resolved": "string",
  636. "references": {}
  637. },
  638. "required": false,
  639. "optional": true,
  640. "docs": {
  641. "tags": [{
  642. "name": "default",
  643. "text": "\"Previous month\""
  644. }],
  645. "text": "Localized string for \"previous month\" (used for aria label)"
  646. },
  647. "attribute": "intl-prev-month",
  648. "reflect": false,
  649. "defaultValue": "TEXT.prevMonth"
  650. },
  651. "intlNextMonth": {
  652. "type": "string",
  653. "mutable": false,
  654. "complexType": {
  655. "original": "string",
  656. "resolved": "string",
  657. "references": {}
  658. },
  659. "required": false,
  660. "optional": true,
  661. "docs": {
  662. "tags": [{
  663. "name": "default",
  664. "text": "\"Next month\""
  665. }],
  666. "text": "Localized string for \"next month\" (used for aria label)"
  667. },
  668. "attribute": "intl-next-month",
  669. "reflect": false,
  670. "defaultValue": "TEXT.nextMonth"
  671. },
  672. "intlYear": {
  673. "type": "string",
  674. "mutable": false,
  675. "complexType": {
  676. "original": "string",
  677. "resolved": "string",
  678. "references": {}
  679. },
  680. "required": false,
  681. "optional": true,
  682. "docs": {
  683. "tags": [{
  684. "name": "default",
  685. "text": "\"Year\""
  686. }],
  687. "text": "Localized string for \"year\" (used for aria label)"
  688. },
  689. "attribute": "intl-year",
  690. "reflect": false,
  691. "defaultValue": "TEXT.year"
  692. },
  693. "locale": {
  694. "type": "string",
  695. "mutable": false,
  696. "complexType": {
  697. "original": "string",
  698. "resolved": "string",
  699. "references": {}
  700. },
  701. "required": false,
  702. "optional": true,
  703. "docs": {
  704. "tags": [{
  705. "name": "deprecated",
  706. "text": "set the global `lang` attribute on the element instead."
  707. }, {
  708. "name": "mdn",
  709. "text": "[lang](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)"
  710. }],
  711. "text": "Specifies the BCP 47 language tag for the desired language and country format."
  712. },
  713. "attribute": "locale",
  714. "reflect": false
  715. },
  716. "numberingSystem": {
  717. "type": "string",
  718. "mutable": false,
  719. "complexType": {
  720. "original": "NumberingSystem",
  721. "resolved": "\"arab\" | \"arabext\" | \"bali\" | \"beng\" | \"deva\" | \"fullwide\" | \"gujr\" | \"guru\" | \"hanidec\" | \"khmr\" | \"knda\" | \"laoo\" | \"latn\" | \"limb\" | \"mlym\" | \"mong\" | \"mymr\" | \"orya\" | \"tamldec\" | \"telu\" | \"thai\" | \"tibt\"",
  722. "references": {
  723. "NumberingSystem": {
  724. "location": "import",
  725. "path": "../../utils/locale"
  726. }
  727. }
  728. },
  729. "required": false,
  730. "optional": true,
  731. "docs": {
  732. "tags": [],
  733. "text": "Specifies the Unicode numeral system used by the component for localization. This property cannot be dynamically changed."
  734. },
  735. "attribute": "numbering-system",
  736. "reflect": true
  737. },
  738. "scale": {
  739. "type": "string",
  740. "mutable": false,
  741. "complexType": {
  742. "original": "\"s\" | \"m\" | \"l\"",
  743. "resolved": "\"l\" | \"m\" | \"s\"",
  744. "references": {}
  745. },
  746. "required": false,
  747. "optional": false,
  748. "docs": {
  749. "tags": [],
  750. "text": "specify the scale of the date picker"
  751. },
  752. "attribute": "scale",
  753. "reflect": true,
  754. "defaultValue": "\"m\""
  755. },
  756. "range": {
  757. "type": "boolean",
  758. "mutable": false,
  759. "complexType": {
  760. "original": "boolean",
  761. "resolved": "boolean",
  762. "references": {}
  763. },
  764. "required": false,
  765. "optional": false,
  766. "docs": {
  767. "tags": [],
  768. "text": "Range mode activation"
  769. },
  770. "attribute": "range",
  771. "reflect": true,
  772. "defaultValue": "false"
  773. },
  774. "start": {
  775. "type": "string",
  776. "mutable": true,
  777. "complexType": {
  778. "original": "string",
  779. "resolved": "string",
  780. "references": {}
  781. },
  782. "required": false,
  783. "optional": true,
  784. "docs": {
  785. "tags": [{
  786. "name": "deprecated",
  787. "text": "use value instead"
  788. }],
  789. "text": "Selected start date"
  790. },
  791. "attribute": "start",
  792. "reflect": true
  793. },
  794. "end": {
  795. "type": "string",
  796. "mutable": true,
  797. "complexType": {
  798. "original": "string",
  799. "resolved": "string",
  800. "references": {}
  801. },
  802. "required": false,
  803. "optional": true,
  804. "docs": {
  805. "tags": [{
  806. "name": "deprecated",
  807. "text": "use value instead"
  808. }],
  809. "text": "Selected end date"
  810. },
  811. "attribute": "end",
  812. "reflect": true
  813. },
  814. "proximitySelectionDisabled": {
  815. "type": "boolean",
  816. "mutable": false,
  817. "complexType": {
  818. "original": "boolean",
  819. "resolved": "boolean",
  820. "references": {}
  821. },
  822. "required": false,
  823. "optional": false,
  824. "docs": {
  825. "tags": [],
  826. "text": "Disables the default behaviour on the third click of narrowing or extending the range and instead starts a new range."
  827. },
  828. "attribute": "proximity-selection-disabled",
  829. "reflect": true,
  830. "defaultValue": "false"
  831. }
  832. };
  833. }
  834. static get states() {
  835. return {
  836. "activeDate": {},
  837. "activeStartDate": {},
  838. "activeEndDate": {},
  839. "globalAttributes": {},
  840. "effectiveLocale": {},
  841. "localeData": {},
  842. "hoverRange": {}
  843. };
  844. }
  845. static get events() {
  846. return [{
  847. "method": "calciteDatePickerChange",
  848. "name": "calciteDatePickerChange",
  849. "bubbles": true,
  850. "cancelable": false,
  851. "composed": true,
  852. "docs": {
  853. "tags": [],
  854. "text": "Trigger calcite date change when a user changes the date."
  855. },
  856. "complexType": {
  857. "original": "Date",
  858. "resolved": "Date",
  859. "references": {
  860. "Date": {
  861. "location": "global"
  862. }
  863. }
  864. }
  865. }, {
  866. "method": "calciteDatePickerRangeChange",
  867. "name": "calciteDatePickerRangeChange",
  868. "bubbles": true,
  869. "cancelable": false,
  870. "composed": true,
  871. "docs": {
  872. "tags": [{
  873. "name": "see",
  874. "text": "[DateRangeChange](https://github.com/Esri/calcite-components/blob/master/src/components/date-picker/interfaces.ts#L1)"
  875. }],
  876. "text": "Trigger calcite date change when a user changes the date range."
  877. },
  878. "complexType": {
  879. "original": "DateRangeChange",
  880. "resolved": "DateRangeChange",
  881. "references": {
  882. "DateRangeChange": {
  883. "location": "import",
  884. "path": "./interfaces"
  885. }
  886. }
  887. }
  888. }];
  889. }
  890. static get elementRef() { return "el"; }
  891. static get watchers() {
  892. return [{
  893. "propName": "valueAsDate",
  894. "methodName": "handleValueAsDate"
  895. }, {
  896. "propName": "startAsDate",
  897. "methodName": "handleRangeChange"
  898. }, {
  899. "propName": "endAsDate",
  900. "methodName": "handleRangeChange"
  901. }, {
  902. "propName": "min",
  903. "methodName": "onMinChanged"
  904. }, {
  905. "propName": "max",
  906. "methodName": "onMaxChanged"
  907. }, {
  908. "propName": "value",
  909. "methodName": "valueHandler"
  910. }, {
  911. "propName": "start",
  912. "methodName": "startWatcher"
  913. }, {
  914. "propName": "end",
  915. "methodName": "endWatcher"
  916. }, {
  917. "propName": "effectiveLocale",
  918. "methodName": "loadLocaleData"
  919. }];
  920. }
  921. }