@vuu-ui/vuu-data-react 0.13.60 → 0.13.61

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.
@@ -1,71 +1,63 @@
1
1
  'use strict';
2
2
 
3
- var vuuLayout = require('@vuu-ui/vuu-layout');
4
3
  var vuuUtils = require('@vuu-ui/vuu-utils');
5
4
  var react = require('react');
6
5
 
7
- const NO_CONFIG = {};
8
- const useSessionDataSource = ({
9
- dataSourceSessionKey = "data-source",
10
- tableSchema
11
- }) => {
12
- const { id, load, save, loadSession, saveSession, title } = vuuLayout.useViewContext();
6
+ const sessionState = /* @__PURE__ */ new Map();
7
+ const useSessionDataSource = (props) => {
13
8
  const { VuuDataSource } = vuuUtils.useData();
14
- const { "datasource-config": dataSourceConfigFromState } = react.useMemo(() => load?.() ?? NO_CONFIG, [load]);
15
- const dataSourceConfigRef = react.useRef(
16
- dataSourceConfigFromState
17
- );
18
- const handleDataSourceConfigChange = react.useCallback(
19
- (config, _range, confirmed) => {
20
- if (confirmed !== false) {
21
- const { noChanges } = vuuUtils.isConfigChanged(
22
- dataSourceConfigRef.current,
23
- config
24
- );
25
- if (noChanges === false) {
26
- dataSourceConfigRef.current = config;
27
- save?.(config, "datasource-config");
9
+ const dataSourceConfigRef = react.useRef(void 0);
10
+ const getDataSource = react.useCallback(
11
+ (sessionKey, config) => {
12
+ let ds = sessionState.get(sessionKey);
13
+ if (ds) {
14
+ if (config) {
15
+ ds.applyConfig(config, true);
16
+ }
17
+ if (ds.range.from > 0) {
18
+ ds.range = ds.range.reset;
28
19
  }
20
+ return ds;
21
+ }
22
+ if (config?.columns) {
23
+ ds = new VuuDataSource({
24
+ ...config,
25
+ viewport: sessionKey,
26
+ ...dataSourceConfigRef.current
27
+ });
28
+ if (props?.onConfigChange) {
29
+ ds.on("config", props.onConfigChange);
30
+ }
31
+ sessionState.set(sessionKey, ds);
32
+ return ds;
33
+ } else {
34
+ throw Error(
35
+ `[useSessionDataSource] unable to create new DataSource, columns have not been defined `
36
+ );
29
37
  }
30
38
  },
31
- [save]
39
+ [VuuDataSource, props?.onConfigChange]
32
40
  );
33
- const dataSource = react.useMemo(() => {
34
- let ds = loadSession?.(dataSourceSessionKey);
35
- if (ds) {
36
- if (dataSourceConfigFromState) {
37
- ds.applyConfig(dataSourceConfigFromState, true);
38
- }
39
- if (ds.range.from > 0) {
40
- ds.range = ds.range.reset;
41
+ const clearDataSource = react.useCallback(
42
+ (sessionKey, unsubscribe) => {
43
+ const ds = sessionState.get(sessionKey);
44
+ if (ds) {
45
+ sessionState.delete(sessionKey);
46
+ if (unsubscribe === true) {
47
+ ds.unsubscribe();
48
+ }
49
+ } else {
50
+ console.warn(
51
+ `[useSessionbDatasource] clearDataSource ${sessionKey} not found `
52
+ );
41
53
  }
42
- return ds;
43
- }
44
- const columns = dataSourceConfigFromState?.columns ?? tableSchema.columns.map((col) => col.name);
45
- ds = new VuuDataSource({
46
- // bufferSize: 0,
47
- viewport: id,
48
- table: tableSchema.table,
49
- ...dataSourceConfigRef.current,
50
- columns,
51
- title
52
- });
53
- ds.on("config", handleDataSourceConfigChange);
54
- saveSession?.(ds, "data-source");
55
- return ds;
56
- }, [
57
- VuuDataSource,
58
- dataSourceConfigFromState,
59
- dataSourceSessionKey,
60
- handleDataSourceConfigChange,
61
- id,
62
- loadSession,
63
- saveSession,
64
- tableSchema.columns,
65
- tableSchema.table,
66
- title
67
- ]);
68
- return dataSource;
54
+ },
55
+ []
56
+ );
57
+ return {
58
+ clearDataSource,
59
+ getDataSource
60
+ };
69
61
  };
70
62
 
71
63
  exports.useSessionDataSource = useSessionDataSource;
@@ -1 +1 @@
1
- {"version":3,"file":"useSessionDataSource.js","sources":["../../../../packages/vuu-data-react/src/hooks/useSessionDataSource.ts"],"sourcesContent":["import type {\n DataSource,\n DataSourceConfig,\n DataSourceConfigChangeHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport type { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { isConfigChanged, useData } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\ntype SessionState = {\n \"datasource-config\"?: DataSourceConfig;\n};\n\nconst NO_CONFIG: SessionState = {};\n\nexport const useSessionDataSource = ({\n dataSourceSessionKey = \"data-source\",\n tableSchema,\n}: {\n dataSourceSessionKey?: string;\n tableSchema: TableSchema;\n}) => {\n const { id, load, save, loadSession, saveSession, title } = useViewContext();\n const { VuuDataSource } = useData();\n\n const { \"datasource-config\": dataSourceConfigFromState } =\n useMemo<SessionState>(() => load?.() ?? NO_CONFIG, [load]);\n\n const dataSourceConfigRef = useRef<DataSourceConfig | undefined>(\n dataSourceConfigFromState,\n );\n\n const handleDataSourceConfigChange =\n useCallback<DataSourceConfigChangeHandler>(\n (\n config: DataSourceConfig | undefined,\n _range: VuuRange,\n confirmed?: boolean,\n ) => {\n if (confirmed !== false) {\n const { noChanges } = isConfigChanged(\n dataSourceConfigRef.current,\n config,\n );\n if (noChanges === false) {\n dataSourceConfigRef.current = config;\n save?.(config, \"datasource-config\");\n }\n }\n },\n [save],\n );\n\n const dataSource: DataSource = useMemo(() => {\n let ds = loadSession?.(dataSourceSessionKey) as DataSource;\n if (ds) {\n if (dataSourceConfigFromState) {\n // this won't do anything if dataSource config already matches this\n // This is only really used when injecting a dataSource into session\n // state in Showcase examples\n // DO we definitely need this ? If not apply config can be provate\n ds.applyConfig(dataSourceConfigFromState, true);\n }\n\n if (ds.range.from > 0) {\n // UI does not currently restore scroll position, so always reset to top of dataset\n ds.range = ds.range.reset;\n }\n\n return ds;\n }\n\n const columns =\n dataSourceConfigFromState?.columns ??\n tableSchema.columns.map((col) => col.name);\n\n ds = new VuuDataSource({\n // bufferSize: 0,\n viewport: id,\n table: tableSchema.table,\n ...dataSourceConfigRef.current,\n columns,\n title,\n });\n ds.on(\"config\", handleDataSourceConfigChange);\n saveSession?.(ds, \"data-source\");\n return ds;\n }, [\n VuuDataSource,\n dataSourceConfigFromState,\n dataSourceSessionKey,\n handleDataSourceConfigChange,\n id,\n loadSession,\n saveSession,\n tableSchema.columns,\n tableSchema.table,\n title,\n ]);\n\n return dataSource;\n};\n"],"names":["useViewContext","useData","useMemo","useRef","useCallback","isConfigChanged"],"mappings":";;;;;;AAeA,MAAM,YAA0B,EAAC;AAE1B,MAAM,uBAAuB,CAAC;AAAA,EACnC,oBAAuB,GAAA,aAAA;AAAA,EACvB;AACF,CAGM,KAAA;AACJ,EAAM,MAAA,EAAE,IAAI,IAAM,EAAA,IAAA,EAAM,aAAa,WAAa,EAAA,KAAA,KAAUA,wBAAe,EAAA;AAC3E,EAAM,MAAA,EAAE,aAAc,EAAA,GAAIC,gBAAQ,EAAA;AAElC,EAAM,MAAA,EAAE,mBAAqB,EAAA,yBAAA,EAC3B,GAAAC,aAAA,CAAsB,MAAM,IAAA,IAAY,IAAA,SAAA,EAAW,CAAC,IAAI,CAAC,CAAA;AAE3D,EAAA,MAAM,mBAAsB,GAAAC,YAAA;AAAA,IAC1B;AAAA,GACF;AAEA,EAAA,MAAM,4BACJ,GAAAC,iBAAA;AAAA,IACE,CACE,MACA,EAAA,MAAA,EACA,SACG,KAAA;AACH,MAAA,IAAI,cAAc,KAAO,EAAA;AACvB,QAAM,MAAA,EAAE,WAAc,GAAAC,wBAAA;AAAA,UACpB,mBAAoB,CAAA,OAAA;AAAA,UACpB;AAAA,SACF;AACA,QAAA,IAAI,cAAc,KAAO,EAAA;AACvB,UAAA,mBAAA,CAAoB,OAAU,GAAA,MAAA;AAC9B,UAAA,IAAA,GAAO,QAAQ,mBAAmB,CAAA;AAAA;AACpC;AACF,KACF;AAAA,IACA,CAAC,IAAI;AAAA,GACP;AAEF,EAAM,MAAA,UAAA,GAAyBH,cAAQ,MAAM;AAC3C,IAAI,IAAA,EAAA,GAAK,cAAc,oBAAoB,CAAA;AAC3C,IAAA,IAAI,EAAI,EAAA;AACN,MAAA,IAAI,yBAA2B,EAAA;AAK7B,QAAG,EAAA,CAAA,WAAA,CAAY,2BAA2B,IAAI,CAAA;AAAA;AAGhD,MAAI,IAAA,EAAA,CAAG,KAAM,CAAA,IAAA,GAAO,CAAG,EAAA;AAErB,QAAG,EAAA,CAAA,KAAA,GAAQ,GAAG,KAAM,CAAA,KAAA;AAAA;AAGtB,MAAO,OAAA,EAAA;AAAA;AAGT,IAAM,MAAA,OAAA,GACJ,2BAA2B,OAC3B,IAAA,WAAA,CAAY,QAAQ,GAAI,CAAA,CAAC,GAAQ,KAAA,GAAA,CAAI,IAAI,CAAA;AAE3C,IAAA,EAAA,GAAK,IAAI,aAAc,CAAA;AAAA;AAAA,MAErB,QAAU,EAAA,EAAA;AAAA,MACV,OAAO,WAAY,CAAA,KAAA;AAAA,MACnB,GAAG,mBAAoB,CAAA,OAAA;AAAA,MACvB,OAAA;AAAA,MACA;AAAA,KACD,CAAA;AACD,IAAG,EAAA,CAAA,EAAA,CAAG,UAAU,4BAA4B,CAAA;AAC5C,IAAA,WAAA,GAAc,IAAI,aAAa,CAAA;AAC/B,IAAO,OAAA,EAAA;AAAA,GACN,EAAA;AAAA,IACD,aAAA;AAAA,IACA,yBAAA;AAAA,IACA,oBAAA;AAAA,IACA,4BAAA;AAAA,IACA,EAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAY,CAAA,OAAA;AAAA,IACZ,WAAY,CAAA,KAAA;AAAA,IACZ;AAAA,GACD,CAAA;AAED,EAAO,OAAA,UAAA;AACT;;;;"}
1
+ {"version":3,"file":"useSessionDataSource.js","sources":["../../../../packages/vuu-data-react/src/hooks/useSessionDataSource.ts"],"sourcesContent":["import type {\n DataSource,\n DataSourceConfig,\n DataSourceConfigChangeHandler,\n DataSourceConstructorProps,\n} from \"@vuu-ui/vuu-data-types\";\nimport { useData } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useRef } from \"react\";\n\nconst sessionState = new Map<string, DataSource>();\n\nexport interface SessionStateHookProps {\n onConfigChange?: DataSourceConfigChangeHandler;\n}\n\nexport const useSessionDataSource = (props?: SessionStateHookProps) => {\n const { VuuDataSource } = useData();\n\n const dataSourceConfigRef = useRef<DataSourceConfig | undefined>(undefined);\n\n const getDataSource = useCallback(\n (sessionKey: string, config?: DataSourceConstructorProps) => {\n let ds = sessionState.get(sessionKey);\n if (ds) {\n if (config) {\n // this won't do anything if dataSource config already matches this\n // This is only really used when injecting a dataSource into session\n // state in Showcase examples\n // Do we definitely need this ? If not apply config can be provate\n ds.applyConfig(config, true);\n }\n\n if (ds.range.from > 0) {\n // UI does not currently restore scroll position, so always reset to top of dataset\n ds.range = ds.range.reset;\n }\n return ds;\n }\n\n if (config?.columns) {\n ds = new VuuDataSource({\n ...config,\n viewport: sessionKey,\n ...dataSourceConfigRef.current,\n });\n if (props?.onConfigChange) {\n ds.on(\"config\", props.onConfigChange);\n }\n sessionState.set(sessionKey, ds);\n return ds;\n } else {\n throw Error(\n `[useSessionDataSource] unable to create new DataSource, columns have not been defined `,\n );\n }\n },\n [VuuDataSource, props?.onConfigChange],\n );\n\n const clearDataSource = useCallback(\n (sessionKey: string, unsubscribe?: boolean) => {\n const ds = sessionState.get(sessionKey);\n if (ds) {\n sessionState.delete(sessionKey);\n if (unsubscribe === true) {\n ds.unsubscribe();\n }\n } else {\n console.warn(\n `[useSessionbDatasource] clearDataSource ${sessionKey} not found `,\n );\n }\n },\n [],\n );\n\n return {\n clearDataSource,\n getDataSource,\n };\n};\n"],"names":["useData","useRef","useCallback"],"mappings":";;;;;AASA,MAAM,YAAA,uBAAmB,GAAwB,EAAA;AAMpC,MAAA,oBAAA,GAAuB,CAAC,KAAkC,KAAA;AACrE,EAAM,MAAA,EAAE,aAAc,EAAA,GAAIA,gBAAQ,EAAA;AAElC,EAAM,MAAA,mBAAA,GAAsBC,aAAqC,KAAS,CAAA,CAAA;AAE1E,EAAA,MAAM,aAAgB,GAAAC,iBAAA;AAAA,IACpB,CAAC,YAAoB,MAAwC,KAA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AA,UACN,2CAA2C,UAAU,CAAA,WAAA;AAAA,SACvD;AAAA;AACF,KACF;AAAA,IACA;AAAC,GACH;AAEA,EAAO,OAAA;AAAA,IACL,eAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -54,12 +54,13 @@ const useVisualLinks = (dataSource) => {
54
54
  content: /* @__PURE__ */ jsxRuntime.jsx(
55
55
  vuuUiControls.IconButton,
56
56
  {
57
+ appearance: "transparent",
57
58
  "aria-label": "remove-link",
58
59
  icon: "link",
59
60
  onClick: removeVisualLink,
60
61
  onMouseEnter: highlightVisualLinkTarget,
61
62
  onMouseLeave: clearVisualLinkTarget,
62
- variant: "secondary"
63
+ sentiment: "neutral"
63
64
  }
64
65
  )
65
66
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useVisualLinks.js","sources":["../../../../packages/vuu-data-react/src/hooks/useVisualLinks.tsx"],"sourcesContent":["import { DataSource } from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport { IconButton } from \"@vuu-ui/vuu-ui-controls\";\nimport { useCallback, useEffect } from \"react\";\n\nexport const useVisualLinks = (dataSource: DataSource) => {\n const { dispatch } = useViewContext();\n\n const clearVisualLinkTarget = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-off\",\n },\n });\n }\n }, [dataSource, dispatch]);\n\n const removeVisualLink = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-off\",\n },\n });\n\n dataSource.visualLink = undefined;\n }\n }, [dataSource, dispatch]);\n\n const handleLinkRemoved = useCallback(() => {\n dispatch?.({\n type: \"remove-toolbar-contribution\",\n location: \"post-title\",\n });\n }, [dispatch]);\n\n const highlightVisualLinkTarget = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-on\",\n },\n });\n }\n }, [dataSource, dispatch]);\n\n const handleLinkCreated = useCallback(() => {\n dispatch?.({\n type: \"add-toolbar-contribution\",\n location: \"post-title\",\n content: (\n <IconButton\n aria-label=\"remove-link\"\n icon=\"link\"\n onClick={removeVisualLink}\n onMouseEnter={highlightVisualLinkTarget}\n onMouseLeave={clearVisualLinkTarget}\n variant=\"secondary\"\n />\n ),\n });\n }, [\n dispatch,\n removeVisualLink,\n highlightVisualLinkTarget,\n clearVisualLinkTarget,\n ]);\n\n useEffect(() => {\n dataSource.on(\"visual-link-created\", handleLinkCreated);\n dataSource.on(\"visual-link-removed\", handleLinkRemoved);\n return () => {\n dataSource.removeListener(\"visual-link-created\", handleLinkCreated);\n dataSource.removeListener(\"visual-link-removed\", handleLinkRemoved);\n };\n }, [dataSource, handleLinkCreated, handleLinkRemoved]);\n};\n"],"names":["useViewContext","useCallback","jsx","IconButton","useEffect"],"mappings":";;;;;;;AAKa,MAAA,cAAA,GAAiB,CAAC,UAA2B,KAAA;AACxD,EAAM,MAAA,EAAE,QAAS,EAAA,GAAIA,wBAAe,EAAA;AAEpC,EAAM,MAAA,qBAAA,GAAwBC,kBAAY,MAAM;AAC9C,IAAA,IAAI,WAAW,UAAY,EAAA;AACzB,MAAW,QAAA,GAAA;AAAA,QACT,IAAM,EAAA,mBAAA;AAAA,QACN,OAAS,EAAA;AAAA,UACP,QAAA,EAAU,WAAW,UAAW,CAAA,gBAAA;AAAA,UAChC,IAAM,EAAA;AAAA;AACR,OACD,CAAA;AAAA;AACH,GACC,EAAA,CAAC,UAAY,EAAA,QAAQ,CAAC,CAAA;AAEzB,EAAM,MAAA,gBAAA,GAAmBA,kBAAY,MAAM;AACzC,IAAA,IAAI,WAAW,UAAY,EAAA;AACzB,MAAW,QAAA,GAAA;AAAA,QACT,IAAM,EAAA,mBAAA;AAAA,QACN,OAAS,EAAA;AAAA,UACP,QAAA,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A,CAAG,uBAAuB,iBAAiB,CAAA;AACtD,IAAW,UAAA,CAAA,EAAA,CAAG,uBAAuB,iBAAiB,CAAA;AACtD,IAAA,OAAO,MAAM;AACX,MAAW,UAAA,CAAA,cAAA,CAAe,uBAAuB,iBAAiB,CAAA;AAClE,MAAW,UAAA,CAAA,cAAA,CAAe,uBAAuB,iBAAiB,CAAA;AAAA,KACpE;AAAA,GACC,EAAA,CAAC,UAAY,EAAA,iBAAA,EAAmB,iBAAiB,CAAC,CAAA;AACvD;;;;"}
1
+ {"version":3,"file":"useVisualLinks.js","sources":["../../../../packages/vuu-data-react/src/hooks/useVisualLinks.tsx"],"sourcesContent":["import type { DataSource } from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport { IconButton } from \"@vuu-ui/vuu-ui-controls\";\nimport { useCallback, useEffect } from \"react\";\n\nexport const useVisualLinks = (dataSource: DataSource) => {\n const { dispatch } = useViewContext();\n\n const clearVisualLinkTarget = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-off\",\n },\n });\n }\n }, [dataSource, dispatch]);\n\n const removeVisualLink = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-off\",\n },\n });\n\n dataSource.visualLink = undefined;\n }\n }, [dataSource, dispatch]);\n\n const handleLinkRemoved = useCallback(() => {\n dispatch?.({\n type: \"remove-toolbar-contribution\",\n location: \"post-title\",\n });\n }, [dispatch]);\n\n const highlightVisualLinkTarget = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-on\",\n },\n });\n }\n }, [dataSource, dispatch]);\n\n const handleLinkCreated = useCallback(() => {\n dispatch?.({\n type: \"add-toolbar-contribution\",\n location: \"post-title\",\n content: (\n <IconButton\n appearance=\"transparent\"\n aria-label=\"remove-link\"\n icon=\"link\"\n onClick={removeVisualLink}\n onMouseEnter={highlightVisualLinkTarget}\n onMouseLeave={clearVisualLinkTarget}\n sentiment=\"neutral\"\n />\n ),\n });\n }, [\n dispatch,\n removeVisualLink,\n highlightVisualLinkTarget,\n clearVisualLinkTarget,\n ]);\n\n useEffect(() => {\n dataSource.on(\"visual-link-created\", handleLinkCreated);\n dataSource.on(\"visual-link-removed\", handleLinkRemoved);\n return () => {\n dataSource.removeListener(\"visual-link-created\", handleLinkCreated);\n dataSource.removeListener(\"visual-link-removed\", handleLinkRemoved);\n };\n }, [dataSource, handleLinkCreated, handleLinkRemoved]);\n};\n"],"names":["useViewContext","useCallback","jsx","IconButton","useEffect"],"mappings":";;;;;;;AAKa,MAAA,cAAA,GAAiB,CAAC,UAA2B,KAAA;AACxD,EAAM,MAAA,EAAE,QAAS,EAAA,GAAIA,wBAAe,EAAA;AAEpC,EAAM,MAAA,qBAAA,GAAwBC,kBAAY,MAAM;AAC9C,IAAA,IAAI,WAAW,UAAY,EAAA;AACzB,MAAW,QAAA,GAAA;AAAA,QACT,IAAM,EAAA,mBAAA;AAAA,QACN,OAAS,EAAA;AAAA,UACP,QAAA,EAAU,WAAW,UAAW,CAAA,gBAAA;AAAA,UAChC,IAAM,EAAA;AAAA;AACR,OACD,CAAA;AAAA;AACH,GACC,EAAA,CAAC,UAAY,EAAA,QAAQ,CAAC,CAAA;AAEzB,EAAM,MAAA,gBAAA,GAAmBA,kBAAY,MAAM;AACzC,IAAA,IAAI,WAAW,UAAY,EAAA;AACzB,MAAW,QAAA,GAAA;AAAA,QACT,IAAM,EAAA,mBAAA;AAAA,QACN,OAAS,EAAA;AAAA,UACP,QAAA,EAAU,WAAW,UAAW,CAAA,gBAAA;AAAA,UAChC,IAAM,EAAA;AAAA;AACR,OACD,CAAA;AAED,MAAA,UAAA,CAAW,UAAa,GAAA,KAAA,CAAA;AA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AAA,OAAO,MAAM;AACX,MAAW,UAAA,CAAA,cAAA,CAAe,uBAAuB,iBAAiB,CAAA;AAClE,MAAW,UAAA,CAAA,cAAA,CAAe,uBAAuB,iBAAiB,CAAA;AAAA,KACpE;AAAA,GACC,EAAA,CAAC,UAAY,EAAA,iBAAA,EAAmB,iBAAiB,CAAC,CAAA;AACvD;;;;"}
package/cjs/index.js CHANGED
@@ -7,14 +7,14 @@ var UnsavedChangesReport = require('./data-editing/UnsavedChangesReport.js');
7
7
  var useEditForm = require('./data-editing/useEditForm.js');
8
8
  var formEditState = require('./data-editing/form-edit-state.js');
9
9
  var VuuDataSourceProvider = require('./datasource-provider/VuuDataSourceProvider.js');
10
+ var useLookupValues = require('./hooks/useLookupValues.js');
11
+ var useRemoteConnection = require('./hooks/useRemoteConnection.js');
10
12
  var useSessionDataSource = require('./hooks/useSessionDataSource.js');
13
+ var useTypeaheadSuggestions = require('./hooks/useTypeaheadSuggestions.js');
14
+ var useVisualLinks = require('./hooks/useVisualLinks.js');
11
15
  var useVuuMenuActions = require('./hooks/useVuuMenuActions.js');
12
16
  var useVuuTables = require('./hooks/useVuuTables.js');
13
- var useVisualLinks = require('./hooks/useVisualLinks.js');
14
- var useTypeaheadSuggestions = require('./hooks/useTypeaheadSuggestions.js');
15
17
  var SessionEditingForm = require('./session-editing-form/SessionEditingForm.js');
16
- var useLookupValues = require('./hooks/useLookupValues.js');
17
- var useRemoteConnection = require('./hooks/useRemoteConnection.js');
18
18
 
19
19
 
20
20
 
@@ -28,15 +28,15 @@ exports.useEditForm = useEditForm.useEditForm;
28
28
  exports.CLEAN_FORM = formEditState.CLEAN_FORM;
29
29
  exports.buildFormEditState = formEditState.buildFormEditState;
30
30
  exports.VuuDataSourceProvider = VuuDataSourceProvider.VuuDataSourceProvider;
31
+ exports.useLookupValues = useLookupValues.useLookupValues;
32
+ exports.useRemoteConnection = useRemoteConnection.useRemoteConnection;
31
33
  exports.useSessionDataSource = useSessionDataSource.useSessionDataSource;
34
+ exports.getTypeaheadParams = useTypeaheadSuggestions.getTypeaheadParams;
35
+ exports.useTypeaheadSuggestions = useTypeaheadSuggestions.useTypeaheadSuggestions;
36
+ exports.useVisualLinks = useVisualLinks.useVisualLinks;
32
37
  exports.isRowMenu = useVuuMenuActions.isRowMenu;
33
38
  exports.isSelectionMenu = useVuuMenuActions.isSelectionMenu;
34
39
  exports.useVuuMenuActions = useVuuMenuActions.useVuuMenuActions;
35
40
  exports.useVuuTables = useVuuTables.useVuuTables;
36
- exports.useVisualLinks = useVisualLinks.useVisualLinks;
37
- exports.getTypeaheadParams = useTypeaheadSuggestions.getTypeaheadParams;
38
- exports.useTypeaheadSuggestions = useTypeaheadSuggestions.useTypeaheadSuggestions;
39
41
  exports.SessionEditingForm = SessionEditingForm.SessionEditingForm;
40
- exports.useLookupValues = useLookupValues.useLookupValues;
41
- exports.useRemoteConnection = useRemoteConnection.useRemoteConnection;
42
42
  //# sourceMappingURL=index.js.map
@@ -1,69 +1,61 @@
1
- import { useViewContext } from '@vuu-ui/vuu-layout';
2
- import { useData, isConfigChanged } from '@vuu-ui/vuu-utils';
3
- import { useMemo, useRef, useCallback } from 'react';
1
+ import { useData } from '@vuu-ui/vuu-utils';
2
+ import { useRef, useCallback } from 'react';
4
3
 
5
- const NO_CONFIG = {};
6
- const useSessionDataSource = ({
7
- dataSourceSessionKey = "data-source",
8
- tableSchema
9
- }) => {
10
- const { id, load, save, loadSession, saveSession, title } = useViewContext();
4
+ const sessionState = /* @__PURE__ */ new Map();
5
+ const useSessionDataSource = (props) => {
11
6
  const { VuuDataSource } = useData();
12
- const { "datasource-config": dataSourceConfigFromState } = useMemo(() => load?.() ?? NO_CONFIG, [load]);
13
- const dataSourceConfigRef = useRef(
14
- dataSourceConfigFromState
15
- );
16
- const handleDataSourceConfigChange = useCallback(
17
- (config, _range, confirmed) => {
18
- if (confirmed !== false) {
19
- const { noChanges } = isConfigChanged(
20
- dataSourceConfigRef.current,
21
- config
22
- );
23
- if (noChanges === false) {
24
- dataSourceConfigRef.current = config;
25
- save?.(config, "datasource-config");
7
+ const dataSourceConfigRef = useRef(void 0);
8
+ const getDataSource = useCallback(
9
+ (sessionKey, config) => {
10
+ let ds = sessionState.get(sessionKey);
11
+ if (ds) {
12
+ if (config) {
13
+ ds.applyConfig(config, true);
14
+ }
15
+ if (ds.range.from > 0) {
16
+ ds.range = ds.range.reset;
26
17
  }
18
+ return ds;
19
+ }
20
+ if (config?.columns) {
21
+ ds = new VuuDataSource({
22
+ ...config,
23
+ viewport: sessionKey,
24
+ ...dataSourceConfigRef.current
25
+ });
26
+ if (props?.onConfigChange) {
27
+ ds.on("config", props.onConfigChange);
28
+ }
29
+ sessionState.set(sessionKey, ds);
30
+ return ds;
31
+ } else {
32
+ throw Error(
33
+ `[useSessionDataSource] unable to create new DataSource, columns have not been defined `
34
+ );
27
35
  }
28
36
  },
29
- [save]
37
+ [VuuDataSource, props?.onConfigChange]
30
38
  );
31
- const dataSource = useMemo(() => {
32
- let ds = loadSession?.(dataSourceSessionKey);
33
- if (ds) {
34
- if (dataSourceConfigFromState) {
35
- ds.applyConfig(dataSourceConfigFromState, true);
36
- }
37
- if (ds.range.from > 0) {
38
- ds.range = ds.range.reset;
39
+ const clearDataSource = useCallback(
40
+ (sessionKey, unsubscribe) => {
41
+ const ds = sessionState.get(sessionKey);
42
+ if (ds) {
43
+ sessionState.delete(sessionKey);
44
+ if (unsubscribe === true) {
45
+ ds.unsubscribe();
46
+ }
47
+ } else {
48
+ console.warn(
49
+ `[useSessionbDatasource] clearDataSource ${sessionKey} not found `
50
+ );
39
51
  }
40
- return ds;
41
- }
42
- const columns = dataSourceConfigFromState?.columns ?? tableSchema.columns.map((col) => col.name);
43
- ds = new VuuDataSource({
44
- // bufferSize: 0,
45
- viewport: id,
46
- table: tableSchema.table,
47
- ...dataSourceConfigRef.current,
48
- columns,
49
- title
50
- });
51
- ds.on("config", handleDataSourceConfigChange);
52
- saveSession?.(ds, "data-source");
53
- return ds;
54
- }, [
55
- VuuDataSource,
56
- dataSourceConfigFromState,
57
- dataSourceSessionKey,
58
- handleDataSourceConfigChange,
59
- id,
60
- loadSession,
61
- saveSession,
62
- tableSchema.columns,
63
- tableSchema.table,
64
- title
65
- ]);
66
- return dataSource;
52
+ },
53
+ []
54
+ );
55
+ return {
56
+ clearDataSource,
57
+ getDataSource
58
+ };
67
59
  };
68
60
 
69
61
  export { useSessionDataSource };
@@ -1 +1 @@
1
- {"version":3,"file":"useSessionDataSource.js","sources":["../../../../packages/vuu-data-react/src/hooks/useSessionDataSource.ts"],"sourcesContent":["import type {\n DataSource,\n DataSourceConfig,\n DataSourceConfigChangeHandler,\n TableSchema,\n} from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport type { VuuRange } from \"@vuu-ui/vuu-protocol-types\";\nimport { isConfigChanged, useData } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\n\ntype SessionState = {\n \"datasource-config\"?: DataSourceConfig;\n};\n\nconst NO_CONFIG: SessionState = {};\n\nexport const useSessionDataSource = ({\n dataSourceSessionKey = \"data-source\",\n tableSchema,\n}: {\n dataSourceSessionKey?: string;\n tableSchema: TableSchema;\n}) => {\n const { id, load, save, loadSession, saveSession, title } = useViewContext();\n const { VuuDataSource } = useData();\n\n const { \"datasource-config\": dataSourceConfigFromState } =\n useMemo<SessionState>(() => load?.() ?? NO_CONFIG, [load]);\n\n const dataSourceConfigRef = useRef<DataSourceConfig | undefined>(\n dataSourceConfigFromState,\n );\n\n const handleDataSourceConfigChange =\n useCallback<DataSourceConfigChangeHandler>(\n (\n config: DataSourceConfig | undefined,\n _range: VuuRange,\n confirmed?: boolean,\n ) => {\n if (confirmed !== false) {\n const { noChanges } = isConfigChanged(\n dataSourceConfigRef.current,\n config,\n );\n if (noChanges === false) {\n dataSourceConfigRef.current = config;\n save?.(config, \"datasource-config\");\n }\n }\n },\n [save],\n );\n\n const dataSource: DataSource = useMemo(() => {\n let ds = loadSession?.(dataSourceSessionKey) as DataSource;\n if (ds) {\n if (dataSourceConfigFromState) {\n // this won't do anything if dataSource config already matches this\n // This is only really used when injecting a dataSource into session\n // state in Showcase examples\n // DO we definitely need this ? If not apply config can be provate\n ds.applyConfig(dataSourceConfigFromState, true);\n }\n\n if (ds.range.from > 0) {\n // UI does not currently restore scroll position, so always reset to top of dataset\n ds.range = ds.range.reset;\n }\n\n return ds;\n }\n\n const columns =\n dataSourceConfigFromState?.columns ??\n tableSchema.columns.map((col) => col.name);\n\n ds = new VuuDataSource({\n // bufferSize: 0,\n viewport: id,\n table: tableSchema.table,\n ...dataSourceConfigRef.current,\n columns,\n title,\n });\n ds.on(\"config\", handleDataSourceConfigChange);\n saveSession?.(ds, \"data-source\");\n return ds;\n }, [\n VuuDataSource,\n dataSourceConfigFromState,\n dataSourceSessionKey,\n handleDataSourceConfigChange,\n id,\n loadSession,\n saveSession,\n tableSchema.columns,\n tableSchema.table,\n title,\n ]);\n\n return dataSource;\n};\n"],"names":[],"mappings":";;;;AAeA,MAAM,YAA0B,EAAC;AAE1B,MAAM,uBAAuB,CAAC;AAAA,EACnC,oBAAuB,GAAA,aAAA;AAAA,EACvB;AACF,CAGM,KAAA;AACJ,EAAM,MAAA,EAAE,IAAI,IAAM,EAAA,IAAA,EAAM,aAAa,WAAa,EAAA,KAAA,KAAU,cAAe,EAAA;AAC3E,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,OAAQ,EAAA;AAElC,EAAM,MAAA,EAAE,mBAAqB,EAAA,yBAAA,EAC3B,GAAA,OAAA,CAAsB,MAAM,IAAA,IAAY,IAAA,SAAA,EAAW,CAAC,IAAI,CAAC,CAAA;AAE3D,EAAA,MAAM,mBAAsB,GAAA,MAAA;AAAA,IAC1B;AAAA,GACF;AAEA,EAAA,MAAM,4BACJ,GAAA,WAAA;AAAA,IACE,CACE,MACA,EAAA,MAAA,EACA,SACG,KAAA;AACH,MAAA,IAAI,cAAc,KAAO,EAAA;AAC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AA;AAAA,IACA,WAAA;AAAA,IACA,WAAY,CAAA,OAAA;AAAA,IACZ,WAAY,CAAA,KAAA;AAAA,IACZ;AAAA,GACD,CAAA;AAED,EAAO,OAAA,UAAA;AACT;;;;"}
1
+ {"version":3,"file":"useSessionDataSource.js","sources":["../../../../packages/vuu-data-react/src/hooks/useSessionDataSource.ts"],"sourcesContent":["import type {\n DataSource,\n DataSourceConfig,\n DataSourceConfigChangeHandler,\n DataSourceConstructorProps,\n} from \"@vuu-ui/vuu-data-types\";\nimport { useData } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useRef } from \"react\";\n\nconst sessionState = new Map<string, DataSource>();\n\nexport interface SessionStateHookProps {\n onConfigChange?: DataSourceConfigChangeHandler;\n}\n\nexport const useSessionDataSource = (props?: SessionStateHookProps) => {\n const { VuuDataSource } = useData();\n\n const dataSourceConfigRef = useRef<DataSourceConfig | undefined>(undefined);\n\n const getDataSource = useCallback(\n (sessionKey: string, config?: DataSourceConstructorProps) => {\n let ds = sessionState.get(sessionKey);\n if (ds) {\n if (config) {\n // this won't do anything if dataSource config already matches this\n // This is only really used when injecting a dataSource into session\n // state in Showcase examples\n // Do we definitely need this ? If not apply config can be provate\n ds.applyConfig(config, true);\n }\n\n if (ds.range.from > 0) {\n // UI does not currently restore scroll position, so always reset to top of dataset\n ds.range = ds.range.reset;\n }\n return ds;\n }\n\n if (config?.columns) {\n ds = new VuuDataSource({\n ...config,\n viewport: sessionKey,\n ...dataSourceConfigRef.current,\n });\n if (props?.onConfigChange) {\n ds.on(\"config\", props.onConfigChange);\n }\n sessionState.set(sessionKey, ds);\n return ds;\n } else {\n throw Error(\n `[useSessionDataSource] unable to create new DataSource, columns have not been defined `,\n );\n }\n },\n [VuuDataSource, props?.onConfigChange],\n );\n\n const clearDataSource = useCallback(\n (sessionKey: string, unsubscribe?: boolean) => {\n const ds = sessionState.get(sessionKey);\n if (ds) {\n sessionState.delete(sessionKey);\n if (unsubscribe === true) {\n ds.unsubscribe();\n }\n } else {\n console.warn(\n `[useSessionbDatasource] clearDataSource ${sessionKey} not found `,\n );\n }\n },\n [],\n );\n\n return {\n clearDataSource,\n getDataSource,\n };\n};\n"],"names":[],"mappings":";;;AASA,MAAM,YAAA,uBAAmB,GAAwB,EAAA;AAMpC,MAAA,oBAAA,GAAuB,CAAC,KAAkC,KAAA;AACrE,EAAM,MAAA,EAAE,aAAc,EAAA,GAAI,OAAQ,EAAA;AAElC,EAAM,MAAA,mBAAA,GAAsB,OAAqC,KAAS,CAAA,CAAA;AAE1E,EAAA,MAAM,aAAgB,GAAA,WAAA;AAAA,IACpB,CAAC,YAAoB,MAAwC,KAAA;AAC3D,MAAI,IAAA,EAAA,GAAK,YAAa,CAAA,GAAA,CAAI,UAAU,CAAA;AACpC,MAAA,IAAI,EAAI,EAAA;AACN,QAAA,IAAI,MAAQ,EAAA;AAKV,UAAG,EAAA,CAAA,WAAA,CAAY,QAAQ,IAAI,CAAA;AAAA;AAG7B,QAAI,IAAA,EAAA,CAAG,KAAM,CAAA,IAAA,GAAO,CAAG,EAAA;AAErB,UAAG,EAAA,CAAA,KAAA,GAAQ,GAAG,KAAM,CAAA,KAAA;AAAA;AAEtB,QAAO,OAAA,EAAA;AAAA;AAGT,MAAA,IAAI,QAAQ,OAAS,EAAA;AACnB,QAAA,EAAA,GAAK,IAAI,aAAc,CAAA;AAAA,UACrB,GAAG,MAAA;AAAA,UACH,QAAU,EAAA,UAAA;AAAA,UACV,GAAG,mBAAoB,CAAA;AAAA,SACxB,CAAA;AACD,QAAA,IAAI,OAAO,cAAgB,EAAA;AACzB,UAAG,EAAA,CAAA,EAAA,CAAG,QAAU,EAAA,KAAA,CAAM,cAAc,CAAA;AAAA;AAEtC,QAAa,YAAA,CAAA,GAAA,CAAI,YAAY,EAAE,CAAA;AAC/B,QAAO,OAAA,EAAA;AAAA,OACF,MAAA;AACL,QAAM,MAAA,KAAA;AAAA,UACJ,CAAA,sFAAA;AAAA,SACF;AAAA;AACF,KACF;AAAA,IACA,CAAC,aAAe,EAAA,KAAA,EAAO,cAAc;AAAA,GACvC;AAEA,EAAA,MAAM,eAAkB,GAAA,WAAA;AAAA,IACtB,CAAC,YAAoB,WAA0B,KAAA;AAC7C,MAAM,MAAA,EAAA,GAAK,YAAa,CAAA,GAAA,CAAI,UAAU,CAAA;AACtC,MAAA,IAAI,EAAI,EAAA;AACN,QAAA,YAAA,CAAa,OAAO,UAAU,CAAA;AAC9B,QAAA,IAAI,gBAAgB,IAAM,EAAA;AACxB,UAAA,EAAA,CAAG,WAAY,EAAA;AAAA;AACjB,OACK,MAAA;AACL,QAAQ,OAAA,CAAA,IAAA;AAAA,UACN,2CAA2C,UAAU,CAAA,WAAA;AAAA,SACvD;AAAA;AACF,KACF;AAAA,IACA;AAAC,GACH;AAEA,EAAO,OAAA;AAAA,IACL,eAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -52,12 +52,13 @@ const useVisualLinks = (dataSource) => {
52
52
  content: /* @__PURE__ */ jsx(
53
53
  IconButton,
54
54
  {
55
+ appearance: "transparent",
55
56
  "aria-label": "remove-link",
56
57
  icon: "link",
57
58
  onClick: removeVisualLink,
58
59
  onMouseEnter: highlightVisualLinkTarget,
59
60
  onMouseLeave: clearVisualLinkTarget,
60
- variant: "secondary"
61
+ sentiment: "neutral"
61
62
  }
62
63
  )
63
64
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useVisualLinks.js","sources":["../../../../packages/vuu-data-react/src/hooks/useVisualLinks.tsx"],"sourcesContent":["import { DataSource } from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport { IconButton } from \"@vuu-ui/vuu-ui-controls\";\nimport { useCallback, useEffect } from \"react\";\n\nexport const useVisualLinks = (dataSource: DataSource) => {\n const { dispatch } = useViewContext();\n\n const clearVisualLinkTarget = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-off\",\n },\n });\n }\n }, [dataSource, dispatch]);\n\n const removeVisualLink = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-off\",\n },\n });\n\n dataSource.visualLink = undefined;\n }\n }, [dataSource, dispatch]);\n\n const handleLinkRemoved = useCallback(() => {\n dispatch?.({\n type: \"remove-toolbar-contribution\",\n location: \"post-title\",\n });\n }, [dispatch]);\n\n const highlightVisualLinkTarget = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-on\",\n },\n });\n }\n }, [dataSource, dispatch]);\n\n const handleLinkCreated = useCallback(() => {\n dispatch?.({\n type: \"add-toolbar-contribution\",\n location: \"post-title\",\n content: (\n <IconButton\n aria-label=\"remove-link\"\n icon=\"link\"\n onClick={removeVisualLink}\n onMouseEnter={highlightVisualLinkTarget}\n onMouseLeave={clearVisualLinkTarget}\n variant=\"secondary\"\n />\n ),\n });\n }, [\n dispatch,\n removeVisualLink,\n highlightVisualLinkTarget,\n clearVisualLinkTarget,\n ]);\n\n useEffect(() => {\n dataSource.on(\"visual-link-created\", handleLinkCreated);\n dataSource.on(\"visual-link-removed\", handleLinkRemoved);\n return () => {\n dataSource.removeListener(\"visual-link-created\", handleLinkCreated);\n dataSource.removeListener(\"visual-link-removed\", handleLinkRemoved);\n };\n }, [dataSource, handleLinkCreated, handleLinkRemoved]);\n};\n"],"names":[],"mappings":";;;;;AAKa,MAAA,cAAA,GAAiB,CAAC,UAA2B,KAAA;AACxD,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,cAAe,EAAA;AAEpC,EAAM,MAAA,qBAAA,GAAwB,YAAY,MAAM;AAC9C,IAAA,IAAI,WAAW,UAAY,EAAA;AACzB,MAAW,QAAA,GAAA;AAAA,QACT,IAAM,EAAA,mBAAA;AAAA,QACN,O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AA;AAAA,UACX,IAAK,EAAA,MAAA;AAAA,UACL,OAAS,EAAA,gBAAA;AAAA,UACT,YAAc,EAAA,yBAAA;AAAA,UACd,YAAc,EAAA,qBAAA;AAAA,UACd,OAAQ,EAAA;AAAA;AAAA;AACV,KAEH,CAAA;AAAA,GACA,EAAA;AAAA,IACD,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,yBAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACd,IAAW,UAAA,CAAA,EAAA,CAAG,uBAAuB,iBAAiB,CAAA;AACtD,IAAW,UAAA,CAAA,EAAA,CAAG,uBAAuB,iBAAiB,CAAA;AACtD,IAAA,OAAO,MAAM;AACX,MAAW,UAAA,CAAA,cAAA,CAAe,uBAAuB,iBAAiB,CAAA;AAClE,MAAW,UAAA,CAAA,cAAA,CAAe,uBAAuB,iBAAiB,CAAA;AAAA,KACpE;AAAA,GACC,EAAA,CAAC,UAAY,EAAA,iBAAA,EAAmB,iBAAiB,CAAC,CAAA;AACvD;;;;"}
1
+ {"version":3,"file":"useVisualLinks.js","sources":["../../../../packages/vuu-data-react/src/hooks/useVisualLinks.tsx"],"sourcesContent":["import type { DataSource } from \"@vuu-ui/vuu-data-types\";\nimport { useViewContext } from \"@vuu-ui/vuu-layout\";\nimport { IconButton } from \"@vuu-ui/vuu-ui-controls\";\nimport { useCallback, useEffect } from \"react\";\n\nexport const useVisualLinks = (dataSource: DataSource) => {\n const { dispatch } = useViewContext();\n\n const clearVisualLinkTarget = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-off\",\n },\n });\n }\n }, [dataSource, dispatch]);\n\n const removeVisualLink = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-off\",\n },\n });\n\n dataSource.visualLink = undefined;\n }\n }, [dataSource, dispatch]);\n\n const handleLinkRemoved = useCallback(() => {\n dispatch?.({\n type: \"remove-toolbar-contribution\",\n location: \"post-title\",\n });\n }, [dispatch]);\n\n const highlightVisualLinkTarget = useCallback(() => {\n if (dataSource.visualLink) {\n dispatch?.({\n type: \"broadcast-message\",\n message: {\n targetId: dataSource.visualLink.parentClientVpId,\n type: \"highlight-on\",\n },\n });\n }\n }, [dataSource, dispatch]);\n\n const handleLinkCreated = useCallback(() => {\n dispatch?.({\n type: \"add-toolbar-contribution\",\n location: \"post-title\",\n content: (\n <IconButton\n appearance=\"transparent\"\n aria-label=\"remove-link\"\n icon=\"link\"\n onClick={removeVisualLink}\n onMouseEnter={highlightVisualLinkTarget}\n onMouseLeave={clearVisualLinkTarget}\n sentiment=\"neutral\"\n />\n ),\n });\n }, [\n dispatch,\n removeVisualLink,\n highlightVisualLinkTarget,\n clearVisualLinkTarget,\n ]);\n\n useEffect(() => {\n dataSource.on(\"visual-link-created\", handleLinkCreated);\n dataSource.on(\"visual-link-removed\", handleLinkRemoved);\n return () => {\n dataSource.removeListener(\"visual-link-created\", handleLinkCreated);\n dataSource.removeListener(\"visual-link-removed\", handleLinkRemoved);\n };\n }, [dataSource, handleLinkCreated, handleLinkRemoved]);\n};\n"],"names":[],"mappings":";;;;;AAKa,MAAA,cAAA,GAAiB,CAAC,UAA2B,KAAA;AACxD,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,cAAe,EAAA;AAEpC,EAAM,MAAA,qBAAA,GAAwB,YAAY,MAAM;AAC9C,IAAA,IAAI,WAAW,UAAY,EAAA;AACzB,MAAW,QAAA,GAAA;AAAA,QACT,IAAM,EAAA,mBAAA;AAAA,QACN,OAAS,EAAA;AAAA,UACP,QAAA,EAAU,WAAW,UAAW,CAAA,gBAAA;AAAA,UAChC,IAAM,EAAA;AAAA;AACR,OACD,CAAA;AAAA;AACH,GACC,EAAA,CAAC,UAAY,EAAA,QAAQ,CAAC,CAAA;AAEzB,EAAM,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AA;AAAA;AACZ,KAEH,CAAA;AAAA,GACA,EAAA;AAAA,IACD,QAAA;AAAA,IACA,gBAAA;AAAA,IACA,yBAAA;AAAA,IACA;AAAA,GACD,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AACd,IAAW,UAAA,CAAA,EAAA,CAAG,uBAAuB,iBAAiB,CAAA;AACtD,IAAW,UAAA,CAAA,EAAA,CAAG,uBAAuB,iBAAiB,CAAA;AACtD,IAAA,OAAO,MAAM;AACX,MAAW,UAAA,CAAA,cAAA,CAAe,uBAAuB,iBAAiB,CAAA;AAClE,MAAW,UAAA,CAAA,cAAA,CAAe,uBAAuB,iBAAiB,CAAA;AAAA,KACpE;AAAA,GACC,EAAA,CAAC,UAAY,EAAA,iBAAA,EAAmB,iBAAiB,CAAC,CAAA;AACvD;;;;"}
package/esm/index.js CHANGED
@@ -5,12 +5,12 @@ export { UnsavedChangesReport } from './data-editing/UnsavedChangesReport.js';
5
5
  export { useEditForm } from './data-editing/useEditForm.js';
6
6
  export { CLEAN_FORM, buildFormEditState } from './data-editing/form-edit-state.js';
7
7
  export { VuuDataSourceProvider } from './datasource-provider/VuuDataSourceProvider.js';
8
+ export { useLookupValues } from './hooks/useLookupValues.js';
9
+ export { useRemoteConnection } from './hooks/useRemoteConnection.js';
8
10
  export { useSessionDataSource } from './hooks/useSessionDataSource.js';
11
+ export { getTypeaheadParams, useTypeaheadSuggestions } from './hooks/useTypeaheadSuggestions.js';
12
+ export { useVisualLinks } from './hooks/useVisualLinks.js';
9
13
  export { isRowMenu, isSelectionMenu, useVuuMenuActions } from './hooks/useVuuMenuActions.js';
10
14
  export { useVuuTables } from './hooks/useVuuTables.js';
11
- export { useVisualLinks } from './hooks/useVisualLinks.js';
12
- export { getTypeaheadParams, useTypeaheadSuggestions } from './hooks/useTypeaheadSuggestions.js';
13
15
  export { SessionEditingForm } from './session-editing-form/SessionEditingForm.js';
14
- export { useLookupValues } from './hooks/useLookupValues.js';
15
- export { useRemoteConnection } from './hooks/useRemoteConnection.js';
16
16
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
- "version": "0.13.60",
2
+ "version": "0.13.61",
3
3
  "author": "heswell",
4
4
  "license": "Apache-2.0",
5
5
  "devDependencies": {
6
- "@vuu-ui/vuu-data-types": "0.13.60",
7
- "@vuu-ui/vuu-filter-types": "0.13.60",
8
- "@vuu-ui/vuu-popups": "0.13.60",
9
- "@vuu-ui/vuu-protocol-types": "0.13.60",
10
- "@vuu-ui/vuu-table-types": "0.13.60"
6
+ "@vuu-ui/vuu-data-types": "0.13.61",
7
+ "@vuu-ui/vuu-filter-types": "0.13.61",
8
+ "@vuu-ui/vuu-popups": "0.13.61",
9
+ "@vuu-ui/vuu-protocol-types": "0.13.61",
10
+ "@vuu-ui/vuu-table-types": "0.13.61"
11
11
  },
12
12
  "dependencies": {
13
- "@vuu-ui/vuu-context-menu": "0.13.60",
14
- "@vuu-ui/vuu-data-remote": "0.13.60",
15
- "@vuu-ui/vuu-filter-parser": "0.13.60",
16
- "@vuu-ui/vuu-filters": "0.13.60",
17
- "@vuu-ui/vuu-layout": "0.13.60",
18
- "@vuu-ui/vuu-popups": "0.13.60",
19
- "@vuu-ui/vuu-ui-controls": "0.13.60",
20
- "@vuu-ui/vuu-utils": "0.13.60",
21
- "@vuu-ui/vuu-table": "0.13.60",
13
+ "@vuu-ui/vuu-context-menu": "0.13.61",
14
+ "@vuu-ui/vuu-data-remote": "0.13.61",
15
+ "@vuu-ui/vuu-filter-parser": "0.13.61",
16
+ "@vuu-ui/vuu-filters": "0.13.61",
17
+ "@vuu-ui/vuu-layout": "0.13.61",
18
+ "@vuu-ui/vuu-popups": "0.13.61",
19
+ "@vuu-ui/vuu-ui-controls": "0.13.61",
20
+ "@vuu-ui/vuu-utils": "0.13.61",
21
+ "@vuu-ui/vuu-table": "0.13.61",
22
22
  "@salt-ds/core": "1.48.0",
23
23
  "@salt-ds/styles": "0.2.1",
24
24
  "@salt-ds/window": "0.1.1"
@@ -1,5 +1,8 @@
1
- import type { DataSource, TableSchema } from "@vuu-ui/vuu-data-types";
2
- export declare const useSessionDataSource: ({ dataSourceSessionKey, tableSchema, }: {
3
- dataSourceSessionKey?: string;
4
- tableSchema: TableSchema;
5
- }) => DataSource;
1
+ import type { DataSource, DataSourceConfigChangeHandler, DataSourceConstructorProps } from "@vuu-ui/vuu-data-types";
2
+ export interface SessionStateHookProps {
3
+ onConfigChange?: DataSourceConfigChangeHandler;
4
+ }
5
+ export declare const useSessionDataSource: (props?: SessionStateHookProps) => {
6
+ clearDataSource: (sessionKey: string, unsubscribe?: boolean) => void;
7
+ getDataSource: (sessionKey: string, config?: DataSourceConstructorProps) => DataSource;
8
+ };
@@ -1,2 +1,2 @@
1
- import { DataSource } from "@vuu-ui/vuu-data-types";
1
+ import type { DataSource } from "@vuu-ui/vuu-data-types";
2
2
  export declare const useVisualLinks: (dataSource: DataSource) => void;
package/types/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  export * from "./data-editing";
2
2
  export * from "./datasource-provider";
3
- export * from "./hooks";
4
- export * from "./session-editing-form";
5
3
  export { useLookupValues } from "./hooks/useLookupValues";
6
4
  export { useRemoteConnection } from "./hooks/useRemoteConnection";
5
+ export { useSessionDataSource } from "./hooks/useSessionDataSource";
6
+ export { getTypeaheadParams, useTypeaheadSuggestions, } from "./hooks/useTypeaheadSuggestions";
7
+ export { useVisualLinks } from "./hooks/useVisualLinks";
8
+ export { type MenuActionConfig, isRowMenu, isSelectionMenu, useVuuMenuActions, } from "./hooks/useVuuMenuActions";
9
+ export { useVuuTables } from "./hooks/useVuuTables";
10
+ export * from "./session-editing-form";
@@ -1,5 +0,0 @@
1
- export * from "./useSessionDataSource";
2
- export * from "./useVuuMenuActions";
3
- export * from "./useVuuTables";
4
- export * from "./useVisualLinks";
5
- export * from "./useTypeaheadSuggestions";