@vanillabp/bc-shared 0.0.3

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 (71) hide show
  1. package/README.md +101 -0
  2. package/dist/chunk-YH4NJHER.js +58 -0
  3. package/dist/components/Badge.d.ts +12 -0
  4. package/dist/components/Badge.js +84 -0
  5. package/dist/components/CircleButton.d.ts +5 -0
  6. package/dist/components/CircleButton.js +47 -0
  7. package/dist/components/CopyClipboard.d.ts +21 -0
  8. package/dist/components/CopyClipboard.js +110 -0
  9. package/dist/components/DefaultListCell.d.ts +44 -0
  10. package/dist/components/DefaultListCell.js +179 -0
  11. package/dist/components/DefaultListHeader.d.ts +22 -0
  12. package/dist/components/DefaultListHeader.js +110 -0
  13. package/dist/components/Link.d.ts +10 -0
  14. package/dist/components/Link.js +34 -0
  15. package/dist/components/LoadingIndicator.d.ts +4 -0
  16. package/dist/components/LoadingIndicator.js +48 -0
  17. package/dist/components/ModalDialog.d.ts +16 -0
  18. package/dist/components/ModalDialog.js +108 -0
  19. package/dist/components/SseProvider.d.ts +46 -0
  20. package/dist/components/SseProvider.js +134 -0
  21. package/dist/components/Toast.d.ts +22 -0
  22. package/dist/components/Toast.js +30 -0
  23. package/dist/components/UserTaskAppLayout.d.ts +9 -0
  24. package/dist/components/UserTaskAppLayout.js +47 -0
  25. package/dist/components/WarningListCell.d.ts +6 -0
  26. package/dist/components/WarningListCell.js +39 -0
  27. package/dist/components/index.d.ts +20 -0
  28. package/dist/components/index.js +12 -0
  29. package/dist/index.d.ts +36 -0
  30. package/dist/index.js +4 -0
  31. package/dist/stories/LoadingIndicator.stories.d.ts +9 -0
  32. package/dist/stories/LoadingIndicator.stories.js +18 -0
  33. package/dist/theme/index.d.ts +5 -0
  34. package/dist/theme/index.js +168 -0
  35. package/dist/types/BcUserTask.d.ts +12 -0
  36. package/dist/types/BcUserTask.js +1 -0
  37. package/dist/types/BcWorkflow.d.ts +11 -0
  38. package/dist/types/BcWorkflow.js +1 -0
  39. package/dist/types/ListCell.d.ts +30 -0
  40. package/dist/types/ListCell.js +15 -0
  41. package/dist/types/UserTaskForm.d.ts +10 -0
  42. package/dist/types/UserTaskForm.js +0 -0
  43. package/dist/types/UserTaskListCell.d.ts +16 -0
  44. package/dist/types/UserTaskListCell.js +0 -0
  45. package/dist/types/WorkflowListCell.d.ts +17 -0
  46. package/dist/types/WorkflowListCell.js +0 -0
  47. package/dist/types/WorkflowPage.d.ts +11 -0
  48. package/dist/types/WorkflowPage.js +0 -0
  49. package/dist/types/index.d.ts +14 -0
  50. package/dist/types/index.js +8 -0
  51. package/dist/types/translate.d.ts +3 -0
  52. package/dist/types/translate.js +0 -0
  53. package/dist/utils/clickOutside.d.ts +6 -0
  54. package/dist/utils/clickOutside.js +20 -0
  55. package/dist/utils/debounce.d.ts +9 -0
  56. package/dist/utils/debounce.js +27 -0
  57. package/dist/utils/fetchApi.d.ts +10 -0
  58. package/dist/utils/fetchApi.js +76 -0
  59. package/dist/utils/i18n.d.ts +3 -0
  60. package/dist/utils/i18n.js +5 -0
  61. package/dist/utils/index.d.ts +13 -0
  62. package/dist/utils/index.js +8 -0
  63. package/dist/utils/now-hook.d.ts +7 -0
  64. package/dist/utils/now-hook.js +30 -0
  65. package/dist/utils/objectUtils.d.ts +5 -0
  66. package/dist/utils/objectUtils.js +95 -0
  67. package/dist/utils/responsiveUtils.d.ts +13 -0
  68. package/dist/utils/responsiveUtils.js +18 -0
  69. package/dist/utils/timeUtils.d.ts +14 -0
  70. package/dist/utils/timeUtils.js +107 -0
  71. package/package.json +76 -0
