diff --git a/dist/components/button/button.type.d.ts b/dist/components/button/button.type.d.ts new file mode 100644 index 0000000..ec0a960 --- /dev/null +++ b/dist/components/button/button.type.d.ts @@ -0,0 +1,5 @@ +import React from 'react'; +export interface ButtonProps extends React.ButtonHTMLAttributes { + title: string; + onClick?: () => void; +} diff --git a/dist/components/button/index.d.ts b/dist/components/button/index.d.ts index 96f7276..7619751 100644 --- a/dist/components/button/index.d.ts +++ b/dist/components/button/index.d.ts @@ -1,2 +1,3 @@ -declare const Button: () => any; +import { ButtonProps } from './button.type'; +declare const Button: ({ title, onClick }: ButtonProps) => any; export default Button; diff --git a/dist/components/button/index.js b/dist/components/button/index.js index 2b39865..7d02211 100644 --- a/dist/components/button/index.js +++ b/dist/components/button/index.js @@ -1,2 +1,2 @@ -import{cn as t}from"../../lib/utils.js";import e from"react";var r=function(){return e.createElement("div",{className:t("bg-blue-500","text-white")},"Button")};export{r as default}; +import{cn as t}from"../../lib/utils.js";import e from"react";var r=function(r){var i=r.title,l=r.onClick;return e.createElement("div",{className:t("bg-blue-500","text-white"),onClick:l},i)};export{r as default}; //# sourceMappingURL=index.js.map diff --git a/dist/components/button/index.js.map b/dist/components/button/index.js.map index a43696f..1df7b8e 100644 --- a/dist/components/button/index.js.map +++ b/dist/components/button/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import { cn } from '@/lib/utils'\r\nimport React from 'react'\r\n\r\n\r\nconst Button = () => {\r\n return (\r\n
\r\n Button\r\n
\r\n )\r\n}\r\n\r\nexport default Button"],"names":["Button","React","createElement","className","cn"],"mappings":"6DAIA,IAAMA,EAAS,WACb,OACEC,EAAAC,cAAA,MAAA,CAAKC,UAAWC,EACd,cACA,eAGI,SAEV"} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../../../src/components/button/index.tsx"],"sourcesContent":["import { cn } from '@/lib/utils'\r\nimport React from 'react'\r\nimport { ButtonProps } from './button.type'\r\n\r\nconst Button = ({ title, onClick }: ButtonProps) => {\r\n return (\r\n
\r\n {title}\r\n
\r\n )\r\n}\r\n\r\nexport default Button"],"names":["Button","_ref","title","onClick","React","createElement","className","cn"],"mappings":"6DAIA,IAAMA,EAAS,SAAHC,GAAuC,IAAjCC,EAAKD,EAALC,MAAOC,EAAOF,EAAPE,QACvB,OACEC,EAAKC,cAAA,MAAA,CAAAC,UAAWC,EACd,cACA,cAEFJ,QAASA,GAEND,EAGP"} \ No newline at end of file diff --git a/generateRollupConfig.js b/generateRollupConfig.js new file mode 100644 index 0000000..9930a00 --- /dev/null +++ b/generateRollupConfig.js @@ -0,0 +1,53 @@ +const typescript = require('@rollup/plugin-typescript') +const babel = require('@rollup/plugin-babel') +const postcss = require('rollup-plugin-postcss') +const tailwind = require('rollup-plugin-tailwindcss') +const autoprefixer = require('autoprefixer') +const resolve = require('@rollup/plugin-node-resolve') +const commonjs = require('@rollup/plugin-commonjs') +const { terser } = require('rollup-plugin-terser') +const pkg = require('./package.json') + +const external = [ + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}), + /@babel\/runtime/ +] + +const rollupConfig = { + input: 'src/index.ts', + output: { + dir: 'dist', + format: 'esm', + sourcemap: true, + preserveModules: true, + preserveModulesRoot: 'src' + }, + external, + plugins: [ + resolve(), + commonjs(), + typescript({ + declaration: true, + noEmitOnError: true + }), + babel({ + extensions: ['.js', '.jsx', '.ts', '.tsx'], + babelHelpers: 'runtime', + include: ['src/**/*'], + plugins: ['@babel/plugin-transform-runtime'] + }), + postcss({ + plugins: [autoprefixer()], + sourceMap: true, + extract: true, + minimize: true + }), + tailwind({ + input: './styles/globals.css' + }), + terser() + ] +} + +module.exports = rollupConfig diff --git a/package.json b/package.json index 7dab5d0..1a88678 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,21 @@ { "name": "library-template", - "version": "1.0.2", + "version": "1.0.3", "type": "module", "exports": { - ".": "./dist/index.js", - "./button": "./dist/components/button/index.js", - "./input": "./dist/components/input/index.js" + ".": { + "import": "./dist/index.js", + "types": "./dist/index.d.ts" + }, + "./button": { + "import": "./dist/components/button/index.js", + "types": "./dist/components/button/index.d.ts" + }, + "./input": { + "import": "./dist/components/input/index.js", + "types": "./dist/components/input/index.d.ts" + } }, - "types": "dist/index.d.ts", "files": [ "dist" ], diff --git a/src/components/button/button.type.ts b/src/components/button/button.type.ts new file mode 100644 index 0000000..3f6f589 --- /dev/null +++ b/src/components/button/button.type.ts @@ -0,0 +1,7 @@ +import React from 'react' + +export interface ButtonProps + extends React.ButtonHTMLAttributes { + title: string + onClick?: () => void +} \ No newline at end of file diff --git a/src/components/button/index.tsx b/src/components/button/index.tsx index 276697e..473cf22 100644 --- a/src/components/button/index.tsx +++ b/src/components/button/index.tsx @@ -1,14 +1,16 @@ import { cn } from '@/lib/utils' import React from 'react' +import { ButtonProps } from './button.type' - -const Button = () => { +const Button = ({ title, onClick }: ButtonProps) => { return (
- Button + )} + onClick={onClick} + > + {title}
) } diff --git a/src/components/input/input.type.ts b/src/components/input/input.type.ts new file mode 100644 index 0000000..e69de29