@trackunit/custom-field-components 0.0.118 → 0.0.122

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 (2) hide show
  1. package/index.js +25 -16
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -1832,6 +1832,15 @@ const BooleanCustomField = _a => {
1832
1832
  }));
1833
1833
  };
1834
1834
 
1835
+ const formatDateToString = date => {
1836
+ const month = date.getMonth() + 1;
1837
+ const mm = month.toString(10).length === 1 ? `0${month}` : month;
1838
+ const day = date.getDate();
1839
+ const dd = day.toString(10).length === 1 ? `0${day}` : day;
1840
+ const year = date.getFullYear();
1841
+ return `${year}-${mm}-${dd}`;
1842
+ };
1843
+
1835
1844
  const DateCustomField = props => {
1836
1845
  const {
1837
1846
  setValue,
@@ -1839,27 +1848,26 @@ const DateCustomField = props => {
1839
1848
  register,
1840
1849
  id,
1841
1850
  validationRules
1842
- } = props;
1851
+ } = props,
1852
+ rest = __rest(props, ["setValue", "defaultValue", "register", "id", "validationRules"]);
1853
+
1843
1854
  const onChangeHandler = useCallback(value => {
1844
- setValue && setValue(id, value === null || value === void 0 ? void 0 : value.toISOString());
1855
+ if (value) {
1856
+ setValue && setValue(id, formatDateToString(value));
1857
+ }
1845
1858
  }, [setValue, id]);
1846
1859
  useEffect(() => {
1860
+ const value = defaultValue && new Date(defaultValue);
1847
1861
  register && register(id, Object.assign(Object.assign({}, validationRules), {
1848
- value: defaultValue && new Date(defaultValue).toISOString()
1862
+ value
1849
1863
  }));
1850
1864
  }, [register, validationRules, defaultValue, id]);
1851
- return jsx(FormGroup, Object.assign({
1852
- label: props.label,
1853
- tip: props.tip,
1854
- isInvalid: props.isInvalid,
1855
- helpText: props.errorMessage || props.helpText,
1856
- helpAddon: props.helpAddon || null,
1857
- dataTestId: `${props.dataTestId}-FormGroup`
1858
- }, {
1859
- children: jsx(DateField, Object.assign({}, props, {
1860
- onChange: onChangeHandler,
1861
- label: undefined
1862
- }))
1865
+ return jsx(DateField, Object.assign({}, rest, {
1866
+ defaultValue: defaultValue,
1867
+ id: id,
1868
+ onChange: onChangeHandler,
1869
+ disabled: props.readOnly,
1870
+ label: undefined
1863
1871
  }));
1864
1872
  };
1865
1873
 
@@ -2552,7 +2560,8 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2552
2560
  label: title,
2553
2561
  isInvalid: errorMessage ? true : false,
2554
2562
  helpText: errorMessage || description,
2555
- dataTestId: `numberField-FormGroup`
2563
+ dataTestId: `numberField-FormGroup`,
2564
+ disabled: !typedDefinition.uiEditable
2556
2565
  }, {
2557
2566
  children: jsx(BaseInput, Object.assign({
2558
2567
  type: "number",
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@trackunit/custom-field-components",
3
- "version": "0.0.118",
3
+ "version": "0.0.122",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
7
- "@trackunit/react-core-contexts-test": "0.0.34",
8
- "@trackunit/react-components": "0.0.131",
7
+ "@trackunit/react-core-contexts-test": "0.0.36",
8
+ "@trackunit/react-components": "0.0.134",
9
9
  "react": "17.0.1",
10
10
  "react-hook-form": "^7.29.0",
11
- "@trackunit/iris-app-runtime-core": "0.0.64",
12
- "@trackunit/iris-app-runtime-core-api": "0.0.61",
11
+ "@trackunit/iris-app-runtime-core": "0.0.66",
12
+ "@trackunit/iris-app-runtime-core-api": "0.0.63",
13
13
  "react-select": "^5.4.0",
14
14
  "libphonenumber-js": "^1.10.7"
15
15
  },