@vonage/vivid 4.17.0 → 4.18.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 (363) hide show
  1. package/custom-elements.json +3903 -3860
  2. package/date-time-picker/index.cjs +5 -0
  3. package/date-time-picker/index.js +3 -0
  4. package/dial-pad/index.cjs +1 -1
  5. package/dial-pad/index.js +1 -1
  6. package/dialog/index.cjs +1 -1
  7. package/dialog/index.js +1 -1
  8. package/divider/index.cjs +1 -1
  9. package/divider/index.js +1 -1
  10. package/elevation/index.cjs +1 -1
  11. package/elevation/index.js +1 -1
  12. package/empty-state/index.cjs +1 -1
  13. package/empty-state/index.js +1 -1
  14. package/fab/index.cjs +1 -1
  15. package/fab/index.js +1 -1
  16. package/file-picker/index.cjs +1 -1
  17. package/file-picker/index.js +1 -1
  18. package/header/index.cjs +1 -1
  19. package/header/index.js +1 -1
  20. package/icon/index.cjs +1 -1
  21. package/icon/index.js +1 -1
  22. package/index.cjs +136 -133
  23. package/index.js +45 -44
  24. package/layout/index.cjs +1 -1
  25. package/layout/index.js +1 -1
  26. package/lib/action-group/action-group.d.ts +449 -3
  27. package/lib/banner/banner.d.ts +449 -3
  28. package/lib/breadcrumb-item/breadcrumb-item.d.ts +449 -1
  29. package/lib/checkbox/checkbox.d.ts +449 -4
  30. package/lib/components.d.ts +1 -0
  31. package/lib/date-picker/date-picker.d.ts +2182 -4
  32. package/lib/date-picker/date-picker.template.d.ts +2 -0
  33. package/lib/date-range-picker/date-range-picker.d.ts +1110 -4
  34. package/lib/date-range-picker/date-range-picker.template.d.ts +2 -0
  35. package/lib/date-time-picker/date-time-picker.d.ts +2175 -0
  36. package/lib/date-time-picker/date-time-picker.template.d.ts +2 -0
  37. package/lib/date-time-picker/definition.d.ts +1 -0
  38. package/lib/date-time-picker/locale.d.ts +9 -0
  39. package/lib/dialog/dialog.d.ts +449 -2
  40. package/lib/divider/divider.d.ts +448 -1
  41. package/lib/menu/menu.d.ts +446 -1
  42. package/lib/nav-disclosure/nav-disclosure.d.ts +449 -2
  43. package/lib/number-field/number-field.d.ts +450 -3
  44. package/lib/option/option.d.ts +1 -11
  45. package/lib/progress/progress.d.ts +449 -2
  46. package/lib/progress-ring/progress-ring.d.ts +449 -2
  47. package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +1 -0
  48. package/lib/rich-text-editor/rich-text-editor.d.ts +7 -4
  49. package/lib/select/select.d.ts +1 -5
  50. package/lib/selectable-box/selectable-box.d.ts +449 -2
  51. package/lib/slider/slider.d.ts +449 -3
  52. package/lib/split-button/split-button.d.ts +449 -3
  53. package/lib/switch/switch.d.ts +449 -2
  54. package/lib/tag-group/tag-group.d.ts +449 -2
  55. package/lib/text-anchor/text-anchor.d.ts +449 -1
  56. package/lib/text-area/text-area.d.ts +450 -3
  57. package/lib/text-field/text-field.d.ts +450 -7
  58. package/lib/time-picker/locale.d.ts +0 -2
  59. package/lib/time-picker/time-picker.d.ts +1053 -9
  60. package/lib/time-picker/time-picker.template.d.ts +2 -1
  61. package/locales/de-DE.cjs +29 -5
  62. package/locales/de-DE.js +29 -5
  63. package/locales/en-GB.cjs +29 -5
  64. package/locales/en-GB.js +29 -5
  65. package/locales/en-US.cjs +29 -5
  66. package/locales/en-US.js +29 -5
  67. package/locales/ja-JP.cjs +29 -5
  68. package/locales/ja-JP.js +29 -5
  69. package/locales/zh-CN.cjs +29 -5
  70. package/locales/zh-CN.js +29 -5
  71. package/menu/index.cjs +1 -1
  72. package/menu/index.js +1 -1
  73. package/menu-item/index.cjs +1 -1
  74. package/menu-item/index.js +1 -1
  75. package/nav/index.cjs +1 -1
  76. package/nav/index.js +1 -1
  77. package/nav-disclosure/index.cjs +1 -1
  78. package/nav-disclosure/index.js +1 -1
  79. package/nav-item/index.cjs +1 -1
  80. package/nav-item/index.js +1 -1
  81. package/note/index.cjs +1 -1
  82. package/note/index.js +1 -1
  83. package/number-field/index.cjs +1 -1
  84. package/number-field/index.js +1 -1
  85. package/option/index.cjs +1 -1
  86. package/option/index.js +1 -1
  87. package/package.json +1 -1
  88. package/pagination/index.cjs +1 -1
  89. package/pagination/index.js +1 -1
  90. package/popup/index.cjs +1 -1
  91. package/popup/index.js +1 -1
  92. package/progress/index.cjs +1 -1
  93. package/progress/index.js +1 -1
  94. package/progress-ring/index.cjs +1 -1
  95. package/progress-ring/index.js +1 -1
  96. package/radio/index.cjs +1 -1
  97. package/radio/index.js +1 -1
  98. package/radio-group/index.cjs +1 -1
  99. package/radio-group/index.js +1 -1
  100. package/range-slider/index.cjs +1 -1
  101. package/range-slider/index.js +1 -1
  102. package/rich-text-editor/index.cjs +1 -1
  103. package/rich-text-editor/index.js +1 -1
  104. package/searchable-select/index.cjs +1 -1
  105. package/searchable-select/index.js +1 -1
  106. package/select/index.cjs +1 -1
  107. package/select/index.js +1 -1
  108. package/selectable-box/index.cjs +1 -1
  109. package/selectable-box/index.js +1 -1
  110. package/shared/Reflector.cjs +71 -0
  111. package/shared/Reflector.js +69 -0
  112. package/shared/affix.cjs +1 -1
  113. package/shared/affix.js +1 -1
  114. package/shared/anchor.cjs +0 -10
  115. package/shared/anchor.js +0 -10
  116. package/shared/aria/delegates-aria.d.ts +454 -0
  117. package/shared/base-progress.js +1 -1
  118. package/shared/breadcrumb-item.cjs +2 -1
  119. package/shared/breadcrumb-item.js +2 -1
  120. package/shared/button.cjs +2 -13
  121. package/shared/button.js +2 -13
  122. package/shared/{presentationDate.cjs → calendar-picker.template.cjs} +730 -900
  123. package/shared/{presentationDate.js → calendar-picker.template.js} +672 -845
  124. package/shared/datetime/dateTimeStr.d.ts +6 -0
  125. package/shared/datetime/presentationDate.d.ts +4 -0
  126. package/shared/{date-picker/calendar → datetime}/presentationDateRange.d.ts +3 -3
  127. package/shared/datetime/presentationDateTime.d.ts +4 -0
  128. package/{lib/time-picker/time → shared/datetime}/time.d.ts +1 -0
  129. package/shared/definition.cjs +1 -1
  130. package/shared/definition.js +1 -1
  131. package/shared/definition11.cjs +8 -11
  132. package/shared/definition11.js +8 -11
  133. package/shared/definition14.cjs +2 -2
  134. package/shared/definition14.js +2 -2
  135. package/shared/definition15.cjs +3 -10
  136. package/shared/definition15.js +3 -10
  137. package/shared/definition16.cjs +29 -33
  138. package/shared/definition16.js +29 -33
  139. package/shared/definition17.cjs +1 -1
  140. package/shared/definition17.js +1 -1
  141. package/shared/definition18.cjs +56 -91
  142. package/shared/definition18.js +56 -91
  143. package/shared/definition19.cjs +68 -32
  144. package/shared/definition19.js +58 -22
  145. package/shared/definition20.cjs +253 -220
  146. package/shared/definition20.js +254 -220
  147. package/shared/definition21.cjs +200 -286
  148. package/shared/definition21.js +198 -284
  149. package/shared/definition22.cjs +302 -31
  150. package/shared/definition22.js +301 -30
  151. package/shared/definition23.cjs +37 -58
  152. package/shared/definition23.js +36 -57
  153. package/shared/definition24.cjs +50 -70
  154. package/shared/definition24.js +49 -69
  155. package/shared/definition25.cjs +75 -2475
  156. package/shared/definition25.js +74 -2475
  157. package/shared/definition26.cjs +2480 -50
  158. package/shared/definition26.js +2479 -48
  159. package/shared/definition27.cjs +53 -271
  160. package/shared/definition27.js +52 -269
  161. package/shared/definition28.cjs +271 -48
  162. package/shared/definition28.js +269 -47
  163. package/shared/definition29.cjs +37 -764
  164. package/shared/definition29.js +36 -758
  165. package/shared/definition3.cjs +2 -9
  166. package/shared/definition3.js +2 -9
  167. package/shared/definition30.cjs +739 -57
  168. package/shared/definition30.js +733 -56
  169. package/shared/definition31.cjs +93 -22
  170. package/shared/definition31.js +92 -21
  171. package/shared/definition32.cjs +28 -10
  172. package/shared/definition32.js +27 -9
  173. package/shared/definition33.cjs +10 -52
  174. package/shared/definition33.js +9 -51
  175. package/shared/definition34.cjs +30 -411
  176. package/shared/definition34.js +30 -412
  177. package/shared/definition35.cjs +422 -52
  178. package/shared/definition35.js +423 -53
  179. package/shared/definition36.cjs +53 -216
  180. package/shared/definition36.js +53 -215
  181. package/shared/definition37.cjs +201 -71
  182. package/shared/definition37.js +200 -70
  183. package/shared/definition38.cjs +53 -48
  184. package/shared/definition38.js +51 -46
  185. package/shared/definition39.cjs +57 -263
  186. package/shared/definition39.js +56 -262
  187. package/shared/definition4.cjs +2 -2
  188. package/shared/definition4.js +2 -2
  189. package/shared/definition40.cjs +220 -148
  190. package/shared/definition40.js +220 -148
  191. package/shared/definition41.cjs +143 -567
  192. package/shared/definition41.js +143 -568
  193. package/shared/definition42.cjs +596 -12573
  194. package/shared/definition42.js +596 -12573
  195. package/shared/definition43.cjs +13489 -1058
  196. package/shared/definition43.js +13489 -1059
  197. package/shared/definition44.cjs +936 -698
  198. package/shared/definition44.js +937 -698
  199. package/shared/definition45.cjs +850 -105
  200. package/shared/definition45.js +850 -104
  201. package/shared/definition46.cjs +110 -90
  202. package/shared/definition46.js +108 -88
  203. package/shared/definition47.cjs +88 -464
  204. package/shared/definition47.js +87 -463
  205. package/shared/definition48.cjs +457 -111
  206. package/shared/definition48.js +456 -110
  207. package/shared/definition49.cjs +103 -109
  208. package/shared/definition49.js +102 -108
  209. package/shared/definition5.cjs +3 -3
  210. package/shared/definition5.js +3 -3
  211. package/shared/definition50.cjs +136 -14
  212. package/shared/definition50.js +135 -13
  213. package/shared/definition51.cjs +16 -115
  214. package/shared/definition51.js +15 -114
  215. package/shared/definition52.cjs +79 -486
  216. package/shared/definition52.js +78 -485
  217. package/shared/definition53.cjs +503 -24
  218. package/shared/definition53.js +502 -23
  219. package/shared/definition54.cjs +23 -137
  220. package/shared/definition54.js +22 -136
  221. package/shared/definition55.cjs +96 -241
  222. package/shared/definition55.js +95 -241
  223. package/shared/definition56.cjs +261 -61
  224. package/shared/definition56.js +260 -60
  225. package/shared/definition57.cjs +419 -788
  226. package/shared/definition57.js +420 -789
  227. package/shared/definition58.cjs +27 -144
  228. package/shared/definition58.js +27 -143
  229. package/shared/definition59.cjs +83 -54
  230. package/shared/definition59.js +82 -53
  231. package/shared/definition6.cjs +1 -1
  232. package/shared/definition6.js +1 -1
  233. package/shared/definition60.cjs +80 -165
  234. package/shared/definition60.js +79 -163
  235. package/shared/definition61.cjs +143 -230
  236. package/shared/definition61.js +141 -229
  237. package/shared/definition62.cjs +233 -69344
  238. package/shared/definition62.js +232 -69343
  239. package/shared/definition63.cjs +69381 -28
  240. package/shared/definition63.js +69379 -26
  241. package/shared/definition64.cjs +28 -2168
  242. package/shared/definition64.js +27 -2166
  243. package/shared/definition65.cjs +2195 -0
  244. package/shared/definition65.js +2190 -0
  245. package/shared/definition7.cjs +1 -1
  246. package/shared/definition7.js +1 -1
  247. package/shared/definition8.cjs +3 -9
  248. package/shared/definition8.js +3 -9
  249. package/shared/definition9.cjs +1 -1
  250. package/shared/definition9.js +1 -1
  251. package/shared/delegates-aria.cjs +69 -0
  252. package/shared/delegates-aria.js +67 -0
  253. package/shared/form-associated.js +1 -1
  254. package/shared/form-elements.cjs +1 -1
  255. package/shared/form-elements.js +1 -1
  256. package/shared/foundation/anchor/anchor.d.ts +0 -8
  257. package/shared/foundation/button/button.d.ts +449 -7
  258. package/shared/foundation/listbox/listbox.d.ts +0 -9
  259. package/shared/listbox.cjs +4 -30
  260. package/shared/listbox.js +4 -30
  261. package/shared/localization/Locale.d.ts +6 -2
  262. package/shared/option.cjs +1 -38
  263. package/shared/option.js +1 -38
  264. package/shared/picker-field/locale.d.ts +4 -0
  265. package/shared/picker-field/mixins/calendar-picker.d.ts +558 -0
  266. package/shared/{date-picker/locale.d.ts → picker-field/mixins/calendar-picker.locale.d.ts} +1 -3
  267. package/shared/picker-field/mixins/calendar-picker.template.d.ts +555 -0
  268. package/shared/picker-field/mixins/calendar-segments/calendarGrid.d.ts +17 -0
  269. package/shared/{date-picker/calendar → picker-field/mixins/calendar-segments}/monthPickerGrid.d.ts +3 -3
  270. package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/columns.d.ts +1 -1
  271. package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/inline-time-picker.d.ts +2 -2
  272. package/{lib/time-picker/time/picker.d.ts → shared/picker-field/mixins/inline-time-picker/picker-option.d.ts} +1 -1
  273. package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +1110 -0
  274. package/shared/picker-field/mixins/single-date-picker.d.ts +1626 -0
  275. package/shared/picker-field/mixins/single-value-picker.d.ts +518 -0
  276. package/shared/picker-field/mixins/time-selection-picker.d.ts +1053 -0
  277. package/shared/picker-field/mixins/time-selection-picker.template.d.ts +1050 -0
  278. package/shared/picker-field/picker-field.d.ts +11 -0
  279. package/shared/picker-field/picker-field.form-associated.d.ts +11 -0
  280. package/shared/picker-field/picker-field.template.d.ts +7 -0
  281. package/shared/picker-field.template.cjs +315 -0
  282. package/shared/picker-field.template.js +310 -0
  283. package/shared/single-date-picker.cjs +46 -0
  284. package/shared/single-date-picker.js +44 -0
  285. package/shared/single-value-picker.cjs +77 -0
  286. package/shared/single-value-picker.js +75 -0
  287. package/shared/slider.template.cjs +3 -3
  288. package/shared/slider.template.js +3 -3
  289. package/shared/text-anchor.cjs +2 -1
  290. package/shared/text-anchor.js +2 -1
  291. package/shared/text-anchor.template.cjs +3 -5
  292. package/shared/text-anchor.template.js +3 -5
  293. package/shared/text-field.cjs +2 -555
  294. package/shared/text-field.js +2 -554
  295. package/shared/time-selection-picker.template.cjs +776 -0
  296. package/shared/time-selection-picker.template.js +767 -0
  297. package/shared/vivid-element.cjs +1 -1
  298. package/shared/vivid-element.js +1 -1
  299. package/side-drawer/index.cjs +1 -1
  300. package/side-drawer/index.js +1 -1
  301. package/slider/index.cjs +1 -1
  302. package/slider/index.js +1 -1
  303. package/split-button/index.cjs +1 -1
  304. package/split-button/index.js +1 -1
  305. package/styles/core/all.css +1 -1
  306. package/styles/core/theme.css +1 -1
  307. package/styles/core/typography.css +1 -1
  308. package/styles/tokens/theme-dark.css +4 -4
  309. package/styles/tokens/theme-light.css +4 -4
  310. package/styles/tokens/vivid-2-compat.css +1 -1
  311. package/switch/index.cjs +1 -1
  312. package/switch/index.js +1 -1
  313. package/tab/index.cjs +1 -1
  314. package/tab/index.js +1 -1
  315. package/tab-panel/index.cjs +1 -1
  316. package/tab-panel/index.js +1 -1
  317. package/tabs/index.cjs +1 -1
  318. package/tabs/index.js +1 -1
  319. package/tag/index.cjs +1 -1
  320. package/tag/index.js +1 -1
  321. package/tag-group/index.cjs +1 -1
  322. package/tag-group/index.js +1 -1
  323. package/text-anchor/index.cjs +1 -1
  324. package/text-anchor/index.js +1 -1
  325. package/text-area/index.cjs +1 -1
  326. package/text-area/index.js +1 -1
  327. package/text-field/index.cjs +1 -1
  328. package/text-field/index.js +1 -1
  329. package/time-picker/index.cjs +1 -1
  330. package/time-picker/index.js +1 -1
  331. package/toggletip/index.cjs +1 -1
  332. package/toggletip/index.js +1 -1
  333. package/tooltip/index.cjs +1 -1
  334. package/tooltip/index.js +1 -1
  335. package/tree-item/index.cjs +1 -1
  336. package/tree-item/index.js +1 -1
  337. package/tree-view/index.cjs +1 -1
  338. package/tree-view/index.js +1 -1
  339. package/video-player/index.cjs +1 -1
  340. package/video-player/index.js +1 -1
  341. package/vivid.api.json +105 -1152
  342. package/lib/time-picker/time-picker.form-associated.d.ts +0 -11
  343. package/shared/aria-global.cjs +0 -93
  344. package/shared/aria-global.js +0 -91
  345. package/shared/date-picker/calendar/calendarGrid.d.ts +0 -17
  346. package/shared/date-picker/calendar/presentationDate.d.ts +0 -4
  347. package/shared/date-picker/date-picker-base.d.ts +0 -21
  348. package/shared/date-picker/date-picker-base.form-associated.d.ts +0 -11
  349. package/shared/date-picker/date-picker-base.template.d.ts +0 -3
  350. package/shared/foundation/patterns/aria-global.d.ts +0 -21
  351. package/shared/foundation/patterns/index.d.ts +0 -1
  352. package/shared/text-field2.cjs +0 -5
  353. package/shared/text-field2.js +0 -3
  354. package/shared/trapped-focus.cjs +0 -35
  355. package/shared/trapped-focus.js +0 -33
  356. /package/shared/{date-picker/calendar → datetime}/dateRange.d.ts +0 -0
  357. /package/shared/{date-picker/calendar → datetime}/dateStr.d.ts +0 -0
  358. /package/shared/{date-picker/calendar → datetime}/month.d.ts +0 -0
  359. /package/{lib/time-picker/time → shared/datetime}/presentationTime.d.ts +0 -0
  360. /package/shared/{date-picker/calendar → datetime}/year.d.ts +0 -0
  361. /package/shared/{date-picker/calendar → picker-field/mixins/calendar-segments}/segment.d.ts +0 -0
  362. /package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/definition.d.ts +0 -0
  363. /package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/inline-time-picker.template.d.ts +0 -0
