@platformatic/ui-components 0.13.4 → 0.15.0
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/dist/assets/index-DjGoNdUR.js +49 -0
- package/dist/index.html +1 -1
- package/index.d.ts +159 -0
- package/package.json +7 -3
- package/src/components/Checkbox.module.css +7 -7
- package/src/components/SplashScreen.jsx +14 -11
- package/src/components/icons/CacheRecommendationIcon.jsx +101 -0
- package/src/components/icons/RouteEditIcon.jsx +110 -0
- package/src/components/icons/RouteHistoryIcon.jsx +128 -0
- package/src/components/icons/RoutingIcon.jsx +104 -0
- package/src/components/icons/index.js +8 -0
- package/src/stories/Checkbox.stories.jsx +6 -0
- package/test-d/index.test-d.ts +86 -0
- package/tsconfig.json +16 -0
- package/dist/assets/index-CvMjKwW6.js +0 -49
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import styles from './Icons.module.css'
|
|
4
|
+
import { COLORS_ICON, SIZES, SMALL, MEDIUM, LARGE, MAIN_DARK_BLUE } from '../constants'
|
|
5
|
+
|
|
6
|
+
const RoutingIcon = ({
|
|
7
|
+
color = MAIN_DARK_BLUE,
|
|
8
|
+
size = MEDIUM,
|
|
9
|
+
disabled = false,
|
|
10
|
+
inactive = false
|
|
11
|
+
}) => {
|
|
12
|
+
let className = `${styles.svgClassName} ` + styles[`${color}`]
|
|
13
|
+
if (disabled) {
|
|
14
|
+
className += ` ${styles.iconDisabled}`
|
|
15
|
+
}
|
|
16
|
+
if (inactive) {
|
|
17
|
+
className += ` ${styles.iconInactive}`
|
|
18
|
+
}
|
|
19
|
+
let icon = <></>
|
|
20
|
+
|
|
21
|
+
switch (size) {
|
|
22
|
+
case SMALL:
|
|
23
|
+
icon = (
|
|
24
|
+
<svg
|
|
25
|
+
width={16}
|
|
26
|
+
height={16}
|
|
27
|
+
viewBox='0 0 16 16'
|
|
28
|
+
fill='none'
|
|
29
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
30
|
+
className={className}
|
|
31
|
+
>
|
|
32
|
+
<circle cx='3' cy='5' r='1' transform='rotate(90 3 5)' stroke='none' />
|
|
33
|
+
<circle cx='13' cy='3' r='1' transform='rotate(90 13 3)' stroke='none' />
|
|
34
|
+
<circle cx='13' cy='8' r='1' transform='rotate(90 13 8)' stroke='none' />
|
|
35
|
+
<circle cx='13' cy='13' r='1' transform='rotate(90 13 13)' stroke='none' />
|
|
36
|
+
<path d='M12 3L10 3L7.5 3C6.94772 3 6.5 3.44772 6.5 4V4C6.5 4.55228 6.05228 5 5.5 5L4 5' stroke='none' strokeLinecap='round' strokeLinejoin='round' />
|
|
37
|
+
<path d='M12 13L9.75002 13C8.64545 13 7.75002 12.1046 7.75002 11L7.75002 7C7.75002 5.89543 6.85459 5 5.75002 5L4.5 5M12 8L7.00001 8C6.17158 8 5.50001 7.32843 5.50001 6.5V6.5C5.50001 5.67157 4.82843 5 4 5V5' stroke='none' strokeLinecap='round' strokeLinejoin='round' />
|
|
38
|
+
</svg>
|
|
39
|
+
)
|
|
40
|
+
break
|
|
41
|
+
case MEDIUM:
|
|
42
|
+
icon = (
|
|
43
|
+
<svg
|
|
44
|
+
width={24}
|
|
45
|
+
height={24}
|
|
46
|
+
viewBox='0 0 24 24'
|
|
47
|
+
fill='none'
|
|
48
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
49
|
+
className={className}
|
|
50
|
+
>
|
|
51
|
+
<circle cx='4.5' cy='7.5' r='1.5' transform='rotate(90 4.5 7.5)' stroke='none' strokeWidth={1.5} />
|
|
52
|
+
<circle cx='19.5' cy='4.5' r='1.5' transform='rotate(90 19.5 4.5)' stroke='none' strokeWidth={1.5} />
|
|
53
|
+
<circle cx='19.5' cy='12' r='1.5' transform='rotate(90 19.5 12)' stroke='none' strokeWidth={1.5} />
|
|
54
|
+
<circle cx='19.5' cy='19.5' r='1.5' transform='rotate(90 19.5 19.5)' stroke='none' strokeWidth={1.5} />
|
|
55
|
+
<path d='M18 4.5L15 4.5L10.75 4.5C10.1977 4.5 9.75 4.94772 9.75 5.5L9.75 6.5C9.75 7.05228 9.30228 7.5 8.75 7.5L6 7.5' stroke='none' strokeWidth={1.5} strokeLinecap='round' strokeLinejoin='round' />
|
|
56
|
+
<path d='M18 19.5L13.625 19.5C12.5205 19.5 11.625 18.6046 11.625 17.5L11.625 9.5C11.625 8.39543 10.7296 7.5 9.62503 7.5L6.75 7.5M18 12L10.25 12C9.14545 12 8.25002 11.1046 8.25001 10L8.25001 9.49999C8.25001 8.39543 7.35458 7.5 6.25002 7.5L6 7.5' stroke='none' strokeWidth={1.5} strokeLinecap='round' strokeLinejoin='round' />
|
|
57
|
+
</svg>
|
|
58
|
+
)
|
|
59
|
+
break
|
|
60
|
+
case LARGE:
|
|
61
|
+
icon = (
|
|
62
|
+
<svg
|
|
63
|
+
width={40}
|
|
64
|
+
height={40}
|
|
65
|
+
viewBox='0 0 40 40'
|
|
66
|
+
fill='none'
|
|
67
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
68
|
+
className={className}
|
|
69
|
+
>
|
|
70
|
+
<circle cx='7.5' cy='12.5' r='2.5' transform='rotate(90 7.5 12.5)' stroke='none' strokeWidth={2} />
|
|
71
|
+
<circle cx='32.5' cy='7.5' r='2.5' transform='rotate(90 32.5 7.5)' stroke='none' strokeWidth={2} />
|
|
72
|
+
<circle cx='32.5' cy='20' r='2.5' transform='rotate(90 32.5 20)' stroke='none' strokeWidth={2} />
|
|
73
|
+
<circle cx='32.5' cy='32.5' r='2.5' transform='rotate(90 32.5 32.5)' stroke='none' strokeWidth={2} />
|
|
74
|
+
<path d='M30 7.5L25 7.5L18.25 7.5C17.1454 7.5 16.25 8.39543 16.25 9.5L16.25 10.5C16.25 11.6046 15.3546 12.5 14.25 12.5L10 12.5' stroke='none' strokeWidth={2} strokeLinecap='round' strokeLinejoin='round' />
|
|
75
|
+
<path d='M30 32.5L21.3751 32.5C20.2705 32.5 19.3751 31.6046 19.3751 30.5L19.375 14.5C19.375 13.3954 18.4796 12.5 17.375 12.5L11.25 12.5M30 20L15.75 20C14.6455 20 13.75 19.1046 13.75 18L13.75 14.5C13.75 13.3954 12.8546 12.5 11.75 12.5L10 12.5' stroke='none' strokeWidth={2} strokeLinecap='round' strokeLinejoin='round' />
|
|
76
|
+
</svg>
|
|
77
|
+
)
|
|
78
|
+
break
|
|
79
|
+
default:
|
|
80
|
+
break
|
|
81
|
+
}
|
|
82
|
+
return icon
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
RoutingIcon.propTypes = {
|
|
86
|
+
/**
|
|
87
|
+
* color of text, icon and borders
|
|
88
|
+
*/
|
|
89
|
+
color: PropTypes.oneOf(COLORS_ICON),
|
|
90
|
+
/**
|
|
91
|
+
* Size
|
|
92
|
+
*/
|
|
93
|
+
size: PropTypes.oneOf(SIZES),
|
|
94
|
+
/**
|
|
95
|
+
* disabled
|
|
96
|
+
*/
|
|
97
|
+
disabled: PropTypes.bool,
|
|
98
|
+
/**
|
|
99
|
+
* inactive
|
|
100
|
+
*/
|
|
101
|
+
inactive: PropTypes.bool
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default RoutingIcon
|
|
@@ -38,6 +38,7 @@ import BellIcon from './BellIcon'
|
|
|
38
38
|
import BillingIcon from './BillingIcon'
|
|
39
39
|
import BranchIcon from './BranchIcon'
|
|
40
40
|
import BuiltInLoggingIcon from './BuiltInLoggingIcon'
|
|
41
|
+
import CacheRecommendationIcon from './CacheRecommendationIcon'
|
|
41
42
|
import CachingIcon from './CachingIcon'
|
|
42
43
|
import Calendar1DayIcon from './Calendar1DayIcon'
|
|
43
44
|
import Calendar7DaysIcon from './Calendar7DaysIcon'
|
|
@@ -167,6 +168,9 @@ import RequestsIcon from './RequestsIcon'
|
|
|
167
168
|
import ResourceIcon from './ResourceIcon'
|
|
168
169
|
import RestartIcon from './RestartIcon'
|
|
169
170
|
import RocketIcon from './RocketIcon'
|
|
171
|
+
import RouteEditIcon from './RouteEditIcon'
|
|
172
|
+
import RouteHistoryIcon from './RouteHistoryIcon'
|
|
173
|
+
import RoutingIcon from './RoutingIcon'
|
|
170
174
|
import RunningAppIcon from './RunningAppIcon'
|
|
171
175
|
import RunningIcon from './RunningIcon'
|
|
172
176
|
import ScalerDetailsIcon from './ScalerDetailsIcon'
|
|
@@ -261,6 +265,7 @@ export default {
|
|
|
261
265
|
BillingIcon,
|
|
262
266
|
BranchIcon,
|
|
263
267
|
BuiltInLoggingIcon,
|
|
268
|
+
CacheRecommendationIcon,
|
|
264
269
|
CachingIcon,
|
|
265
270
|
Calendar1DayIcon,
|
|
266
271
|
Calendar7DaysIcon,
|
|
@@ -390,6 +395,9 @@ export default {
|
|
|
390
395
|
ResourceIcon,
|
|
391
396
|
RestartIcon,
|
|
392
397
|
RocketIcon,
|
|
398
|
+
RouteEditIcon,
|
|
399
|
+
RouteHistoryIcon,
|
|
400
|
+
RoutingIcon,
|
|
393
401
|
RunningAppIcon,
|
|
394
402
|
RunningIcon,
|
|
395
403
|
ScalerDetailsIcon,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { expectType, expectAssignable } from "tsd";
|
|
2
|
+
import { ComponentType } from "react";
|
|
3
|
+
import {
|
|
4
|
+
VerticalSeparatorProps,
|
|
5
|
+
Checkbox,
|
|
6
|
+
BorderedBox,
|
|
7
|
+
Button,
|
|
8
|
+
HorizontalSeparator,
|
|
9
|
+
LoadingSpinnerV2,
|
|
10
|
+
Tooltip,
|
|
11
|
+
VerticalSeparator,
|
|
12
|
+
TooltipAbsolute,
|
|
13
|
+
PlatformaticIconProps,
|
|
14
|
+
CopyAndPasteProps,
|
|
15
|
+
IconsType,
|
|
16
|
+
PlatformaticIcon,
|
|
17
|
+
CopyAndPaste,
|
|
18
|
+
Icons,
|
|
19
|
+
} from "@platformatic/ui-components";
|
|
20
|
+
|
|
21
|
+
// Test VerticalSeparatorProps interface
|
|
22
|
+
expectAssignable<VerticalSeparatorProps>({});
|
|
23
|
+
expectAssignable<VerticalSeparatorProps>({
|
|
24
|
+
color: "red",
|
|
25
|
+
backgroundColorOpacity: "0.5",
|
|
26
|
+
classes: "custom-class",
|
|
27
|
+
height: "100px",
|
|
28
|
+
width: "2px",
|
|
29
|
+
marginLeft: "10px",
|
|
30
|
+
marginRight: "10px",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Test PlatformaticIconProps interface
|
|
34
|
+
expectAssignable<PlatformaticIconProps>({
|
|
35
|
+
iconName: "test-icon",
|
|
36
|
+
});
|
|
37
|
+
expectAssignable<PlatformaticIconProps>({
|
|
38
|
+
iconName: "test-icon",
|
|
39
|
+
color: "blue",
|
|
40
|
+
size: "large",
|
|
41
|
+
onClick: () => {},
|
|
42
|
+
disabled: false,
|
|
43
|
+
inactive: true,
|
|
44
|
+
className: "custom-icon",
|
|
45
|
+
internalOverHandling: true,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Test CopyAndPasteProps interface
|
|
49
|
+
expectAssignable<CopyAndPasteProps>({
|
|
50
|
+
value: "test",
|
|
51
|
+
});
|
|
52
|
+
expectAssignable<CopyAndPasteProps>({
|
|
53
|
+
value: { test: "object" },
|
|
54
|
+
tooltipLabel: "Copy me",
|
|
55
|
+
color: "green",
|
|
56
|
+
size: "small",
|
|
57
|
+
tooltipClassName: "custom-tooltip",
|
|
58
|
+
position: "top",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Test that components are properly typed as React ComponentType
|
|
62
|
+
expectType<ComponentType<any>>(Checkbox);
|
|
63
|
+
expectType<ComponentType<any>>(BorderedBox);
|
|
64
|
+
expectType<ComponentType<any>>(Button);
|
|
65
|
+
expectType<ComponentType<any>>(HorizontalSeparator);
|
|
66
|
+
expectType<ComponentType<any>>(LoadingSpinnerV2);
|
|
67
|
+
expectType<ComponentType<any>>(Tooltip);
|
|
68
|
+
expectType<ComponentType<VerticalSeparatorProps>>(VerticalSeparator);
|
|
69
|
+
expectType<ComponentType<any>>(TooltipAbsolute);
|
|
70
|
+
expectType<ComponentType<PlatformaticIconProps>>(PlatformaticIcon);
|
|
71
|
+
expectType<ComponentType<CopyAndPasteProps>>(CopyAndPaste);
|
|
72
|
+
|
|
73
|
+
// Test IconsType
|
|
74
|
+
expectAssignable<IconsType>({
|
|
75
|
+
CircleStopIcon: (() => null) as ComponentType<any>,
|
|
76
|
+
RunningIcon: (() => null) as ComponentType<any>,
|
|
77
|
+
customIcon: "string-value",
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Test specific Icons exports
|
|
81
|
+
expectType<ComponentType<any>>(Icons.CircleStopIcon);
|
|
82
|
+
expectType<ComponentType<any>>(Icons.RunningIcon);
|
|
83
|
+
|
|
84
|
+
// Test that Icons allows string index access
|
|
85
|
+
const dynamicIcon: string | ComponentType<any> = Icons["someIconName"];
|
|
86
|
+
expectType<string | ComponentType<any>>(dynamicIcon);
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"target": "es2019",
|
|
5
|
+
"lib": ["es2019"],
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"baseUrl": ".",
|
|
11
|
+
"paths": {
|
|
12
|
+
"@platformatic/ui-components": ["./index.d.ts"]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"include": ["test-d/**/*.ts"]
|
|
16
|
+
}
|