@evoke-platform/ui-components 1.0.0-dev.200 → 1.0.0-dev.201

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.
@@ -14,13 +14,13 @@ import UIThemeProvider from '../../../theme';
14
14
  import { DateTimePicker as MUIDateTimePicker, } from '@mui/x-date-pickers';
15
15
  import TextField from '../TextField';
16
16
  import { InvalidDate } from '../../../util';
17
- import { LocalDateTime } from '@js-joda/core';
17
+ import { LocalDateTime, nativeJs } from '@js-joda/core';
18
18
  const DateTimePicker = (props) => {
19
19
  var _a;
20
20
  const { value: inputValue, onChange: handleChange } = props, rest = __rest(props, ["value", "onChange"]);
21
21
  let value = null;
22
22
  try {
23
- value = typeof inputValue === 'string' ? LocalDateTime.parse(inputValue) : inputValue;
23
+ value = typeof inputValue === 'string' ? LocalDateTime.from(nativeJs(new Date(inputValue))) : inputValue;
24
24
  }
25
25
  catch (err) {
26
26
  // If we fail to parse the input string, log the error and continue as if no value was set.
@@ -3,6 +3,8 @@ import { DateTimePicker, LocalizationProvider, TextField } from '../../../core';
3
3
  import InputFieldComponent from '../InputFieldComponent/InputFieldComponent';
4
4
  import { LocalDate, LocalDateTime, LocalTime, nativeJs } from '@js-joda/core';
5
5
  import { InvalidDate } from '../../../../util';
6
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
7
+ const { format } = require('small-date');
6
8
  function asCalendarDate(value) {
7
9
  if (!value) {
8
10
  return null;
@@ -19,6 +21,11 @@ function asCalendarDate(value) {
19
21
  }
20
22
  return value.toString();
21
23
  }
24
+ const formatDateTime = (date) => {
25
+ if (date) {
26
+ return format(new Date(date), 'MM-dd-yyyy hh:mm a');
27
+ }
28
+ };
22
29
  const DateTimePickerSelect = (props) => {
23
30
  const { id, property, defaultValue, error, errorMessage, readOnly, required, size, onBlur, additionalProps } = props;
24
31
  const [value, setValue] = useState(asCalendarDate(defaultValue));
@@ -35,7 +42,7 @@ const DateTimePickerSelect = (props) => {
35
42
  setValue(date);
36
43
  props.onChange(property.id, date, property);
37
44
  };
38
- return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, Object.assign(Object.assign({}, props), { defaultValue: value })))) : (React.createElement(LocalizationProvider, null,
45
+ return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, Object.assign(Object.assign({}, props), { defaultValue: formatDateTime(value) })))) : (React.createElement(LocalizationProvider, null,
39
46
  React.createElement(DateTimePicker, { value: value, onChange: handleChange, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, sx: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium' }, (additionalProps !== null && additionalProps !== void 0 ? additionalProps : {})))) })));
40
47
  };
41
48
  export default DateTimePickerSelect;
@@ -20,4 +20,4 @@ export declare class InvalidDate implements Temporal {
20
20
  }
21
21
  export declare type CalendarDate = LocalDate | InvalidDate | LocalDateTime;
22
22
  export declare function isValidDate(date: CalendarDate): date is LocalDate | LocalDateTime;
23
- export { nativeJs, LocalDate, LocalDateTime, Instant, ZoneOffset } from '@js-joda/core';
23
+ export { nativeJs, LocalDate, LocalDateTime } from '@js-joda/core';
@@ -44,4 +44,4 @@ export function isValidDate(date) {
44
44
  return date.invalid !== true;
45
45
  }
46
46
  // Re-export type and utility function from Joda for convenience.
47
- export { nativeJs, LocalDate, LocalDateTime, Instant, ZoneOffset } from '@js-joda/core';
47
+ export { nativeJs, LocalDate, LocalDateTime } from '@js-joda/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.0.0-dev.200",
3
+ "version": "1.0.0-dev.201",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",
@@ -105,7 +105,8 @@
105
105
  "react-dropzone": "^14.2.2",
106
106
  "react-input-mask": "^2.0.4",
107
107
  "react-number-format": "^4.9.3",
108
- "react-querybuilder": "^6.0.2"
108
+ "react-querybuilder": "^6.0.2",
109
+ "small-date": "^2.0.0"
109
110
  },
110
111
  "lint-staged": {
111
112
  "*.{js,jsx,ts,tsx,json,css,md}": [