@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.
- package/README.md +101 -0
- package/dist/chunk-YH4NJHER.js +58 -0
- package/dist/components/Badge.d.ts +12 -0
- package/dist/components/Badge.js +84 -0
- package/dist/components/CircleButton.d.ts +5 -0
- package/dist/components/CircleButton.js +47 -0
- package/dist/components/CopyClipboard.d.ts +21 -0
- package/dist/components/CopyClipboard.js +110 -0
- package/dist/components/DefaultListCell.d.ts +44 -0
- package/dist/components/DefaultListCell.js +179 -0
- package/dist/components/DefaultListHeader.d.ts +22 -0
- package/dist/components/DefaultListHeader.js +110 -0
- package/dist/components/Link.d.ts +10 -0
- package/dist/components/Link.js +34 -0
- package/dist/components/LoadingIndicator.d.ts +4 -0
- package/dist/components/LoadingIndicator.js +48 -0
- package/dist/components/ModalDialog.d.ts +16 -0
- package/dist/components/ModalDialog.js +108 -0
- package/dist/components/SseProvider.d.ts +46 -0
- package/dist/components/SseProvider.js +134 -0
- package/dist/components/Toast.d.ts +22 -0
- package/dist/components/Toast.js +30 -0
- package/dist/components/UserTaskAppLayout.d.ts +9 -0
- package/dist/components/UserTaskAppLayout.js +47 -0
- package/dist/components/WarningListCell.d.ts +6 -0
- package/dist/components/WarningListCell.js +39 -0
- package/dist/components/index.d.ts +20 -0
- package/dist/components/index.js +12 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +4 -0
- package/dist/stories/LoadingIndicator.stories.d.ts +9 -0
- package/dist/stories/LoadingIndicator.stories.js +18 -0
- package/dist/theme/index.d.ts +5 -0
- package/dist/theme/index.js +168 -0
- package/dist/types/BcUserTask.d.ts +12 -0
- package/dist/types/BcUserTask.js +1 -0
- package/dist/types/BcWorkflow.d.ts +11 -0
- package/dist/types/BcWorkflow.js +1 -0
- package/dist/types/ListCell.d.ts +30 -0
- package/dist/types/ListCell.js +15 -0
- package/dist/types/UserTaskForm.d.ts +10 -0
- package/dist/types/UserTaskForm.js +0 -0
- package/dist/types/UserTaskListCell.d.ts +16 -0
- package/dist/types/UserTaskListCell.js +0 -0
- package/dist/types/WorkflowListCell.d.ts +17 -0
- package/dist/types/WorkflowListCell.js +0 -0
- package/dist/types/WorkflowPage.d.ts +11 -0
- package/dist/types/WorkflowPage.js +0 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.js +8 -0
- package/dist/types/translate.d.ts +3 -0
- package/dist/types/translate.js +0 -0
- package/dist/utils/clickOutside.d.ts +6 -0
- package/dist/utils/clickOutside.js +20 -0
- package/dist/utils/debounce.d.ts +9 -0
- package/dist/utils/debounce.js +27 -0
- package/dist/utils/fetchApi.d.ts +10 -0
- package/dist/utils/fetchApi.js +76 -0
- package/dist/utils/i18n.d.ts +3 -0
- package/dist/utils/i18n.js +5 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/now-hook.d.ts +7 -0
- package/dist/utils/now-hook.js +30 -0
- package/dist/utils/objectUtils.d.ts +5 -0
- package/dist/utils/objectUtils.js +95 -0
- package/dist/utils/responsiveUtils.d.ts +13 -0
- package/dist/utils/responsiveUtils.js +18 -0
- package/dist/utils/timeUtils.d.ts +14 -0
- package/dist/utils/timeUtils.js +107 -0
- package/package.json +76 -0
package/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Use in workflow modules
|
|
2
|
+
|
|
3
|
+
Example:
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { LoadingIndicator } from '@vanillabp/bc-shared';
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Read the next sections for instructions of installation.
|
|
10
|
+
|
|
11
|
+
## package.json
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @vanillabp/bc-shared
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Development
|
|
18
|
+
|
|
19
|
+
For local development of user-task forms in workflow modules one can
|
|
20
|
+
|
|
21
|
+
1. [build this package locally](#build)
|
|
22
|
+
1. Link the package `npm link`
|
|
23
|
+
1. Get current package-version `npm -g list` (e.g. `@vanillabp/bc-shared@0.0.1`)
|
|
24
|
+
1. Change to webapp folder of the workflow module
|
|
25
|
+
1. Link the global package `npm link @vanillabp/bc-shared@0.0.1` (this needs to be repeated after each `npm install`)
|
|
26
|
+
|
|
27
|
+
### Webpack
|
|
28
|
+
|
|
29
|
+
Also Webpack needs to learn about the module. If the project is using `create-react-app` scripts one can use the drop-in replacement `craco` instead which allows to modify Webpack configuration.
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
install craco --save-dev
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
In the scripts-section of `package.json` replace occurrences of `react-script` by `craco`.
|
|
36
|
+
|
|
37
|
+
Add the file `craco.config.js` to your root-folder:
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
const path = require("path");
|
|
41
|
+
|
|
42
|
+
const aliases = {
|
|
43
|
+
'@vanillabp/bc-shared': path.join(path.resolve(__dirname, '.'), "node_modules", "@vanillabp", "bc-shared"),
|
|
44
|
+
'styled-components': path.join(path.resolve(__dirname, '.'), "node_modules", "styled-components"),
|
|
45
|
+
'react': path.join(path.resolve(__dirname, '.'), "node_modules", "react"),
|
|
46
|
+
'react-dom': path.join(path.resolve(__dirname, '.'), "node_modules", "react-dom")
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
webpack: {
|
|
51
|
+
alias: aliases
|
|
52
|
+
},
|
|
53
|
+
plugins: [
|
|
54
|
+
{
|
|
55
|
+
plugin: {
|
|
56
|
+
overrideWebpackConfig: ({ webpackConfig, pluginOptions, context: { paths } }) => {
|
|
57
|
+
const moduleScopePlugin = webpackConfig.resolve.plugins.find(plugin => plugin.appSrcs && plugin.allowedFiles);
|
|
58
|
+
if (moduleScopePlugin) {
|
|
59
|
+
Object
|
|
60
|
+
.keys(aliases)
|
|
61
|
+
.map(key => aliases[key])
|
|
62
|
+
.forEach(path => moduleScopePlugin.appSrcs.push(path));
|
|
63
|
+
}
|
|
64
|
+
const ignoreWarnings = [
|
|
65
|
+
{ module: /@microsoft\/fetch-event-source/ }
|
|
66
|
+
];
|
|
67
|
+
return { ...webpackConfig, ignoreWarnings }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
*Details:*
|
|
76
|
+
|
|
77
|
+
In the exports section `webpack.alias` the alias to the module is defined. In addition it is necessary to define aliases for 'react' and 'react-dom' because otherwise Webpack would add these modules twice (one time for the original app and one time for the module we've added).
|
|
78
|
+
|
|
79
|
+
Create-react-app scripts limit sources to the `./src` folder. Unfortunately, the new aliases point to the `node_modules` directory and will be rejected. In the exports section `plugins[].plugin{}.overrideWebpackConfig` a craco-plugin is defined which is able to modify the webpack configuration. The `ModuleScopePlugin` which is used to block other folders than `./src` is determined and the pathes of the aliases are added.
|
|
80
|
+
|
|
81
|
+
Last but not least, the craco plugin is also used to suppress warnings regarding missing `.map` files.
|
|
82
|
+
|
|
83
|
+
# Build
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
npm run build
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Development
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
npm start
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
does the same as normal building but also enters `watch` mode.
|
|
96
|
+
|
|
97
|
+
## Storybook
|
|
98
|
+
|
|
99
|
+
```sh
|
|
100
|
+
npm storybook
|
|
101
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
__spreadValues,
|
|
55
|
+
__spreadProps,
|
|
56
|
+
__objRest,
|
|
57
|
+
__async
|
|
58
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BackgroundType } from 'grommet/utils';
|
|
2
|
+
|
|
3
|
+
declare type BadgeSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
4
|
+
interface BadgeProps {
|
|
5
|
+
background?: BackgroundType;
|
|
6
|
+
count: string | number;
|
|
7
|
+
size?: BadgeSize;
|
|
8
|
+
textSize?: BadgeSize;
|
|
9
|
+
}
|
|
10
|
+
declare const Badge: ({ count, size, textSize, ...props }: BadgeProps) => JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { Badge };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__objRest,
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../chunk-YH4NJHER.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { useContext } from "react";
|
|
8
|
+
import styled from "styled-components";
|
|
9
|
+
import { Box, ResponsiveContext, Text } from "grommet";
|
|
10
|
+
const badgeSize = (size) => {
|
|
11
|
+
switch (size) {
|
|
12
|
+
case "xsmall":
|
|
13
|
+
return "1rem";
|
|
14
|
+
case "small":
|
|
15
|
+
return "1.25rem";
|
|
16
|
+
case "medium":
|
|
17
|
+
return "1.5rem";
|
|
18
|
+
case "large":
|
|
19
|
+
return "1.75rem";
|
|
20
|
+
case "xlarge":
|
|
21
|
+
return "2rem";
|
|
22
|
+
default:
|
|
23
|
+
throw new Error("Unknown size");
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const textOffset = (size) => {
|
|
27
|
+
switch (size) {
|
|
28
|
+
case "xsmall":
|
|
29
|
+
return "0.02rem";
|
|
30
|
+
case "small":
|
|
31
|
+
return "0.035rem";
|
|
32
|
+
case "medium":
|
|
33
|
+
return "0.05rem";
|
|
34
|
+
case "large":
|
|
35
|
+
return "0.08rem";
|
|
36
|
+
case "xlarge":
|
|
37
|
+
return "0.12rem";
|
|
38
|
+
default:
|
|
39
|
+
throw new Error("Unknown size");
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const CountText = styled(Text)`
|
|
43
|
+
font-size: ${(props) => badgeSize(props.textSize)};
|
|
44
|
+
line-height: ${(props) => badgeSize(props.size)};
|
|
45
|
+
font-weight: 700;
|
|
46
|
+
width: 5rem;
|
|
47
|
+
left: calc(-2.5rem + ${(props) => badgeSize(props.size)} / 2 - ${(props) => textOffset(props.size)} / 2);
|
|
48
|
+
text-align: center;
|
|
49
|
+
top: ${(props) => textOffset(props.size)};
|
|
50
|
+
position: absolute;
|
|
51
|
+
`;
|
|
52
|
+
const Badge = (_a) => {
|
|
53
|
+
var _b = _a, { count, size = "medium", textSize = "medium" } = _b, props = __objRest(_b, ["count", "size", "textSize"]);
|
|
54
|
+
const rc = useContext(ResponsiveContext);
|
|
55
|
+
return /* @__PURE__ */ jsx(
|
|
56
|
+
Box,
|
|
57
|
+
__spreadProps(__spreadValues({
|
|
58
|
+
align: "center",
|
|
59
|
+
justify: "center",
|
|
60
|
+
pad: rc === "small" ? "small" : "xsmall",
|
|
61
|
+
round: badgeSize(size)
|
|
62
|
+
}, props), {
|
|
63
|
+
children: /* @__PURE__ */ jsx(
|
|
64
|
+
Box,
|
|
65
|
+
{
|
|
66
|
+
width: badgeSize(size),
|
|
67
|
+
height: badgeSize(size),
|
|
68
|
+
style: { position: "relative" },
|
|
69
|
+
children: /* @__PURE__ */ jsx(
|
|
70
|
+
CountText,
|
|
71
|
+
{
|
|
72
|
+
size,
|
|
73
|
+
textSize,
|
|
74
|
+
children: count
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
Badge
|
|
84
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "../chunk-YH4NJHER.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Box, Button } from "grommet";
|
|
4
|
+
import { createRef } from "react";
|
|
5
|
+
const CircleButton = ({
|
|
6
|
+
style,
|
|
7
|
+
className,
|
|
8
|
+
icon,
|
|
9
|
+
onClick,
|
|
10
|
+
color = "accent-3"
|
|
11
|
+
}) => {
|
|
12
|
+
const buttonRef = createRef();
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
Box,
|
|
15
|
+
{
|
|
16
|
+
style,
|
|
17
|
+
className,
|
|
18
|
+
margin: "medium",
|
|
19
|
+
round: "full",
|
|
20
|
+
height: "xxsmall",
|
|
21
|
+
width: "xxsmall",
|
|
22
|
+
overflow: "hidden",
|
|
23
|
+
background: color,
|
|
24
|
+
align: "center",
|
|
25
|
+
children: /* @__PURE__ */ jsx(
|
|
26
|
+
Button,
|
|
27
|
+
{
|
|
28
|
+
size: "large",
|
|
29
|
+
icon,
|
|
30
|
+
ref: buttonRef,
|
|
31
|
+
color,
|
|
32
|
+
hoverIndicator: true,
|
|
33
|
+
style: { border: "none", height: "4rem" },
|
|
34
|
+
onClick: (event) => {
|
|
35
|
+
var _a;
|
|
36
|
+
(_a = buttonRef.current) == null ? void 0 : _a.blur();
|
|
37
|
+
if (onClick)
|
|
38
|
+
onClick(event);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
CircleButton
|
|
47
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { BackgroundType, EdgeSizeType } from 'grommet/utils';
|
|
3
|
+
|
|
4
|
+
declare type ButtonSizeType = 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | string;
|
|
5
|
+
interface CopyClipbardButtonProps {
|
|
6
|
+
content?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
background?: BackgroundType;
|
|
9
|
+
onCopy?: () => any;
|
|
10
|
+
size?: ButtonSizeType;
|
|
11
|
+
}
|
|
12
|
+
declare const CopyClipboardButton: ({ content, color, background, onCopy, size, }: CopyClipbardButtonProps) => JSX.Element;
|
|
13
|
+
interface CopyClipbardProps {
|
|
14
|
+
content?: string;
|
|
15
|
+
size?: EdgeSizeType | string;
|
|
16
|
+
color?: string;
|
|
17
|
+
background?: BackgroundType;
|
|
18
|
+
}
|
|
19
|
+
declare const CopyClipboard: ({ content, size, background, color, children, }: PropsWithChildren<CopyClipbardProps>) => JSX.Element;
|
|
20
|
+
|
|
21
|
+
export { CopyClipboard, CopyClipboardButton };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__async
|
|
3
|
+
} from "../chunk-YH4NJHER.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Box, Drop } from "grommet";
|
|
6
|
+
import React, { useRef, useState } from "react";
|
|
7
|
+
import { Copy } from "grommet-icons";
|
|
8
|
+
;
|
|
9
|
+
const CopyClipboardButton = ({
|
|
10
|
+
content,
|
|
11
|
+
color = "white",
|
|
12
|
+
background = { color: "rgba(0, 0, 0, 0.45)" },
|
|
13
|
+
onCopy,
|
|
14
|
+
size = "medium"
|
|
15
|
+
}) => {
|
|
16
|
+
const copyContent = (data) => __async(void 0, null, function* () {
|
|
17
|
+
try {
|
|
18
|
+
yield navigator.clipboard.writeText(data);
|
|
19
|
+
} catch (err) {
|
|
20
|
+
console.error("Failed to copy: ", err);
|
|
21
|
+
}
|
|
22
|
+
if (onCopy) {
|
|
23
|
+
onCopy();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
Box,
|
|
28
|
+
{
|
|
29
|
+
flex: false,
|
|
30
|
+
round: "xsmall",
|
|
31
|
+
background,
|
|
32
|
+
margin: { left: "xsmall" },
|
|
33
|
+
pad: "xsmall",
|
|
34
|
+
children: /* @__PURE__ */ jsx(
|
|
35
|
+
Copy,
|
|
36
|
+
{
|
|
37
|
+
color,
|
|
38
|
+
size,
|
|
39
|
+
onClick: () => copyContent(content)
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
;
|
|
46
|
+
const CopyClipboard = ({
|
|
47
|
+
content,
|
|
48
|
+
size = "medium",
|
|
49
|
+
background,
|
|
50
|
+
color = "white",
|
|
51
|
+
children
|
|
52
|
+
}) => {
|
|
53
|
+
const targetRef = useRef(null);
|
|
54
|
+
const [over, _setOver] = useState(false);
|
|
55
|
+
const hideTimer = React.useRef(0);
|
|
56
|
+
if (!Boolean(content)) {
|
|
57
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
58
|
+
}
|
|
59
|
+
const setOver = (status) => {
|
|
60
|
+
if (Boolean(hideTimer.current)) {
|
|
61
|
+
window.clearTimeout(hideTimer.current);
|
|
62
|
+
hideTimer.current = 0;
|
|
63
|
+
}
|
|
64
|
+
if (status) {
|
|
65
|
+
_setOver(status);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
hideTimer.current = window.setTimeout(() => {
|
|
69
|
+
_setOver(false);
|
|
70
|
+
hideTimer.current = 0;
|
|
71
|
+
}, 200);
|
|
72
|
+
};
|
|
73
|
+
const sizeFactor = size === "xxsmall" ? 0.3 : size === "xsmall" ? 0.4 : size === "small" ? 0.5 : size === "medium" ? 0.6 : size === "large" ? 0.8 : size === "xlarge" ? 1 : size === "xxlarge" ? 1.2 : 0;
|
|
74
|
+
const iconSize = sizeFactor === 0 || !targetRef.current ? size : `${targetRef.current.clientHeight * sizeFactor}px`;
|
|
75
|
+
return /* @__PURE__ */ jsxs(
|
|
76
|
+
"span",
|
|
77
|
+
{
|
|
78
|
+
ref: targetRef,
|
|
79
|
+
style: { display: "inline-block" },
|
|
80
|
+
onMouseLeave: (event) => setOver(false),
|
|
81
|
+
onMouseEnter: (event) => setOver(true),
|
|
82
|
+
children: [
|
|
83
|
+
children,
|
|
84
|
+
over && targetRef.current && /* @__PURE__ */ jsx(
|
|
85
|
+
Drop,
|
|
86
|
+
{
|
|
87
|
+
plain: true,
|
|
88
|
+
target: targetRef.current,
|
|
89
|
+
stretch: false,
|
|
90
|
+
align: { left: "right" },
|
|
91
|
+
children: /* @__PURE__ */ jsx(
|
|
92
|
+
CopyClipboardButton,
|
|
93
|
+
{
|
|
94
|
+
content,
|
|
95
|
+
color,
|
|
96
|
+
onCopy: () => setOver(false),
|
|
97
|
+
size: iconSize,
|
|
98
|
+
background
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
export {
|
|
108
|
+
CopyClipboard,
|
|
109
|
+
CopyClipboardButton
|
|
110
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BoxExtendedProps, TextExtendedProps } from 'grommet';
|
|
2
|
+
import { ColorType } from 'grommet/utils/index.js';
|
|
3
|
+
import React, { PropsWithChildren, FC } from 'react';
|
|
4
|
+
import { BackgroundType } from 'grommet/utils';
|
|
5
|
+
import { ListItem, Column } from '../types/ListCell.js';
|
|
6
|
+
import { TranslationFunction } from '../types/translate.js';
|
|
7
|
+
|
|
8
|
+
declare const ENDED_FONT_COLOR = "light-4";
|
|
9
|
+
declare const ENDED_FONT_COLOR_ODD = "#b4b4b4";
|
|
10
|
+
declare type Alignment = 'left' | 'center' | 'right';
|
|
11
|
+
declare const colorForEndedItemsOrUndefined: (item: ListItem<any>) => ColorType;
|
|
12
|
+
interface ListCellProps extends BoxExtendedProps {
|
|
13
|
+
background?: BackgroundType;
|
|
14
|
+
align?: Alignment;
|
|
15
|
+
}
|
|
16
|
+
declare const ListCell: React.FC<PropsWithChildren<ListCellProps>>;
|
|
17
|
+
interface TextListCellProps extends TextExtendedProps {
|
|
18
|
+
item: ListItem<any>;
|
|
19
|
+
value?: string | String;
|
|
20
|
+
tip?: string;
|
|
21
|
+
showUnreadAsBold?: boolean;
|
|
22
|
+
background?: BackgroundType;
|
|
23
|
+
align?: Alignment;
|
|
24
|
+
}
|
|
25
|
+
declare const TextListCell: React.FC<TextListCellProps>;
|
|
26
|
+
interface DefaultListCellProps<D> {
|
|
27
|
+
t: TranslationFunction;
|
|
28
|
+
item: ListItem<D>;
|
|
29
|
+
column: Column;
|
|
30
|
+
showUnreadAsBold?: boolean;
|
|
31
|
+
defaultLanguage?: string;
|
|
32
|
+
currentLanguage: string;
|
|
33
|
+
nameOfList?: string;
|
|
34
|
+
selectItem: (select: boolean) => void;
|
|
35
|
+
isPhone: boolean;
|
|
36
|
+
isTablet: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface DefaultListCellAwareProps<T> extends DefaultListCellProps<T> {
|
|
39
|
+
defaultCell: FC<DefaultListCellProps<T>>;
|
|
40
|
+
}
|
|
41
|
+
declare const colorRowAccordingToUpdateStatus: <T extends ListItem<any>>(item: T) => BackgroundType | undefined;
|
|
42
|
+
declare const DefaultListCell: FC<DefaultListCellProps<any>>;
|
|
43
|
+
|
|
44
|
+
export { Alignment, DefaultListCell, DefaultListCellAwareProps, DefaultListCellProps, ENDED_FONT_COLOR, ENDED_FONT_COLOR_ODD, ListCell, TextListCell, colorForEndedItemsOrUndefined, colorRowAccordingToUpdateStatus };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__objRest,
|
|
3
|
+
__spreadProps,
|
|
4
|
+
__spreadValues
|
|
5
|
+
} from "../chunk-YH4NJHER.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { Box, Text } from "grommet";
|
|
8
|
+
import { ListItemStatus } from "../types/index.js";
|
|
9
|
+
import {
|
|
10
|
+
getObjectProperty,
|
|
11
|
+
toLocaleDateString,
|
|
12
|
+
toLocaleStringWithoutSeconds,
|
|
13
|
+
toLocaleTimeStringWithoutSeconds
|
|
14
|
+
} from "../utils/index.js";
|
|
15
|
+
const DATE_REGEXP = /^(\d{4})-(\d{2})-(\d{2})/;
|
|
16
|
+
const ENDED_FONT_COLOR = "light-4";
|
|
17
|
+
const ENDED_FONT_COLOR_ODD = "#b4b4b4";
|
|
18
|
+
const colorForEndedItemsOrUndefined = (item) => {
|
|
19
|
+
return item.status !== ListItemStatus.ENDED ? void 0 : ENDED_FONT_COLOR;
|
|
20
|
+
};
|
|
21
|
+
const ListCell = (_a) => {
|
|
22
|
+
var _b = _a, {
|
|
23
|
+
background,
|
|
24
|
+
align,
|
|
25
|
+
children
|
|
26
|
+
} = _b, props = __objRest(_b, [
|
|
27
|
+
"background",
|
|
28
|
+
"align",
|
|
29
|
+
"children"
|
|
30
|
+
]);
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
Box,
|
|
33
|
+
__spreadProps(__spreadValues({
|
|
34
|
+
fill: true,
|
|
35
|
+
align: "center",
|
|
36
|
+
direction: "row",
|
|
37
|
+
justify: align === "left" ? "start" : align === "right" ? "end" : "center",
|
|
38
|
+
background,
|
|
39
|
+
pad: "xsmall",
|
|
40
|
+
gap: "xsmall"
|
|
41
|
+
}, props), {
|
|
42
|
+
children
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
const TextListCell = (_c) => {
|
|
47
|
+
var _d = _c, {
|
|
48
|
+
item,
|
|
49
|
+
value = "",
|
|
50
|
+
align = "left",
|
|
51
|
+
tip,
|
|
52
|
+
showUnreadAsBold = false,
|
|
53
|
+
background
|
|
54
|
+
} = _d, props = __objRest(_d, [
|
|
55
|
+
"item",
|
|
56
|
+
"value",
|
|
57
|
+
"align",
|
|
58
|
+
"tip",
|
|
59
|
+
"showUnreadAsBold",
|
|
60
|
+
"background"
|
|
61
|
+
]);
|
|
62
|
+
const color = colorForEndedItemsOrUndefined(item);
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
ListCell,
|
|
65
|
+
{
|
|
66
|
+
background,
|
|
67
|
+
align,
|
|
68
|
+
children: tip === void 0 ? /* @__PURE__ */ jsx(
|
|
69
|
+
Text,
|
|
70
|
+
__spreadProps(__spreadValues({
|
|
71
|
+
truncate: "tip",
|
|
72
|
+
color,
|
|
73
|
+
weight: showUnreadAsBold && item.read === void 0 ? "bold" : "normal"
|
|
74
|
+
}, props), {
|
|
75
|
+
children: value
|
|
76
|
+
})
|
|
77
|
+
) : /* @__PURE__ */ jsx(
|
|
78
|
+
Text,
|
|
79
|
+
__spreadProps(__spreadValues({
|
|
80
|
+
truncate: true,
|
|
81
|
+
color,
|
|
82
|
+
weight: showUnreadAsBold && item.read === void 0 ? "bold" : "normal",
|
|
83
|
+
tip: { content: tip }
|
|
84
|
+
}, props), {
|
|
85
|
+
children: value
|
|
86
|
+
})
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
const render = (t, propertyValue, currentLanguage, defaultLanguage) => {
|
|
92
|
+
let align = "left";
|
|
93
|
+
let value;
|
|
94
|
+
let tip;
|
|
95
|
+
if (typeof propertyValue === "object") {
|
|
96
|
+
let langValue = propertyValue[currentLanguage];
|
|
97
|
+
if (langValue !== void 0) {
|
|
98
|
+
propertyValue = langValue;
|
|
99
|
+
} else if (defaultLanguage !== void 0) {
|
|
100
|
+
langValue = propertyValue[defaultLanguage];
|
|
101
|
+
if (langValue !== void 0) {
|
|
102
|
+
propertyValue = langValue;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (propertyValue === void 0) {
|
|
107
|
+
value = "";
|
|
108
|
+
} else if (propertyValue instanceof Date) {
|
|
109
|
+
value = toLocaleTimeStringWithoutSeconds(propertyValue);
|
|
110
|
+
} else if (typeof propertyValue === "number") {
|
|
111
|
+
value = propertyValue.toLocaleString(window.navigator.language);
|
|
112
|
+
align = "right";
|
|
113
|
+
} else if (typeof propertyValue === "boolean") {
|
|
114
|
+
if (propertyValue) {
|
|
115
|
+
value = t("boolean-true");
|
|
116
|
+
} else {
|
|
117
|
+
value = t("boolean-false");
|
|
118
|
+
}
|
|
119
|
+
} else if (typeof propertyValue === "string") {
|
|
120
|
+
const dateMatch = DATE_REGEXP.exec(propertyValue);
|
|
121
|
+
if (dateMatch) {
|
|
122
|
+
if (propertyValue.length === 10) {
|
|
123
|
+
value = toLocaleDateString(new Date(Date.parse(propertyValue)));
|
|
124
|
+
align = "right";
|
|
125
|
+
} else {
|
|
126
|
+
const tmpDate = new Date(Date.parse(propertyValue));
|
|
127
|
+
value = toLocaleStringWithoutSeconds(tmpDate);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
value = propertyValue;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return { value, align };
|
|
134
|
+
};
|
|
135
|
+
const colorRowAccordingToUpdateStatus = (item) => item.status === ListItemStatus.NEW ? { color: "accent-3", opacity: 0.1 } : item.status === ListItemStatus.UPDATED ? { color: "accent-1", opacity: 0.15 } : item.status === ListItemStatus.ENDED ? { color: "light-2", opacity: 0.5 } : item.status === ListItemStatus.REMOVED_FROM_LIST ? { color: "light-2", opacity: 0.5 } : void 0;
|
|
136
|
+
const DefaultListCell = ({
|
|
137
|
+
item,
|
|
138
|
+
column,
|
|
139
|
+
showUnreadAsBold,
|
|
140
|
+
currentLanguage,
|
|
141
|
+
defaultLanguage,
|
|
142
|
+
t,
|
|
143
|
+
selectItem
|
|
144
|
+
}) => {
|
|
145
|
+
let propertyValue = getObjectProperty(item.data, column.path);
|
|
146
|
+
let align = "left";
|
|
147
|
+
let value;
|
|
148
|
+
let tip;
|
|
149
|
+
if (column.path === "dueDate") {
|
|
150
|
+
value = toLocaleDateString(item.data.dueDate);
|
|
151
|
+
tip = toLocaleStringWithoutSeconds(item.data.dueDate);
|
|
152
|
+
align = "right";
|
|
153
|
+
} else {
|
|
154
|
+
const { value: v, align: a } = render(t, propertyValue, currentLanguage, defaultLanguage);
|
|
155
|
+
value = v;
|
|
156
|
+
align = a;
|
|
157
|
+
}
|
|
158
|
+
const background = colorRowAccordingToUpdateStatus(item);
|
|
159
|
+
return /* @__PURE__ */ jsx(
|
|
160
|
+
TextListCell,
|
|
161
|
+
{
|
|
162
|
+
item,
|
|
163
|
+
value,
|
|
164
|
+
tip,
|
|
165
|
+
showUnreadAsBold,
|
|
166
|
+
background,
|
|
167
|
+
align
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
export {
|
|
172
|
+
DefaultListCell,
|
|
173
|
+
ENDED_FONT_COLOR,
|
|
174
|
+
ENDED_FONT_COLOR_ODD,
|
|
175
|
+
ListCell,
|
|
176
|
+
TextListCell,
|
|
177
|
+
colorForEndedItemsOrUndefined,
|
|
178
|
+
colorRowAccordingToUpdateStatus
|
|
179
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Column } from '../types/ListCell.js';
|
|
3
|
+
|
|
4
|
+
interface DefaultListHeaderProps<D> {
|
|
5
|
+
column: Column;
|
|
6
|
+
currentLanguage: string;
|
|
7
|
+
nameOfList?: string;
|
|
8
|
+
isPhone: boolean;
|
|
9
|
+
isTablet: boolean;
|
|
10
|
+
selectAll: (select: boolean) => void;
|
|
11
|
+
allSelected: boolean;
|
|
12
|
+
sort?: boolean;
|
|
13
|
+
sortAscending?: boolean;
|
|
14
|
+
setSort: (column?: Column) => void;
|
|
15
|
+
setSortAscending: (ascending: boolean) => void;
|
|
16
|
+
}
|
|
17
|
+
interface DefaultListHeaderAwareProps<T> extends DefaultListHeaderProps<T> {
|
|
18
|
+
defaultHeader: FC<DefaultListHeaderProps<T>>;
|
|
19
|
+
}
|
|
20
|
+
declare const DefaultListHeader: FC<DefaultListHeaderProps<any>>;
|
|
21
|
+
|
|
22
|
+
export { DefaultListHeader, DefaultListHeaderAwareProps, DefaultListHeaderProps };
|