@vuu-ui/vuu-utils 2.1.19-beta.1 → 2.1.19-beta.2

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.
Files changed (82) hide show
  1. package/package.json +8 -9
  2. package/src/Clock.js +43 -0
  3. package/src/PageVisibilityObserver.js +42 -0
  4. package/src/ScaledDecimal.js +32 -0
  5. package/src/ShellContext.js +5 -0
  6. package/src/ThemeProvider.js +56 -0
  7. package/src/array-utils.js +51 -0
  8. package/src/box-utils.js +51 -0
  9. package/src/broadcast-channel.js +0 -0
  10. package/src/column-utils.js +790 -0
  11. package/src/common-types.js +11 -0
  12. package/src/component-registry.js +83 -0
  13. package/src/context-definitions/DataContext.js +15 -0
  14. package/src/context-definitions/DataProvider.js +13 -0
  15. package/src/context-definitions/DataSourceProvider.js +18 -0
  16. package/src/context-definitions/WorkspaceContext.js +14 -0
  17. package/src/cookie-utils.js +15 -0
  18. package/src/css-utils.js +5 -0
  19. package/src/data-editing/DataEditingProvider.js +13 -0
  20. package/src/data-editing/EditButtons.js +32 -0
  21. package/src/data-editing/EditModeProvider.js +18 -0
  22. package/src/data-editing/EditSession.js +149 -0
  23. package/src/data-editing/edit-utils.js +37 -0
  24. package/src/data-editing/useEditableTable.js +76 -0
  25. package/src/data-utils.js +55 -0
  26. package/src/datasource/BaseDataSource.js +233 -0
  27. package/src/datasource/datasource-action-utils.js +6 -0
  28. package/src/datasource/datasource-filter-utils.js +27 -0
  29. package/src/datasource/datasource-utils.js +148 -0
  30. package/src/date/date-utils.js +80 -0
  31. package/src/date/dateTimePattern.js +17 -0
  32. package/src/date/formatter.js +101 -0
  33. package/src/date/index.js +4 -0
  34. package/src/date/types.js +27 -0
  35. package/src/debug-utils.js +25 -0
  36. package/src/event-emitter.js +78 -0
  37. package/src/feature-utils.js +86 -0
  38. package/src/filters/filter-utils.js +136 -0
  39. package/src/filters/filterAsQuery.js +70 -0
  40. package/src/filters/index.js +2 -0
  41. package/src/form-utils.js +69 -0
  42. package/src/formatting-utils.js +42 -0
  43. package/src/getUniqueId.js +2 -0
  44. package/src/group-utils.js +16 -0
  45. package/src/html-utils.js +108 -0
  46. package/src/index.js +77 -0
  47. package/src/input-utils.js +3 -0
  48. package/src/invariant.js +9 -0
  49. package/src/itemToString.js +9 -0
  50. package/src/json-types.js +0 -0
  51. package/src/json-utils.js +108 -0
  52. package/src/keyboard-utils.js +14 -0
  53. package/src/keyset.js +57 -0
  54. package/src/layout-types.js +0 -0
  55. package/src/list-utils.js +5 -0
  56. package/src/local-storage-utils.js +23 -0
  57. package/src/logging-utils.js +52 -0
  58. package/src/module-utils.js +2 -0
  59. package/src/nanoid/index.js +13 -0
  60. package/src/perf-utils.js +28 -0
  61. package/src/promise-utils.js +26 -0
  62. package/src/protocol-message-utils.js +68 -0
  63. package/src/range-utils.js +109 -0
  64. package/src/react-utils.js +64 -0
  65. package/src/round-decimal.js +83 -0
  66. package/src/row-utils.js +43 -0
  67. package/src/selection-utils.js +25 -0
  68. package/src/shell-layout-types.js +9 -0
  69. package/src/sort-utils.js +75 -0
  70. package/src/table-schema-utils.js +11 -0
  71. package/src/text-utils.js +13 -0
  72. package/src/theme-utils.js +21 -0
  73. package/src/tree-types.js +0 -0
  74. package/src/tree-utils.js +96 -0
  75. package/src/ts-utils.js +6 -0
  76. package/src/typeahead-utils.js +4 -0
  77. package/src/url-utils.js +12 -0
  78. package/src/useId.js +6 -0
  79. package/src/useLayoutEffectSkipFirst.js +9 -0
  80. package/src/useResizeObserver.js +122 -0
  81. package/src/useStateRef.js +21 -0
  82. package/src/user-types.js +0 -0
