@vanillabp/bc-ui 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +1 -1
  2. package/dist/components/CustomWorkflowModuleComponent.d.ts +13 -0
  3. package/dist/components/CustomWorkflowModuleComponent.js +54 -0
  4. package/dist/components/FulltextSearchInput.d.ts +13 -0
  5. package/dist/components/FulltextSearchInput.js +159 -0
  6. package/dist/components/ListCell.d.ts +1 -2
  7. package/dist/components/ListCell.js +3 -5
  8. package/dist/components/ListColumnHeader.d.ts +7 -3
  9. package/dist/components/ListColumnHeader.js +27 -12
  10. package/dist/components/ListOfTasks.d.ts +7 -4
  11. package/dist/components/ListOfTasks.js +245 -157
  12. package/dist/components/ListOfWorkflows.d.ts +5 -2
  13. package/dist/components/ListOfWorkflows.js +150 -260
  14. package/dist/components/SearchableAndSortableUpdatingList.d.ts +3 -3
  15. package/dist/components/SearchableAndSortableUpdatingList.js +3 -2
  16. package/dist/components/SnapScrolling.d.ts +4 -4
  17. package/dist/components/SnapScrolling.js +1 -1
  18. package/dist/components/SnapScrollingDataTable.d.ts +2 -2
  19. package/dist/components/SnapScrollingDataTable.js +42 -17
  20. package/dist/components/User.d.ts +6 -4
  21. package/dist/components/User.js +34 -27
  22. package/dist/components/UserAvatar.d.ts +5 -3
  23. package/dist/components/UserAvatar.js +7 -35
  24. package/dist/components/UserTaskPage.d.ts +2 -1
  25. package/dist/components/UserTaskPage.js +21 -7
  26. package/dist/components/WorkflowPage.d.ts +3 -2
  27. package/dist/components/WorkflowPage.js +13 -5
  28. package/dist/components/index.d.ts +8 -6
  29. package/dist/components/index.js +2 -0
  30. package/dist/index.d.ts +7 -4
  31. package/dist/types/apis.d.ts +5 -3
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/lists.d.ts +2 -1
  34. package/dist/utils/column-type.d.ts +6 -0
  35. package/dist/utils/column-type.js +11 -0
  36. package/dist/utils/index.d.ts +2 -1
  37. package/dist/utils/index.js +1 -0
  38. package/dist/utils/module-federation.d.ts +5 -5
  39. package/dist/utils/module-federation.js +90 -38
  40. package/package.json +4 -4
