@variocube/app-ui 1.14.5 → 1.16.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 (323) hide show
  1. package/esm/AppShell/AppShell.js +12 -12
  2. package/esm/AppShell/AppShell.js.map +1 -1
  3. package/esm/AppShell/index.js.map +1 -1
  4. package/esm/Input/ActionsMenu.js +1 -1
  5. package/esm/Input/ActionsMenu.js.map +1 -1
  6. package/esm/Input/EmailSenderField.js +3 -3
  7. package/esm/Input/EmailSenderField.js.map +1 -1
  8. package/esm/Input/Selector.js +2 -2
  9. package/esm/Input/Selector.js.map +1 -1
  10. package/esm/Paging/Paging.d.ts +1 -1
  11. package/esm/Paging/Paging.js +5 -5
  12. package/esm/Paging/Paging.js.map +1 -1
  13. package/esm/Paging/index.d.ts +2 -1
  14. package/esm/Paging/index.js.map +1 -1
  15. package/esm/VCThemeProvider/JetbrainsMonoFont.js +8 -8
  16. package/esm/VCThemeProvider/JetbrainsMonoFont.js.map +1 -1
  17. package/esm/VCThemeProvider/RobotoFont.js +8 -8
  18. package/esm/VCThemeProvider/RobotoFont.js.map +1 -1
  19. package/esm/VCThemeProvider/ThemeModeSwitcher.js +5 -5
  20. package/esm/VCThemeProvider/ThemeModeSwitcher.js.map +1 -1
  21. package/esm/VCThemeProvider/VCThemeProvider.d.ts +1 -1
  22. package/esm/VCThemeProvider/VCThemeProvider.js +21 -21
  23. package/esm/VCThemeProvider/VCThemeProvider.js.map +1 -1
  24. package/esm/audit/AuditChanges.js +9 -5
  25. package/esm/audit/AuditChanges.js.map +1 -1
  26. package/esm/audit/AuditTimeline.js +1 -1
  27. package/esm/audit/AuditTimeline.js.map +1 -1
  28. package/esm/audit/AuditTimelineItem.js +3 -3
  29. package/esm/audit/AuditTimelineItem.js.map +1 -1
  30. package/esm/audit/index.d.ts +1 -1
  31. package/esm/audit/index.js +1 -1
  32. package/esm/audit/index.js.map +1 -1
  33. package/esm/breadcrumbs.d.ts +2 -2
  34. package/esm/breadcrumbs.js +3 -3
  35. package/esm/breadcrumbs.js.map +1 -1
  36. package/esm/code/CodeBlock.d.ts +1 -1
  37. package/esm/code/CodeBlock.js +1 -1
  38. package/esm/code/CodeBlock.js.map +1 -1
  39. package/esm/confirm/ConfirmButton.js.map +1 -1
  40. package/esm/confirm/ConfirmDialog.js +1 -1
  41. package/esm/confirm/ConfirmDialog.js.map +1 -1
  42. package/esm/confirm/ConfirmMenuItem.js +1 -1
  43. package/esm/confirm/ConfirmMenuItem.js.map +1 -1
  44. package/esm/container/ContainerLayout.d.ts +1 -1
  45. package/esm/container/ContainerLayout.js +5 -5
  46. package/esm/container/ContainerLayout.js.map +1 -1
  47. package/esm/container/ContainerSettingsContext.d.ts +2 -2
  48. package/esm/container/ContainerSettingsContext.js +6 -6
  49. package/esm/container/ContainerSettingsContext.js.map +1 -1
  50. package/esm/container/ContainerWidthControl.js +2 -2
  51. package/esm/container/ContainerWidthControl.js.map +1 -1
  52. package/esm/container/index.d.ts +1 -1
  53. package/esm/container/index.js +1 -1
  54. package/esm/container/index.js.map +1 -1
  55. package/esm/content-table/ContentTable.d.ts +1 -1
  56. package/esm/content-table/ContentTable.js +26 -19
  57. package/esm/content-table/ContentTable.js.map +1 -1
  58. package/esm/content-table/UndrawEmpty.js.map +1 -1
  59. package/esm/content-table/index.js.map +1 -1
  60. package/esm/country/country-select.js.map +1 -1
  61. package/esm/country/index.d.ts +3 -3
  62. package/esm/country/index.js +3 -3
  63. package/esm/country/index.js.map +1 -1
  64. package/esm/country/locale-select.js +1 -1
  65. package/esm/country/locale-select.js.map +1 -1
  66. package/esm/country/locales.js +1 -1
  67. package/esm/country/locales.js.map +1 -1
  68. package/esm/country/phone-prefix-select.js +1 -1
  69. package/esm/country/phone-prefix-select.js.map +1 -1
  70. package/esm/cube/accessibility.js +2 -1
  71. package/esm/cube/accessibility.js.map +1 -1
  72. package/esm/data-table/DataTableColumnSettings.d.ts +1 -1
  73. package/esm/data-table/DataTableColumnSettings.js +2 -2
  74. package/esm/data-table/DataTableColumnSettings.js.map +1 -1
  75. package/esm/data-table/DataTableHeader.js +1 -1
  76. package/esm/data-table/DataTableHeader.js.map +1 -1
  77. package/esm/data-table/DataTableToolbar.js +1 -1
  78. package/esm/data-table/DataTableToolbar.js.map +1 -1
  79. package/esm/data-table/index.d.ts +4 -4
  80. package/esm/data-table/index.js +4 -4
  81. package/esm/data-table/index.js.map +1 -1
  82. package/esm/data-table/useDataTableColumnStorage.d.ts +9 -1
  83. package/esm/data-table/useDataTableColumnStorage.js +12 -5
  84. package/esm/data-table/useDataTableColumnStorage.js.map +1 -1
  85. package/esm/data-table/useDataTableStorage.d.ts +31 -6
  86. package/esm/data-table/useDataTableStorage.js +25 -5
  87. package/esm/data-table/useDataTableStorage.js.map +1 -1
  88. package/esm/date-pickers/PlainAdapterCommon.d.ts +1 -1
  89. package/esm/date-pickers/PlainAdapterCommon.js.map +1 -1
  90. package/esm/date-pickers/PlainDateAdapter.js.map +1 -1
  91. package/esm/date-pickers/PlainDatePicker.js +1 -1
  92. package/esm/date-pickers/PlainDatePicker.js.map +1 -1
  93. package/esm/date-pickers/PlainDatePicker.spec.js +2 -2
  94. package/esm/date-pickers/PlainDatePicker.spec.js.map +1 -1
  95. package/esm/date-pickers/PlainDateTimeAdapter.js.map +1 -1
  96. package/esm/date-pickers/PlainDateTimePicker.js +2 -2
  97. package/esm/date-pickers/PlainDateTimePicker.js.map +1 -1
  98. package/esm/date-pickers/PlainDateTimePicker.spec.js +2 -2
  99. package/esm/date-pickers/PlainDateTimePicker.spec.js.map +1 -1
  100. package/esm/date-pickers/PlainTimeAdapter.js.map +1 -1
  101. package/esm/date-pickers/PlainTimePicker.js +2 -2
  102. package/esm/date-pickers/PlainTimePicker.js.map +1 -1
  103. package/esm/date-pickers/PlainTimePicker.spec.js +2 -2
  104. package/esm/date-pickers/PlainTimePicker.spec.js.map +1 -1
  105. package/esm/date-pickers/TemporalAdapter.d.ts +1 -1
  106. package/esm/date-pickers/TemporalAdapter.js +1 -1
  107. package/esm/date-pickers/TemporalAdapter.js.map +1 -1
  108. package/esm/date-pickers/TimezoneSelect.js +348 -348
  109. package/esm/date-pickers/TimezoneSelect.js.map +1 -1
  110. package/esm/date-pickers/getFormatString.js.map +1 -1
  111. package/esm/date-pickers/index.d.ts +2 -1
  112. package/esm/date-pickers/index.js +1 -1
  113. package/esm/date-pickers/index.js.map +1 -1
  114. package/esm/date-pickers/parse.js.map +1 -1
  115. package/esm/date-pickers/timeframe-picker.js +7 -7
  116. package/esm/date-pickers/timeframe-picker.js.map +1 -1
  117. package/esm/date-pickers/useLocale.js.map +1 -1
  118. package/esm/date-pickers/useRenderInput.js +5 -3
  119. package/esm/date-pickers/useRenderInput.js.map +1 -1
  120. package/esm/fetch.d.ts +2 -3
  121. package/esm/fetch.js +4 -4
  122. package/esm/fetch.js.map +1 -1
  123. package/esm/formats/CompactFormat.js +1 -1
  124. package/esm/formats/CompactFormat.js.map +1 -1
  125. package/esm/formats/CompactFormat.spec.js +1 -1
  126. package/esm/formats/CompactFormat.spec.js.map +1 -1
  127. package/esm/formats/CurrencyFormat.js +1 -1
  128. package/esm/formats/CurrencyFormat.js.map +1 -1
  129. package/esm/formats/CurrencyFormat.spec.js +1 -1
  130. package/esm/formats/CurrencyFormat.spec.js.map +1 -1
  131. package/esm/formats/DecimalFormat.js +1 -1
  132. package/esm/formats/DecimalFormat.js.map +1 -1
  133. package/esm/formats/DecimalFormat.spec.js +1 -1
  134. package/esm/formats/DecimalFormat.spec.js.map +1 -1
  135. package/esm/formats/DurationFormat.js +2 -2
  136. package/esm/formats/DurationFormat.js.map +1 -1
  137. package/esm/formats/DurationFormat.spec.js +2 -2
  138. package/esm/formats/DurationFormat.spec.js.map +1 -1
  139. package/esm/formats/TemporalFormat.spec.js +2 -2
  140. package/esm/formats/TemporalFormat.spec.js.map +1 -1
  141. package/esm/formats/TemporalRangeFormat.js +1 -1
  142. package/esm/formats/TemporalRangeFormat.js.map +1 -1
  143. package/esm/formats/TemporalRangeFormat.spec.js +2 -2
  144. package/esm/formats/TemporalRangeFormat.spec.js.map +1 -1
  145. package/esm/formats/useDateTimeFormat.js +5 -2
  146. package/esm/formats/useDateTimeFormat.js.map +1 -1
  147. package/esm/formats/useNumberFormat.js +1 -1
  148. package/esm/formats/useNumberFormat.js.map +1 -1
  149. package/esm/formats/useRelativeTimeFormat.js +4 -2
  150. package/esm/formats/useRelativeTimeFormat.js.map +1 -1
  151. package/esm/forms/SearchForm.js +1 -1
  152. package/esm/forms/SearchForm.js.map +1 -1
  153. package/esm/getNavigatorLanguages.js.map +1 -1
  154. package/esm/getSupportedFormatLocale.js.map +1 -1
  155. package/esm/help/HelpDrawer.js +12 -8
  156. package/esm/help/HelpDrawer.js.map +1 -1
  157. package/esm/help/index.d.ts +1 -1
  158. package/esm/help/index.js +1 -1
  159. package/esm/help/index.js.map +1 -1
  160. package/esm/icons.d.ts +13 -13
  161. package/esm/icons.js +13 -13
  162. package/esm/icons.js.map +1 -1
  163. package/esm/layout/ErrorBoundary.js +36 -36
  164. package/esm/layout/ErrorBoundary.js.map +1 -1
  165. package/esm/layout/NotFound.js +6 -6
  166. package/esm/layout/NotFound.js.map +1 -1
  167. package/esm/layout/NotFoundSvg.js.map +1 -1
  168. package/esm/layout/UserNav.js +18 -18
  169. package/esm/layout/UserNav.js.map +1 -1
  170. package/esm/layout/index.d.ts +2 -2
  171. package/esm/layout/index.js +2 -2
  172. package/esm/layout/index.js.map +1 -1
  173. package/esm/logo/Logo.js +2 -2
  174. package/esm/logo/Logo.js.map +1 -1
  175. package/esm/logo/VCAppLogo.js +1 -1
  176. package/esm/logo/VCAppLogo.js.map +1 -1
  177. package/esm/logo/index.d.ts +3 -3
  178. package/esm/logo/index.js +3 -3
  179. package/esm/logo/index.js.map +1 -1
  180. package/esm/splash/index.js +2 -2
  181. package/esm/splash/index.js.map +1 -1
  182. package/esm/storage/MemoryStorage.d.ts +6 -4
  183. package/esm/storage/MemoryStorage.js +13 -4
  184. package/esm/storage/MemoryStorage.js.map +1 -1
  185. package/esm/storage/index.d.ts +2 -1
  186. package/esm/storage/index.js +1 -1
  187. package/esm/storage/index.js.map +1 -1
  188. package/esm/storage/storage.d.ts +6 -4
  189. package/esm/storage/storage.js +35 -15
  190. package/esm/storage/storage.js.map +1 -1
  191. package/esm/storage/types.d.ts +6 -0
  192. package/esm/storage/types.js +2 -0
  193. package/esm/storage/types.js.map +1 -0
  194. package/esm/storage/useStorage.d.ts +10 -1
  195. package/esm/storage/useStorage.js +18 -6
  196. package/esm/storage/useStorage.js.map +1 -1
  197. package/esm/tabs/Tabs.d.ts +2 -2
  198. package/esm/tabs/Tabs.js +15 -15
  199. package/esm/tabs/Tabs.js.map +1 -1
  200. package/esm/tabs/index.js.map +1 -1
  201. package/esm/temporal/index.d.ts +1 -1
  202. package/esm/temporal/index.js +1 -1
  203. package/esm/temporal/index.js.map +1 -1
  204. package/esm/temporal/parse.js.map +1 -1
  205. package/esm/temporal/polyfill.d.ts +1 -1
  206. package/esm/temporal/polyfill.js +3 -3
  207. package/esm/temporal/polyfill.js.map +1 -1
  208. package/esm/utils/defined.js.map +1 -1
  209. package/esm/utils/index.d.ts +1 -1
  210. package/esm/utils/index.js +1 -1
  211. package/esm/utils/index.js.map +1 -1
  212. package/esm/utils/useFlag.js.map +1 -1
  213. package/esm/utils/useIsMounted.js.map +1 -1
  214. package/package.json +8 -9
  215. package/src/AppShell/AppShell.tsx +147 -140
  216. package/src/AppShell/index.tsx +1 -1
  217. package/src/Input/ActionsMenu.tsx +70 -73
  218. package/src/Input/EmailSenderField.tsx +59 -52
  219. package/src/Input/Selector.tsx +15 -15
  220. package/src/LanguageSwitcher/index.ts +1 -1
  221. package/src/Paging/Paging.ts +56 -57
  222. package/src/Paging/index.ts +2 -1
  223. package/src/VCThemeProvider/JetbrainsMonoFont.tsx +52 -42
  224. package/src/VCThemeProvider/RobotoFont.tsx +47 -39
  225. package/src/VCThemeProvider/ThemeModeSwitcher.tsx +17 -17
  226. package/src/VCThemeProvider/VCThemeProvider.tsx +149 -145
  227. package/src/audit/AuditChanges.tsx +18 -12
  228. package/src/audit/AuditTimeline.tsx +16 -17
  229. package/src/audit/AuditTimelineItem.tsx +58 -61
  230. package/src/audit/index.ts +2 -2
  231. package/src/audit/types.ts +27 -28
  232. package/src/breadcrumbs.tsx +11 -15
  233. package/src/code/CodeBlock.tsx +10 -10
  234. package/src/confirm/ConfirmButton.tsx +56 -56
  235. package/src/confirm/ConfirmDialog.tsx +54 -54
  236. package/src/confirm/ConfirmMenuItem.tsx +51 -53
  237. package/src/container/ContainerLayout.tsx +7 -8
  238. package/src/container/ContainerSettingsContext.tsx +49 -46
  239. package/src/container/ContainerWidthControl.tsx +11 -9
  240. package/src/container/index.ts +8 -3
  241. package/src/content-table/ContentTable.tsx +235 -197
  242. package/src/content-table/UndrawEmpty.tsx +281 -281
  243. package/src/content-table/index.ts +1 -1
  244. package/src/country/country-select.tsx +0 -1
  245. package/src/country/index.ts +3 -3
  246. package/src/country/locale-select.tsx +36 -36
  247. package/src/country/locales.ts +185 -187
  248. package/src/country/phone-prefix-select.tsx +4 -5
  249. package/src/cube/accessibility.tsx +2 -1
  250. package/src/data-table/DataTableColumnSettings.tsx +181 -181
  251. package/src/data-table/DataTableHeader.tsx +6 -6
  252. package/src/data-table/DataTableToolbar.tsx +6 -6
  253. package/src/data-table/index.tsx +4 -4
  254. package/src/data-table/useDataTableColumnStorage.ts +30 -19
  255. package/src/data-table/useDataTableStorage.spec.ts +108 -0
  256. package/src/data-table/useDataTableStorage.ts +91 -36
  257. package/src/date-pickers/PlainAdapterCommon.ts +118 -120
  258. package/src/date-pickers/PlainDateAdapter.spec.ts +44 -46
  259. package/src/date-pickers/PlainDateAdapter.ts +130 -132
  260. package/src/date-pickers/PlainDatePicker.spec.tsx +17 -18
  261. package/src/date-pickers/PlainDatePicker.tsx +33 -36
  262. package/src/date-pickers/PlainDateTimeAdapter.spec.ts +44 -46
  263. package/src/date-pickers/PlainDateTimeAdapter.ts +141 -134
  264. package/src/date-pickers/PlainDateTimePicker.spec.tsx +17 -18
  265. package/src/date-pickers/PlainDateTimePicker.tsx +35 -36
  266. package/src/date-pickers/PlainTimeAdapter.ts +219 -221
  267. package/src/date-pickers/PlainTimePicker.spec.tsx +17 -18
  268. package/src/date-pickers/PlainTimePicker.tsx +35 -34
  269. package/src/date-pickers/TemporalAdapter.ts +110 -111
  270. package/src/date-pickers/TimezoneSelect.tsx +375 -375
  271. package/src/date-pickers/getFormatString.ts +29 -29
  272. package/src/date-pickers/index.ts +6 -5
  273. package/src/date-pickers/parse.spec.ts +37 -40
  274. package/src/date-pickers/parse.ts +44 -47
  275. package/src/date-pickers/timeframe-picker.tsx +16 -17
  276. package/src/date-pickers/useLocale.ts +1 -1
  277. package/src/date-pickers/useRenderInput.tsx +24 -15
  278. package/src/fetch.ts +4 -5
  279. package/src/formats/CompactFormat.spec.tsx +18 -20
  280. package/src/formats/CompactFormat.tsx +30 -30
  281. package/src/formats/CurrencyFormat.spec.tsx +18 -20
  282. package/src/formats/CurrencyFormat.tsx +52 -52
  283. package/src/formats/DecimalFormat.spec.tsx +18 -20
  284. package/src/formats/DecimalFormat.tsx +47 -47
  285. package/src/formats/DurationFormat.spec.tsx +48 -49
  286. package/src/formats/DurationFormat.tsx +51 -51
  287. package/src/formats/TemporalFormat.spec.tsx +93 -95
  288. package/src/formats/TemporalRangeFormat.spec.tsx +143 -144
  289. package/src/formats/TemporalRangeFormat.tsx +54 -54
  290. package/src/formats/types.ts +1 -3
  291. package/src/formats/useDateTimeFormat.ts +5 -2
  292. package/src/formats/useNumberFormat.ts +3 -3
  293. package/src/formats/useRelativeTimeFormat.ts +5 -3
  294. package/src/forms/SearchForm.tsx +37 -38
  295. package/src/getNavigatorLanguages.ts +4 -5
  296. package/src/getSupportedFormatLocale.ts +10 -10
  297. package/src/help/HelpDrawer.tsx +76 -55
  298. package/src/help/index.ts +3 -3
  299. package/src/icons.ts +21 -21
  300. package/src/layout/ErrorBoundary.tsx +226 -215
  301. package/src/layout/NotFound.tsx +36 -39
  302. package/src/layout/NotFoundSvg.tsx +193 -169
  303. package/src/layout/UserNav.tsx +98 -98
  304. package/src/layout/index.ts +3 -3
  305. package/src/logo/Logo.tsx +6 -7
  306. package/src/logo/VCAppLogo.tsx +22 -20
  307. package/src/logo/index.tsx +3 -3
  308. package/src/splash/index.tsx +25 -25
  309. package/src/storage/MemoryStorage.ts +22 -15
  310. package/src/storage/index.ts +2 -1
  311. package/src/storage/storage.spec.ts +184 -0
  312. package/src/storage/storage.ts +37 -15
  313. package/src/storage/types.ts +6 -0
  314. package/src/storage/useStorage.ts +21 -6
  315. package/src/tabs/Tabs.tsx +172 -170
  316. package/src/tabs/index.ts +1 -1
  317. package/src/temporal/index.ts +1 -1
  318. package/src/temporal/parse.ts +1 -2
  319. package/src/temporal/polyfill.ts +11 -11
  320. package/src/utils/defined.ts +2 -3
  321. package/src/utils/index.ts +1 -1
  322. package/src/utils/useFlag.ts +5 -5
  323. package/src/utils/useIsMounted.ts +9 -9
