w-design-system 0.0.21 → 0.0.22

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/dist/assets/icon/chevron-down.svg +3 -0
  2. package/dist/assets/icon/chevron-left.svg +3 -0
  3. package/dist/assets/icon/chevron-right.svg +3 -0
  4. package/dist/assets/icon/dump.svg +3 -0
  5. package/dist/assets/icon/edit.svg +10 -0
  6. package/dist/assets/icon/index.d.ts +6 -1
  7. package/dist/assets/icon/index.d.ts.map +1 -1
  8. package/dist/assets/icon/index.js +6 -1
  9. package/dist/assets/icon/index.js.map +1 -1
  10. package/dist/assets/icon/index.ts +17 -1
  11. package/dist/assets/icon/spin.svg +3 -0
  12. package/dist/components/ButtonRound/index.d.ts.map +1 -1
  13. package/dist/components/ButtonRound/index.js +4 -4
  14. package/dist/components/ButtonRound/index.js.map +1 -1
  15. package/dist/components/ButtonRound/stories.d.ts.map +1 -1
  16. package/dist/components/ButtonRound/stories.js +1 -2
  17. package/dist/components/ButtonRound/stories.js.map +1 -1
  18. package/dist/components/ButtonRound/styles.js +5 -5
  19. package/dist/components/ButtonRound/styles.js.map +1 -1
  20. package/dist/components/CardStories/index.d.ts +9 -0
  21. package/dist/components/CardStories/index.d.ts.map +1 -0
  22. package/dist/components/CardStories/index.js +43 -0
  23. package/dist/components/CardStories/index.js.map +1 -0
  24. package/dist/components/CardStories/stories.d.ts +9 -0
  25. package/dist/components/CardStories/stories.d.ts.map +1 -0
  26. package/dist/components/CardStories/stories.js +35 -0
  27. package/dist/components/CardStories/stories.js.map +1 -0
  28. package/dist/components/Loading/index.d.ts +8 -0
  29. package/dist/components/Loading/index.d.ts.map +1 -0
  30. package/dist/components/Loading/index.js +50 -0
  31. package/dist/components/Loading/index.js.map +1 -0
  32. package/dist/components/Loading/stories.d.ts +12 -0
  33. package/dist/components/Loading/stories.d.ts.map +1 -0
  34. package/dist/components/Loading/stories.js +46 -0
  35. package/dist/components/Loading/stories.js.map +1 -0
  36. package/dist/components/Paginate/index.d.ts +10 -0
  37. package/dist/components/Paginate/index.d.ts.map +1 -0
  38. package/dist/components/Paginate/index.js +58 -0
  39. package/dist/components/Paginate/index.js.map +1 -0
  40. package/dist/components/Paginate/stories.d.ts +6 -0
  41. package/dist/components/Paginate/stories.d.ts.map +1 -0
  42. package/dist/components/Paginate/stories.js +37 -0
  43. package/dist/components/Paginate/stories.js.map +1 -0
  44. package/dist/components/Paginate/styles.d.ts +2 -0
  45. package/dist/components/Paginate/styles.d.ts.map +1 -0
  46. package/dist/components/Paginate/styles.js +97 -0
  47. package/dist/components/Paginate/styles.js.map +1 -0
  48. package/dist/components/Paragraph/index.d.ts +1 -0
  49. package/dist/components/Paragraph/index.d.ts.map +1 -1
  50. package/dist/components/Paragraph/index.js +4 -3
  51. package/dist/components/Paragraph/index.js.map +1 -1
  52. package/dist/components/Table/index.d.ts +21 -0
  53. package/dist/components/Table/index.d.ts.map +1 -0
  54. package/dist/components/Table/index.js +90 -0
  55. package/dist/components/Table/index.js.map +1 -0
  56. package/dist/components/Table/stories.d.ts +9 -0
  57. package/dist/components/Table/stories.d.ts.map +1 -0
  58. package/dist/components/Table/stories.js +159 -0
  59. package/dist/components/Table/stories.js.map +1 -0
  60. package/dist/components/Table/styles.d.ts +1 -0
  61. package/dist/components/Table/styles.d.ts.map +1 -0
  62. package/dist/components/Table/styles.js +2 -0
  63. package/dist/components/Table/styles.js.map +1 -0
  64. package/dist/components/Types/index.d.ts +1 -0
  65. package/dist/components/Types/index.d.ts.map +1 -1
  66. package/dist/components/index.d.ts +2 -0
  67. package/dist/components/index.d.ts.map +1 -1
  68. package/dist/components/index.js +2 -0
  69. package/dist/components/index.js.map +1 -1
  70. package/package.json +1 -1
  71. package/src/assets/icon/chevron-down.svg +3 -0
  72. package/src/assets/icon/chevron-left.svg +3 -0
  73. package/src/assets/icon/chevron-right.svg +3 -0
  74. package/src/assets/icon/dump.svg +3 -0
  75. package/src/assets/icon/edit.svg +10 -0
  76. package/src/assets/icon/index.ts +17 -1
  77. package/src/assets/icon/spin.svg +3 -0
  78. package/src/components/ButtonRound/index.tsx +5 -4
  79. package/src/components/ButtonRound/stories.tsx +2 -2
  80. package/src/components/ButtonRound/styles.ts +5 -5
  81. package/src/components/CardStories/index.tsx +59 -0
  82. package/src/components/CardStories/stories.tsx +44 -0
  83. package/src/components/Loading/index.tsx +73 -0
  84. package/src/components/Loading/stories.tsx +65 -0
  85. package/src/components/Paginate/index.tsx +108 -0
  86. package/src/components/Paginate/stories.tsx +53 -0
  87. package/src/components/Paginate/styles.ts +96 -0
  88. package/src/components/Paragraph/index.tsx +13 -4
  89. package/src/components/Table/index.tsx +203 -0
  90. package/src/components/Table/stories.tsx +198 -0
  91. package/src/components/Table/styles.ts +0 -0
  92. package/src/components/Types/index.ts +1 -0
  93. package/src/components/index.tsx +2 -0
