@vuu-ui/vuu-data-react 4.0.0-alpha.2 → 4.0.0-alpha.20
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.0.0-alpha.
|
|
2
|
+
"version": "4.0.0-alpha.20",
|
|
3
3
|
"main": "./src/index.js",
|
|
4
4
|
"author": "heswell",
|
|
5
5
|
"type": "module",
|
|
@@ -11,25 +11,25 @@
|
|
|
11
11
|
"type-defs": "node ../../scripts/build-type-defs.mjs"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@vuu-ui/vuu-data-types": "4.0.0-alpha.
|
|
15
|
-
"@vuu-ui/vuu-filter-types": "4.0.0-alpha.
|
|
16
|
-
"@vuu-ui/vuu-protocol-types": "4.0.0-alpha.
|
|
17
|
-
"@vuu-ui/vuu-table-types": "4.0.0-alpha.
|
|
14
|
+
"@vuu-ui/vuu-data-types": "4.0.0-alpha.20",
|
|
15
|
+
"@vuu-ui/vuu-filter-types": "4.0.0-alpha.20",
|
|
16
|
+
"@vuu-ui/vuu-protocol-types": "4.0.0-alpha.20",
|
|
17
|
+
"@vuu-ui/vuu-table-types": "4.0.0-alpha.20"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@vuu-ui/vuu-context-menu": "4.0.0-alpha.
|
|
21
|
-
"@vuu-ui/vuu-data-remote": "4.0.0-alpha.
|
|
22
|
-
"@vuu-ui/vuu-filter-parser": "4.0.0-alpha.
|
|
23
|
-
"@vuu-ui/vuu-filters": "4.0.0-alpha.
|
|
24
|
-
"@vuu-ui/vuu-layout": "4.0.0-alpha.
|
|
25
|
-
"@vuu-ui/vuu-notifications": "4.0.0-alpha.
|
|
26
|
-
"@vuu-ui/vuu-ui-controls": "4.0.0-alpha.
|
|
27
|
-
"@vuu-ui/vuu-utils": "4.0.0-alpha.
|
|
28
|
-
"@vuu-ui/vuu-table": "4.0.0-alpha.
|
|
20
|
+
"@vuu-ui/vuu-context-menu": "4.0.0-alpha.20",
|
|
21
|
+
"@vuu-ui/vuu-data-remote": "4.0.0-alpha.20",
|
|
22
|
+
"@vuu-ui/vuu-filter-parser": "4.0.0-alpha.20",
|
|
23
|
+
"@vuu-ui/vuu-filters": "4.0.0-alpha.20",
|
|
24
|
+
"@vuu-ui/vuu-layout": "4.0.0-alpha.20",
|
|
25
|
+
"@vuu-ui/vuu-notifications": "4.0.0-alpha.20",
|
|
26
|
+
"@vuu-ui/vuu-ui-controls": "4.0.0-alpha.20",
|
|
27
|
+
"@vuu-ui/vuu-utils": "4.0.0-alpha.20",
|
|
28
|
+
"@vuu-ui/vuu-table": "4.0.0-alpha.20",
|
|
29
29
|
"@salt-ds/core": "1.67.0",
|
|
30
30
|
"@salt-ds/styles": "0.2.1",
|
|
31
31
|
"@salt-ds/window": "0.1.1",
|
|
32
|
-
"@vuu-ui/core": "4.0.0-alpha.
|
|
32
|
+
"@vuu-ui/core": "4.0.0-alpha.20"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"clsx": "^2.0.0",
|
|
@@ -43,8 +43,9 @@
|
|
|
43
43
|
],
|
|
44
44
|
"exports": {
|
|
45
45
|
".": {
|
|
46
|
+
"types": "./types/index.d.ts",
|
|
46
47
|
"import": "./src/index.js",
|
|
47
|
-
"
|
|
48
|
+
"default": "./src/index.js"
|
|
48
49
|
}
|
|
49
50
|
},
|
|
50
51
|
"module": "./src/index.js",
|
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { VuuDatePicker, VuuInput, VuuTimePicker, VuuTypeaheadInput } from "@vuu-ui/vuu-ui-controls";
|
|
3
|
-
import {
|
|
3
|
+
import { EpochTimestamp, getTemporalInfo, isDataValueEditable, isTimeDataValueWithMilliseconds, isValidTimeString, isValidTimeStringMillis, parseTemporalInput } from "@vuu-ui/vuu-utils";
|
|
4
4
|
import { ToggleFilter } from "@vuu-ui/vuu-filters";
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 getDataItemEditControl = ({ InputProps, TypeaheadProps, className, commitOnBlur, commitWhenCleared, dataDescriptor, editOperation = "update", errorMessage, labels, onCommit, table, values, variant })=>{
|
|
9
25
|
const dataVariant = variant && "toggle" !== variant ? variant : void 0;
|
|
26
|
+
const temporalInfo = getTemporalInfo(dataDescriptor);
|
|
10
27
|
if (!isDataValueEditable(dataDescriptor, editOperation, true)) return /*#__PURE__*/ jsx(VuuInput, {
|
|
11
28
|
variant: "secondary",
|
|
12
29
|
...InputProps,
|
|
@@ -14,26 +31,62 @@ const getDataItemEditControl = ({ InputProps, TypeaheadProps, className, commitO
|
|
|
14
31
|
readOnly: true,
|
|
15
32
|
"data-edit-control": true
|
|
16
33
|
});
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
if (temporalInfo?.kind === "time") {
|
|
35
|
+
const { value, onChange } = InputProps?.inputProps ?? {};
|
|
36
|
+
const baseValue = toEpochTimestamp(value, temporalInfo);
|
|
37
|
+
const handleCommitTime = (evt, timeString)=>{
|
|
38
|
+
if (baseValue) {
|
|
39
|
+
const timestamp = parseTemporalInput(timeString, temporalInfo, baseValue);
|
|
40
|
+
onCommit(evt, timestamp ? `${timestamp.toWire(temporalInfo.encoding)}` : "");
|
|
41
|
+
} else onCommit(evt, timeString);
|
|
42
|
+
};
|
|
43
|
+
return isTimeDataValueWithMilliseconds(dataDescriptor) ? /*#__PURE__*/ jsx(VuuTimePicker, {
|
|
44
|
+
className: className,
|
|
45
|
+
milliseconds: true,
|
|
46
|
+
value: "" === value ? "" : toTimeString(value, baseValue, temporalInfo, true),
|
|
47
|
+
onChange: onChange,
|
|
48
|
+
onCommit: handleCommitTime,
|
|
49
|
+
"data-edit-control": true
|
|
50
|
+
}) : /*#__PURE__*/ jsx(VuuTimePicker, {
|
|
51
|
+
className: className,
|
|
52
|
+
value: "" === value ? "" : toTimeString(value, baseValue, temporalInfo),
|
|
53
|
+
onChange: onChange,
|
|
54
|
+
onCommit: handleCommitTime,
|
|
55
|
+
"data-edit-control": true
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (temporalInfo) {
|
|
59
|
+
const baseValue = toEpochTimestamp(InputProps?.inputProps?.value, temporalInfo);
|
|
60
|
+
const handleCommitDate = (evt, startOfDayMillis)=>{
|
|
61
|
+
let timestamp = EpochTimestamp.fromMillis(startOfDayMillis);
|
|
62
|
+
if (baseValue && "datetime" === temporalInfo.kind) {
|
|
63
|
+
const { year, month, day } = timestamp.getFields(temporalInfo.timeZone);
|
|
64
|
+
const { hour, minute, second, millisecond } = baseValue.getFields(temporalInfo.timeZone);
|
|
65
|
+
timestamp = EpochTimestamp.fromFields({
|
|
66
|
+
year,
|
|
67
|
+
month,
|
|
68
|
+
day,
|
|
69
|
+
hour,
|
|
70
|
+
minute,
|
|
71
|
+
second,
|
|
72
|
+
millisecond
|
|
73
|
+
}, temporalInfo.timeZone, baseValue.subMilliNanos);
|
|
74
|
+
}
|
|
75
|
+
onCommit(evt, `${timestamp.toWire(temporalInfo.encoding)}`);
|
|
76
|
+
};
|
|
77
|
+
return /*#__PURE__*/ jsx(VuuDatePicker, {
|
|
78
|
+
className: className,
|
|
79
|
+
onCommit: handleCommitDate,
|
|
80
|
+
timeZone: temporalInfo.timeZone,
|
|
81
|
+
value: baseValue,
|
|
82
|
+
"data-edit-control": true
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if ("string" === dataDescriptor.serverDataType && table) if ("toggle" === variant && values?.length) return /*#__PURE__*/ jsx(ToggleFilter, {
|
|
34
86
|
className: className,
|
|
35
87
|
column: dataDescriptor.name,
|
|
36
88
|
"data-edit-control": true,
|
|
89
|
+
labels: labels,
|
|
37
90
|
onCommit: onCommit,
|
|
38
91
|
table: table,
|
|
39
92
|
values: values,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useModal } from "@vuu-ui/core";
|
|
2
3
|
import { Range, buildColumnMap, dataSourceRowToEntity, messageHasDataRows, queryClosest } from "@vuu-ui/vuu-utils";
|
|
3
4
|
import { Button } from "@salt-ds/core";
|
|
4
5
|
import { useCallback, useMemo, useRef, useState } from "react";
|
|
5
6
|
import { UnsavedChangesReport } from "./UnsavedChangesReport.js";
|
|
6
7
|
import { buildValidationChecker, getEditValidationRules } from "./edit-rule-validation-checker.js";
|
|
7
8
|
import { CLEAN_FORM, buildFormEditState } from "./form-edit-state.js";
|
|
8
|
-
import { useModal } from "@vuu-ui/vuu-ui-controls";
|
|
9
9
|
const CLEAN_VALIDATION = {
|
|
10
10
|
ok: true,
|
|
11
11
|
messages: {}
|
|
@@ -5,9 +5,9 @@ import { getFilterPredicate } from "@vuu-ui/vuu-filter-parser";
|
|
|
5
5
|
import { NotificationType, useNotifications } from "@vuu-ui/vuu-notifications";
|
|
6
6
|
import { BulkEditPanel, isTableLocation } from "@vuu-ui/vuu-table";
|
|
7
7
|
import { getLayoutComponent, isActionMessage, isCustomComponentActionMessage, isSessionTableActionMessage, useData } from "@vuu-ui/vuu-utils";
|
|
8
|
+
import { useModal } from "@vuu-ui/core";
|
|
8
9
|
import { useCallback } from "react";
|
|
9
10
|
import { SessionEditingForm } from "../session-editing-form/index.js";
|
|
10
|
-
import { useModal } from "@vuu-ui/vuu-ui-controls";
|
|
11
11
|
const isRoot = (menu)=>"ROOT" === menu.name;
|
|
12
12
|
const isCellMenu = (options)=>"cell" === options.context;
|
|
13
13
|
const isRowMenu = (options)=>"row" === options.context;
|
|
@@ -21,6 +21,11 @@ export interface DataItemEditControlProps {
|
|
|
21
21
|
dataDescriptor: DataValueDescriptor;
|
|
22
22
|
editOperation?: "insert" | "update";
|
|
23
23
|
errorMessage?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional labels, only used with 'toggle' variant. If provided, must
|
|
26
|
+
* have same number of items as values. Defaults to values.
|
|
27
|
+
*/
|
|
28
|
+
labels?: string[];
|
|
24
29
|
onCommit: CommitHandler<HTMLElement>;
|
|
25
30
|
table?: TableSchemaTable;
|
|
26
31
|
/**
|
|
@@ -34,4 +39,4 @@ export interface DataItemEditControlProps {
|
|
|
34
39
|
variant?: FilterControlVariant;
|
|
35
40
|
}
|
|
36
41
|
export type ValidationStatus = "initial" | true | string;
|
|
37
|
-
export declare const getDataItemEditControl: ({ InputProps, TypeaheadProps, className, commitOnBlur, commitWhenCleared, dataDescriptor, editOperation, errorMessage, onCommit, table, values, variant, }: DataItemEditControlProps) => import("react").JSX.Element;
|
|
42
|
+
export declare const getDataItemEditControl: ({ InputProps, TypeaheadProps, className, commitOnBlur, commitWhenCleared, dataDescriptor, editOperation, errorMessage, labels, onCommit, table, values, variant, }: DataItemEditControlProps) => import("react").JSX.Element;
|