@@ -1,247 +1,245 @@
1
- import { Unit } from "@date-io/core/IUtils";
2
- import { Temporal } from "@js-temporal/polyfill";
1
+ import {Unit} from "@date-io/core/IUtils";
2
+ import {Temporal} from "@js-temporal/polyfill";
3
3
  import {MuiPickersAdapter} from "@mui/x-date-pickers/internals";
4
4
  import {DateTimeFormat, Now, PlainTime} from "../temporal";
5
5
  import {parsePlainTime} from "./parse";
6
6
  import {durationToUnit, TemporalAdapter} from "./TemporalAdapter";
7
7
 
8
8
  export class PlainTimeAdapter extends TemporalAdapter<PlainTime> implements MuiPickersAdapter<PlainTime> {
9
- lib = "PlainTimeAdapter";
10
-
11
- date(value?: any): PlainTime | null {
12
- if (value === null) {
13
- return null;
14
- }
15
- if (value === undefined) {
16
- return Now.plainTimeISO();
17
- }
18
-
19
- if (value instanceof PlainTime) {
20
- return value;
21
- }
22
-
23
- if (typeof value === "string") {
24
- try {
25
- return PlainTime.from(value, {overflow: "reject"});
26
- }
27
- catch (error) {
28
- return this.parse(value, this.formats.fullTime);
29
- }
30
- }
31
-
32
- console.error("Unexpected value", value);
33
- return null;
34
- }
35
-
36
- toJsDate(value: PlainTime): Date {
37
- const date = new Date();
38
- date.setHours(value.hour, value.minute, value.second, value.millisecond);
39
- return date;
40
- }
41
-
42
- parseISO(isString: string): PlainTime {
43
- return PlainTime.from(isString);
44
- }
45
-
46
- parse(value: string, format: string | DateTimeFormat): PlainTime | null {
47
- try {
48
- return parsePlainTime(value, format as any as DateTimeFormat);
49
- }
50
- catch (error) {
51
- console.warn("Could not parse", {value, format});
52
- }
53
- return null;
54
- }
55
-
56
- isValid(value: any): boolean {
57
- return this.date(value) != null;
58
- }
59
-
60
- isEqual(value: any, comparing: any): boolean {
61
- const first = this.date(value);
62
- const second = this.date(comparing);
63
- if (first === second) {
64
- return true;
65
- }
66
- if (!first || !second) {
67
- return false;
68
- }
69
- return first.equals(second);
70
- }
71
-
72
- isSameHour(value: PlainTime, comparing: PlainTime): boolean {
73
- return value.hour == comparing.hour;
74
- }
75
-
76
- startOfDay(value: PlainTime): PlainTime {
77
- return new PlainTime();
78
- }
79
-
80
- endOfDay(value: PlainTime): PlainTime {
81
- return new PlainTime();
82
- }
83
-
84
- getHours(value: PlainTime): number {
85
- return value.hour;
86
- }
87
-
88
- setHours(value: PlainTime, count: number): PlainTime {
89
- return value.with({hour: count});
90
- }
91
-
92
- getMinutes(value: PlainTime): number {
93
- return value.minute;
94
- }
95
-
96
- setMinutes(value: PlainTime, count: number): PlainTime {
97
- return value.with({minute: count});
98
- }
99
-
100
- getSeconds(value: PlainTime): number {
101
- return value.second;
102
- }
103
-
104
- setSeconds(value: PlainTime, count: number): PlainTime {
105
- return value.with({second: count});
106
- }
107
-
108
- setMonth(value: PlainTime, count: number): PlainTime {
109
- return value;
110
- }
111
-
112
- setYear(value: PlainTime, count: number): PlainTime {
113
- return value;
114
- }
115
-
116
- mergeDateAndTime(date: PlainTime, time: PlainTime): PlainTime {
117
- return time;
118
- }
119
-
120
- addSeconds(value: PlainTime, count: number): PlainTime {
121
- return value.add({seconds: count});
122
- }
123
-
124
- addMinutes(value: PlainTime, count: number): PlainTime {
125
- return value.add({minutes: count});
126
- }
127
-
128
- addHours(value: PlainTime, count: number): PlainTime {
129
- return value.add({hours: count});
130
- }
131
-
132
- addDays(value: PlainTime, count: number): PlainTime {
133
- return value.add({days: count});
134
- }
135
-
136
- addWeeks(value: PlainTime, count: number): PlainTime {
137
- return value.add({weeks: count});
138
- }
139
-
140
- addMonths(value: PlainTime, count: number): PlainTime {
141
- return value.add({months: count});
142
- }
143
-
144
- getDiff(value: PlainTime, comparing: string | Temporal.PlainTime, unit?: Unit | undefined): number {
145
- return durationToUnit(value.until(comparing), unit);
146
- }
147
-
148
- isSameDay(value: PlainTime, comparing: PlainTime): boolean {
149
- return true;
150
- }
151
-
152
- isSameMonth(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
153
- return true;
154
- }
155
-
156
- isSameYear(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
157
- return true;
158
- }
159
-
160
- isAfter(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
161
- return PlainTime.compare(value, comparing) > 0;
162
- }
163
-
164
- isAfterDay(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
165
- return false;
166
- }
167
-
168
- isAfterYear(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
169
- return false;
170
- }
9
+ lib = "PlainTimeAdapter";
10
+
11
+ date(value?: any): PlainTime | null {
12
+ if (value === null) {
13
+ return null;
14
+ }
15
+ if (value === undefined) {
16
+ return Now.plainTimeISO();
17
+ }
18
+
19
+ if (value instanceof PlainTime) {
20
+ return value;
21
+ }
22
+
23
+ if (typeof value === "string") {
24
+ try {
25
+ return PlainTime.from(value, {overflow: "reject"});
26
+ } catch (error) {
27
+ return this.parse(value, this.formats.fullTime);
28
+ }
29
+ }
30
+
31
+ console.error("Unexpected value", value);
32
+ return null;
33
+ }
34
+
35
+ toJsDate(value: PlainTime): Date {
36
+ const date = new Date();
37
+ date.setHours(value.hour, value.minute, value.second, value.millisecond);
38
+ return date;
39
+ }
40
+
41
+ parseISO(isString: string): PlainTime {
42
+ return PlainTime.from(isString);
43
+ }
44
+
45
+ parse(value: string, format: string | DateTimeFormat): PlainTime | null {
46
+ try {
47
+ return parsePlainTime(value, format as any as DateTimeFormat);
48
+ } catch (error) {
49
+ console.warn("Could not parse", {value, format});
50
+ }
51
+ return null;
52
+ }
53
+
54
+ isValid(value: any): boolean {
55
+ return this.date(value) != null;
56
+ }
57
+
58
+ isEqual(value: any, comparing: any): boolean {
59
+ const first = this.date(value);
60
+ const second = this.date(comparing);
61
+ if (first === second) {
62
+ return true;
63
+ }
64
+ if (!first || !second) {
65
+ return false;
66
+ }
67
+ return first.equals(second);
68
+ }
69
+
70
+ isSameHour(value: PlainTime, comparing: PlainTime): boolean {
71
+ return value.hour == comparing.hour;
72
+ }
73
+
74
+ startOfDay(value: PlainTime): PlainTime {
75
+ return new PlainTime();
76
+ }
77
+
78
+ endOfDay(value: PlainTime): PlainTime {
79
+ return new PlainTime();
80
+ }
81
+
82
+ getHours(value: PlainTime): number {
83
+ return value.hour;
84
+ }
85
+
86
+ setHours(value: PlainTime, count: number): PlainTime {
87
+ return value.with({hour: count});
88
+ }
89
+
90
+ getMinutes(value: PlainTime): number {
91
+ return value.minute;
92
+ }
93
+
94
+ setMinutes(value: PlainTime, count: number): PlainTime {
95
+ return value.with({minute: count});
96
+ }
97
+
98
+ getSeconds(value: PlainTime): number {
99
+ return value.second;
100
+ }
101
+
102
+ setSeconds(value: PlainTime, count: number): PlainTime {
103
+ return value.with({second: count});
104
+ }
105
+
106
+ setMonth(value: PlainTime, count: number): PlainTime {
107
+ return value;
108
+ }
109
+
110
+ setYear(value: PlainTime, count: number): PlainTime {
111
+ return value;
112
+ }
113
+
114
+ mergeDateAndTime(date: PlainTime, time: PlainTime): PlainTime {
115
+ return time;
116
+ }
117
+
118
+ addSeconds(value: PlainTime, count: number): PlainTime {
119
+ return value.add({seconds: count});
120
+ }
121
+
122
+ addMinutes(value: PlainTime, count: number): PlainTime {
123
+ return value.add({minutes: count});
124
+ }
125
+
126
+ addHours(value: PlainTime, count: number): PlainTime {
127
+ return value.add({hours: count});
128
+ }
129
+
130
+ addDays(value: PlainTime, count: number): PlainTime {
131
+ return value.add({days: count});
132
+ }
133
+
134
+ addWeeks(value: PlainTime, count: number): PlainTime {
135
+ return value.add({weeks: count});
136
+ }
137
+
138
+ addMonths(value: PlainTime, count: number): PlainTime {
139
+ return value.add({months: count});
140
+ }
141
+
142
+ getDiff(value: PlainTime, comparing: string | Temporal.PlainTime, unit?: Unit | undefined): number {
143
+ return durationToUnit(value.until(comparing), unit);
144
+ }
145
+
146
+ isSameDay(value: PlainTime, comparing: PlainTime): boolean {
147
+ return true;
148
+ }
149
+
150
+ isSameMonth(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
151
+ return true;
152
+ }
153
+
154
+ isSameYear(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
155
+ return true;
156
+ }
157
+
158
+ isAfter(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
159
+ return PlainTime.compare(value, comparing) > 0;
160
+ }
161
+
162
+ isAfterDay(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
163
+ return false;
164
+ }
165
+
166
+ isAfterYear(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
167
+ return false;
168
+ }
171
169
 
172
- isBeforeDay(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
173
- return false;
174
- }
170
+ isBeforeDay(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
171
+ return false;
172
+ }
175
173
 
176
- isBeforeYear(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
177
- return false;
178
- }
174
+ isBeforeYear(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
175
+ return false;
176
+ }
179
177
 
180
- isBefore(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
181
- return PlainTime.compare(value, comparing) < 0;
182
- }
178
+ isBefore(value: Temporal.PlainTime, comparing: Temporal.PlainTime): boolean {
179
+ return PlainTime.compare(value, comparing) < 0;
180
+ }
183
181
 
184
- isWithinRange(value: Temporal.PlainTime, [start, end]: [Temporal.PlainTime, Temporal.PlainTime]): boolean {
185
- return PlainTime.compare(value, start) > 0 && PlainTime.compare(value, end) < 0;
186
- }
182
+ isWithinRange(value: Temporal.PlainTime, [start, end]: [Temporal.PlainTime, Temporal.PlainTime]): boolean {
183
+ return PlainTime.compare(value, start) > 0 && PlainTime.compare(value, end) < 0;
184
+ }
187
185
 
188
- startOfYear(value: Temporal.PlainTime): Temporal.PlainTime {
189
- return value;
190
- }
186
+ startOfYear(value: Temporal.PlainTime): Temporal.PlainTime {
187
+ return value;
188
+ }
191
189
 
192
- endOfYear(value: Temporal.PlainTime): Temporal.PlainTime {
193
- return value;
194
- }
190
+ endOfYear(value: Temporal.PlainTime): Temporal.PlainTime {
191
+ return value;
192
+ }
195
193
 
196
- startOfMonth(value: Temporal.PlainTime): Temporal.PlainTime {
197
- return value;
198
- }
194
+ startOfMonth(value: Temporal.PlainTime): Temporal.PlainTime {
195
+ return value;
196
+ }
199
197
 
200
- endOfMonth(value: Temporal.PlainTime): Temporal.PlainTime {
201
- return value;
202
- }
198
+ endOfMonth(value: Temporal.PlainTime): Temporal.PlainTime {
199
+ return value;
200
+ }
203
201
 
204
- startOfWeek(value: Temporal.PlainTime): Temporal.PlainTime {
205
- return value;
206
- }
202
+ startOfWeek(value: Temporal.PlainTime): Temporal.PlainTime {
203
+ return value;
204
+ }
207
205
 
208
- endOfWeek(value: Temporal.PlainTime): Temporal.PlainTime {
209
- return value;
210
- }
206
+ endOfWeek(value: Temporal.PlainTime): Temporal.PlainTime {
207
+ return value;
208
+ }
211
209
 
212
- getMonth(value: Temporal.PlainTime): number {
213
- return 1;
214
- }
210
+ getMonth(value: Temporal.PlainTime): number {
211
+ return 1;
212
+ }
215
213
 
216
- getDaysInMonth(value: Temporal.PlainTime): number {
217
- return 30;
218
- }
214
+ getDaysInMonth(value: Temporal.PlainTime): number {
215
+ return 30;
216
+ }
219
217
 
220
- getNextMonth(value: Temporal.PlainTime): Temporal.PlainTime {
221
- return value;
222
- }
218
+ getNextMonth(value: Temporal.PlainTime): Temporal.PlainTime {
219
+ return value;
220
+ }
223
221
 
224
- getPreviousMonth(value: Temporal.PlainTime): Temporal.PlainTime {
225
- return value;
226
- }
222
+ getPreviousMonth(value: Temporal.PlainTime): Temporal.PlainTime {
223
+ return value;
224
+ }
227
225
 
228
- getMonthArray(value: Temporal.PlainTime): Temporal.PlainTime[] {
229
- throw new Error("Method not implemented.");
230
- }
226
+ getMonthArray(value: Temporal.PlainTime): Temporal.PlainTime[] {
227
+ throw new Error("Method not implemented.");
228
+ }
231
229
 
232
- getYear(value: Temporal.PlainTime): number {
233
- throw new Error("Method not implemented.");
234
- }
230
+ getYear(value: Temporal.PlainTime): number {
231
+ throw new Error("Method not implemented.");
232
+ }
235
233
 
236
- getWeekdays(): string[] {
237
- throw new Error("Method not implemented.");
238
- }
234
+ getWeekdays(): string[] {
235
+ throw new Error("Method not implemented.");
236
+ }
239
237
 
240
- getWeekArray(date: Temporal.PlainTime): Temporal.PlainTime[][] {
241
- throw new Error("Method not implemented.");
242
- }
238
+ getWeekArray(date: Temporal.PlainTime): Temporal.PlainTime[][] {
239
+ throw new Error("Method not implemented.");
240
+ }
243
241
 
244
- getYearRange(start: Temporal.PlainTime, end: Temporal.PlainTime): Temporal.PlainTime[] {
245
- throw new Error("Method not implemented.");
246
- }
242
+ getYearRange(start: Temporal.PlainTime, end: Temporal.PlainTime): Temporal.PlainTime[] {
243
+ throw new Error("Method not implemented.");
244
+ }
247
245
  }
