@vuu-ui/vuu-data-react 4.0.0-alpha.20 → 4.0.0-alpha.21

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.20",
2
+ "version": "4.0.0-alpha.21",
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.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"
14
+ "@vuu-ui/vuu-data-types": "4.0.0-alpha.21",
15
+ "@vuu-ui/vuu-filter-types": "4.0.0-alpha.21",
16
+ "@vuu-ui/vuu-protocol-types": "4.0.0-alpha.21",
17
+ "@vuu-ui/vuu-table-types": "4.0.0-alpha.21"
18
18
  },
19
19
  "dependencies": {
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
- "@salt-ds/core": "1.67.0",
30
- "@salt-ds/styles": "0.2.1",
31
- "@salt-ds/window": "0.1.1",
32
- "@vuu-ui/core": "4.0.0-alpha.20"
20
+ "@vuu-ui/vuu-context-menu": "4.0.0-alpha.21",
21
+ "@vuu-ui/vuu-data-remote": "4.0.0-alpha.21",
22
+ "@vuu-ui/vuu-filter-parser": "4.0.0-alpha.21",
23
+ "@vuu-ui/vuu-filters": "4.0.0-alpha.21",
24
+ "@vuu-ui/vuu-layout": "4.0.0-alpha.21",
25
+ "@vuu-ui/vuu-notifications": "4.0.0-alpha.21",
26
+ "@vuu-ui/vuu-ui-controls": "4.0.0-alpha.21",
27
+ "@vuu-ui/vuu-utils": "4.0.0-alpha.21",
28
+ "@vuu-ui/vuu-table": "4.0.0-alpha.21",
29
+ "@salt-ds/core": "1.72.0",
30
+ "@salt-ds/styles": "0.4.1",
31
+ "@salt-ds/window": "0.1.2",
32
+ "@vuu-ui/core": "4.0.0-alpha.21"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "clsx": "^2.0.0",
@@ -21,6 +21,10 @@ function toTimeString(value, timestamp, { timeZone }, milliseconds = false) {
21
21
  if (isValidTimeString(timeString)) return timeString;
22
22
  }
23
23
  }
24
+ const BOOLEAN_TOGGLE_VALUES = [
25
+ true,
26
+ false
27
+ ];
24
28
  const getDataItemEditControl = ({ InputProps, TypeaheadProps, className, commitOnBlur, commitWhenCleared, dataDescriptor, editOperation = "update", errorMessage, labels, onCommit, table, values, variant })=>{
25
29
  const dataVariant = variant && "toggle" !== variant ? variant : void 0;
26
30
  const temporalInfo = getTemporalInfo(dataDescriptor);
@@ -82,6 +86,16 @@ const getDataItemEditControl = ({ InputProps, TypeaheadProps, className, commitO
82
86
  "data-edit-control": true
83
87
  });
84
88
  }
