@mirror-physics/fractal-ui 0.2.0-next.57 → 0.2.0-next.58
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.cjs +41 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +16 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +44 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1045,7 +1045,7 @@ function DataTable({ columns, data, emptyMessage, header, size = "md", className
|
|
|
1045
1045
|
|
|
1046
1046
|
// src/components/Dropdown/Dropdown.tsx
|
|
1047
1047
|
import * as React9 from "react";
|
|
1048
|
-
import { ChevronDown, ChevronUp } from "@mirror-physics/fractal-icons";
|
|
1048
|
+
import { ChevronDown, ChevronLeft, ChevronRight as ChevronRight2, ChevronUp } from "@mirror-physics/fractal-icons";
|
|
1049
1049
|
import { Fragment as Fragment2, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1050
1050
|
var MARGIN = 4;
|
|
1051
1051
|
function Dropdown({
|
|
@@ -1055,6 +1055,7 @@ function Dropdown({
|
|
|
1055
1055
|
triggerLabel = "Options",
|
|
1056
1056
|
direction = "down",
|
|
1057
1057
|
align = "left",
|
|
1058
|
+
triggerOrientation = "horizontal",
|
|
1058
1059
|
triggerContent,
|
|
1059
1060
|
label,
|
|
1060
1061
|
iconOnly = false,
|
|
@@ -1078,41 +1079,59 @@ function Dropdown({
|
|
|
1078
1079
|
const selectableItems = visibleItems.filter((i) => i.kind !== "header");
|
|
1079
1080
|
const selected = items.find((i) => i.value === selectedValue && i.kind !== "header") ?? selectableItems[0] ?? visibleItems[0];
|
|
1080
1081
|
const isUp = direction === "up";
|
|
1081
|
-
const
|
|
1082
|
+
const isHorizontalDirection = direction === "left" || direction === "right";
|
|
1083
|
+
const ChevronIcon = direction === "up" ? ChevronUp : direction === "left" ? ChevronLeft : direction === "right" ? ChevronRight2 : ChevronDown;
|
|
1082
1084
|
React9.useLayoutEffect(() => {
|
|
1083
1085
|
if (!open || !triggerRef.current || !panelRef.current) return;
|
|
1084
1086
|
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
1085
1087
|
const panelRect = panelRef.current.getBoundingClientRect();
|
|
1086
1088
|
const vw = window.innerWidth;
|
|
1087
1089
|
const vh = window.innerHeight;
|
|
1088
|
-
|
|
1089
|
-
const spaceAbove = triggerRect.top - MARGIN;
|
|
1090
|
-
let placeAbove = isUp;
|
|
1091
|
-
if (placeAbove && panelRect.height > spaceAbove && spaceBelow > spaceAbove) {
|
|
1092
|
-
placeAbove = false;
|
|
1093
|
-
} else if (!placeAbove && panelRect.height > spaceBelow && spaceAbove > spaceBelow) {
|
|
1094
|
-
placeAbove = true;
|
|
1095
|
-
}
|
|
1096
|
-
const top = placeAbove ? -(panelRect.height + MARGIN) : triggerRect.height + MARGIN;
|
|
1090
|
+
let top;
|
|
1097
1091
|
let left;
|
|
1098
1092
|
let right;
|
|
1099
|
-
if (
|
|
1100
|
-
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1093
|
+
if (isHorizontalDirection) {
|
|
1094
|
+
const spaceRight = vw - triggerRect.right - MARGIN;
|
|
1095
|
+
const spaceLeft = triggerRect.left - MARGIN;
|
|
1096
|
+
let placeRight = direction === "right";
|
|
1097
|
+
if (placeRight && panelRect.width > spaceRight && spaceLeft > spaceRight) {
|
|
1098
|
+
placeRight = false;
|
|
1099
|
+
} else if (!placeRight && panelRect.width > spaceLeft && spaceRight > spaceLeft) {
|
|
1100
|
+
placeRight = true;
|
|
1105
1101
|
}
|
|
1102
|
+
left = placeRight ? triggerRect.width + MARGIN : -(panelRect.width + MARGIN);
|
|
1103
|
+
top = 0;
|
|
1104
|
+
const panelBottom = triggerRect.top + panelRect.height;
|
|
1105
|
+
if (panelBottom > vh - MARGIN) top -= panelBottom - (vh - MARGIN);
|
|
1106
|
+
if (triggerRect.top + top < MARGIN) top += MARGIN - (triggerRect.top + top);
|
|
1106
1107
|
} else {
|
|
1107
|
-
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
|
|
1108
|
+
const spaceBelow = vh - triggerRect.bottom - MARGIN;
|
|
1109
|
+
const spaceAbove = triggerRect.top - MARGIN;
|
|
1110
|
+
let placeAbove = isUp;
|
|
1111
|
+
if (placeAbove && panelRect.height > spaceAbove && spaceBelow > spaceAbove) {
|
|
1112
|
+
placeAbove = false;
|
|
1113
|
+
} else if (!placeAbove && panelRect.height > spaceBelow && spaceAbove > spaceBelow) {
|
|
1114
|
+
placeAbove = true;
|
|
1115
|
+
}
|
|
1116
|
+
top = placeAbove ? -(panelRect.height + MARGIN) : triggerRect.height + MARGIN;
|
|
1117
|
+
if (align === "right") {
|
|
1111
1118
|
right = 0;
|
|
1119
|
+
const panelLeft = triggerRect.right - panelRect.width;
|
|
1120
|
+
if (panelLeft < 0) {
|
|
1121
|
+
right = void 0;
|
|
1122
|
+
left = 0;
|
|
1123
|
+
}
|
|
1124
|
+
} else {
|
|
1125
|
+
left = 0;
|
|
1126
|
+
const panelRight = triggerRect.left + panelRect.width;
|
|
1127
|
+
if (panelRight > vw) {
|
|
1128
|
+
left = void 0;
|
|
1129
|
+
right = 0;
|
|
1130
|
+
}
|
|
1112
1131
|
}
|
|
1113
1132
|
}
|
|
1114
1133
|
setPanelStyle({ top, left, right });
|
|
1115
|
-
}, [open, isUp, align]);
|
|
1134
|
+
}, [open, direction, isHorizontalDirection, isUp, align]);
|
|
1116
1135
|
React9.useEffect(() => {
|
|
1117
1136
|
if (!open) return;
|
|
1118
1137
|
const handleClickOutside = (e) => {
|
|
@@ -1138,6 +1157,7 @@ function Dropdown({
|
|
|
1138
1157
|
"fractal-dropdown-trigger",
|
|
1139
1158
|
`fractal-dropdown-trigger--${size}`,
|
|
1140
1159
|
`fractal-dropdown-trigger--${triggerVariant}`,
|
|
1160
|
+
`fractal-dropdown-trigger--${triggerOrientation}`,
|
|
1141
1161
|
iconOnly && "fractal-dropdown-trigger--icon-only",
|
|
1142
1162
|
triggerClassName
|
|
1143
1163
|
),
|
|
@@ -1678,7 +1698,7 @@ function ContentSwitcher({ items, value, onValueChange, ariaLabel, fullWidth = f
|
|
|
1678
1698
|
|
|
1679
1699
|
// src/components/Disclosure/Disclosure.tsx
|
|
1680
1700
|
import { useId as useId3, useState as useState7 } from "react";
|
|
1681
|
-
import { ChevronRight as
|
|
1701
|
+
import { ChevronRight as ChevronRight3, ChevronDown as ChevronDown2 } from "@mirror-physics/fractal-icons";
|
|
1682
1702
|
import { jsx as jsx21, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1683
1703
|
function Disclosure({
|
|
1684
1704
|
title,
|
|
@@ -1729,7 +1749,7 @@ function Disclosure({
|
|
|
1729
1749
|
disabled,
|
|
1730
1750
|
onClick: toggle,
|
|
1731
1751
|
children: [
|
|
1732
|
-
/* @__PURE__ */ jsx21("span", { className: "fractal-disclosure-icon", "aria-hidden": "true", children: isOpen ? /* @__PURE__ */ jsx21(ChevronDown2, { size: 16 }) : /* @__PURE__ */ jsx21(
|
|
1752
|
+
/* @__PURE__ */ jsx21("span", { className: "fractal-disclosure-icon", "aria-hidden": "true", children: isOpen ? /* @__PURE__ */ jsx21(ChevronDown2, { size: 16 }) : /* @__PURE__ */ jsx21(ChevronRight3, { size: 16 }) }),
|
|
1733
1753
|
/* @__PURE__ */ jsx21("span", { className: "fractal-disclosure-title", children: title }),
|
|
1734
1754
|
meta && /* @__PURE__ */ jsx21("span", { className: "fractal-disclosure-meta", children: meta })
|
|
1735
1755
|
]
|