@govtechsg/sgds-web-component 1.1.0-rc.0 → 1.1.0

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.
Files changed (79) hide show
  1. package/base/dropdown-element.cjs.js +0 -1
  2. package/base/dropdown-element.cjs.js.map +1 -1
  3. package/base/dropdown-element.d.ts +1 -2
  4. package/base/dropdown-element.js +0 -1
  5. package/base/dropdown-element.js.map +1 -1
  6. package/components/ActionCard/index.umd.js +3 -1
  7. package/components/ActionCard/index.umd.js.map +1 -1
  8. package/components/Button/index.umd.js +3 -1
  9. package/components/Button/index.umd.js.map +1 -1
  10. package/components/Checkbox/index.umd.js +3 -1
  11. package/components/Checkbox/index.umd.js.map +1 -1
  12. package/components/ComboBox/index.umd.js +43 -26
  13. package/components/ComboBox/index.umd.js.map +1 -1
  14. package/components/Datepicker/datepicker-calendar.cjs.js +29 -14
  15. package/components/Datepicker/datepicker-calendar.cjs.js.map +1 -1
  16. package/components/Datepicker/datepicker-calendar.js +29 -14
  17. package/components/Datepicker/datepicker-calendar.js.map +1 -1
  18. package/components/Datepicker/datepicker-header.cjs.js +35 -17
  19. package/components/Datepicker/datepicker-header.cjs.js.map +1 -1
  20. package/components/Datepicker/datepicker-header.d.ts +2 -0
  21. package/components/Datepicker/datepicker-header.js +35 -18
  22. package/components/Datepicker/datepicker-header.js.map +1 -1
  23. package/components/Datepicker/datepicker-input.cjs.js +150 -0
  24. package/components/Datepicker/datepicker-input.cjs.js.map +1 -0
  25. package/components/Datepicker/datepicker-input.d.ts +24 -0
  26. package/components/Datepicker/datepicker-input.js +141 -0
  27. package/components/Datepicker/datepicker-input.js.map +1 -0
  28. package/components/Datepicker/index.js.map +1 -1
  29. package/components/Datepicker/index.umd.js +16655 -7545
  30. package/components/Datepicker/index.umd.js.map +1 -1
  31. package/components/Datepicker/sgds-datepicker.cjs.js +207 -150
  32. package/components/Datepicker/sgds-datepicker.cjs.js.map +1 -1
  33. package/components/Datepicker/sgds-datepicker.cjs2.js +1 -1
  34. package/components/Datepicker/sgds-datepicker.d.ts +38 -13
  35. package/components/Datepicker/sgds-datepicker.js +209 -152
  36. package/components/Datepicker/sgds-datepicker.js.map +1 -1
  37. package/components/Datepicker/sgds-datepicker2.js +1 -1
  38. package/components/Dropdown/index.umd.js +8 -3
  39. package/components/Dropdown/index.umd.js.map +1 -1
  40. package/components/Dropdown/sgds-dropdown.cjs.js +5 -1
  41. package/components/Dropdown/sgds-dropdown.cjs.js.map +1 -1
  42. package/components/Dropdown/sgds-dropdown.d.ts +4 -3
  43. package/components/Dropdown/sgds-dropdown.js +5 -1
  44. package/components/Dropdown/sgds-dropdown.js.map +1 -1
  45. package/components/FileUpload/index.umd.js +3 -1
  46. package/components/FileUpload/index.umd.js.map +1 -1
  47. package/components/Input/index.umd.js +43 -25
  48. package/components/Input/index.umd.js.map +1 -1
  49. package/components/Input/sgds-input.cjs.js +40 -24
  50. package/components/Input/sgds-input.cjs.js.map +1 -1
  51. package/components/Input/sgds-input.d.ts +15 -9
  52. package/components/Input/sgds-input.js +40 -24
  53. package/components/Input/sgds-input.js.map +1 -1
  54. package/components/Mainnav/index.umd.js +0 -1
  55. package/components/Mainnav/index.umd.js.map +1 -1
  56. package/components/QuantityToggle/index.umd.js +3 -1
  57. package/components/QuantityToggle/index.umd.js.map +1 -1
  58. package/components/Radio/index.umd.js +3 -1
  59. package/components/Radio/index.umd.js.map +1 -1
  60. package/components/Textarea/index.umd.js +3 -1
  61. package/components/Textarea/index.umd.js.map +1 -1
  62. package/components/index.umd.js +9905 -791
  63. package/components/index.umd.js.map +1 -1
  64. package/index.umd.js +9905 -791
  65. package/index.umd.js.map +1 -1
  66. package/package.json +2 -2
  67. package/react/datepicker/index.cjs.js +1 -2
  68. package/react/datepicker/index.cjs.js.map +1 -1
  69. package/react/datepicker/index.js +1 -2
  70. package/react/datepicker/index.js.map +1 -1
  71. package/utils/form.cjs.js +3 -1
  72. package/utils/form.cjs.js.map +1 -1
  73. package/utils/form.js +3 -1
  74. package/utils/form.js.map +1 -1
  75. package/utils/time.cjs.js +18 -4
  76. package/utils/time.cjs.js.map +1 -1
  77. package/utils/time.d.ts +17 -0
  78. package/utils/time.js +18 -4
  79. package/utils/time.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"datepicker-header.cjs.js","sources":["../../../src/components/Datepicker/datepicker-header.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { sanitizedNextMonth, sanitizedPreviousMonth } from \"../../utils/time\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./datepicker-header.scss\";\nimport { ViewEnum } from \"./types\";\n\nconst MONTH_LABELS = [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\"\n];\n\nexport class DatepickerHeader extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /** @internal */\n @property({ attribute: false })\n displayDate: Date;\n /** @internal */\n @property({ attribute: false })\n focusedDate: Date;\n /** @internal */\n @property({ attribute: false })\n selectedDate: Date[] = [];\n\n /** @internal */\n @property()\n view: ViewEnum;\n /** @internal */\n @property()\n focusedTabIndex: number;\n\n @watch(\"focusedTabIndex\", { waitUntilFirstUpdate: true })\n _handleFocusedTabIndexChange() {\n if (this.focusedTabIndex < 3) {\n const buttonToFocus: HTMLButtonElement = this.shadowRoot.querySelector(\n `button[tabindex=\"${this.focusedTabIndex}\"]`\n );\n buttonToFocus.focus();\n return;\n }\n return;\n }\n\n private _changeView() {\n switch (this.view) {\n case \"days\":\n this.view = \"months\";\n break;\n case \"months\":\n this.view = \"years\";\n break;\n case \"years\":\n break;\n }\n this.emit(\"sgds-view\", { detail: this.view }); // emit event to render the correct view\n }\n\n private _renderHeader() {\n const { view, displayDate } = this;\n if (view === \"months\") {\n return html` ${displayDate.getFullYear()} `;\n }\n if (view === \"years\") {\n const CURRENT_YEAR = new Date().getFullYear();\n const displayYear = this.displayDate.getFullYear();\n const remainder = (displayYear - CURRENT_YEAR) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1;\n return html` ${startLimit} - ${endLimit} `;\n }\n return html` ${MONTH_LABELS[displayDate.getMonth()]} ${displayDate.getFullYear()} `;\n }\n\n /** @internal */\n private handleClickPrevious() {\n const { view, displayDate, focusedDate } = this;\n let newDisplayDate = new Date(displayDate);\n if (view === \"months\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() - 1);\n } else if (this.view === \"years\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() - 12);\n } else {\n /**\n * FocusedDate gets precedence over displayDate.\n * This happens when the arrow keys are pressed to\n * change focus date and user clicks the arrow buttons to\n * shift months\n */\n if (focusedDate.getDate() !== displayDate.getDate()) {\n newDisplayDate = sanitizedPreviousMonth(focusedDate);\n } else {\n newDisplayDate = sanitizedPreviousMonth(newDisplayDate);\n }\n }\n this.displayDate = newDisplayDate; // Update the displayDate property\n // emit event to render correct view\n this.emit(\"sgds-change-calendar\", { detail: this.displayDate });\n }\n\n /** @internal */\n private _handleClickNext() {\n const { view, displayDate, focusedDate } = this;\n let newDisplayDate = new Date(displayDate);\n\n if (view === \"months\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() + 1);\n } else if (this.view === \"years\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() + 12);\n } else {\n /** FocusedDate gets precedence over displayDate */\n if (focusedDate.getDate() !== displayDate.getDate()) {\n newDisplayDate = sanitizedNextMonth(focusedDate);\n } else {\n newDisplayDate = sanitizedNextMonth(newDisplayDate);\n }\n }\n this.displayDate = newDisplayDate; // Update the displayDate property\n\n //emit event to render correct view\n this.emit(\"sgds-change-calendar\", { detail: this.displayDate });\n }\n\n render() {\n return html`\n <div class=\"datepicker-header dropdown-header\" role=\"heading\">\n <div class=\"text-center d-flex justify-content-between align-items-center\">\n <button @click=\"${this.handleClickPrevious}\" tabindex=\"0\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n class=\"bi bi-chevron-left\"\n viewBox=\"0 0 16 16\"\n >\n <path\n fill-rule=\"evenodd\"\n d=\"M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z\"\n />\n </svg>\n </button>\n <button @click=${this._changeView} tabindex=\"1\">${this._renderHeader()}</button>\n <button @click=\"${this._handleClickNext}\" tabindex=\"2\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n class=\"bi bi-chevron-right\"\n viewBox=\"0 0 16 16\"\n >\n <path\n fill-rule=\"evenodd\"\n d=\"M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z\"\n />\n </svg>\n </button>\n </div>\n </div>\n `;\n }\n}\n\nexport default DatepickerHeader;\n"],"names":["SgdsElement","html","sanitizedPreviousMonth","sanitizedNextMonth","styles","__decorate","property","watch"],"mappings":";;;;;;;;;;;;AAQA,MAAM,YAAY,GAAG;IACnB,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,UAAU;CACX,CAAC;AAEI,MAAO,gBAAiB,SAAQA,sBAAW,CAAA;AAAjD,IAAA,WAAA,GAAA;;;QAWE,IAAY,CAAA,YAAA,GAAW,EAAE,CAAC;KA4I3B;IAlIC,4BAA4B,GAAA;AAC1B,QAAA,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE;AAC5B,YAAA,M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AC;AACb,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGlBD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACL,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI1BD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,EAAE;AACI,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGfD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,EAAE;AACa,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGxBD,gBAAA,CAAA;IADCE,WAAK,CAAC,iBAAiB,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAUxD,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,8BAAA,EAAA,IAAA,CAAA;;;;;"}
