kdpa-components 0.0.4

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/.eslintrc.cjs ADDED
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es2020: true
5
+ },
6
+ extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended", "plugin:storybook/recommended"],
7
+ parser: '@typescript-eslint/parser',
8
+ parserOptions: {
9
+ ecmaVersion: 'latest',
10
+ sourceType: 'module'
11
+ },
12
+ plugins: ['react-refresh'],
13
+ rules: {
14
+ 'react-refresh/only-export-components': 'warn'
15
+ }
16
+ };
@@ -0,0 +1,17 @@
1
+ import type { StorybookConfig } from "@storybook/react-vite";
2
+ const config: StorybookConfig = {
3
+ stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
4
+ addons: [
5
+ "@storybook/addon-links",
6
+ "@storybook/addon-essentials",
7
+ "@storybook/addon-interactions",
8
+ ],
9
+ framework: {
10
+ name: "@storybook/react-vite",
11
+ options: {},
12
+ },
13
+ docs: {
14
+ autodocs: "tag",
15
+ },
16
+ };
17
+ export default config;
@@ -0,0 +1,15 @@
1
+ import type { Preview } from "@storybook/react";
2
+
3
+ const preview: Preview = {
4
+ parameters: {
5
+ actions: { argTypesRegex: "^on[A-Z].*" },
6
+ controls: {
7
+ matchers: {
8
+ color: /(background|color)$/i,
9
+ date: /Date$/,
10
+ },
11
+ },
12
+ },
13
+ };
14
+
15
+ export default preview;
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,55 @@
1
+ {
2
+ "name": "kdpa-components",
3
+ "version": "0.0.4",
4
+ "type": "module",
5
+ "main": "./dist",
6
+ "types": "./dist",
7
+ "exports": {
8
+ ".": "./dist"
9
+ },
10
+ "scripts": {
11
+ "dev": "vite",
12
+ "build": "tsc && vite build",
13
+ "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
14
+ "preview": "vite preview",
15
+ "storybook": "storybook dev -p 6006",
16
+ "build-storybook": "storybook build"
17
+ },
18
+ "dependencies": {
19
+ "@emotion/react": "^11.10.6",
20
+ "@emotion/styled": "^11.10.6",
21
+ "@mui/material": "^5.12.2",
22
+ "@types/babel__traverse": "^7.18.5",
23
+ "react": "^17.0.2",
24
+ "react-dom": "^17.0.2",
25
+ "rollup-plugin-dts": "^5.3.0",
26
+ "vite-plugin-dts": "^2.3.0",
27
+ "vite-tsconfig-paths": "^4.2.0"
28
+ },
29
+ "peerDependencies": {
30
+ "react": "^17.0.2",
31
+ "react-dom": "^17.0.2"
32
+ },
33
+ "devDependencies": {
34
+ "@storybook/addon-essentials": "7.0.7",
35
+ "@storybook/addon-interactions": "7.0.7",
36
+ "@storybook/addon-links": "7.0.7",
37
+ "@storybook/blocks": "7.0.7",
38
+ "@storybook/react": "7.0.7",
39
+ "@storybook/react-vite": "7.0.7",
40
+ "@storybook/testing-library": "0.0.14-next.2",
41
+ "@types/react": "^18.0.28",
42
+ "@types/react-dom": "^18.0.11",
43
+ "@typescript-eslint/eslint-plugin": "^5.57.1",
44
+ "@typescript-eslint/parser": "^5.57.1",
45
+ "@vitejs/plugin-react": "^4.0.0",
46
+ "eslint": "^8.38.0",
47
+ "eslint-plugin-react-hooks": "^4.6.0",
48
+ "eslint-plugin-react-refresh": "^0.3.4",
49
+ "eslint-plugin-storybook": "^0.6.11",
50
+ "prop-types": "15.8.1",
51
+ "storybook": "7.0.7",
52
+ "typescript": "^5.0.2",
53
+ "vite": "^4.3.2"
54
+ }
55
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/src/App.tsx ADDED
@@ -0,0 +1,34 @@
1
+ import { useState } from "react";
2
+ // import reactLogo from "./assets/react.svg";
3
+ // import viteLogo from "/vite.svg";
4
+
5
+ function App() {
6
+ const [count, setCount] = useState(0);
7
+
8
+ return (
9
+ <>
10
+ <div>
11
+ <a href="https://vitejs.dev" target="_blank">
12
+ {/* <img src={viteLogo} className="logo" alt="Vite logo" /> */}
13
+ </a>
14
+ <a href="https://react.dev" target="_blank">
15
+ {/* <img src={reactLogo} className="logo react" alt="React logo" /> */}
16
+ </a>
17
+ </div>
18
+ <h1>Vite + React</h1>
19
+ <div className="card">
20
+ <button onClick={() => setCount((count) => count + 1)}>
21
+ count is {count}
22
+ </button>
23
+ <p>
24
+ Edit <code>src/App.tsx</code> and save to test HMR
25
+ </p>
26
+ </div>
27
+ <p className="read-the-docs">
28
+ Click on the Vite and React logos to learn more
29
+ </p>
30
+ </>
31
+ );
32
+ }
33
+
34
+ export default App;
@@ -0,0 +1,30 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import {
3
+ KdpaAccordion,
4
+ KdpaAccordionDetails,
5
+ KdpaAccordionSummary,
6
+ } from "./KdpaAccordions";
7
+
8
+ const meta: Meta<typeof KdpaAccordion> = {
9
+ title: "@Kdpa/KdpaAccordion",
10
+ component: KdpaAccordion,
11
+ tags: ["autodocs"],
12
+ };
13
+
14
+ export default meta;
15
+ type Story = StoryObj<typeof KdpaAccordion>;
16
+
17
+ export const Primary: Story = {
18
+ args: {
19
+ children: (
20
+ <KdpaAccordion>
21
+ <KdpaAccordionSummary>تست موضوع</KdpaAccordionSummary>
22
+ <KdpaAccordionDetails>این موضوع تست میشود</KdpaAccordionDetails>
23
+ </KdpaAccordion>
24
+ ),
25
+ },
26
+ parameters: {
27
+ componentSubtitle:
28
+ "This link is for viewing the main component : https://mui.com/material-ui/react-accordion/",
29
+ },
30
+ };
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import Accordion, { AccordionProps } from "@mui/material/Accordion";
3
+ import AccordionSummary, {
4
+ AccordionSummaryProps,
5
+ } from "@mui/material/AccordionSummary";
6
+ import AccordionDetails, {
7
+ AccordionDetailsProps,
8
+ } from "@mui/material/AccordionDetails";
9
+
10
+ export type KdpaAccordionProps = AccordionProps;
11
+ export type KdpaAccordionSummaryProps = AccordionSummaryProps;
12
+ export type KdpaAccordionDetailsProps = AccordionDetailsProps;
13
+
14
+ const KdpaAccordion = ({ children, ...props }: KdpaAccordionProps) => {
15
+ return <Accordion {...props}>{children}</Accordion>;
16
+ };
17
+
18
+ const KdpaAccordionSummary = ({
19
+ children,
20
+ ...props
21
+ }: KdpaAccordionSummaryProps) => {
22
+ return (
23
+ <AccordionSummary aria-controls="panel1a-content" {...props}>
24
+ {children}
25
+ </AccordionSummary>
26
+ );
27
+ };
28
+
29
+ const KdpaAccordionDetails = ({
30
+ children,
31
+ ...props
32
+ }: KdpaAccordionDetailsProps) => {
33
+ return <AccordionDetails {...props}>{children}</AccordionDetails>;
34
+ };
35
+
36
+ export { KdpaAccordion, KdpaAccordionSummary, KdpaAccordionDetails };
@@ -0,0 +1,11 @@
1
+ export {
2
+ KdpaAccordion,
3
+ KdpaAccordionDetails,
4
+ KdpaAccordionSummary,
5
+ } from "./KdpaAccordions";
6
+
7
+ export type {
8
+ KdpaAccordionProps,
9
+ KdpaAccordionDetailsProps,
10
+ KdpaAccordionSummaryProps,
11
+ } from "./KdpaAccordions";
@@ -0,0 +1,25 @@
1
+ import { Meta, StoryObj } from "@storybook/react";
2
+ import KdpaAlert from "./KdpaAlert";
3
+ import KdpaAlertTitle from "./KdpaAlertTitle";
4
+
5
+ const meta: Meta<typeof KdpaAlert> = {
6
+ title: "@Kdpa/KdpaAlert",
7
+ component: KdpaAlert,
8
+ tags: ["autodocs"],
9
+ };
10
+
11
+ export default meta;
12
+ type Story = StoryObj<typeof KdpaAlert>;
13
+
14
+ export const Primary: Story = {
15
+ args: {
16
+ severity: "warning",
17
+ className: "my-1",
18
+ children: (
19
+ <>
20
+ <KdpaAlertTitle>توجه!</KdpaAlertTitle>
21
+ <p>ارتباط برقرار نشد</p>
22
+ </>
23
+ ),
24
+ },
25
+ };
@@ -0,0 +1,29 @@
1
+ import React, { forwardRef } from "react";
2
+ import { Alert, AlertProps } from "@mui/material";
3
+
4
+ export type KdpaAlertProps = AlertProps;
5
+
6
+ const KdpaAlert = forwardRef<HTMLDivElement, KdpaAlertProps>(function KdpaAlert(
7
+ props: KdpaAlertProps,
8
+ ref
9
+ ) {
10
+ const color = {
11
+ success: "bg-light-success",
12
+ info: "bg-light-info",
13
+ warning: "bg-light-warning",
14
+ error: "bg-light-danger",
15
+ }[props.severity ?? "info"];
16
+
17
+ const className = props.className ?? "d-flex align-items-center mb-50";
18
+ return (
19
+ <Alert
20
+ ref={ref}
21
+ severity={props.severity}
22
+ className={`${className} ${color}`}
23
+ >
24
+ {props.children}
25
+ </Alert>
26
+ );
27
+ });
28
+
29
+ export default KdpaAlert;
@@ -0,0 +1,11 @@
1
+ import { AlertTitle, AlertTitleProps } from "@mui/material";
2
+
3
+ export type KdpaAlertTitleProps = AlertTitleProps;
4
+
5
+ function KdpaAlertTitle(props: KdpaAlertTitleProps) {
6
+ return (
7
+ <AlertTitle className={props.className ?? ""}>{props.children}</AlertTitle>
8
+ );
9
+ }
10
+
11
+ export default KdpaAlertTitle;
@@ -0,0 +1,5 @@
1
+ export { default as KdpaAlert } from "./KdpaAlert";
2
+ export { default as KdpaAlertTitle } from "./KdpaAlertTitle";
3
+
4
+ export type { KdpaAlertProps } from "./KdpaAlert";
5
+ export type { KdpaAlertTitleProps } from "./KdpaAlertTitle";
package/src/main.tsx ADDED
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import App from "./App";
4
+
5
+ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
6
+ <React.StrictMode>
7
+ <App />
8
+ </React.StrictMode>
9
+ );
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
package/tsconfig.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "compilerOptions": {
3
+ // "target": "ESNext",
4
+ // "lib": ["DOM", "DOM.Iterable", "ESNext"],
5
+ // "module": "ESNext",
6
+ // "skipLibCheck": true,
7
+
8
+ // /* Bundler mode */
9
+ // "moduleResolution": "bundler",
10
+ // "allowImportingTsExtensions": true,
11
+ // "resolveJsonModule": true,
12
+ // "isolatedModules": true,
13
+ // "noEmit": true,
14
+ // "jsx": "react-jsx",
15
+
16
+ // /* Linting */
17
+ // "strict": true,
18
+ // "noUnusedLocals": true,
19
+ // "noUnusedParameters": true,
20
+ // "noFallthroughCasesInSwitch": true
21
+
22
+ "target": "ESNext",
23
+ "useDefineForClassFields": true,
24
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
25
+ "allowJs": false,
26
+ "allowSyntheticDefaultImports": true,
27
+ "strict": true,
28
+ "forceConsistentCasingInFileNames": true,
29
+ "module": "ESNext",
30
+ "moduleResolution": "Node",
31
+ "resolveJsonModule": true,
32
+ "isolatedModules": true,
33
+ "noEmit": true,
34
+ "jsx": "react-jsx",
35
+ "declaration": true,
36
+ "skipLibCheck": true,
37
+ "esModuleInterop": true ,
38
+ "declarationMap": true,
39
+ "baseUrl": ".",
40
+ },
41
+ "include": ["src"],
42
+ "references": [{ "path": "./tsconfig.node.json" }]
43
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "include": ["vite.config.ts"]
10
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,106 @@
1
+ import { defineConfig } from "vite";
2
+ import react from "@vitejs/plugin-react";
3
+ import dts from "vite-plugin-dts";
4
+ import tsConfigPaths from "vite-tsconfig-paths";
5
+
6
+ import path, { resolve } from "node:path";
7
+
8
+ import glob from "glob";
9
+ import { fileURLToPath } from "node:url";
10
+
11
+ // https://vitejs.dev/config/
12
+ export default defineConfig({
13
+ plugins: [
14
+ // tsConfigPaths(),
15
+ dts({
16
+ include: ["src/components/**/*.ts"],
17
+ // outputDir: "./build",
18
+ // insertTypesEntry: true,
19
+ }),
20
+ react(),
21
+ ],
22
+
23
+ build: {
24
+ // outDir: "./build",
25
+
26
+ lib: {
27
+ // entry: resolve("src", "components/index.ts"),
28
+ entry: Object.fromEntries(
29
+ glob.sync("src/components/**/*index.ts").map((file) => [
30
+ // This remove `src/` as well as the file extension from each
31
+ // file, so e.g. src/nested/foo.js becomes nested/foo
32
+ // path.relative(
33
+ // "src/components",
34
+ // file.slice(0, file.length - path.extname(file).length)
35
+ // ),
36
+ file,
37
+ // This expands the relative paths to absolute paths, so e.g.
38
+ // src/nested/foo becomes /project/src/nested/foo.js
39
+ fileURLToPath(new URL(file, import.meta.url)),
40
+ ])
41
+ ),
42
+ // entry: glob.sync("src/components/**/index.ts"),
43
+
44
+ name: "KdpaComponents",
45
+
46
+ formats: ["es"],
47
+ // fileName: (_, name) => {
48
+ // const filePath = name.split("/").slice(1, -1).join("/");
49
+
50
+ // console.log("name", filePath);
51
+ // return `${filePath}/index.js`;
52
+ // },
53
+
54
+ fileName: (_, name) => {
55
+ const path = name.split("/").slice(2).join("/").split(".")[0];
56
+ return `${path}.js`;
57
+ },
58
+ },
59
+
60
+ rollupOptions: {
61
+ external: ["react", "react-dom"],
62
+
63
+ input: Object.fromEntries(
64
+ glob.sync("src/components/**/index.ts").map((file) => [
65
+ // This remove `src/` as well as the file extension from each
66
+ // file, so e.g. src/nested/foo.js becomes nested/foo
67
+ // path.relative(
68
+ // "src/components",
69
+ // file.slice(0, file.length - path.extname(file).length)
70
+ // ),
71
+ file,
72
+ // This expands the relative paths to absolute paths, so e.g.
73
+ // src/nested/foo becomes /project/src/nested/foo.js
74
+ fileURLToPath(new URL(file, import.meta.url)),
75
+ ])
76
+ ),
77
+ // input: glob.sync("src/components/**/index.ts"),
78
+ output: {
79
+ inlineDynamicImports: false,
80
+ format: "es",
81
+
82
+ // entryFileNames: "[name].js",
83
+ // chunkFileNames: "[name].js",
84
+ },
85
+ },
86
+
87
+ minify: true,
88
+ },
89
+ });
90
+
91
+ // console.log(
92
+ // Object.fromEntries(
93
+ // glob.sync("src/components/**/index.ts").map((file) => [
94
+ // // This remove `src/` as well as the file extension from each
95
+ // // file, so e.g. src/nested/foo.js becomes nested/foo
96
+ // // path.relative(
97
+ // // "src/components",
98
+ // // file.slice(0, file.length - path.extname(file).length)
99
+ // // ),
100
+ // file,
101
+ // // This expands the relative paths to absolute paths, so e.g.
102
+ // // src/nested/foo becomes /project/src/nested/foo.js
103
+ // fileURLToPath(new URL(file, import.meta.url)),
104
+ // ])
105
+ // )
106
+ // );