@dragunio/fe-libs 0.1.0
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/LICENSE +21 -0
- package/README.md +64 -0
- package/dist/index.d.mts +65 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +157 -0
- package/dist/index.mjs +118 -0
- package/dist/styles.css +215 -0
- package/dist/styles.d.mts +2 -0
- package/dist/styles.d.ts +2 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kdragon113
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# fe-libs
|
|
2
|
+
|
|
3
|
+
Reusable React component library published as one npm package.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
src/ # Public library entrypoints and styles
|
|
9
|
+
packages/ # Internal component source folders
|
|
10
|
+
├── icons/
|
|
11
|
+
├── button/
|
|
12
|
+
└── table/
|
|
13
|
+
apps/playground/ # Local component storybook
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Development
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm install
|
|
20
|
+
pnpm build
|
|
21
|
+
pnpm typecheck
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Test locally before publishing
|
|
25
|
+
|
|
26
|
+
The playground resolves package names directly to `packages/*/src`, so component changes are reflected by Vite HMR immediately.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm dev
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Open the URL printed by Vite, usually `http://127.0.0.1:5173`.
|
|
33
|
+
|
|
34
|
+
Available review routes:
|
|
35
|
+
|
|
36
|
+
- `http://127.0.0.1:5173/#/` — overview
|
|
37
|
+
- `http://127.0.0.1:5173/#/icons` — SVG Icons
|
|
38
|
+
- `http://127.0.0.1:5173/#/button` — Button
|
|
39
|
+
- `http://127.0.0.1:5173/#/table` — Table
|
|
40
|
+
|
|
41
|
+
To test the playground against generated package output instead of source aliases:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pnpm --filter @dragunio/playground dev:dist
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
To verify a production-like consumer build:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pnpm build
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Consuming the published library
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm add @dragunio/fe-libs
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { Button, PlusIcon, Table } from '@dragunio/fe-libs';
|
|
61
|
+
import '@dragunio/fe-libs/styles.css';
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The library exposes ESM, CommonJS, TypeScript declarations, and keeps React as a peer dependency.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode, SVGProps, TableHTMLAttributes, HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type ButtonHierarchy = 'primary' | 'secondary-gray' | 'secondary-color' | 'tertiary-gray' | 'tertiary-color';
|
|
5
|
+
type ButtonSize = '24' | '32' | '40';
|
|
6
|
+
type ButtonColor = 'normal' | 'success' | 'error' | 'warning';
|
|
7
|
+
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
8
|
+
type ButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'size' | 'prefix'> & {
|
|
9
|
+
/** Preferred visual API ported from the Haraworks Button. */
|
|
10
|
+
hierarchy?: ButtonHierarchy;
|
|
11
|
+
size?: ButtonSize;
|
|
12
|
+
color?: ButtonColor;
|
|
13
|
+
destructive?: boolean;
|
|
14
|
+
iconOnly?: boolean;
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
/** Content rendered before the label, usually an icon. */
|
|
17
|
+
prefix?: ReactNode;
|
|
18
|
+
/** Content rendered after the label, usually an icon. */
|
|
19
|
+
suffix?: ReactNode;
|
|
20
|
+
content?: ReactNode;
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
alignCenter?: boolean;
|
|
23
|
+
/** Compatibility alias for the initial fe-libs playground API. */
|
|
24
|
+
variant?: ButtonVariant;
|
|
25
|
+
};
|
|
26
|
+
declare const getIconSize: (size: ButtonSize) => 16 | 20;
|
|
27
|
+
declare const Button: react.ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>, "color" | "size" | "prefix"> & {
|
|
28
|
+
/** Preferred visual API ported from the Haraworks Button. */
|
|
29
|
+
hierarchy?: ButtonHierarchy;
|
|
30
|
+
size?: ButtonSize;
|
|
31
|
+
color?: ButtonColor;
|
|
32
|
+
destructive?: boolean;
|
|
33
|
+
iconOnly?: boolean;
|
|
34
|
+
icon?: ReactNode;
|
|
35
|
+
/** Content rendered before the label, usually an icon. */
|
|
36
|
+
prefix?: ReactNode;
|
|
37
|
+
/** Content rendered after the label, usually an icon. */
|
|
38
|
+
suffix?: ReactNode;
|
|
39
|
+
content?: ReactNode;
|
|
40
|
+
loading?: boolean;
|
|
41
|
+
alignCenter?: boolean;
|
|
42
|
+
/** Compatibility alias for the initial fe-libs playground API. */
|
|
43
|
+
variant?: ButtonVariant;
|
|
44
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
|
|
46
|
+
type IconProps = SVGProps<SVGSVGElement> & {
|
|
47
|
+
size?: number | string;
|
|
48
|
+
};
|
|
49
|
+
declare function PlusIcon(props: IconProps): react.JSX.Element;
|
|
50
|
+
declare function ChevronDownIcon(props: IconProps): react.JSX.Element;
|
|
51
|
+
declare function CloseIcon(props: IconProps): react.JSX.Element;
|
|
52
|
+
declare function SearchIcon(props: IconProps): react.JSX.Element;
|
|
53
|
+
|
|
54
|
+
type TableProps = TableHTMLAttributes<HTMLTableElement> & {
|
|
55
|
+
striped?: boolean;
|
|
56
|
+
};
|
|
57
|
+
declare function Table({ striped, children, ...props }: TableProps): react.JSX.Element;
|
|
58
|
+
declare function TableHead(props: HTMLAttributes<HTMLTableSectionElement>): react.JSX.Element;
|
|
59
|
+
declare function TableBody(props: HTMLAttributes<HTMLTableSectionElement>): react.JSX.Element;
|
|
60
|
+
declare function TableRow({ children, ...props }: HTMLAttributes<HTMLTableRowElement>): react.JSX.Element;
|
|
61
|
+
declare function TableCell({ children, ...props }: HTMLAttributes<HTMLTableCellElement>): react.JSX.Element;
|
|
62
|
+
declare function TableHeader({ children, ...props }: HTMLAttributes<HTMLTableCellElement>): react.JSX.Element;
|
|
63
|
+
declare function TableCaption(props: HTMLAttributes<HTMLTableCaptionElement>): react.JSX.Element;
|
|
64
|
+
|
|
65
|
+
export { Button, type ButtonColor, type ButtonHierarchy, type ButtonProps, type ButtonSize, type ButtonVariant, ChevronDownIcon, CloseIcon, type IconProps, PlusIcon, SearchIcon, Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, type TableProps, TableRow, getIconSize };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode, SVGProps, TableHTMLAttributes, HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type ButtonHierarchy = 'primary' | 'secondary-gray' | 'secondary-color' | 'tertiary-gray' | 'tertiary-color';
|
|
5
|
+
type ButtonSize = '24' | '32' | '40';
|
|
6
|
+
type ButtonColor = 'normal' | 'success' | 'error' | 'warning';
|
|
7
|
+
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
8
|
+
type ButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'size' | 'prefix'> & {
|
|
9
|
+
/** Preferred visual API ported from the Haraworks Button. */
|
|
10
|
+
hierarchy?: ButtonHierarchy;
|
|
11
|
+
size?: ButtonSize;
|
|
12
|
+
color?: ButtonColor;
|
|
13
|
+
destructive?: boolean;
|
|
14
|
+
iconOnly?: boolean;
|
|
15
|
+
icon?: ReactNode;
|
|
16
|
+
/** Content rendered before the label, usually an icon. */
|
|
17
|
+
prefix?: ReactNode;
|
|
18
|
+
/** Content rendered after the label, usually an icon. */
|
|
19
|
+
suffix?: ReactNode;
|
|
20
|
+
content?: ReactNode;
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
alignCenter?: boolean;
|
|
23
|
+
/** Compatibility alias for the initial fe-libs playground API. */
|
|
24
|
+
variant?: ButtonVariant;
|
|
25
|
+
};
|
|
26
|
+
declare const getIconSize: (size: ButtonSize) => 16 | 20;
|
|
27
|
+
declare const Button: react.ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>, "color" | "size" | "prefix"> & {
|
|
28
|
+
/** Preferred visual API ported from the Haraworks Button. */
|
|
29
|
+
hierarchy?: ButtonHierarchy;
|
|
30
|
+
size?: ButtonSize;
|
|
31
|
+
color?: ButtonColor;
|
|
32
|
+
destructive?: boolean;
|
|
33
|
+
iconOnly?: boolean;
|
|
34
|
+
icon?: ReactNode;
|
|
35
|
+
/** Content rendered before the label, usually an icon. */
|
|
36
|
+
prefix?: ReactNode;
|
|
37
|
+
/** Content rendered after the label, usually an icon. */
|
|
38
|
+
suffix?: ReactNode;
|
|
39
|
+
content?: ReactNode;
|
|
40
|
+
loading?: boolean;
|
|
41
|
+
alignCenter?: boolean;
|
|
42
|
+
/** Compatibility alias for the initial fe-libs playground API. */
|
|
43
|
+
variant?: ButtonVariant;
|
|
44
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
|
|
46
|
+
type IconProps = SVGProps<SVGSVGElement> & {
|
|
47
|
+
size?: number | string;
|
|
48
|
+
};
|
|
49
|
+
declare function PlusIcon(props: IconProps): react.JSX.Element;
|
|
50
|
+
declare function ChevronDownIcon(props: IconProps): react.JSX.Element;
|
|
51
|
+
declare function CloseIcon(props: IconProps): react.JSX.Element;
|
|
52
|
+
declare function SearchIcon(props: IconProps): react.JSX.Element;
|
|
53
|
+
|
|
54
|
+
type TableProps = TableHTMLAttributes<HTMLTableElement> & {
|
|
55
|
+
striped?: boolean;
|
|
56
|
+
};
|
|
57
|
+
declare function Table({ striped, children, ...props }: TableProps): react.JSX.Element;
|
|
58
|
+
declare function TableHead(props: HTMLAttributes<HTMLTableSectionElement>): react.JSX.Element;
|
|
59
|
+
declare function TableBody(props: HTMLAttributes<HTMLTableSectionElement>): react.JSX.Element;
|
|
60
|
+
declare function TableRow({ children, ...props }: HTMLAttributes<HTMLTableRowElement>): react.JSX.Element;
|
|
61
|
+
declare function TableCell({ children, ...props }: HTMLAttributes<HTMLTableCellElement>): react.JSX.Element;
|
|
62
|
+
declare function TableHeader({ children, ...props }: HTMLAttributes<HTMLTableCellElement>): react.JSX.Element;
|
|
63
|
+
declare function TableCaption(props: HTMLAttributes<HTMLTableCaptionElement>): react.JSX.Element;
|
|
64
|
+
|
|
65
|
+
export { Button, type ButtonColor, type ButtonHierarchy, type ButtonProps, type ButtonSize, type ButtonVariant, ChevronDownIcon, CloseIcon, type IconProps, PlusIcon, SearchIcon, Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, type TableProps, TableRow, getIconSize };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
Button: () => Button,
|
|
24
|
+
ChevronDownIcon: () => ChevronDownIcon,
|
|
25
|
+
CloseIcon: () => CloseIcon,
|
|
26
|
+
PlusIcon: () => PlusIcon,
|
|
27
|
+
SearchIcon: () => SearchIcon,
|
|
28
|
+
Table: () => Table,
|
|
29
|
+
TableBody: () => TableBody,
|
|
30
|
+
TableCaption: () => TableCaption,
|
|
31
|
+
TableCell: () => TableCell,
|
|
32
|
+
TableHead: () => TableHead,
|
|
33
|
+
TableHeader: () => TableHeader,
|
|
34
|
+
TableRow: () => TableRow,
|
|
35
|
+
getIconSize: () => getIconSize
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
|
|
39
|
+
// packages/button/src/index.tsx
|
|
40
|
+
var import_react = require("react");
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
var hierarchyFromVariant = {
|
|
43
|
+
primary: "primary",
|
|
44
|
+
secondary: "secondary-gray",
|
|
45
|
+
ghost: "tertiary-gray",
|
|
46
|
+
danger: "primary"
|
|
47
|
+
};
|
|
48
|
+
var getIconSize = (size) => size === "24" ? 16 : 20;
|
|
49
|
+
var Button = (0, import_react.forwardRef)(function Button2({
|
|
50
|
+
hierarchy,
|
|
51
|
+
variant,
|
|
52
|
+
size = "32",
|
|
53
|
+
color = "normal",
|
|
54
|
+
destructive,
|
|
55
|
+
iconOnly = false,
|
|
56
|
+
icon,
|
|
57
|
+
prefix,
|
|
58
|
+
suffix,
|
|
59
|
+
content,
|
|
60
|
+
loading = false,
|
|
61
|
+
alignCenter = false,
|
|
62
|
+
children,
|
|
63
|
+
className,
|
|
64
|
+
disabled,
|
|
65
|
+
type = "button",
|
|
66
|
+
...props
|
|
67
|
+
}, ref) {
|
|
68
|
+
const resolvedHierarchy = hierarchy ?? hierarchyFromVariant[variant ?? "primary"];
|
|
69
|
+
const resolvedDestructive = destructive || variant === "danger";
|
|
70
|
+
const isDisabled = disabled || loading;
|
|
71
|
+
const label = loading ? "Loading\u2026" : children ?? content;
|
|
72
|
+
const classes = [
|
|
73
|
+
"fe-button",
|
|
74
|
+
`fe-button--${resolvedHierarchy}`,
|
|
75
|
+
`fe-button--${size}`,
|
|
76
|
+
`fe-button--${color}`,
|
|
77
|
+
iconOnly && "fe-button--icon-only",
|
|
78
|
+
resolvedDestructive && "fe-button--destructive",
|
|
79
|
+
alignCenter && "fe-button--align-center",
|
|
80
|
+
className
|
|
81
|
+
].filter(Boolean).join(" ");
|
|
82
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref, className: classes, type, disabled: isDisabled, "aria-busy": loading || void 0, ...props, children: iconOnly ? icon : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
83
|
+
prefix && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "fe-button__icon", children: prefix }),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "fe-button__label", children: label }),
|
|
85
|
+
suffix && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "fe-button__icon", children: suffix })
|
|
86
|
+
] }) });
|
|
87
|
+
});
|
|
88
|
+
Button.displayName = "Button";
|
|
89
|
+
|
|
90
|
+
// packages/icons/src/index.tsx
|
|
91
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
92
|
+
var iconProps = ({ size, ...props }) => ({
|
|
93
|
+
width: size ?? 20,
|
|
94
|
+
height: size ?? 20,
|
|
95
|
+
fill: "none",
|
|
96
|
+
viewBox: "0 0 24 24",
|
|
97
|
+
"aria-hidden": true,
|
|
98
|
+
...props
|
|
99
|
+
});
|
|
100
|
+
function PlusIcon(props) {
|
|
101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { ...iconProps(props), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 5v14M5 12h14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) });
|
|
102
|
+
}
|
|
103
|
+
function ChevronDownIcon(props) {
|
|
104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { ...iconProps(props), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m6 9 6 6 6-6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
105
|
+
}
|
|
106
|
+
function CloseIcon(props) {
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { ...iconProps(props), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m6 6 12 12M18 6 6 18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) });
|
|
108
|
+
}
|
|
109
|
+
function SearchIcon(props) {
|
|
110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { ...iconProps(props), children: [
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "11", cy: "11", r: "6.5", stroke: "currentColor", strokeWidth: "2" }),
|
|
112
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "m16 16 4 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
|
|
113
|
+
] });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// packages/table/src/index.tsx
|
|
117
|
+
var import_react2 = require("react");
|
|
118
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
119
|
+
var TableContext = (0, import_react2.createContext)({ striped: false });
|
|
120
|
+
function Table({ striped = false, children, ...props }) {
|
|
121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TableContext.Provider, { value: { striped }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("table", { ...props, children }) });
|
|
122
|
+
}
|
|
123
|
+
function TableHead(props) {
|
|
124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { ...props });
|
|
125
|
+
}
|
|
126
|
+
function TableBody(props) {
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { ...props });
|
|
128
|
+
}
|
|
129
|
+
function TableRow({ children, ...props }) {
|
|
130
|
+
const { striped } = (0, import_react2.useContext)(TableContext);
|
|
131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tr", { "data-striped": striped || void 0, ...props, children });
|
|
132
|
+
}
|
|
133
|
+
function TableCell({ children, ...props }) {
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("td", { ...props, children });
|
|
135
|
+
}
|
|
136
|
+
function TableHeader({ children, ...props }) {
|
|
137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { scope: "col", ...props, children });
|
|
138
|
+
}
|
|
139
|
+
function TableCaption(props) {
|
|
140
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("caption", { ...props });
|
|
141
|
+
}
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
Button,
|
|
145
|
+
ChevronDownIcon,
|
|
146
|
+
CloseIcon,
|
|
147
|
+
PlusIcon,
|
|
148
|
+
SearchIcon,
|
|
149
|
+
Table,
|
|
150
|
+
TableBody,
|
|
151
|
+
TableCaption,
|
|
152
|
+
TableCell,
|
|
153
|
+
TableHead,
|
|
154
|
+
TableHeader,
|
|
155
|
+
TableRow,
|
|
156
|
+
getIconSize
|
|
157
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// packages/button/src/index.tsx
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
var hierarchyFromVariant = {
|
|
5
|
+
primary: "primary",
|
|
6
|
+
secondary: "secondary-gray",
|
|
7
|
+
ghost: "tertiary-gray",
|
|
8
|
+
danger: "primary"
|
|
9
|
+
};
|
|
10
|
+
var getIconSize = (size) => size === "24" ? 16 : 20;
|
|
11
|
+
var Button = forwardRef(function Button2({
|
|
12
|
+
hierarchy,
|
|
13
|
+
variant,
|
|
14
|
+
size = "32",
|
|
15
|
+
color = "normal",
|
|
16
|
+
destructive,
|
|
17
|
+
iconOnly = false,
|
|
18
|
+
icon,
|
|
19
|
+
prefix,
|
|
20
|
+
suffix,
|
|
21
|
+
content,
|
|
22
|
+
loading = false,
|
|
23
|
+
alignCenter = false,
|
|
24
|
+
children,
|
|
25
|
+
className,
|
|
26
|
+
disabled,
|
|
27
|
+
type = "button",
|
|
28
|
+
...props
|
|
29
|
+
}, ref) {
|
|
30
|
+
const resolvedHierarchy = hierarchy ?? hierarchyFromVariant[variant ?? "primary"];
|
|
31
|
+
const resolvedDestructive = destructive || variant === "danger";
|
|
32
|
+
const isDisabled = disabled || loading;
|
|
33
|
+
const label = loading ? "Loading\u2026" : children ?? content;
|
|
34
|
+
const classes = [
|
|
35
|
+
"fe-button",
|
|
36
|
+
`fe-button--${resolvedHierarchy}`,
|
|
37
|
+
`fe-button--${size}`,
|
|
38
|
+
`fe-button--${color}`,
|
|
39
|
+
iconOnly && "fe-button--icon-only",
|
|
40
|
+
resolvedDestructive && "fe-button--destructive",
|
|
41
|
+
alignCenter && "fe-button--align-center",
|
|
42
|
+
className
|
|
43
|
+
].filter(Boolean).join(" ");
|
|
44
|
+
return /* @__PURE__ */ jsx("button", { ref, className: classes, type, disabled: isDisabled, "aria-busy": loading || void 0, ...props, children: iconOnly ? icon : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
|
+
prefix && /* @__PURE__ */ jsx("span", { className: "fe-button__icon", children: prefix }),
|
|
46
|
+
/* @__PURE__ */ jsx("span", { className: "fe-button__label", children: label }),
|
|
47
|
+
suffix && /* @__PURE__ */ jsx("span", { className: "fe-button__icon", children: suffix })
|
|
48
|
+
] }) });
|
|
49
|
+
});
|
|
50
|
+
Button.displayName = "Button";
|
|
51
|
+
|
|
52
|
+
// packages/icons/src/index.tsx
|
|
53
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
54
|
+
var iconProps = ({ size, ...props }) => ({
|
|
55
|
+
width: size ?? 20,
|
|
56
|
+
height: size ?? 20,
|
|
57
|
+
fill: "none",
|
|
58
|
+
viewBox: "0 0 24 24",
|
|
59
|
+
"aria-hidden": true,
|
|
60
|
+
...props
|
|
61
|
+
});
|
|
62
|
+
function PlusIcon(props) {
|
|
63
|
+
return /* @__PURE__ */ jsx2("svg", { ...iconProps(props), children: /* @__PURE__ */ jsx2("path", { d: "M12 5v14M5 12h14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) });
|
|
64
|
+
}
|
|
65
|
+
function ChevronDownIcon(props) {
|
|
66
|
+
return /* @__PURE__ */ jsx2("svg", { ...iconProps(props), children: /* @__PURE__ */ jsx2("path", { d: "m6 9 6 6 6-6", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
67
|
+
}
|
|
68
|
+
function CloseIcon(props) {
|
|
69
|
+
return /* @__PURE__ */ jsx2("svg", { ...iconProps(props), children: /* @__PURE__ */ jsx2("path", { d: "m6 6 12 12M18 6 6 18", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) });
|
|
70
|
+
}
|
|
71
|
+
function SearchIcon(props) {
|
|
72
|
+
return /* @__PURE__ */ jsxs2("svg", { ...iconProps(props), children: [
|
|
73
|
+
/* @__PURE__ */ jsx2("circle", { cx: "11", cy: "11", r: "6.5", stroke: "currentColor", strokeWidth: "2" }),
|
|
74
|
+
/* @__PURE__ */ jsx2("path", { d: "m16 16 4 4", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
|
|
75
|
+
] });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// packages/table/src/index.tsx
|
|
79
|
+
import { createContext, useContext } from "react";
|
|
80
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
81
|
+
var TableContext = createContext({ striped: false });
|
|
82
|
+
function Table({ striped = false, children, ...props }) {
|
|
83
|
+
return /* @__PURE__ */ jsx3(TableContext.Provider, { value: { striped }, children: /* @__PURE__ */ jsx3("table", { ...props, children }) });
|
|
84
|
+
}
|
|
85
|
+
function TableHead(props) {
|
|
86
|
+
return /* @__PURE__ */ jsx3("thead", { ...props });
|
|
87
|
+
}
|
|
88
|
+
function TableBody(props) {
|
|
89
|
+
return /* @__PURE__ */ jsx3("tbody", { ...props });
|
|
90
|
+
}
|
|
91
|
+
function TableRow({ children, ...props }) {
|
|
92
|
+
const { striped } = useContext(TableContext);
|
|
93
|
+
return /* @__PURE__ */ jsx3("tr", { "data-striped": striped || void 0, ...props, children });
|
|
94
|
+
}
|
|
95
|
+
function TableCell({ children, ...props }) {
|
|
96
|
+
return /* @__PURE__ */ jsx3("td", { ...props, children });
|
|
97
|
+
}
|
|
98
|
+
function TableHeader({ children, ...props }) {
|
|
99
|
+
return /* @__PURE__ */ jsx3("th", { scope: "col", ...props, children });
|
|
100
|
+
}
|
|
101
|
+
function TableCaption(props) {
|
|
102
|
+
return /* @__PURE__ */ jsx3("caption", { ...props });
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
Button,
|
|
106
|
+
ChevronDownIcon,
|
|
107
|
+
CloseIcon,
|
|
108
|
+
PlusIcon,
|
|
109
|
+
SearchIcon,
|
|
110
|
+
Table,
|
|
111
|
+
TableBody,
|
|
112
|
+
TableCaption,
|
|
113
|
+
TableCell,
|
|
114
|
+
TableHead,
|
|
115
|
+
TableHeader,
|
|
116
|
+
TableRow,
|
|
117
|
+
getIconSize
|
|
118
|
+
};
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/* packages/button/src/styles.css */
|
|
2
|
+
.fe-button {
|
|
3
|
+
--fe-button-blue-10: #e7f1ff;
|
|
4
|
+
--fe-button-blue-20: #c6e0ff;
|
|
5
|
+
--fe-button-blue-30: #94c4ff;
|
|
6
|
+
--fe-button-blue-40: #5b9cff;
|
|
7
|
+
--fe-button-blue-60: #2878f0;
|
|
8
|
+
--fe-button-blue-70: #1e60cc;
|
|
9
|
+
--fe-button-blue-80: #194da3;
|
|
10
|
+
--fe-button-gray-10: #f5f6f8;
|
|
11
|
+
--fe-button-gray-20: #e8eaee;
|
|
12
|
+
--fe-button-gray-30: #d4d8e0;
|
|
13
|
+
--fe-button-gray-40: #b8bec9;
|
|
14
|
+
--fe-button-red-10: #ffeaed;
|
|
15
|
+
--fe-button-red-20: #ffc9d0;
|
|
16
|
+
--fe-button-red-30: #f3909d;
|
|
17
|
+
--fe-button-red-60: #d83d55;
|
|
18
|
+
--fe-button-red-70: #b92c43;
|
|
19
|
+
--fe-button-red-80: #94233a;
|
|
20
|
+
--fe-button-green-10: #e4f8ee;
|
|
21
|
+
--fe-button-green-20: #b9ebd0;
|
|
22
|
+
--fe-button-green-30: #7fd5a7;
|
|
23
|
+
--fe-button-green-60: #168657;
|
|
24
|
+
--fe-button-green-70: #0f6c46;
|
|
25
|
+
--fe-button-green-80: #0a5739;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
gap: 8px;
|
|
29
|
+
border: 1px solid transparent;
|
|
30
|
+
font: inherit;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
line-height: 1;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
user-select: none;
|
|
35
|
+
}
|
|
36
|
+
.fe-button--24 {
|
|
37
|
+
min-height: 24px;
|
|
38
|
+
padding: 4px 10px;
|
|
39
|
+
border-radius: 999px;
|
|
40
|
+
font-size: 12px;
|
|
41
|
+
}
|
|
42
|
+
.fe-button--32 {
|
|
43
|
+
min-height: 32px;
|
|
44
|
+
padding: 6px 14px;
|
|
45
|
+
border-radius: 18px;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
}
|
|
48
|
+
.fe-button--40 {
|
|
49
|
+
min-height: 40px;
|
|
50
|
+
padding: 10px 18px;
|
|
51
|
+
border-radius: 999px;
|
|
52
|
+
font-size: 14px;
|
|
53
|
+
}
|
|
54
|
+
.fe-button--primary,
|
|
55
|
+
.fe-button--secondary-gray,
|
|
56
|
+
.fe-button--secondary-color,
|
|
57
|
+
.fe-button--tertiary-gray,
|
|
58
|
+
.fe-button--tertiary-color {
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
}
|
|
61
|
+
.fe-button--primary {
|
|
62
|
+
min-width: 100px;
|
|
63
|
+
background: var(--fe-button-blue-60);
|
|
64
|
+
color: #fff;
|
|
65
|
+
}
|
|
66
|
+
.fe-button--primary:hover {
|
|
67
|
+
background: var(--fe-button-blue-70);
|
|
68
|
+
}
|
|
69
|
+
.fe-button--primary:active {
|
|
70
|
+
background: var(--fe-button-blue-80);
|
|
71
|
+
}
|
|
72
|
+
.fe-button--secondary-gray {
|
|
73
|
+
min-width: 100px;
|
|
74
|
+
background: #fff;
|
|
75
|
+
border-color: var(--fe-button-gray-40);
|
|
76
|
+
color: #20242c;
|
|
77
|
+
}
|
|
78
|
+
.fe-button--secondary-gray:hover {
|
|
79
|
+
background: var(--fe-button-gray-10);
|
|
80
|
+
}
|
|
81
|
+
.fe-button--secondary-gray:active {
|
|
82
|
+
background: var(--fe-button-gray-20);
|
|
83
|
+
}
|
|
84
|
+
.fe-button--secondary-color {
|
|
85
|
+
min-width: 100px;
|
|
86
|
+
background: #fff;
|
|
87
|
+
border-color: var(--fe-button-blue-20);
|
|
88
|
+
color: var(--fe-button-blue-70);
|
|
89
|
+
}
|
|
90
|
+
.fe-button--secondary-color:hover {
|
|
91
|
+
background: var(--fe-button-blue-10);
|
|
92
|
+
}
|
|
93
|
+
.fe-button--secondary-color:active {
|
|
94
|
+
background: var(--fe-button-blue-20);
|
|
95
|
+
}
|
|
96
|
+
.fe-button--tertiary-gray {
|
|
97
|
+
background: transparent;
|
|
98
|
+
color: #252a33;
|
|
99
|
+
}
|
|
100
|
+
.fe-button--tertiary-gray:hover {
|
|
101
|
+
background: var(--fe-button-gray-20);
|
|
102
|
+
}
|
|
103
|
+
.fe-button--tertiary-gray:active {
|
|
104
|
+
background: var(--fe-button-gray-30);
|
|
105
|
+
}
|
|
106
|
+
.fe-button--tertiary-color {
|
|
107
|
+
background: #fff;
|
|
108
|
+
color: var(--fe-button-blue-70);
|
|
109
|
+
}
|
|
110
|
+
.fe-button--tertiary-color:hover {
|
|
111
|
+
background: var(--fe-button-blue-10);
|
|
112
|
+
}
|
|
113
|
+
.fe-button--tertiary-color:active {
|
|
114
|
+
background: var(--fe-button-blue-20);
|
|
115
|
+
}
|
|
116
|
+
.fe-button--destructive.fe-button--primary,
|
|
117
|
+
.fe-button--error.fe-button--primary {
|
|
118
|
+
background: var(--fe-button-red-60);
|
|
119
|
+
}
|
|
120
|
+
.fe-button--destructive.fe-button--primary:hover,
|
|
121
|
+
.fe-button--error.fe-button--primary:hover {
|
|
122
|
+
background: var(--fe-button-red-70);
|
|
123
|
+
}
|
|
124
|
+
.fe-button--destructive.fe-button--primary:active,
|
|
125
|
+
.fe-button--error.fe-button--primary:active {
|
|
126
|
+
background: var(--fe-button-red-80);
|
|
127
|
+
}
|
|
128
|
+
.fe-button--destructive.fe-button--secondary-color,
|
|
129
|
+
.fe-button--error.fe-button--secondary-color {
|
|
130
|
+
border-color: var(--fe-button-red-20);
|
|
131
|
+
color: var(--fe-button-red-70);
|
|
132
|
+
}
|
|
133
|
+
.fe-button--destructive.fe-button--secondary-color:hover,
|
|
134
|
+
.fe-button--error.fe-button--secondary-color:hover {
|
|
135
|
+
background: var(--fe-button-red-10);
|
|
136
|
+
}
|
|
137
|
+
.fe-button--destructive.fe-button--tertiary-color,
|
|
138
|
+
.fe-button--error.fe-button--tertiary-color {
|
|
139
|
+
color: var(--fe-button-red-70);
|
|
140
|
+
}
|
|
141
|
+
.fe-button--destructive.fe-button--tertiary-color:hover,
|
|
142
|
+
.fe-button--error.fe-button--tertiary-color:hover {
|
|
143
|
+
background: var(--fe-button-red-10);
|
|
144
|
+
}
|
|
145
|
+
.fe-button--success.fe-button--primary {
|
|
146
|
+
background: var(--fe-button-green-60);
|
|
147
|
+
}
|
|
148
|
+
.fe-button--success.fe-button--primary:hover {
|
|
149
|
+
background: var(--fe-button-green-70);
|
|
150
|
+
}
|
|
151
|
+
.fe-button--success.fe-button--primary:active {
|
|
152
|
+
background: var(--fe-button-green-80);
|
|
153
|
+
}
|
|
154
|
+
.fe-button--success.fe-button--secondary-color {
|
|
155
|
+
border-color: var(--fe-button-green-20);
|
|
156
|
+
color: var(--fe-button-green-70);
|
|
157
|
+
}
|
|
158
|
+
.fe-button--success.fe-button--secondary-color:hover {
|
|
159
|
+
background: var(--fe-button-green-10);
|
|
160
|
+
}
|
|
161
|
+
.fe-button--success.fe-button--tertiary-color {
|
|
162
|
+
color: var(--fe-button-green-70);
|
|
163
|
+
}
|
|
164
|
+
.fe-button--success.fe-button--tertiary-color:hover {
|
|
165
|
+
background: var(--fe-button-green-10);
|
|
166
|
+
}
|
|
167
|
+
.fe-button--warning.fe-button--primary {
|
|
168
|
+
background: #cb7a00;
|
|
169
|
+
}
|
|
170
|
+
.fe-button--warning.fe-button--primary:hover {
|
|
171
|
+
background: #a36200;
|
|
172
|
+
}
|
|
173
|
+
.fe-button--warning.fe-button--secondary-color {
|
|
174
|
+
border-color: #ffd493;
|
|
175
|
+
color: #a36200;
|
|
176
|
+
}
|
|
177
|
+
.fe-button--warning.fe-button--secondary-color:hover,
|
|
178
|
+
.fe-button--warning.fe-button--tertiary-color:hover {
|
|
179
|
+
background: #fff3dd;
|
|
180
|
+
}
|
|
181
|
+
.fe-button--warning.fe-button--tertiary-color {
|
|
182
|
+
color: #a36200;
|
|
183
|
+
}
|
|
184
|
+
.fe-button--icon-only {
|
|
185
|
+
width: 24px;
|
|
186
|
+
min-width: 0;
|
|
187
|
+
padding: 4px;
|
|
188
|
+
}
|
|
189
|
+
.fe-button--icon-only.fe-button--32 {
|
|
190
|
+
width: 32px;
|
|
191
|
+
padding: 6px;
|
|
192
|
+
}
|
|
193
|
+
.fe-button--icon-only.fe-button--40 {
|
|
194
|
+
width: 40px;
|
|
195
|
+
padding: 10px;
|
|
196
|
+
}
|
|
197
|
+
.fe-button--align-center {
|
|
198
|
+
width: 100%;
|
|
199
|
+
}
|
|
200
|
+
.fe-button__icon {
|
|
201
|
+
display: inline-flex;
|
|
202
|
+
}
|
|
203
|
+
.fe-button__label {
|
|
204
|
+
white-space: nowrap;
|
|
205
|
+
}
|
|
206
|
+
.fe-button:disabled {
|
|
207
|
+
cursor: not-allowed;
|
|
208
|
+
opacity: .52;
|
|
209
|
+
}
|
|
210
|
+
.fe-button:focus-visible {
|
|
211
|
+
outline: 3px solid color-mix(in srgb, var(--fe-button-blue-40), transparent 55%);
|
|
212
|
+
outline-offset: 2px;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* src/styles.css */
|
package/dist/styles.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dragunio/fe-libs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Reusable React components, icons, and table primitives.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": { "type": "git", "url": "git+https://github.com/kdragon113/fe-libs.git" },
|
|
7
|
+
"homepage": "https://github.com/kdragon113/fe-libs#readme",
|
|
8
|
+
"bugs": { "url": "https://github.com/kdragon113/fe-libs/issues" },
|
|
9
|
+
"sideEffects": ["*.css"],
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"module": "./dist/index.mjs",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.mjs", "require": "./dist/index.js" },
|
|
15
|
+
"./styles.css": "./dist/styles.css"
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
18
|
+
"publishConfig": { "access": "public" },
|
|
19
|
+
"packageManager": "pnpm@9.15.0",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup src/index.ts src/styles.css --format esm,cjs --dts --clean",
|
|
22
|
+
"build:playground": "pnpm --filter @dragunio/playground build",
|
|
23
|
+
"clean": "rm -rf dist",
|
|
24
|
+
"dev": "pnpm --filter @dragunio/playground dev",
|
|
25
|
+
"typecheck": "tsc -p tsconfig.json && pnpm --filter @dragunio/playground typecheck",
|
|
26
|
+
"format": "prettier --write .",
|
|
27
|
+
"pack:check": "node scripts/verify-packages.mjs",
|
|
28
|
+
"release:check": "pnpm typecheck && pnpm build && pnpm build:playground && pnpm pack:check",
|
|
29
|
+
"release": "pnpm release:check && npm publish --access public",
|
|
30
|
+
"release:dry-run": "pnpm release:check && npm publish --dry-run --access public"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": { "react": ">=18", "react-dom": ">=18" },
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^22.10.2",
|
|
35
|
+
"@types/react": "^18.3.12",
|
|
36
|
+
"@types/react-dom": "^18.3.1",
|
|
37
|
+
"prettier": "^3.4.2",
|
|
38
|
+
"react": "^18.3.1",
|
|
39
|
+
"react-dom": "^18.3.1",
|
|
40
|
+
"tsup": "^8.3.5",
|
|
41
|
+
"typescript": "^5.7.2"
|
|
42
|
+
}
|
|
43
|
+
}
|