@@ -1,23 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const definition$1 = require('./definition11.cjs');
4
- const definition = require('./definition64.cjs');
5
- const textField = require('./text-field.cjs');
6
- const definition$2 = require('./definition22.cjs');
7
- const ref = require('./ref.cjs');
8
- const slotted = require('./slotted.cjs');
3
+ const vividElement = require('./vivid-element.cjs');
4
+ const definition$1 = require('./definition23.cjs');
5
+ const definition = require('./definition11.cjs');
9
6
  const repeat = require('./repeat.cjs');
10
7
  const when = require('./when.cjs');
11
- const vividElement = require('./vivid-element.cjs');
12
8
  const classNames = require('./class-names.cjs');
13
- const applyMixinsWithObservables = require('./applyMixinsWithObservables.cjs');
14
- const index = require('./index.cjs');
15
- const formAssociated = require('./form-associated.cjs');
16
- const trappedFocus = require('./trapped-focus.cjs');
17
- const formElements = require('./form-elements.cjs');
18
- const localized = require('./localized.cjs');
19
9
 
20
- const styles = ":host{display:inline-block}.base{display:inline-block;inline-size:100%}.control{inline-size:100%}.dialog{display:inline-flex;flex-direction:column;padding:12px;gap:12px}.dialog .footer{display:flex;align-items:center;justify-content:flex-end;padding:8px;gap:8px}.segments{display:flex;gap:24px}.segment{display:flex;flex-direction:column;gap:12px}.segment .header{display:flex;align-items:center;padding-block:8px}.segment .title{display:flex;flex-grow:1;justify-content:center}.segment .title-action{border-radius:8px;block-size:24px;font:var(--vvd-typography-base-extended);padding-inline:8px}.calendar{display:flex;flex-direction:column;margin-top:8px;gap:4px}.calendar .calendar-separator{margin-inline:10px}.calendar .calendar-weekdays{display:flex;justify-content:center}.calendar .calendar-weekday{display:inline-flex;align-items:center;justify-content:center;block-size:16px;font:var(--vvd-typography-base-condensed);inline-size:40px}.calendar .calendar-week{display:flex;justify-content:center}.calendar .calendar-day{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;aspect-ratio:1/1;block-size:28px;font:var(--vvd-typography-base);margin-inline:6px;--focus-inset: -2px}.calendar .calendar-day.start,.calendar .calendar-day.end{border:2px solid var(--vvd-color-cta-50);background-color:var(--vvd-color-cta-200)}.calendar .calendar-day:before,.calendar .calendar-day:after{position:absolute;z-index:-1;display:block;width:20px;height:28px}.calendar .calendar-day:before{right:50%}.calendar .calendar-day:after{left:50%}.calendar .calendar-day.range:before,.calendar .calendar-day.range:after{background-color:var(--vvd-color-cta-50)}.calendar .calendar-day.range:not(.start):before,.calendar .calendar-day.range:not(.end):after{content:\"\"}.calendar .calendar-day.outside-month,.calendar .calendar-day:disabled{color:var(--vvd-color-neutral-400)}.months-separator{margin-inline:-12px}.month-grid{display:flex;flex-direction:column;gap:34px}.month-grid .months-row{display:flex;justify-content:center;gap:29px}.month-grid .month{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;aspect-ratio:1/1;block-size:48px;font:var(--vvd-typography-base-extended);text-transform:uppercase}.month-grid .month:disabled{color:var(--vvd-color-neutral-400)}.button{--_connotation-color-primary: var(--vvd-date-picker-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-firm: var(--vvd-date-picker-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-date-picker-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-date-picker-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-dim: var(--vvd-date-picker-accent-dim, var(--vvd-color-neutral-200));--_connotation-color-pale: var(--vvd-date-picker-accent-pale, var(--vvd-color-neutral-300))}.button{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.button:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.button:where(.active,:active):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.button:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.button:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.button:where(.selected):where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-200);--_appearance-color-outline: transparent}.button{position:relative;padding:0;border:none;background-color:var(--_appearance-color-fill);color:var(--_appearance-color-text);cursor:pointer}.button:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px));color:var(--vvd-color-canvas-text)}.button.current{border:1px solid var(--vvd-color-neutral-200)}.button:disabled{cursor:not-allowed}";
10
+ const calendarStyles = ".segments{display:inline-flex;gap:24px}.segment{display:flex;flex-direction:column;gap:12px}.segment .header{display:flex;align-items:center;padding-block:8px}.segment .title{display:flex;flex-grow:1;justify-content:center}.segment .title-action{border-radius:8px;block-size:24px;font:var(--vvd-typography-base-extended);padding-inline:8px}.calendar{display:flex;flex-direction:column;margin-top:8px;gap:4px}.calendar .calendar-separator{margin-inline:10px}.calendar .calendar-weekdays{display:flex;justify-content:center}.calendar .calendar-weekday{display:inline-flex;align-items:center;justify-content:center;block-size:16px;font:var(--vvd-typography-base-condensed);inline-size:40px}.calendar .calendar-week{display:flex;justify-content:center}.calendar .calendar-day{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;aspect-ratio:1/1;block-size:28px;font:var(--vvd-typography-base);margin-inline:6px;--focus-inset: -2px}.calendar .calendar-day.start,.calendar .calendar-day.end{border:2px solid var(--vvd-color-cta-50);background-color:var(--vvd-color-cta-200)}.calendar .calendar-day:before,.calendar .calendar-day:after{position:absolute;z-index:-1;display:block;width:20px;height:28px}.calendar .calendar-day:before{right:50%}.calendar .calendar-day:after{left:50%}.calendar .calendar-day.range:before,.calendar .calendar-day.range:after{background-color:var(--vvd-color-cta-50)}.calendar .calendar-day.range:not(.start):before,.calendar .calendar-day.range:not(.end):after{content:\"\"}.calendar .calendar-day.outside-month,.calendar .calendar-day:disabled{color:var(--vvd-color-neutral-400)}.months-separator{margin-inline:-12px}.month-grid{display:flex;flex-direction:column;gap:34px}.month-grid .months-row{display:flex;justify-content:center;gap:29px}.month-grid .month{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;aspect-ratio:1/1;block-size:48px;font:var(--vvd-typography-base-extended);text-transform:uppercase}.month-grid .month:disabled{color:var(--vvd-color-neutral-400)}.button{--_connotation-color-primary: var(--vvd-date-picker-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-firm: var(--vvd-date-picker-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-faint: var(--vvd-date-picker-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-date-picker-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-dim: var(--vvd-date-picker-accent-dim, var(--vvd-color-neutral-200));--_connotation-color-pale: var(--vvd-date-picker-accent-pale, var(--vvd-color-neutral-300))}.button{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.button:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.button:where(.active,:active):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.button:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.button:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-dim);--_appearance-color-outline: transparent}.button:where(.selected):where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-200);--_appearance-color-outline: transparent}.button{position:relative;padding:0;border:none;background-color:var(--_appearance-color-fill);color:var(--_appearance-color-text);cursor:pointer}.button:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px));color:var(--vvd-color-canvas-text)}.button.current{border:1px solid var(--vvd-color-neutral-200)}.button:disabled{cursor:not-allowed}";
21
11
 
