wca-designsystem 0.0.87 → 0.0.89
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
CHANGED
|
@@ -1,181 +1,73 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
# Documentação do Design System
|
|
2
|
+
|
|
3
|
+
## Visão Geral
|
|
4
|
+
Este projeto é um Design System baseado em React e TypeScript, utilizando TSDX para compilação, Storybook para documentação e Jest para testes automatizados.
|
|
5
|
+
|
|
6
|
+
## Requisitos
|
|
7
|
+
Antes de iniciar, certifique-se de ter instalado:
|
|
8
|
+
- [Node.js](https://nodejs.org/) (versão recomendada: 18 ou superior)
|
|
9
|
+
- [npm](https://www.npmjs.com/) ou [yarn](https://yarnpkg.com/)
|
|
10
|
+
|
|
11
|
+
## Instalação
|
|
12
|
+
Clone o repositório e instale as dependências:
|
|
13
|
+
```sh
|
|
14
|
+
# Clonar o repositório
|
|
15
|
+
git clone http://wcavmdevops:82/WCA/_git/WCA.DesignSystem
|
|
16
|
+
cd wca-designsystem
|
|
17
|
+
|
|
18
|
+
# Instalar dependências
|
|
19
|
+
npm install
|
|
20
|
+
# ou
|
|
21
|
+
yarn install
|
|
17
22
|
```
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Run inside another terminal:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
24
|
+
## Storybook, para poder ver os componentes
|
|
25
|
+
Para visualizar a documentação interativa dos componentes:
|
|
26
|
+
```sh
|
|
27
|
+
npm run storybook
|
|
28
|
+
# ou
|
|
28
29
|
yarn storybook
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
O Storybook estará disponível em `http://localhost:6006/`.
|
|
32
33
|
|
|
33
|
-
> NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
npm i # or yarn to install dependencies
|
|
42
|
-
npm start # or yarn start
|
|
35
|
+
## Executando os Testes
|
|
36
|
+
Para rodar os testes unitários com Jest:
|
|
37
|
+
```sh
|
|
38
|
+
npm run test
|
|
39
|
+
# ou
|
|
40
|
+
yarn test
|
|
43
41
|
```
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
## Configuration
|
|
52
|
-
|
|
53
|
-
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
|
|
54
|
-
|
|
55
|
-
### Jest
|
|
56
|
-
|
|
57
|
-
Jest tests are set up to run with `npm test` or `yarn test`.
|
|
58
|
-
|
|
59
|
-
### Bundle analysis
|
|
60
|
-
|
|
61
|
-
Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `npm run size` and visulize it with `npm run analyze`.
|
|
62
|
-
|
|
63
|
-
#### Setup Files
|
|
64
|
-
|
|
65
|
-
This is the folder structure we set up for you:
|
|
66
|
-
|
|
67
|
-
```txt
|
|
68
|
-
/example
|
|
69
|
-
index.html
|
|
70
|
-
index.tsx # test your component here in a demo app
|
|
71
|
-
package.json
|
|
72
|
-
tsconfig.json
|
|
73
|
-
/src
|
|
74
|
-
index.tsx # EDIT THIS
|
|
75
|
-
/test
|
|
76
|
-
blah.test.tsx # EDIT THIS
|
|
77
|
-
/stories
|
|
78
|
-
Thing.stories.tsx # EDIT THIS
|
|
79
|
-
/.storybook
|
|
80
|
-
main.js
|
|
81
|
-
preview.js
|
|
82
|
-
.gitignore
|
|
83
|
-
package.json
|
|
84
|
-
README.md # EDIT THIS
|
|
85
|
-
tsconfig.json
|
|
43
|
+
## Linter e Formatação
|
|
44
|
+
Verifique o código com ESLint:
|
|
45
|
+
```sh
|
|
46
|
+
npm run lint
|
|
47
|
+
# ou
|
|
48
|
+
yarn lint
|
|
86
49
|
```
|
|
87
50
|
|
|
88
|
-
#### React Testing Library
|
|
89
|
-
|
|
90
|
-
We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
|
|
91
|
-
|
|
92
|
-
### Rollup
|
|
93
|
-
|
|
94
|
-
TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
|
|
95
51
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
### GitHub Actions
|
|
103
|
-
|
|
104
|
-
Two actions are added by default:
|
|
105
|
-
|
|
106
|
-
- `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
|
|
107
|
-
- `size` which comments cost comparison of your library on every pull request using [size-limit](https://github.com/ai/size-limit)
|
|
108
|
-
|
|
109
|
-
## Optimizations
|
|
110
|
-
|
|
111
|
-
Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
|
|
112
|
-
|
|
113
|
-
```js
|
|
114
|
-
// ./types/index.d.ts
|
|
115
|
-
declare var __DEV__: boolean;
|
|
116
|
-
|
|
117
|
-
// inside your code...
|
|
118
|
-
if (__DEV__) {
|
|
119
|
-
console.log('foo');
|
|
120
|
-
}
|
|
52
|
+
## Publicação
|
|
53
|
+
Para publicar uma nova versão do Design System no NPM:
|
|
54
|
+
```sh
|
|
55
|
+
npm run deploy
|
|
56
|
+
# ou
|
|
57
|
+
yarn deploy
|
|
121
58
|
```
|
|
122
59
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
CJS, ESModules, and UMD module formats are supported.
|
|
128
|
-
|
|
129
|
-
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
|
|
130
|
-
|
|
131
|
-
## Deploying the Example Playground
|
|
132
|
-
|
|
133
|
-
The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
cd example # if not already in the example folder
|
|
137
|
-
npm run build # builds to dist
|
|
138
|
-
netlify deploy # deploy the dist folder
|
|
60
|
+
---
|
|
61
|
+
Isso irá gerar uma nova versão irá atualizar a versão e subir para o NPM vinculado ao projeto.
|
|
62
|
+
```sh
|
|
63
|
+
https://www.npmjs.com/package/wca-designsystem
|
|
139
64
|
```
|
|
140
65
|
|
|
141
|
-
|
|
66
|
+
Para conseguir subir o projeto, o usuário tem que estar logado no NPM, e precisa fazer parte da organização acima.
|
|
142
67
|
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
# build command: yarn build && cd example && yarn && yarn build
|
|
146
|
-
# directory to deploy: example/dist
|
|
147
|
-
# pick yes for netlify.toml
|
|
68
|
+
```sh
|
|
69
|
+
npm login
|
|
148
70
|
```
|
|
149
71
|
|
|
150
|
-
## Named Exports
|
|
151
|
-
|
|
152
|
-
Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
|
|
153
|
-
|
|
154
|
-
## Including Styles
|
|
155
|
-
|
|
156
|
-
There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
|
|
157
|
-
|
|
158
|
-
For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
|
|
159
|
-
|
|
160
|
-
## Publishing to NPM
|
|
161
72
|
|
|
162
|
-
We recommend using [np](https://github.com/sindresorhus/np).
|
|
163
|
-
|
|
164
|
-
## Usage with Lerna
|
|
165
|
-
|
|
166
|
-
When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
|
|
167
|
-
|
|
168
|
-
The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
|
|
169
|
-
|
|
170
|
-
Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
|
|
171
|
-
|
|
172
|
-
```diff
|
|
173
|
-
"alias": {
|
|
174
|
-
- "react": "../node_modules/react",
|
|
175
|
-
- "react-dom": "../node_modules/react-dom"
|
|
176
|
-
+ "react": "../../../node_modules/react",
|
|
177
|
-
+ "react-dom": "../../../node_modules/react-dom"
|
|
178
|
-
},
|
|
179
|
-
```
|
|
180
73
|
|
|
181
|
-
An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.89",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"analyze": "size-limit --why",
|
|
21
21
|
"storybook": "storybook dev -p 6006",
|
|
22
22
|
"build-storybook": "storybook build",
|
|
23
|
-
"deploy": "npm publish"
|
|
23
|
+
"deploy": "npm version patch && npm publish"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": ">=16"
|
|
@@ -54,6 +54,8 @@ const TabelaHeader = <T extends { id: string | number; children?: Array<T> }>({
|
|
|
54
54
|
});
|
|
55
55
|
setFormatedColumns(columnsFormated);
|
|
56
56
|
}, []);
|
|
57
|
+
|
|
58
|
+
const columnsToHide = ['expand', 'select'];
|
|
57
59
|
return (
|
|
58
60
|
<S.HeaderTableContent>
|
|
59
61
|
<InputDeTexto
|
|
@@ -137,7 +139,7 @@ const TabelaHeader = <T extends { id: string | number; children?: Array<T> }>({
|
|
|
137
139
|
checked={column.active}
|
|
138
140
|
onChange={() => onChangeCheckedColumn(String(column.key))}
|
|
139
141
|
/>
|
|
140
|
-
{column.header}
|
|
142
|
+
{columnsToHide.includes(column.header) ? '' : column.header}
|
|
141
143
|
</S.MenuDropDown>
|
|
142
144
|
</Menu.Item>
|
|
143
145
|
))}
|
|
@@ -157,8 +157,8 @@ const Tabela = <
|
|
|
157
157
|
setOrdenarPor={setOrdenarPor}
|
|
158
158
|
/>
|
|
159
159
|
{/* Scroll horizontal no topo */}
|
|
160
|
-
<S.ScrollWrapper ref={topScrollRef}></S.ScrollWrapper>
|
|
161
160
|
<S.TableContainer ref={TableContainerRef}>
|
|
161
|
+
<S.ScrollWrapper ref={topScrollRef}></S.ScrollWrapper>
|
|
162
162
|
<S.StyledTable ref={tabelaRef}>
|
|
163
163
|
{data?.length == 0 ? (
|
|
164
164
|
<></>
|
|
@@ -203,7 +203,6 @@ const Tabela = <
|
|
|
203
203
|
)}
|
|
204
204
|
</S.StyledTable>
|
|
205
205
|
</S.TableContainer>
|
|
206
|
-
{}
|
|
207
206
|
|
|
208
207
|
{data.length > 0 && !hasInfinitScrool && (
|
|
209
208
|
<Paginacao
|
|
@@ -60,8 +60,9 @@ export const StyledTable = styled.table`
|
|
|
60
60
|
export const TabelaHeader = styled.thead<ColorsProp>`
|
|
61
61
|
${({ theme, color }) => css`
|
|
62
62
|
position: sticky;
|
|
63
|
+
overflow-x: visible;
|
|
63
64
|
top: 0;
|
|
64
|
-
z-index:
|
|
65
|
+
z-index: 10;
|
|
65
66
|
|
|
66
67
|
th {
|
|
67
68
|
text-align: center;
|
|
@@ -242,9 +243,10 @@ export const PaginationButtons = styled.div<ColorsProp>`
|
|
|
242
243
|
`;
|
|
243
244
|
|
|
244
245
|
export const ScrollWrapper = styled.div`
|
|
245
|
-
|
|
246
|
+
position: relative;
|
|
247
|
+
z-index: 10;
|
|
248
|
+
overflow-x: visible;
|
|
246
249
|
width: 100%;
|
|
247
|
-
margin-bottom: -15px;
|
|
248
250
|
`;
|
|
249
251
|
|
|
250
252
|
export const FakeTable = styled.div`
|