@tecsinapse/cortex-react 1.0.2 → 1.1.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/LICENSE.md +21 -0
- package/dist/cjs/components/Badge.js +27 -0
- package/dist/cjs/components/Button.js +11 -0
- package/dist/cjs/components/Card.js +19 -0
- package/dist/cjs/components/Hint.js +21 -0
- package/dist/cjs/components/Input.js +79 -0
- package/dist/cjs/components/Modal.js +25 -0
- package/dist/cjs/components/SearchInput.js +70 -0
- package/dist/cjs/components/Select.js +101 -0
- package/dist/cjs/components/Snackbar.js +18 -0
- package/dist/cjs/components/Table.js +22 -0
- package/dist/cjs/components/Tag.js +18 -0
- package/dist/cjs/components/TextArea.js +81 -0
- package/dist/cjs/components/Toggle.js +18 -0
- package/dist/cjs/hooks/useDebouncedState.js +16 -0
- package/dist/cjs/index.js +42 -0
- package/dist/esm/components/Badge.js +24 -0
- package/dist/esm/components/Button.js +9 -0
- package/dist/esm/components/Card.js +17 -0
- package/dist/esm/components/Hint.js +19 -0
- package/dist/esm/components/Input.js +72 -0
- package/dist/esm/components/Modal.js +23 -0
- package/dist/esm/components/SearchInput.js +68 -0
- package/dist/esm/components/Select.js +96 -0
- package/dist/esm/components/Snackbar.js +16 -0
- package/dist/esm/components/Table.js +13 -0
- package/dist/esm/components/Tag.js +16 -0
- package/dist/esm/components/TextArea.js +79 -0
- package/dist/esm/components/Toggle.js +16 -0
- package/dist/esm/hooks/useDebouncedState.js +14 -0
- package/dist/esm/index.js +12 -0
- package/dist/types/components/Badge.d.ts +12 -0
- package/dist/types/components/Button.d.ts +8 -0
- package/dist/types/components/Card.d.ts +6 -0
- package/dist/types/components/Hint.d.ts +14 -0
- package/dist/types/components/Input.d.ts +34 -0
- package/dist/types/components/Modal.d.ts +8 -0
- package/dist/types/components/SearchInput.d.ts +11 -0
- package/dist/types/components/Select.d.ts +28 -0
- package/dist/types/components/Snackbar.d.ts +9 -0
- package/dist/types/components/Table.d.ts +13 -0
- package/dist/types/components/Tag.d.ts +8 -0
- package/dist/types/components/TextArea.d.ts +24 -0
- package/dist/types/components/Toggle.d.ts +2 -0
- package/{src/components/index.ts → dist/types/components/index.d.ts} +1 -0
- package/dist/types/docs/badge-anchor.stories.d.ts +29 -0
- package/dist/types/docs/badge.stories.d.ts +27 -0
- package/dist/types/docs/button.stories.d.ts +30 -0
- package/dist/types/docs/card.stories.d.ts +10 -0
- package/dist/types/docs/hint.stories.d.ts +27 -0
- package/dist/types/docs/input-custom.stories.d.ts +33 -0
- package/dist/types/docs/input.stories.d.ts +33 -0
- package/dist/types/docs/modal.stories.d.ts +10 -0
- package/dist/types/docs/select-grouped.stories.d.ts +32 -0
- package/dist/types/docs/select.stories.d.ts +32 -0
- package/dist/types/docs/snackbar.stories.d.ts +21 -0
- package/dist/types/docs/table.stories.d.ts +10 -0
- package/dist/types/docs/tag.stories.d.ts +21 -0
- package/dist/types/docs/text-area.stories.d.ts +39 -0
- package/dist/types/docs/toggle.stories.d.ts +10 -0
- package/dist/types/docs/utils.d.ts +1 -0
- package/dist/types/hooks/useDebouncedState.d.ts +2 -0
- package/package.json +19 -14
- package/src/components/Badge.tsx +0 -45
- package/src/components/Button.tsx +0 -19
- package/src/components/Card.tsx +0 -18
- package/src/components/Hint.tsx +0 -31
- package/src/components/Input.tsx +0 -110
- package/src/components/Modal.tsx +0 -24
- package/src/components/SearchInput.tsx +0 -86
- package/src/components/Select.tsx +0 -170
- package/src/components/Snackbar.tsx +0 -26
- package/src/components/Tag.tsx +0 -19
- package/src/components/TextArea.tsx +0 -121
- package/src/components/Toggle.tsx +0 -25
- package/src/docs/badge-anchor.stories.tsx +0 -42
- package/src/docs/badge.stories.tsx +0 -31
- package/src/docs/button.stories.tsx +0 -37
- package/src/docs/card.stories.tsx +0 -29
- package/src/docs/hint.stories.tsx +0 -32
- package/src/docs/input-custom.stories.tsx +0 -45
- package/src/docs/input.stories.tsx +0 -40
- package/src/docs/modal.stories.tsx +0 -48
- package/src/docs/select-grouped.stories.tsx +0 -79
- package/src/docs/select.stories.tsx +0 -70
- package/src/docs/snackbar.stories.tsx +0 -31
- package/src/docs/tag.stories.tsx +0 -37
- package/src/docs/text-area.stories.tsx +0 -50
- package/src/docs/toggle.stories.tsx +0 -18
- package/src/docs/utils.ts +0 -8
- package/src/hooks/useDebouncedState.ts +0 -24
- /package/{src/hooks/index.ts → dist/types/hooks/index.d.ts} +0 -0
- /package/{src/index.ts → dist/types/index.d.ts} +0 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 TecSinapse
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const Badge = React.forwardRef((props, ref) => {
|
|
7
|
+
const { value, variants, ...rest } = props;
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
ref,
|
|
12
|
+
className: cortexCore.badge({
|
|
13
|
+
className: `relative ${variants?.className}`,
|
|
14
|
+
intent: variants?.intent
|
|
15
|
+
}),
|
|
16
|
+
...rest
|
|
17
|
+
},
|
|
18
|
+
value
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
const BadgeAnchor = React.forwardRef((props, ref) => {
|
|
22
|
+
const { value, variants, children, ...rest } = props;
|
|
23
|
+
return /* @__PURE__ */ React.createElement("div", { className: cortexCore.containerBadge() }, children, /* @__PURE__ */ React.createElement("div", { ref, className: cortexCore.badge(variants), ...rest }, value));
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
exports.Badge = Badge;
|
|
27
|
+
exports.BadgeAnchor = BadgeAnchor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const Button = React.forwardRef((props, ref) => {
|
|
7
|
+
const { variants, children, ...rest } = props;
|
|
8
|
+
return /* @__PURE__ */ React.createElement("button", { className: cortexCore.button(variants), ref, ...rest }, children);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
exports.Button = Button;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const Card = React.forwardRef((props, ref) => {
|
|
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
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
exports.Card = Card;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const Hint = React.forwardRef(
|
|
7
|
+
(props, ref) => {
|
|
8
|
+
const { description, children, variants } = props;
|
|
9
|
+
return /* @__PURE__ */ React.createElement(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
className: cortexCore.hint(variants),
|
|
13
|
+
ref
|
|
14
|
+
},
|
|
15
|
+
description ? /* @__PURE__ */ React.createElement("p", null, description) : /* @__PURE__ */ React.createElement(React.Fragment, null),
|
|
16
|
+
children
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
exports.Hint = Hint;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
|
|
7
|
+
const getValidChildren = (children) => {
|
|
8
|
+
return React.Children.toArray(children).filter(
|
|
9
|
+
(el) => React.isValidElement(el)
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
const Box = React.forwardRef(
|
|
13
|
+
({ id, name, variants, label, placeholder, className, ...rest }, ref) => {
|
|
14
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col" }, /* @__PURE__ */ React.createElement(
|
|
15
|
+
"input",
|
|
16
|
+
{
|
|
17
|
+
id: id ?? name,
|
|
18
|
+
name,
|
|
19
|
+
placeholder: placeholder ?? " ",
|
|
20
|
+
className: clsx.clsx(cortexCore.inputBox(placeholder, label, className)),
|
|
21
|
+
...rest,
|
|
22
|
+
ref
|
|
23
|
+
}
|
|
24
|
+
), /* @__PURE__ */ React.createElement(
|
|
25
|
+
"label",
|
|
26
|
+
{
|
|
27
|
+
htmlFor: id ?? name,
|
|
28
|
+
className: cortexCore.labelStyle({ intent: variants?.intent, placeholder })
|
|
29
|
+
},
|
|
30
|
+
label
|
|
31
|
+
));
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
const Face = React.forwardRef(
|
|
35
|
+
({ children, variants, className, ...rest }, ref) => {
|
|
36
|
+
const clones = getValidChildren(children).map((el) => {
|
|
37
|
+
return React.cloneElement(el, { ...el.props, variants });
|
|
38
|
+
});
|
|
39
|
+
return /* @__PURE__ */ React.createElement(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
...rest,
|
|
43
|
+
className: clsx.clsx(cortexCore.input(variants), className),
|
|
44
|
+
id: "input-face",
|
|
45
|
+
ref
|
|
46
|
+
},
|
|
47
|
+
clones
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
const Root = React.forwardRef(
|
|
52
|
+
({ variants, className, ...rest }, ref) => {
|
|
53
|
+
return /* @__PURE__ */ React.createElement(Face, { variants, className }, /* @__PURE__ */ React.createElement(Box, { ...rest, ref }));
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
const Left = React.forwardRef(
|
|
57
|
+
({ children, className, ...rest }, ref) => {
|
|
58
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx.clsx(className, "mr-2.5"), ...rest, ref }, children);
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
const Right = React.forwardRef(
|
|
62
|
+
({ children, className, ...rest }, ref) => {
|
|
63
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx.clsx(className, "ml-2.5"), ...rest, ref }, children);
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
const Input = {
|
|
67
|
+
Root,
|
|
68
|
+
Face,
|
|
69
|
+
Box,
|
|
70
|
+
Left,
|
|
71
|
+
Right
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
exports.Box = Box;
|
|
75
|
+
exports.Face = Face;
|
|
76
|
+
exports.Input = Input;
|
|
77
|
+
exports.Left = Left;
|
|
78
|
+
exports.Right = Right;
|
|
79
|
+
exports.Root = Root;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const Modal = React.forwardRef((props, ref) => {
|
|
7
|
+
const { open, onClose, children, className } = props;
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
ref,
|
|
12
|
+
...props
|
|
13
|
+
},
|
|
14
|
+
/* @__PURE__ */ React.createElement(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
className: cortexCore.overlay({ show: open }),
|
|
18
|
+
onClick: onClose
|
|
19
|
+
}
|
|
20
|
+
),
|
|
21
|
+
/* @__PURE__ */ React.createElement("dialog", { className: cortexCore.modal({ open, className }) }, children)
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
exports.Modal = Modal;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
require('./Badge.js');
|
|
5
|
+
var Button = require('./Button.js');
|
|
6
|
+
require('./Card.js');
|
|
7
|
+
require('./Hint.js');
|
|
8
|
+
var Input = require('./Input.js');
|
|
9
|
+
require('./Modal.js');
|
|
10
|
+
require('./Select.js');
|
|
11
|
+
require('./Snackbar.js');
|
|
12
|
+
require('./Tag.js');
|
|
13
|
+
require('./Toggle.js');
|
|
14
|
+
require('./TextArea.js');
|
|
15
|
+
require('@tecsinapse/cortex-core');
|
|
16
|
+
var ai = require('react-icons/ai');
|
|
17
|
+
var io5 = require('react-icons/io5');
|
|
18
|
+
var useDebouncedState = require('../hooks/useDebouncedState.js');
|
|
19
|
+
|
|
20
|
+
const inputFace = "bg-white w-full";
|
|
21
|
+
const inputLeft = "flex items-center";
|
|
22
|
+
const SearchInput = ({
|
|
23
|
+
label,
|
|
24
|
+
placeholder,
|
|
25
|
+
isSubmitting = false,
|
|
26
|
+
onChange,
|
|
27
|
+
onClick,
|
|
28
|
+
BOUNCE_TIMEOUT = 1e3
|
|
29
|
+
}) => {
|
|
30
|
+
const [bouncedText, setBouncedText] = React.useState("");
|
|
31
|
+
const [searchInput, setSearchInput] = useDebouncedState.useDebouncedState(
|
|
32
|
+
"",
|
|
33
|
+
setBouncedText,
|
|
34
|
+
BOUNCE_TIMEOUT
|
|
35
|
+
);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
if (onChange) {
|
|
38
|
+
onChange(bouncedText);
|
|
39
|
+
}
|
|
40
|
+
}, [bouncedText]);
|
|
41
|
+
const handleEnterKey = (e) => {
|
|
42
|
+
if (e.key === "Enter" && onClick && searchInput) {
|
|
43
|
+
onClick(searchInput);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex flex-row w-full space-x-mili" }, /* @__PURE__ */ React.createElement(Input.Input.Face, { variants: { className: inputFace } }, !onClick && /* @__PURE__ */ React.createElement(Input.Input.Left, { className: inputLeft }, /* @__PURE__ */ React.createElement(io5.IoSearchOutline, null)), /* @__PURE__ */ React.createElement(
|
|
47
|
+
Input.Input.Box,
|
|
48
|
+
{
|
|
49
|
+
placeholder,
|
|
50
|
+
label,
|
|
51
|
+
onChange: (e) => setSearchInput(e.target.value),
|
|
52
|
+
onKeyDown: handleEnterKey,
|
|
53
|
+
disabled: isSubmitting
|
|
54
|
+
}
|
|
55
|
+
)), onClick && /* @__PURE__ */ React.createElement(
|
|
56
|
+
Button.Button,
|
|
57
|
+
{
|
|
58
|
+
variants: {
|
|
59
|
+
intent: "primary",
|
|
60
|
+
size: "square",
|
|
61
|
+
className: "h-11"
|
|
62
|
+
},
|
|
63
|
+
onClick: () => onClick(searchInput),
|
|
64
|
+
disabled: !searchInput || isSubmitting
|
|
65
|
+
},
|
|
66
|
+
isSubmitting ? /* @__PURE__ */ React.createElement("div", { className: "animate-spin" }, /* @__PURE__ */ React.createElement(ai.AiOutlineLoading, null)) : /* @__PURE__ */ React.createElement(io5.IoSearchOutline, null)
|
|
67
|
+
));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
module.exports = SearchInput;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var Hint = require('./Hint.js');
|
|
8
|
+
var io5 = require('react-icons/io5');
|
|
9
|
+
var io = require('react-icons/io');
|
|
10
|
+
var SearchInput = require('./SearchInput.js');
|
|
11
|
+
|
|
12
|
+
const { button, dropdown, groupedTitle, containerGrouped, hintBody } = cortexCore.selectVariants();
|
|
13
|
+
const Select = (props) => {
|
|
14
|
+
const {
|
|
15
|
+
label,
|
|
16
|
+
keyExtractor,
|
|
17
|
+
labelExtractor,
|
|
18
|
+
options,
|
|
19
|
+
value,
|
|
20
|
+
onSelect,
|
|
21
|
+
onSearch,
|
|
22
|
+
disabled,
|
|
23
|
+
grouped,
|
|
24
|
+
groupedLabelExtractor,
|
|
25
|
+
hint,
|
|
26
|
+
placeholderSearchInput,
|
|
27
|
+
variant = "default"
|
|
28
|
+
} = props;
|
|
29
|
+
const [open, setOpen] = React.useState(false);
|
|
30
|
+
const placeholder = React.useMemo(
|
|
31
|
+
() => value ? labelExtractor(value) : label,
|
|
32
|
+
[label, labelExtractor, value]
|
|
33
|
+
);
|
|
34
|
+
const ref = React.useRef(null);
|
|
35
|
+
const handleClickOutside = React.useCallback((event) => {
|
|
36
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
37
|
+
setOpen(false);
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
const handleSelect = React.useCallback(
|
|
41
|
+
(option) => {
|
|
42
|
+
onSelect(option);
|
|
43
|
+
setOpen(false);
|
|
44
|
+
},
|
|
45
|
+
[onSelect]
|
|
46
|
+
);
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
document.addEventListener("click", handleClickOutside, true);
|
|
49
|
+
return () => {
|
|
50
|
+
document.removeEventListener("click", handleClickOutside, true);
|
|
51
|
+
};
|
|
52
|
+
}, [handleClickOutside]);
|
|
53
|
+
const Option = ({ option }) => /* @__PURE__ */ React.createElement(
|
|
54
|
+
"li",
|
|
55
|
+
{
|
|
56
|
+
onClick: () => handleSelect(option),
|
|
57
|
+
className: cortexCore.option(),
|
|
58
|
+
role: "option"
|
|
59
|
+
},
|
|
60
|
+
labelExtractor(option)
|
|
61
|
+
);
|
|
62
|
+
const GroupedOptions = ({ options: options2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, [...options2 ?? []].map(([key, value2]) => /* @__PURE__ */ React.createElement("div", { key, className: containerGrouped() }, /* @__PURE__ */ React.createElement("span", { className: groupedTitle() }, groupedLabelExtractor?.(key)), value2.map((option) => /* @__PURE__ */ React.createElement(Option, { option, key: keyExtractor(option) })))));
|
|
63
|
+
const DefaultOptions = ({ options: options2 }) => /* @__PURE__ */ React.createElement(React.Fragment, null, (options2 ?? []).map((option) => /* @__PURE__ */ React.createElement(Option, { option, key: keyExtractor(option) })));
|
|
64
|
+
return /* @__PURE__ */ React.createElement("div", { className: "w-full relative bg-white", ref }, /* @__PURE__ */ React.createElement(
|
|
65
|
+
"button",
|
|
66
|
+
{
|
|
67
|
+
className: button({ disabled, intent: variant }),
|
|
68
|
+
onClick: () => setOpen((prevState) => !prevState),
|
|
69
|
+
disabled
|
|
70
|
+
},
|
|
71
|
+
/* @__PURE__ */ React.createElement("span", null, placeholder),
|
|
72
|
+
/* @__PURE__ */ React.createElement(io5.IoChevronDownOutline, null)
|
|
73
|
+
), /* @__PURE__ */ React.createElement(
|
|
74
|
+
"ul",
|
|
75
|
+
{
|
|
76
|
+
role: "select",
|
|
77
|
+
className: dropdown({
|
|
78
|
+
open
|
|
79
|
+
})
|
|
80
|
+
},
|
|
81
|
+
onSearch ? /* @__PURE__ */ React.createElement("div", { className: "m-mili" }, /* @__PURE__ */ React.createElement(
|
|
82
|
+
SearchInput,
|
|
83
|
+
{
|
|
84
|
+
placeholder: placeholderSearchInput,
|
|
85
|
+
onChange: onSearch
|
|
86
|
+
}
|
|
87
|
+
)) : /* @__PURE__ */ React.createElement(React.Fragment, null),
|
|
88
|
+
grouped ? /* @__PURE__ */ React.createElement(GroupedOptions, { options }) : /* @__PURE__ */ React.createElement(DefaultOptions, { options })
|
|
89
|
+
), hint && /* @__PURE__ */ React.createElement(
|
|
90
|
+
Hint.Hint,
|
|
91
|
+
{
|
|
92
|
+
variants: {
|
|
93
|
+
intent: variant
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
/* @__PURE__ */ React.createElement("div", { className: hintBody() }, variant === "error" ? /* @__PURE__ */ React.createElement(io.IoIosCloseCircleOutline, null) : /* @__PURE__ */ React.createElement(React.Fragment, null), /* @__PURE__ */ React.createElement("span", null, hint))
|
|
97
|
+
));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
exports.Select = Select;
|
|
101
|
+
exports.default = Select;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const Snackbar = React.forwardRef((props, ref) => {
|
|
7
|
+
const { children, show, variants } = props;
|
|
8
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, show ? /* @__PURE__ */ React.createElement(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
className: cortexCore.snackbar(variants),
|
|
12
|
+
ref
|
|
13
|
+
},
|
|
14
|
+
children
|
|
15
|
+
) : /* @__PURE__ */ React.createElement(React.Fragment, null));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
exports.Snackbar = Snackbar;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const THead = ({ children }) => /* @__PURE__ */ React.createElement("thead", { className: cortexCore.tHead() }, children);
|
|
7
|
+
const TRow = ({ children }) => /* @__PURE__ */ React.createElement("tr", { className: cortexCore.tRow() }, children);
|
|
8
|
+
const THeadCell = ({ children }) => /* @__PURE__ */ React.createElement("th", { className: cortexCore.tHeadCell() }, children);
|
|
9
|
+
const TCell = ({ children }) => /* @__PURE__ */ React.createElement("td", { className: cortexCore.tCell() }, children);
|
|
10
|
+
const TFoot = ({ children }) => /* @__PURE__ */ React.createElement("tfoot", { className: cortexCore.tFoot() }, children);
|
|
11
|
+
const Table = ({ children }) => /* @__PURE__ */ React.createElement("table", { className: cortexCore.tRoot() }, children);
|
|
12
|
+
const Hr = ({ children }) => /* @__PURE__ */ React.createElement("hr", { className: cortexCore.hr() }, children);
|
|
13
|
+
const Td = ({ children }) => /* @__PURE__ */ React.createElement("td", { colSpan: 99 }, children);
|
|
14
|
+
|
|
15
|
+
exports.Hr = Hr;
|
|
16
|
+
exports.TCell = TCell;
|
|
17
|
+
exports.TFoot = TFoot;
|
|
18
|
+
exports.THead = THead;
|
|
19
|
+
exports.THeadCell = THeadCell;
|
|
20
|
+
exports.TRow = TRow;
|
|
21
|
+
exports.Table = Table;
|
|
22
|
+
exports.Td = Td;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const Tag = React.forwardRef((props, ref) => {
|
|
7
|
+
const { label, variants } = props;
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
className: cortexCore.tag(variants),
|
|
12
|
+
ref
|
|
13
|
+
},
|
|
14
|
+
/* @__PURE__ */ React.createElement("p", null, label)
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
exports.Tag = Tag;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
|
|
7
|
+
const getValidChildren = (children) => {
|
|
8
|
+
return React.Children.toArray(children).filter(
|
|
9
|
+
(el) => React.isValidElement(el)
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
const Box = React.forwardRef(
|
|
13
|
+
({ id, name, variants, label, placeholder, rows, className, ...rest }, ref) => {
|
|
14
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex w-full flex-col" }, /* @__PURE__ */ React.createElement(
|
|
15
|
+
"textarea",
|
|
16
|
+
{
|
|
17
|
+
ref,
|
|
18
|
+
id: id ?? name,
|
|
19
|
+
name,
|
|
20
|
+
placeholder: placeholder ?? " ",
|
|
21
|
+
className: clsx.clsx(
|
|
22
|
+
cortexCore.inputBox(placeholder, label, className),
|
|
23
|
+
"resize-none mt-mili"
|
|
24
|
+
),
|
|
25
|
+
rows,
|
|
26
|
+
...rest
|
|
27
|
+
}
|
|
28
|
+
), /* @__PURE__ */ React.createElement(
|
|
29
|
+
"label",
|
|
30
|
+
{
|
|
31
|
+
htmlFor: id ?? name,
|
|
32
|
+
className: cortexCore.labelStyle({
|
|
33
|
+
intent: variants?.intent,
|
|
34
|
+
placeholder
|
|
35
|
+
})
|
|
36
|
+
},
|
|
37
|
+
label
|
|
38
|
+
));
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
const Face = React.forwardRef(
|
|
42
|
+
({ children, variants, className, ...rest }, ref) => {
|
|
43
|
+
const clones = getValidChildren(children).map((el) => {
|
|
44
|
+
return React.cloneElement(el, { ...el.props, variants });
|
|
45
|
+
});
|
|
46
|
+
return /* @__PURE__ */ React.createElement(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
ref,
|
|
50
|
+
className: clsx.clsx(cortexCore.input(variants), className),
|
|
51
|
+
id: "textarea-face",
|
|
52
|
+
...rest
|
|
53
|
+
},
|
|
54
|
+
clones
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
const Root = React.forwardRef(
|
|
59
|
+
({ variants, className, ...rest }, ref) => {
|
|
60
|
+
return /* @__PURE__ */ React.createElement(Face, { variants, className }, /* @__PURE__ */ React.createElement(Box, { ref, ...rest }));
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
const Left = React.forwardRef(
|
|
64
|
+
({ children, className, ...rest }, ref) => {
|
|
65
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx.clsx(className, "mr-2.5"), ...rest, ref }, children);
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
const Right = React.forwardRef(
|
|
69
|
+
({ children, className, ...rest }, ref) => {
|
|
70
|
+
return /* @__PURE__ */ React.createElement("div", { className: clsx.clsx(className, "ml-2.5"), ...rest, ref }, children);
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
const TextArea = {
|
|
74
|
+
Root,
|
|
75
|
+
Face,
|
|
76
|
+
Box,
|
|
77
|
+
Left,
|
|
78
|
+
Right
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
exports.TextArea = TextArea;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var cortexCore = require('@tecsinapse/cortex-core');
|
|
5
|
+
|
|
6
|
+
const Toggle = React.forwardRef((props, ref) => {
|
|
7
|
+
return /* @__PURE__ */ React.createElement("div", { className: "flex flex-row items-center gap-x-centi" }, /* @__PURE__ */ React.createElement("label", { className: cortexCore.styleLabelElement() }, /* @__PURE__ */ React.createElement(
|
|
8
|
+
"input",
|
|
9
|
+
{
|
|
10
|
+
type: "checkbox",
|
|
11
|
+
className: cortexCore.styleInputElement(),
|
|
12
|
+
ref,
|
|
13
|
+
...props
|
|
14
|
+
}
|
|
15
|
+
), /* @__PURE__ */ React.createElement("div", { className: cortexCore.toggle() })));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
exports.Toggle = Toggle;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function useDebouncedState(initialState, timeoutCallback, timeoutMs = 166) {
|
|
6
|
+
const timeoutId = React.useRef();
|
|
7
|
+
const [state, setState] = React.useState(initialState);
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
if (timeoutId.current) clearTimeout(timeoutId.current);
|
|
10
|
+
if (timeoutCallback)
|
|
11
|
+
timeoutId.current = setTimeout(() => timeoutCallback(state), timeoutMs);
|
|
12
|
+
}, [state]);
|
|
13
|
+
return [state, setState];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.useDebouncedState = useDebouncedState;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Badge = require('./components/Badge.js');
|
|
4
|
+
var Button = require('./components/Button.js');
|
|
5
|
+
var Card = require('./components/Card.js');
|
|
6
|
+
var Hint = require('./components/Hint.js');
|
|
7
|
+
var Input = require('./components/Input.js');
|
|
8
|
+
var Modal = require('./components/Modal.js');
|
|
9
|
+
var Select = require('./components/Select.js');
|
|
10
|
+
var Snackbar = require('./components/Snackbar.js');
|
|
11
|
+
var Tag = require('./components/Tag.js');
|
|
12
|
+
var Toggle = require('./components/Toggle.js');
|
|
13
|
+
var TextArea = require('./components/TextArea.js');
|
|
14
|
+
var Table = require('./components/Table.js');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.Badge = Badge.Badge;
|
|
19
|
+
exports.BadgeAnchor = Badge.BadgeAnchor;
|
|
20
|
+
exports.Button = Button.Button;
|
|
21
|
+
exports.Card = Card.Card;
|
|
22
|
+
exports.Hint = Hint.Hint;
|
|
23
|
+
exports.Box = Input.Box;
|
|
24
|
+
exports.Face = Input.Face;
|
|
25
|
+
exports.Input = Input.Input;
|
|
26
|
+
exports.Left = Input.Left;
|
|
27
|
+
exports.Right = Input.Right;
|
|
28
|
+
exports.Root = Input.Root;
|
|
29
|
+
exports.Modal = Modal.Modal;
|
|
30
|
+
exports.Select = Select.Select;
|
|
31
|
+
exports.Snackbar = Snackbar.Snackbar;
|
|
32
|
+
exports.Tag = Tag.Tag;
|
|
33
|
+
exports.Toggle = Toggle.Toggle;
|
|
34
|
+
exports.TextArea = TextArea.TextArea;
|
|
35
|
+
exports.Hr = Table.Hr;
|
|
36
|
+
exports.TCell = Table.TCell;
|
|
37
|
+
exports.TFoot = Table.TFoot;
|
|
38
|
+
exports.THead = Table.THead;
|
|
39
|
+
exports.THeadCell = Table.THeadCell;
|
|
40
|
+
exports.TRow = Table.TRow;
|
|
41
|
+
exports.Table = Table.Table;
|
|
42
|
+
exports.Td = Table.Td;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { badge, containerBadge } from '@tecsinapse/cortex-core';
|
|
3
|
+
|
|
4
|
+
const Badge = forwardRef((props, ref) => {
|
|
5
|
+
const { value, variants, ...rest } = props;
|
|
6
|
+
return /* @__PURE__ */ React.createElement(
|
|
7
|
+
"div",
|
|
8
|
+
{
|
|
9
|
+
ref,
|
|
10
|
+
className: badge({
|
|
11
|
+
className: `relative ${variants?.className}`,
|
|
12
|
+
intent: variants?.intent
|
|
13
|
+
}),
|
|
14
|
+
...rest
|
|
15
|
+
},
|
|
16
|
+
value
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
const BadgeAnchor = forwardRef((props, ref) => {
|
|
20
|
+
const { value, variants, children, ...rest } = props;
|
|
21
|
+
return /* @__PURE__ */ React.createElement("div", { className: containerBadge() }, children, /* @__PURE__ */ React.createElement("div", { ref, className: badge(variants), ...rest }, value));
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export { Badge, BadgeAnchor };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { button } from '@tecsinapse/cortex-core';
|
|
3
|
+
|
|
4
|
+
const Button = forwardRef((props, ref) => {
|
|
5
|
+
const { variants, children, ...rest } = props;
|
|
6
|
+
return /* @__PURE__ */ React.createElement("button", { className: button(variants), ref, ...rest }, children);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { Button };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { card } from '@tecsinapse/cortex-core';
|
|
3
|
+
|
|
4
|
+
const Card = forwardRef((props, ref) => {
|
|
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
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { Card };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { hint } from '@tecsinapse/cortex-core';
|
|
3
|
+
|
|
4
|
+
const Hint = forwardRef(
|
|
5
|
+
(props, ref) => {
|
|
6
|
+
const { description, children, variants } = props;
|
|
7
|
+
return /* @__PURE__ */ React.createElement(
|
|
8
|
+
"div",
|
|
9
|
+
{
|
|
10
|
+
className: hint(variants),
|
|
11
|
+
ref
|
|
12
|
+
},
|
|
13
|
+
description ? /* @__PURE__ */ React.createElement("p", null, description) : /* @__PURE__ */ React.createElement(React.Fragment, null),
|
|
14
|
+
children
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export { Hint };
|