1
+ {"version":3,"file":"datepicker-header.cjs.js","sources":["../../../src/components/Datepicker/datepicker-header.ts"],"sourcesContent":["import { isBefore, isEqual } from \"date-fns\";\nimport { html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { sanitizedNextMonth, sanitizedPreviousMonth } from \"../../utils/time\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./datepicker-header.scss\";\nimport { ViewEnum } from \"./types\";\n\nexport class DatepickerHeader extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /** @internal */\n @property({ attribute: false })\n displayDate: Date;\n /** @internal */\n @property({ attribute: false })\n focusedDate: Date;\n /** @internal */\n @property({ attribute: false })\n selectedDate: Date[] = [];\n\n /** @internal */\n @property()\n view: ViewEnum;\n /** @internal */\n @property()\n focusedTabIndex: number;\n\n @watch(\"focusedTabIndex\", { waitUntilFirstUpdate: true })\n _handleFocusedTabIndexChange() {\n if (this.focusedTabIndex < 3) {\n const buttonToFocus: HTMLButtonElement = this.shadowRoot.querySelector(\n `button[tabindex=\"${this.focusedTabIndex}\"]`\n );\n buttonToFocus.focus();\n }\n return;\n }\n\n private _changeView() {\n switch (this.view) {\n case \"days\":\n this.view = \"months\";\n break;\n case \"months\":\n this.view = \"years\";\n break;\n case \"years\":\n break;\n }\n this.emit(\"sgds-view\", { detail: this.view }); // emit event to render the correct view\n }\n\n private _renderHeader() {\n const { view, displayDate } = this;\n if (view === \"months\") {\n return html` ${displayDate.getFullYear()} `;\n }\n if (view === \"years\") {\n const CURRENT_YEAR = new Date().getFullYear();\n const displayYear = this.displayDate.getFullYear();\n const remainder = (displayYear - CURRENT_YEAR) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1;\n return html` ${startLimit} - ${endLimit} `;\n }\n return html`${MONTH_LABELS[displayDate.getMonth()]} ${displayDate.getFullYear()}`;\n }\n\n /** @internal */\n private handleClickPrevious() {\n const { view, displayDate, focusedDate } = this;\n let newDisplayDate = new Date(displayDate);\n\n if (view === \"months\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() - 1);\n } else if (this.view === \"years\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() - 12);\n } else {\n /**\n * FocusedDate gets precedence over displayDate.\n * This happens when the arrow keys are pressed to\n * change focus date and user clicks the arrow buttons to\n * shift months\n */\n if (focusedDate.getDate() !== displayDate.getDate()) {\n newDisplayDate = sanitizedPreviousMonth(focusedDate);\n } else {\n newDisplayDate = sanitizedPreviousMonth(newDisplayDate);\n }\n }\n this.displayDate = newDisplayDate; // Update the displayDate property\n // emit event to render correct view\n this.emit(\"sgds-change-calendar\", { detail: this.displayDate });\n }\n\n /** @internal */\n private _handleClickNext() {\n const { view, displayDate, focusedDate } = this;\n let newDisplayDate = new Date(displayDate);\n\n if (view === \"months\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() + 1);\n } else if (this.view === \"years\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() + 12);\n } else {\n /** FocusedDate gets precedence over displayDate */\n if (focusedDate.getDate() !== displayDate.getDate()) {\n newDisplayDate = sanitizedNextMonth(focusedDate);\n } else {\n newDisplayDate = sanitizedNextMonth(newDisplayDate);\n }\n }\n this.displayDate = newDisplayDate; // Update the displayDate property\n\n //emit event to render correct view\n this.emit(\"sgds-change-calendar\", { detail: this.displayDate });\n }\n private _removeCaret(): boolean {\n const displayYear = this.displayDate.getFullYear();\n const displayMonth = this.displayDate.getMonth();\n const displayMonthYear = new Date(displayYear, displayMonth);\n\n if (this.view === \"months\") {\n return displayYear <= 1900;\n }\n if (this.view === \"years\") {\n return displayYear < 1904;\n }\n return isEqual(displayMonthYear, new Date(0, 0, 1)) || isBefore(displayMonthYear, new Date(0, 0, 1));\n }\n\n render() {\n return html`\n <div class=\"datepicker-header dropdown-header\" role=\"heading\">\n <div class=\"text-center d-flex justify-content-between align-items-center\">\n <button\n @click=\"${this.handleClickPrevious}\"\n tabindex=\"0\"\n class=\"${classMap({ invisible: this._removeCaret() })}\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n class=\"bi bi-chevron-left\"\n viewBox=\"0 0 16 16\"\n >\n <path\n fill-rule=\"evenodd\"\n d=\"M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z\"\n />\n </svg>\n </button>\n <button @click=${this._changeView} tabindex=\"1\">${this._renderHeader()}</button>\n <button @click=\"${this._handleClickNext}\" tabindex=\"2\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n class=\"bi bi-chevron-right\"\n viewBox=\"0 0 16 16\"\n >\n <path\n fill-rule=\"evenodd\"\n d=\"M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z\"\n />\n </svg>\n </button>\n </div>\n </div>\n `;\n }\n}\n\nexport default DatepickerHeader;\n\nexport const MONTH_LABELS = [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\"\n];\n"],"names":["SgdsElement","html","sanitizedPreviousMonth","sanitizedNextMonth","isEqual","isBefore","classMap","styles","__decorate","property","watch"],"mappings":";;;;;;;;;;;;;;AAUM,MAAO,gBAAiB,SAAQA,sBAAW,CAAA;AAAjD,IAAA,WAAA,GAAA;;;QAWE,IAAY,CAAA,YAAA,GAAW,EAAE,CAAC;KA6J3B;IAnJC,4BAA4B,GAAA;AAC1B,QAAA,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE;AAC5B,YAAA,MAAM,aAAa,GAAsB,IAAI,CAAC,UAAU,CAAC,aAAa,CACpE,CAAA,iBAAA,EAAoB,IAAI,CAAC,eAAe,CAAA,EAAA,CAAI,CAC7C,CAAC;YACF,aAAa,CAAC,KAAK,EAAE,CAAC;SACvB;QACD,OAAO;KACR;IAEO,WAAW,GAAA;AACjB,QAAA,QAAQ,IAAI,CAAC,IAAI;AACf,YAAA,KAAK,MAAM;AACT,gBAAA,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;gBACrB,MAAM;AACR,YAAA,KAAK,QAAQ;AACX,gBAAA,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;gBACpB,MAAM;SAGT;AACD,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;KAC/C;IAEO,aAAa,GAAA;AACn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AE,CAAC;AACb,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGlBD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACb,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGlBD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACL,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI1BD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,EAAE;AACI,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGfD,gBAAA,CAAA;AADC,IAAAC,sBAAQ,EAAE;AACa,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGxBD,gBAAA,CAAA;IADCE,WAAK,CAAC,iBAAiB,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AASxD,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,8BAAA,EAAA,IAAA,CAAA,CAAA;AA+IU,MAAA,YAAY,GAAG;IAC1B,SAAS;IACT,UAAU;IACV,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,UAAU;;;;;;;"}
@@ -19,6 +19,8 @@ export declare class DatepickerHeader extends SgdsElement {
19
19
  private handleClickPrevious;
20
20
  /** @internal */
21
21
  private _handleClickNext;
22
+ private _removeCaret;
22
23
  render(): import("lit-html").TemplateResult<1>;
23
24
  }
