@trackunit/custom-field-components 0.0.202 → 0.0.207

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.
package/index.js CHANGED
@@ -31,34 +31,24 @@ var FunctionPrototype$1 = Function.prototype;
31
31
  var call$8 = FunctionPrototype$1.call;
32
32
  var uncurryThisWithBind = NATIVE_BIND$1 && FunctionPrototype$1.bind.bind(call$8, call$8);
33
33
 
34
- var functionUncurryThisRaw = function (fn) {
35
- return NATIVE_BIND$1 ? uncurryThisWithBind(fn) : function () {
34
+ var functionUncurryThis = NATIVE_BIND$1 ? uncurryThisWithBind : function (fn) {
35
+ return function () {
36
36
  return call$8.apply(fn, arguments);
37
37
  };
38
38
  };
39
39
 
40
- var uncurryThisRaw$1 = functionUncurryThisRaw;
40
+ var uncurryThis$e = functionUncurryThis;
41
41
 
42
- var toString$7 = uncurryThisRaw$1({}.toString);
43
- var stringSlice$3 = uncurryThisRaw$1(''.slice);
42
+ var toString$7 = uncurryThis$e({}.toString);
43
+ var stringSlice$3 = uncurryThis$e(''.slice);
44
44
 
45
- var classofRaw$2 = function (it) {
45
+ var classofRaw$1 = function (it) {
46
46
  return stringSlice$3(toString$7(it), 8, -1);
47
47
  };
48
48
 
49
- var classofRaw$1 = classofRaw$2;
50
- var uncurryThisRaw = functionUncurryThisRaw;
51
-
52
- var functionUncurryThis = function (fn) {
53
- // Nashorn bug:
54
- // https://github.com/zloirock/core-js/issues/1128
55
- // https://github.com/zloirock/core-js/issues/1130
56
- if (classofRaw$1(fn) === 'Function') return uncurryThisRaw(fn);
57
- };
58
-
59
49
  var uncurryThis$d = functionUncurryThis;
60
50
  var fails$f = fails$h;
61
- var classof$3 = classofRaw$2;
51
+ var classof$3 = classofRaw$1;
62
52
 
63
53
  var $Object$4 = Object;
64
54
  var split = uncurryThis$d(''.split);
@@ -140,10 +130,10 @@ var store$2 = sharedStore;
140
130
  (shared$4.exports = function (key, value) {
141
131
  return store$2[key] || (store$2[key] = value !== undefined ? value : {});
142
132
  })('versions', []).push({
143
- version: '3.25.5',
133
+ version: '3.26.1',
144
134
  mode: 'global',
145
135
  copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
146
- license: 'https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE',
136
+ license: 'https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE',
147
137
  source: 'https://github.com/zloirock/core-js'
148
138
  });
149
139
 
@@ -1570,7 +1560,7 @@ var toStringTagSupport = String(test) === '[object z]';
1570
1560
 
1571
1561
  var TO_STRING_TAG_SUPPORT = toStringTagSupport;
1572
1562
  var isCallable$2 = isCallable$h;
1573
- var classofRaw = classofRaw$2;
1563
+ var classofRaw = classofRaw$1;
1574
1564
  var wellKnownSymbol$3 = wellKnownSymbol$b;
1575
1565
 
1576
1566
  var TO_STRING_TAG = wellKnownSymbol$3('toStringTag');
@@ -1885,25 +1875,24 @@ function __rest(s, e) {
1885
1875
 
1886
1876
  const BooleanCustomField = _a => {
1887
1877
  var {
1888
- defaultValue,
1889
- dataTestId = "booleanField",
1890
- onChange,
1891
- value,
1892
- id,
1893
- setValue,
1894
- register,
1895
- validationRules,
1896
- disabled = false,
1897
- label,
1898
- tip,
1899
- isInvalid,
1900
- errorMessage,
1901
- helpAddon,
1902
- maxLength,
1903
- helpText
1904
- } = _a,
1905
- rest = __rest(_a, ["defaultValue", "dataTestId", "onChange", "value", "id", "setValue", "register", "validationRules", "disabled", "label", "tip", "isInvalid", "errorMessage", "helpAddon", "maxLength", "helpText"]);
1906
-
1878
+ defaultValue,
1879
+ dataTestId = "booleanField",
1880
+ onChange,
1881
+ value,
1882
+ id,
1883
+ setValue,
1884
+ register,
1885
+ validationRules,
1886
+ disabled = false,
1887
+ label,
1888
+ tip,
1889
+ isInvalid,
1890
+ errorMessage,
1891
+ helpAddon,
1892
+ maxLength,
1893
+ helpText
1894
+ } = _a,
1895
+ rest = __rest(_a, ["defaultValue", "dataTestId", "onChange", "value", "id", "setValue", "register", "validationRules", "disabled", "label", "tip", "isInvalid", "errorMessage", "helpAddon", "maxLength", "helpText"]);
1907
1896
  const initialValue = value !== undefined ? value : defaultValue ? defaultValue : false;
1908
1897
  const renderAsInvalid = isInvalid || Boolean(errorMessage);
1909
1898
  const [internalValue, setInternalValue] = React.useState(initialValue);
@@ -1913,19 +1902,17 @@ const BooleanCustomField = _a => {
1913
1902
  const onChangeHandler = React.useCallback(event => {
1914
1903
  onChange && onChange(event);
1915
1904
  const isChecked = event.target.checked;
1916
-
1917
1905
  if (setValue) {
1918
1906
  setValue(id, isChecked);
1919
1907
  }
1920
-
1921
1908
  setInternalValue(isChecked);
1922
1909
  }, [setInternalValue, onChange, id, setValue]);
1923
1910
  React.useEffect(() => {
1924
1911
  register && register(id, Object.assign(Object.assign({}, validationRules), {
1925
1912
  value: internalValue.toString()
1926
- })); // eslint-disable-next-line react-hooks/exhaustive-deps
1913
+ }));
1914
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1927
1915
  }, []); // register only once
1928
-
1929
1916
  return jsx(FormGroup, Object.assign({
1930
1917
  label: label,
1931
1918
  tip: tip,
@@ -1948,17 +1935,15 @@ const BooleanCustomField = _a => {
1948
1935
 
1949
1936
  const DateCustomField = props => {
1950
1937
  const {
1951
- setValue,
1952
- defaultValue,
1953
- register,
1954
- id,
1955
- validationRules
1956
- } = props,
1957
- rest = __rest(props, ["setValue", "defaultValue", "register", "id", "validationRules"]);
1958
-
1938
+ setValue,
1939
+ defaultValue,
1940
+ register,
1941
+ id,
1942
+ validationRules
1943
+ } = props,
1944
+ rest = __rest(props, ["setValue", "defaultValue", "register", "id", "validationRules"]);
1959
1945
  const onChangeHandler = useCallback(e => {
1960
1946
  var _a;
1961
-
1962
1947
  setValue && setValue(id, (_a = e.target.valueAsDate) === null || _a === void 0 ? void 0 : _a.toISOString());
1963
1948
  }, [setValue, id]);
1964
1949
  useEffect(() => {
@@ -1982,7 +1967,6 @@ const convertToValueFormat = value => {
1982
1967
  value
1983
1968
  };
1984
1969
  };
1985
-
1986
1970
  const DropdownCustomField = ({
1987
1971
  defaultValue,
1988
1972
  dataTestId,
@@ -2063,7 +2047,7 @@ var inheritIfRequired$1 = function ($this, dummy, Wrapper) {
2063
2047
  };
2064
2048
 
2065
2049
  var isObject = isObject$8;
2066
- var classof = classofRaw$2;
2050
+ var classof = classofRaw$1;
2067
2051
  var wellKnownSymbol$2 = wellKnownSymbol$b;
2068
2052
 
2069
2053
  var MATCH$1 = wellKnownSymbol$2('match');
@@ -2500,8 +2484,8 @@ const getNumberValidationRules = definition => {
2500
2484
  value: definition.maximumNumber,
2501
2485
  message: `maximum value is ${definition.maximumNumber}`
2502
2486
  }
2503
- }; // TODO: Validate if integer if definition requires integer
2504
-
2487
+ };
2488
+ // TODO: Validate if integer if definition requires integer
2505
2489
  return definition.uiEditable ? Object.assign(Object.assign(Object.assign({}, maximum), minimum), defaultRules) : defaultRules;
2506
2490
  };
2507
2491
  const getStringValidationRules = definition => {
@@ -2561,15 +2545,13 @@ const getPhoneNumberValidationRules = definition => {
2561
2545
  };
2562
2546
 
2563
2547
  let _ = t => t,
2564
- _t2,
2565
- _t3;
2548
+ _t2,
2549
+ _t3;
2566
2550
  const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldId) => {
2567
2551
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
2568
-
2569
2552
  const [isEditing, setIsEditing] = useState(false);
2570
2553
  const [numberValue, setNumberValue] = useState(() => {
2571
2554
  var _a;
2572
-
2573
2555
  if ((field === null || field === void 0 ? void 0 : field.definition) && field.definition.type === CustomFieldType.NUMBER) {
2574
2556
  const typedValue = field.value;
2575
2557
  return (_a = typedValue.numberValue) !== null && _a !== void 0 ? _a : field.definition.defaultNumberValue;
@@ -2577,11 +2559,9 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2577
2559
  return "";
2578
2560
  }
2579
2561
  });
2580
-
2581
2562
  if ((field === null || field === void 0 ? void 0 : field.definition) === undefined || ((_a = field === null || field === void 0 ? void 0 : field.definition) === null || _a === void 0 ? void 0 : _a.type) === undefined) {
2582
2563
  return null;
2583
2564
  }
2584
-
2585
2565
  const key = (_b = fieldId !== null && fieldId !== void 0 ? fieldId : field.definition.key) !== null && _b !== void 0 ? _b : "";
2586
2566
  const fieldError = key ? validation.formState.errors[key] : undefined;
2587
2567
  const errorMessage = fieldError ? fieldError.message + "" : undefined;
@@ -2590,7 +2570,6 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2590
2570
  description,
2591
2571
  title
2592
2572
  } = field.definition;
2593
-
2594
2573
  switch (type) {
2595
2574
  case CustomFieldType.WEB_ADDRESS:
2596
2575
  {
@@ -2612,7 +2591,6 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2612
2591
  errorMessage: errorMessage
2613
2592
  }, validation.register(key, rules)));
2614
2593
  }
2615
-
2616
2594
  case CustomFieldType.EMAIL:
2617
2595
  {
2618
2596
  const typedDefinition = field.definition;
@@ -2632,7 +2610,6 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2632
2610
  errorMessage: errorMessage
2633
2611
  }, validation.register(key, rules)));
2634
2612
  }
2635
-
2636
2613
  case CustomFieldType.PHONE_NUMBER:
2637
2614
  {
2638
2615
  const typedDefinition = field.definition;
@@ -2652,7 +2629,6 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2652
2629
  errorMessage: errorMessage === "" ? "Must be a phone number" : undefined
2653
2630
  }, validation.register(key, rules)));