@@ -0,0 +1,203 @@
1
+ import React, { useState } from 'react'
2
+ import styled from 'styled-components'
3
+ import { Paragraph } from '../Paragraph'
4
+ import { theme } from '../Themes'
5
+ import { ContainerLoading } from '../Loading'
6
+
7
+ type Column = {
8
+ header: string
9
+ accessor: string
10
+ width?: string
11
+ sortable?: boolean
12
+ onClick?: (row: any) => void
13
+ Cell?: (row: any, handleExpandClick: (id: number) => void) => React.ReactNode
14
+ align?: 'left' | 'center' | 'right'
15
+ }
16
+
17
+ type TableProps = {
18
+ columns: Column[] | any
19
+ data: any[]
20
+ height?: string
21
+ loading?: boolean
22
+ emptyStateMessage?: string
23
+ striped?: boolean
24
+ }
25
+
26
+ const TableContainer = styled.div`
27
+ display: flex;
28
+ flex-direction: column;
29
+ width: 100%;
30
+ height: 100%;
31
+ overflow-x: auto;
32
+ `
33
+
34
+ const StyledTable = styled.table`
35
+ width: 100%;
36
+ border-collapse: collapse;
37
+ height: 100%;
38
+ `
39
+
40
+ const Thead = styled.thead`
41
+ display: table-header-group;
42
+ border-bottom: 1px solid #ddd;
43
+ `
44
+
45
+ const Tbody = styled.tbody<{ height?: string }>`
46
+ display: block;
47
+ width: 100%;
48
+ overflow-y: auto;
49
+ height: ${props => props.height || '100%'};
50
+ `
51
+
52
+ const Tr = styled.tr<{ striped?: boolean }>`
53
+ display: table;
54
+ width: 100%;
55
+ table-layout: fixed;
56
+ `
57
+ const TrRow = styled.tr<{ striped?: boolean }>`
58
+ display: table;
59
+ width: 100%;
60
+ table-layout: fixed;
61
+ &:nth-of-type(n + 2) {
62
+ background-color: ${props => (props.striped ? '#f9f9f9' : 'transparent')};
63
+ }
64
+ &:nth-of-type(odd) {
65
+ background-color: ${props => (props.striped ? '#fff' : 'transparent')};
66
+ }
67
+ `
68
+
69
+ const Th = styled.th<{ width?: string; align?: 'left' | 'center' | 'right' }>`
70
+ padding: 10px;
71
+ text-align: ${props => props.align || 'left'};
72
+ width: ${props => props.width || 'auto'};
73
+ `
74
+
75
+ const Td = styled.td<{ width?: string; align: 'left' | 'center' | 'right' }>`
76
+ padding: 12px;
77
+ width: ${props => props?.width || 'auto'};
78
+ text-align: ${props => props?.align || 'left'};
79
+ `
80
+
81
+ const ExpandableRow = styled.div`
82
+ padding: 8px;
83
+ min-height: 50px;
84
+ `
85
+
86
+ const LoadingWrapper = styled.div`
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ width: 100%;
91
+ height: 100%;
92
+ `
93
+
94
+ const EmptyStateWrapper = styled.div`
95
+ display: flex;
96
+ align-items: center;
97
+ justify-content: center;
98
+ width: 100%;
99
+ height: 100%;
100
+ padding: 20px;
101
+ `
102
+
103
+ export const Table: React.FC<TableProps> = ({
104
+ columns,
105
+ data,
106
+ height = '100%',
107
+ loading = false,
108
+ emptyStateMessage = 'No data available',
109
+ striped = false,
110
+ }) => {
111
+ const [expandedRow, setExpandedRow] = useState<number | null>(null)
112
+
113
+ const handleExpandClick = (id: number) => {
114
+ setExpandedRow(expandedRow === id ? null : id)
115
+ }
116
+
117
+ // @ts-ignore
118
+ return (
119
+ <TableContainer>
120
+ <StyledTable>
121
+ <Thead>
122
+ <Tr striped={striped}>
123
+ {columns.map(
124
+ (
125
+ col: {
126
+ width: string | undefined
127
+ align: any
128
+ header:
129
+ | string
130
+ | number
131
+ | boolean
132
+ | React.ReactElement<any, string | React.JSXElementConstructor<any>>
133
+ | Iterable<React.ReactNode>
134
+ | React.ReactPortal
135
+ | null
136
+ | undefined
137
+ },
138
+ index: React.Key | null | undefined,
139
+ ) => (
140
+ <Th key={index} width={col.width} align={col.align}>
141
+ <Paragraph color={theme.colors.shade30} textTransform={'uppercase'} weight={400}>
142
+ {col.header}
143
+ </Paragraph>
144
+ </Th>
145
+ ),
146
+ )}
147
+ </Tr>
148
+ </Thead>
149
+ <Tbody height={height}>
150
+ {loading ? (
151
+ <LoadingWrapper>
152
+ <ContainerLoading size={'small'} />
153
+ </LoadingWrapper>
154
+ ) : data.length === 0 ? (
155
+ <EmptyStateWrapper>
156
+ <Paragraph>{emptyStateMessage}</Paragraph>
157
+ </EmptyStateWrapper>
158
+ ) : (
159
+ data.map((row, rowIndex) => (
160
+ <React.Fragment key={row.id}>
161
+ <TrRow striped={striped}>
162
+ {columns.map(
163
+ (
164
+ col: {
165
+ width: string | undefined
166
+ align: any
167
+ Cell: (
168
+ arg0: any,
169
+ arg1: (id: number) => void,
170
+ ) =>
171
+ | string
172
+ | number
173
+ | boolean
174
+ | React.ReactElement<any, string | React.JSXElementConstructor<any>>
175
+ | Iterable<React.ReactNode>
176
+ | React.ReactPortal
177
+ | null
178
+ | undefined
179
+ accessor: string | number
180
+ },
181
+ colIndex: React.Key | null | undefined,
182
+ ) => (
183
+ <Td key={colIndex} width={col?.width} align={col?.align}>
184
+ {col.Cell ? (
185
+ col.Cell(row, handleExpandClick)
186
+ ) : (
187
+ <Paragraph color={theme.colors.shade40}>{row[col.accessor]}</Paragraph>
188
+ )}
189
+ </Td>
190
+ ),
191
+ )}
192
+ </TrRow>
193
+ {expandedRow === row.id && row.containerColapsed && (
194
+ <ExpandableRow>{row.containerColapsed(row)}</ExpandableRow>
195
+ )}
196
+ </React.Fragment>
197
+ ))
198
+ )}
199
+ </Tbody>
200
+ </StyledTable>
201
+ </TableContainer>
202
+ )
203
+ }
@@ -0,0 +1,198 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import React from 'react'
3
+ import { ButtonRound } from '../ButtonRound'
4
+ import { dumpSVG, editSVG } from '../../assets/icon'
5
+ import { Table } from './index'
6
+ import CardStories from '../CardStories'
7
+ import { Paragraph } from '../Paragraph'
8
+
9
+ const meta: Meta<typeof Table> = {
10
+ title: 'Components/Table',
11
+ component: Table,
12
+ parameters: {
13
+ layout: 'centered',
14
+ },
15
+ tags: ['autodocs'],
16
+ argTypes: {
17
+ columns: {
18
+ control: 'object',
19
+ description: 'Array of column definitions',
20
+ },
21
+ data: {
22
+ control: 'object',
23
+ description: 'Array of data objects',
24
+ },
25
+ loading: {
26
+ control: 'boolean',
27
+ description: 'Loading state of the table',
28
+ },
29
+ emptyStateMessage: {
30
+ control: 'text',
31
+ description: 'Message to display when there is no data',
32
+ },
33
+ },
34
+ } satisfies Meta<typeof Table>
35
+
36
+ export default meta
37
+ type Story = StoryObj<typeof meta>
38
+
39
+ const columns = [
40
+ {
41
+ header: 'id',
42
+ accessor: 'id',
43
+ width: 'auto',
44
+ },
45
+ {
46
+ header: 'item',
47
+ accessor: 'item',
48
+ width: 'auto',
49
+ sortable: true,
50
+ },
51
+ {
52
+ header: 'unidades',
53
+ accessor: 'unidades',
54
+ width: 'auto',
55
+ sortable: true,
56
+ },
57
+ {
58
+ header: 'marca/ fabricante',
59
+ accessor: 'marca_fabricante',
60
+ width: 'auto',
61
+ Cell: (row: any) => (
62
+ <div
63
+ onClick={() => alert('aqui')}
64
+ style={{
65
+ background: 'red',
66
+ color: 'white',
67
+ padding: '4px, 2px',
68
+ borderRadius: '8px',
69
+ display: 'flex',
70
+ alignItems: 'center',
71
+ justifyContent: 'center',
72
+ }}
73
+ >
74
+ {row.marca_fabricante}
75
+ </div>
76
+ ),
77
+ },
78
+ {
79
+ header: 'modelo',
80
+ accessor: 'modelo',
81
+ width: 'auto',
82
+ sortable: true,
83
+ },
84
+ {
85
+ header: 'quantidade solitada',
86
+ accessor: 'quantidade_solitada',
87
+ width: 'auto',
88
+ sortable: true,
89
+ },
90
+ {
91
+ header: 'valor estimado unitario',
92
+ accessor: 'valor_estimado_unitario',
93
+ width: 'auto',
94
+ sortable: true,
95
+ },
96
+ {
97
+ header: 'valor estimado total',
98
+ accessor: 'valor_estimado_total',
99
+ width: 'auto',
100
+ sortable: true,
101
+ },
102
+ {
103
+ header: 'Actions',
104
+ accessor: 'valor_estimado_total',
105
+ width: '100px',
106
+ align: 'center',
107
+ Cell: (row: any, handleExpandClick: (id: number) => void) => (
108
+ <div style={{ display: 'flex', gap: '8px', justifyContent: 'center' }}>
109
+ <ButtonRound icon={editSVG} onClick={() => handleExpandClick(row.id)} />
110
+ <ButtonRound icon={dumpSVG} onClick={() => alert(`Delete ID: ${row.id}`)} variant={'danger'} />
111
+ </div>
112
+ ),
113
+ },
114
+ ]
115
+
116
+ export const Default: Story = {
117
+ args: {
118
+ height: 'auto',
119
+ columns: columns,
120
+ striped: true,
121
+ loading: false,
122
+ emptyStateMessage: 'No data available',
123
+ data: [
124
+ {
125
+ id: 1,
126
+ item: 'Beetlejuice',
127
+ unidades: '1988',
128
+ marca_fabricante: 'adidas',
129
+ modelo: 'modelo',
130
+ quantidade_solitada: '10000',
131
+ valor_estimado_unitario: '1000',
132
+ valor_estimado_total: '10000000',
133
+ colapsed: true,
134
+ containerColapsed: ({ item }: any) => (
135
+ <div>
136
+ <Paragraph size={'large'} weight={800}>
137
+ {item}
138
+ </Paragraph>
139
+ <Paragraph>Esta é uma informação adicional sobre .</Paragraph>
140
+ </div>
141
+ ),
142
+ },
143
+ {
144
+ id: 2,
145
+ item: 'Beetlejuice',
146
+ unidades: '1988',
147
+ marca_fabricante: 'adidas',
148
+ modelo: 'modelo',
149
+ quantidade_solitada: '10000',
150
+ valor_estimado_unitario: '1000',
151
+ valor_estimado_total: '10000000',
152
+ containerColapsed: ({ item }: any) => (
153
+ <div>
154
+ <Paragraph size={'large'} weight={800}>
155
+ {item}
156
+ </Paragraph>
157
+ <Paragraph>Esta é uma informação adicional sobre .</Paragraph>
158
+ </div>
159
+ ),
160
+ },
161
+ {
162
+ id: 3,
163
+ item: 'Beetlejuice',
164
+ unidades: '1988',
165
+ marca_fabricante: 'adidas',
166
+ modelo: 'modelo',
167
+ quantidade_solitada: '10000',
168
+ valor_estimado_unitario: '1000',
169
+ valor_estimado_total: '10000000',
170
+ containerColapsed: ({ item }: any) => (
171
+ <div>
172
+ <Paragraph size={'large'} weight={800}>
173
+ {item}
174
+ </Paragraph>
175
+ <Paragraph>Esta é uma informação adicional sobre .</Paragraph>
176
+ </div>
177
+ ),
178
+ },
179
+ ],
180
+ },
181
+ }
182
+
183
+ export const LoadingState: Story = {
184
+ render: () => (
185
+ <CardStories title={'Tabela'} subTitle={'tabela-loading'}>
186
+ <div style={{ width: '900px', height: '800px' }}>
187
+ <Table columns={columns} loading={true} height={'100%'} data={[]} />
188
+ </div>
189
+ </CardStories>
190
+ ),
191
+ }
192
+
193
+ export const EmptyState: Story = {
194
+ args: {
195
+ ...Default.args,
196
+ data: [],
197
+ },
198
+ }
File without changes
@@ -23,6 +23,7 @@ export interface ButtonRoundTypes extends ButtonHTMLAttributes<HTMLButtonElement
23
23
  icon?: string
24
24
  outline?: boolean
25
25
  badge?: number
26
+ size?: 'small' | 'medium'
26
27
  }
27
28
 
28
29
  export interface BannerTypes extends HTMLAttributes<HTMLDivElement> {
@@ -8,3 +8,5 @@ export { Paragraph } from './Paragraph/index'
8
8
  export { Tabs } from './Tabs/index'
9
9
  export { theme } from './Themes/index'
10
10
  export { Title } from './Title/index'
11
+ export { Paginate } from './Paginate/index'
12
+ export { Table } from './Table/index'