package/README.md CHANGED
@@ -1 +1 @@
1
- For details see [https://github.com/vanillabp/business-cockpit](https://github.com/vanillabp/business-cockpit).
1
+ For details see [https://github.com/vanillabp/business-cockpit](https://github.com/vanillabp/business-cockpit).
@@ -0,0 +1,13 @@
1
+ import { ShowLoadingIndicatorFunction, ToastFunction, TranslationFunction } from '@vanillabp/bc-shared';
2
+ import { WorkflowModule } from '@vanillabp/bc-official-gui-client';
3
+
4
+ declare const CustomWorkflowModuleComponent: ({ showLoadingIndicator, toast, workflowModule, useCase, t, entryPoint }: {
5
+ showLoadingIndicator: ShowLoadingIndicatorFunction;
6
+ toast: ToastFunction;
7
+ workflowModule: WorkflowModule;
8
+ useCase: string;
9
+ t: TranslationFunction;
10
+ entryPoint?: string | undefined;
11
+ }) => JSX.Element;
12
+
13
+ export { CustomWorkflowModuleComponent };
@@ -0,0 +1,54 @@
1
+ import "../chunk-YH4NJHER.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { UiUriType, useFederationModule } from "../utils/index.js";
4
+ import { NoElementGivenByModule } from "./NoElementGivenByModule.js";
5
+ import { useMemo } from "react";
6
+ const CustomWorkflowModuleComponent = ({
7
+ showLoadingIndicator,
8
+ toast,
9
+ workflowModule,
10
+ useCase,
11
+ t,
12
+ entryPoint = "/remoteEntry.js"
13
+ }) => {
14
+ const module = useMemo(() => ({
15
+ uiUriType: UiUriType.WebpackMfReact,
16
+ uiUri: `${workflowModule.uri}${entryPoint}`,
17
+ workflowModuleId: workflowModule.id,
18
+ workflowModuleUri: workflowModule.uri
19
+ }), [workflowModule.id, workflowModule.uri, entryPoint]);
20
+ const federatedModule = useFederationModule(module, useCase);
21
+ if (federatedModule == null ? void 0 : federatedModule.retry) {
22
+ console.error("Could not load module!");
23
+ return /* @__PURE__ */ jsx(
24
+ NoElementGivenByModule,
25
+ {
26
+ t,
27
+ loading: false,
28
+ showLoadingIndicator,
29
+ retry: federatedModule.retry
30
+ }
31
+ );
32
+ }
33
+ const Component = federatedModule && federatedModule[useCase];
34
+ if (!Component) {
35
+ return /* @__PURE__ */ jsx(
36
+ NoElementGivenByModule,
37
+ {
38
+ t,
39
+ loading: true,
40
+ showLoadingIndicator
41
+ }
42
+ );
43
+ }
44
+ return /* @__PURE__ */ jsx(
45
+ Component,
46
+ {
47
+ toast,
48
+ workflowModule
49
+ }
50
+ );
51
+ };
52
+ export {
53
+ CustomWorkflowModuleComponent
54
+ };
@@ -0,0 +1,13 @@
1
+ import { TranslationFunction } from '@vanillabp/bc-shared';
2
+
3
+ declare const FulltextSearchInput: ({ t, initialQuery, limitListToKwic, kwic, }: {
4
+ t: TranslationFunction;
5
+ initialQuery: (columnPath?: string) => string;
6
+ limitListToKwic: (columnPath: string | undefined, query?: string) => void;
7
+ kwic: (columnPath: string | undefined, query: string) => Promise<Array<{
8
+ item: string;
9
+ count: number;
10
+ }>>;
11
+ }) => JSX.Element;
12
+
13
+ export { FulltextSearchInput };
@@ -0,0 +1,159 @@
1
+ import {
2
+ __async
3
+ } from "../chunk-YH4NJHER.js";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { debounce, useResponsiveScreen } from "@vanillabp/bc-shared";
6
+ import { useMemo, useRef, useState } from "react";
7
+ import { Box, Grid, Text, TextInput, Tip } from "grommet";
8
+ import { Clear, Search } from "grommet-icons";
9
+ const FulltextSearchInput = ({
10
+ t,
11
+ initialQuery,
12
+ limitListToKwic,
13
+ kwic
14
+ }) => {
15
+ const { isPhone } = useResponsiveScreen();
16
+ const textFieldRef = useRef(null);
17
+ const [query, setQuery] = useState(initialQuery);
18
+ const currentQuery = useRef(initialQuery(void 0));
19
+ const [suggestions, setSuggestions] = useState(void 0);
20
+ const ignoreKeyEnter = useRef(false);
21
+ const select = (value, suggestion) => {
22
+ if (suggestion) {
23
+ ignoreKeyEnter.current = true;
24
+ } else if (ignoreKeyEnter.current) {
25
+ ignoreKeyEnter.current = false;
26
+ return;
27
+ }
28
+ if (value === void 0)
29
+ return;
30
+ setSuggestions(void 0);
31
+ setQuery(value);
32
+ currentQuery.current = value;
33
+ limitListToKwic(void 0, value);
34
+ };
35
+ const kwicDebounced = useMemo(() => debounce(() => __async(void 0, null, function* () {
36
+ const result = yield kwic(void 0, currentQuery.current);
37
+ const newSuggestions = result.map((r) => ({
38
+ value: r.item,
39
+ label: /* @__PURE__ */ jsxs(
40
+ Box,
41
+ {
42
+ direction: "row",
43
+ justify: "between",
44
+ pad: "xsmall",
45
+ children: [
46
+ /* @__PURE__ */ jsx(
47
+ Text,
48
+ {
49
+ weight: "bold",
50
+ truncate: "tip",
51
+ children: r.item
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx(
55
+ Box,
56
+ {
57
+ align: "right",
58
+ children: r.count
59
+ }
60
+ )
61
+ ]
62
+ }
63
+ )
64
+ }));
65
+ setSuggestions(
66
+ newSuggestions.length > 20 ? [...newSuggestions.slice(0, 20), { value: void 0, label: /* @__PURE__ */ jsx(Box, { pad: "xsmall", children: t("kwic_to-many-hits") }) }] : newSuggestions
67
+ );
68
+ }), 300), [currentQuery, setSuggestions]);
69
+ const updateResult = (newQuery) => {
70
+ currentQuery.current = newQuery;
71
+ setQuery(newQuery);
72
+ if (newQuery.length < 3) {
73
+ if (suggestions) {
74
+ setSuggestions(void 0);
75
+ }
76
+ return;
77
+ }
78
+ kwicDebounced();
79
+ };
80
+ const clear = () => {
81
+ currentQuery.current = "";
82
+ setQuery("");
83
+ setSuggestions(void 0);
84
+ textFieldRef.current.focus();
85
+ limitListToKwic(void 0, void 0);
86
+ };
87
+ return /* @__PURE__ */ jsx(
88
+ Box,
89
+ {
90
+ width: isPhone ? "100%" : "min(100%, 18rem)",
91
+ elevation: "small",
92
+ alignContent: "center",
93
+ hoverIndicator: "white",
94
+ focusIndicator: false,
95
+ round: { size: "0.4rem" },
96
+ border: { color: "dark-4" },
97
+ children: /* @__PURE__ */ jsxs(
98
+ Grid,
99
+ {
100
+ columns: ["auto", "2rem"],
101
+ fill: true,
102
+ children: [
103
+ /* @__PURE__ */ jsx(
104
+ Box,
105
+ {
106
+ pad: { horizontal: "0.4rem", vertical: "0.25rem" },
107
+ direction: "row",
108
+ justify: "center",
109
+ children: /* @__PURE__ */ jsx(
110
+ TextInput,
111
+ {
112
+ plain: "full",
113
+ ref: textFieldRef,
114
+ value: query,
115
+ placeholder: t("kwic_placeholder"),
116
+ onKeyDown: (event) => event.key === "Enter" ? select(query, false) : void 0,
117
+ onChange: (event) => updateResult(event.target.value),
118
+ suggestions: suggestions === void 0 ? [] : suggestions.length === 0 ? [{ value: void 0, label: /* @__PURE__ */ jsx(Box, { pad: "xsmall", children: t("kwic_no-hit") }) }] : suggestions,
119
+ onSuggestionSelect: (x) => select(x.suggestion.value, true),
120
+ focusIndicator: false,
121
+ reverse: true
122
+ }
123
+ )
124
+ }
125
+ ),
126
+ /* @__PURE__ */ jsx(
127
+ Tip,
128
+ {
129
+ content: t("kwic_tooltip"),
130
+ children: /* @__PURE__ */ jsx(
131
+ Box,
132
+ {
133
+ align: "center",
134
+ justify: "center",
135
+ children: Boolean(query) ? /* @__PURE__ */ jsx(
136
+ Clear,
137
+ {
138
+ onMouseUp: clear,
139
+ color: "dark-4"
140
+ }
141
+ ) : /* @__PURE__ */ jsx(
142
+ Search,
143
+ {
144
+ color: "dark-4"
145
+ }
146
+ )
147
+ }
148
+ )
149
+ }
150
+ )
151
+ ]
152
+ }
153
+ )
154
+ }
155
+ );
156
+ };
157
+ export {
158
+ FulltextSearchInput
159
+ };
@@ -12,7 +12,6 @@ declare enum TypeOfItem {
12
12
  interface ListCellParameters<T extends ListItemData & ModuleDefinition> {
13
13
  modulesAvailable: Module[];
14
14
  column: Column;
15
- defaultLanguage?: string;
16
15
  currentLanguage: string;
17
16
  nameOfList?: string;
18
17
  typeOfItem: TypeOfItem;
@@ -22,6 +21,6 @@ interface ListCellParameters<T extends ListItemData & ModuleDefinition> {
22
21
  showUnreadAsBold?: boolean;
23
22
  selectItem: (item: ListItem<T>, select: boolean) => void;
24
23
  }
25
- declare const ListCell: <T extends ListItemData & ModuleDefinition>({ modulesAvailable, column, defaultLanguage, currentLanguage, nameOfList, typeOfItem, item, t, showUnreadAsBold, defaultListCell, selectItem, }: ListCellParameters<T>) => JSX.Element;
24
+ declare const ListCell: <T extends ListItemData & ModuleDefinition>({ modulesAvailable, column, currentLanguage, nameOfList, typeOfItem, item, t, showUnreadAsBold, defaultListCell, selectItem, }: ListCellParameters<T>) => JSX.Element;
26
25
 
27
26
  export { ListCell, TypeOfItem };
@@ -4,7 +4,7 @@ import {
4
4
  useResponsiveScreen,
5
5
  WarningListCell
6
6
  } from "@vanillabp/bc-shared";
7
- import { memo } from "react";
7
+ import { memo, Suspense } from "react";
8
8
  var TypeOfItem = /* @__PURE__ */ ((TypeOfItem2) => {
9
9
  TypeOfItem2[TypeOfItem2["TaskList"] = 0] = "TaskList";
10
10
  TypeOfItem2[TypeOfItem2["WorkflowList"] = 1] = "WorkflowList";
@@ -18,7 +18,6 @@ const warningsForWorkflowCells = {};
18
18
  const ListCell = ({
19
19
  modulesAvailable,
20
20
  column,
21
- defaultLanguage = "en",
22
21
  currentLanguage,
23
22
  nameOfList,
24
23
  typeOfItem,
@@ -100,7 +99,7 @@ const ListCell = ({
100
99
  }
101
100
  );
102
101
  }
103
- return /* @__PURE__ */ jsx(
102
+ return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(
104
103
  Cell,
105
104
  {
106
105
  t,
@@ -108,14 +107,13 @@ const ListCell = ({
108
107
  column,
109
108
  showUnreadAsBold,
110
109
  currentLanguage,
111
- defaultLanguage,
112
110
  defaultCell: defaultListCell,
113
111
  nameOfList,
114
112
  isPhone,
115
113
  isTablet,
116
114
  selectItem: (select) => selectItem(item, select)
117
115
  }
118
- );
116
+ ) });
119
117
  };
120
118
  export {
121
119
  ListCell,
@@ -1,7 +1,8 @@
1
1
  import { TranslationFunction, Column, DefaultListHeaderAwareProps } from '@vanillabp/bc-shared';
2
2
  import { FC } from 'react';
3
3
 
4
- declare const ListColumnHeader: ({ t, currentLanguage, column, columnIndex, numberOfAllColumns, nameOfList, columnHeader, hasColumnWidthAdjustment, setColumnWidthAdjustment, sort, sortAscending, setSort, setSortAscending, allSelected, selectAll }: {
4
+ declare const AUTO_SIZE_COLUMN = "";
5
+ declare const ListColumnHeader: ({ t, currentLanguage, column, columnIndex, numberOfAllColumns, nameOfList, columnHeader, columnWidthAdjustment, setAutoColumnWidth, setColumnWidthAdjustment, sort, isDefaultSort, sortAscending, defaultSortAscending, setSort, setSortAscending, allSelected, selectAll }: {
5
6
  t: TranslationFunction;
6
7
  currentLanguage: string;
7
8
  column: Column;
@@ -9,14 +10,17 @@ declare const ListColumnHeader: ({ t, currentLanguage, column, columnIndex, numb
9
10
  numberOfAllColumns: number;
10
11
  nameOfList?: string | undefined;
11
12
  columnHeader?: FC<DefaultListHeaderAwareProps<any>> | undefined;
12
- hasColumnWidthAdjustment: boolean;
13
+ columnWidthAdjustment?: number | undefined;
14
+ setAutoColumnWidth: (column: Column, width: number) => void;
13
15
  setColumnWidthAdjustment: (column: Column, adjustment: number) => void;
14
16
  sort?: boolean | undefined;
17
+ isDefaultSort: boolean;
15
18
  sortAscending?: boolean | undefined;
19
+ defaultSortAscending: boolean;
16
20
  setSort: (column?: Column) => void;
17
21
  setSortAscending: (ascending: boolean) => void;
18
22
  allSelected: boolean;
19
23
  selectAll: (select: boolean) => void;
20
24
  }) => JSX.Element;
21
25
 
22
- export { ListColumnHeader };
26
+ export { AUTO_SIZE_COLUMN, ListColumnHeader };
@@ -6,6 +6,7 @@ import {
6
6
  } from "@vanillabp/bc-shared";
7
7
  import { useCallback, useEffect, useRef, useState } from "react";
8
8
  import { Box } from "grommet";
9
+ const AUTO_SIZE_COLUMN = "";
9
10
  const ListColumnHeader = ({
10
11
  t,
11
12
  currentLanguage,
@@ -14,10 +15,13 @@ const ListColumnHeader = ({
14
15
  numberOfAllColumns,
15
16
  nameOfList,
16
17
  columnHeader,
17
- hasColumnWidthAdjustment,
18
+ columnWidthAdjustment,
19
+ setAutoColumnWidth,
18
20
  setColumnWidthAdjustment,
19
21
  sort,
22
+ isDefaultSort,
20
23
  sortAscending,
24
+ defaultSortAscending,
21
25
  setSort,
22
26
  setSortAscending,
23
27
  allSelected,
@@ -25,12 +29,13 @@ const ListColumnHeader = ({
25
29
  }) => {
26
30
  const { isPhone, isTablet } = useResponsiveScreen();
27
31
  const resize = useRef(-1);
28
- const [widthAdjustment, setWidthAdjustment] = useState(0);
32
+ const [widthAdjustment, setWidthAdjustment] = useState(columnWidthAdjustment != null ? columnWidthAdjustment : 0);
29
33
  const startResize = (event) => {
30
34
  event.stopPropagation();
31
35
  event.preventDefault();
32
36
  resize.current = event.clientX;
33
37
  document.body.style.cursor = "col-resize";
38
+ moveHandler(event.nativeEvent);
34
39
  };
35
40
  const moveHandler = useCallback((ev) => {
36
41
  if (resize.current == -1)
@@ -65,14 +70,11 @@ const ListColumnHeader = ({
65
70
  ref: (element) => {
66
71
  if (element === null)
67
72
  return;
68
- if (hasColumnWidthAdjustment)
73
+ if (columnWidthAdjustment !== void 0)
69
74
  return;
70
- if (column.width !== "")
75
+ if (column.width !== AUTO_SIZE_COLUMN)
71
76
  return;
72
- setColumnWidthAdjustment(
73
- column,
74
- element.getBoundingClientRect().width
75
- );
77
+ setAutoColumnWidth(column, element.getBoundingClientRect().width);
76
78
  },
77
79
  children: [
78
80
  /* @__PURE__ */ jsx(
@@ -95,7 +97,9 @@ const ListColumnHeader = ({
95
97
  selectAll,
96
98
  allSelected,
97
99
  sort,
100
+ isDefaultSort,
98
101
  sortAscending,
102
+ defaultSortAscending,
99
103
  setSort,
100
104
  setSortAscending
101
105
  }
@@ -110,26 +114,37 @@ const ListColumnHeader = ({
110
114
  selectAll,
111
115
  allSelected,
112
116
  sort,
117
+ isDefaultSort,
113
118
  sortAscending,
119
+ defaultSortAscending,
114
120
  setSort,
115
121
  setSortAscending
116
122
  }
117
123
  )
118
124
  }
119
125
  ),
120
- column.resizeable ? /* @__PURE__ */ jsx(
126
+ /* @__PURE__ */ jsx(
121
127
  Box,
122
128
  {
123
129
  align: "center",
124
- onMouseDown: startResize,
125
- style: { cursor: "col-resize", position: "absolute", top: "-0.5rem", bottom: "-0.5rem", right: "-0.2rem", zIndex: 1e3 },
130
+ onMouseDown: column.resizeable ? startResize : void 0,
131
+ style: {
132
+ cursor: column.resizeable ? "col-resize" : "not-allowed",
133
+ position: "absolute",
134
+ top: "-0.5rem",
135
+ bottom: "-0.5rem",
136
+ right: "-0.2rem",
137
+ width: "0.5rem",
138
+ zIndex: 1e3
139
+ },
126
140
  children: "\xA0"
127
141
  }
128
- ) : void 0
142
+ )
129
143
  ]
130
144
  }
131
145
  );
132
146
  };
133
147
  export {
148
+ AUTO_SIZE_COLUMN,
134
149
  ListColumnHeader
135
150
  };
@@ -1,13 +1,13 @@
1
- import { FC } from 'react';
1
+ import React from 'react';
2
+ import { SearchQuery } from '@vanillabp/bc-official-gui-client';
2
3
  import { ShowLoadingIndicatorFunction, GuiSseHook, TranslationFunction, DefaultListHeaderAwareProps } from '@vanillabp/bc-shared';
3
4
  import { BackgroundType, ColorType } from 'grommet/utils';
4
5
  import { OpenTaskFunction, NavigateToWorkflowFunction } from '../types/navigate.js';
5
6
  import { TasklistApiHook } from '../types/apis.js';
6
7
  import { ListOfTasksHeaderFooterFunction } from '../types/lists.js';
7
- import '@vanillabp/bc-official-gui-client';
8
8
  import '@vanillabp/bc-official-gui-client/dist/models/UserTasks';
9
9
 
10
- declare const ListOfTasks: ({ showLoadingIndicator, useGuiSse, useTasklistApi, openTask, navigateToWorkflow, t, currentLanguage, defaultSort, defaultSortAscending, name, columns, children, headerHeight, footer, footerHeight, rowSeparator, applyBackgroundColor, showColumnHeaders, excludeIdColumn, columnHeader, columnHeaderBackground, columnHeaderSeparator, }: {
10
+ declare const ListOfTasks: ({ showLoadingIndicator, useGuiSse, useTasklistApi, openTask, navigateToWorkflow, t, currentLanguage, defaultSort, defaultSortAscending, name, columns, minWidthOfColumns, minWidthOfAutoColumn, children, headerHeight, footer, footerHeight, rowSeparator, applyBackgroundColor, showColumnHeaders, excludeIdColumn, columnHeader, columnHeaderBackground, columnHeaderSeparator, defaultSearchQueries, }: {
11
11
  showLoadingIndicator: ShowLoadingIndicatorFunction;
12
12
  useGuiSse: GuiSseHook;
13
13
  useTasklistApi: TasklistApiHook;
@@ -19,6 +19,8 @@ declare const ListOfTasks: ({ showLoadingIndicator, useGuiSse, useTasklistApi, o
19
19
  defaultSortAscending?: boolean | undefined;
20
20
  name?: string | undefined;
21
21
  columns?: string[] | undefined;
22
+ minWidthOfColumns?: string | undefined;
23
+ minWidthOfAutoColumn?: string | undefined;
22
24
  children?: ListOfTasksHeaderFooterFunction | undefined;
23
25
  headerHeight?: string | undefined;
24
26
  footer?: ListOfTasksHeaderFooterFunction | undefined;
@@ -27,9 +29,10 @@ declare const ListOfTasks: ({ showLoadingIndicator, useGuiSse, useTasklistApi, o
27
29
  applyBackgroundColor?: boolean | undefined;
28
30
  showColumnHeaders?: boolean | undefined;
29
31
  excludeIdColumn?: boolean | undefined;
30
- columnHeader?: FC<DefaultListHeaderAwareProps<any>> | undefined;
32
+ columnHeader?: React.FC<DefaultListHeaderAwareProps<any>> | undefined;
31
33
  columnHeaderBackground?: BackgroundType | undefined;
32
34
  columnHeaderSeparator?: ColorType | null;
35
+ defaultSearchQueries?: SearchQuery[] | undefined;
33
36
  }) => JSX.Element;
34
37
 
35
38
  export { ListOfTasks };