@vuu-ui/vuu-data-react 4.2.7 → 4.2.9

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.2.7",
2
+ "version": "4.2.9",
3
3
  "main": "./src/index.js",
4
4
  "author": "heswell",
5
5
  "license": "Apache-2.0",
@@ -9,21 +9,21 @@
9
9
  "type-defs": "node ../../scripts/build-type-defs.mjs"
10
10
  },
11
11
  "devDependencies": {
12
- "@vuu-ui/vuu-data-types": "4.2.7",
13
- "@vuu-ui/vuu-filter-types": "4.2.7",
14
- "@vuu-ui/vuu-protocol-types": "4.2.7",
15
- "@vuu-ui/vuu-table-types": "4.2.7"
12
+ "@vuu-ui/vuu-data-types": "4.2.9",
13
+ "@vuu-ui/vuu-filter-types": "4.2.9",
14
+ "@vuu-ui/vuu-protocol-types": "4.2.9",
15
+ "@vuu-ui/vuu-table-types": "4.2.9"
16
16
  },
17
17
  "dependencies": {
18
- "@vuu-ui/vuu-context-menu": "4.2.7",
19
- "@vuu-ui/vuu-data-remote": "4.2.7",
20
- "@vuu-ui/vuu-filter-parser": "4.2.7",
21
- "@vuu-ui/vuu-filters": "4.2.7",
22
- "@vuu-ui/vuu-layout": "4.2.7",
23
- "@vuu-ui/vuu-notifications": "4.2.7",
24
- "@vuu-ui/vuu-ui-controls": "4.2.7",
25
- "@vuu-ui/vuu-utils": "4.2.7",
26
- "@vuu-ui/vuu-table": "4.2.7",
18
+ "@vuu-ui/vuu-context-menu": "4.2.9",
19
+ "@vuu-ui/vuu-data-remote": "4.2.9",
20
+ "@vuu-ui/vuu-filter-parser": "4.2.9",
21
+ "@vuu-ui/vuu-filters": "4.2.9",
22
+ "@vuu-ui/vuu-layout": "4.2.9",
23
+ "@vuu-ui/vuu-notifications": "4.2.9",
24
+ "@vuu-ui/vuu-ui-controls": "4.2.9",
25
+ "@vuu-ui/vuu-utils": "4.2.9",
26
+ "@vuu-ui/vuu-table": "4.2.9",
27
27
  "@salt-ds/core": "1.74.0",
28
28
  "@salt-ds/styles": "0.4.2",
29
29
  "@salt-ds/window": "0.1.2"
@@ -4,7 +4,7 @@ const CLEAN_FORM = {
4
4
  };
5
5
  const buildFormEditState = (entity, newEntity)=>{
6
6
  if (void 0 === entity) return CLEAN_FORM;
7
- {
7
+ else {
8
8
  const editedFields = [];
9
9
  for (const [fieldName, value] of Object.entries(entity))if (value !== newEntity[fieldName]) editedFields.push(fieldName);
10
10
  return {
@@ -20,8 +20,7 @@ function toTimeString(value, timestamp, { timeZone }, milliseconds = false) {
20
20
  const { hour, minute, second, millisecond } = timestamp.getFields(timeZone);
21
21
  const timeString = `${pad(hour)}:${pad(minute)}:${pad(second)}`;
22
22
  return milliseconds ? `${timeString}.${`${millisecond}`.padStart(3, "0")}` : timeString;
23
- }
24
- if ("string" == typeof value) if (milliseconds) {
23
+ } else if ("string" == typeof value) if (milliseconds) {
25
24
  const timeString = 8 === value.length ? `${value}.000` : value.slice(0, 12);
26
25
  if (isValidTimeStringMillis(timeString)) return timeString;
27
26
  } else {
@@ -43,7 +42,7 @@ const getDataItemEditControl = ({ InputProps, TypeaheadProps, appearance, classN
43
42
  readOnly: true,
44
43
  "data-edit-control": true
45
44
  });
46
- if (temporalInfo?.kind === "time") {
45
+ else if (temporalInfo?.kind === "time") {
47
46
  const { value, onChange } = InputProps?.inputProps ?? {};
48
47
  const baseValue = toEpochTimestamp(value, temporalInfo);
49
48
  const handleCommitTime = (evt, timeString)=>{
@@ -66,8 +65,7 @@ const getDataItemEditControl = ({ InputProps, TypeaheadProps, appearance, classN
66
65
  onCommit: handleCommitTime,
67
66
  "data-edit-control": true
68
67
  });
69
- }
70
- if (temporalInfo) {
68
+ } else if (temporalInfo) {
71
69
  const baseValue = toEpochTimestamp(InputProps?.inputProps?.value, temporalInfo);
72
70
  const handleCommitDate = (evt, startOfDayMillis)=>{
73
71
  let timestamp = EpochTimestamp.fromMillis(startOfDayMillis);
@@ -93,8 +91,7 @@ const getDataItemEditControl = ({ InputProps, TypeaheadProps, appearance, classN
93
91
  value: baseValue,
94
92
  "data-edit-control": true
95
93
  });
96
- }
97
- if (showToggleFilter(dataDescriptor, variant, values, table)) return /*#__PURE__*/ jsx(ToggleFilter, {
94
+ } else if (showToggleFilter(dataDescriptor, variant, values, table)) return /*#__PURE__*/ jsx(ToggleFilter, {
98
95
  appearance: "transparent" !== appearance ? appearance : void 0,
99
96
  className: className,
100
97
  column: dataDescriptor.name,
@@ -106,7 +103,7 @@ const getDataItemEditControl = ({ InputProps, TypeaheadProps, appearance, classN
106
103
  values: values?.length ? values : BOOLEAN_TOGGLE_VALUES,
107
104
  value: InputProps?.inputProps?.value ?? "all"
108
105
  });
109
- if ("string" === dataDescriptor.serverDataType && table) return /*#__PURE__*/ jsx(VuuTypeaheadInput, {
106
+ else if ("string" === dataDescriptor.serverDataType && table) return /*#__PURE__*/ jsx(VuuTypeaheadInput, {
110
107
  ...InputProps,
111
108
  ...TypeaheadProps,
112
109
  className: className,
@@ -26,7 +26,7 @@ const nextValidationState = (state, dataDescriptor, value)=>{
26
26
  [name]: result.messages.join("\n")
27
27
  }
28
28
  };
29
- if (!wasOk) {
29
+ else if (!wasOk) {
30
30
  const fieldsInError = Object.keys(existingMessages);
31
31
  if (fieldsInError.includes(name)) if (1 === fieldsInError.length) return {
32
32
  ok: true,
@@ -53,7 +53,7 @@ function find(descriptors, fieldname) {
53
53
  const getField = (target)=>{
54
54
  const fieldElement = queryClosest(target, "[data-field]");
55
55
  if (fieldElement) return fieldElement.dataset.field;
56
- throw Error("no field ");
56
+ else throw Error("no field ");
57
57
  };
58
58
  const useEditForm = ({ dataSource, formFieldDescriptors, onSubmit })=>{
59
59
  const { showDialog, closeDialog } = useModal();
@@ -11,7 +11,7 @@ const loadLookupValues = ({ labelColumn, table, valueColumn })=>{
11
11
  const tableKey = `${table.module}:${table.table}`;
12
12
  const lookupValues = lookupValueMap.get(tableKey);
13
13
  if (lookupValues) return lookupValues;
14
- {
14
+ else {
15
15
  const promise = new Promise((resolve)=>{
16
16
  const columns = [
17
17
  valueColumn,
@@ -44,7 +44,7 @@ const loadLookupValues = ({ labelColumn, table, valueColumn })=>{
44
44
  };
45
45
  const getLookupDetails = ({ name, type })=>{
46
46
  if (isTypeDescriptor(type) && isLookupRenderer(type.renderer)) return type.renderer.lookup;
47
- throw Error(`useLookupValues column ${name} is not configured to use lookup values`);
47
+ else throw Error(`useLookupValues column ${name} is not configured to use lookup values`);
48
48
  };
49
49
  const useLookupValues = (column, initialValueProp)=>{
50
50
  const { type: columnType } = column;
@@ -56,8 +56,7 @@ const useLookupValues = (column, initialValueProp)=>{
56
56
  initialValue: getSelectedOption(values, initialValueProp) ?? null,
57
57
  values
58
58
  };
59
- }
60
- {
59
+ } else {
61
60
  const lookupDetails = getLookupDetails(column);
62
61
  const values = getLookupValues?.(lookupDetails.table) ?? NO_VALUES;
63
62
  return {
@@ -16,8 +16,7 @@ const useSessionDataSource = (props)=>{
16
16
  if (props?.onConfigChange) ds.on("config", props.onConfigChange);
17
17
  sessionState.set(sessionKey, ds);
18
18
  return ds;
19
- }
20
- throw Error("[useSessionDataSource] unable to create new DataSource, columns have not been defined ");
19
+ } else throw Error("[useSessionDataSource] unable to create new DataSource, columns have not been defined ");
21
20
  }, [
22
21
  VuuDataSource,
23
22
  props?.onConfigChange
@@ -39,7 +39,7 @@ const useTypeaheadSuggestions = ()=>{
39
39
  try {
40
40
  const response = await dataSource.rpcRequest?.(rpcMessage);
41
41
  if (response?.type === "SUCCESS_RESULT") return response.data;
42
- return false;
42
+ else return false;
43
43
  } catch (err) {
44
44
  return false;
45
45
  }
@@ -44,7 +44,7 @@ const vuuContextCompatibleWithTableLocation = (uiLocation, vuuContext, selectedR
44
44
  switch(uiLocation){
45
45
  case "grid":
46
46
  if ("selected-rows" === vuuContext) return selectedRowCount > 0;
47
- return true;
47
+ else return true;
48
48
  case "header":
49
49
  return "grid" === vuuContext;
50
50
  default:
@@ -55,8 +55,7 @@ const gridRowMeetsFilterCriteria = (context, dataRow, selectedRows, filter)=>{
55
55
  if ("cell" === context || "row" === context) {
56
56
  const filterPredicate = getFilterPredicate(filter);
57
57
  return filterPredicate(dataRow);
58
- }
59
- if ("selected-rows" === context) if (0 === selectedRows.length) return false;
58
+ } else if ("selected-rows" === context) if (0 === selectedRows.length) return false;
60
59
  else {
61
60
  const filterPredicate = getFilterPredicate(filter);
62
61
  return selectedRows.every(filterPredicate);
@@ -209,24 +208,24 @@ const useVuuMenuActions = ({ clientSideMenuActionHandler, dataSource, onRpcRespo
209
208
  value: options.value,
210
209
  type: "VIEW_PORT_MENU_CELL_RPC"
211
210
  };
212
- if (isRowMenu(options)) return {
211
+ else if (isRowMenu(options)) return {
213
212
  rowKey: options.rowKey,
214
213
  row: options.row,
215
214
  rpcName,
216
215
  type: "VIEW_PORT_MENU_ROW_RPC"
217
216
  };
218
- if (isSelectionMenu(options)) return {
217
+ else if (isSelectionMenu(options)) return {
219
218
  rpcName,
220
219
  type: "VIEW_PORT_MENUS_SELECT_RPC"
221
220
  };
222
- return {
221
+ else return {
223
222
  rpcName,
224
223
  type: "VIEW_PORT_MENU_TABLE_RPC"
225
224
  };
226
225
  };
227
226
  const menuActionHandler = useCallback((menuItemId, options)=>{
228
227
  if (clientSideMenuActionHandler?.(menuItemId, options)) return true;
229
- if ("MENU_RPC_CALL" === menuItemId) {
228
+ else if ("MENU_RPC_CALL" === menuItemId) {
230
229
  const rpcRequest = getMenuRpcRequest(options);
231
230
  dataSource?.menuRpcCall(rpcRequest).then((rpcResponse)=>{
232
231
  if (rpcResponse) {
@@ -245,12 +244,10 @@ const useVuuMenuActions = ({ clientSideMenuActionHandler, dataSource, onRpcRespo
245
244
  }
246
245
  });
247
246
  return true;
248
- }
249
- if ("link-table" === menuItemId) {
247
+ } else if ("link-table" === menuItemId) {
250
248
  if (dataSource) dataSource.visualLink = options;
251
249
  return true;
252
- }
253
- console.log(`useViewServer handleMenuAction, can't handle action type ${menuItemId}`);
250
+ } else console.log(`useViewServer handleMenuAction, can't handle action type ${menuItemId}`);
254
251
  return false;
255
252
  }, [
256
253
  clientSideMenuActionHandler,
@@ -11,7 +11,7 @@ const classBase = "vuuSessionEditingForm";
11
11
  const getField = (fields, name)=>{
12
12
  const field = fields.find((f)=>f.name === name);
13
13
  if (field) return field;
14
- throw Error(`SessionEditingForm, no field '${name}' found`);
14
+ else throw Error(`SessionEditingForm, no field '${name}' found`);
15
15
  };
16
16
  const getFieldNameAndValue = ({ target })=>{
17
17
  const formField = queryClosest(target, ".saltFormField");
@@ -22,8 +22,7 @@ const getFieldNameAndValue = ({ target })=>{
22
22
  field,
23
23
  target.value
24
24
  ];
25
- }
26
- throw Error("Form control is not enclosed in FormField");
25
+ } else throw Error("Form control is not enclosed in FormField");
27
26
  };
28
27
  const Status = {
29
28
  uninitialised: 0,
@@ -33,12 +32,12 @@ const Status = {
33
32
  };
34
33
  const getDataSource = (dataSource, schema)=>{
35
34
  if (dataSource) return dataSource;
36
- if (schema) return new VuuDataSource({
35
+ else if (schema) return new VuuDataSource({
37
36
  bufferSize: 0,
38
37
  table: schema.table,
39
38
  columns: schema.columns.map((col)=>col.name)
40
39
  });
41
- throw Error("SessionEditingForm: either a DataSource or a TableSchema must be provided");
40
+ else throw Error("SessionEditingForm: either a DataSource or a TableSchema must be provided");
42
41
  };
43
42
  const SessionEditingForm_SessionEditingForm = ({ className, config: { fields, key: keyField }, dataSource: dataSourceProp, id: idProp, onClose, schema, ...htmlAttributes })=>{
44
43
  const targetWindow = useWindow();
@@ -159,7 +158,7 @@ const SessionEditingForm_SessionEditingForm = ({ className, config: { fields, ke
159
158
  className: `${classBase}-fieldValue vuuReadOnly`,
160
159
  children: value
161
160
  });
162
- return /*#__PURE__*/ jsx(Input, {
161
+ else return /*#__PURE__*/ jsx(Input, {
163
162
  className: `${classBase}-fieldValue`,
164
163
  onBlur: handleBlur,
165
164
  onChange: handleChange,