22
12
  /**
23
13
  * @name toDate
@@ -5505,6 +5495,15 @@ const isValidDateStr = (string) => {
5505
5495
  return hasThreeComponents(components) && allComponentsAreNumbers(components) && isValidDate(components);
5506
5496
  };
5507
5497
 
5498
+ const formatPresentationDate = (dateStr, locale) => {
5499
+ const date = parseDateStr(dateStr);
5500
+ return format(date, locale.dateFormat);
5501
+ };
5502
+ const parsePresentationDate = (presentationDate, locale) => {
5503
+ const date = parse(presentationDate, locale.dateFormat, /* @__PURE__ */ new Date());
5504
+ return formatDateStr(date);
5505
+ };
5506
+
5508
5507
  const getCurrentMonth = (now = /* @__PURE__ */ new Date()) => ({
5509
5508
  month: now.getMonth(),
5510
5509
  year: now.getFullYear()
@@ -5522,340 +5521,28 @@ const compareMonths = (a, b) => a.year === b.year ? a.month - b.month : a.year -
5522
5521
  const areMonthsEqual = (a, b) => compareMonths(a, b) === 0;
5523
5522
  const monthToStr = ({ month, year }) => `${year.toString().padStart(4, "0")}-${(month + 1).toString().padStart(2, "0")}`;
5524
5523
 
5525
- function renderDialogHeader(context) {
5526
- const buttonTag = context.tagFor(definition$1.Button);
5527
- return vividElement.html`<div class="header">
5528
- ${when.when(
5529
- (x) => x.prevYearButton,
5530
- vividElement.html`
5531
- <${buttonTag}
5532
- tabindex="1"
5533
- class="vwc-button"
5534
- size="super-condensed"
5535
- icon="${(_, c) => c.parent._inMonthPicker ? "chevron-left-line" : "double-chevron-left-line"}"
5536
- aria-label="${(_, c) => c.parent.locale.datePicker.prevYearLabel}"
5537
- ?disabled="${(_, c) => c.parent._isPrevYearDisabled}"
5538
- @click="${(_, c) => c.parent._onPrevYearClick()}"
5539
- ></${buttonTag}>
5540
- `
5541
- )}
5542
- ${when.when(
5543
- (x) => x.prevMonthButton,
5544
- vividElement.html`
5545
- <${buttonTag}
5546
- tabindex="1"
5547
- class="vwc-button"
5548
- size="super-condensed"
5549
- icon="chevron-left-line"
5550
- aria-label="${(_, c) => c.parent.locale.datePicker.prevMonthLabel}"
5551
- ?disabled="${(_, c) => c.parent._isPrevMonthDisabled}"
5552
- @click="${(_, c) => c.parent._onPrevMonthClick()}"
5553
- ></${buttonTag}>
5554
- `
5555
- )}
5556
- <div class="title">
5557
- ${when.when(
5558
- (x) => x.titleClickable,
5559
- vividElement.html`
5560
- <button
5561
- tabindex="1"
5562
- id="${(x) => `grid-label-${x.id}`}"
5563
- class="title-action button"
5564
- aria-live="polite"
5565
- @click="${(_, c) => c.parent._onTitleActionClick()}"
5566
- >
5567
- ${(x) => x.title}
5568
- </button>
5569
- `
5570
- )}
5571
- ${when.when(
5572
- (x) => !x.titleClickable,
5573
- vividElement.html`
5574
- <div
5575
- id="${(x) => `grid-label-${x.id}`}"
5576
- class="title-action"
5577
- aria-live="polite"
5578
- >
5579
- ${(x) => x.title}
5580
- </div>
5581
- `
5582
- )}
5583
- </div>
5524
+ const yearOfDate = (dateStr) => {
5525
+ const date = parseDateStr(dateStr);
5526
+ return date.getFullYear();
5527
+ };
5584
5528
 
5585
- ${when.when(
5586
- (x) => x.nextMonthButton,
5587
- vividElement.html`
5588
- <${buttonTag}
5589
- tabindex="1"
5590
- class="vwc-button"
5591
- size="super-condensed"
5592
- icon="chevron-right-line"
5593
- aria-label="${(_, c) => c.parent.locale.datePicker.nextMonthLabel}"
5594
- ?disabled="${(_, c) => c.parent._isNextMonthDisabled}"
5595
- @click="${(_, c) => c.parent._onNextMonthClick()}"
5596
- ></${buttonTag}>
5597
- `
5598
- )}
5599
- ${when.when(
5600
- (x) => x.nextYearButton,
5601
- vividElement.html`
5602
- <${buttonTag}
5603
- tabindex="1"
5604
- class="vwc-button"
5605
- size="super-condensed"
5606
- icon="${(_, c) => c.parent._inMonthPicker ? "chevron-right-line" : "double-chevron-right-line"}"
5607
- aria-label="${(_, c) => c.parent.locale.datePicker.nextYearLabel}"
5608
- ?disabled="${(_, c) => c.parent._isNextYearDisabled}"
5609
- @click="${(_, c) => c.parent._onNextYearClick()}"
5610
- ></${buttonTag}>
5611
- `
5612
- )}
5613
- </div>`;
5614
- }
5615
- function renderCalendarGrid(context) {
5616
- const dividerTag = context.tagFor(definition$2.Divider);
5617
- return vividElement.html`<div
5618
- class="calendar"
5619
- role="grid"
5620
- aria-labelledby="${(x) => `grid-label-${x.id}`}"
5621
- >
5622
- <div class="calendar-weekdays" role="row">
5623
- ${repeat.repeat(
5624
- (x) => x.calendar.weekdays,
5625
- vividElement.html`
5626
- <div
5627
- class="calendar-weekday"
5628
- role="columnheader"
5629
- aria-label="${(x) => x.name}"
5630
- >
5631
- ${(x) => x.shortName}
5632
- </div>
5633
- `
5634
- )}
5635
- </div>
5636
- <${dividerTag} class="calendar-separator" role="presentation"></${dividerTag}>
5637
- ${repeat.repeat(
5638
- (x) => x.calendar.grid,
5639
- vividElement.html` <div class="calendar-week" role="row">
5640
- ${repeat.repeat(
5641
- (x) => x,
5642
- vividElement.html`
5643
- ${when.when(
5644
- (x, c) => c.parentContext.parentContext.parent._hideDatesOutsideMonth && x.isOutsideMonth,
5645
- vividElement.html`<div class="calendar-day"></div>`
5646
- )}
5647
- ${when.when(
5648
- (x, c) => !c.parentContext.parentContext.parent._hideDatesOutsideMonth || !x.isOutsideMonth,
5649
- vividElement.html` <span role="gridcell">
5650
- <button
5651
- class="${(x, c) => classNames.classNames(
5652
- "calendar-day",
5653
- "button",
5654
- [
5655
- "current",
5656
- x.date === c.parentContext.parentContext.parent._currentDate
5657
- ],
5658
- [
5659
- "selected",
5660
- c.parentContext.parentContext.parent._isDateSelected(x.date)
5661
- ],
5662
- [
5663
- "range",
5664
- c.parentContext.parentContext.parent._isDateInSelectedRange(
5665
- x.date
5666
- )
5667
- ],
5668
- [
5669
- "start",
5670
- c.parentContext.parentContext.parent._isDateRangeStart(
5671
- x.date
5672
- )
5673
- ],
5674
- [
5675
- "end",
5676
- c.parentContext.parentContext.parent._isDateRangeEnd(x.date)
5677
- ],
5678
- ["outside-month", x.isOutsideMonth]
5679
- )}"
5680
- ?disabled="${(x, c) => !c.parentContext.parentContext.parent._isDateInValidRange(
5681
- x.date
5682
- )}"
5683
- tabindex="${(x, c) => x.date === c.parentContext.parentContext.parent._tabbableDate ? 2 : -1}"
5684
- aria-selected="${(x, c) => c.parentContext.parentContext.parent._isDateAriaSelected(x.date)}"
5685
- data-date="${(x) => x.date}"
5686
- @click="${(x, c) => c.parentContext.parentContext.parent._onDateClick(x.date)}"
5687
- @focus="${(x, c) => c.parentContext.parentContext.parent._onDateFocus(x.date)}"
5688
- @mouseenter="${(x, c) => c.parentContext.parentContext.parent._onDateMouseEnter(x.date)}"
5689
- @mouseleave="${(x, c) => c.parentContext.parentContext.parent._onDateMouseLeave(x.date)}"
5690
- @keydown="${(x, c) => c.parentContext.parentContext.parent._onDateKeydown(
5691
- x.date,
5692
- c.event
5693
- )}"
5694
- >
5695
- ${(x) => x.label}
5696
- </button>
5697
- </span>`
5698
- )}
5699
- </div>
5700
- `
5701
- )}
5702
- </div>`
5703
- )}`;
5704
- }
5705
- function renderMonthPickerGrid(context) {
5706
- const dividerTag = context.tagFor(definition$2.Divider);
5707
- return vividElement.html`
5708
- <${dividerTag}
5709
- class="months-separator"
5710
- role="presentation"
5711
- ></${dividerTag}>
5712
- <div
5713
- class="month-grid"
5714
- role="grid"
5715
- aria-labelledby="grid-label"
5716
- >
5717
- ${repeat.repeat(
5718
- (x) => x.months,
5719
- vividElement.html`
5720
- <div class="months-row" role="row">
5721
- ${repeat.repeat(
5722
- (x) => x,
5723
- vividElement.html`
5724
- <span role="gridcell">
5725
- <button
5726
- class="${(x, c) => classNames.classNames(
5727
- "month",
5728
- "button",
5729
- [
5730
- "current",
5731
- areMonthsEqual(
5732
- x.month,
5733
- c.parentContext.parentContext.parent._currentMonth
5734
- )
5735
- ],
5736
- [
5737
- "selected",
5738
- areMonthsEqual(
5739
- x.month,
5740
- c.parentContext.parentContext.parent._selectedMonth
5741
- )
5742
- ]
5743
- )}"
5744
- tabindex="${(x, c) => c.parentContext.parentContext.parent._tabbableMonth && areMonthsEqual(
5745
- x.month,
5746
- c.parentContext.parentContext.parent._tabbableMonth
5747
- ) ? 2 : -1}"
5748
- aria-label="${(x) => x.monthName}"
5749
- aria-selected="${(x, c) => areMonthsEqual(
5750
- x.month,
5751
- c.parentContext.parentContext.parent._selectedMonth
5752
- )}"
5753
- data-month="${(x) => monthToStr(x.month)}"
5754
- ?disabled="${(x, c) => !c.parentContext.parentContext.parent._isMonthInValidRange(
5755
- x.month
5756
- )}"
5757
- @click="${(x, c) => c.parentContext.parentContext.parent._onMonthClick(
5758
- x.month
5759
- )}"
5760
- @focus="${(x, c) => c.parentContext.parentContext.parent._onMonthFocus(
5761
- x.month
5762
- )}"
5763
- @keydown="${(x, c) => c.parentContext.parentContext.parent._onMonthKeydown(
5764
- x.month,
5765
- c.event
5766
- )}"
5767
- >
5768
- ${(x) => x.label}
5769
- </button>
5770
- </span>
5771
- `
5772
- )}
5773
- </div>
5774
- `
5775
- )}
5776
- </div>`;
5777
- }
5778
- const DatePickerBaseTemplate = (context) => {
5779
- const popupTag = context.tagFor(definition.Popup);
5780
- const textFieldTag = context.tagFor(textField.TextField);
5781
- const buttonTag = context.tagFor(definition$1.Button);
5782
- return vividElement.html`<div class="base" @keydown="${(x, { event }) => x._onBaseKeyDown(event)}">
5783
- <${textFieldTag} id="text-field"
5784
- ${ref.ref("_textFieldEl")}
5785
- class="control"
5786
- label="${(x) => x.label}"
5787
- helper-text="${(x) => x.helperText}"
5788
- error-text="${(x) => x.errorValidationMessage}"
5789
- placeholder="${(x) => x._textFieldPlaceholder}"
5790
- size="${(x) => x._textFieldSize}"
5791
- current-value="${(x) => x._presentationValue}"
5792
- ?disabled="${(x) => x.disabled}"
5793
- ?readonly="${(x) => x.readOnly}"
5794
- @input="${(x, c) => x._onTextFieldInput(c.event)}"
5795
- @change="${(x) => x._onTextFieldChange()}"
5796
- >
5797
- <slot
5798
- slot="${(x) => x._helperTextSlottedContent?.length ? "helper-text" : void 0}"
5799
- name="helper-text"
5800
- ${slotted.slotted("_helperTextSlottedContent")}
5801
- ></slot>
5802
- <${buttonTag}
5803
- id="calendar-button"
5804
- ${ref.ref("_calendarButtonEl")}
5805
- slot="action-items"
5806
- size="condensed"
5807
- icon="calendar-line"
5808
- appearance="ghost"
5809
- ?disabled="${(x) => x.disabled || x.readOnly}"
5810
- aria-label="${(x) => x._calendarButtonLabel}"
5811
- @click="${(x) => x._onCalendarButtonClick()}"
5812
- ></${buttonTag}>
5813
- </${textFieldTag}>
5814
- <${popupTag}
5815
- ?open="${(x) => x._popupOpen}"
5816
- :anchor="${(x) => x._textFieldEl}"
5817
- placement="bottom-start"
5818
- class="popup">
5819
- <div class="dialog" role="dialog" ${ref.ref(
5820
- "_dialogEl"
5821
- )} aria-modal="true" aria-label="${(x) => x.locale.datePicker.chooseDateLabel}">
5822
- <div class="segments">
5823
- ${repeat.repeat(
5824
- (x) => x._segments,
5825
- vividElement.html` <div class="segment">
5826
- ${renderDialogHeader(context)}
5827
- ${when.when(
5828
- (x) => x.type === "month-picker",
5829
- vividElement.html`${renderMonthPickerGrid(context)}`
5830
- )}
5831
- ${when.when(
5832
- (x) => x.type === "calendar",
5833
- vividElement.html`${renderCalendarGrid(context)}`
5834
- )}
5835
- </div>`
5836
- )}
5837
- </div>
5838
- <div class="footer">
5839
- <${buttonTag}
5840
- tabindex="3"
5841
- class="vwc-button"
5842
- size="condensed"
5843
- label="${(x) => x.locale.datePicker.clearLabel}"
5844
- @click="${(x) => x._onClearClick()},
5845
- ${(x) => x.$emit("clear-click")}"
5846
- ></${buttonTag}>
5847
- <${buttonTag}
5848
- tabindex="3"
5849
- class="vwc-button"
5850
- size="condensed"
5851
- appearance="filled"
5852
- label="${(x) => x.locale.datePicker.okLabel}"
5853
- @click="${(x) => x._onOkClick()}"
5854
- ></${buttonTag}>
5855
- </div>
5856
- </div>
5857
- </${popupTag}>
5858
- </div>`;
5529
+ const MonthsPerRow = 4;
5530
+ const buildMonthPickerGrid = (year, locale) => {
5531
+ const grid = [];
5532
+ let row = [];
5533
+ for (let i = 0; i < 12; i++) {
5534
+ const month = { month: i, year };
5535
+ row.push({
5536
+ label: locale.months.shorthand[i],
5537
+ monthName: locale.months.name[i],
5538
+ month
5539
+ });
5540
+ if (row.length === MonthsPerRow) {
5541
+ grid.push(row);
5542
+ row = [];
5543
+ }
5544
+ }
5545
+ return grid;
5859
5546
  };
5860
5547
 
5861
5548
  const getWeekdays = (locale) => {
@@ -5911,610 +5598,753 @@ const buildCalendarGrid = (month, locale) => {
5911
5598
  };
5912
5599
  };
5913
5600
 
5914
- const MonthsPerRow = 4;
5915
- const buildMonthPickerGrid = (year, locale) => {
5916
- const grid = [];
5917
- let row = [];
5918
- for (let i = 0; i < 12; i++) {
5919
- const month = { month: i, year };
5920
- row.push({
5921
- label: locale.months.shorthand[i],
5922
- monthName: locale.months.name[i],
5923
- month
5924
- });
5925
- if (row.length === MonthsPerRow) {
5926
- grid.push(row);
5927
- row = [];
5928
- }
5929
- }
5930
- return grid;
5931
- };
5932
-
5933
- const yearOfDate = (dateStr) => {
5934
- const date = parseDateStr(dateStr);
5935
- return date.getFullYear();
5936
- };
5937
-
5938
- class _DatePickerBase extends vividElement.VividElement {
5939
- }
5940
- class FormAssociatedDatePickerBase extends formAssociated.FormAssociated(
5941
- _DatePickerBase
5942
- ) {
5943
- constructor() {
5944
- super(...arguments);
5945
- this.proxy = document.createElement("input");
5946
- }
5947
- }
5948
-
5949
- var __defProp = Object.defineProperty;
5601
+ var __defProp$1 = Object.defineProperty;
5950
5602
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5951
- var __decorateClass = (decorators, target, key, kind) => {
5603
+ var __decorateClass$1 = (decorators, target, key, kind) => {
5952
5604
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5953
5605
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
5954
5606
  if (decorator = decorators[i])
5955
5607
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
5956
- if (kind && result) __defProp(target, key, result);
5608
+ if (kind && result) __defProp$1(target, key, result);
5957
5609
  return result;
5958
5610
  };
5959
- const ValidDateFilter = {
5960
- fromView: (value) => {
5961
- if (value && isValidDateStr(value)) {
5962
- return value;
5611
+ const CalendarPicker = (Base) => {
5612
+ class CalendarPickerElement extends Base {
5613
+ // --- Core ---
5614
+ constructor(...args) {
5615
+ super(...args);
5616
+ this._selectedMonth = getCurrentMonth();
5617
+ /**
5618
+ * Today's date.
5619
+ * @internal
5620
+ */
5621
+ this._currentDate = currentDateStr();
5622
+ /**
5623
+ * Today's month.
5624
+ * @internal
5625
+ */
5626
+ this._currentMonth = getCurrentMonth();
5627
+ this._numCalendars = 1;
5628
+ // --- Date picker ---
5629
+ /**
5630
+ * @internal
5631
+ */
5632
+ this._hideDatesOutsideMonth = false;
5633
+ this._lastFocussedDate = null;
5634
+ this._monthPickerYear = null;
5635
+ this._lastFocussedMonth = null;
5636
+ this.value = "";
5963
5637
  }
5964
- return "";
5965
- },
5966
- toView(value) {
5967
- return value;
5968
- }
5969
- };
5970
- class DatePickerBase extends FormAssociatedDatePickerBase {
5971
- // --- Core ---
5972
- constructor() {
5973
- super();
5974
- this.readOnly = false;
5975
- this._selectedMonth = getCurrentMonth();
5976
5638
  /**
5977
- * Today's date.
5978
5639
  * @internal
5979
5640
  */
5980
- this._currentDate = currentDateStr();
5641
+ _adjustSelectedMonthToEnsureVisibilityOf(date) {
5642
+ const month = monthOfDate(date);
5643
+ const firstDisplayedMonth = this._selectedMonth;
5644
+ const lastDisplayedMonth = addMonths(
5645
+ this._selectedMonth,
5646
+ this._numCalendars - 1
5647
+ );
5648
+ if (compareMonths(month, firstDisplayedMonth) < 0) {
5649
+ this._selectedMonth = month;
5650
+ return true;
5651
+ } else if (compareMonths(month, lastDisplayedMonth) > 0) {
5652
+ this._selectedMonth = addMonths(month, 1 - this._numCalendars);
5653
+ return true;
5654
+ }
5655
+ return false;
5656
+ }
5981
5657
  /**
5982
- * Today's month.
5983
5658
  * @internal
5984
5659
  */
5985
- this._currentMonth = getCurrentMonth();
5986
- this.#onFocusIn = () => {
5987
- this.$emit("focus", void 0, { bubbles: false });
5988
- };
5989
- this.#onFocusOut = () => {
5990
- this.$emit("blur", void 0, { bubbles: false });
5991
- };
5992
- // Reformat the presentation value when the locale changes
5993
- this.#localeChangeHandler = {
5994
- handleChange: () => {
5995
- this._updatePresentationValue();
5660
+ _isDateInValidRange(date) {
5661
+ return (!this._resolvedMinDate || compareDateStr(date, this._resolvedMinDate) >= 0) && (!this._resolvedMaxDate || compareDateStr(date, this._resolvedMaxDate) <= 0);
5662
+ }
5663
+ #isMonthAfterValidRange(month) {
5664
+ return this._resolvedMaxDate && compareMonths(month, monthOfDate(this._resolvedMaxDate)) > 0;
5665
+ }
5666
+ #isMonthBeforeValidRange(month) {
5667
+ return this._resolvedMinDate && compareMonths(month, monthOfDate(this._resolvedMinDate)) < 0;
5668
+ }
5669
+ /**
5670
+ * @internal
5671
+ */
5672
+ _isMonthInValidRange(month) {
5673
+ return !(this.#isMonthBeforeValidRange(month) || this.#isMonthAfterValidRange(month));
5674
+ }
5675
+ /**
5676
+ * @internal
5677
+ */
5678
+ _closePopup(restoreFocusToTextField = true) {
5679
+ super._closePopup(restoreFocusToTextField);
5680
+ this._monthPickerYear = null;
5681
+ }
5682
+ /**
5683
+ * @internal
5684
+ */
5685
+ _onPickerButtonClick() {
5686
+ super._onPickerButtonClick();
5687
+ if (this._popupOpen) {
5688
+ vividElement.DOM.processUpdates();
5689
+ const tabbableDate = this._tabbableDate;
5690
+ if (tabbableDate)
5691
+ this.shadowRoot.querySelector(
5692
+ `[data-date="${tabbableDate}"]`
5693
+ ).focus();
5996
5694
  }
5997
- };
5998
- this._popupOpen = false;
5999
- this.#dismissOnClickOutside = (event) => {
6000
- if (!this._popupOpen) {
6001
- return;
5695
+ }
5696
+ // --- Calendar header ---
5697
+ /**
5698
+ * @internal
5699
+ */
5700
+ _onTitleActionClick() {
5701
+ if (this._inMonthPicker) {
5702
+ this._monthPickerYear = null;
5703
+ } else {
5704
+ this._monthPickerYear = this._selectedMonth.year;
6002
5705
  }
6003
- const path = event.composedPath();
6004
- const elementsToIgnoreClicksOn = [this._dialogEl, this._calendarButtonEl];
6005
- if (!elementsToIgnoreClicksOn.some((element) => path.includes(element))) {
6006
- this._closePopup(false);
5706
+ }
5707
+ get _isPrevYearDisabled() {
5708
+ const currentYear = this._inMonthPicker ? this._monthPickerYear : this._selectedMonth.year;
5709
+ const prevYear = currentYear - 1;
5710
+ return this._resolvedMinDate && prevYear < yearOfDate(this._resolvedMinDate);
5711
+ }
5712
+ /**
5713
+ * @internal
5714
+ */
5715
+ _onPrevYearClick() {
5716
+ if (this._inMonthPicker) {
5717
+ this._monthPickerYear = this._monthPickerYear - 1;
5718
+ } else {
5719
+ this._selectedMonth = {
5720
+ year: this._selectedMonth.year - 1,
5721
+ month: this._selectedMonth.month
5722
+ };
6007
5723
  }
6008
- };
6009
- this._presentationValue = "";
6010
- this._numCalendars = 1;
5724
+ }
5725
+ get _isNextYearDisabled() {
5726
+ const currentYear = this._inMonthPicker ? this._monthPickerYear : this._selectedMonth.year;
5727
+ const nextYear = currentYear + 1;
5728
+ return this._resolvedMaxDate && nextYear > yearOfDate(this._resolvedMaxDate);
5729
+ }
6011
5730
  /**
6012
5731
  * @internal
6013
5732
  */
6014
- this._hideDatesOutsideMonth = false;
6015
- this._lastFocussedDate = null;
6016
- this._monthPickerYear = null;
6017
- this._lastFocussedMonth = null;
6018
- this.value = "";
6019
- this.min = "";
6020
- this.max = "";
6021
- }
6022
- /**
6023
- * @internal
6024
- */
6025
- minChanged(_, newMin) {
6026
- if (this.proxy instanceof HTMLInputElement) {
6027
- this.proxy.min = newMin;
6028
- this.validate();
5733
+ _onNextYearClick() {
5734
+ if (this._inMonthPicker) {
5735
+ this._monthPickerYear = this._monthPickerYear + 1;
5736
+ } else {
5737
+ this._selectedMonth = {
5738
+ year: this._selectedMonth.year + 1,
5739
+ month: this._selectedMonth.month
5740
+ };
5741
+ }
6029
5742
  }
6030
- }
6031
- /**
6032
- * @internal
6033
- */
6034
- maxChanged(_, newMax) {
6035
- if (this.proxy instanceof HTMLInputElement) {
6036
- this.proxy.max = newMax;
6037
- this.validate();
5743
+ /**
5744
+ * @internal
5745
+ */
5746
+ get _isPrevMonthDisabled() {
5747
+ return this.#isMonthBeforeValidRange(addMonths(this._selectedMonth, -1));
6038
5748
  }
6039
- }
6040
- /**
6041
- * @internal
6042
- */
6043
- readOnlyChanged() {
6044
- if (this.proxy instanceof HTMLInputElement) {
6045
- this.proxy.readOnly = this.readOnly;
6046
- this.validate();
5749
+ /**
5750
+ * @internal
5751
+ */
5752
+ _onPrevMonthClick() {
5753
+ this._selectedMonth = addMonths(this._selectedMonth, -1);
6047
5754
  }
6048
- }
6049
- _adjustSelectedMonthToEnsureVisibilityOf(date) {
6050
- const month = monthOfDate(date);
6051
- const firstDisplayedMonth = this._selectedMonth;
6052
- const lastDisplayedMonth = addMonths(
6053
- this._selectedMonth,
6054
- this._numCalendars - 1
6055
- );
6056
- if (compareMonths(month, firstDisplayedMonth) < 0) {
6057
- this._selectedMonth = month;
6058
- return true;
6059
- } else if (compareMonths(month, lastDisplayedMonth) > 0) {
6060
- this._selectedMonth = addMonths(month, 1 - this._numCalendars);
6061
- return true;
5755
+ /**
5756
+ * @internal
5757
+ */
5758
+ get _isNextMonthDisabled() {
5759
+ return this.#isMonthAfterValidRange(addMonths(this._selectedMonth, 1));
6062
5760
  }
6063
- return false;
6064
- }
6065
- /**
6066
- * @internal
6067
- */
6068
- _isDateInValidRange(date) {
6069
- return (!this.min || compareDateStr(date, this.min) >= 0) && (!this.max || compareDateStr(date, this.max) <= 0);
6070
- }
6071
- #isMonthAfterValidRange(month) {
6072
- return this.max && compareMonths(month, monthOfDate(this.max)) > 0;
6073
- }
6074
- #isMonthBeforeValidRange(month) {
6075
- return this.min && compareMonths(month, monthOfDate(this.min)) < 0;
6076
- }
6077
- /**
6078
- * @internal
6079
- */
6080
- _isMonthInValidRange(month) {
6081
- return !(this.#isMonthBeforeValidRange(month) || this.#isMonthAfterValidRange(month));
6082
- }
6083
- connectedCallback() {
6084
- super.connectedCallback();
6085
- document.addEventListener("click", this.#dismissOnClickOutside);
6086
- this.addEventListener("focusin", this.#onFocusIn);
6087
- this.addEventListener("focusout", this.#onFocusOut);
6088
- this.#localeChangeObserver = vividElement.Observable.binding(
6089
- () => this.locale,
6090
- this.#localeChangeHandler
6091
- );
6092
- this.#localeChangeObserver.observe(this, vividElement.defaultExecutionContext);
6093
- }
6094
- disconnectedCallback() {
6095
- super.disconnectedCallback();
6096
- document.removeEventListener("click", this.#dismissOnClickOutside);
6097
- this.removeEventListener("focusin", this.#onFocusIn);
6098
- this.removeEventListener("focusout", this.#onFocusOut);
6099
- this.#localeChangeObserver.disconnect();
6100
- }
6101
- #onFocusIn;
6102
- #onFocusOut;
6103
- /**
6104
- * @internal
6105
- */
6106
- validate() {
6107
- if (this.proxy) {
6108
- this.proxy.setCustomValidity(this._getCustomValidationError() ?? "");
5761
+ /**
5762
+ * @internal
5763
+ */
5764
+ _onNextMonthClick() {
5765
+ this._selectedMonth = addMonths(this._selectedMonth, 1);
6109
5766
  }
6110
- super.validate(this._textFieldEl?.querySelector("input") ?? void 0);
6111
- }
6112
- #localeChangeHandler;
6113
- #localeChangeObserver;
6114
- #dismissOnClickOutside;
6115
- #openPopupIfPossible() {
6116
- if (!this.readOnly) {
6117
- this._popupOpen = true;
5767
+ /**
5768
+ * @internal
5769
+ */
5770
+ get _segments() {
5771
+ const segments = [];
5772
+ if (this._inMonthPicker) {
5773
+ segments.push({
5774
+ id: 0,
5775
+ type: "month-picker",
5776
+ title: `${this._monthPickerYear}`,
5777
+ titleClickable: true,
5778
+ prevYearButton: true,
5779
+ nextYearButton: true,
5780
+ months: buildMonthPickerGrid(
5781
+ this._monthPickerYear,
5782
+ this.locale.calendarPicker
5783
+ )
5784
+ });
5785
+ } else {
5786
+ for (let i = 0; i < this._numCalendars; i++) {
5787
+ const month = addMonths(this._selectedMonth, i);
5788
+ const isSingle = this._numCalendars === 1;
5789
+ const isFirst = i === 0;
5790
+ const isLast = i === this._numCalendars - 1;
5791
+ segments.push({
5792
+ id: i,
5793
+ type: "calendar",
5794
+ title: `${this.locale.calendarPicker.months.name[month.month]} ${month.year}`,
5795
+ titleClickable: isSingle,
5796
+ prevYearButton: isFirst && isSingle,
5797
+ prevMonthButton: isFirst,
5798
+ nextMonthButton: isLast,
5799
+ nextYearButton: isLast && isSingle,
5800
+ calendar: buildCalendarGrid(month, this.locale.calendarPicker)
5801
+ });
5802
+ }
5803
+ }
5804
+ return segments;
6118
5805
  }
6119
- }
6120
- /**
6121
- * @internal
6122
- */
6123
- _closePopup(restoreFocusToTextField = true) {
6124
- this._popupOpen = false;
6125
- this._monthPickerYear = null;
6126
- if (restoreFocusToTextField) {
6127
- this._textFieldEl.focus();
5806
+ /**
5807
+ * @internal
5808
+ */
5809
+ _isDateSelected(_) {
5810
+ return false;
6128
5811
  }
6129
- }
6130
- /**
6131
- * On keydown anywhere in the date picker.
6132
- * @internal
6133
- */
6134
- _onBaseKeyDown(event) {
6135
- if (this._popupOpen && index.handleEscapeKeyAndStopPropogation(event)) {
6136
- this._closePopup();
5812
+ /**
5813
+ * @internal
5814
+ * @private
5815
+ */
5816
+ _isDateInSelectedRange(_) {
6137
5817
  return false;
6138
5818
  }
6139
- if (this._trappedFocus(
6140
- event,
6141
- () => this.shadowRoot.querySelectorAll(`
6142
- .dialog .button:not(:disabled),
6143
- .dialog .vwc-button:not(:disabled)
6144
- `)
6145
- )) {
5819
+ /**
5820
+ * @internal
5821
+ */
5822
+ _isDateRangeStart(_) {
6146
5823
  return false;
6147
5824
  }
6148
- return true;
6149
- }
6150
- /**
6151
- * @internal
6152
- */
6153
- _presentationValueChanged() {
6154
- this.dirtyValue = true;
6155
- this.validate();
6156
- }
6157
- /**
6158
- * @internal
6159
- */
6160
- _onTextFieldInput(event) {
6161
- const textField = event.currentTarget;
6162
- this._presentationValue = textField.value;
6163
- }
6164
- /**
6165
- * @internal
6166
- */
6167
- _onCalendarButtonClick() {
6168
- if (this._popupOpen) {
6169
- this._closePopup();
6170
- } else {
6171
- this.#openPopupIfPossible();
6172
- vividElement.DOM.processUpdates();
6173
- const tabbableDate = this._tabbableDate;
6174
- if (tabbableDate)
6175
- this.shadowRoot.querySelector(
6176
- `[data-date="${tabbableDate}"]`
5825
+ /**
5826
+ * @internal
5827
+ */
5828
+ _isDateRangeEnd(_) {
5829
+ return false;
5830
+ }
5831
+ /**
5832
+ * @internal
5833
+ */
5834
+ _onDateMouseEnter(_) {
5835
+ }
5836
+ /**
5837
+ * @internal
5838
+ */
5839
+ _onDateMouseLeave(_) {
5840
+ }
5841
+ /**
5842
+ * Handle keydown on a date in the calendar.
5843
+ * @internal
5844
+ */
5845
+ _onDateKeydown(date, event) {
5846
+ let newDate = null;
5847
+ if (event.key === "ArrowUp") {
5848
+ newDate = addDays(date, -7);
5849
+ } else if (event.key === "ArrowDown") {
5850
+ newDate = addDays(date, 7);
5851
+ } else if (event.key === "ArrowLeft") {
5852
+ newDate = addDays(date, -1);
5853
+ } else if (event.key === "ArrowRight") {
5854
+ newDate = addDays(date, 1);
5855
+ }
5856
+ if (newDate && this._isDateInValidRange(newDate)) {
5857
+ if (this._adjustSelectedMonthToEnsureVisibilityOf(newDate)) {
5858
+ vividElement.DOM.processUpdates();
5859
+ }
5860
+ this._dialogEl.querySelector(
5861
+ `[data-date="${newDate}"]`
6177
5862
  ).focus();
5863
+ return false;
5864
+ }
5865
+ return true;
6178
5866
  }
6179
- }
6180
- // --- Dialog header ---
6181
- /**
6182
- * @internal
6183
- */
6184
- _onTitleActionClick() {
6185
- if (this._inMonthPicker) {
5867
+ /**
5868
+ * @internal
5869
+ */
5870
+ _onDateFocus(date) {
5871
+ this._lastFocussedDate = date;
5872
+ }
5873
+ get _tabbableDate() {
5874
+ const datesInSegments = this._segments.filter(
5875
+ (segment) => segment.type === "calendar"
5876
+ ).flatMap((segment) => segment.calendar.grid.flat().map((d) => d.date));
5877
+ const candidates = [
5878
+ this._lastFocussedDate,
5879
+ ...this._getSelectedDates(),
5880
+ currentDateStr(),
5881
+ ...datesInSegments
5882
+ ];
5883
+ const firstVisibleMonth = this._selectedMonth;
5884
+ const lastVisibleMonth = addMonths(
5885
+ this._selectedMonth,
5886
+ this._numCalendars - 1
5887
+ );
5888
+ return candidates.find(
5889
+ (date) => date && compareMonths(monthOfDate(date), firstVisibleMonth) >= 0 && compareMonths(monthOfDate(date), lastVisibleMonth) <= 0 && this._isDateInValidRange(date)
5890
+ ) ?? null;
5891
+ }
5892
+ /**
5893
+ * @internal
5894
+ */
5895
+ get _inMonthPicker() {
5896
+ return this._monthPickerYear !== null;
5897
+ }
5898
+ /**
5899
+ * Handle month selected in the month picker.
5900
+ * @internal
5901
+ */
5902
+ _onMonthClick(month) {
5903
+ this._selectedMonth = month;
6186
5904
  this._monthPickerYear = null;
6187
- } else {
6188
- this._monthPickerYear = this._selectedMonth.year;
6189
5905
  }
6190
- }
6191
- get _isPrevYearDisabled() {
6192
- const currentYear = this._inMonthPicker ? this._monthPickerYear : this._selectedMonth.year;
6193
- const prevYear = currentYear - 1;
6194
- return this.min && prevYear < yearOfDate(this.min);
6195
- }
6196
- /**
6197
- * @internal
6198
- */
6199
- _onPrevYearClick() {
6200
- if (this._inMonthPicker) {
6201
- this._monthPickerYear = this._monthPickerYear - 1;
6202
- } else {
6203
- this._selectedMonth = {
6204
- year: this._selectedMonth.year - 1,
6205
- month: this._selectedMonth.month
6206
- };
5906
+ /**
5907
+ * Handle keydown on a month in the month picker.
5908
+ * @internal
5909
+ */
5910
+ _onMonthKeydown(month, event) {
5911
+ let newMonth = null;
5912
+ if (event.key === "ArrowUp") {
5913
+ newMonth = addMonths(month, -4);
5914
+ } else if (event.key === "ArrowDown") {
5915
+ newMonth = addMonths(month, MonthsPerRow);
5916
+ } else if (event.key === "ArrowLeft") {
5917
+ newMonth = addMonths(month, -1);
5918
+ } else if (event.key === "ArrowRight") {
5919
+ newMonth = addMonths(month, 1);
5920
+ }
5921
+ if (newMonth && this._isMonthInValidRange(newMonth)) {
5922
+ if (newMonth.year !== this._monthPickerYear) {
5923
+ this._monthPickerYear = newMonth.year;
5924
+ vividElement.DOM.processUpdates();
5925
+ }
5926
+ this._dialogEl.querySelector(
5927
+ `[data-month="${monthToStr(newMonth)}"]`
5928
+ ).focus();
5929
+ return false;
5930
+ }
5931
+ return true;
5932
+ }
5933
+ /**
5934
+ * @internal
5935
+ */
5936
+ _onMonthFocus(month) {
5937
+ this._lastFocussedMonth = month;
5938
+ }
5939
+ get _tabbableMonth() {
5940
+ const monthsInSegments = this._segments.filter(
5941
+ (segments) => segments.type === "month-picker"
5942
+ ).flatMap((segment) => segment.months.flat().map((c) => c.month));
5943
+ const candidates = [
5944
+ this._lastFocussedMonth,
5945
+ this._selectedMonth,
5946
+ getCurrentMonth(),
5947
+ ...monthsInSegments
5948
+ ];
5949
+ return candidates.find(
5950
+ (month) => month && month.year === this._monthPickerYear && this._isMonthInValidRange(month)
5951
+ ) ?? null;
6207
5952
  }
6208
5953
  }
6209
- get _isNextYearDisabled() {
6210
- const currentYear = this._inMonthPicker ? this._monthPickerYear : this._selectedMonth.year;
6211
- const nextYear = currentYear + 1;
6212
- return this.max && nextYear > yearOfDate(this.max);
6213
- }
6214
- /**
6215
- * @internal
6216
- */
6217
- _onNextYearClick() {
6218
- if (this._inMonthPicker) {
6219
- this._monthPickerYear = this._monthPickerYear + 1;
6220
- } else {
6221
- this._selectedMonth = {
6222
- year: this._selectedMonth.year + 1,
6223
- month: this._selectedMonth.month
6224
- };
5954
+ __decorateClass$1([
5955
+ vividElement.observable
5956
+ ], CalendarPickerElement.prototype, "_selectedMonth", 2);
5957
+ __decorateClass$1([
5958
+ vividElement.volatile
5959
+ ], CalendarPickerElement.prototype, "_isPrevYearDisabled", 1);
5960
+ __decorateClass$1([
5961
+ vividElement.volatile
5962
+ ], CalendarPickerElement.prototype, "_isNextYearDisabled", 1);
5963
+ __decorateClass$1([
5964
+ vividElement.observable
5965
+ ], CalendarPickerElement.prototype, "_numCalendars", 2);
5966
+ __decorateClass$1([
5967
+ vividElement.observable
5968
+ ], CalendarPickerElement.prototype, "_lastFocussedDate", 2);
5969
+ __decorateClass$1([
5970
+ vividElement.volatile
5971
+ ], CalendarPickerElement.prototype, "_tabbableDate", 1);
5972
+ __decorateClass$1([
5973
+ vividElement.observable
5974
+ ], CalendarPickerElement.prototype, "_monthPickerYear", 2);
5975
+ __decorateClass$1([
5976
+ vividElement.observable
5977
+ ], CalendarPickerElement.prototype, "_lastFocussedMonth", 2);
5978
+ __decorateClass$1([
5979
+ vividElement.volatile
5980
+ ], CalendarPickerElement.prototype, "_tabbableMonth", 1);
5981
+ return CalendarPickerElement;
5982
+ };
5983
+
5984
+ var __defProp = Object.defineProperty;
5985
+ var __decorateClass = (decorators, target, key, kind) => {
5986
+ var result = void 0 ;
5987
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
5988
+ if (decorator = decorators[i])
5989
+ result = (decorator(target, key, result) ) || result;
5990
+ if (result) __defProp(target, key, result);
5991
+ return result;
5992
+ };
5993
+ const ValidDateFilter = {
5994
+ fromView: (value) => {
5995
+ if (value && isValidDateStr(value)) {
5996
+ return value;
6225
5997
  }
5998
+ return "";
5999
+ },
6000
+ toView(value) {
6001
+ return value;
6226
6002
  }
6227
- /**
6228
- * @internal
6229
- */
6230
- get _isPrevMonthDisabled() {
6231
- return this.#isMonthBeforeValidRange(addMonths(this._selectedMonth, -1));
6232
- }
6233
- /**
6234
- * @internal
6235
- */
6236
- _onPrevMonthClick() {
6237
- this._selectedMonth = addMonths(this._selectedMonth, -1);
6238
- }
6239
- /**
6240
- * @internal
6241
- */
6242
- get _isNextMonthDisabled() {
6243
- return this.#isMonthAfterValidRange(addMonths(this._selectedMonth, 1));
6244
- }
6245
- /**
6246
- * @internal
6247
- */
6248
- _onNextMonthClick() {
6249
- this._selectedMonth = addMonths(this._selectedMonth, 1);
6250
- }
6251
- /**
6252
- * @internal
6253
- */
6254
- get _segments() {
6255
- const segments = [];
6256
- if (this._inMonthPicker) {
6257
- segments.push({
6258
- id: 0,
6259
- type: "month-picker",
6260
- title: `${this._monthPickerYear}`,
6261
- titleClickable: true,
6262
- prevYearButton: true,
6263
- nextYearButton: true,
6264
- months: buildMonthPickerGrid(
6265
- this._monthPickerYear,
6266
- this.locale.datePicker
6267
- )
6268
- });
6269
- } else {
6270
- for (let i = 0; i < this._numCalendars; i++) {
6271
- const month = addMonths(this._selectedMonth, i);
6272
- const isSingle = this._numCalendars === 1;
6273
- const isFirst = i === 0;
6274
- const isLast = i === this._numCalendars - 1;
6275
- segments.push({
6276
- id: i,
6277
- type: "calendar",
6278
- title: `${this.locale.datePicker.months.name[month.month]} ${month.year}`,
6279
- titleClickable: isSingle,
6280
- prevYearButton: isFirst && isSingle,
6281
- prevMonthButton: isFirst,
6282
- nextMonthButton: isLast,
6283
- nextYearButton: isLast && isSingle,
6284
- calendar: buildCalendarGrid(month, this.locale.datePicker)
6285
- });
6003
+ };
6004
+ const MinMaxCalendarPicker = (SuperClass) => {
6005
+ class MinMaxDatePickerElement extends SuperClass {
6006
+ /**
6007
+ * @internal
6008
+ */
6009
+ minChanged(_, newMin) {
6010
+ if (this.proxy instanceof HTMLInputElement) {
6011
+ this.proxy.min = newMin;
6012
+ this.validate();
6286
6013
  }
6287
6014
  }
6288
- return segments;
6289
- }
6290
- /**
6291
- * @internal
6292
- */
6293
- _isDateSelected(_) {
6294
- return false;
6295
- }
6296
- /**
6297
- * @internal
6298
- */
6299
- _isDateInSelectedRange(_) {
6300
- return false;
6301
- }
6302
- /**
6303
- * @internal
6304
- */
6305
- _isDateRangeStart(_) {
6306
- return false;
6307
- }
6308
- /**
6309
- * @internal
6310
- */
6311
- _isDateRangeEnd(_) {
6312
- return false;
6313
- }
6314
- /**
6315
- * @internal
6316
- */
6317
- _onDateMouseEnter(_) {
6318
- }
6319
- /**
6320
- * @internal
6321
- */
6322
- _onDateMouseLeave(_) {
6323
- }
6324
- /**
6325
- * Handle keydown on a date in the calendar.
6326
- * @internal
6327
- */
6328
- _onDateKeydown(date, event) {
6329
- let newDate = null;
6330
- if (event.key === "ArrowUp") {
6331
- newDate = addDays(date, -7);
6332
- } else if (event.key === "ArrowDown") {
6333
- newDate = addDays(date, 7);
6334
- } else if (event.key === "ArrowLeft") {
6335
- newDate = addDays(date, -1);
6336
- } else if (event.key === "ArrowRight") {
6337
- newDate = addDays(date, 1);
6015
+ /**
6016
+ * @internal
6017
+ */
6018
+ get _resolvedMinDate() {
6019
+ return this.min;
6338
6020
  }
6339
- if (newDate && this._isDateInValidRange(newDate)) {
6340
- if (this._adjustSelectedMonthToEnsureVisibilityOf(newDate)) {
6341
- vividElement.DOM.processUpdates();
6021
+ /**
6022
+ * @internal
6023
+ */
6024
+ maxChanged(_, newMax) {
6025
+ if (this.proxy instanceof HTMLInputElement) {
6026
+ this.proxy.max = newMax;
6027
+ this.validate();
6342
6028
  }
6343
- this._dialogEl.querySelector(
6344
- `[data-date="${newDate}"]`
6345
- ).focus();
6346
- return false;
6347
6029
  }
6348
- return true;
6349
- }
6350
- /**
6351
- * @internal
6352
- */
6353
- _onDateFocus(date) {
6354
- this._lastFocussedDate = date;
6355
- }
6356
- get _tabbableDate() {
6357
- const datesInSegments = this._segments.filter(
6358
- (segment) => segment.type === "calendar"
6359
- ).flatMap((segment) => segment.calendar.grid.flat().map((d) => d.date));
6360
- const candidates = [
6361
- this._lastFocussedDate,
6362
- ...this._getSelectedDates(),
6363
- currentDateStr(),
6364
- ...datesInSegments
6365
- ];
6366
- const firstVisibleMonth = this._selectedMonth;
6367
- const lastVisibleMonth = addMonths(
6368
- this._selectedMonth,
6369
- this._numCalendars - 1
6370
- );
6371
- return candidates.find(
6372
- (date) => date && compareMonths(monthOfDate(date), firstVisibleMonth) >= 0 && compareMonths(monthOfDate(date), lastVisibleMonth) <= 0 && this._isDateInValidRange(date)
6373
- ) ?? null;
6374
- }
6375
- /**
6376
- * @internal
6377
- */
6378
- get _inMonthPicker() {
6379
- return this._monthPickerYear !== null;
6380
- }
6381
- /**
6382
- * Handle month selected in the month picker.
6383
- * @internal
6384
- */
6385
- _onMonthClick(month) {
6386
- this._selectedMonth = month;
6387
- this._monthPickerYear = null;
6388
- }
6389
- /**
6390
- * Handle keydown on a month in the month picker.
6391
- * @internal
6392
- */
6393
- _onMonthKeydown(month, event) {
6394
- let newMonth = null;
6395
- if (event.key === "ArrowUp") {
6396
- newMonth = addMonths(month, -4);
6397
- } else if (event.key === "ArrowDown") {
6398
- newMonth = addMonths(month, MonthsPerRow);
6399
- } else if (event.key === "ArrowLeft") {
6400
- newMonth = addMonths(month, -1);
6401
- } else if (event.key === "ArrowRight") {
6402
- newMonth = addMonths(month, 1);
6030
+ /**
6031
+ * The latest accepted date.
6032
+ * @internal
6033
+ */
6034
+ get _resolvedMaxDate() {
6035
+ return this.max;
6403
6036
  }
6404
- if (newMonth && this._isMonthInValidRange(newMonth)) {
6405
- if (newMonth.year !== this._monthPickerYear) {
6406
- this._monthPickerYear = newMonth.year;
6407
- vividElement.DOM.processUpdates();
6408
- }
6409
- this._dialogEl.querySelector(
6410
- `[data-month="${monthToStr(newMonth)}"]`
6411
- ).focus();
6412
- return false;
6037
+ constructor(...args) {
6038
+ super(...args);
6039
+ this.min = "";
6040
+ this.max = "";
6413
6041
  }
6414
- return true;
6415
- }
6416
- /**
6417
- * @internal
6418
- */
6419
- _onMonthFocus(month) {
6420
- this._lastFocussedMonth = month;
6421
- }
6422
- get _tabbableMonth() {
6423
- const monthsInSegments = this._segments.filter(
6424
- (segments) => segments.type === "month-picker"
6425
- ).flatMap((segment) => segment.months.flat().map((c) => c.month));
6426
- const candidates = [
6427
- this._lastFocussedMonth,
6428
- this._selectedMonth,
6429
- getCurrentMonth(),
6430
- ...monthsInSegments
6431
- ];
6432
- return candidates.find(
6433
- (month) => month && month.year === this._monthPickerYear && this._isMonthInValidRange(month)
6434
- ) ?? null;
6435
- }
6436
- // --- Dialog footer ---
6437
- /**
6438
- * @internal
6439
- */
6440
- _onOkClick() {
6441
- this._closePopup();
6442
- }
6443
- /**
6444
- * @internal
6445
- */
6446
- _onClearClick() {
6447
- this._closePopup();
6448
6042
  }
6449
- }
6450
- __decorateClass([
6451
- vividElement.attr({ converter: ValidDateFilter })
6452
- ], DatePickerBase.prototype, "min", 2);
6453
- __decorateClass([
6454
- vividElement.attr({ converter: ValidDateFilter })
6455
- ], DatePickerBase.prototype, "max", 2);
6456
- __decorateClass([
6457
- vividElement.attr({ attribute: "value" })
6458
- ], DatePickerBase.prototype, "initialValue", 2);
6459
- __decorateClass([
6460
- vividElement.attr({ attribute: "current-value" })
6461
- ], DatePickerBase.prototype, "currentValue", 2);
6462
- __decorateClass([
6463
- vividElement.attr({ attribute: "readonly", mode: "boolean" })
6464
- ], DatePickerBase.prototype, "readOnly", 2);
6465
- __decorateClass([
6466
- vividElement.observable
6467
- ], DatePickerBase.prototype, "_selectedMonth", 2);
6468
- __decorateClass([
6469
- vividElement.observable
6470
- ], DatePickerBase.prototype, "_popupOpen", 2);
6471
- __decorateClass([
6472
- vividElement.observable
6473
- ], DatePickerBase.prototype, "_presentationValue", 2);
6474
- __decorateClass([
6475
- vividElement.volatile
6476
- ], DatePickerBase.prototype, "_isPrevYearDisabled", 1);
6477
- __decorateClass([
6478
- vividElement.volatile
6479
- ], DatePickerBase.prototype, "_isNextYearDisabled", 1);
6480
- __decorateClass([
6481
- vividElement.observable
6482
- ], DatePickerBase.prototype, "_numCalendars", 2);
6483
- __decorateClass([
6484
- vividElement.observable
6485
- ], DatePickerBase.prototype, "_lastFocussedDate", 2);
6486
- __decorateClass([
6487
- vividElement.volatile
6488
- ], DatePickerBase.prototype, "_tabbableDate", 1);
6489
- __decorateClass([
6490
- vividElement.observable
6491
- ], DatePickerBase.prototype, "_monthPickerYear", 2);
6492
- __decorateClass([
6493
- vividElement.observable
6494
- ], DatePickerBase.prototype, "_lastFocussedMonth", 2);
6495
- __decorateClass([
6496
- vividElement.volatile
6497
- ], DatePickerBase.prototype, "_tabbableMonth", 1);
6498
- applyMixinsWithObservables.applyMixinsWithObservables(
6499
- DatePickerBase,
6500
- localized.Localized,
6501
- formElements.FormElementHelperText,
6502
- trappedFocus.TrappedFocus
6503
- );
6504
-
6505
- const formatPresentationDate = (dateStr, locale) => {
6506
- const date = parseDateStr(dateStr);
6507
- return format(date, locale.dateFormat);
6043
+ __decorateClass([
6044
+ vividElement.attr({ converter: ValidDateFilter })
6045
+ ], MinMaxDatePickerElement.prototype, "min");
6046
+ __decorateClass([
6047
+ vividElement.attr({ converter: ValidDateFilter })
6048
+ ], MinMaxDatePickerElement.prototype, "max");
6049
+ return MinMaxDatePickerElement;
6508
6050
  };
6509
- const parsePresentationDate = (presentationDate, locale) => {
6510
- const date = parse(presentationDate, locale.dateFormat, /* @__PURE__ */ new Date());
6511
- return formatDateStr(date);
6051
+
6052
+ function renderDialogHeader(context) {
6053
+ const buttonTag = context.tagFor(definition.Button);
6054
+ return vividElement.html` <div class="header">
6055
+ ${when.when(
6056
+ (x) => x.prevYearButton,
6057
+ vividElement.html`
6058
+ <${buttonTag}
6059
+ tabindex='1'
6060
+ class='vwc-button'
6061
+ size='super-condensed'
6062
+ icon='${(_, c) => c.parent._inMonthPicker ? "chevron-left-line" : "double-chevron-left-line"}'
6063
+ aria-label='${(_, c) => c.parent.locale.calendarPicker.prevYearLabel}'
6064
+ ?disabled='${(_, c) => c.parent._isPrevYearDisabled}'
6065
+ @click='${(_, c) => c.parent._onPrevYearClick()}'
6066
+ ></${buttonTag}>
6067
+ `
6068
+ )}
6069
+ ${when.when(
6070
+ (x) => x.prevMonthButton,
6071
+ vividElement.html`
6072
+ <${buttonTag}
6073
+ tabindex='1'
6074
+ class='vwc-button'
6075
+ size='super-condensed'
6076
+ icon='chevron-left-line'
6077
+ aria-label='${(_, c) => c.parent.locale.calendarPicker.prevMonthLabel}'
6078
+ ?disabled='${(_, c) => c.parent._isPrevMonthDisabled}'
6079
+ @click='${(_, c) => c.parent._onPrevMonthClick()}'
6080
+ ></${buttonTag}>
6081
+ `
6082
+ )}
6083
+ <div class="title">
6084
+ ${when.when(
6085
+ (x) => x.titleClickable,
6086
+ vividElement.html`
6087
+ <button
6088
+ tabindex="1"
6089
+ id="${(x) => `grid-label-${x.id}`}"
6090
+ class="title-action button"
6091
+ aria-live="polite"
6092
+ @click="${(_, c) => c.parent._onTitleActionClick()}"
6093
+ >
6094
+ ${(x) => x.title}
6095
+ </button>
6096
+ `
6097
+ )}
6098
+ ${when.when(
6099
+ (x) => !x.titleClickable,
6100
+ vividElement.html`
6101
+ <div
6102
+ id="${(x) => `grid-label-${x.id}`}"
6103
+ class="title-action"
6104
+ aria-live="polite"
6105
+ >
6106
+ ${(x) => x.title}
6107
+ </div>
6108
+ `
6109
+ )}
6110
+ </div>
6111
+
6112
+ ${when.when(
6113
+ (x) => x.nextMonthButton,
6114
+ vividElement.html`
6115
+ <${buttonTag}
6116
+ tabindex='1'
6117
+ class='vwc-button'
6118
+ size='super-condensed'
6119
+ icon='chevron-right-line'
6120
+ aria-label='${(_, c) => c.parent.locale.calendarPicker.nextMonthLabel}'
6121
+ ?disabled='${(_, c) => c.parent._isNextMonthDisabled}'
6122
+ @click='${(_, c) => c.parent._onNextMonthClick()}'
6123
+ ></${buttonTag}>
6124
+ `
6125
+ )}
6126
+ ${when.when(
6127
+ (x) => x.nextYearButton,
6128
+ vividElement.html`
6129
+ <${buttonTag}
6130
+ tabindex='1'
6131
+ class='vwc-button'
6132
+ size='super-condensed'
6133
+ icon='${(_, c) => c.parent._inMonthPicker ? "chevron-right-line" : "double-chevron-right-line"}'
6134
+ aria-label='${(_, c) => c.parent.locale.calendarPicker.nextYearLabel}'
6135
+ ?disabled='${(_, c) => c.parent._isNextYearDisabled}'
6136
+ @click='${(_, c) => c.parent._onNextYearClick()}'
6137
+ ></${buttonTag}>
6138
+ `
6139
+ )}
6140
+ </div>`;
6141
+ }
6142
+ function renderCalendarGrid(context) {
6143
+ const dividerTag = context.tagFor(definition$1.Divider);
6144
+ return vividElement.html`
6145
+ <div
6146
+ class='calendar'
6147
+ role='grid'
6148
+ aria-labelledby='${(x) => `grid-label-${x.id}`}'
6149
+ >
6150
+ <div class='calendar-weekdays' role='row'>
6151
+ ${repeat.repeat(
6152
+ (x) => x.calendar.weekdays,
6153
+ vividElement.html`
6154
+ <div
6155
+ class="calendar-weekday"
6156
+ role="columnheader"
6157
+ aria-label="${(x) => x.name}"
6158
+ >
6159
+ ${(x) => x.shortName}
6160
+ </div>
6161
+ `
6162
+ )}
6163
+ </div>
6164
+ <${dividerTag} class='calendar-separator' role='presentation'></${dividerTag}>
6165
+ ${repeat.repeat(
6166
+ (x) => x.calendar.grid,
6167
+ vividElement.html` <div class="calendar-week" role="row">
6168
+ ${repeat.repeat(
6169
+ (x) => x,
6170
+ vividElement.html`
6171
+ ${when.when(
6172
+ (x, c) => c.parentContext.parentContext.parent._hideDatesOutsideMonth && x.isOutsideMonth,
6173
+ vividElement.html`<div class="calendar-day"></div>`
6174
+ )}
6175
+ ${when.when(
6176
+ (x, c) => !c.parentContext.parentContext.parent._hideDatesOutsideMonth || !x.isOutsideMonth,
6177
+ vividElement.html` <span role="gridcell">
6178
+ <button
6179
+ class="${(x, c) => classNames.classNames(
6180
+ "calendar-day",
6181
+ "button",
6182
+ [
6183
+ "current",
6184
+ x.date === c.parentContext.parentContext.parent._currentDate
6185
+ ],
6186
+ [
6187
+ "selected",
6188
+ c.parentContext.parentContext.parent._isDateSelected(
6189
+ x.date
6190
+ )
6191
+ ],
6192
+ [
6193
+ "range",
6194
+ c.parentContext.parentContext.parent._isDateInSelectedRange(
6195
+ x.date
6196
+ )
6197
+ ],
6198
+ [
6199
+ "start",
6200
+ c.parentContext.parentContext.parent._isDateRangeStart(
6201
+ x.date
6202
+ )
6203
+ ],
6204
+ [
6205
+ "end",
6206
+ c.parentContext.parentContext.parent._isDateRangeEnd(
6207
+ x.date
6208
+ )
6209
+ ],
6210
+ ["outside-month", x.isOutsideMonth]
6211
+ )}"
6212
+ ?disabled="${(x, c) => !c.parentContext.parentContext.parent._isDateInValidRange(
6213
+ x.date
6214
+ )}"
6215
+ tabindex="${(x, c) => x.date === c.parentContext.parentContext.parent._tabbableDate ? 2 : -1}"
6216
+ aria-selected="${(x, c) => c.parentContext.parentContext.parent._isDateAriaSelected(
6217
+ x.date
6218
+ )}"
6219
+ data-date="${(x) => x.date}"
6220
+ @click="${(x, c) => c.parentContext.parentContext.parent._onDateClick(
6221
+ x.date
6222
+ )}"
6223
+ @focus="${(x, c) => c.parentContext.parentContext.parent._onDateFocus(
6224
+ x.date
6225
+ )}"
6226
+ @mouseenter="${(x, c) => c.parentContext.parentContext.parent._onDateMouseEnter(
6227
+ x.date
6228
+ )}"
6229
+ @mouseleave="${(x, c) => c.parentContext.parentContext.parent._onDateMouseLeave(
6230
+ x.date
6231
+ )}"
6232
+ @keydown="${(x, c) => c.parentContext.parentContext.parent._onDateKeydown(
6233
+ x.date,
6234
+ c.event
6235
+ )}"
6236
+ >
6237
+ ${(x) => x.label}
6238
+ </button>
6239
+ </span>`
6240
+ )}
6241
+ </div>
6242
+ `
6243
+ )}
6244
+ </div>`
6245
+ )}`;
6246
+ }
6247
+ function renderMonthPickerGrid(context) {
6248
+ const dividerTag = context.tagFor(definition$1.Divider);
6249
+ return vividElement.html`
6250
+ <${dividerTag}
6251
+ class='months-separator'
6252
+ role='presentation'
6253
+ ></${dividerTag}>
6254
+ <div
6255
+ class='month-grid'
6256
+ role='grid'
6257
+ aria-labelledby='grid-label'
6258
+ >
6259
+ ${repeat.repeat(
6260
+ (x) => x.months,
6261
+ vividElement.html`
6262
+ <div class="months-row" role="row">
6263
+ ${repeat.repeat(
6264
+ (x) => x,
6265
+ vividElement.html`
6266
+ <span role="gridcell">
6267
+ <button
6268
+ class="${(x, c) => classNames.classNames(
6269
+ "month",
6270
+ "button",
6271
+ [
6272
+ "current",
6273
+ areMonthsEqual(
6274
+ x.month,
6275
+ c.parentContext.parentContext.parent._currentMonth
6276
+ )
6277
+ ],
6278
+ [
6279
+ "selected",
6280
+ areMonthsEqual(
6281
+ x.month,
6282
+ c.parentContext.parentContext.parent._selectedMonth
6283
+ )
6284
+ ]
6285
+ )}"
6286
+ tabindex="${(x, c) => c.parentContext.parentContext.parent._tabbableMonth && areMonthsEqual(
6287
+ x.month,
6288
+ c.parentContext.parentContext.parent._tabbableMonth
6289
+ ) ? 2 : -1}"
6290
+ aria-label="${(x) => x.monthName}"
6291
+ aria-selected="${(x, c) => areMonthsEqual(
6292
+ x.month,
6293
+ c.parentContext.parentContext.parent._selectedMonth
6294
+ )}"
6295
+ data-month="${(x) => monthToStr(x.month)}"
6296
+ ?disabled="${(x, c) => !c.parentContext.parentContext.parent._isMonthInValidRange(
6297
+ x.month
6298
+ )}"
6299
+ @click="${(x, c) => c.parentContext.parentContext.parent._onMonthClick(
6300
+ x.month
6301
+ )}"
6302
+ @focus="${(x, c) => c.parentContext.parentContext.parent._onMonthFocus(
6303
+ x.month
6304
+ )}"
6305
+ @keydown="${(x, c) => c.parentContext.parentContext.parent._onMonthKeydown(
6306
+ x.month,
6307
+ c.event
6308
+ )}"
6309
+ >
6310
+ ${(x) => x.label}
6311
+ </button>
6312
+ </span>
6313
+ `
6314
+ )}
6315
+ </div>
6316
+ `
6317
+ )}
6318
+ </div>`;
6319
+ }
6320
+ const CalendarPickerTemplate = (context) => {
6321
+ return vividElement.html`
6322
+ <div class="segments">
6323
+ ${repeat.repeat(
6324
+ (x) => x._segments,
6325
+ vividElement.html` <div class="segment">
6326
+ ${renderDialogHeader(context)}
6327
+ ${when.when(
6328
+ (x) => x.type === "month-picker",
6329
+ vividElement.html`${renderMonthPickerGrid(context)}`
6330
+ )}
6331
+ ${when.when(
6332
+ (x) => x.type === "calendar",
6333
+ vividElement.html`${renderCalendarGrid(context)}`
6334
+ )}
6335
+ </div>`
6336
+ )}
6337
+ </div>
6338
+ `;
6512
6339
  };
6513
6340
 
6514
- exports.DatePickerBase = DatePickerBase;
6515
- exports.DatePickerBaseTemplate = DatePickerBaseTemplate;
6341
+ exports.CalendarPicker = CalendarPicker;
6342
+ exports.CalendarPickerTemplate = CalendarPickerTemplate;
6343
+ exports.MinMaxCalendarPicker = MinMaxCalendarPicker;
6344
+ exports.ValidDateFilter = ValidDateFilter;
6345
+ exports.calendarStyles = calendarStyles;
6516
6346
  exports.compareDateStr = compareDateStr;
6347
+ exports.currentDateStr = currentDateStr;
6517
6348
  exports.formatPresentationDate = formatPresentationDate;
6518
6349
  exports.isValidDateStr = isValidDateStr;
6519
6350
  exports.parsePresentationDate = parsePresentationDate;
6520
- exports.styles = styles;