@tecsinapse/cortex-react 1.2.0 → 1.2.2-beta.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/README.md +65 -5
- package/dist/cjs/components/Avatar.js +34 -0
- package/dist/cjs/components/BreadcrumbItem.js +27 -0
- package/dist/cjs/components/Breadcrumbs.js +22 -0
- package/dist/cjs/components/Card.js +2 -10
- package/dist/cjs/components/Drawer.js +32 -0
- package/dist/cjs/components/GroupButton.js +42 -0
- package/dist/cjs/components/Input.js +5 -3
- package/dist/cjs/components/Modal.js +6 -13
- package/dist/cjs/components/ProgressBar.js +70 -0
- package/dist/cjs/components/SearchInput.js +5 -0
- package/dist/cjs/components/Skeleton.js +21 -0
- package/dist/cjs/components/Table.js +5 -1
- package/dist/cjs/components/Toggle.js +17 -9
- package/dist/cjs/components/utils.js +12 -0
- package/dist/cjs/index.js +13 -0
- package/dist/cjs/styles/groupButton.js +16 -0
- package/dist/cjs/styles/progressBar.js +21 -0
- package/dist/esm/components/Avatar.js +32 -0
- package/dist/esm/components/BreadcrumbItem.js +25 -0
- package/dist/esm/components/Breadcrumbs.js +20 -0
- package/dist/esm/components/Card.js +2 -10
- package/dist/esm/components/Drawer.js +30 -0
- package/dist/esm/components/GroupButton.js +40 -0
- package/dist/esm/components/Input.js +5 -3
- package/dist/esm/components/Modal.js +6 -13
- package/dist/esm/components/ProgressBar.js +68 -0
- package/dist/esm/components/SearchInput.js +5 -0
- package/dist/esm/components/Skeleton.js +19 -0
- package/dist/esm/components/Table.js +6 -3
- package/dist/esm/components/Toggle.js +17 -9
- package/dist/esm/components/utils.js +10 -0
- package/dist/esm/index.js +7 -1
- package/dist/esm/styles/groupButton.js +14 -0
- package/dist/esm/styles/progressBar.js +19 -0
- package/dist/types/components/Avatar.d.ts +7 -0
- package/dist/types/components/BreadcrumbItem.d.ts +5 -0
- package/dist/types/components/Breadcrumbs.d.ts +10 -0
- package/dist/types/components/Button.d.ts +1 -1
- package/dist/types/components/Card.d.ts +1 -1
- package/dist/types/components/Drawer.d.ts +9 -0
- package/dist/types/components/GroupButton.d.ts +19 -0
- package/dist/types/components/Input.d.ts +1 -1
- package/dist/types/components/Modal.d.ts +2 -2
- package/dist/types/components/ProgressBar.d.ts +9 -0
- package/dist/types/components/SearchInput.d.ts +0 -1
- package/dist/types/components/Select.d.ts +0 -1
- package/dist/types/components/Skeleton.d.ts +4 -0
- package/dist/types/components/Table.d.ts +1 -0
- package/dist/types/components/index.d.ts +6 -0
- package/dist/types/components/utils.d.ts +1 -0
- package/dist/types/styles/groupButton.d.ts +77 -0
- package/dist/types/styles/index.d.ts +2 -0
- package/dist/types/styles/progressBar.d.ts +78 -0
- package/dist/types/tests/Avatar.test.d.ts +1 -0
- package/dist/types/tests/Badge.test.d.ts +1 -0
- package/dist/types/tests/BreadcrumbItem.test.d.ts +1 -0
- package/dist/types/tests/Breadcrumbs.test.d.ts +1 -0
- package/dist/types/tests/Card.test.d.ts +1 -0
- package/dist/types/tests/Drawer.test.d.ts +1 -0
- package/dist/types/tests/GroupButton.test.d.ts +1 -0
- package/dist/types/tests/Hint.test.d.ts +1 -0
- package/dist/types/tests/Input.test.d.ts +1 -0
- package/dist/types/tests/Modal.test.d.ts +1 -0
- package/dist/types/tests/ProgressBar.test.d.ts +1 -0
- package/dist/types/tests/Tag.test.d.ts +1 -0
- package/dist/types/tests/Toggle.test.d.ts +1 -0
- package/dist/types/tests/utils.test.d.ts +1 -0
- package/package.json +6 -4
- package/dist/types/docs/badge-anchor.stories.d.ts +0 -29
- package/dist/types/docs/badge.stories.d.ts +0 -27
- package/dist/types/docs/button.stories.d.ts +0 -30
- package/dist/types/docs/card.stories.d.ts +0 -10
- package/dist/types/docs/hint.stories.d.ts +0 -27
- package/dist/types/docs/input-custom.stories.d.ts +0 -33
- package/dist/types/docs/input.stories.d.ts +0 -33
- package/dist/types/docs/modal.stories.d.ts +0 -10
- package/dist/types/docs/select-grouped.stories.d.ts +0 -32
- package/dist/types/docs/select.stories.d.ts +0 -32
- package/dist/types/docs/snackbar.stories.d.ts +0 -21
- package/dist/types/docs/table.stories.d.ts +0 -10
- package/dist/types/docs/tag.stories.d.ts +0 -21
- package/dist/types/docs/text-area.stories.d.ts +0 -39
- package/dist/types/docs/toggle.stories.d.ts +0 -10
- package/dist/types/docs/utils.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# TecSinapse Design System
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/tecsinapse/design-system/actions/workflows/publish.yml)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Welcome to [TecSinapse](https://www.tecsinapse.com.br/) Design System. This repo contains core components to build web and mobile applications.
|
|
6
|
+
Our primary goal is to create a system that can be used to build a wide variety of TecSinapse websites and apps,
|
|
7
|
+
while providing a consistent and inclusive user experience to our end users.
|
|
8
|
+
In addition, the design system and component library should be easy to use for developers and designers.
|
|
6
9
|
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
Please refer to the official [documentation](https://tecsinapse.github.io/design-system).
|
|
13
|
+
|
|
14
|
+
## Packages
|
|
15
|
+
|
|
16
|
+
| Package | Content | Version |
|
|
17
|
+
| --------------------------------------------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
18
|
+
| **[@tecsinapse/react-core](./packages/react-core)** | core primitives for `CSS-in-JS` packages | [](https://badge.fury.io/js/%40tecsinapse%2Freact-core) |
|
|
19
|
+
| **[@tecsinapse/react-web-kit](./packages/react-web-kit)** | emotion `styled-components` for browsers with `react-native-web` | [](https://badge.fury.io/js/%40tecsinapse%2Freact-web-kit) |
|
|
20
|
+
| **[@tecsinapse/react-native-kit](./packages/react-native-kit)** | emotion native `styled-components` for `react-native` cross platform development | [](https://badge.fury.io/js/%40tecsinapse%2Freact-native-kit) |
|
|
21
|
+
| **[@tecsinapse/react-charts](./packages/react-charts)** | charts for react & react-native based on SVG | [](https://badge.fury.io/js/%40tecsinapse%2Freact-charts) |
|
|
22
|
+
| **[@tecsinapse/cortex-core](./packages/cortex-core)** | core primitives for `tailwindcss` packages | [](https://badge.fury.io/js/%40tecsinapse%2Fcortex-core) |
|
|
23
|
+
| **[@tecsinapse/cortex-react](./packages/cortex-react)** | `html` based components using `cortex-core` primitives | [](https://badge.fury.io/js/%40tecsinapse%2Fcortex-react) |
|
|
24
|
+
|
|
25
|
+
## Code of conduct
|
|
26
|
+
|
|
27
|
+
We want to foster an inclusive and friendly community around our Open Source efforts. This project follows the Contributor Covenant Code of Conduct.
|
|
28
|
+
Please, [read it and follow it](./CODE_OF_CONDUCT.md).
|
|
29
|
+
|
|
30
|
+
If you feel another member of the community violated our code or you are experiencing problems participating in our community because of another individual's behavior,
|
|
31
|
+
please get in touch with our maintainers.
|
|
32
|
+
|
|
33
|
+
## Running locally
|
|
34
|
+
|
|
35
|
+
Recommended requirements:
|
|
36
|
+
|
|
37
|
+
- `pnpm` >= 9
|
|
38
|
+
- `node` >= 20
|
|
39
|
+
|
|
40
|
+
To run locally, you should install the dependencies first:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
pnpm i
|
|
7
44
|
```
|
|
8
|
-
const index = require('cortex-react');
|
|
9
45
|
|
|
10
|
-
|
|
46
|
+
After this script, all packages will build. When developing, for a better experience, also use:
|
|
47
|
+
|
|
11
48
|
```
|
|
49
|
+
pnpm dev
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
This script watch for changes on any package and rebuild files to reflect on live mode. To run storybook with all components, use:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
pnpm storybook
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
For web development this is sufficient. For mobile, follow additional steps on [rn-playground](./packages/rn-playground).
|
|
59
|
+
|
|
60
|
+
## How to make local changes available for other projects?
|
|
61
|
+
|
|
62
|
+
Check [these docs](https://pnpm.io/cli/link).
|
|
63
|
+
|
|
64
|
+
## Contributing
|
|
65
|
+
|
|
66
|
+
If you have ideas for how we could improve this readme or the project in general, [let us know](https://github.com/tecsinapse/design-system/issues)!
|
|
67
|
+
|
|
68
|
+
## About TecSinapse
|
|
69
|
+
|
|
70
|
+
[TecSinapse](https://www.tecsinapse.com.br/) is a specialist in the automotive industry for over 15 years.
|
|
71
|
+
We operate with diverse integrated solutions, from client prospecting to after-sales, plus market indicators tools and process improvement for complete management.\_
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var clsx = require('clsx');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var utils = require('./utils.js');
|
|
6
|
+
|
|
7
|
+
const Avatar = ({ src, name, className, ...rest }) => {
|
|
8
|
+
const [hasError, setHasError] = React.useState(false);
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
setHasError(false);
|
|
11
|
+
}, [src]);
|
|
12
|
+
return /* @__PURE__ */ React.createElement(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
...rest,
|
|
16
|
+
className: clsx(
|
|
17
|
+
"rounded-pill bg-secondary-dark w-mega h-mega flex items-center justify-center cursor-pointer",
|
|
18
|
+
className
|
|
19
|
+
)
|
|
20
|
+
},
|
|
21
|
+
src && !hasError ? /* @__PURE__ */ React.createElement(
|
|
22
|
+
"img",
|
|
23
|
+
{
|
|
24
|
+
src,
|
|
25
|
+
alt: name,
|
|
26
|
+
className: "rounded-pill",
|
|
27
|
+
onError: () => setHasError(true),
|
|
28
|
+
"data-testid": "avatar-img"
|
|
29
|
+
}
|
|
30
|
+
) : /* @__PURE__ */ React.createElement("p", { className: "font-bold text-white text-base", "data-testid": "avatar-p" }, utils.getNameInitials(name))
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.Avatar = Avatar;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var md = require('react-icons/md');
|
|
5
|
+
|
|
6
|
+
const BreadcrumbItem = ({
|
|
7
|
+
isLast,
|
|
8
|
+
Component,
|
|
9
|
+
componentProps,
|
|
10
|
+
title
|
|
11
|
+
}) => {
|
|
12
|
+
return /* @__PURE__ */ React.createElement(Component, { ...componentProps, key: title }, /* @__PURE__ */ React.createElement("div", { className: "flex gap-x-mili items-center" }, /* @__PURE__ */ React.createElement(
|
|
13
|
+
"p",
|
|
14
|
+
{
|
|
15
|
+
className: isLast ? "text-secondary-medium" : "text-secondary-xdark"
|
|
16
|
+
},
|
|
17
|
+
title
|
|
18
|
+
), !isLast ? /* @__PURE__ */ React.createElement(
|
|
19
|
+
md.MdOutlineKeyboardDoubleArrowRight,
|
|
20
|
+
{
|
|
21
|
+
className: "mt-[0.125rem] text-primary-medium",
|
|
22
|
+
"data-testid": "breadcrumb-item-icon"
|
|
23
|
+
}
|
|
24
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null)));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.BreadcrumbItem = BreadcrumbItem;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var BreadcrumbItem = require('./BreadcrumbItem.js');
|
|
5
|
+
var Card = require('./Card.js');
|
|
6
|
+
|
|
7
|
+
const Breadcrumbs = (props) => {
|
|
8
|
+
const { breadcrumbs, ...rest } = props;
|
|
9
|
+
return /* @__PURE__ */ React.createElement(Card.Card, { className: "flex gap-x-mili w-full items-center py-mili", ...rest }, breadcrumbs.map((item, index) => {
|
|
10
|
+
const isLast = index === breadcrumbs.length - 1;
|
|
11
|
+
return /* @__PURE__ */ React.createElement(
|
|
12
|
+
BreadcrumbItem.BreadcrumbItem,
|
|
13
|
+
{
|
|
14
|
+
key: `${item.title}-${index}`,
|
|
15
|
+
...item,
|
|
16
|
+
isLast
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.Breadcrumbs = Breadcrumbs;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var React = require('react');
|
|
4
3
|
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var React = require('react');
|
|
5
5
|
|
|
6
6
|
const Card = React.forwardRef((props, ref) => {
|
|
7
7
|
const { children, className, ...rest } = props;
|
|
8
|
-
return /* @__PURE__ */ React.createElement(
|
|
9
|
-
"div",
|
|
10
|
-
{
|
|
11
|
-
className: cortexCore.card({ className }),
|
|
12
|
-
ref,
|
|
13
|
-
...rest
|
|
14
|
-
},
|
|
15
|
-
children
|
|
16
|
-
);
|
|
8
|
+
return /* @__PURE__ */ React.createElement("div", { className: cortexCore.card({ className }), ref, ...rest }, children);
|
|
17
9
|
});
|
|
18
10
|
|
|
19
11
|
exports.Card = Card;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const Drawer = ({
|
|
7
|
+
children,
|
|
8
|
+
onClose,
|
|
9
|
+
open,
|
|
10
|
+
position = "right"
|
|
11
|
+
}) => {
|
|
12
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
"data-testid": "overlay",
|
|
16
|
+
className: cortexCore.overlay({ show: open }),
|
|
17
|
+
onClick: onClose
|
|
18
|
+
}
|
|
19
|
+
), /* @__PURE__ */ React.createElement(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
"data-testid": "drawer",
|
|
23
|
+
className: cortexCore.drawer({
|
|
24
|
+
position,
|
|
25
|
+
open
|
|
26
|
+
})
|
|
27
|
+
},
|
|
28
|
+
children
|
|
29
|
+
));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.Drawer = Drawer;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var clsx = require('clsx');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
require('../styles/progressBar.js');
|
|
6
|
+
var groupButton = require('../styles/groupButton.js');
|
|
7
|
+
|
|
8
|
+
const { button, container, active, inactive, firstButton, lastButton } = groupButton.groupButton();
|
|
9
|
+
const GroupButton = (props) => {
|
|
10
|
+
const {
|
|
11
|
+
options,
|
|
12
|
+
value,
|
|
13
|
+
renderKey,
|
|
14
|
+
renderOption,
|
|
15
|
+
onChange,
|
|
16
|
+
customStyles,
|
|
17
|
+
disableAllOptions
|
|
18
|
+
} = props;
|
|
19
|
+
return /* @__PURE__ */ React.createElement("div", { className: container(), "data-testid": "group-button-container" }, options.map((option) => {
|
|
20
|
+
const key = renderKey?.(option.value);
|
|
21
|
+
const isActive = key === renderKey?.(value);
|
|
22
|
+
return /* @__PURE__ */ React.createElement(
|
|
23
|
+
"button",
|
|
24
|
+
{
|
|
25
|
+
disabled: disableAllOptions,
|
|
26
|
+
value: String(value),
|
|
27
|
+
onClick: () => onChange(option.value),
|
|
28
|
+
className: clsx(
|
|
29
|
+
button(),
|
|
30
|
+
firstButton({ className: customStyles?.firstButton }),
|
|
31
|
+
lastButton({ className: customStyles?.lastButton }),
|
|
32
|
+
!isActive && inactive({ className: customStyles?.inactive }),
|
|
33
|
+
isActive && active({ className: customStyles?.active })
|
|
34
|
+
),
|
|
35
|
+
key
|
|
36
|
+
},
|
|
37
|
+
renderOption(option.value)
|
|
38
|
+
);
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
exports.GroupButton = GroupButton;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var React = require('react');
|
|
4
3
|
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
4
|
var clsx = require('clsx');
|
|
5
|
+
var React = require('react');
|
|
6
6
|
|
|
7
7
|
const getValidChildren = (children) => {
|
|
8
8
|
return React.Children.toArray(children).filter(
|
|
@@ -19,13 +19,15 @@ const Box = React.forwardRef(
|
|
|
19
19
|
placeholder: placeholder ?? " ",
|
|
20
20
|
className: clsx.clsx(cortexCore.inputBox(placeholder, label, className)),
|
|
21
21
|
...rest,
|
|
22
|
-
ref
|
|
22
|
+
ref,
|
|
23
|
+
"data-testid": "input-input"
|
|
23
24
|
}
|
|
24
25
|
), /* @__PURE__ */ React.createElement(
|
|
25
26
|
"label",
|
|
26
27
|
{
|
|
27
28
|
htmlFor: id ?? name,
|
|
28
|
-
className: cortexCore.labelStyle({ intent: variants?.intent, placeholder })
|
|
29
|
+
className: cortexCore.labelStyle({ intent: variants?.intent, placeholder }),
|
|
30
|
+
"data-testid": "input-label"
|
|
29
31
|
},
|
|
30
32
|
label
|
|
31
33
|
));
|
|
@@ -5,21 +5,14 @@ var cortexCore = require('@tecsinapse/cortex-core');
|
|
|
5
5
|
|
|
6
6
|
const Modal = React.forwardRef((props, ref) => {
|
|
7
7
|
const { open, onClose, children, className } = props;
|
|
8
|
-
return /* @__PURE__ */ React.createElement(
|
|
8
|
+
return /* @__PURE__ */ React.createElement("div", { ref, ...props }, /* @__PURE__ */ React.createElement(
|
|
9
9
|
"div",
|
|
10
10
|
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
{
|
|
17
|
-
className: cortexCore.overlay({ show: open }),
|
|
18
|
-
onClick: onClose
|
|
19
|
-
}
|
|
20
|
-
),
|
|
21
|
-
/* @__PURE__ */ React.createElement("dialog", { className: cortexCore.modal({ open, className }) }, children)
|
|
22
|
-
);
|
|
11
|
+
"data-testid": "overlay",
|
|
12
|
+
className: cortexCore.overlay({ show: open }),
|
|
13
|
+
onClick: onClose
|
|
14
|
+
}
|
|
15
|
+
), /* @__PURE__ */ React.createElement("dialog", { "data-testid": "modal", className: cortexCore.modal({ open, className }) }, children));
|
|
23
16
|
});
|
|
24
17
|
|
|
25
18
|
exports.Modal = Modal;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var clsx = require('clsx');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var progressBar = require('../styles/progressBar.js');
|
|
6
|
+
require('../styles/groupButton.js');
|
|
7
|
+
|
|
8
|
+
const ProgressBar = ({
|
|
9
|
+
segments: _segments = 1,
|
|
10
|
+
valueMin = 0,
|
|
11
|
+
valueMax = 100,
|
|
12
|
+
valueCurrent = 50,
|
|
13
|
+
intentProgress = "default",
|
|
14
|
+
animated = true
|
|
15
|
+
}) => {
|
|
16
|
+
const [displayedValue, setDisplayedValue] = React.useState(0);
|
|
17
|
+
const [showAnimation, setShowAnimation] = React.useState(true);
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
const timeout = setTimeout(() => {
|
|
20
|
+
if (valueCurrent < displayedValue) {
|
|
21
|
+
setShowAnimation(false);
|
|
22
|
+
}
|
|
23
|
+
if (animated && valueCurrent > displayedValue) setShowAnimation(true);
|
|
24
|
+
setDisplayedValue(valueCurrent);
|
|
25
|
+
}, 0);
|
|
26
|
+
return () => clearTimeout(timeout);
|
|
27
|
+
}, [valueCurrent]);
|
|
28
|
+
const progressStyle = React.useCallback(
|
|
29
|
+
(width, index) => {
|
|
30
|
+
return {
|
|
31
|
+
width: `${width}%`,
|
|
32
|
+
transitionDelay: `${showAnimation ? `${index * 1e3}ms` : `0ms`}`
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
[showAnimation]
|
|
36
|
+
);
|
|
37
|
+
const totalProgress = (displayedValue - valueMin) / (valueMax - valueMin) * 100;
|
|
38
|
+
const segments = Math.max(1, _segments);
|
|
39
|
+
const lengthSeg = 100 / Math.max(segments);
|
|
40
|
+
const items = [...Array(segments).keys()];
|
|
41
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex gap-x-nano flex-row" }, items.map((_, index) => {
|
|
42
|
+
const max = lengthSeg * (index + 1);
|
|
43
|
+
const min = lengthSeg * index;
|
|
44
|
+
const minmax = (totalProgress - min) / (max - min);
|
|
45
|
+
const width = (minmax > 1 ? 1 : minmax < 0 ? 0 : minmax) * 100;
|
|
46
|
+
return /* @__PURE__ */ React.createElement(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
"data-testid": "progress-bar",
|
|
50
|
+
key: index,
|
|
51
|
+
className: clsx(
|
|
52
|
+
"h-[0.5rem] bg-secondary-light flex flex-1 first:rounded-l-pill last:rounded-r-pill"
|
|
53
|
+
)
|
|
54
|
+
},
|
|
55
|
+
/* @__PURE__ */ React.createElement(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
"data-testid": "div-segment-filled",
|
|
59
|
+
style: progressStyle(width, index),
|
|
60
|
+
className: progressBar.progressBarFilled({
|
|
61
|
+
intentProgress,
|
|
62
|
+
showAnimation
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.ProgressBar = ProgressBar;
|
|
@@ -13,6 +13,11 @@ require('./Tag.js');
|
|
|
13
13
|
require('./Toggle.js');
|
|
14
14
|
require('./TextArea.js');
|
|
15
15
|
require('@tecsinapse/cortex-core');
|
|
16
|
+
require('react-icons/md');
|
|
17
|
+
require('clsx');
|
|
18
|
+
require('../styles/progressBar.js');
|
|
19
|
+
require('../styles/groupButton.js');
|
|
20
|
+
require('./GroupButton.js');
|
|
16
21
|
var ai = require('react-icons/ai');
|
|
17
22
|
var io5 = require('react-icons/io5');
|
|
18
23
|
var useDebouncedState = require('../hooks/useDebouncedState.js');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var clsx = require('clsx');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
const Skeleton = ({
|
|
7
|
+
className,
|
|
8
|
+
children,
|
|
9
|
+
...rest
|
|
10
|
+
}) => {
|
|
11
|
+
return /* @__PURE__ */ React.createElement(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
...rest,
|
|
15
|
+
className: clsx("animate-pulse bg-secondary-light", className)
|
|
16
|
+
},
|
|
17
|
+
children
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.Skeleton = Skeleton;
|
|
@@ -18,6 +18,9 @@ const THeadCell = ({
|
|
|
18
18
|
className,
|
|
19
19
|
...rest
|
|
20
20
|
}) => /* @__PURE__ */ React.createElement("th", { className: cortexCore.tHeadCell({ className }), ...rest }, children);
|
|
21
|
+
const TRowHeader = ({
|
|
22
|
+
children
|
|
23
|
+
}) => /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("tr", { className: cortexCore.tRow() }, children), /* @__PURE__ */ React.createElement("tr", { className: cortexCore.tRow() }, /* @__PURE__ */ React.createElement("td", { colSpan: 99 }, /* @__PURE__ */ React.createElement("hr", { className: cortexCore.hr() }))));
|
|
21
24
|
const TCell = ({
|
|
22
25
|
children,
|
|
23
26
|
className,
|
|
@@ -41,7 +44,7 @@ const Hr = ({
|
|
|
41
44
|
const Td = ({
|
|
42
45
|
children,
|
|
43
46
|
...rest
|
|
44
|
-
}) => /* @__PURE__ */ React.createElement("td", {
|
|
47
|
+
}) => /* @__PURE__ */ React.createElement("td", { ...rest }, children);
|
|
45
48
|
|
|
46
49
|
exports.Hr = Hr;
|
|
47
50
|
exports.TCell = TCell;
|
|
@@ -49,5 +52,6 @@ exports.TFoot = TFoot;
|
|
|
49
52
|
exports.THead = THead;
|
|
50
53
|
exports.THeadCell = THeadCell;
|
|
51
54
|
exports.TRow = TRow;
|
|
55
|
+
exports.TRowHeader = TRowHeader;
|
|
52
56
|
exports.Table = Table;
|
|
53
57
|
exports.Td = Td;
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var React = require('react');
|
|
4
3
|
var cortexCore = require('@tecsinapse/cortex-core');
|
|
4
|
+
var React = require('react');
|
|
5
5
|
|
|
6
6
|
const Toggle = React.forwardRef((props, ref) => {
|
|
7
|
-
return /* @__PURE__ */ React.createElement(
|
|
8
|
-
"
|
|
7
|
+
return /* @__PURE__ */ React.createElement(
|
|
8
|
+
"div",
|
|
9
9
|
{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
className: "flex flex-row items-center gap-x-centi",
|
|
11
|
+
"data-testid": "toggle-div"
|
|
12
|
+
},
|
|
13
|
+
/* @__PURE__ */ React.createElement("label", { className: cortexCore.styleLabelElement() }, /* @__PURE__ */ React.createElement(
|
|
14
|
+
"input",
|
|
15
|
+
{
|
|
16
|
+
type: "checkbox",
|
|
17
|
+
className: cortexCore.styleInputElement(),
|
|
18
|
+
ref,
|
|
19
|
+
"data-testid": "toggle-input",
|
|
20
|
+
...props
|
|
21
|
+
}
|
|
22
|
+
), /* @__PURE__ */ React.createElement("div", { className: cortexCore.toggle() }))
|
|
23
|
+
);
|
|
16
24
|
});
|
|
17
25
|
|
|
18
26
|
exports.Toggle = Toggle;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const getNameInitials = (name) => {
|
|
4
|
+
const nameSplit = name.split(" ");
|
|
5
|
+
const length = nameSplit.length;
|
|
6
|
+
if (length > 1) {
|
|
7
|
+
return `${nameSplit[0][0]}${nameSplit[length - 1][0]}`;
|
|
8
|
+
}
|
|
9
|
+
return name[0];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.getNameInitials = getNameInitials;
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,6 +12,12 @@ var Tag = require('./components/Tag.js');
|
|
|
12
12
|
var Toggle = require('./components/Toggle.js');
|
|
13
13
|
var TextArea = require('./components/TextArea.js');
|
|
14
14
|
var Table = require('./components/Table.js');
|
|
15
|
+
var Drawer = require('./components/Drawer.js');
|
|
16
|
+
var Breadcrumbs = require('./components/Breadcrumbs.js');
|
|
17
|
+
var Avatar = require('./components/Avatar.js');
|
|
18
|
+
var Skeleton = require('./components/Skeleton.js');
|
|
19
|
+
var ProgressBar = require('./components/ProgressBar.js');
|
|
20
|
+
var GroupButton = require('./components/GroupButton.js');
|
|
15
21
|
|
|
16
22
|
|
|
17
23
|
|
|
@@ -38,5 +44,12 @@ exports.TFoot = Table.TFoot;
|
|
|
38
44
|
exports.THead = Table.THead;
|
|
39
45
|
exports.THeadCell = Table.THeadCell;
|
|
40
46
|
exports.TRow = Table.TRow;
|
|
47
|
+
exports.TRowHeader = Table.TRowHeader;
|
|
41
48
|
exports.Table = Table.Table;
|
|
42
49
|
exports.Td = Table.Td;
|
|
50
|
+
exports.Drawer = Drawer.Drawer;
|
|
51
|
+
exports.Breadcrumbs = Breadcrumbs.Breadcrumbs;
|
|
52
|
+
exports.Avatar = Avatar.Avatar;
|
|
53
|
+
exports.Skeleton = Skeleton.Skeleton;
|
|
54
|
+
exports.ProgressBar = ProgressBar.ProgressBar;
|
|
55
|
+
exports.GroupButton = GroupButton.GroupButton;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tailwindVariants = require('tailwind-variants');
|
|
4
|
+
|
|
5
|
+
const groupButton = tailwindVariants.tv({
|
|
6
|
+
slots: {
|
|
7
|
+
button: "border-[1px] border-secondary-medium px-centi py-mili items-center flex text-sub font-bold",
|
|
8
|
+
inactive: "bg-white text-secondary-medium disabled:bg-secondary-light",
|
|
9
|
+
firstButton: "first:rounded-l-mili first:border-r-0",
|
|
10
|
+
lastButton: "last:rounded-r-mili last:border-l-0",
|
|
11
|
+
container: "flex flex-row flex-1 h-[2rem] w-[500px]",
|
|
12
|
+
active: "text-white bg-secondary-medium"
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
exports.groupButton = groupButton;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tailwindVariants = require('tailwind-variants');
|
|
4
|
+
|
|
5
|
+
const progressBarFilled = tailwindVariants.tv({
|
|
6
|
+
base: "h-full first:rounded-l-pill last:rounded-r-pill",
|
|
7
|
+
variants: {
|
|
8
|
+
intentProgress: {
|
|
9
|
+
default: "bg-primary-medium",
|
|
10
|
+
error: "bg-error-medium",
|
|
11
|
+
info: "bg-info-medium",
|
|
12
|
+
warning: "bg-warning-medium",
|
|
13
|
+
success: "bg-success-medium"
|
|
14
|
+
},
|
|
15
|
+
showAnimation: {
|
|
16
|
+
true: "transition-[width] duration-1000 ease-linear"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
exports.progressBarFilled = progressBarFilled;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { getNameInitials } from './utils.js';
|
|
4
|
+
|
|
5
|
+
const Avatar = ({ src, name, className, ...rest }) => {
|
|
6
|
+
const [hasError, setHasError] = React.useState(false);
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
setHasError(false);
|
|
9
|
+
}, [src]);
|
|
10
|
+
return /* @__PURE__ */ React.createElement(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
...rest,
|
|
14
|
+
className: clsx(
|
|
15
|
+
"rounded-pill bg-secondary-dark w-mega h-mega flex items-center justify-center cursor-pointer",
|
|
16
|
+
className
|
|
17
|
+
)
|
|
18
|
+
},
|
|
19
|
+
src && !hasError ? /* @__PURE__ */ React.createElement(
|
|
20
|
+
"img",
|
|
21
|
+
{
|
|
22
|
+
src,
|
|
23
|
+
alt: name,
|
|
24
|
+
className: "rounded-pill",
|
|
25
|
+
onError: () => setHasError(true),
|
|
26
|
+
"data-testid": "avatar-img"
|
|
27
|
+
}
|
|
28
|
+
) : /* @__PURE__ */ React.createElement("p", { className: "font-bold text-white text-base", "data-testid": "avatar-p" }, getNameInitials(name))
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { Avatar };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MdOutlineKeyboardDoubleArrowRight } from 'react-icons/md';
|
|
3
|
+
|
|
4
|
+
const BreadcrumbItem = ({
|
|
5
|
+
isLast,
|
|
6
|
+
Component,
|
|
7
|
+
componentProps,
|
|
8
|
+
title
|
|
9
|
+
}) => {
|
|
10
|
+
return /* @__PURE__ */ React.createElement(Component, { ...componentProps, key: title }, /* @__PURE__ */ React.createElement("div", { className: "flex gap-x-mili items-center" }, /* @__PURE__ */ React.createElement(
|
|
11
|
+
"p",
|
|
12
|
+
{
|
|
13
|
+
className: isLast ? "text-secondary-medium" : "text-secondary-xdark"
|
|
14
|
+
},
|
|
15
|
+
title
|
|
16
|
+
), !isLast ? /* @__PURE__ */ React.createElement(
|
|
17
|
+
MdOutlineKeyboardDoubleArrowRight,
|
|
18
|
+
{
|
|
19
|
+
className: "mt-[0.125rem] text-primary-medium",
|
|
20
|
+
"data-testid": "breadcrumb-item-icon"
|
|
21
|
+
}
|
|
22
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null)));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { BreadcrumbItem };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BreadcrumbItem } from './BreadcrumbItem.js';
|
|
3
|
+
import { Card } from './Card.js';
|
|
4
|
+
|
|
5
|
+
const Breadcrumbs = (props) => {
|
|
6
|
+
const { breadcrumbs, ...rest } = props;
|
|
7
|
+
return /* @__PURE__ */ React.createElement(Card, { className: "flex gap-x-mili w-full items-center py-mili", ...rest }, breadcrumbs.map((item, index) => {
|
|
8
|
+
const isLast = index === breadcrumbs.length - 1;
|
|
9
|
+
return /* @__PURE__ */ React.createElement(
|
|
10
|
+
BreadcrumbItem,
|
|
11
|
+
{
|
|
12
|
+
key: `${item.title}-${index}`,
|
|
13
|
+
...item,
|
|
14
|
+
isLast
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { Breadcrumbs };
|
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
1
|
import { card } from '@tecsinapse/cortex-core';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
3
|
|
|
4
4
|
const Card = forwardRef((props, ref) => {
|
|
5
5
|
const { children, className, ...rest } = props;
|
|
6
|
-
return /* @__PURE__ */ React.createElement(
|
|
7
|
-
"div",
|
|
8
|
-
{
|
|
9
|
-
className: card({ className }),
|
|
10
|
-
ref,
|
|
11
|
-
...rest
|
|
12
|
-
},
|
|
13
|
-
children
|
|
14
|
-
);
|
|
6
|
+
return /* @__PURE__ */ React.createElement("div", { className: card({ className }), ref, ...rest }, children);
|
|
15
7
|
});
|
|
16
8
|
|
|
17
9
|
export { Card };
|