package/src/index.js ADDED
@@ -0,0 +1,77 @@
1
+ export * from "./array-utils.js";
2
+ export * from "./box-utils.js";
3
+ export * from "./broadcast-channel.js";
4
+ export * from "./column-utils.js";
5
+ export * from "./common-types.js";
6
+ export * from "./component-registry.js";
7
+ export * from "./cookie-utils.js";
8
+ export * from "./css-utils.js";
9
+ export * from "./data-utils.js";
10
+ export * from "./datasource/BaseDataSource.js";
11
+ export * from "./datasource/datasource-action-utils.js";
12
+ export * from "./datasource/datasource-filter-utils.js";
13
+ export * from "./datasource/datasource-utils.js";
14
+ export * from "./date/index.js";
15
+ export * from "./debug-utils.js";
16
+ export * from "./event-emitter.js";
17
+ export * from "./feature-utils.js";
18
+ export * from "./filters/index.js";
19
+ export * from "./form-utils.js";
20
+ export * from "./formatting-utils.js";
21
+ export * from "./getUniqueId.js";
22
+ export * from "./group-utils.js";
23
+ export * from "./html-utils.js";
24
+ export * from "./input-utils.js";
25
+ export * from "./invariant.js";
26
+ export * from "./itemToString.js";
27
+ export * from "./json-types.js";
28
+ export * from "./json-utils.js";
29
+ export * from "./keyboard-utils.js";
30
+ export * from "./keyset.js";
31
+ export * from "./layout-types.js";
32
+ export * from "./list-utils.js";
33
+ export * from "./local-storage-utils.js";
34
+ export * from "./logging-utils.js";
35
+ export * from "./module-utils.js";
36
+ export * from "./nanoid/index.js";
37
+ export * from "./perf-utils.js";
38
+ export * from "./promise-utils.js";
39
+ export * from "./protocol-message-utils.js";
40
+ export * from "./range-utils.js";
41
+ export * from "./react-utils.js";
42
+ export * from "./round-decimal.js";
43
+ export * from "./row-utils.js";
44
+ export * from "./ScaledDecimal.js";
45
+ export * from "./selection-utils.js";
46
+ export * from "./shell-layout-types.js";
47
+ export * from "./sort-utils.js";
48
+ export * from "./table-schema-utils.js";
49
+ export * from "./text-utils.js";
50
+ export * from "./ThemeProvider.js";
51
+ export * from "./tree-types.js";
52
+ export * from "./tree-utils.js";
53
+ export * from "./ts-utils.js";
54
+ export * from "./typeahead-utils.js";
55
+ export * from "./url-utils.js";
56
+ export * from "./useId.js";
57
+ export * from "./useLayoutEffectSkipFirst.js";
58
+ export * from "./user-types.js";
59
+ export * from "./useStateRef.js";
60
+ export * from "./context-definitions/DataProvider.js";
61
+ export * from "./context-definitions/WorkspaceContext.js";
62
+ export * from "./ShellContext.js";
63
+ export { RestrictToHorizontalAxis } from "@dnd-kit/abstract/modifiers";
64
+ export { KeyboardSensor, PointerSensor } from "@dnd-kit/dom";
65
+ export { DragDropProvider, DragOverlay, useInstance } from "@dnd-kit/react";
66
+ export { useSortable } from "@dnd-kit/react/sortable";
67
+ export { Clock } from "./Clock.js";
68
+ export { DataEditingProvider, useEditSession } from "./data-editing/DataEditingProvider.js";
69
+ export { getVuuEditMessage, isInlineEditingSession } from "./data-editing/edit-utils.js";
70
+ export { EditButtons } from "./data-editing/EditButtons.js";
71
+ export { EditSession, StaleUpdateError } from "./data-editing/EditSession.js";
72
+ export { useEditableTable } from "./data-editing/useEditableTable.js";
73
+ export { WidthHeight, WidthOnly, useResizeObserver } from "./useResizeObserver.js";
74
+ export { DataContext } from "./context-definitions/DataContext.js";
75
+ export { DataSourceProvider, useDataSource } from "./context-definitions/DataSourceProvider.js";
76
+ export { PageVisibilityObserver } from "./PageVisibilityObserver.js";
77
+ export { ThemeLoadChecker } from "./theme-utils.js";
@@ -0,0 +1,3 @@
1
+ const isCharacterKey = (key)=>1 === key.length;
2
+ const isQuoteKey = (evt)=>'"' === evt.key || "'" === evt.key;
3
+ export { isCharacterKey, isQuoteKey };
@@ -0,0 +1,9 @@
1
+ function invariant(condition, message) {
2
+ if (!condition) {
3
+ const error = new Error(message);
4
+ error.name = "Invariant Violation";
5
+ error.framesToPop = 1;
6
+ throw error;
7
+ }
8
+ }
9
+ export { invariant };
@@ -0,0 +1,9 @@
1
+ const isPlainObject = (obj)=>"[object Object]" === Object.prototype.toString.call(obj);
2
+ function itemToString(item) {
3
+ if ("string" == typeof item) return item;
4
+ if (!isPlainObject(item)) return String(item);
5
+ if (Object.prototype.hasOwnProperty.call(item, "label")) return String(item.label);
6
+ console.warn("itemToString: you've likely forgotten to set the label prop on the item object.\nYou can also provide your own `itemToString` implementation.");
7
+ return "";
8
+ }
9
+ export { itemToString };
File without changes
@@ -0,0 +1,108 @@
1
+ import { metadataKeys } from "./column-utils.js";
2
+ const { COUNT: COUNT } = metadataKeys;
3
+ const isJsonData = (value)=>"object" == typeof value && null !== value;
4
+ const vuuRowDataItemTypes = [
5
+ "boolean",
6
+ "number",
7
+ "string"
8
+ ];
9
+ const isVuuRowDataItem = (value)=>vuuRowDataItemTypes.includes(typeof value);
10
+ const getCellValue = (attribute, attributeValue)=>{
11
+ if (Array.isArray(attributeValue)) return {
12
+ attribute: `${attribute}[`,
13
+ attributeValue: "",
14
+ isLeaf: false
15
+ };
16
+ if (isJsonData(attributeValue)) return {
17
+ attribute: `${attribute}{`,
18
+ attributeValue: "",
19
+ isLeaf: false
20
+ };
21
+ if (void 0 === attributeValue) return {
22
+ attribute,
23
+ attributeValue: "undefined",
24
+ isLeaf: true
25
+ };
26
+ if (isVuuRowDataItem(attributeValue)) return {
27
+ attribute,
28
+ attributeValue,
29
+ isLeaf: true
30
+ };
31
+ throw Error(`unsupported type ${typeof attributeValue} in JSON`);
32
+ };
33
+ const jsonColumnType = {
34
+ name: "json",
35
+ renderer: {
36
+ name: "json"
37
+ }
38
+ };
39
+ const jsonToDataSourceRows = (json)=>{
40
+ const cols = [];
41
+ cols.push({
42
+ className: "vuuJsonCell",
43
+ name: "Level 1",
44
+ type: jsonColumnType
45
+ }, {
46
+ className: "vuuJsonCell",
47
+ name: "Level 2",
48
+ type: jsonColumnType
49
+ });
50
+ const rows = [];
51
+ addChildValues(rows, json, cols);
52
+ return [
53
+ cols,
54
+ rows
55
+ ];
56
+ };
57
+ const addChildValues = (rows, json, cols, index = {
58
+ value: 0
59
+ }, keyBase = "$root", depth = 0)=>{
60
+ let leafCount = 0;
61
+ let rowCount = 0;
62
+ if (depth === cols.length - 1) cols.push({
63
+ className: "vuuJsonCell",
64
+ name: `Level ${cols.length + 1}`,
65
+ hidden: true,
66
+ type: jsonColumnType
67
+ });
68
+ const columnEntries = Object.entries(json);
69
+ for(let i = 0; i < columnEntries.length; i++, index.value += 1){
70
+ const [key, value] = columnEntries[i];
71
+ const { attribute, attributeValue, isLeaf } = getCellValue(key, value);
72
+ const blanks = Array(depth).fill("");
73
+ const fullKey = `${keyBase}|${key}`;
74
+ const ts = 0;
75
+ const isNew = false;
76
+ const row = [
77
+ index.value,
78
+ index.value,
79
+ isLeaf,
80
+ false,
81
+ depth,
82
+ 0,
83
+ fullKey,
84
+ 0,
85
+ ts,
86
+ isNew,
87
+ ...blanks,
88
+ attribute,
89
+ attributeValue
90
+ ];
91
+ rows.push(row);
92
+ rowCount += 1;
93
+ if (isJsonData(value)) {
94
+ const [nestedLeafCount, nestedRowCount] = addChildValues(rows, value, cols, {
95
+ value: index.value + 1
96
+ }, fullKey, depth + 1);
97
+ row[COUNT] = nestedLeafCount;
98
+ leafCount += nestedLeafCount;
99
+ rowCount += nestedRowCount;
100
+ index.value += nestedRowCount;
101
+ } else leafCount += 1;
102
+ }
103
+ return [
104
+ leafCount,
105
+ rowCount
106
+ ];
107
+ };
108
+ export { jsonToDataSourceRows };
@@ -0,0 +1,14 @@
1
+ const ArrowUp = "ArrowUp";
2
+ const ArrowDown = "ArrowDown";
3
+ const ArrowLeft = "ArrowLeft";
4
+ const ArrowRight = "ArrowRight";
5
+ const Enter = "Enter";
6
+ const Escape = "Escape";
7
+ const Home = "Home";
8
+ const End = "End";
9
+ const PageUp = "PageUp";
10
+ const PageDown = "PageDown";
11
+ const Space = " ";
12
+ const Tab = "Tab";
13
+ const isArrowKey = (key)=>"ArrowUp" === key || "ArrowDown" === key || "ArrowLeft" === key || "ArrowRight" === key;
14
+ export { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Escape, Home, PageDown, PageUp, Space, Tab, isArrowKey };
package/src/keyset.js ADDED
@@ -0,0 +1,57 @@
1
+ const EMPTY = [];
2
+ class KeySet {
3
+ keys = new Map();
4
+ nextKeyValue = 0;
5
+ range;
6
+ constructor(range){
7
+ this.range = range;
8
+ this.init(range);
9
+ }
10
+ next(free = EMPTY) {
11
+ if (free.length > 0) return free.shift();
12
+ return this.nextKeyValue++;
13
+ }
14
+ init({ from, to }) {
15
+ this.keys.clear();
16
+ this.nextKeyValue = 0;
17
+ for(let rowIndex = from; rowIndex < to; rowIndex++){
18
+ const nextKeyValue = this.next();
19
+ this.keys.set(rowIndex, nextKeyValue);
20
+ }
21
+ return true;
22
+ }
23
+ reset(range) {
24
+ const { from, to } = range;
25
+ const newSize = to - from;
26
+ const currentSize = this.range.to - this.range.from;
27
+ this.range = range;
28
+ if (currentSize > newSize) return this.init(range);
29
+ const freeKeys = [];
30
+ this.keys.forEach((keyValue, rowIndex)=>{
31
+ if (rowIndex < from || rowIndex >= to) {
32
+ freeKeys.push(keyValue);
33
+ this.keys.delete(rowIndex);
34
+ }
35
+ });
36
+ for(let rowIndex = from; rowIndex < to; rowIndex++)if (!this.keys.has(rowIndex)) {
37
+ const nextKeyValue = this.next(freeKeys);
38
+ this.keys.set(rowIndex, nextKeyValue);
39
+ }
40
+ return false;
41
+ }
42
+ keyFor(rowIndex) {
43
+ const key = this.keys.get(rowIndex);
44
+ if (void 0 === key) {
45
+ console.log(`key not found
46
+ keys: ${this.toDebugString()}
47
+ `);
48
+ throw Error(`KeySet, no key found for rowIndex ${rowIndex}`);
49
+ }
50
+ return key;
51
+ }
52
+ toDebugString() {
53
+ return `${this.keys.size} keys
54
+ ${Array.from(this.keys.entries()).sort(([key1], [key2])=>key1 - key2).map(([k, v])=>`${k}=>${v}`).join(",")}]\n`;
55
+ }
56
+ }
57
+ export { KeySet };
File without changes
@@ -0,0 +1,5 @@
1
+ const getSelectedOption = (values, selectedValue)=>{
2
+ if (void 0 === selectedValue) return;
3
+ return values.find((option)=>option.value === selectedValue);
4
+ };
5
+ export { getSelectedOption };
@@ -0,0 +1,23 @@
1
+ const getLocalEntity = (key, deleteOnRead = false)=>{
2
+ const data = localStorage.getItem(key);
3
+ if (data) {
4
+ if (deleteOnRead) localStorage.removeItem(key);
5
+ return JSON.parse(data);
6
+ }
7
+ };
8
+ const clearLocalEntity = (key)=>{
9
+ const doomedItem = localStorage.getItem(key);
10
+ if (!doomedItem) return false;
11
+ localStorage.removeItem(key);
12
+ return true;
13
+ };
14
+ const getAllLocalEntity = (url)=>Object.entries(localStorage).filter(([key])=>key.includes(url)).map(([, value])=>JSON.parse(value));
15
+ const saveLocalEntity = (key, data)=>{
16
+ try {
17
+ localStorage.setItem(key, JSON.stringify(data));
18
+ return data;
19
+ } catch {
20
+ return;
21
+ }
22
+ };
23
+ export { clearLocalEntity, getAllLocalEntity, getLocalEntity, saveLocalEntity };
@@ -0,0 +1,52 @@
1
+ import { getCookieValue } from "./cookie-utils.js";
2
+ const logLevels = [
3
+ "error",
4
+ "warn",
5
+ "info",
6
+ "debug"
7
+ ];
8
+ const isValidLogLevel = (value)=>"string" == typeof value && logLevels.includes(value);
9
+ const DEFAULT_LOG_LEVEL = "error";
10
+ const NO_OP = ()=>void 0;
11
+ const DEFAULT_DEBUG_LEVEL = "production" === process.env.NODE_ENV ? "error" : "info";
12
+ const { loggingLevel: loggingLevel = DEFAULT_DEBUG_LEVEL } = getLoggingSettings();
13
+ const logger = (category)=>{
14
+ const debugEnabled = "debug" === loggingLevel;
15
+ const infoEnabled = debugEnabled || "info" === loggingLevel;
16
+ const warnEnabled = infoEnabled || "warn" === loggingLevel;
17
+ const errorEnabled = warnEnabled || "error" === loggingLevel;
18
+ const info = infoEnabled ? (message)=>console.info(`${Date.now()} [${category}] ${message}`) : NO_OP;
19
+ const warn = warnEnabled ? (message)=>console.warn(`[${category}] ${message}`) : NO_OP;
20
+ const debug = debugEnabled ? (message)=>console.debug(`${Date.now()} [${category}] ${message}`) : NO_OP;
21
+ const error = errorEnabled ? (message)=>console.error(`[${category}] ${message}`) : NO_OP;
22
+ if ("production" === process.env.NODE_ENV) return {
23
+ errorEnabled,
24
+ error
25
+ };
26
+ return {
27
+ debugEnabled,
28
+ infoEnabled,
29
+ warnEnabled,
30
+ errorEnabled,
31
+ info,
32
+ warn,
33
+ debug,
34
+ error
35
+ };
36
+ };
37
+ function getLoggingSettings() {
38
+ if ("u" > typeof loggingSettings) return loggingSettings;
39
+ return {
40
+ loggingLevel: getLoggingLevelFromCookie()
41
+ };
42
+ }
43
+ function getLoggingLevelFromCookie() {
44
+ const value = getCookieValue("vuu-logging-level");
45
+ if (isValidLogLevel(value)) return value;
46
+ return DEFAULT_LOG_LEVEL;
47
+ }
48
+ const getLoggingConfigForWorker = ()=>`const loggingSettings = { loggingLevel: "${getLoggingLevelFromCookie()}"};`;
49
+ const logUnhandledMessage = (message, context = "[logUnhandledStruct]")=>{
50
+ console.log(`${context} ${JSON.stringify(message)}`);
51
+ };
52
+ export { getLoggingConfigForWorker, logUnhandledMessage, logger };
@@ -0,0 +1,2 @@
1
+ const isModule = (entity)=>void 0 !== entity && "function" != typeof entity;
2
+ export { isModule };
@@ -0,0 +1,13 @@
1
+ const uuid = (size = 21)=>{
2
+ let id = '';
3
+ const bytes = crypto.getRandomValues(new Uint8Array(size));
4
+ while(size--){
5
+ const byte = 63 & bytes[size];
6
+ if (byte < 36) id += byte.toString(36);
7
+ else if (byte < 62) id += (byte - 26).toString(36).toUpperCase();
8
+ else if (byte < 63) id += '_';
9
+ else id += '-';
10
+ }
11
+ return id;
12
+ };
13
+ export { uuid };
@@ -0,0 +1,28 @@
1
+ function debounce(callback, timeInterval) {
2
+ let timeout;
3
+ return (...args)=>{
4
+ clearTimeout(timeout);
5
+ timeout = window.setTimeout(()=>callback(...args), timeInterval);
6
+ };
7
+ }
8
+ function throttle(callback, limit) {
9
+ let wait = false;
10
+ let lastArgs;
11
+ function checkLastArgs() {
12
+ if (void 0 == lastArgs) wait = false;
13
+ else {
14
+ callback(...lastArgs);
15
+ lastArgs = void 0;
16
+ setTimeout(checkLastArgs, limit);
17
+ }
18
+ }
19
+ return (...args)=>{
20
+ if (wait) lastArgs = args;
21
+ else {
22
+ callback(...args);
23
+ wait = true;
24
+ setTimeout(checkLastArgs, limit);
25
+ }
26
+ };
27
+ }
28
+ export { debounce, throttle };
@@ -0,0 +1,26 @@
1
+ class DeferredPromise {
2
+ #promise;
3
+ #resolve = ()=>console.log("resolve was not set");
4
+ #reject = ()=>console.log("reject was not set");
5
+ #resolved = false;
6
+ constructor(){
7
+ this.#promise = new Promise((resolve, reject)=>{
8
+ this.#resolve = resolve;
9
+ this.#reject = reject;
10
+ });
11
+ }
12
+ get promise() {
13
+ return this.#promise;
14
+ }
15
+ get isResolved() {
16
+ return this.#resolved;
17
+ }
18
+ resolve(value) {
19
+ this.#resolved = true;
20
+ return this.#resolve(value);
21
+ }
22
+ get reject() {
23
+ return this.#reject;
24
+ }
25
+ }
26
+ export { DeferredPromise };
@@ -0,0 +1,68 @@
1
+ import { isView } from "./component-registry.js";
2
+ const MENU_RPC_TYPES = [
3
+ "VIEW_PORT_MENUS_SELECT_RPC",
4
+ "VIEW_PORT_MENU_TABLE_RPC",
5
+ "VIEW_PORT_MENU_ROW_RPC",
6
+ "VIEW_PORT_MENU_CELL_RPC"
7
+ ];
8
+ const INVALID_SESSION = "Invalid session";
9
+ const SESSION_LIMIT_EXCEEDED = "User session limit exceeded";
10
+ const INVALID_TOKEN = "Invalid token";
11
+ const TOKEN_EXPIRED = "Token has expired";
12
+ const InvalidLoginMessages = [
13
+ INVALID_SESSION,
14
+ SESSION_LIMIT_EXCEEDED,
15
+ INVALID_TOKEN,
16
+ TOKEN_EXPIRED
17
+ ];
18
+ const isErrorMessage = (message)=>"object" == typeof message && message?.type === "ERROR";
19
+ const isLoginErrorMessage = (message)=>"string" == typeof message && InvalidLoginMessages.includes(message);
20
+ const isSelectRequest = (message)=>message && "object" == typeof message && "type" in message && ("SELECT_ROW" === message.type || "DESELECT_ROW" === message.type || "SELECT_ROW_RANGE" === message.type || "SELECT_ALL" === message.type || "DESELECT_ALL" === message.type);
21
+ const isSelectSuccessWithRowCount = (response)=>[
22
+ "SELECT_ROW_SUCCESS",
23
+ "DESELECT_ROW_SUCCESS",
24
+ "SELECT_ROW_RANGE_SUCCESS",
25
+ "SELECT_ALL_SUCCESS",
26
+ "DESELECT_ALL_SUCCESS"
27
+ ].includes(response.type ?? "") && "number" == typeof response.selectedRowCount;
28
+ const isRpcServiceRequest = (message)=>"RPC_REQUEST" === message.type;
29
+ const hasViewPortContext = (message)=>"VIEWPORT_CONTEXT" === message.context.type;
30
+ const isVuuMenuRpcRequest = (message)=>MENU_RPC_TYPES.includes(message["type"]);
31
+ const isLoginResponse = (message)=>null !== message && "object" == typeof message && "type" in message && ("LOGIN_SUCCESS" === message.type || "LOGIN_FAIL" === message.type);
32
+ const isRpcSuccess = (rpcResult)=>rpcResult?.type === "SUCCESS_RESULT";
33
+ const isRpcError = (rpcResult)=>rpcResult?.type === "ERROR_RESULT";
34
+ const isRequestResponse = (message)=>"requestId" in message;
35
+ const isOpenSessionTableDialogMessage = (rpcResponse)=>"VIEW_PORT_MENU_RESP" === rpcResponse.type && isOpenDialogAction(rpcResponse.action) && "tableSchema" in rpcResponse.action;
36
+ const isOpenDialogAction = (action)=>void 0 !== action && "OPEN_DIALOG_ACTION" === action.type;
37
+ const isTypeaheadRequest = (request)=>isRpcServiceRequest(request) && ("getUniqueFieldValues" === request.rpcName || "getUniqueFieldValuesStartingWith" === request.rpcName);
38
+ const isCreateVpSuccess = (response)=>"CREATE_VP_SUCCESS" === response.type;
39
+ const isSessionTable = (table)=>{
40
+ if (null !== table && "object" == typeof table && "table" in table && "module" in table) return table.table.startsWith("session");
41
+ return false;
42
+ };
43
+ function isActionMessage(rpcResponse) {
44
+ return "VIEW_PORT_MENU_RESP" === rpcResponse.type;
45
+ }
46
+ function isSessionTableActionMessage(rpcResponse) {
47
+ return isActionMessage(rpcResponse) && isOpenDialogAction(rpcResponse.action) && isSessionTable(rpcResponse.action.table) && (rpcResponse.action?.renderComponent === "inline-form" || rpcResponse.action?.renderComponent === "grid");
48
+ }
49
+ function isCustomComponentActionMessage(rpcResponse) {
50
+ return isActionMessage(rpcResponse) && isOpenDialogAction(rpcResponse.action) && isSessionTable(rpcResponse.action.table) && "string" == typeof rpcResponse.action.renderComponent && isView(rpcResponse.action.renderComponent);
51
+ }
52
+ const numericTypes = [
53
+ "int",
54
+ "long",
55
+ "double",
56
+ "scaleddecimal2",
57
+ "scaleddecimal4",
58
+ "scaleddecimal6",
59
+ "scaleddecimal8"
60
+ ];
61
+ function isNumericType(dataType) {
62
+ return numericTypes.includes(dataType);
63
+ }
64
+ const isAddRowRpcRequest = (rpcRequest)=>"addRow" === rpcRequest.rpcName;
65
+ const isEditCellRpcRequest = (rpcRequest)=>"editCell" === rpcRequest.rpcName;
66
+ const isBeginEditSessionRpcRequest = (rpcRequest)=>"beginEditSession" === rpcRequest.rpcName;
67
+ const isEndEditSessionRpcRequest = (rpcRequest)=>"endEditSession" === rpcRequest.rpcName;
68
+ export { INVALID_SESSION, INVALID_TOKEN, SESSION_LIMIT_EXCEEDED, TOKEN_EXPIRED, hasViewPortContext, isActionMessage, isAddRowRpcRequest, isBeginEditSessionRpcRequest, isCreateVpSuccess, isCustomComponentActionMessage, isEditCellRpcRequest, isEndEditSessionRpcRequest, isErrorMessage, isLoginErrorMessage, isLoginResponse, isNumericType, isOpenDialogAction, isOpenSessionTableDialogMessage, isRequestResponse, isRpcError, isRpcServiceRequest, isRpcSuccess, isSelectRequest, isSelectSuccessWithRowCount, isSessionTable, isSessionTableActionMessage, isTypeaheadRequest, isVuuMenuRpcRequest };
@@ -0,0 +1,109 @@
1
+ class RangeImpl {
2
+ from;
3
+ to;
4
+ #baseFrom;
5
+ #renderBufferSize = 0;
6
+ #baseTo;
7
+ constructor(from, to, renderBufferSize = 0){
8
+ this.from = from;
9
+ this.to = to;
10
+ this.#baseFrom = from;
11
+ this.#baseTo = to;
12
+ this.#renderBufferSize = renderBufferSize;
13
+ }
14
+ get reset() {
15
+ return new RangeImpl(0, this.#baseTo - this.#baseFrom, this.#renderBufferSize);
16
+ }
17
+ get withBuffer() {
18
+ return getFullRange(this, this.#renderBufferSize);
19
+ }
20
+ equals(range) {
21
+ return range.from === this.#baseFrom && range.to === this.#baseTo;
22
+ }
23
+ toJson() {
24
+ return {
25
+ from: this.from,
26
+ to: this.to,
27
+ baseFrom: this.#baseFrom,
28
+ baseTo: this.#baseTo,
29
+ renderBufferSize: this.#renderBufferSize
30
+ };
31
+ }
32
+ }
33
+ const Range = (from, to, renderBufferSize)=>new RangeImpl(from, to, renderBufferSize);
34
+ const NULL_RANGE = Range(0, 0);
35
+ function getFullRange({ from, to }, bufferSize = 0, totalRowCount = Number.MAX_SAFE_INTEGER) {
36
+ if (0 === from && 0 === to) return {
37
+ from,
38
+ to
39
+ };
40
+ if (0 === bufferSize) if (totalRowCount < from) return {
41
+ from: 0,
42
+ to: 0
43
+ };
44
+ else return {
45
+ from,
46
+ to: Math.min(to, totalRowCount)
47
+ };
48
+ {
49
+ if (0 === from) return {
50
+ from,
51
+ to: Math.min(to + bufferSize, totalRowCount)
52
+ };
53
+ const shortfallBefore = from - bufferSize < 0;
54
+ const shortfallAfter = totalRowCount - (to + bufferSize) < 0;
55
+ if (shortfallBefore && shortfallAfter) return {
56
+ from: 0,
57
+ to: totalRowCount
58
+ };
59
+ if (shortfallBefore) return {
60
+ from: 0,
61
+ to: to + bufferSize
62
+ };
63
+ if (shortfallAfter) return {
64
+ from: Math.max(0, from - bufferSize),
65
+ to: totalRowCount
66
+ };
67
+ else return {
68
+ from: from - bufferSize,
69
+ to: to + bufferSize
70
+ };
71
+ }
72
+ }
73
+ const withinRange = (value, { from, to })=>value >= from && value < to;
74
+ const rangeNewItems = ({ from: from1, to: to1 }, newRange)=>{
75
+ const { from: from2, to: to2 } = newRange;
76
+ const noOverlap = from2 >= to1 || to2 <= from1;
77
+ const newFullySubsumesOld = from2 < from1 && to2 > to1;
78
+ return noOverlap || newFullySubsumesOld ? newRange : to2 > to1 ? {
79
+ from: to1,
80
+ to: to2
81
+ } : {
82
+ from: from2,
83
+ to: from1
84
+ };
85
+ };
86
+ class WindowRange {
87
+ from;
88
+ to;
89
+ constructor(from, to){
90
+ this.from = from;
91
+ this.to = to;
92
+ }
93
+ isWithin(index) {
94
+ return withinRange(index, this);
95
+ }
96
+ overlap(from, to) {
97
+ return from >= this.to || to < this.from ? [
98
+ 0,
99
+ 0
100
+ ] : [
101
+ Math.max(from, this.from),
102
+ Math.min(to, this.to)
103
+ ];
104
+ }
105
+ copy() {
106
+ return new WindowRange(this.from, this.to);
107
+ }
108
+ }
109
+ export { NULL_RANGE, Range, WindowRange, getFullRange, rangeNewItems, withinRange };