@@ -0,0 +1,20 @@
1
+ export { LoadingIndicator, ShowLoadingIndicatorFunction } from './LoadingIndicator.js';
2
+ export { EventMessage, EventSourceMessage, GuiSseHook, OnMessageFunction, SseContextInterface, SseProvider, WakeupSseCallback, useSse } from './SseProvider.js';
3
+ export { MessageToast, Toast, ToastAction, ToastFunction } from './Toast.js';
4
+ export { Badge } from './Badge.js';
5
+ export { CircleButton } from './CircleButton.js';
6
+ export { Link } from './Link.js';
7
+ export { Modal } from './ModalDialog.js';
8
+ export { UserTaskAppLayout } from './UserTaskAppLayout.js';
9
+ export { WarningListCell } from './WarningListCell.js';
10
+ export { Alignment, DefaultListCell, DefaultListCellAwareProps, DefaultListCellProps, ENDED_FONT_COLOR, ENDED_FONT_COLOR_ODD, ListCell, TextListCell, colorForEndedItemsOrUndefined, colorRowAccordingToUpdateStatus } from './DefaultListCell.js';
11
+ export { DefaultListHeader, DefaultListHeaderAwareProps, DefaultListHeaderProps } from './DefaultListHeader.js';
12
+ export { CopyClipboard, CopyClipboardButton } from './CopyClipboard.js';
13
+ import '@microsoft/fetch-event-source';
14
+ import 'react';
15
+ import 'grommet';
16
+ import 'grommet/utils';
17
+ import 'i18next';
18
+ import 'grommet/utils/index.js';
19
+ import '../types/ListCell.js';
20
+ import '../types/translate.js';
@@ -0,0 +1,12 @@
1
+ export * from "./LoadingIndicator.js";
2
+ export * from "./SseProvider.js";
3
+ export * from "./Toast.js";
4
+ export * from "./Badge.js";
5
+ export * from "./CircleButton.js";
6
+ export * from "./Link.js";
7
+ export * from "./ModalDialog.js";
8
+ export * from "./UserTaskAppLayout.js";
9
+ export * from "./WarningListCell.js";
10
+ export * from "./DefaultListCell.js";
11
+ export * from "./DefaultListHeader.js";
12
+ export * from "./CopyClipboard.js";
@@ -0,0 +1,36 @@
1
+ export { LoadingIndicator, ShowLoadingIndicatorFunction } from './components/LoadingIndicator.js';
2
+ export { EventMessage, EventSourceMessage, GuiSseHook, OnMessageFunction, SseContextInterface, SseProvider, WakeupSseCallback, useSse } from './components/SseProvider.js';
3
+ export { MessageToast, Toast, ToastAction, ToastFunction } from './components/Toast.js';
4
+ export { Badge } from './components/Badge.js';
5
+ export { CircleButton } from './components/CircleButton.js';
6
+ export { Link } from './components/Link.js';
7
+ export { Modal } from './components/ModalDialog.js';
8
+ export { UserTaskAppLayout } from './components/UserTaskAppLayout.js';
9
+ export { WarningListCell } from './components/WarningListCell.js';
10
+ export { Alignment, DefaultListCell, DefaultListCellAwareProps, DefaultListCellProps, ENDED_FONT_COLOR, ENDED_FONT_COLOR_ODD, ListCell, TextListCell, colorForEndedItemsOrUndefined, colorRowAccordingToUpdateStatus } from './components/DefaultListCell.js';
11
+ export { DefaultListHeader, DefaultListHeaderAwareProps, DefaultListHeaderProps } from './components/DefaultListHeader.js';
12
+ export { CopyClipboard, CopyClipboardButton } from './components/CopyClipboard.js';
13
+ export { useOnClickOutside } from './utils/clickOutside.js';
14
+ export { debounce, debounceByKey } from './utils/debounce.js';
15
+ export { REFRESH_TOKEN_HEADER, buildFetchApi } from './utils/fetchApi.js';
16
+ export { now, registerEachSecondHook, unregisterEachSecondHook, useKeepNowUpToDate } from './utils/now-hook.js';
17
+ export { useResponsiveScreen } from './utils/responsiveUtils.js';
18
+ export { currentHour, hoursBetween, isValidLocalDate, nextHours, numberOfHoursBetween, parseLocalDate, parseLocalDateToIsoString, timeAsString, toLocalDateString, toLocaleDateString, toLocaleStringWithoutSeconds, toLocaleTimeStringWithoutSeconds } from './utils/timeUtils.js';
19
+ export { getObjectProperty, keepOldItemsInArray, mergeTwoSortedArrays } from './utils/objectUtils.js';
20
+ export { i18n } from './utils/i18n.js';
21
+ export { theme } from './theme/index.js';
22
+ export { UserTaskForm } from './types/UserTaskForm.js';
23
+ export { ColumnsOfUserTaskFunction, UserTaskListCell } from './types/UserTaskListCell.js';
24
+ export { Column, ListItem, ListItemStatus } from './types/ListCell.js';
25
+ export { WorkflowPage } from './types/WorkflowPage.js';
26
+ export { ColumnsOfWorkflowFunction, WorkflowListCell } from './types/WorkflowListCell.js';
27
+ export { BcWorkflow, GetUserTasksFunction, NavigateToWorkflowFunction } from './types/BcWorkflow.js';
28
+ export { BcUserTask, OpenUserTaskFunction, OpenWorkflowFunction, UnassignFunction } from './types/BcUserTask.js';
29
+ export { TranslationFunction } from './types/translate.js';
30
+ import '@microsoft/fetch-event-source';
31
+ import 'react';
32
+ import 'grommet';
33
+ import 'grommet/utils';
34
+ import 'i18next';
35
+ import 'grommet/utils/index.js';
36
+ import '@vanillabp/bc-official-gui-client';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./components/index.js";
2
+ export * from "./utils/index.js";
3
+ export * from "./theme/index.js";
4
+ export * from "./types/index.js";
@@ -0,0 +1,9 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { LoadingIndicator } from '../components/LoadingIndicator.js';
3
+
4
+ declare const meta: Meta<typeof LoadingIndicator>;
5
+
6
+ declare type Story = StoryObj<typeof LoadingIndicator>;
7
+ declare const Primary: Story;
8
+
9
+ export { Primary, meta as default };
@@ -0,0 +1,18 @@
1
+ import "../chunk-YH4NJHER.js";
2
+ import { LoadingIndicator } from "../components/LoadingIndicator";
3
+ const meta = {
4
+ title: "components/LoadingIndicator",
5
+ component: LoadingIndicator,
6
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
7
+ tags: ["autodocs"],
8
+ // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
9
+ argTypes: {
10
+ backgroundColor: { control: "color" }
11
+ }
12
+ };
13
+ var LoadingIndicator_stories_default = meta;
14
+ const Primary = {};
15
+ export {
16
+ Primary,
17
+ LoadingIndicator_stories_default as default
18
+ };
@@ -0,0 +1,5 @@
1
+ import { ThemeType } from 'grommet';
2
+
3
+ declare const theme: ThemeType;
4
+
5
+ export { theme };
@@ -0,0 +1,168 @@
1
+ import "../chunk-YH4NJHER.js";
2
+ import { css } from "styled-components";
3
+ const theme = {
4
+ global: {
5
+ colors: {
6
+ brand: "#e2e2e2",
7
+ "accent-1": "#ffe699",
8
+ "accent-2": "#bf9000",
9
+ "accent-3": "#663300",
10
+ "accent-4": "#333333",
11
+ "placeholder": "#bbbbbb",
12
+ "light-5": "#c7c7c7",
13
+ "light-6": "#b4b4b4"
14
+ },
15
+ font: {
16
+ family: "Roboto",
17
+ size: "18px",
18
+ height: "20px"
19
+ },
20
+ focus: {
21
+ border: {
22
+ color: "#e0a244"
23
+ },
24
+ outline: {
25
+ color: "#e0a244"
26
+ }
27
+ }
28
+ },
29
+ table: {
30
+ header: {
31
+ border: void 0
32
+ },
33
+ body: {
34
+ border: void 0,
35
+ extend: css`
36
+ overflow: visible;
37
+ `
38
+ }
39
+ },
40
+ heading: {
41
+ color: "#444444",
42
+ extend: css`
43
+ margin-top: 0;
44
+ `
45
+ },
46
+ formField: {
47
+ label: {
48
+ requiredIndicator: true
49
+ }
50
+ },
51
+ textArea: {
52
+ extend: css`
53
+ font-weight: normal;
54
+ ::placeholder {
55
+ font-weight: normal;
56
+ color: ${(props) => props.theme.global.colors.placeholder};
57
+ }
58
+ `
59
+ },
60
+ maskedInput: {
61
+ extend: css`
62
+ ::placeholder {
63
+ font-weight: normal;
64
+ color: ${(props) => props.theme.global.colors.placeholder};
65
+ }
66
+ `
67
+ },
68
+ textInput: {
69
+ extend: css`
70
+ ::placeholder {
71
+ font-weight: normal;
72
+ color: ${(props) => props.theme.global.colors.placeholder};
73
+ }
74
+ `,
75
+ placeholder: {
76
+ extend: css`
77
+ font-weight: normal;
78
+ color: ${(props) => props.theme.global.colors.placeholder};
79
+ `
80
+ }
81
+ },
82
+ button: {
83
+ default: {
84
+ background: "#ffffff",
85
+ border: { color: "accent-1", width: "3px" },
86
+ color: "accent-3"
87
+ },
88
+ primary: {
89
+ background: "accent-1",
90
+ border: { color: "accent-2", width: "3px" },
91
+ color: "accent-3"
92
+ },
93
+ secondary: {
94
+ background: "accent-2",
95
+ border: { color: "accent-3", width: "3px" },
96
+ color: "accent-1"
97
+ },
98
+ hover: {
99
+ default: {
100
+ background: "accent-1",
101
+ color: "accent-3"
102
+ },
103
+ primary: {
104
+ background: "accent-2",
105
+ color: "accent-1"
106
+ },
107
+ secondary: {
108
+ background: "accent-3",
109
+ color: "accent-1"
110
+ }
111
+ },
112
+ disabled: {
113
+ opacity: 1,
114
+ color: "dark-4",
115
+ background: "light-2",
116
+ border: { color: "light-4" }
117
+ }
118
+ },
119
+ accordion: {
120
+ heading: {
121
+ margin: "small"
122
+ },
123
+ icons: {
124
+ color: "accent-3"
125
+ }
126
+ },
127
+ dataTable: {
128
+ pinned: {
129
+ header: {
130
+ background: {
131
+ color: "accent-2",
132
+ opacity: "strong"
133
+ },
134
+ extend: css`
135
+ z-index: 19;
136
+ `
137
+ }
138
+ }
139
+ },
140
+ page: {
141
+ wide: {
142
+ width: {
143
+ min: "small",
144
+ max: "xlarge"
145
+ }
146
+ }
147
+ },
148
+ paragraph: {
149
+ extend: css`
150
+ margin-top: 0;
151
+ `
152
+ },
153
+ checkBox: {
154
+ size: "20px",
155
+ color: "black"
156
+ },
157
+ tip: {
158
+ content: {
159
+ background: "white"
160
+ }
161
+ },
162
+ layer: {
163
+ zIndex: "100"
164
+ }
165
+ };
166
+ export {
167
+ theme
168
+ };
@@ -0,0 +1,12 @@
1
+ import { UserTask } from '@vanillabp/bc-official-gui-client';
2
+
3
+ declare type OpenUserTaskFunction = () => void;
4
+ declare type OpenWorkflowFunction = () => void;
5
+ declare type UnassignFunction = (userId: string) => void;
6
+ interface BcUserTask extends UserTask {
7
+ open: OpenUserTaskFunction;
8
+ navigateToWorkflow: OpenWorkflowFunction;
9
+ unassign: UnassignFunction;
10
+ }
11
+
12
+ export { BcUserTask, OpenUserTaskFunction, OpenWorkflowFunction, UnassignFunction };
@@ -0,0 +1 @@
1
+ ;
@@ -0,0 +1,11 @@
1
+ import { Workflow } from '@vanillabp/bc-official-gui-client';
2
+ import { BcUserTask } from './BcUserTask.js';
3
+
4
+ declare type GetUserTasksFunction = (activeOnly: boolean, limitListAccordingToCurrentUsersPermissions: boolean) => Promise<Array<BcUserTask>>;
5
+ declare type NavigateToWorkflowFunction = () => void;
6
+ interface BcWorkflow extends Workflow {
7
+ navigateToWorkflow: NavigateToWorkflowFunction;
8
+ getUserTasks: GetUserTasksFunction;
9
+ }
10
+
11
+ export { BcWorkflow, GetUserTasksFunction, NavigateToWorkflowFunction };
@@ -0,0 +1 @@
1
+ ;
@@ -0,0 +1,30 @@
1
+ interface Title {
2
+ [key: string]: string;
3
+ }
4
+ interface Column {
5
+ title: Title;
6
+ path: string;
7
+ priority: number;
8
+ width: string;
9
+ show: boolean;
10
+ sortable: boolean;
11
+ filterable: boolean;
12
+ resizeable: boolean;
13
+ }
14
+ declare enum ListItemStatus {
15
+ INITIAL = 0,
16
+ NEW = 1,
17
+ UPDATED = 2,
18
+ ENDED = 3,
19
+ REMOVED_FROM_LIST = 4
20
+ }
21
+ interface ListItem<D> {
22
+ id: string;
23
+ number: number;
24
+ data: D;
25
+ status: ListItemStatus;
26
+ selected: boolean;
27
+ read?: Date;
28
+ }
29
+
30
+ export { Column, ListItem, ListItemStatus };
@@ -0,0 +1,15 @@
1
+ import "../chunk-YH4NJHER.js";
2
+ ;
3
+ var ListItemStatus = /* @__PURE__ */ ((ListItemStatus2) => {
4
+ ListItemStatus2[ListItemStatus2["INITIAL"] = 0] = "INITIAL";
5
+ ListItemStatus2[ListItemStatus2["NEW"] = 1] = "NEW";
6
+ ListItemStatus2[ListItemStatus2["UPDATED"] = 2] = "UPDATED";
7
+ ListItemStatus2[ListItemStatus2["ENDED"] = 3] = "ENDED";
8
+ ListItemStatus2[ListItemStatus2["REMOVED_FROM_LIST"] = 4] = "REMOVED_FROM_LIST";
9
+ return ListItemStatus2;
10
+ })(ListItemStatus || {});
11
+ ;
12
+ ;
13
+ export {
14
+ ListItemStatus
15
+ };
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ import { BcUserTask } from './BcUserTask.js';
3
+ import '@vanillabp/bc-official-gui-client';
4
+
5
+ interface UserTaskFormProps {
6
+ userTask: BcUserTask;
7
+ }
8
+ declare type UserTaskForm = FC<UserTaskFormProps>;
9
+
10
+ export { UserTaskForm };
File without changes
@@ -0,0 +1,16 @@
1
+ import { FC } from 'react';
2
+ import { UserTask } from '@vanillabp/bc-official-gui-client';
3
+ import { BcUserTask } from './BcUserTask.js';
4
+ import { Column } from './ListCell.js';
5
+ import { DefaultListCellAwareProps } from '../components/DefaultListCell.js';
6
+ import 'grommet';
7
+ import 'grommet/utils/index.js';
8
+ import 'grommet/utils';
9
+ import './translate.js';
10
+
11
+ interface UserTaskListCellProps extends DefaultListCellAwareProps<BcUserTask> {
12
+ }
13
+ declare type UserTaskListCell = FC<UserTaskListCellProps>;
14
+ declare type ColumnsOfUserTaskFunction = (userTask: UserTask) => Column[] | undefined;
15
+
16
+ export { ColumnsOfUserTaskFunction, UserTaskListCell };
File without changes
@@ -0,0 +1,17 @@
1
+ import { FC } from 'react';
2
+ import { Workflow } from '@vanillabp/bc-official-gui-client';
3
+ import { DefaultListCellAwareProps } from '../components/DefaultListCell.js';
4
+ import { Column } from './ListCell.js';
5
+ import { BcWorkflow } from './BcWorkflow.js';
6
+ import 'grommet';
7
+ import 'grommet/utils/index.js';
8
+ import 'grommet/utils';
9
+ import './translate.js';
10
+ import './BcUserTask.js';
11
+
12
+ interface WorkflowCellProps extends DefaultListCellAwareProps<BcWorkflow> {
13
+ }
14
+ declare type WorkflowListCell = FC<WorkflowCellProps>;
15
+ declare type ColumnsOfWorkflowFunction = (workflow: Workflow) => Column[] | undefined;
16
+
17
+ export { ColumnsOfWorkflowFunction, WorkflowListCell };
File without changes
@@ -0,0 +1,11 @@
1
+ import { FC } from 'react';
2
+ import { BcWorkflow } from './BcWorkflow.js';
3
+ import '@vanillabp/bc-official-gui-client';
4
+ import './BcUserTask.js';
5
+
6
+ interface WorkflowPageProps {
7
+ workflow: BcWorkflow;
8
+ }
9
+ declare type WorkflowPage = FC<WorkflowPageProps>;
10
+
11
+ export { WorkflowPage };
File without changes
@@ -0,0 +1,14 @@
1
+ export { UserTaskForm } from './UserTaskForm.js';
2
+ export { ColumnsOfUserTaskFunction, UserTaskListCell } from './UserTaskListCell.js';
3
+ export { Column, ListItem, ListItemStatus } from './ListCell.js';
4
+ export { WorkflowPage } from './WorkflowPage.js';
5
+ export { ColumnsOfWorkflowFunction, WorkflowListCell } from './WorkflowListCell.js';
6
+ export { BcWorkflow, GetUserTasksFunction, NavigateToWorkflowFunction } from './BcWorkflow.js';
7
+ export { BcUserTask, OpenUserTaskFunction, OpenWorkflowFunction, UnassignFunction } from './BcUserTask.js';
8
+ export { TranslationFunction } from './translate.js';
9
+ import 'react';
10
+ import '@vanillabp/bc-official-gui-client';
11
+ import '../components/DefaultListCell.js';
12
+ import 'grommet';
13
+ import 'grommet/utils/index.js';
14
+ import 'grommet/utils';
@@ -0,0 +1,8 @@
1
+ export * from "./UserTaskForm.js";
2
+ export * from "./UserTaskListCell.js";
3
+ export * from "./ListCell.js";
4
+ export * from "./WorkflowPage.js";
5
+ export * from "./WorkflowListCell.js";
6
+ export * from "./BcWorkflow.js";
7
+ export * from "./BcUserTask.js";
8
+ export * from "./translate.js";
@@ -0,0 +1,3 @@
1
+ declare type TranslationFunction = (key: string) => string;
2
+
3
+ export { TranslationFunction };
File without changes
@@ -0,0 +1,6 @@
1
+ import { RefObject } from 'react';
2
+
3
+ declare type Handler = (event: MouseEvent) => void;
4
+ declare function useOnClickOutside<T extends HTMLElement = HTMLElement>(ref: RefObject<T>, handler: Handler, mouseEvent?: 'mousedown' | 'mouseup'): void;
5
+
6
+ export { useOnClickOutside };
@@ -0,0 +1,20 @@
1
+ import "../chunk-YH4NJHER.js";
2
+ import { useEventListener } from "usehooks-ts";
3
+ function useOnClickOutside(ref, handler, mouseEvent = "mousedown") {
4
+ useEventListener(
5
+ mouseEvent,
6
+ (event) => {
7
+ const el = ref == null ? void 0 : ref.current;
8
+ if (!el || el.contains(event.target)) {
9
+ return;
10
+ }
11
+ handler(event);
12
+ },
13
+ void 0,
14
+ // window
15
+ { capture: true }
16
+ );
17
+ }
18
+ export {
19
+ useOnClickOutside
20
+ };
@@ -0,0 +1,9 @@
1
+ declare type Params = any[];
2
+ declare type Func = (...args: Params) => void;
3
+ declare type Debounce = (func: Func, timeout?: number) => Func;
4
+ declare const debounce: Debounce;
5
+ declare type FuncForKey = () => void;
6
+ declare type DebounceByKey = (key: string, func?: FuncForKey, timeout?: number) => void;
7
+ declare const debounceByKey: DebounceByKey;
8
+
9
+ export { debounce, debounceByKey };
@@ -0,0 +1,27 @@
1
+ import "../chunk-YH4NJHER.js";
2
+ const debounce = (func, timeout = 300) => {
3
+ let timer;
4
+ return (...args) => {
5
+ window.clearTimeout(timer);
6
+ timer = window.setTimeout(() => {
7
+ func(...args);
8
+ }, timeout);
9
+ };
10
+ };
11
+ const timers = {};
12
+ const debounceByKey = (key, func, timeout = 300) => {
13
+ const prevTimer = timers[key];
14
+ if (prevTimer) {
15
+ window.clearTimeout(prevTimer);
16
+ delete timers[key];
17
+ }
18
+ if (func) {
19
+ timers[key] = window.setTimeout(() => {
20
+ func();
21
+ }, timeout);
22
+ }
23
+ };
24
+ export {
25
+ debounce,
26
+ debounceByKey
27
+ };
@@ -0,0 +1,10 @@
1
+ import { Dispatch } from 'react';
2
+ import { WakeupSseCallback } from '../components/SseProvider.js';
3
+ import { ToastAction } from '../components/Toast.js';
4
+ import '@microsoft/fetch-event-source';
5
+ import 'grommet';
6
+
7
+ declare const REFRESH_TOKEN_HEADER = "x-refresh-token";
8
+ declare const buildFetchApi: (dispatch: Dispatch<ToastAction>, wakeupSeeCallback?: WakeupSseCallback) => WindowOrWorkerGlobalScope['fetch'];
9
+
10
+ export { REFRESH_TOKEN_HEADER, buildFetchApi };
@@ -0,0 +1,76 @@
1
+ import {
2
+ __async,
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "../chunk-YH4NJHER.js";
6
+ const REFRESH_TOKEN_HEADER = "x-refresh-token";
7
+ const doRequest = (dispatch, resolve, reject, input, init, refreshToken) => {
8
+ navigator.locks.request(
9
+ "bc-webapp",
10
+ {
11
+ mode: Boolean(refreshToken) ? "exclusive" : "shared"
12
+ },
13
+ (_lock) => __async(void 0, null, function* () {
14
+ try {
15
+ const storedRefreshToken = window.localStorage.getItem(REFRESH_TOKEN_HEADER);
16
+ const isRefresh = Boolean(storedRefreshToken) && storedRefreshToken === refreshToken;
17
+ const initWithRefreshToken = !isRefresh ? init : __spreadProps(__spreadValues({}, init), {
18
+ headers: __spreadProps(__spreadValues({}, init == null ? void 0 : init.headers), {
19
+ [REFRESH_TOKEN_HEADER]: storedRefreshToken
20
+ })
21
+ });
22
+ const response = yield fetch(input, initWithRefreshToken);
23
+ const responseRefreshToken = response.headers.get(REFRESH_TOKEN_HEADER);
24
+ if (responseRefreshToken) {
25
+ window.localStorage.setItem(REFRESH_TOKEN_HEADER, responseRefreshToken);
26
+ }
27
+ if (response.redirected) {
28
+ document.location.href = response.url;
29
+ return;
30
+ }
31
+ if (response.status === 401) {
32
+ if (isRefresh && !Boolean(responseRefreshToken)) {
33
+ window.localStorage.removeItem(REFRESH_TOKEN_HEADER);
34
+ } else if (Boolean(storedRefreshToken)) {
35
+ doRequest(dispatch, resolve, reject, input, init, storedRefreshToken);
36
+ return;
37
+ }
38
+ } else if (response.status >= 500) {
39
+ dispatch({ type: "toast", toast: {
40
+ namespace: "app",
41
+ title: "error",
42
+ message: "unexpected"
43
+ } });
44
+ } else if (response.status === 403) {
45
+ dispatch({ type: "toast", toast: {
46
+ namespace: "app",
47
+ title: "error",
48
+ message: "forbidden"
49
+ } });
50
+ }
51
+ resolve(response);
52
+ } catch (error) {
53
+ dispatch({ type: "toast", toast: {
54
+ namespace: "app",
55
+ title: "error",
56
+ message: "unexpected"
57
+ } });
58
+ reject(error);
59
+ }
60
+ })
61
+ );
62
+ };
63
+ const buildFetchApi = (dispatch, wakeupSeeCallback) => {
64
+ return (input, init) => {
65
+ return new Promise((resolve, reject) => {
66
+ if (wakeupSeeCallback !== void 0) {
67
+ wakeupSeeCallback();
68
+ }
69
+ doRequest(dispatch, resolve, reject, input, init);
70
+ });
71
+ };
72
+ };
73
+ export {
74
+ REFRESH_TOKEN_HEADER,
75
+ buildFetchApi
76
+ };
@@ -0,0 +1,3 @@
1
+ declare const i18n: any;
2
+
3
+ export { i18n };
@@ -0,0 +1,5 @@
1
+ import "../chunk-YH4NJHER.js";
2
+ const i18n = window.i18n;
3
+ export {
4
+ i18n
5
+ };
@@ -0,0 +1,13 @@
1
+ export { useOnClickOutside } from './clickOutside.js';
2
+ export { debounce, debounceByKey } from './debounce.js';
3
+ export { REFRESH_TOKEN_HEADER, buildFetchApi } from './fetchApi.js';
4
+ export { now, registerEachSecondHook, unregisterEachSecondHook, useKeepNowUpToDate } from './now-hook.js';
5
+ export { useResponsiveScreen } from './responsiveUtils.js';
6
+ export { currentHour, hoursBetween, isValidLocalDate, nextHours, numberOfHoursBetween, parseLocalDate, parseLocalDateToIsoString, timeAsString, toLocalDateString, toLocaleDateString, toLocaleStringWithoutSeconds, toLocaleTimeStringWithoutSeconds } from './timeUtils.js';
7
+ export { getObjectProperty, keepOldItemsInArray, mergeTwoSortedArrays } from './objectUtils.js';
8
+ export { i18n } from './i18n.js';
9
+ import 'react';
10
+ import '../components/SseProvider.js';
11
+ import '@microsoft/fetch-event-source';
12
+ import '../components/Toast.js';
13
+ import 'grommet';
@@ -0,0 +1,8 @@
1
+ export * from "./clickOutside.js";
2
+ export * from "./debounce.js";
3
+ export * from "./fetchApi.js";
4
+ export * from "./now-hook.js";
5
+ export * from "./responsiveUtils.js";
6
+ export * from "./timeUtils.js";
7
+ export * from "./objectUtils.js";
8
+ export * from "./i18n.js";