@optigrit/optigrit-ui 0.0.1 → 0.0.2
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 +66 -0
- package/dist/{chunk-2LJSVQ6B.js → chunk-EUAKUHDG.js} +109 -16
- package/dist/components/index.d.ts +94 -2
- package/dist/components/index.js +499 -102
- package/dist/core/index.d.ts +55 -1
- package/dist/core/index.js +7 -3
- package/index.css +165 -125
- package/package.json +3 -3
- package/tailwind.preset.js +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @optigrit/optigrit-ui
|
|
2
|
+
|
|
3
|
+
UI component library for Optigrit apps (React + Tailwind CSS).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @optigrit/optigrit-ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies (install in your app):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install react react-dom tailwindcss
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Import components from the package root or subpaths:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { /* components */ } from "@optigrit/optigrit-ui";
|
|
23
|
+
import { /* theme helpers */ } from "@optigrit/optigrit-ui/theme";
|
|
24
|
+
import { /* hooks */ } from "@optigrit/optigrit-ui/hooks";
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Tailwind preset:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
// tailwind.config.js
|
|
31
|
+
import preset from "@optigrit/optigrit-ui/preset";
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
presets: [preset],
|
|
35
|
+
content: [
|
|
36
|
+
"./node_modules/@optigrit/optigrit-ui/**/*.{js,jsx,ts,tsx}",
|
|
37
|
+
"./src/**/*.{js,jsx,ts,tsx}",
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Base styles (optional): copy or import `index.css` from the package as needed.
|
|
43
|
+
|
|
44
|
+
## CLI (`init`)
|
|
45
|
+
|
|
46
|
+
After installing the package:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx optigrit-ui init
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
(or `npx @optigrit/optigrit-ui init`)
|
|
53
|
+
|
|
54
|
+
This wires Tailwind to use the preset and copies starter CSS when possible.
|
|
55
|
+
|
|
56
|
+
## Scripts (development)
|
|
57
|
+
|
|
58
|
+
| Script | Description |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `npm run build` | Production bundle (`tsup` → `dist/`) |
|
|
61
|
+
| `npm run lint` | Typecheck (`tsc`) |
|
|
62
|
+
| `npm run storybook` | Storybook dev server |
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
ISC
|
|
@@ -266,8 +266,98 @@ var Input = forwardRef((props, ref) => {
|
|
|
266
266
|
);
|
|
267
267
|
});
|
|
268
268
|
|
|
269
|
+
// src/core/Ripple/index.tsx
|
|
270
|
+
import { forwardRef as forwardRef2, useImperativeHandle, useCallback, useRef as useRef3 } from "react";
|
|
271
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
272
|
+
var Ripple = forwardRef2(
|
|
273
|
+
({ color = "rgba(255, 255, 255, 0.3)", duration = 600 }, ref) => {
|
|
274
|
+
const containerRef = useRef3(null);
|
|
275
|
+
const addRipple = useCallback(
|
|
276
|
+
(event) => {
|
|
277
|
+
const container = containerRef.current;
|
|
278
|
+
if (!container) return;
|
|
279
|
+
const rect = container.getBoundingClientRect();
|
|
280
|
+
const diameter = Math.max(rect.width, rect.height);
|
|
281
|
+
const radius = diameter / 2;
|
|
282
|
+
const circle = document.createElement("span");
|
|
283
|
+
circle.style.position = "absolute";
|
|
284
|
+
circle.style.width = `${diameter}px`;
|
|
285
|
+
circle.style.height = `${diameter}px`;
|
|
286
|
+
circle.style.left = `${event.clientX - rect.left - radius}px`;
|
|
287
|
+
circle.style.top = `${event.clientY - rect.top - radius}px`;
|
|
288
|
+
circle.style.borderRadius = "9999px";
|
|
289
|
+
circle.style.pointerEvents = "none";
|
|
290
|
+
circle.style.backgroundColor = color;
|
|
291
|
+
container.appendChild(circle);
|
|
292
|
+
const anim = circle.animate(
|
|
293
|
+
[
|
|
294
|
+
{ transform: "scale(0)", opacity: "1" },
|
|
295
|
+
{ transform: "scale(4)", opacity: "0" }
|
|
296
|
+
],
|
|
297
|
+
{ duration, easing: "linear" }
|
|
298
|
+
);
|
|
299
|
+
anim.onfinish = () => circle.remove();
|
|
300
|
+
},
|
|
301
|
+
[color, duration]
|
|
302
|
+
);
|
|
303
|
+
useImperativeHandle(ref, () => ({
|
|
304
|
+
addRipple
|
|
305
|
+
}));
|
|
306
|
+
return /* @__PURE__ */ jsx3(
|
|
307
|
+
"span",
|
|
308
|
+
{
|
|
309
|
+
ref: containerRef,
|
|
310
|
+
className: "absolute inset-0 overflow-hidden pointer-events-none",
|
|
311
|
+
"aria-hidden": "true"
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
Ripple.displayName = "Ripple";
|
|
317
|
+
|
|
318
|
+
// src/core/Spinner/index.tsx
|
|
319
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
320
|
+
var colorClasses = {
|
|
321
|
+
primary: "text-primary",
|
|
322
|
+
secondary: "text-secondary",
|
|
323
|
+
error: "text-error",
|
|
324
|
+
info: "text-info",
|
|
325
|
+
success: "text-success",
|
|
326
|
+
warning: "text-warning",
|
|
327
|
+
inherit: "text-inherit"
|
|
328
|
+
};
|
|
329
|
+
function Spinner({
|
|
330
|
+
size = 40,
|
|
331
|
+
thickness = 3.6,
|
|
332
|
+
color = "primary",
|
|
333
|
+
className = ""
|
|
334
|
+
}) {
|
|
335
|
+
const sizeStyle = typeof size === "number" ? `${size}px` : size;
|
|
336
|
+
return /* @__PURE__ */ jsx4(
|
|
337
|
+
"div",
|
|
338
|
+
{
|
|
339
|
+
role: "progressbar",
|
|
340
|
+
className: `inline-block animate-circular-rotate ${colorClasses[color]} ${className}`,
|
|
341
|
+
style: { width: sizeStyle, height: sizeStyle },
|
|
342
|
+
children: /* @__PURE__ */ jsx4("svg", { viewBox: "22 22 44 44", className: "block w-full h-full", children: /* @__PURE__ */ jsx4(
|
|
343
|
+
"circle",
|
|
344
|
+
{
|
|
345
|
+
className: "animate-circular-dash",
|
|
346
|
+
cx: "44",
|
|
347
|
+
cy: "44",
|
|
348
|
+
r: 20,
|
|
349
|
+
fill: "none",
|
|
350
|
+
stroke: "currentColor",
|
|
351
|
+
strokeWidth: thickness,
|
|
352
|
+
strokeLinecap: "round"
|
|
353
|
+
}
|
|
354
|
+
) })
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
269
359
|
// src/core/ShowWithAnimation/index.tsx
|
|
270
|
-
import { useLayoutEffect as useLayoutEffect3, useRef as
|
|
360
|
+
import { useLayoutEffect as useLayoutEffect3, useRef as useRef4, useState as useState2 } from "react";
|
|
271
361
|
|
|
272
362
|
// src/core/ShowWithAnimation/const.ts
|
|
273
363
|
var defaultAnimationStyle = {
|
|
@@ -304,7 +394,7 @@ var defaultAnimationStyle = {
|
|
|
304
394
|
};
|
|
305
395
|
|
|
306
396
|
// src/core/ShowWithAnimation/index.tsx
|
|
307
|
-
import { jsx as
|
|
397
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
308
398
|
function ShowWithAnimation(props) {
|
|
309
399
|
const {
|
|
310
400
|
when,
|
|
@@ -312,11 +402,12 @@ function ShowWithAnimation(props) {
|
|
|
312
402
|
containerProps,
|
|
313
403
|
animationStyle,
|
|
314
404
|
otherwise = null,
|
|
315
|
-
removeOnHide = false,
|
|
405
|
+
removeOnHide: _removeOnHide = false,
|
|
316
406
|
animationType = "fade",
|
|
317
407
|
animationDuration = 300,
|
|
318
408
|
...wrapperProps
|
|
319
409
|
} = props;
|
|
410
|
+
const removeOnHide = _removeOnHide === void 0 || _removeOnHide;
|
|
320
411
|
if (animationStyle) {
|
|
321
412
|
if (!animationStyle.children.to) {
|
|
322
413
|
animationStyle.children.to = animationStyle.children.from;
|
|
@@ -329,20 +420,21 @@ function ShowWithAnimation(props) {
|
|
|
329
420
|
}
|
|
330
421
|
}
|
|
331
422
|
const defaultAnimationStyle2 = (() => {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
423
|
+
if (animationStyle) return animationStyle;
|
|
424
|
+
const defaultAnimationStyle3 = defaultAnimationStyle[animationType];
|
|
425
|
+
if (!defaultAnimationStyle3.children.to) {
|
|
426
|
+
defaultAnimationStyle3.children.to = defaultAnimationStyle3.children.from;
|
|
335
427
|
}
|
|
336
|
-
if (!
|
|
337
|
-
|
|
428
|
+
if (!defaultAnimationStyle3.otherwise) {
|
|
429
|
+
defaultAnimationStyle3.otherwise = defaultAnimationStyle3.children;
|
|
338
430
|
}
|
|
339
|
-
if (!
|
|
340
|
-
|
|
431
|
+
if (!defaultAnimationStyle3.otherwise.to) {
|
|
432
|
+
defaultAnimationStyle3.otherwise.to = defaultAnimationStyle3.otherwise.from;
|
|
341
433
|
}
|
|
342
|
-
return
|
|
434
|
+
return defaultAnimationStyle3;
|
|
343
435
|
})();
|
|
344
|
-
const childrenContainer =
|
|
345
|
-
const otherwiseContainer =
|
|
436
|
+
const childrenContainer = useRef4(null);
|
|
437
|
+
const otherwiseContainer = useRef4(null);
|
|
346
438
|
const [isChildrenVisible, setIsChildrenVisible] = useState2(when);
|
|
347
439
|
const [isOtherwiseVisible, setIsOtherwiseVisible] = useState2(!when);
|
|
348
440
|
function handleShow() {
|
|
@@ -413,9 +505,8 @@ function ShowWithAnimation(props) {
|
|
|
413
505
|
{
|
|
414
506
|
...containerProps,
|
|
415
507
|
className: cn("relative flex items-center justify-center", containerProps?.className),
|
|
416
|
-
style: { ...containerProps?.style, position: "relative" },
|
|
417
508
|
children: [
|
|
418
|
-
isChildrenVisible ? /* @__PURE__ */
|
|
509
|
+
isChildrenVisible ? /* @__PURE__ */ jsx5(
|
|
419
510
|
"div",
|
|
420
511
|
{
|
|
421
512
|
...wrapperProps,
|
|
@@ -430,7 +521,7 @@ function ShowWithAnimation(props) {
|
|
|
430
521
|
children
|
|
431
522
|
}
|
|
432
523
|
) : null,
|
|
433
|
-
otherwise && isOtherwiseVisible ? /* @__PURE__ */
|
|
524
|
+
otherwise && isOtherwiseVisible ? /* @__PURE__ */ jsx5(
|
|
434
525
|
"div",
|
|
435
526
|
{
|
|
436
527
|
...wrapperProps,
|
|
@@ -460,6 +551,8 @@ export {
|
|
|
460
551
|
Popover,
|
|
461
552
|
cn,
|
|
462
553
|
Input,
|
|
554
|
+
Ripple,
|
|
555
|
+
Spinner,
|
|
463
556
|
ShowWithAnimation,
|
|
464
557
|
Show
|
|
465
558
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ButtonHTMLAttributes, ReactNode, HTMLAttributes, RefObject } from 'react';
|
|
2
|
+
import react__default, { ButtonHTMLAttributes, ReactNode, HTMLAttributes, RefObject, TableHTMLAttributes } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { P as PopoverProps, a as InputProps } from '../Input-CL3wQvR_.js';
|
|
5
5
|
|
|
@@ -66,4 +66,96 @@ type MultiSelectProps = {
|
|
|
66
66
|
} & Omit<InputFieldProps, 'readOnly' | 'value' | 'onChange' | 'onChangeValue'>;
|
|
67
67
|
declare function MultiSelect(props: MultiSelectProps): react_jsx_runtime.JSX.Element;
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
interface TableProps extends TableHTMLAttributes<HTMLTableElement> {
|
|
70
|
+
stickyHeader?: boolean;
|
|
71
|
+
size?: "small" | "medium";
|
|
72
|
+
}
|
|
73
|
+
declare const Table: react.ForwardRefExoticComponent<TableProps & react.RefAttributes<HTMLTableElement>>;
|
|
74
|
+
|
|
75
|
+
interface TableBodyProps extends HTMLAttributes<HTMLTableSectionElement> {
|
|
76
|
+
}
|
|
77
|
+
declare const TableBody: react.ForwardRefExoticComponent<TableBodyProps & react.RefAttributes<HTMLTableSectionElement>>;
|
|
78
|
+
|
|
79
|
+
interface TableCellProps extends HTMLAttributes<HTMLTableCellElement> {
|
|
80
|
+
align?: "left" | "center" | "right" | "justify" | "inherit";
|
|
81
|
+
padding?: "normal" | "none" | "checkbox";
|
|
82
|
+
variant?: "head" | "body" | "footer";
|
|
83
|
+
component?: "td" | "th";
|
|
84
|
+
}
|
|
85
|
+
declare const TableCell: react.ForwardRefExoticComponent<TableCellProps & react.RefAttributes<HTMLTableCellElement>>;
|
|
86
|
+
|
|
87
|
+
interface TableContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
88
|
+
}
|
|
89
|
+
declare const TableContainer: react.ForwardRefExoticComponent<TableContainerProps & react.RefAttributes<HTMLDivElement>>;
|
|
90
|
+
|
|
91
|
+
interface TableFooterProps extends HTMLAttributes<HTMLTableSectionElement> {
|
|
92
|
+
}
|
|
93
|
+
declare const TableFooter: react.ForwardRefExoticComponent<TableFooterProps & react.RefAttributes<HTMLTableSectionElement>>;
|
|
94
|
+
|
|
95
|
+
interface TableHeadProps extends HTMLAttributes<HTMLTableSectionElement> {
|
|
96
|
+
}
|
|
97
|
+
declare const TableHead: react.ForwardRefExoticComponent<TableHeadProps & react.RefAttributes<HTMLTableSectionElement>>;
|
|
98
|
+
|
|
99
|
+
interface TableRowProps extends HTMLAttributes<HTMLTableRowElement> {
|
|
100
|
+
hover?: boolean;
|
|
101
|
+
selected?: boolean;
|
|
102
|
+
}
|
|
103
|
+
declare const TableRow: react.ForwardRefExoticComponent<TableRowProps & react.RefAttributes<HTMLTableRowElement>>;
|
|
104
|
+
|
|
105
|
+
type DialogProps = {
|
|
106
|
+
open: boolean;
|
|
107
|
+
onClose?: () => void;
|
|
108
|
+
children?: react__default.ReactNode;
|
|
109
|
+
backdropClose?: boolean;
|
|
110
|
+
className?: string;
|
|
111
|
+
closeOnEsc?: boolean;
|
|
112
|
+
animationDuration?: number;
|
|
113
|
+
size?: SIZE | "full" | "auto";
|
|
114
|
+
};
|
|
115
|
+
declare function Dialog(props: DialogProps): react__default.ReactPortal | null;
|
|
116
|
+
|
|
117
|
+
type DialogHeaderProps = HTMLAttributes<HTMLDivElement> & {
|
|
118
|
+
title?: string;
|
|
119
|
+
};
|
|
120
|
+
declare function DialogHeader(props: DialogHeaderProps): react_jsx_runtime.JSX.Element;
|
|
121
|
+
|
|
122
|
+
declare function DialogFooter(props: HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
123
|
+
|
|
124
|
+
declare function DialogContent(props: HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
125
|
+
|
|
126
|
+
type DrawerProps = {
|
|
127
|
+
open: boolean;
|
|
128
|
+
onClose?: () => void;
|
|
129
|
+
children?: react__default.ReactNode;
|
|
130
|
+
backdropClose?: boolean;
|
|
131
|
+
className?: string;
|
|
132
|
+
closeOnEsc?: boolean;
|
|
133
|
+
animationDuration?: number;
|
|
134
|
+
side?: 'right' | 'left' | 'top' | 'bottom';
|
|
135
|
+
size?: SIZE | number;
|
|
136
|
+
rounded?: number;
|
|
137
|
+
};
|
|
138
|
+
declare function Drawer(props: DrawerProps): react__default.ReactPortal | null;
|
|
139
|
+
|
|
140
|
+
type DrawerContentProps = {
|
|
141
|
+
children?: react__default.ReactNode;
|
|
142
|
+
className?: string;
|
|
143
|
+
style?: react__default.CSSProperties;
|
|
144
|
+
};
|
|
145
|
+
declare function DrawerContent({ children, className, style }: DrawerContentProps): react_jsx_runtime.JSX.Element;
|
|
146
|
+
|
|
147
|
+
type DrawerHeaderProps = {
|
|
148
|
+
children?: react__default.ReactNode;
|
|
149
|
+
className?: string;
|
|
150
|
+
style?: react__default.CSSProperties;
|
|
151
|
+
};
|
|
152
|
+
declare function DrawerHeader({ children, className, style }: DrawerHeaderProps): react_jsx_runtime.JSX.Element;
|
|
153
|
+
|
|
154
|
+
type DrawerFooterProps = {
|
|
155
|
+
children?: react__default.ReactNode;
|
|
156
|
+
className?: string;
|
|
157
|
+
style?: react__default.CSSProperties;
|
|
158
|
+
};
|
|
159
|
+
declare function DrawerFooter({ children, className, style }: DrawerFooterProps): react_jsx_runtime.JSX.Element;
|
|
160
|
+
|
|
161
|
+
export { Button, type ButtonProps, type ButtonRoundness, type ButtonSize, type ButtonVariant, Dialog, DialogContent, DialogFooter, DialogHeader, type DialogProps, Drawer, DrawerContent, DrawerFooter, DrawerHeader, type DrawerProps, InputField, type InputFieldProps, MultiSelect, type MultiSelectProps, Select, type SelectProps, Table, TableBody, type TableBodyProps, TableCell, type TableCellProps, TableContainer, type TableContainerProps, TableFooter, type TableFooterProps, TableHead, type TableHeadProps, type TableProps, TableRow, type TableRowProps, Tooltip, type TooltipProps };
|