@canaia/ui-kit 0.0.1
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/.storybook/main.ts +21 -0
- package/.storybook/preview.ts +23 -0
- package/README.md +50 -0
- package/eslint.config.js +30 -0
- package/index.html +13 -0
- package/package.json +56 -0
- package/src/components/Select/Select.stories.tsx +29 -0
- package/src/components/Select/Select.styles.ts +12 -0
- package/src/components/Select/Select.tsx +16 -0
- package/src/components/Select/Select.types.ts +9 -0
- package/src/components/Select/index.tsx +3 -0
- package/src/index.tsx +6 -0
- package/src/provider/index.tsx +14 -0
- package/src/theme/index.tsx +44 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.app.json +26 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +24 -0
- package/vite.config.ts +26 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { mergeConfig } from "vite";
|
|
2
|
+
import type { StorybookConfig } from "@storybook/react-vite";
|
|
3
|
+
|
|
4
|
+
const config: StorybookConfig = {
|
|
5
|
+
stories: ["../src/components/**/*.stories.@(js|jsx|ts|tsx)"],
|
|
6
|
+
addons: [
|
|
7
|
+
"@storybook/addon-essentials",
|
|
8
|
+
"@storybook/addon-interactions",
|
|
9
|
+
'@chakra-ui/storybook-addon',
|
|
10
|
+
],
|
|
11
|
+
framework: "@storybook/react-vite",
|
|
12
|
+
async viteFinal(config) {
|
|
13
|
+
return mergeConfig(config, {
|
|
14
|
+
optimizeDeps: {
|
|
15
|
+
include: ["lodash.mergewith"],
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default config;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Preview } from "@storybook/react";
|
|
2
|
+
import theme from "../src/theme"; // Tu tema personalizado
|
|
3
|
+
|
|
4
|
+
export const parameters = {
|
|
5
|
+
chakra: {
|
|
6
|
+
theme,
|
|
7
|
+
},
|
|
8
|
+
}
|
|
9
|
+
const preview: Preview = {
|
|
10
|
+
parameters: {
|
|
11
|
+
controls: {
|
|
12
|
+
matchers: {
|
|
13
|
+
color: /(background|color)$/i,
|
|
14
|
+
date: /Date$/,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
chakra: {
|
|
18
|
+
theme,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default preview;
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## Expanding the ESLint configuration
|
|
11
|
+
|
|
12
|
+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
|
13
|
+
|
|
14
|
+
- Configure the top-level `parserOptions` property like this:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
export default tseslint.config({
|
|
18
|
+
languageOptions: {
|
|
19
|
+
// other options...
|
|
20
|
+
parserOptions: {
|
|
21
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
22
|
+
tsconfigRootDir: import.meta.dirname,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
|
|
29
|
+
- Optionally add `...tseslint.configs.stylisticTypeChecked`
|
|
30
|
+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
// eslint.config.js
|
|
34
|
+
import react from 'eslint-plugin-react'
|
|
35
|
+
|
|
36
|
+
export default tseslint.config({
|
|
37
|
+
// Set the react version
|
|
38
|
+
settings: { react: { version: '18.3' } },
|
|
39
|
+
plugins: {
|
|
40
|
+
// Add the react plugin
|
|
41
|
+
react,
|
|
42
|
+
},
|
|
43
|
+
rules: {
|
|
44
|
+
// other rules...
|
|
45
|
+
// Enable its recommended rules
|
|
46
|
+
...react.configs.recommended.rules,
|
|
47
|
+
...react.configs['jsx-runtime'].rules,
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
```
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
5
|
+
import tseslint from 'typescript-eslint'
|
|
6
|
+
|
|
7
|
+
export default tseslint.config(
|
|
8
|
+
{ ignores: ['dist'] },
|
|
9
|
+
{
|
|
10
|
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
11
|
+
files: ['**/*.{ts,tsx}'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
ecmaVersion: 2020,
|
|
14
|
+
globals: globals.browser,
|
|
15
|
+
},
|
|
16
|
+
plugins: {
|
|
17
|
+
'react-hooks': reactHooks,
|
|
18
|
+
'react-refresh': reactRefresh,
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
...reactHooks.configs.recommended.rules,
|
|
22
|
+
'react-refresh/only-export-components': [
|
|
23
|
+
'warn',
|
|
24
|
+
{ allowConstantExport: true },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
package/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + React + TS</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@canaia/ui-kit",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite",
|
|
7
|
+
"build": "tsc -b && vite build",
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"storybook": "storybook dev -p 6006",
|
|
11
|
+
"build-storybook": "storybook build"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@chakra-ui/icons": "^2.2.4",
|
|
15
|
+
"@chakra-ui/react": "^2.10.4",
|
|
16
|
+
"@chakra-ui/storybook-addon": "^5.2.5",
|
|
17
|
+
"@emotion/react": "^11.13.5",
|
|
18
|
+
"@emotion/styled": "^11.13.5",
|
|
19
|
+
"@storybook/addon-themes": "^8.4.5",
|
|
20
|
+
"framer-motion": "^11.11.17",
|
|
21
|
+
"lodash.mergewith": "^4.6.2",
|
|
22
|
+
"path": "^0.12.7",
|
|
23
|
+
"react": "^18.2.0",
|
|
24
|
+
"react-dom": "^18.2.0",
|
|
25
|
+
"react-router-dom": "^7.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@chromatic-com/storybook": "^3.2.2",
|
|
29
|
+
"@eslint/js": "^9.13.0",
|
|
30
|
+
"@storybook/addon-essentials": "^8.4.5",
|
|
31
|
+
"@storybook/addon-interactions": "^8.4.5",
|
|
32
|
+
"@storybook/addon-onboarding": "^8.4.5",
|
|
33
|
+
"@storybook/blocks": "^8.4.5",
|
|
34
|
+
"@storybook/react": "^8.4.5",
|
|
35
|
+
"@storybook/react-vite": "^8.4.5",
|
|
36
|
+
"@storybook/test": "^8.4.5",
|
|
37
|
+
"@types/node": "^22.9.1",
|
|
38
|
+
"@types/react": "^18.3.12",
|
|
39
|
+
"@types/react-dom": "^18.3.1",
|
|
40
|
+
"@vitejs/plugin-react": "^4.3.3",
|
|
41
|
+
"eslint": "^9.13.0",
|
|
42
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
43
|
+
"eslint-plugin-react-refresh": "^0.4.14",
|
|
44
|
+
"eslint-plugin-storybook": "^0.11.1",
|
|
45
|
+
"globals": "^15.11.0",
|
|
46
|
+
"storybook": "^8.4.5",
|
|
47
|
+
"typescript": "^5.6.3",
|
|
48
|
+
"typescript-eslint": "^8.11.0",
|
|
49
|
+
"vite": "^5.4.10"
|
|
50
|
+
},
|
|
51
|
+
"eslintConfig": {
|
|
52
|
+
"extends": [
|
|
53
|
+
"plugin:storybook/recommended"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
2
|
+
import Select from "./Select";
|
|
3
|
+
import { SelectProps } from "./Select.types";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "Components/Select",
|
|
7
|
+
component: Select,
|
|
8
|
+
argTypes: {
|
|
9
|
+
options: { control: "object" },
|
|
10
|
+
size: { control: "select", options: ["sm", "md", "lg"] },
|
|
11
|
+
variant: { control: "select", options: ["outline", "filled", "flushed", "unstyled"] },
|
|
12
|
+
},
|
|
13
|
+
} as Meta;
|
|
14
|
+
|
|
15
|
+
const Template: StoryFn<SelectProps> = (args) => <Select {...args} />;
|
|
16
|
+
|
|
17
|
+
export const Default = Template.bind({});
|
|
18
|
+
Default.args = {
|
|
19
|
+
options: [
|
|
20
|
+
{ label: "Option 1", value: "1" },
|
|
21
|
+
{ label: "Option 2", value: "2" },
|
|
22
|
+
],
|
|
23
|
+
size: "md",
|
|
24
|
+
variant: "outline",
|
|
25
|
+
onChange: (value) => console.log(value),
|
|
26
|
+
color: "white.50",
|
|
27
|
+
placeholder: "placeholder",
|
|
28
|
+
disabled: false,
|
|
29
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Select as ChakraSelect } from "@chakra-ui/react";
|
|
2
|
+
import { SelectProps } from "./Select.types";
|
|
3
|
+
|
|
4
|
+
const Select: React.FC<SelectProps> = ({ options, onChange, ...rest }) => {
|
|
5
|
+
return (
|
|
6
|
+
<ChakraSelect onChange={(e) => onChange(e.target.value)} {...rest}>
|
|
7
|
+
{options.map((option) => (
|
|
8
|
+
<option key={option.value} value={option.value}>
|
|
9
|
+
{option.label}
|
|
10
|
+
</option>
|
|
11
|
+
))}
|
|
12
|
+
</ChakraSelect>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default Select;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ChakraProvider } from "@chakra-ui/react";
|
|
3
|
+
import { Outlet } from "react-router-dom";
|
|
4
|
+
import theme from "../theme";
|
|
5
|
+
|
|
6
|
+
const ChakraOutletProvider: React.FC = () => {
|
|
7
|
+
return (
|
|
8
|
+
<ChakraProvider theme={theme}>
|
|
9
|
+
<Outlet />
|
|
10
|
+
</ChakraProvider>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default ChakraOutletProvider;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { extendTheme } from "@chakra-ui/react";
|
|
2
|
+
|
|
3
|
+
const theme = extendTheme({
|
|
4
|
+
colors: {
|
|
5
|
+
primary: {
|
|
6
|
+
50: "#e3f2f9",
|
|
7
|
+
100: "#c5e4f3",
|
|
8
|
+
500: "#062B60",
|
|
9
|
+
600: "#0C56C0",
|
|
10
|
+
700: "#0A48A1",
|
|
11
|
+
},
|
|
12
|
+
secondary: {
|
|
13
|
+
500: "#38ADC7",
|
|
14
|
+
700: "#2D9DB2",
|
|
15
|
+
},
|
|
16
|
+
blue: {
|
|
17
|
+
50: "#38ADC7",
|
|
18
|
+
100: "#0C56C0",
|
|
19
|
+
500: "#094192",
|
|
20
|
+
600: "#062B60",
|
|
21
|
+
700: "#094192",
|
|
22
|
+
800: "#051a39"
|
|
23
|
+
},
|
|
24
|
+
grey: {
|
|
25
|
+
50: "#F7F7F7",
|
|
26
|
+
100: "#999",
|
|
27
|
+
500: "#ECECEC",
|
|
28
|
+
600: "#4E4D4D",
|
|
29
|
+
},
|
|
30
|
+
white: {
|
|
31
|
+
50: "#FFF"
|
|
32
|
+
},
|
|
33
|
+
green: {
|
|
34
|
+
100: "#34C759",
|
|
35
|
+
300: "#269642"
|
|
36
|
+
},
|
|
37
|
+
black: {
|
|
38
|
+
300: "#000000"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default theme;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
+
"target": "ES2020",
|
|
5
|
+
"useDefineForClassFields": true,
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"module": "ESNext",
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
|
|
10
|
+
/* Bundler mode */
|
|
11
|
+
"moduleResolution": "Bundler",
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
|
|
18
|
+
/* Linting */
|
|
19
|
+
"strict": true,
|
|
20
|
+
"noUnusedLocals": true,
|
|
21
|
+
"noUnusedParameters": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noUncheckedSideEffectImports": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["src"]
|
|
26
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"moduleResolution": "Bundler",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"moduleDetection": "force",
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
|
|
16
|
+
/* Linting */
|
|
17
|
+
"strict": true,
|
|
18
|
+
"noUnusedLocals": true,
|
|
19
|
+
"noUnusedParameters": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"noUncheckedSideEffectImports": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["vite.config.ts"]
|
|
24
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import path from "path";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react()],
|
|
7
|
+
optimizeDeps: {
|
|
8
|
+
include: ["lodash.mergewith"],
|
|
9
|
+
},
|
|
10
|
+
build: {
|
|
11
|
+
lib: {
|
|
12
|
+
entry: path.resolve(__dirname, "src/index.tsx"),
|
|
13
|
+
name: "CanaiaUiKit",
|
|
14
|
+
fileName: (format) => `canaia-ui-kit.${format}.js`,
|
|
15
|
+
},
|
|
16
|
+
rollupOptions: {
|
|
17
|
+
external: ["react", "react-dom"],
|
|
18
|
+
output: {
|
|
19
|
+
globals: {
|
|
20
|
+
react: "React",
|
|
21
|
+
"react-dom": "ReactDOM",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|