2654
2631
  }
2655
-
2656
2632
  case CustomFieldType.STRING:
2657
2633
  {
2658
2634
  const typedDefinition = field.definition;
@@ -2669,7 +2645,6 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2669
2645
  dataTestId: `stringField`
2670
2646
  }, validation.register(key, rules)));
2671
2647
  }
2672
-
2673
2648
  case CustomFieldType.NUMBER:
2674
2649
  {
2675
2650
  const typedDefinition = field.definition;
@@ -2722,7 +2697,6 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2722
2697
  }, numberProps))
2723
2698
  }));
2724
2699
  }
2725
-
2726
2700
  case CustomFieldType.BOOLEAN:
2727
2701
  {
2728
2702
  const typedDefinition = field.definition;
@@ -2741,7 +2715,6 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2741
2715
  dataTestId: "booleanField"
2742
2716
  }, key);
2743
2717
  }
2744
-
2745
2718
  case CustomFieldType.DROPDOWN:
2746
2719
  {
2747
2720
  const typedDefinition = field.definition;
@@ -2762,20 +2735,17 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2762
2735
  dataTestId: "dropdownField"
2763
2736
  }, key);
2764
2737
  }
2765
-
2766
2738
  case CustomFieldType.DATE:
2767
2739
  {
2768
2740
  const typedDefinition = field.definition;
2769
2741
  const typedValue = field.value;
2770
2742
  const rules = getDateValidationRules();
2771
2743
  let defaultValue;
2772
-
2773
2744
  if (typedValue.dateValue !== undefined && typedValue.dateValue !== null) {
2774
2745
  defaultValue = new Date(typedValue.dateValue);
2775
2746
  } else if (typedDefinition.defaultDateValue !== undefined && typedDefinition.defaultDateValue !== null) {
2776
2747
  defaultValue = new Date(typedDefinition.defaultDateValue);
2777
2748
  }
2778
-
2779
2749
  return jsx(DateCustomField, {
2780
2750
  dataTestId: "dateField",
2781
2751
  id: key || "date-field",
@@ -2790,7 +2760,6 @@ const useCustomFieldResolver = (field, validation, unitPreference = "SI", fieldI
2790
2760
  title: field.definition.title || ""
2791
2761
  }, key);
2792
2762
  }
2793
-
2794
2763
  default:
2795
2764
  throw new Error(`Type not supported: ${type}`);
2796
2765
  }
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@trackunit/custom-field-components",
3
- "version": "0.0.202",
3
+ "version": "0.0.207",
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.1.9",
8
- "@trackunit/react-components": "0.0.199",
7
+ "@trackunit/react-core-contexts-test": "0.1.11",
8
+ "@trackunit/react-components": "0.0.203",
9
9
  "react": "17.0.2",
10
- "react-hook-form": "^7.36.1",
11
- "@trackunit/iris-app-runtime-core": "0.3.1",
12
- "@trackunit/iris-app-runtime-core-api": "0.3.0",
13
- "@trackunit/tailwind-styled-components": "0.0.49",
14
- "react-select": "^5.4.0",
15
- "libphonenumber-js": "^1.10.13"
10
+ "react-hook-form": "7.40.0",
11
+ "@trackunit/iris-app-runtime-core": "0.3.3",
12
+ "@trackunit/iris-app-runtime-core-api": "0.3.2",
13
+ "@trackunit/tailwind-styled-components": "0.0.50",
14
+ "react-select": "5.7.0",
15
+ "libphonenumber-js": "1.10.14"
16
16
  },
17
17
  "module": "./index.js",
18
18
  "main": "./index.js",
19
19
  "type": "module",
20
- "types": "./index.d.ts",
20
+ "types": "./src/index.d.ts",
21
21
  "peerDependencies": {}
22
22
  }
File without changes
File without changes
File without changes
File without changes
File without changes