24
25
  export default DatepickerHeader;
26
+ export declare const MONTH_LABELS: string[];
@@ -1,25 +1,13 @@
1
1
  import { __decorate } from 'tslib';
2
+ import { isEqual, isBefore } from 'date-fns';
2
3
  import { html } from 'lit';
3
4
  import { property } from 'lit/decorators.js';
5
+ import { classMap } from 'lit/directives/class-map.js';
4
6
  import SgdsElement from '../../base/sgds-element.js';
5
7
  import { sanitizedPreviousMonth, sanitizedNextMonth } from '../../utils/time.js';
6
8
  import { watch } from '../../utils/watch.js';
7
9
  import css_248z from './datepicker-header2.js';
8
10
 
9
- const MONTH_LABELS = [
10
- "January",
11
- "February",
12
- "March",
13
- "April",
14
- "May",
15
- "June",
16
- "July",
17
- "August",
18
- "September",
19
- "October",
20
- "November",
21
- "December"
22
- ];
23
11
  class DatepickerHeader extends SgdsElement {
24
12
  constructor() {
25
13
  super(...arguments);
@@ -30,7 +18,6 @@ class DatepickerHeader extends SgdsElement {
30
18
  if (this.focusedTabIndex < 3) {
31
19
  const buttonToFocus = this.shadowRoot.querySelector(`button[tabindex="${this.focusedTabIndex}"]`);
32
20
  buttonToFocus.focus();
33
- return;
34
21
  }
35
22
  return;
36
23
  }
@@ -59,7 +46,7 @@ class DatepickerHeader extends SgdsElement {
59
46
  const endLimit = displayYear - yearsPosition + 12 - 1;
60
47
  return html ` ${startLimit} - ${endLimit} `;
61
48
  }
62
- return html ` ${MONTH_LABELS[displayDate.getMonth()]} ${displayDate.getFullYear()} `;
49
+ return html `${MONTH_LABELS[displayDate.getMonth()]} ${displayDate.getFullYear()}`;
63
50
  }
64
51
  /** @internal */
65
52
  handleClickPrevious() {
@@ -112,11 +99,27 @@ class DatepickerHeader extends SgdsElement {
112
99
  //emit event to render correct view
113
100
  this.emit("sgds-change-calendar", { detail: this.displayDate });
114
101
  }
102
+ _removeCaret() {
103
+ const displayYear = this.displayDate.getFullYear();
104
+ const displayMonth = this.displayDate.getMonth();
105
+ const displayMonthYear = new Date(displayYear, displayMonth);
106
+ if (this.view === "months") {
107
+ return displayYear <= 1900;
108
+ }
109
+ if (this.view === "years") {
110
+ return displayYear < 1904;
111
+ }
112
+ return isEqual(displayMonthYear, new Date(0, 0, 1)) || isBefore(displayMonthYear, new Date(0, 0, 1));
113
+ }
115
114
  render() {
116
115
  return html `
117
116
  <div class="datepicker-header dropdown-header" role="heading">
118
117
  <div class="text-center d-flex justify-content-between align-items-center">
119
- <button @click="${this.handleClickPrevious}" tabindex="0">
118
+ <button
119
+ @click="${this.handleClickPrevious}"
120
+ tabindex="0"
121
+ class="${classMap({ invisible: this._removeCaret() })}"
122
+ >
120
123
  <svg
121
124
  xmlns="http://www.w3.org/2000/svg"
122
125
  width="16"
@@ -171,6 +174,20 @@ __decorate([
171
174
  __decorate([
172
175
  watch("focusedTabIndex", { waitUntilFirstUpdate: true })
173
176
  ], DatepickerHeader.prototype, "_handleFocusedTabIndexChange", null);
177
+ const MONTH_LABELS = [
178
+ "January",
179
+ "February",
180
+ "March",
181
+ "April",
182
+ "May",
183
+ "June",
184
+ "July",
185
+ "August",
186
+ "September",
187
+ "October",
188
+ "November",
189
+ "December"
190
+ ];
174
191
 
175
- export { DatepickerHeader, DatepickerHeader as default };
192
+ export { DatepickerHeader, MONTH_LABELS, DatepickerHeader as default };
176
193
  //# sourceMappingURL=datepicker-header.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"datepicker-header.js","sources":["../../../src/components/Datepicker/datepicker-header.ts"],"sourcesContent":["import { html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { sanitizedNextMonth, sanitizedPreviousMonth } from \"../../utils/time\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./datepicker-header.scss\";\nimport { ViewEnum } from \"./types\";\n\nconst MONTH_LABELS = [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\"\n];\n\nexport class DatepickerHeader extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /** @internal */\n @property({ attribute: false })\n displayDate: Date;\n /** @internal */\n @property({ attribute: false })\n focusedDate: Date;\n /** @internal */\n @property({ attribute: false })\n selectedDate: Date[] = [];\n\n /** @internal */\n @property()\n view: ViewEnum;\n /** @internal */\n @property()\n focusedTabIndex: number;\n\n @watch(\"focusedTabIndex\", { waitUntilFirstUpdate: true })\n _handleFocusedTabIndexChange() {\n if (this.focusedTabIndex < 3) {\n const buttonToFocus: HTMLButtonElement = this.shadowRoot.querySelector(\n `button[tabindex=\"${this.focusedTabIndex}\"]`\n );\n buttonToFocus.focus();\n return;\n }\n return;\n }\n\n private _changeView() {\n switch (this.view) {\n case \"days\":\n this.view = \"months\";\n break;\n case \"months\":\n this.view = \"years\";\n break;\n case \"years\":\n break;\n }\n this.emit(\"sgds-view\", { detail: this.view }); // emit event to render the correct view\n }\n\n private _renderHeader() {\n const { view, displayDate } = this;\n if (view === \"months\") {\n return html` ${displayDate.getFullYear()} `;\n }\n if (view === \"years\") {\n const CURRENT_YEAR = new Date().getFullYear();\n const displayYear = this.displayDate.getFullYear();\n const remainder = (displayYear - CURRENT_YEAR) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1;\n return html` ${startLimit} - ${endLimit} `;\n }\n return html` ${MONTH_LABELS[displayDate.getMonth()]} ${displayDate.getFullYear()} `;\n }\n\n /** @internal */\n private handleClickPrevious() {\n const { view, displayDate, focusedDate } = this;\n let newDisplayDate = new Date(displayDate);\n if (view === \"months\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() - 1);\n } else if (this.view === \"years\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() - 12);\n } else {\n /**\n * FocusedDate gets precedence over displayDate.\n * This happens when the arrow keys are pressed to\n * change focus date and user clicks the arrow buttons to\n * shift months\n */\n if (focusedDate.getDate() !== displayDate.getDate()) {\n newDisplayDate = sanitizedPreviousMonth(focusedDate);\n } else {\n newDisplayDate = sanitizedPreviousMonth(newDisplayDate);\n }\n }\n this.displayDate = newDisplayDate; // Update the displayDate property\n // emit event to render correct view\n this.emit(\"sgds-change-calendar\", { detail: this.displayDate });\n }\n\n /** @internal */\n private _handleClickNext() {\n const { view, displayDate, focusedDate } = this;\n let newDisplayDate = new Date(displayDate);\n\n if (view === \"months\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() + 1);\n } else if (this.view === \"years\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() + 12);\n } else {\n /** FocusedDate gets precedence over displayDate */\n if (focusedDate.getDate() !== displayDate.getDate()) {\n newDisplayDate = sanitizedNextMonth(focusedDate);\n } else {\n newDisplayDate = sanitizedNextMonth(newDisplayDate);\n }\n }\n this.displayDate = newDisplayDate; // Update the displayDate property\n\n //emit event to render correct view\n this.emit(\"sgds-change-calendar\", { detail: this.displayDate });\n }\n\n render() {\n return html`\n <div class=\"datepicker-header dropdown-header\" role=\"heading\">\n <div class=\"text-center d-flex justify-content-between align-items-center\">\n <button @click=\"${this.handleClickPrevious}\" tabindex=\"0\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n class=\"bi bi-chevron-left\"\n viewBox=\"0 0 16 16\"\n >\n <path\n fill-rule=\"evenodd\"\n d=\"M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z\"\n />\n </svg>\n </button>\n <button @click=${this._changeView} tabindex=\"1\">${this._renderHeader()}</button>\n <button @click=\"${this._handleClickNext}\" tabindex=\"2\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n class=\"bi bi-chevron-right\"\n viewBox=\"0 0 16 16\"\n >\n <path\n fill-rule=\"evenodd\"\n d=\"M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8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A,EAAA,IAAI,CAAC,WAAW,CAAA,cAAA,EAAiB,IAAI,CAAC,aAAa,EAAE,CAAA;AACpD,0BAAA,EAAA,IAAI,CAAC,gBAAgB,CAAA;;;;;;;;;;;;;;;;;KAiB5C,CAAC;KACH;;AArJM,gBAAM,CAAA,MAAA,GAAG,CAAC,WAAW,CAAC,MAAM,EAAEA,QAAM,CAA9B,CAAgC;AAI7C,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACb,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGlB,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACb,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,aAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGlB,UAAA,CAAA;AADC,IAAA,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AACL,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,cAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAI1B,UAAA,CAAA;AADC,IAAA,QAAQ,EAAE;AACI,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGf,UAAA,CAAA;AADC,IAAA,QAAQ,EAAE;AACa,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,iBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAGxB,UAAA,CAAA;IADC,KAAK,CAAC,iBAAiB,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;AAUxD,CAAA,EAAA,gBAAA,CAAA,SAAA,EAAA,8BAAA,EAAA,IAAA,CAAA;;;;"}
1
+ {"version":3,"file":"datepicker-header.js","sources":["../../../src/components/Datepicker/datepicker-header.ts"],"sourcesContent":["import { isBefore, isEqual } from \"date-fns\";\nimport { html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport SgdsElement from \"../../base/sgds-element\";\nimport { sanitizedNextMonth, sanitizedPreviousMonth } from \"../../utils/time\";\nimport { watch } from \"../../utils/watch\";\nimport styles from \"./datepicker-header.scss\";\nimport { ViewEnum } from \"./types\";\n\nexport class DatepickerHeader extends SgdsElement {\n static styles = [SgdsElement.styles, styles];\n\n /** @internal */\n @property({ attribute: false })\n displayDate: Date;\n /** @internal */\n @property({ attribute: false })\n focusedDate: Date;\n /** @internal */\n @property({ attribute: false })\n selectedDate: Date[] = [];\n\n /** @internal */\n @property()\n view: ViewEnum;\n /** @internal */\n @property()\n focusedTabIndex: number;\n\n @watch(\"focusedTabIndex\", { waitUntilFirstUpdate: true })\n _handleFocusedTabIndexChange() {\n if (this.focusedTabIndex < 3) {\n const buttonToFocus: HTMLButtonElement = this.shadowRoot.querySelector(\n `button[tabindex=\"${this.focusedTabIndex}\"]`\n );\n buttonToFocus.focus();\n }\n return;\n }\n\n private _changeView() {\n switch (this.view) {\n case \"days\":\n this.view = \"months\";\n break;\n case \"months\":\n this.view = \"years\";\n break;\n case \"years\":\n break;\n }\n this.emit(\"sgds-view\", { detail: this.view }); // emit event to render the correct view\n }\n\n private _renderHeader() {\n const { view, displayDate } = this;\n if (view === \"months\") {\n return html` ${displayDate.getFullYear()} `;\n }\n if (view === \"years\") {\n const CURRENT_YEAR = new Date().getFullYear();\n const displayYear = this.displayDate.getFullYear();\n const remainder = (displayYear - CURRENT_YEAR) % 12;\n const yearsPosition = remainder < 0 ? 12 + remainder : remainder;\n const startLimit = displayYear - yearsPosition;\n const endLimit = displayYear - yearsPosition + 12 - 1;\n return html` ${startLimit} - ${endLimit} `;\n }\n return html`${MONTH_LABELS[displayDate.getMonth()]} ${displayDate.getFullYear()}`;\n }\n\n /** @internal */\n private handleClickPrevious() {\n const { view, displayDate, focusedDate } = this;\n let newDisplayDate = new Date(displayDate);\n\n if (view === \"months\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() - 1);\n } else if (this.view === \"years\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() - 12);\n } else {\n /**\n * FocusedDate gets precedence over displayDate.\n * This happens when the arrow keys are pressed to\n * change focus date and user clicks the arrow buttons to\n * shift months\n */\n if (focusedDate.getDate() !== displayDate.getDate()) {\n newDisplayDate = sanitizedPreviousMonth(focusedDate);\n } else {\n newDisplayDate = sanitizedPreviousMonth(newDisplayDate);\n }\n }\n this.displayDate = newDisplayDate; // Update the displayDate property\n // emit event to render correct view\n this.emit(\"sgds-change-calendar\", { detail: this.displayDate });\n }\n\n /** @internal */\n private _handleClickNext() {\n const { view, displayDate, focusedDate } = this;\n let newDisplayDate = new Date(displayDate);\n\n if (view === \"months\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() + 1);\n } else if (this.view === \"years\") {\n newDisplayDate.setFullYear(newDisplayDate.getFullYear() + 12);\n } else {\n /** FocusedDate gets precedence over displayDate */\n if (focusedDate.getDate() !== displayDate.getDate()) {\n newDisplayDate = sanitizedNextMonth(focusedDate);\n } else {\n newDisplayDate = sanitizedNextMonth(newDisplayDate);\n }\n }\n this.displayDate = newDisplayDate; // Update the displayDate property\n\n //emit event to render correct view\n this.emit(\"sgds-change-calendar\", { detail: this.displayDate });\n }\n private _removeCaret(): boolean {\n const displayYear = this.displayDate.getFullYear();\n const displayMonth = this.displayDate.getMonth();\n const displayMonthYear = new Date(displayYear, displayMonth);\n\n if (this.view === \"months\") {\n return displayYear <= 1900;\n }\n if (this.view === \"years\") {\n return displayYear < 1904;\n }\n return isEqual(displayMonthYear, new Date(0, 0, 1)) || isBefore(displayMonthYear, new Date(0, 0, 1));\n }\n\n render() {\n return html`\n <div class=\"datepicker-header dropdown-header\" role=\"heading\">\n <div class=\"text-center d-flex justify-content-between align-items-center\">\n <button\n @click=\"${this.handleClickPrevious}\"\n tabindex=\"0\"\n class=\"${classMap({ invisible: this._removeCaret() })}\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n class=\"bi bi-chevron-left\"\n viewBox=\"0 0 16 16\"\n >\n <path\n fill-rule=\"evenodd\"\n d=\"M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z\"\n />\n </svg>\n </button>\n <button @click=${this._changeView} tabindex=\"1\">${this._renderHeader()}</button>\n <button @click=\"${this._handleClickNext}\" tabindex=\"2\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n fill=\"currentColor\"\n class=\"bi bi-chevron-right\"\n viewBox=\"0 0 16 16\"\n >\n <path\n fill-rule=\"evenodd\"\n d=\"M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z\"\n />\n </svg>\n </button>\n </div>\n </div>\n `;\n }\n}\n\nexport default DatepickerHeader;\n\nexport const MONTH_LABELS = [\n \"January\",\n \"February\",\n \"March\",\n \"April\",\n \"May\",\n \"June\",\n \"July\",\n \"August\",\n \"September\",\n \"October\",\n \"November\",\n \"December\"\n];\n"],"names":["styles"],"mappings":";;;;;;;;;;AAUM,MAAO,gBAAiB,SAAQ,WAAW,CAAA;AAAjD,IAAA,WAAA,GAAA;;;QAWE,IAAY,CAAA,YAAA,GAAW,EAAE,CAAC;KA6J3B;IAnJC,4BAA4B,GAAA;AAC1B,QAAA,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE;AAC5B,YAAA,MAAM,aAAa,GAAsB,IAAI,CAAC,UAAU,CAAC,aAAa,CACpE,CAAA,iBAAA,EAAoB,IAAI,CAAC,eAAe,CAAA,EAAA,CAAI,CAC7C,CAAC;YACF,aAAa,CAAC,KAAK,EAAE,CAAC;SACvB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AO;IACP,KAAK;IACL,MAAM;IACN,MAAM;IACN,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,UAAU;;;;;"}
@@ -0,0 +1,150 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var dateFns = require('date-fns');
7
+ var IMask = require('imask');
8
+ var lit = require('lit');
9
+ var decorators_js = require('lit/decorators.js');
10
+ var time = require('../../utils/time.cjs.js');
11
+ var sgdsInput = require('../Input/sgds-input.cjs.js');
12
+
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
+
15
+ var IMask__default = /*#__PURE__*/_interopDefaultLegacy(IMask);
16
+
17
+ class DatepickerInput extends sgdsInput.SgdsInput {
18
+ constructor() {
19
+ super();
20
+ /** Date format reflected on input */
21
+ this.dateFormat = "DD/MM/YYYY";
22
+ /** Changes DatePicker to single date selection or range date selection */
23
+ this.mode = "single";
24
+ this._validateInput = async () => {
25
+ const dates = this.mask.value.split(" - ");
26
+ const noEmptyDates = dates.filter(d => d !== this.dateFormat.toLowerCase());
27
+ const dateArray = noEmptyDates.map(date => time.setTimeToNoon(dateFns.parse(date, time.DATE_PATTERNS[this.dateFormat].fnsPattern, new Date())));
28
+ const invalidDates = dateArray.filter(date => !dateFns.isValid(date) ||
29
+ dateFns.isBefore(date, new Date(0, 0, 1)) ||
30
+ dateFns.isBefore(date, time.setTimeToNoon(new Date(this.minDate))) ||
31
+ dateFns.isAfter(date, time.setTimeToNoon(new Date(this.maxDate))));
32
+ if (invalidDates.length > 0) {
33
+ this.setInvalid(true);
34
+ return this.emit("sgds-invalid-input");
35
+ }
36
+ if (this.mode === "range" && dateArray.length === 1) {
37
+ this.setInvalid(true);
38
+ return this.emit("sgds-invalid-input");
39
+ }
40
+ if (invalidDates.length === 0 && dateArray.length > 0) {
41
+ this.setInvalid(false);
42
+ return this.emit("sgds-selectdates-input", { detail: dateArray });
43
+ }
44
+ if (dateArray.length === 0 && invalidDates.length === 0) {
45
+ this.setInvalid(false);
46
+ return this.emit("sgds-empty-input");
47
+ }
48
+ };
49
+ this.inputClasses = `rounded-0 rounded-start`;
50
+ this.type = "text";
51
+ this.hasFeedback = true;
52
+ this._handleValueChange = () => null;
53
+ }
54
+ connectedCallback() {
55
+ super.connectedCallback();
56
+ this.addEventListener("sgds-change", this._validateInput);
57
+ }
58
+ async firstUpdated(changes) {
59
+ super.firstUpdated(changes);
60
+ this._applyInputMask(this.dateFormat);
61
+ }
62
+ async _applyInputMask(dateFormat) {
63
+ const shadowInput = await this.shadowInput;
64
+ const imPattern = this.mode === "single" ? time.DATE_PATTERNS[dateFormat].imPattern : time.DATE_PATTERNS[dateFormat].imRangePattern;
65
+ const blocks = {
66
+ d: { mask: IMask__default["default"].MaskedRange, placeholderChar: "d", from: 0, to: 9, maxLength: 1 },
67
+ m: { mask: IMask__default["default"].MaskedRange, placeholderChar: "m", from: 0, to: 9, maxLength: 1 },
68
+ y: { mask: IMask__default["default"].MaskedRange, placeholderChar: "y", from: 0, to: 9, maxLength: 1 },
69
+ D: { mask: IMask__default["default"].MaskedRange, placeholderChar: "d", from: 0, to: 9, maxLength: 1 },
70
+ M: { mask: IMask__default["default"].MaskedRange, placeholderChar: "m", from: 0, to: 9, maxLength: 1 },
71
+ Y: { mask: IMask__default["default"].MaskedRange, placeholderChar: "y", from: 0, to: 9, maxLength: 1 }
72
+ };
73
+ const maskOptions = {
74
+ mask: imPattern,
75
+ pattern: imPattern,
76
+ eager: true,
77
+ overwrite: true,
78
+ // define str -> date convertion
79
+ parse: function (str) {
80
+ const dates = str.split(" - ");
81
+ return dates.map(date => dateFns.parse(date, time.DATE_PATTERNS[dateFormat].fnsPattern, new Date()));
82
+ },
83
+ format: function (dateArr) {
84
+ const dateStrings = dateArr.map(date => {
85
+ let dayStr, monthStr = "";
86
+ const day = date.getDate();
87
+ const month = date.getMonth() + 1;
88
+ const year = date.getFullYear();
89
+ if (day < 10)
90
+ dayStr = "0" + day;
91
+ if (month < 10)
92
+ monthStr = "0" + month;
93
+ return [dayStr, monthStr, year].join("/");
94
+ });
95
+ return dateStrings.join(" - ");
96
+ },
97
+ lazy: false,
98
+ blocks
99
+ };
100
+ this.mask = IMask__default["default"](shadowInput, maskOptions);
101
+ this.mask.on("accept", () => {
102
+ this.value = this.mask.masked.value;
103
+ this.emit("sgds-mask-input-change", { detail: this.value });
104
+ });
105
+ /**
106
+ * Validation after date is complete
107
+ */
108
+ this.mask.on("complete", this._validateInput);
109
+ }
110
+ updateMaskValue() {
111
+ var _a;
112
+ (_a = this.mask) === null || _a === void 0 ? void 0 : _a.updateValue();
113
+ }
114
+ destroyInputMask() {
115
+ var _a;
116
+ (_a = this.mask) === null || _a === void 0 ? void 0 : _a.destroy();
117
+ }
118
+ async applyInputMask() {
119
+ return await this._applyInputMask(this.dateFormat);
120
+ }
121
+ render() {
122
+ return lit.html `
123
+ ${this._renderLabel()} ${this._renderHintText()}
124
+ <div class="d-flex">
125
+ <div class="d-flex flex-column w-100">${this._renderInput()}</div>
126
+ <slot name="calendar-btn"></slot>
127
+ <slot name="reset-btn"></slot>
128
+ </div>
129
+ `;
130
+ }
131
+ }
132
+ tslib.__decorate([
133
+ decorators_js.property({ type: String })
134
+ ], DatepickerInput.prototype, "dateFormat", void 0);
135
+ tslib.__decorate([
136
+ decorators_js.property({ type: String })
137
+ ], DatepickerInput.prototype, "minDate", void 0);
138
+ tslib.__decorate([
139
+ decorators_js.property({ type: String })
140
+ ], DatepickerInput.prototype, "maxDate", void 0);
141
+ tslib.__decorate([
142
+ decorators_js.property({ type: String, reflect: true })
143
+ ], DatepickerInput.prototype, "mode", void 0);
144
+ tslib.__decorate([
145
+ decorators_js.queryAsync("input")
146
+ ], DatepickerInput.prototype, "shadowInput", void 0);
147
+
148
+ exports.DatepickerInput = DatepickerInput;
149
+ exports["default"] = DatepickerInput;
150
+ //# sourceMappingURL=datepicker-input.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datepicker-input.cjs.js","sources":["../../../src/components/Datepicker/datepicker-input.ts"],"sourcesContent":["import { isAfter, isBefore, isValid, parse } from \"date-fns\";\nimport IMask, { InputMask } from \"imask\";\nimport { html } from \"lit\";\nimport { property, queryAsync } from \"lit/decorators.js\";\nimport { DATE_PATTERNS, setTimeToNoon } from \"../../utils/time\";\nimport { SgdsInput } from \"../Input/sgds-input\";\nexport type DateFormat = \"MM/DD/YYYY\" | \"DD/MM/YYYY\" | \"YYYY/MM/DD\";\n\nexport class DatepickerInput extends SgdsInput {\n /** Date format reflected on input */\n @property({ type: String }) dateFormat: DateFormat = \"DD/MM/YYYY\";\n\n /** ISO date string to set the lowest allowable date value. e.g. \"2016-05-19T12:00:00.000Z\" */\n @property({ type: String }) minDate: string;\n\n /** ISO date string to set the highest allowable date value. e.g. \"2016-05-19T12:00:00.000Z\" */\n @property({ type: String }) maxDate: string;\n\n /** Changes DatePicker to single date selection or range date selection */\n @property({ type: String, reflect: true }) mode: \"single\" | \"range\" = \"single\";\n\n @queryAsync(\"input\")\n shadowInput: Promise<HTMLInputElement>;\n\n private mask: InputMask;\n constructor() {\n super();\n this.inputClasses = `rounded-0 rounded-start`;\n this.type = \"text\";\n this.hasFeedback = true;\n this._handleValueChange = () => null;\n }\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"sgds-change\", this._validateInput);\n }\n\n async firstUpdated(changes) {\n super.firstUpdated(changes);\n this._applyInputMask(this.dateFormat);\n }\n private async _applyInputMask(dateFormat: string) {\n const shadowInput = await this.shadowInput;\n const imPattern =\n this.mode === \"single\" ? DATE_PATTERNS[dateFormat].imPattern : DATE_PATTERNS[dateFormat].imRangePattern;\n const blocks = {\n d: { mask: IMask.MaskedRange, placeholderChar: \"d\", from: 0, to: 9, maxLength: 1 },\n m: { mask: IMask.MaskedRange, placeholderChar: \"m\", from: 0, to: 9, maxLength: 1 },\n y: { mask: IMask.MaskedRange, placeholderChar: \"y\", from: 0, to: 9, maxLength: 1 },\n D: { mask: IMask.MaskedRange, placeholderChar: \"d\", from: 0, to: 9, maxLength: 1 },\n M: { mask: IMask.MaskedRange, placeholderChar: \"m\", from: 0, to: 9, maxLength: 1 },\n Y: { mask: IMask.MaskedRange, placeholderChar: \"y\", from: 0, to: 9, maxLength: 1 }\n };\n const maskOptions = {\n mask: imPattern,\n pattern: imPattern,\n eager: true,\n overwrite: true,\n // define str -> date convertion\n parse: function (str: string) {\n const dates = str.split(\" - \");\n return dates.map(date => parse(date, DATE_PATTERNS[dateFormat].fnsPattern, new Date()));\n },\n format: function (dateArr: Date[]) {\n const dateStrings = dateArr.map(date => {\n let dayStr: string,\n monthStr = \"\";\n const day = date.getDate();\n const month = date.getMonth() + 1;\n const year = date.getFullYear();\n\n if (day < 10) dayStr = \"0\" + day;\n if (month < 10) monthStr = \"0\" + month;\n\n return [dayStr, monthStr, year].join(\"/\");\n });\n return dateStrings.join(\" - \");\n },\n lazy: false,\n blocks\n };\n\n this.mask = IMask(shadowInput, maskOptions);\n this.mask.on(\"accept\", () => {\n this.value = this.mask.masked.value;\n this.emit(\"sgds-mask-input-change\", { detail: this.value });\n });\n /**\n * Validation after date is complete\n */\n this.mask.on(\"complete\", this._validateInput);\n }\n public updateMaskValue() {\n this.mask?.updateValue();\n }\n private _validateInput = async () => {\n const dates = this.mask.value.split(\" - \");\n const noEmptyDates = dates.filter(d => d !== this.dateFormat.toLowerCase());\n const dateArray: Date[] | string[] = noEmptyDates.map(date =>\n setTimeToNoon(parse(date, DATE_PATTERNS[this.dateFormat].fnsPattern, new Date()))\n );\n const invalidDates = dateArray.filter(\n date =>\n !isValid(date) ||\n isBefore(date, new Date(0, 0, 1)) ||\n isBefore(date, setTimeToNoon(new Date(this.minDate))) ||\n isAfter(date, setTimeToNoon(new Date(this.maxDate)))\n );\n\n if (invalidDates.length > 0) {\n this.setInvalid(true);\n return this.emit(\"sgds-invalid-input\");\n }\n if (this.mode === \"range\" && dateArray.length === 1) {\n this.setInvalid(true);\n return this.emit(\"sgds-invalid-input\");\n }\n if (invalidDates.length === 0 && dateArray.length > 0) {\n this.setInvalid(false);\n return this.emit(\"sgds-selectdates-input\", { detail: dateArray });\n }\n if (dateArray.length === 0 && invalidDates.length === 0) {\n this.setInvalid(false);\n return this.emit(\"sgds-empty-input\");\n }\n };\n\n public destroyInputMask() {\n this.mask?.destroy();\n }\n public async applyInputMask() {\n return await this._applyInputMask(this.dateFormat);\n }\n\n render() {\n return html`\n ${this._renderLabel()} ${this._renderHintText()}\n <div class=\"d-flex\">\n <div class=\"d-flex flex-column w-100\">${this._renderInput()}</div>\n <slot name=\"calendar-btn\"></slot>\n <slot name=\"reset-btn\"></slot>\n </div>\n `;\n }\n}\n\nexport default DatepickerInput;\n"],"names":["SgdsInput","setTimeToNoon","parse","DATE_PATTERNS","isValid","isBefore","isAfter","IMask","html","__decorate","property","queryAsync"],"mappings":";;;;;;;;;;;;;;;;AAQM,MAAO,eAAgB,SAAQA,mBAAS,CAAA;AAiB5C,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE,CAAC;;QAhBkB,IAAU,CAAA,UAAA,GAAe,YAAY,CAAC;;QASvB,IAAI,CAAA,IAAA,GAAuB,QAAQ,CAAC;QA4EvE,IAAc,CAAA,cAAA,GAAG,YAAW;AAClC,YAAA,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC3C,YAAA,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;AAC5E,YAAA,MAAM,SAAS,GAAsB,YAAY,CAAC,GAAG,CAAC,IAAI,IACxDC,kBAAa,CAACC,aAAK,CAAC,IAAI,EAAEC,kBAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC,CAClF,CA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-0,0 +1,24 @@
1
+ import { SgdsInput } from "../Input/sgds-input";
2
+ export type DateFormat = "MM/DD/YYYY" | "DD/MM/YYYY" | "YYYY/MM/DD";
3
+ export declare class DatepickerInput extends SgdsInput {
4
+ /** Date format reflected on input */
5
+ dateFormat: DateFormat;
6
+ /** ISO date string to set the lowest allowable date value. e.g. "2016-05-19T12:00:00.000Z" */
7
+ minDate: string;
8
+ /** ISO date string to set the highest allowable date value. e.g. "2016-05-19T12:00:00.000Z" */
9
+ maxDate: string;
10
+ /** Changes DatePicker to single date selection or range date selection */
11
+ mode: "single" | "range";
12
+ shadowInput: Promise<HTMLInputElement>;
13
+ private mask;
14
+ constructor();
15
+ connectedCallback(): void;
16
+ firstUpdated(changes: any): Promise<void>;
17
+ private _applyInputMask;
18
+ updateMaskValue(): void;
19
+ private _validateInput;
20
+ destroyInputMask(): void;
21
+ applyInputMask(): Promise<void>;
22
+ render(): import("lit-html").TemplateResult<1>;
23
+ }
24
+ export default DatepickerInput;
@@ -0,0 +1,141 @@
1
+ import { __decorate } from 'tslib';
2
+ import { parse, isValid, isBefore, isAfter } from 'date-fns';
3
+ import IMask from 'imask';
4
+ import { html } from 'lit';
5
+ import { property, queryAsync } from 'lit/decorators.js';
6
+ import { setTimeToNoon, DATE_PATTERNS } from '../../utils/time.js';
7
+ import { SgdsInput } from '../Input/sgds-input.js';
8
+
9
+ class DatepickerInput extends SgdsInput {
10
+ constructor() {
11
+ super();
12
+ /** Date format reflected on input */
13
+ this.dateFormat = "DD/MM/YYYY";
14
+ /** Changes DatePicker to single date selection or range date selection */
15
+ this.mode = "single";
16
+ this._validateInput = async () => {
17
+ const dates = this.mask.value.split(" - ");
18
+ const noEmptyDates = dates.filter(d => d !== this.dateFormat.toLowerCase());
19
+ const dateArray = noEmptyDates.map(date => setTimeToNoon(parse(date, DATE_PATTERNS[this.dateFormat].fnsPattern, new Date())));
20
+ const invalidDates = dateArray.filter(date => !isValid(date) ||
21
+ isBefore(date, new Date(0, 0, 1)) ||
22
+ isBefore(date, setTimeToNoon(new Date(this.minDate))) ||
23
+ isAfter(date, setTimeToNoon(new Date(this.maxDate))));
24
+ if (invalidDates.length > 0) {
25
+ this.setInvalid(true);
26
+ return this.emit("sgds-invalid-input");
27
+ }
28
+ if (this.mode === "range" && dateArray.length === 1) {
29
+ this.setInvalid(true);
30
+ return this.emit("sgds-invalid-input");
31
+ }
32
+ if (invalidDates.length === 0 && dateArray.length > 0) {
33
+ this.setInvalid(false);
34
+ return this.emit("sgds-selectdates-input", { detail: dateArray });
35
+ }
36
+ if (dateArray.length === 0 && invalidDates.length === 0) {
37
+ this.setInvalid(false);
38
+ return this.emit("sgds-empty-input");
39
+ }
40
+ };
41
+ this.inputClasses = `rounded-0 rounded-start`;
42
+ this.type = "text";
43
+ this.hasFeedback = true;
44
+ this._handleValueChange = () => null;
45
+ }
46
+ connectedCallback() {
47
+ super.connectedCallback();
48
+ this.addEventListener("sgds-change", this._validateInput);
49
+ }
50
+ async firstUpdated(changes) {
51
+ super.firstUpdated(changes);
52
+ this._applyInputMask(this.dateFormat);
53
+ }
54
+ async _applyInputMask(dateFormat) {
55
+ const shadowInput = await this.shadowInput;
56
+ const imPattern = this.mode === "single" ? DATE_PATTERNS[dateFormat].imPattern : DATE_PATTERNS[dateFormat].imRangePattern;
57
+ const blocks = {
58
+ d: { mask: IMask.MaskedRange, placeholderChar: "d", from: 0, to: 9, maxLength: 1 },
59
+ m: { mask: IMask.MaskedRange, placeholderChar: "m", from: 0, to: 9, maxLength: 1 },
60
+ y: { mask: IMask.MaskedRange, placeholderChar: "y", from: 0, to: 9, maxLength: 1 },
61
+ D: { mask: IMask.MaskedRange, placeholderChar: "d", from: 0, to: 9, maxLength: 1 },
62
+ M: { mask: IMask.MaskedRange, placeholderChar: "m", from: 0, to: 9, maxLength: 1 },
63
+ Y: { mask: IMask.MaskedRange, placeholderChar: "y", from: 0, to: 9, maxLength: 1 }
64
+ };
65
+ const maskOptions = {
66
+ mask: imPattern,
67
+ pattern: imPattern,
68
+ eager: true,
69
+ overwrite: true,
70
+ // define str -> date convertion
71
+ parse: function (str) {
72
+ const dates = str.split(" - ");
73
+ return dates.map(date => parse(date, DATE_PATTERNS[dateFormat].fnsPattern, new Date()));
74
+ },
75
+ format: function (dateArr) {
76
+ const dateStrings = dateArr.map(date => {
77
+ let dayStr, monthStr = "";
78
+ const day = date.getDate();
79
+ const month = date.getMonth() + 1;
80
+ const year = date.getFullYear();
81
+ if (day < 10)
82
+ dayStr = "0" + day;
83
+ if (month < 10)
84
+ monthStr = "0" + month;
85
+ return [dayStr, monthStr, year].join("/");
86
+ });
87
+ return dateStrings.join(" - ");
88
+ },
89
+ lazy: false,
90
+ blocks
91
+ };
92
+ this.mask = IMask(shadowInput, maskOptions);
93
+ this.mask.on("accept", () => {
94
+ this.value = this.mask.masked.value;
95
+ this.emit("sgds-mask-input-change", { detail: this.value });
96
+ });
97
+ /**
98
+ * Validation after date is complete
99
+ */
100
+ this.mask.on("complete", this._validateInput);
101
+ }
102
+ updateMaskValue() {
103
+ var _a;
104
+ (_a = this.mask) === null || _a === void 0 ? void 0 : _a.updateValue();
105
+ }
106
+ destroyInputMask() {
107
+ var _a;
108
+ (_a = this.mask) === null || _a === void 0 ? void 0 : _a.destroy();
109
+ }
110
+ async applyInputMask() {
111
+ return await this._applyInputMask(this.dateFormat);
112
+ }
113
+ render() {
114
+ return html `
115
+ ${this._renderLabel()} ${this._renderHintText()}
116
+ <div class="d-flex">
117
+ <div class="d-flex flex-column w-100">${this._renderInput()}</div>
118
+ <slot name="calendar-btn"></slot>
119
+ <slot name="reset-btn"></slot>
120
+ </div>
121
+ `;
122
+ }
123
+ }
124
+ __decorate([
125
+ property({ type: String })
126
+ ], DatepickerInput.prototype, "dateFormat", void 0);
127
+ __decorate([
128
+ property({ type: String })
129
+ ], DatepickerInput.prototype, "minDate", void 0);
130
+ __decorate([
131
+ property({ type: String })
132
+ ], DatepickerInput.prototype, "maxDate", void 0);
133
+ __decorate([
134
+ property({ type: String, reflect: true })
135
+ ], DatepickerInput.prototype, "mode", void 0);
136
+ __decorate([
137
+ queryAsync("input")
138
+ ], DatepickerInput.prototype, "shadowInput", void 0);
139
+
140
+ export { DatepickerInput, DatepickerInput as default };
141
+ //# sourceMappingURL=datepicker-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datepicker-input.js","sources":["../../../src/components/Datepicker/datepicker-input.ts"],"sourcesContent":["import { isAfter, isBefore, isValid, parse } from \"date-fns\";\nimport IMask, { InputMask } from \"imask\";\nimport { html } from \"lit\";\nimport { property, queryAsync } from \"lit/decorators.js\";\nimport { DATE_PATTERNS, setTimeToNoon } from \"../../utils/time\";\nimport { SgdsInput } from \"../Input/sgds-input\";\nexport type DateFormat = \"MM/DD/YYYY\" | \"DD/MM/YYYY\" | \"YYYY/MM/DD\";\n\nexport class DatepickerInput extends SgdsInput {\n /** Date format reflected on input */\n @property({ type: String }) dateFormat: DateFormat = \"DD/MM/YYYY\";\n\n /** ISO date string to set the lowest allowable date value. e.g. \"2016-05-19T12:00:00.000Z\" */\n @property({ type: String }) minDate: string;\n\n /** ISO date string to set the highest allowable date value. e.g. \"2016-05-19T12:00:00.000Z\" */\n @property({ type: String }) maxDate: string;\n\n /** Changes DatePicker to single date selection or range date selection */\n @property({ type: String, reflect: true }) mode: \"single\" | \"range\" = \"single\";\n\n @queryAsync(\"input\")\n shadowInput: Promise<HTMLInputElement>;\n\n private mask: InputMask;\n constructor() {\n super();\n this.inputClasses = `rounded-0 rounded-start`;\n this.type = \"text\";\n this.hasFeedback = true;\n this._handleValueChange = () => null;\n }\n connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener(\"sgds-change\", this._validateInput);\n }\n\n async firstUpdated(changes) {\n super.firstUpdated(changes);\n this._applyInputMask(this.dateFormat);\n }\n private async _applyInputMask(dateFormat: string) {\n const shadowInput = await this.shadowInput;\n const imPattern =\n this.mode === \"single\" ? DATE_PATTERNS[dateFormat].imPattern : DATE_PATTERNS[dateFormat].imRangePattern;\n const blocks = {\n d: { mask: IMask.MaskedRange, placeholderChar: \"d\", from: 0, to: 9, maxLength: 1 },\n m: { mask: IMask.MaskedRange, placeholderChar: \"m\", from: 0, to: 9, maxLength: 1 },\n y: { mask: IMask.MaskedRange, placeholderChar: \"y\", from: 0, to: 9, maxLength: 1 },\n D: { mask: IMask.MaskedRange, placeholderChar: \"d\", from: 0, to: 9, maxLength: 1 },\n M: { mask: IMask.MaskedRange, placeholderChar: \"m\", from: 0, to: 9, maxLength: 1 },\n Y: { mask: IMask.MaskedRange, placeholderChar: \"y\", from: 0, to: 9, maxLength: 1 }\n };\n const maskOptions = {\n mask: imPattern,\n pattern: imPattern,\n eager: true,\n overwrite: true,\n // define str -> date convertion\n parse: function (str: string) {\n const dates = str.split(\" - \");\n return dates.map(date => parse(date, DATE_PATTERNS[dateFormat].fnsPattern, new Date()));\n },\n format: function (dateArr: Date[]) {\n const dateStrings = dateArr.map(date => {\n let dayStr: string,\n monthStr = \"\";\n const day = date.getDate();\n const month = date.getMonth() + 1;\n const year = date.getFullYear();\n\n if (day < 10) dayStr = \"0\" + day;\n if (month < 10) monthStr = \"0\" + month;\n\n return [dayStr, monthStr, year].join(\"/\");\n });\n return dateStrings.join(\" - \");\n },\n lazy: false,\n blocks\n };\n\n this.mask = IMask(shadowInput, maskOptions);\n this.mask.on(\"accept\", () => {\n this.value = this.mask.masked.value;\n this.emit(\"sgds-mask-input-change\", { detail: this.value });\n });\n /**\n * Validation after date is complete\n */\n this.mask.on(\"complete\", this._validateInput);\n }\n public updateMaskValue() {\n this.mask?.updateValue();\n }\n private _validateInput = async () => {\n const dates = this.mask.value.split(\" - \");\n const noEmptyDates = dates.filter(d => d !== this.dateFormat.toLowerCase());\n const dateArray: Date[] | string[] = noEmptyDates.map(date =>\n setTimeToNoon(parse(date, DATE_PATTERNS[this.dateFormat].fnsPattern, new Date()))\n );\n const invalidDates = dateArray.filter(\n date =>\n !isValid(date) ||\n isBefore(date, new Date(0, 0, 1)) ||\n isBefore(date, setTimeToNoon(new Date(this.minDate))) ||\n isAfter(date, setTimeToNoon(new Date(this.maxDate)))\n );\n\n if (invalidDates.length > 0) {\n this.setInvalid(true);\n return this.emit(\"sgds-invalid-input\");\n }\n if (this.mode === \"range\" && dateArray.length === 1) {\n this.setInvalid(true);\n return this.emit(\"sgds-invalid-input\");\n }\n if (invalidDates.length === 0 && dateArray.length > 0) {\n this.setInvalid(false);\n return this.emit(\"sgds-selectdates-input\", { detail: dateArray });\n }\n if (dateArray.length === 0 && invalidDates.length === 0) {\n this.setInvalid(false);\n return this.emit(\"sgds-empty-input\");\n }\n };\n\n public destroyInputMask() {\n this.mask?.destroy();\n }\n public async applyInputMask() {\n return await this._applyInputMask(this.dateFormat);\n }\n\n render() {\n return html`\n ${this._renderLabel()} ${this._renderHintText()}\n <div class=\"d-flex\">\n <div class=\"d-flex flex-column w-100\">${this._renderInput()}</div>\n <slot name=\"calendar-btn\"></slot>\n <slot name=\"reset-btn\"></slot>\n </div>\n `;\n }\n}\n\nexport default DatepickerInput;\n"],"names":[],"mappings":";;;;;;;;AAQM,MAAO,eAAgB,SAAQ,SAAS,CAAA;AAiB5C,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE,CAAC;;QAhBkB,IAAU,CAAA,UAAA,GAAe,YAAY,CAAC;;QASvB,IAAI,CAAA,IAAA,GAAuB,QAAQ,CAAC;QA4EvE,IAAc,CAAA,cAAA,GAAG,YAAW;AAClC,YAAA,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC3C,YAAA,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;AAC5E,YAAA,MAAM,SAAS,GAAsB,YAAY,CAAC,GAAG,CAAC,IAAI,IACxD,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,aAA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A,CAAA,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Datepicker/index.ts"],"sourcesContent":["import { SgdsDatepicker } from \"./sgds-datepicker\";\n\ncustomElements.define(\"sgds-datepicker\", SgdsDatepicker);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"sgds-datepicker\": SgdsDatepicker;\n }\n}\n"],"names":[],"mappings":";;AAEA,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Datepicker/index.ts"],"sourcesContent":["import { SgdsDatepicker } from \"./sgds-datepicker\";\n\ncustomElements.define(\"sgds-datepicker\", SgdsDatepicker);\ndeclare global {\n interface HTMLElementTagNameMap {\n \"sgds-datepicker\": SgdsDatepicker;\n }\n}\n"],"names":[],"mappings":";;AAEA,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC"}