@@ -1,22 +1,21 @@
1
- import {PlainTime} from "../temporal";
2
- import {act, create, ReactTestRenderer} from "react-test-renderer";
3
1
  import * as React from "react";
2
+ import {act, create, ReactTestRenderer} from "react-test-renderer";
3
+ import {PlainTime} from "../temporal";
4
4
  import {PlainTimePicker} from "./PlainTimePicker";
5
5
 
6
6
  describe("PlainTimePicker", () => {
7
-
8
- test("render", () => {
9
- let element: ReactTestRenderer;
10
- act(() => {
11
- element = create(
12
- <PlainTimePicker
13
- locale="de"
14
- value={new PlainTime(22, 33)}
15
- onChange={() => {}}
16
- />);
17
- })
18
- const {value} = element!.root.findByType("input").props;
19
- expect(value).toBe("22:33");
20
- });
21
-
22
- });
7
+ test("render", () => {
8
+ let element: ReactTestRenderer;
9
+ act(() => {
10
+ element = create(
11
+ <PlainTimePicker
12
+ locale="de"
13
+ value={new PlainTime(22, 33)}
14
+ onChange={() => {}}
15
+ />,
16
+ );
17
+ });
18
+ const {value} = element!.root.findByType("input").props;
19
+ expect(value).toBe("22:33");
20
+ });
21
+ });
@@ -1,45 +1,46 @@
1
- import {PlainTime} from "../temporal";
2
- import {useLocale} from "./useLocale";
3
- import {useRenderInput, UseRenderInputProps} from "./useRenderInput";
4
1
  import {LocalizationProvider, TimePicker} from "@mui/x-date-pickers";
