@tecsinapse/cortex-react 1.0.2 → 1.2.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.
Files changed (93) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/cjs/components/Badge.js +27 -0
  3. package/dist/cjs/components/Button.js +11 -0
  4. package/dist/cjs/components/Card.js +19 -0
  5. package/dist/cjs/components/Hint.js +21 -0
  6. package/dist/cjs/components/Input.js +79 -0
  7. package/dist/cjs/components/Modal.js +25 -0
  8. package/dist/cjs/components/SearchInput.js +70 -0
  9. package/dist/cjs/components/Select.js +101 -0
  10. package/dist/cjs/components/Snackbar.js +18 -0
  11. package/dist/cjs/components/Table.js +53 -0
  12. package/dist/cjs/components/Tag.js +18 -0
  13. package/dist/cjs/components/TextArea.js +81 -0
  14. package/dist/cjs/components/Toggle.js +18 -0
  15. package/dist/cjs/hooks/useDebouncedState.js +16 -0
  16. package/dist/cjs/index.js +42 -0
  17. package/dist/esm/components/Badge.js +24 -0
  18. package/dist/esm/components/Button.js +9 -0
  19. package/dist/esm/components/Card.js +17 -0
  20. package/dist/esm/components/Hint.js +19 -0
  21. package/dist/esm/components/Input.js +72 -0
  22. package/dist/esm/components/Modal.js +23 -0
  23. package/dist/esm/components/SearchInput.js +68 -0
  24. package/dist/esm/components/Select.js +96 -0
  25. package/dist/esm/components/Snackbar.js +16 -0
  26. package/dist/esm/components/Table.js +44 -0
  27. package/dist/esm/components/Tag.js +16 -0
  28. package/dist/esm/components/TextArea.js +79 -0
  29. package/dist/esm/components/Toggle.js +16 -0
  30. package/dist/esm/hooks/useDebouncedState.js +14 -0
  31. package/dist/esm/index.js +12 -0
  32. package/dist/types/components/Badge.d.ts +12 -0
  33. package/dist/types/components/Button.d.ts +8 -0
  34. package/dist/types/components/Card.d.ts +6 -0
  35. package/dist/types/components/Hint.d.ts +14 -0
  36. package/dist/types/components/Input.d.ts +34 -0
  37. package/dist/types/components/Modal.d.ts +8 -0
  38. package/dist/types/components/SearchInput.d.ts +11 -0
  39. package/dist/types/components/Select.d.ts +28 -0
  40. package/dist/types/components/Snackbar.d.ts +9 -0
  41. package/dist/types/components/Table.d.ts +13 -0
  42. package/dist/types/components/Tag.d.ts +8 -0
  43. package/dist/types/components/TextArea.d.ts +24 -0
  44. package/dist/types/components/Toggle.d.ts +2 -0
  45. package/{src/components/index.ts → dist/types/components/index.d.ts} +1 -0
  46. package/dist/types/docs/badge-anchor.stories.d.ts +29 -0
  47. package/dist/types/docs/badge.stories.d.ts +27 -0
  48. package/dist/types/docs/button.stories.d.ts +30 -0
  49. package/dist/types/docs/card.stories.d.ts +10 -0
  50. package/dist/types/docs/hint.stories.d.ts +27 -0
  51. package/dist/types/docs/input-custom.stories.d.ts +33 -0
  52. package/dist/types/docs/input.stories.d.ts +33 -0
  53. package/dist/types/docs/modal.stories.d.ts +10 -0
  54. package/dist/types/docs/select-grouped.stories.d.ts +32 -0
  55. package/dist/types/docs/select.stories.d.ts +32 -0
  56. package/dist/types/docs/snackbar.stories.d.ts +21 -0
  57. package/dist/types/docs/table.stories.d.ts +10 -0
  58. package/dist/types/docs/tag.stories.d.ts +21 -0
  59. package/dist/types/docs/text-area.stories.d.ts +39 -0
  60. package/dist/types/docs/toggle.stories.d.ts +10 -0
  61. package/dist/types/docs/utils.d.ts +1 -0
  62. package/dist/types/hooks/useDebouncedState.d.ts +2 -0
  63. package/package.json +19 -14
  64. package/src/components/Badge.tsx +0 -45
  65. package/src/components/Button.tsx +0 -19
  66. package/src/components/Card.tsx +0 -18
  67. package/src/components/Hint.tsx +0 -31
  68. package/src/components/Input.tsx +0 -110
  69. package/src/components/Modal.tsx +0 -24
  70. package/src/components/SearchInput.tsx +0 -86
  71. package/src/components/Select.tsx +0 -170
  72. package/src/components/Snackbar.tsx +0 -26
  73. package/src/components/Tag.tsx +0 -19
  74. package/src/components/TextArea.tsx +0 -121
  75. package/src/components/Toggle.tsx +0 -25
  76. package/src/docs/badge-anchor.stories.tsx +0 -42
  77. package/src/docs/badge.stories.tsx +0 -31
  78. package/src/docs/button.stories.tsx +0 -37
  79. package/src/docs/card.stories.tsx +0 -29
  80. package/src/docs/hint.stories.tsx +0 -32
  81. package/src/docs/input-custom.stories.tsx +0 -45
  82. package/src/docs/input.stories.tsx +0 -40
  83. package/src/docs/modal.stories.tsx +0 -48
  84. package/src/docs/select-grouped.stories.tsx +0 -79
  85. package/src/docs/select.stories.tsx +0 -70
  86. package/src/docs/snackbar.stories.tsx +0 -31
  87. package/src/docs/tag.stories.tsx +0 -37
  88. package/src/docs/text-area.stories.tsx +0 -50
  89. package/src/docs/toggle.stories.tsx +0 -18
  90. package/src/docs/utils.ts +0 -8
  91. package/src/hooks/useDebouncedState.ts +0 -24
  92. /package/{src/hooks/index.ts → dist/types/hooks/index.d.ts} +0 -0
  93. /package/{src/index.ts → dist/types/index.d.ts} +0 -0
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Button, Card } from '../index';
4
- import { IoMdArrowForward } from 'react-icons/io';
5
- export default {
6
- title: 'Cortex-React/Card',
7
- component: <div />,
8
- };
9
-
10
- const Template: StoryFn = () => {
11
- return (
12
- <Card>
13
- <div className={'w-[300px]'}>
14
- <p className={'text-h5 font-bold'}>Exemple card</p>
15
- <div className={'flex flex-row items-center gap-x-deca mt-deca'}>
16
- <Button variants={{ variant: 'outline', size: 'small' }}>
17
- <IoMdArrowForward />
18
- </Button>
19
- <p className={''}>Exemple description card</p>
20
- </div>
21
- </div>
22
- </Card>
23
- );
24
- };
25
-
26
- export const Base = {
27
- render: Template,
28
- args: {},
29
- };
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Hint } from '../index';
4
-
5
- export default {
6
- title: 'Cortex-React/Hint',
7
- component: <div />,
8
- args: {
9
- intent: 'default',
10
- description: 'Hint description',
11
- },
12
- argTypes: {
13
- intent: {
14
- options: ['default', 'success', 'warning', 'error'],
15
- control: { type: 'select' },
16
- },
17
- description: {
18
- control: { type: 'text' },
19
- },
20
- },
21
- };
22
-
23
- const Template: StoryFn = args => {
24
- return (
25
- <Hint variants={{ intent: args.intent }} description={args.description} />
26
- );
27
- };
28
-
29
- export const Base = {
30
- render: Template,
31
- args: {},
32
- };
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Input } from '../components';
4
- import { IoPerson } from 'react-icons/io5';
5
- import { IoEye } from 'react-icons/io5';
6
- export default {
7
- title: 'Cortex-React/Input/Custom',
8
- component: <div />,
9
- args: {
10
- label: 'Label',
11
- placeholder: 'Placeholder',
12
- intent: 'default',
13
- },
14
- argTypes: {
15
- intent: {
16
- options: ['default', 'success', 'warning', 'error'],
17
- control: { type: 'select' },
18
- },
19
- label: {
20
- control: { type: 'text' },
21
- },
22
- placeholder: {
23
- control: { type: 'text' },
24
- },
25
- },
26
- };
27
-
28
- const Template: StoryFn = args => {
29
- return (
30
- <Input.Face variants={{ intent: args.intent }}>
31
- <Input.Left>
32
- <IoPerson size={16} />
33
- </Input.Left>
34
- <Input.Box label={args.label} placeholder={args.placeholder}></Input.Box>
35
- <Input.Right>
36
- <IoEye />
37
- </Input.Right>
38
- </Input.Face>
39
- );
40
- };
41
-
42
- export const Base = {
43
- render: Template,
44
- args: {},
45
- };
@@ -1,40 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Input } from '../components';
4
-
5
- export default {
6
- title: 'Cortex-React/Input',
7
- component: <div />,
8
- args: {
9
- label: 'Label',
10
- placeholder: 'Placeholder',
11
- intent: 'default',
12
- },
13
- argTypes: {
14
- intent: {
15
- options: ['default', 'success', 'warning', 'error'],
16
- control: { type: 'select' },
17
- },
18
- label: {
19
- control: { type: 'text' },
20
- },
21
- placeholder: {
22
- control: { type: 'text' },
23
- },
24
- },
25
- };
26
-
27
- const Template: StoryFn = args => {
28
- return (
29
- <Input.Root
30
- variants={{ intent: args.intent }}
31
- label={args.label}
32
- placeholder={args.placeholder}
33
- />
34
- );
35
- };
36
-
37
- export const Base = {
38
- render: Template,
39
- args: {},
40
- };
@@ -1,48 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Button, Modal } from '../index';
4
- import { MdClose } from 'react-icons/md';
5
- export default {
6
- title: 'Cortex-React/Modal',
7
- component: <div />,
8
- };
9
-
10
- const Template: StoryFn = () => {
11
- const [showModal, setShowModal] = useState(false);
12
- return (
13
- <>
14
- <Button onClick={() => setShowModal(true)}>
15
- <p>Show modal</p>
16
- </Button>
17
- <Modal open={showModal} onClose={() => setShowModal(false)}>
18
- <div className={'w-[600px] h-[80%]'}>
19
- <div className={'justify-between flex flex-row'}>
20
- <p className={'font-black text-h3'}>What is Lorem Ipsum?</p>
21
- <MdClose
22
- className={
23
- 'text-primary-medium text-deca cursor-pointer hover:text-primary-dark'
24
- }
25
- onClick={() => setShowModal(false)}
26
- />
27
- </div>
28
- <p className={'mt-giga'}>
29
- Lorem Ipsum is simply dummy text of the printing and typesetting
30
- industry. Lorem Ipsum has been the industry's standard dummy text
31
- ever since the 1500s, when an unknown printer took a galley of type
32
- and scrambled it to make a type specimen book. It has survived not
33
- only five centuries, but also the leap into electronic typesetting,
34
- remaining essentially unchanged. It was popularised in the 1960s
35
- with the release of Letraset sheets containing Lorem Ipsum passages,
36
- and more recently with desktop publishing software like Aldus
37
- PageMaker including versions of Lorem Ipsum.
38
- </p>
39
- </div>
40
- </Modal>
41
- </>
42
- );
43
- };
44
-
45
- export const Base = {
46
- render: Template,
47
- args: {},
48
- };
@@ -1,79 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Select } from '../index';
4
-
5
- export default {
6
- title: 'Cortex-React/Select/Grouped',
7
- component: <div />,
8
- argTypes: {
9
- variant: {
10
- options: ['default', 'error'],
11
- control: { type: 'select' },
12
- },
13
- label: {
14
- control: { type: 'text' },
15
- },
16
- placeholderSearchInput: {
17
- control: { type: 'text' },
18
- },
19
- },
20
- };
21
-
22
- const Template: StoryFn = args => {
23
- const [value, setValue] = useState<{ key: string; label: string }>();
24
-
25
- const estadosECidades = new Map();
26
-
27
- estadosECidades.set('São Paulo', [
28
- { key: 'SP1', label: 'São Paulo' },
29
- { key: 'SP2', label: 'Campinas' },
30
- { key: 'SP3', label: 'Santos' },
31
- ]);
32
- estadosECidades.set('Rio de Janeiro', [
33
- { key: 'RJ1', label: 'Rio de Janeiro' },
34
- { key: 'RJ2', label: 'Niterói' },
35
- { key: 'RJ3', label: 'Petrópolis' },
36
- ]);
37
- estadosECidades.set('Minas Gerais', [
38
- { key: 'MG1', label: 'Belo Horizonte' },
39
- { key: 'MG2', label: 'Uberlândia' },
40
- { key: 'MG3', label: 'Ouro Preto' },
41
- ]);
42
- estadosECidades.set('Bahia', [
43
- { key: 'BA1', label: 'Salvador' },
44
- { key: 'BA2', label: 'Feira de Santana' },
45
- { key: 'BA3', label: 'Ilhéus' },
46
- ]);
47
- estadosECidades.set('Paraná', [
48
- { key: 'PR1', label: 'Curitiba' },
49
- { key: 'PR2', label: 'Londrina' },
50
- { key: 'PR3', label: 'Maringá' },
51
- ]);
52
-
53
- return (
54
- <div className={'w-[350px]'}>
55
- <Select
56
- variant={args.variant}
57
- label={args.label}
58
- // onSearch={handleSearch}
59
- placeholderSearchInput={args.placeholderSearchInput}
60
- labelExtractor={op => op.label}
61
- keyExtractor={op => op.key}
62
- onSelect={setValue}
63
- value={value}
64
- grouped={true}
65
- groupedLabelExtractor={labelGroup => labelGroup}
66
- options={estadosECidades}
67
- />
68
- </div>
69
- );
70
- };
71
-
72
- export const Base = {
73
- render: Template,
74
- args: {
75
- variant: 'default',
76
- label: 'Label',
77
- placeholderSearchInput: 'Placeholder Search',
78
- },
79
- };
@@ -1,70 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Select } from '../index';
4
-
5
- export default {
6
- title: 'Cortex-React/Select',
7
- component: <div />,
8
- argTypes: {
9
- variant: {
10
- options: ['default', 'error'],
11
- control: { type: 'select' },
12
- },
13
- label: {
14
- control: { type: 'text' },
15
- },
16
- placeholderSearchInput: {
17
- control: { type: 'text' },
18
- },
19
- },
20
- };
21
-
22
- const _options = [
23
- { key: '1', label: 'São paulo' },
24
- { key: '2', label: 'Rio de Janeiro' },
25
- { key: '3', label: 'Campo Grande' },
26
- { key: '4', label: 'Goiania' },
27
- { key: '5', label: 'Uberlândia' },
28
- { key: '6', label: 'Salvador' },
29
- { key: '7', label: 'São Luis' },
30
- { key: '7', label: 'Manaus' },
31
- { key: '8', label: 'Rio Branco' },
32
- ];
33
-
34
- type Option = { key: string; label: string };
35
- const Template: StoryFn = args => {
36
- const [value, setValue] = useState<{ key: string; label: string }>();
37
- const [options, setOptions] = useState<Option[]>(_options);
38
-
39
- const handleSearch = React.useCallback((searchArg: string) => {
40
- setOptions(
41
- (options as Option[]).filter(item =>
42
- new RegExp(searchArg, 'ig').test(item.label)
43
- )
44
- );
45
- }, []);
46
- return (
47
- <div className={'w-[350px]'}>
48
- <Select
49
- variant={args.variant}
50
- keyExtractor={op => op.key}
51
- label={args.label}
52
- onSearch={handleSearch}
53
- placeholderSearchInput={args.placeholderSearchInput}
54
- labelExtractor={op => op.label}
55
- onSelect={setValue}
56
- value={value}
57
- options={options}
58
- />
59
- </div>
60
- );
61
- };
62
-
63
- export const Base = {
64
- render: Template,
65
- args: {
66
- variant: 'default',
67
- label: 'Label',
68
- placeholderSearchInput: 'Placeholder Search',
69
- },
70
- };
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Snackbar } from '../index';
4
- import { defaultIntents } from './utils';
5
-
6
- export default {
7
- title: 'Cortex-React/Snackbar',
8
- component: <div />,
9
- args: {
10
- intent: 'primary',
11
- },
12
- argTypes: {
13
- intent: {
14
- options: defaultIntents,
15
- control: { type: 'select' },
16
- },
17
- },
18
- };
19
-
20
- const Template: StoryFn = args => {
21
- return (
22
- <Snackbar show={true} variants={{ intent: args.intent }}>
23
- <p>Description snackbar</p>
24
- </Snackbar>
25
- );
26
- };
27
-
28
- export const Base = {
29
- render: Template,
30
- args: {},
31
- };
@@ -1,37 +0,0 @@
1
- import React from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Tag } from '../index';
4
-
5
- export default {
6
- title: 'Cortex-React/Tag',
7
- component: <div />,
8
- args: {
9
- intent: 'primary',
10
- },
11
- argTypes: {
12
- intent: {
13
- options: ['success', 'primary', 'secondary', 'info', 'white'],
14
- control: { type: 'select' },
15
- },
16
- },
17
- };
18
-
19
- const Template: StoryFn = args => {
20
- return (
21
- <div className={'flex flex-col justify-center items-center'}>
22
- <Tag variants={{ intent: args.intent }} label={'Intent color'} />
23
- <div className={'flex flex-row gap-x-deca mt-giga'}>
24
- <Tag variants={{ intent: 'primary' }} label={'Tag label'} />
25
- <Tag variants={{ intent: 'success' }} label={'Tag label'} />
26
- <Tag variants={{ intent: 'info' }} label={'Tag label'} />
27
- <Tag variants={{ intent: 'secondary' }} label={'Tag label'} />
28
- <Tag variants={{ intent: 'white' }} label={'Tag label'} />
29
- </div>
30
- </div>
31
- );
32
- };
33
-
34
- export const Base = {
35
- render: Template,
36
- args: {},
37
- };
@@ -1,50 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { TextArea } from '../index';
4
-
5
- export default {
6
- title: 'Cortex-React/TextArea',
7
- component: <div />,
8
- args: {
9
- rows: 6,
10
- intent: 'default',
11
- label: 'Label',
12
- placeholder: 'placeholder',
13
- },
14
- argTypes: {
15
- intent: {
16
- options: ['default', 'success', 'warning', 'error'],
17
- control: { type: 'select' },
18
- },
19
- rows: {
20
- control: { type: 'number' },
21
- },
22
- label: {
23
- control: { type: 'text' },
24
- },
25
- placeholder: {
26
- control: { type: 'text' },
27
- },
28
- },
29
- };
30
-
31
- const Template: StoryFn = args => {
32
- const [value, setValue] = useState('');
33
- return (
34
- <div className={'w-[300px]'}>
35
- <TextArea.Root
36
- placeholder={args.placeholder}
37
- label={args.label}
38
- variants={{ intent: args.intent }}
39
- rows={args.rows}
40
- value={value}
41
- onChange={e => setValue(e.currentTarget.value)}
42
- />
43
- </div>
44
- );
45
- };
46
-
47
- export const Base = {
48
- render: Template,
49
- args: {},
50
- };
@@ -1,18 +0,0 @@
1
- import React, { useState } from 'react';
2
- import { StoryFn } from '@storybook/react';
3
- import { Toggle } from '../index';
4
-
5
- export default {
6
- title: 'Cortex-React/Toggle',
7
- component: <div />,
8
- };
9
-
10
- const Template: StoryFn = () => {
11
- const [checked, setChecked] = useState(false);
12
- return <Toggle checked={checked} onClick={() => setChecked(!checked)} />;
13
- };
14
-
15
- export const Base = {
16
- render: Template,
17
- args: {},
18
- };
package/src/docs/utils.ts DELETED
@@ -1,8 +0,0 @@
1
- export const defaultIntents = [
2
- 'primary',
3
- 'secondary',
4
- 'success',
5
- 'info',
6
- 'warning',
7
- 'error',
8
- ];
@@ -1,24 +0,0 @@
1
- import { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
2
-
3
- /**
4
- * @param initialState
5
- * @param timeoutCallback callback to be called after bouncing ends. Should be memoized.
6
- * @param timeoutMs
7
- */
8
- export function useDebouncedState<S>(
9
- initialState: S | (() => S),
10
- timeoutCallback?: (state: S) => void,
11
- timeoutMs = 166
12
- ): [S, Dispatch<SetStateAction<S>>] {
13
- const timeoutId = useRef<NodeJS.Timeout>();
14
-
15
- const [state, setState] = useState<S>(initialState);
16
-
17
- useEffect(() => {
18
- if (timeoutId.current) clearTimeout(timeoutId.current);
19
- if (timeoutCallback)
20
- timeoutId.current = setTimeout(() => timeoutCallback(state), timeoutMs);
21
- }, [state]);
22
-
23
- return [state, setState];
24
- }
File without changes