89
+ if ("toggle" === variant && "boolean" === dataDescriptor.serverDataType) return /*#__PURE__*/ jsx(ToggleFilter, {
90
+ className: className,
91
+ column: dataDescriptor.name,
92
+ "data-edit-control": true,
93
+ labels: labels,
94
+ onCommit: onCommit,
95
+ table: table,
96
+ values: values?.length ? values : BOOLEAN_TOGGLE_VALUES,
97
+ value: InputProps?.inputProps?.value ?? "all"
98
+ });
85
99
  if ("string" === dataDescriptor.serverDataType && table) if ("toggle" === variant && values?.length) return /*#__PURE__*/ jsx(ToggleFilter, {
86
100
  className: className,
87
101
  column: dataDescriptor.name,
@@ -1,4 +1,5 @@
1
- import { VuuDataSource } from "@vuu-ui/vuu-data-remote";
1
+ import { useData, useOptionalVuuConnectionId } from "@vuu-ui/core";
2
+ import { DEFAULT_CONNECTION_ID } from "@vuu-ui/vuu-data-remote";
2
3
  import { Range, buildColumnMap, getSelectedOption, isLookupRenderer, isTypeDescriptor, isValueListRenderer, useShellContext } from "@vuu-ui/vuu-utils";
3
4
  import { useMemo, useState } from "react";
4
5
  const NO_VALUES = [];
@@ -7,8 +8,8 @@ const toListOption = (value)=>({
7
8
  value
8
9
  });
9
10
  const lookupValueMap = new Map();
10
- const loadLookupValues = ({ labelColumn, table, valueColumn })=>{
11
- const tableKey = `${table.module}:${table.table}`;
11
+ const loadLookupValues = (connectionId, VuuDataSource, { labelColumn, table, valueColumn })=>{
12
+ const tableKey = `${connectionId}:${table.module}:${table.table}`;
12
13
  const lookupValues = lookupValueMap.get(tableKey);
13
14
  if (lookupValues) return lookupValues;
14
15
  {
@@ -49,6 +50,8 @@ const getLookupDetails = ({ name, type })=>{
49
50
  const useLookupValues = (column, initialValueProp)=>{
50
51
  const { type: columnType } = column;
51
52
  const { getLookupValues } = useShellContext();
53
+ const { VuuDataSource } = useData();
54
+ const connectionId = useOptionalVuuConnectionId() ?? DEFAULT_CONNECTION_ID;
52
55
  const initialState = useMemo(()=>{
53
56
  if (isTypeDescriptor(columnType) && isValueListRenderer(columnType?.renderer)) {
54
57
  const values = columnType.renderer.values.map(toListOption);
@@ -75,7 +78,7 @@ const useLookupValues = (column, initialValueProp)=>{
75
78
  useMemo(()=>{
76
79
  if (values === NO_VALUES) {
77
80
  const lookupDetails = getLookupDetails(column);
78
- loadLookupValues(lookupDetails).then((values)=>setLookupState({
81
+ loadLookupValues(connectionId, VuuDataSource, lookupDetails).then((values)=>setLookupState({
79
82
  initialValue: getSelectedOption(values, initialValueProp) ?? null,
80
83
  values
81
84
  }));
@@ -83,7 +86,9 @@ const useLookupValues = (column, initialValueProp)=>{
83
86
  }, [
84
87
  values,
85
88
  column,
86
- initialValueProp
89
+ initialValueProp,
90
+ connectionId,
91
+ VuuDataSource
87
92
  ]);
88
93
  return {
89
94
  initialValue,
@@ -1,11 +1,13 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { ConnectionManager, isConnected } from "@vuu-ui/vuu-data-remote";
3
- import { useCallback, useMemo, useRef } from "react";
2
+ import { useOptionalVuuConnectionId } from "@vuu-ui/core";
3
+ import { ConnectionManager, DEFAULT_CONNECTION_ID, isConnected } from "@vuu-ui/vuu-data-remote";
4
+ import { useCallback, useEffect, useRef } from "react";
4
5
  import { NotificationType, useNotifications } from "@vuu-ui/vuu-notifications";
5
6
  import { LostConnectionIndicator } from "./LostConnectionIndicator.js";
6
7
  const useLostConnection = ()=>{
7
8
  const { hideNotification, showNotification } = useNotifications();
8
- const isConnectedRef = useRef(ConnectionManager.connected);
9
+ const connectionId = useOptionalVuuConnectionId() ?? DEFAULT_CONNECTION_ID;
10
+ const isConnectedRef = useRef(ConnectionManager.connectedFor(connectionId));
9
11
  const handleConnectionStatusChange = useCallback((connectionStatus)=>{
10
12
  const { current: wasConnected } = isConnectedRef;
11
13
  isConnectedRef.current = isConnected(connectionStatus);
@@ -19,9 +21,8 @@ const useLostConnection = ()=>{
19
21
  hideNotification,
20
22
  showNotification
21
23
  ]);
22
- useMemo(async ()=>{
23
- ConnectionManager.on("connection-status", handleConnectionStatusChange);
24
- }, [
24
+ useEffect(()=>ConnectionManager.onConnectionStatus(connectionId, handleConnectionStatusChange), [
25
+ connectionId,
25
26
  handleConnectionStatusChange
26
27
  ]);
27
28
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { VuuDataSource } from "@vuu-ui/vuu-data-remote";
2
+ import { useData } from "@vuu-ui/core";
3
3
  import { Range, buildColumnMap, getTypedValue, queryClosest, shallowEquals } from "@vuu-ui/vuu-utils";
4
4
  import { Button, FormField, FormFieldHelperText, FormFieldLabel, Input, useIdMemo } from "@salt-ds/core";
5
5
  import { useComponentCssInjection } from "@salt-ds/styles";
@@ -31,7 +31,7 @@ const Status = {
31
31
  changed: 2,
32
32
  invalid: 3
33
33
  };
34
- const getDataSource = (dataSource, schema)=>{
34
+ const getDataSource = (VuuDataSource, dataSource, schema)=>{
35
35
  if (dataSource) return dataSource;
36
36
  if (schema) return new VuuDataSource({
37
37
  bufferSize: 0,
@@ -53,8 +53,9 @@ const SessionEditingForm_SessionEditingForm = ({ className, config: { fields, ke
53
53
  const formContentRef = useRef(null);
54
54
  const initialDataRef = useRef(void 0);
55
55
  const dataStatusRef = useRef(Status.uninitialised);
56
+ const { VuuDataSource } = useData();
56
57
  const dataSource = useMemo(()=>{
57
- const ds = getDataSource(dataSourceProp, schema);
58
+ const ds = getDataSource(VuuDataSource, dataSourceProp, schema);
58
59
  const { columns } = ds;
59
60
  const columnMap = buildColumnMap(ds.columns);
60
61
  const applyServerData = (data)=>{
@@ -76,6 +77,7 @@ const SessionEditingForm_SessionEditingForm = ({ className, config: { fields, ke
76
77
  });
77
78
  return ds;
78
79
  }, [
80
+ VuuDataSource,
79
81
  dataSourceProp,
80
82
  schema
81
83
  ]);
@@ -2,4 +2,4 @@ import type { HTMLAttributes } from "react";
2
2
  import { type EditFormHookProps } from "./useEditForm";
3
3
  export interface EditFormProps extends EditFormHookProps, Omit<HTMLAttributes<HTMLDivElement>, "onSubmit"> {
4
4
  }
5
- export declare const EditForm: ({ className, dataSource, formFieldDescriptors, onSubmit: onSubmitProp, ...htmlAttributes }: EditFormProps) => import("react").JSX.Element;
5
+ export declare const EditForm: ({ className, dataSource, formFieldDescriptors, onSubmit: onSubmitProp, ...htmlAttributes }: EditFormProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,4 +3,4 @@ export interface UnsavedChangesReportProps<T extends Entity = Entity> {
3
3
  entity: T;
4
4
  editedEntity: T;
5
5
  }
6
- export declare const UnsavedChangesReport: ({ entity, editedEntity, }: UnsavedChangesReportProps) => import("react").JSX.Element;
6
+ export declare const UnsavedChangesReport: ({ entity, editedEntity, }: UnsavedChangesReportProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,6 +2,7 @@ import type { DataValueDescriptor, TableSchemaTable } from "@vuu-ui/vuu-data-typ
2
2
  import { type VuuTypeaheadInputProps } from "@vuu-ui/vuu-ui-controls";
3
3
  import { type CommitHandler } from "@vuu-ui/vuu-utils";
4
4
  import type { InputProps } from "@salt-ds/core";
5
+ import { type ToggleFilterValue } from "@vuu-ui/vuu-filters";
5
6
  /**
6
7
  * variant can be used to provide a rendering hint to the filter control rendered.
7
8
  * 'toggle' for A ToggleButtonGroup, only suitable for up to 3 value choices
@@ -33,10 +34,11 @@ export interface DataItemEditControlProps {
33
34
  * They will be validated against server with Typeahead service, so
34
35
  * unavailable options are not offered.
35
36
  * Recommended for toggle filters, not usually necessary for other
36
- * filter variants.
37
+ * filter variants. Boolean values are supported for toggle filters on
38
+ * boolean columns, where values default to [true, false].
37
39
  */
38
- values?: string[];
40
+ values?: ToggleFilterValue[];
39
41
  variant?: FilterControlVariant;
40
42
  }
41
43
  export type ValidationStatus = "initial" | true | string;
42
- export declare const getDataItemEditControl: ({ InputProps, TypeaheadProps, className, commitOnBlur, commitWhenCleared, dataDescriptor, editOperation, errorMessage, labels, onCommit, table, values, variant, }: DataItemEditControlProps) => import("react").JSX.Element;
44
+ export declare const getDataItemEditControl: ({ InputProps, TypeaheadProps, className, commitOnBlur, commitWhenCleared, dataDescriptor, editOperation, errorMessage, labels, onCommit, table, values, variant, }: DataItemEditControlProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import type { DataSource, DataValueDescriptor } from "@vuu-ui/vuu-data-types";
2
2
  import { type CommitHandler, type Entity } from "@vuu-ui/vuu-utils";
3
- import { type ChangeEventHandler, type FocusEventHandler } from "react";
3
+ import { type FormEventHandler, type FocusEventHandler } from "react";
4
4
  export interface EditFormHookProps {
5
5
  dataSource?: DataSource;
6
6
  formFieldDescriptors: DataValueDescriptor[];
@@ -14,7 +14,7 @@ export declare const useEditForm: ({ dataSource, formFieldDescriptors, onSubmit,
14
14
  isClean: boolean;
15
15
  ok: boolean;
16
16
  onCancel: () => Promise<void>;
17
- onChange: ChangeEventHandler<HTMLElement>;
17
+ onChange: FormEventHandler<HTMLElement>;
18
18
  onCommit: CommitHandler<HTMLElement>;
19
19
  onFocus: FocusEventHandler;
20
20
  onSubmit: () => Promise<void>;
@@ -5,4 +5,4 @@ import { type ReactNode } from "react";
5
5
  */
6
6
  export declare const VuuDataSourceProvider: ({ children, }: {
7
7
  children: ReactNode;
8
- }) => import("react").JSX.Element;
8
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- export declare const LostConnectionIndicator: () => import("react").JSX.Element;
1
+ export declare const LostConnectionIndicator: () => import("react/jsx-runtime").JSX.Element;
@@ -21,4 +21,4 @@ export interface SessionEditingFormProps extends HTMLAttributes<HTMLDivElement>
21
21
  dataSource?: DataSource;
22
22
  schema?: TableSchema;
23
23
  }
24
- export declare const SessionEditingForm: ({ className, config: { fields, key: keyField }, dataSource: dataSourceProp, id: idProp, onClose, schema, ...htmlAttributes }: SessionEditingFormProps) => import("react").JSX.Element;
24
+ export declare const SessionEditingForm: ({ className, config: { fields, key: keyField }, dataSource: dataSourceProp, id: idProp, onClose, schema, ...htmlAttributes }: SessionEditingFormProps) => import("react/jsx-runtime").JSX.Element;