5
2
  import * as React from "react";
3
+ import {PlainTime} from "../temporal";
6
4
  import {PlainTimeAdapter} from "./PlainTimeAdapter";
5
+ import {useLocale} from "./useLocale";
6
+ import {useRenderInput, UseRenderInputProps} from "./useRenderInput";
7
7
 
8
8
  interface PlainTimePickerProps {
9
- value: PlainTime | null;
10
- onChange: (value: PlainTime | null) => any;
11
- label?: string;
12
- disabled?: boolean;
13
- required?: boolean;
9
+ value: PlainTime | null;
10
+ onChange: (value: PlainTime | null) => any;
11
+ label?: string;
12
+ disabled?: boolean;
13
+ required?: boolean;
14
14
 
15
- /**
16
- * Allows overriding the locale. Only use for testing.
17
- */
18
- locale?: string;
15
+ /**
16
+ * Allows overriding the locale. Only use for testing.
17
+ */
18
+ locale?: string;
19
19
  }
20
20
 
21
21
  export function PlainTimePicker(props: PlainTimePickerProps & UseRenderInputProps) {
22
- const {
23
- value,
24
- onChange, label,
25
- locale: suppliedLocale,
26
- disabled,
27
- ...renderInputProps
28
- } = props;
22
+ const {
23
+ value,
24
+ onChange,
25
+ label,
26
+ locale: suppliedLocale,
27
+ disabled,
28
+ ...renderInputProps
29
+ } = props;
29
30
 
30
- const locale = useLocale(suppliedLocale);
31
- const renderInput = useRenderInput(renderInputProps);
31
+ const locale = useLocale(suppliedLocale);
32
+ const renderInput = useRenderInput(renderInputProps);
32
33
 
33
- return (
34
- <LocalizationProvider dateAdapter={PlainTimeAdapter} adapterLocale={locale}>
35
- <TimePicker
36
- label={label}
37
- value={value}
38
- disableMaskedInput
39
- onChange={onChange}
40
- disabled={disabled}
41
- renderInput={renderInput}
42
- />
43
- </LocalizationProvider>
44
- );
45
- }
34
+ return (
35
+ <LocalizationProvider dateAdapter={PlainTimeAdapter} adapterLocale={locale}>
36
+ <TimePicker
37
+ label={label}
38
+ value={value}
39
+ disableMaskedInput
40
+ onChange={onChange}
41
+ disabled={disabled}
42
+ renderInput={renderInput}
43
+ />
44
+ </LocalizationProvider>
45
+ );
46
+ }