@vuu-ui/vuu-data-react 5.0.0-alpha.2 → 5.0.0-alpha.4

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": "5.0.0-alpha.2",
2
+ "version": "5.0.0-alpha.4",
3
3
  "main": "./src/index.js",
4
4
  "author": "heswell",
5
5
  "type": "module",
@@ -10,25 +10,26 @@
10
10
  "type-defs": "node ../../scripts/build-type-defs.mjs"
11
11
  },
12
12
  "devDependencies": {
13
- "@vuu-ui/vuu-data-types": "5.0.0-alpha.2",
14
- "@vuu-ui/vuu-filter-types": "5.0.0-alpha.2",
15
- "@vuu-ui/vuu-protocol-types": "5.0.0-alpha.2",
16
- "@vuu-ui/vuu-table-types": "5.0.0-alpha.2"
13
+ "@vuu-ui/vuu-data-types": "5.0.0-alpha.4",
14
+ "@vuu-ui/vuu-filter-types": "5.0.0-alpha.4",
15
+ "@vuu-ui/vuu-protocol-types": "5.0.0-alpha.4",
16
+ "@vuu-ui/vuu-table-types": "5.0.0-alpha.4"
17
17
  },
18
18
  "dependencies": {
19
- "@vuu-ui/vuu-context-menu": "5.0.0-alpha.2",
20
- "@vuu-ui/vuu-data-remote": "5.0.0-alpha.2",
21
- "@vuu-ui/vuu-filter-parser": "5.0.0-alpha.2",
22
- "@vuu-ui/vuu-filters": "5.0.0-alpha.2",
23
- "@vuu-ui/vuu-layout": "5.0.0-alpha.2",
24
- "@vuu-ui/vuu-notifications": "5.0.0-alpha.2",
25
- "@vuu-ui/vuu-ui-controls": "5.0.0-alpha.2",
26
- "@vuu-ui/vuu-utils": "5.0.0-alpha.2",
27
- "@vuu-ui/vuu-table": "5.0.0-alpha.2",
19
+ "@vuu-ui/vuu-context-menu": "5.0.0-alpha.4",
20
+ "@vuu-ui/vuu-data-editing": "5.0.0-alpha.4",
21
+ "@vuu-ui/vuu-data-remote": "5.0.0-alpha.4",
22
+ "@vuu-ui/vuu-filter-parser": "5.0.0-alpha.4",
23
+ "@vuu-ui/vuu-filters": "5.0.0-alpha.4",
24
+ "@vuu-ui/vuu-layout": "5.0.0-alpha.4",
25
+ "@vuu-ui/vuu-notifications": "5.0.0-alpha.4",
26
+ "@vuu-ui/vuu-ui-controls": "5.0.0-alpha.4",
27
+ "@vuu-ui/vuu-utils": "5.0.0-alpha.4",
28
+ "@vuu-ui/vuu-table": "5.0.0-alpha.4",
28
29
  "@salt-ds/core": "1.74.0",
29
30
  "@salt-ds/styles": "0.4.2",
30
31
  "@salt-ds/window": "0.1.2",
31
- "@vuu-ui/core": "5.0.0-alpha.2"
32
+ "@vuu-ui/core": "5.0.0-alpha.4"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "clsx": "^2.0.0",
@@ -6,7 +6,7 @@ import clsx from "clsx";
6
6
  import { registerRules } from "./edit-validation-rules.js";
7
7
  import { useEditForm } from "./useEditForm.js";
8
8
  import EditForm from "./EditForm.css";
9
- import { getDataItemEditControl } from "./get-data-item-edit-control.js";
9
+ import { getDataItemEditControl } from "@vuu-ui/vuu-data-editing";
10
10
  const classBase = "EditForm";
11
11
  registerRules();
12
12
  const EditForm_EditForm = ({ className, dataSource, formFieldDescriptors, onSubmit: onSubmitProp, ...htmlAttributes })=>{
@@ -1,6 +1,6 @@
1
- export * from "./get-data-item-edit-control.js";
2
1
  export * from "./EditForm.js";
3
2
  export * from "./edit-rule-validation-checker.js";
4
3
  export * from "./UnsavedChangesReport.js";
5
4
  export * from "./useEditForm.js";
6
5
  export * from "./form-edit-state.js";
6
+ export { getDataItemEditControl } from "@vuu-ui/vuu-data-editing";
package/src/index.js CHANGED
@@ -3,7 +3,7 @@ export * from "./datasource-provider/index.js";
3
3
  export * from "./session-editing-form/index.js";
4
4
  export { useLookupValues } from "./hooks/useLookupValues.js";
5
5
  export { useSessionDataSource } from "./hooks/useSessionDataSource.js";
6
- export { getTypeaheadParams, useTypeaheadSuggestions } from "./hooks/useTypeaheadSuggestions.js";
6
+ export { getTypeaheadParams, useTypeaheadSuggestions } from "@vuu-ui/vuu-utils";
7
7
  export { useVisualLinks } from "./hooks/useVisualLinks.js";
8
8
  export { isRowMenu, isSelectionMenu, useVuuMenuActions } from "./hooks/useVuuMenuActions.js";
9
9
  export { useVuuTables } from "./hooks/useVuuTables.js";
@@ -1,4 +1,5 @@
1
- export * from "./get-data-item-edit-control";
1
+ /** @deprecated import from @vuu-ui/vuu-data-editing */
2
+ export { getDataItemEditControl, type DataItemEditControlProps, type DataItemEditControlPurpose, type DataItemEditControlVariant, type ValidationStatus, } from "@vuu-ui/vuu-data-editing";
2
3
  export * from "./EditForm";
3
4
  export * from "./edit-rule-validation-checker";
4
5
  export * from "./UnsavedChangesReport";
package/types/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export * from "./data-editing";
2
2
  export * from "./datasource-provider";
3
3
  export { useLookupValues } from "./hooks/useLookupValues";
4
4
  export { useSessionDataSource } from "./hooks/useSessionDataSource";
5
- export { getTypeaheadParams, useTypeaheadSuggestions, } from "./hooks/useTypeaheadSuggestions";
5
+ export { getTypeaheadParams, useTypeaheadSuggestions, } from "@vuu-ui/vuu-utils";
6
6
  export { useVisualLinks } from "./hooks/useVisualLinks";
7
7
  export { isRowMenu, isSelectionMenu, useVuuMenuActions, type MenuActionConfig, } from "./hooks/useVuuMenuActions";
8
8
  export { useVuuTables } from "./hooks/useVuuTables";
@@ -1,131 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { VuuDatePicker, VuuInput, VuuTimePicker, VuuTypeaheadInput } from "@vuu-ui/vuu-ui-controls";
3
- import { EpochTimestamp, getTemporalInfo, isDataValueEditable, isTimeDataValueWithMilliseconds, isValidTimeString, isValidTimeStringMillis, parseTemporalInput } from "@vuu-ui/vuu-utils";
4
- import { ToggleFilter } from "@vuu-ui/vuu-filters";
5
- const timeOfDayPattern = /^\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?$/;
6
- const toEpochTimestamp = (value, { encoding })=>{
7
- if (("string" == typeof value || "number" == typeof value) && !timeOfDayPattern.test(`${value}`)) return EpochTimestamp.fromWire(value, encoding);
8
- };
9
- const pad = (n)=>`${n}`.padStart(2, "0");
10
- function toTimeString(value, timestamp, { timeZone }, milliseconds = false) {
11
- if (timestamp) {
12
- const { hour, minute, second, millisecond } = timestamp.getFields(timeZone);
13
- const timeString = `${pad(hour)}:${pad(minute)}:${pad(second)}`;
14
- return milliseconds ? `${timeString}.${`${millisecond}`.padStart(3, "0")}` : timeString;
15
- }
16
- if ("string" == typeof value) if (milliseconds) {
17
- const timeString = 8 === value.length ? `${value}.000` : value.slice(0, 12);
18
- if (isValidTimeStringMillis(timeString)) return timeString;
19
- } else {
20
- const timeString = value.slice(0, 8);
21
- if (isValidTimeString(timeString)) return timeString;
22
- }
23
- }
24
- const BOOLEAN_TOGGLE_VALUES = [
25
- true,
26
- false
27
- ];
28
- const getDataItemEditControl = ({ InputProps, TypeaheadProps, className, commitOnBlur, commitWhenCleared, dataDescriptor, editOperation = "update", errorMessage, labels, onCommit, table, values, variant })=>{
29
- const dataVariant = variant && "toggle" !== variant ? variant : void 0;
30
- const temporalInfo = getTemporalInfo(dataDescriptor);
31
- if (!isDataValueEditable(dataDescriptor, editOperation, true)) return /*#__PURE__*/ jsx(VuuInput, {
32
- variant: "secondary",
33
- ...InputProps,
34
- onCommit: onCommit,
35
- readOnly: true,
36
- "data-edit-control": true
37
- });
38
- if (temporalInfo?.kind === "time") {
39
- const { value, onChange } = InputProps?.inputProps ?? {};
40
- const baseValue = toEpochTimestamp(value, temporalInfo);
41
- const handleCommitTime = (evt, timeString)=>{
42
- if (baseValue) {
43
- const timestamp = parseTemporalInput(timeString, temporalInfo, baseValue);
44
- onCommit(evt, timestamp ? `${timestamp.toWire(temporalInfo.encoding)}` : "");
45
- } else onCommit(evt, timeString);
46
- };
47
- return isTimeDataValueWithMilliseconds(dataDescriptor) ? /*#__PURE__*/ jsx(VuuTimePicker, {
48
- className: className,
49
- milliseconds: true,
50
- value: "" === value ? "" : toTimeString(value, baseValue, temporalInfo, true),
51
- onChange: onChange,
52
- onCommit: handleCommitTime,
53
- "data-edit-control": true
54
- }) : /*#__PURE__*/ jsx(VuuTimePicker, {
55
- className: className,
56
- value: "" === value ? "" : toTimeString(value, baseValue, temporalInfo),
57
- onChange: onChange,
58
- onCommit: handleCommitTime,
59
- "data-edit-control": true
60
- });
61
- }
62
- if (temporalInfo) {
63
- const baseValue = toEpochTimestamp(InputProps?.inputProps?.value, temporalInfo);
64
- const handleCommitDate = (evt, startOfDayMillis)=>{
65
- let timestamp = EpochTimestamp.fromMillis(startOfDayMillis);
66
- if (baseValue && "datetime" === temporalInfo.kind) {
67
- const { year, month, day } = timestamp.getFields(temporalInfo.timeZone);
68
- const { hour, minute, second, millisecond } = baseValue.getFields(temporalInfo.timeZone);
69
- timestamp = EpochTimestamp.fromFields({
70
- year,
71
- month,
72
- day,
73
- hour,
74
- minute,
75
- second,
76
- millisecond
77
- }, temporalInfo.timeZone, baseValue.subMilliNanos);
78
- }
79
- onCommit(evt, `${timestamp.toWire(temporalInfo.encoding)}`);
80
- };
81
- return /*#__PURE__*/ jsx(VuuDatePicker, {
82
- className: className,
83
- onCommit: handleCommitDate,
84
- timeZone: temporalInfo.timeZone,
85
- value: baseValue,
86
- "data-edit-control": true
87
- });
88
- }
89
- if ("toggle" === variant && ("boolean" === dataDescriptor.serverDataType || "char" === dataDescriptor.serverDataType && values?.length)) return /*#__PURE__*/ jsx(ToggleFilter, {
90
- className: className,
91
- column: dataDescriptor.name,
92
- "data-edit-control": true,
93
- disableTypeahead: true,
94
- labels: labels,
95
- onCommit: onCommit,
96
- table: table,
97
- values: values?.length ? values : BOOLEAN_TOGGLE_VALUES,
98
- value: InputProps?.inputProps?.value ?? "all"
99
- });
100
- if ("string" === dataDescriptor.serverDataType && table) if ("toggle" === variant && values?.length) return /*#__PURE__*/ jsx(ToggleFilter, {
101
- className: className,
102
- column: dataDescriptor.name,
103
- "data-edit-control": true,
104
- labels: labels,
105
- onCommit: onCommit,
106
- table: table,
107
- values: values,
108
- value: InputProps?.inputProps?.value ?? "all"
109
- });
110
- else return /*#__PURE__*/ jsx(VuuTypeaheadInput, {
111
- ...InputProps,
112
- ...TypeaheadProps,
113
- className: className,
114
- column: dataDescriptor.name,
115
- "data-edit-control": true,
116
- "data-variant": dataVariant,
117
- onCommit: onCommit,
118
- table: table
119
- });
120
- return /*#__PURE__*/ jsx(VuuInput, {
121
- variant: "secondary",
122
- ...InputProps,
123
- className: className,
124
- commitOnBlur: commitOnBlur,
125
- commitWhenCleared: commitWhenCleared,
126
- onCommit: onCommit,
127
- errorMessage: errorMessage,
128
- "data-edit-control": true
129
- });
130
- };
131
- export { getDataItemEditControl };
@@ -1,50 +0,0 @@
1
- import { useDataSource } from "@vuu-ui/vuu-utils";
2
- import { useCallback } from "react";
3
- const getTypeaheadParams = (table, column, text = "", selectedValues = [])=>{
4
- if ("" !== text && !selectedValues.includes(text.toLowerCase())) return [
5
- table,
6
- column,
7
- text
8
- ];
9
- return [
10
- table,
11
- column
12
- ];
13
- };
14
- const useTypeaheadSuggestions = ()=>{
15
- const dataSource = useDataSource(false);
16
- return useCallback(async ([{ module, table }, column, starts])=>{
17
- if (void 0 === dataSource) {
18
- console.warn("[useTypeaheadSuggestions] no dataSource provided (use DataSourceProvider)");
19
- return false;
20
- }
21
- const rpcMessage = void 0 === starts ? {
22
- params: {
23
- column,
24
- module,
25
- table
26
- },
27
- rpcName: "getUniqueFieldValues",
28
- type: "RPC_REQUEST"
29
- } : {
30
- params: {
31
- column,
32
- module,
33
- starts,
34
- table
35
- },
36
- rpcName: "getUniqueFieldValuesStartingWith",
37
- type: "RPC_REQUEST"
38
- };
39
- try {
40
- const response = await dataSource.rpcRequest?.(rpcMessage);
41
- if (response?.type === "SUCCESS_RESULT") return response.data;
42
- return false;
43
- } catch (err) {
44
- return false;
45
- }
46
- }, [
47
- dataSource
48
- ]);
49
- };
50
- export { getTypeaheadParams, useTypeaheadSuggestions };