design-zystem 1.0.241 → 1.0.243
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/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +65 -43
- package/dist/index.mjs +71 -44
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { HTMLAttributes, ReactNode, CSSProperties, MouseEventHandler, MouseEvent, ChangeEvent, FocusEvent, KeyboardEvent, ImgHTMLAttributes } from 'react';
|
|
3
|
+
import { HTMLAttributes, ReactNode, CSSProperties, MouseEventHandler, MouseEvent, ChangeEvent, FocusEvent, KeyboardEvent, ImgHTMLAttributes, RefObject } from 'react';
|
|
4
4
|
|
|
5
5
|
interface PageContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
justifyContent?: string;
|
|
@@ -64,6 +64,7 @@ interface RowProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
64
64
|
fullHeight?: boolean;
|
|
65
65
|
width?: string;
|
|
66
66
|
wrap?: string;
|
|
67
|
+
backgroundColor?: string;
|
|
67
68
|
style?: CSSProperties;
|
|
68
69
|
className?: string;
|
|
69
70
|
}
|
|
@@ -805,8 +806,10 @@ interface PopoverItem {
|
|
|
805
806
|
interface PopoverProps {
|
|
806
807
|
items?: PopoverItem[];
|
|
807
808
|
children?: ReactNode;
|
|
809
|
+
anchorRef?: RefObject<HTMLElement>;
|
|
810
|
+
offsetY?: number;
|
|
808
811
|
}
|
|
809
|
-
declare const Popover: ({ items, children }: PopoverProps) => react_jsx_runtime.JSX.Element;
|
|
812
|
+
declare const Popover: ({ items, children, anchorRef, offsetY, }: PopoverProps) => react_jsx_runtime.JSX.Element;
|
|
810
813
|
|
|
811
814
|
interface MetricCardProps {
|
|
812
815
|
icon: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { HTMLAttributes, ReactNode, CSSProperties, MouseEventHandler, MouseEvent, ChangeEvent, FocusEvent, KeyboardEvent, ImgHTMLAttributes } from 'react';
|
|
3
|
+
import { HTMLAttributes, ReactNode, CSSProperties, MouseEventHandler, MouseEvent, ChangeEvent, FocusEvent, KeyboardEvent, ImgHTMLAttributes, RefObject } from 'react';
|
|
4
4
|
|
|
5
5
|
interface PageContainerProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
6
|
justifyContent?: string;
|
|
@@ -64,6 +64,7 @@ interface RowProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
64
64
|
fullHeight?: boolean;
|
|
65
65
|
width?: string;
|
|
66
66
|
wrap?: string;
|
|
67
|
+
backgroundColor?: string;
|
|
67
68
|
style?: CSSProperties;
|
|
68
69
|
className?: string;
|
|
69
70
|
}
|
|
@@ -805,8 +806,10 @@ interface PopoverItem {
|
|
|
805
806
|
interface PopoverProps {
|
|
806
807
|
items?: PopoverItem[];
|
|
807
808
|
children?: ReactNode;
|
|
809
|
+
anchorRef?: RefObject<HTMLElement>;
|
|
810
|
+
offsetY?: number;
|
|
808
811
|
}
|
|
809
|
-
declare const Popover: ({ items, children }: PopoverProps) => react_jsx_runtime.JSX.Element;
|
|
812
|
+
declare const Popover: ({ items, children, anchorRef, offsetY, }: PopoverProps) => react_jsx_runtime.JSX.Element;
|
|
810
813
|
|
|
811
814
|
interface MetricCardProps {
|
|
812
815
|
icon: string;
|
package/dist/index.js
CHANGED
|
@@ -411,15 +411,18 @@ var shouldForwardPropRow = (prop) => ![
|
|
|
411
411
|
"fullWidth",
|
|
412
412
|
"fullwidth",
|
|
413
413
|
"margin",
|
|
414
|
-
"width"
|
|
414
|
+
"width",
|
|
415
|
+
"wrap",
|
|
416
|
+
"backgroundColor"
|
|
415
417
|
].includes(prop);
|
|
416
418
|
var StyledRow = import_styled_components4.default.div.withConfig({
|
|
417
419
|
shouldForwardProp: shouldForwardPropRow
|
|
418
420
|
})`
|
|
419
421
|
display: flex;
|
|
420
|
-
flex-wrap: nowrap;
|
|
422
|
+
flex-wrap: ${(props) => props.wrap || "nowrap"};
|
|
421
423
|
width: ${(props) => props.width || "100%"};
|
|
422
424
|
max-height: 100%;
|
|
425
|
+
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
423
426
|
margin: ${(props) => props.margin || "0"};
|
|
424
427
|
height: ${(props) => props.fullHeight ? `100%` : "auto"};
|
|
425
428
|
gap: ${(props) => props.gap ? `${props.gap}px` : "0"};
|
|
@@ -4507,31 +4510,49 @@ var PopoverItem = import_styled_components41.default.div`
|
|
|
4507
4510
|
background: #f5f5f5;
|
|
4508
4511
|
}
|
|
4509
4512
|
`;
|
|
4510
|
-
var Popover = ({
|
|
4513
|
+
var Popover = ({
|
|
4514
|
+
items = [],
|
|
4515
|
+
children,
|
|
4516
|
+
anchorRef,
|
|
4517
|
+
offsetY = 8
|
|
4518
|
+
}) => {
|
|
4511
4519
|
const [open, setOpen] = (0, import_react24.useState)(false);
|
|
4512
4520
|
const ref = (0, import_react24.useRef)(null);
|
|
4513
4521
|
const menuRef = (0, import_react24.useRef)(null);
|
|
4514
|
-
const [menuPosition, setMenuPosition] = (0, import_react24.useState)({
|
|
4522
|
+
const [menuPosition, setMenuPosition] = (0, import_react24.useState)({
|
|
4523
|
+
mode: "default",
|
|
4524
|
+
top: 0,
|
|
4525
|
+
left: 0
|
|
4526
|
+
});
|
|
4515
4527
|
const updatePosition = (0, import_react24.useCallback)(() => {
|
|
4516
4528
|
var _a;
|
|
4517
|
-
if (!ref.current)
|
|
4518
|
-
|
|
4529
|
+
if (!ref.current) return;
|
|
4530
|
+
if (anchorRef == null ? void 0 : anchorRef.current) {
|
|
4531
|
+
const anchorRect = anchorRef.current.getBoundingClientRect();
|
|
4532
|
+
setMenuPosition({
|
|
4533
|
+
mode: "anchor",
|
|
4534
|
+
bottom: window.innerHeight - anchorRect.top + offsetY,
|
|
4535
|
+
left: anchorRect.left,
|
|
4536
|
+
width: anchorRect.width
|
|
4537
|
+
});
|
|
4538
|
+
} else {
|
|
4539
|
+
const rect = ref.current.getBoundingClientRect();
|
|
4540
|
+
const estimatedMenuHeight = items.length * 42 + 8;
|
|
4541
|
+
const menuHeight = ((_a = menuRef.current) == null ? void 0 : _a.getBoundingClientRect().height) ? menuRef.current.getBoundingClientRect().height : estimatedMenuHeight;
|
|
4542
|
+
const viewportPadding = 8;
|
|
4543
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
4544
|
+
const shouldOpenAbove = spaceBelow < menuHeight + 6;
|
|
4545
|
+
const top = shouldOpenAbove ? rect.top - menuHeight - 6 : rect.bottom + 6;
|
|
4546
|
+
setMenuPosition({
|
|
4547
|
+
mode: "default",
|
|
4548
|
+
top: Math.max(
|
|
4549
|
+
viewportPadding,
|
|
4550
|
+
Math.min(top, window.innerHeight - menuHeight - viewportPadding)
|
|
4551
|
+
),
|
|
4552
|
+
left: rect.right
|
|
4553
|
+
});
|
|
4519
4554
|
}
|
|
4520
|
-
|
|
4521
|
-
const estimatedMenuHeight = items.length * 42 + 8;
|
|
4522
|
-
const menuHeight = ((_a = menuRef.current) == null ? void 0 : _a.getBoundingClientRect().height) ? menuRef.current.getBoundingClientRect().height : estimatedMenuHeight;
|
|
4523
|
-
const viewportPadding = 8;
|
|
4524
|
-
const spaceBelow = window.innerHeight - rect.bottom;
|
|
4525
|
-
const shouldOpenAbove = spaceBelow < menuHeight + 6;
|
|
4526
|
-
const top = shouldOpenAbove ? rect.top - menuHeight - 6 : rect.bottom + 6;
|
|
4527
|
-
setMenuPosition({
|
|
4528
|
-
top: Math.max(
|
|
4529
|
-
viewportPadding,
|
|
4530
|
-
Math.min(top, window.innerHeight - menuHeight - viewportPadding)
|
|
4531
|
-
),
|
|
4532
|
-
left: rect.right
|
|
4533
|
-
});
|
|
4534
|
-
}, [items.length]);
|
|
4555
|
+
}, [items.length, anchorRef, offsetY]);
|
|
4535
4556
|
(0, import_react24.useEffect)(() => {
|
|
4536
4557
|
const handleClickOutside = (event) => {
|
|
4537
4558
|
var _a, _b;
|
|
@@ -4553,33 +4574,34 @@ var Popover = ({ items = [], children }) => {
|
|
|
4553
4574
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
4554
4575
|
};
|
|
4555
4576
|
}, [open, updatePosition]);
|
|
4577
|
+
const menuStyle = menuPosition.mode === "anchor" ? {
|
|
4578
|
+
top: "auto",
|
|
4579
|
+
bottom: menuPosition.bottom,
|
|
4580
|
+
left: menuPosition.left,
|
|
4581
|
+
width: menuPosition.width,
|
|
4582
|
+
transform: "none"
|
|
4583
|
+
} : {
|
|
4584
|
+
top: menuPosition.top,
|
|
4585
|
+
bottom: "auto",
|
|
4586
|
+
left: menuPosition.left,
|
|
4587
|
+
transform: "translateX(-100%)"
|
|
4588
|
+
};
|
|
4556
4589
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(PopoverWrapper, { ref, children: [
|
|
4557
4590
|
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(PopoverTrigger, { onClick: () => setOpen((o) => !o), children }),
|
|
4558
4591
|
open && (0, import_react_dom2.createPortal)(
|
|
4559
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4560
|
-
|
|
4592
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(PopoverMenu, { ref: menuRef, style: menuStyle, children: items.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4593
|
+
PopoverItem,
|
|
4561
4594
|
{
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
transform: "translateX(-100%)"
|
|
4595
|
+
isLast: idx === items.length - 1,
|
|
4596
|
+
onClick: () => {
|
|
4597
|
+
setOpen(false);
|
|
4598
|
+
item.action();
|
|
4567
4599
|
},
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
setOpen(false);
|
|
4574
|
-
item.action();
|
|
4575
|
-
},
|
|
4576
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
4577
|
-
children: item.label
|
|
4578
|
-
},
|
|
4579
|
-
typeof item.label === "string" ? item.label : idx
|
|
4580
|
-
))
|
|
4581
|
-
}
|
|
4582
|
-
),
|
|
4600
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4601
|
+
children: item.label
|
|
4602
|
+
},
|
|
4603
|
+
typeof item.label === "string" ? item.label : idx
|
|
4604
|
+
)) }),
|
|
4583
4605
|
document.body
|
|
4584
4606
|
)
|
|
4585
4607
|
] });
|
package/dist/index.mjs
CHANGED
|
@@ -317,15 +317,18 @@ var shouldForwardPropRow = (prop) => ![
|
|
|
317
317
|
"fullWidth",
|
|
318
318
|
"fullwidth",
|
|
319
319
|
"margin",
|
|
320
|
-
"width"
|
|
320
|
+
"width",
|
|
321
|
+
"wrap",
|
|
322
|
+
"backgroundColor"
|
|
321
323
|
].includes(prop);
|
|
322
324
|
var StyledRow = styled4.div.withConfig({
|
|
323
325
|
shouldForwardProp: shouldForwardPropRow
|
|
324
326
|
})`
|
|
325
327
|
display: flex;
|
|
326
|
-
flex-wrap: nowrap;
|
|
328
|
+
flex-wrap: ${(props) => props.wrap || "nowrap"};
|
|
327
329
|
width: ${(props) => props.width || "100%"};
|
|
328
330
|
max-height: 100%;
|
|
331
|
+
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
329
332
|
margin: ${(props) => props.margin || "0"};
|
|
330
333
|
height: ${(props) => props.fullHeight ? `100%` : "auto"};
|
|
331
334
|
gap: ${(props) => props.gap ? `${props.gap}px` : "0"};
|
|
@@ -4393,7 +4396,12 @@ var IconTabs = ({
|
|
|
4393
4396
|
};
|
|
4394
4397
|
|
|
4395
4398
|
// src/Components/Popover/Popover.tsx
|
|
4396
|
-
import {
|
|
4399
|
+
import {
|
|
4400
|
+
useState as useState15,
|
|
4401
|
+
useRef as useRef12,
|
|
4402
|
+
useEffect as useEffect13,
|
|
4403
|
+
useCallback as useCallback4
|
|
4404
|
+
} from "react";
|
|
4397
4405
|
import { createPortal } from "react-dom";
|
|
4398
4406
|
import styled41 from "styled-components";
|
|
4399
4407
|
import { jsx as jsx49, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
@@ -4428,31 +4436,49 @@ var PopoverItem = styled41.div`
|
|
|
4428
4436
|
background: #f5f5f5;
|
|
4429
4437
|
}
|
|
4430
4438
|
`;
|
|
4431
|
-
var Popover = ({
|
|
4439
|
+
var Popover = ({
|
|
4440
|
+
items = [],
|
|
4441
|
+
children,
|
|
4442
|
+
anchorRef,
|
|
4443
|
+
offsetY = 8
|
|
4444
|
+
}) => {
|
|
4432
4445
|
const [open, setOpen] = useState15(false);
|
|
4433
4446
|
const ref = useRef12(null);
|
|
4434
4447
|
const menuRef = useRef12(null);
|
|
4435
|
-
const [menuPosition, setMenuPosition] = useState15({
|
|
4448
|
+
const [menuPosition, setMenuPosition] = useState15({
|
|
4449
|
+
mode: "default",
|
|
4450
|
+
top: 0,
|
|
4451
|
+
left: 0
|
|
4452
|
+
});
|
|
4436
4453
|
const updatePosition = useCallback4(() => {
|
|
4437
4454
|
var _a;
|
|
4438
|
-
if (!ref.current)
|
|
4439
|
-
|
|
4455
|
+
if (!ref.current) return;
|
|
4456
|
+
if (anchorRef == null ? void 0 : anchorRef.current) {
|
|
4457
|
+
const anchorRect = anchorRef.current.getBoundingClientRect();
|
|
4458
|
+
setMenuPosition({
|
|
4459
|
+
mode: "anchor",
|
|
4460
|
+
bottom: window.innerHeight - anchorRect.top + offsetY,
|
|
4461
|
+
left: anchorRect.left,
|
|
4462
|
+
width: anchorRect.width
|
|
4463
|
+
});
|
|
4464
|
+
} else {
|
|
4465
|
+
const rect = ref.current.getBoundingClientRect();
|
|
4466
|
+
const estimatedMenuHeight = items.length * 42 + 8;
|
|
4467
|
+
const menuHeight = ((_a = menuRef.current) == null ? void 0 : _a.getBoundingClientRect().height) ? menuRef.current.getBoundingClientRect().height : estimatedMenuHeight;
|
|
4468
|
+
const viewportPadding = 8;
|
|
4469
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
4470
|
+
const shouldOpenAbove = spaceBelow < menuHeight + 6;
|
|
4471
|
+
const top = shouldOpenAbove ? rect.top - menuHeight - 6 : rect.bottom + 6;
|
|
4472
|
+
setMenuPosition({
|
|
4473
|
+
mode: "default",
|
|
4474
|
+
top: Math.max(
|
|
4475
|
+
viewportPadding,
|
|
4476
|
+
Math.min(top, window.innerHeight - menuHeight - viewportPadding)
|
|
4477
|
+
),
|
|
4478
|
+
left: rect.right
|
|
4479
|
+
});
|
|
4440
4480
|
}
|
|
4441
|
-
|
|
4442
|
-
const estimatedMenuHeight = items.length * 42 + 8;
|
|
4443
|
-
const menuHeight = ((_a = menuRef.current) == null ? void 0 : _a.getBoundingClientRect().height) ? menuRef.current.getBoundingClientRect().height : estimatedMenuHeight;
|
|
4444
|
-
const viewportPadding = 8;
|
|
4445
|
-
const spaceBelow = window.innerHeight - rect.bottom;
|
|
4446
|
-
const shouldOpenAbove = spaceBelow < menuHeight + 6;
|
|
4447
|
-
const top = shouldOpenAbove ? rect.top - menuHeight - 6 : rect.bottom + 6;
|
|
4448
|
-
setMenuPosition({
|
|
4449
|
-
top: Math.max(
|
|
4450
|
-
viewportPadding,
|
|
4451
|
-
Math.min(top, window.innerHeight - menuHeight - viewportPadding)
|
|
4452
|
-
),
|
|
4453
|
-
left: rect.right
|
|
4454
|
-
});
|
|
4455
|
-
}, [items.length]);
|
|
4481
|
+
}, [items.length, anchorRef, offsetY]);
|
|
4456
4482
|
useEffect13(() => {
|
|
4457
4483
|
const handleClickOutside = (event) => {
|
|
4458
4484
|
var _a, _b;
|
|
@@ -4474,33 +4500,34 @@ var Popover = ({ items = [], children }) => {
|
|
|
4474
4500
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
4475
4501
|
};
|
|
4476
4502
|
}, [open, updatePosition]);
|
|
4503
|
+
const menuStyle = menuPosition.mode === "anchor" ? {
|
|
4504
|
+
top: "auto",
|
|
4505
|
+
bottom: menuPosition.bottom,
|
|
4506
|
+
left: menuPosition.left,
|
|
4507
|
+
width: menuPosition.width,
|
|
4508
|
+
transform: "none"
|
|
4509
|
+
} : {
|
|
4510
|
+
top: menuPosition.top,
|
|
4511
|
+
bottom: "auto",
|
|
4512
|
+
left: menuPosition.left,
|
|
4513
|
+
transform: "translateX(-100%)"
|
|
4514
|
+
};
|
|
4477
4515
|
return /* @__PURE__ */ jsxs24(PopoverWrapper, { ref, children: [
|
|
4478
4516
|
/* @__PURE__ */ jsx49(PopoverTrigger, { onClick: () => setOpen((o) => !o), children }),
|
|
4479
4517
|
open && createPortal(
|
|
4480
|
-
/* @__PURE__ */ jsx49(
|
|
4481
|
-
|
|
4518
|
+
/* @__PURE__ */ jsx49(PopoverMenu, { ref: menuRef, style: menuStyle, children: items.map((item, idx) => /* @__PURE__ */ jsx49(
|
|
4519
|
+
PopoverItem,
|
|
4482
4520
|
{
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
transform: "translateX(-100%)"
|
|
4521
|
+
isLast: idx === items.length - 1,
|
|
4522
|
+
onClick: () => {
|
|
4523
|
+
setOpen(false);
|
|
4524
|
+
item.action();
|
|
4488
4525
|
},
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
setOpen(false);
|
|
4495
|
-
item.action();
|
|
4496
|
-
},
|
|
4497
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
4498
|
-
children: item.label
|
|
4499
|
-
},
|
|
4500
|
-
typeof item.label === "string" ? item.label : idx
|
|
4501
|
-
))
|
|
4502
|
-
}
|
|
4503
|
-
),
|
|
4526
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4527
|
+
children: item.label
|
|
4528
|
+
},
|
|
4529
|
+
typeof item.label === "string" ? item.label : idx
|
|
4530
|
+
)) }),
|
|
4504
4531
|
document.body
|
|
4505
4532
|
)
|
|
4506
4533
|
] });
|