@basictech/react 0.12.0-beta.2 → 0.12.0-beta.3
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/CHANGELOG.md +13 -0
- package/README.md +56 -9
- package/dist/index.d.mts +21 -3
- package/dist/index.d.ts +21 -3
- package/dist/index.js +53 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -4
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +19 -12
- package/dist/styles.css.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1100,9 +1100,22 @@ import { Tabs } from "@base-ui/react/tabs";
|
|
|
1100
1100
|
import { BasicError as BasicError6 } from "@basictech/core";
|
|
1101
1101
|
import { Fragment as Fragment2, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
1102
1102
|
var AppearanceContext = createContext2({});
|
|
1103
|
+
function accentText(accent) {
|
|
1104
|
+
if (!/^#([\da-f]{3}|[\da-f]{6})$/i.test(accent)) return "#fff";
|
|
1105
|
+
const hex = accent.length === 4 ? accent.slice(1).split("").map((digit) => digit + digit).join("") : accent.slice(1);
|
|
1106
|
+
const [red, green, blue] = [0, 2, 4].map((offset) => {
|
|
1107
|
+
const channel = parseInt(hex.slice(offset, offset + 2), 16) / 255;
|
|
1108
|
+
return channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4;
|
|
1109
|
+
});
|
|
1110
|
+
return 0.2126 * red + 0.7152 * green + 0.0722 * blue > 0.179 ? "#000" : "#fff";
|
|
1111
|
+
}
|
|
1103
1112
|
function appearanceStyle(appearance) {
|
|
1104
1113
|
return {
|
|
1105
|
-
...appearance.
|
|
1114
|
+
...appearance.base ? { "--basic-surface": appearance.base } : {},
|
|
1115
|
+
...appearance.accent ? {
|
|
1116
|
+
"--basic-accent": appearance.accent,
|
|
1117
|
+
"--basic-accent-text": accentText(appearance.accent)
|
|
1118
|
+
} : {},
|
|
1106
1119
|
...appearance.radius ? { "--basic-radius": appearance.radius } : {}
|
|
1107
1120
|
};
|
|
1108
1121
|
}
|
|
@@ -1219,6 +1232,7 @@ function UserAvatar({
|
|
|
1219
1232
|
auth,
|
|
1220
1233
|
projectProfile,
|
|
1221
1234
|
allowAddAccount,
|
|
1235
|
+
menuItems,
|
|
1222
1236
|
...avatarProps
|
|
1223
1237
|
}) {
|
|
1224
1238
|
return /* @__PURE__ */ jsx3(
|
|
@@ -1228,6 +1242,7 @@ function UserAvatar({
|
|
|
1228
1242
|
auth,
|
|
1229
1243
|
projectProfile,
|
|
1230
1244
|
allowAddAccount,
|
|
1245
|
+
menuItems,
|
|
1231
1246
|
sync: avatarProps.sync,
|
|
1232
1247
|
showSyncBadge: avatarProps.showSyncBadge,
|
|
1233
1248
|
avatarProps
|
|
@@ -1356,7 +1371,8 @@ function UserMenu({
|
|
|
1356
1371
|
projectProfile,
|
|
1357
1372
|
allowAddAccount = true,
|
|
1358
1373
|
className = "",
|
|
1359
|
-
accountSettingsUrl
|
|
1374
|
+
accountSettingsUrl,
|
|
1375
|
+
menuItems = []
|
|
1360
1376
|
}) {
|
|
1361
1377
|
const liveAccounts = useAccounts();
|
|
1362
1378
|
const liveAuth = useAuth();
|
|
@@ -1476,6 +1492,22 @@ function UserMenu({
|
|
|
1476
1492
|
]
|
|
1477
1493
|
}
|
|
1478
1494
|
),
|
|
1495
|
+
menuItems.map((item) => /* @__PURE__ */ jsxs(
|
|
1496
|
+
Menu.Item,
|
|
1497
|
+
{
|
|
1498
|
+
className: "basic-menu-item",
|
|
1499
|
+
render: item.href !== void 0 ? /* @__PURE__ */ jsx3("a", { href: item.href }) : void 0,
|
|
1500
|
+
disabled: item.disabled || action.pending,
|
|
1501
|
+
onClick: () => {
|
|
1502
|
+
if (item.onClick) void action.run(item.onClick);
|
|
1503
|
+
},
|
|
1504
|
+
children: [
|
|
1505
|
+
/* @__PURE__ */ jsx3("span", { className: "basic-menu-icon", "aria-hidden": "true", children: item.icon }),
|
|
1506
|
+
item.label
|
|
1507
|
+
]
|
|
1508
|
+
},
|
|
1509
|
+
item.id
|
|
1510
|
+
)),
|
|
1479
1511
|
(auth.isSignedIn || expired || active?.kind === "anon") && /* @__PURE__ */ jsxs(
|
|
1480
1512
|
Menu.Item,
|
|
1481
1513
|
{
|
|
@@ -1532,7 +1564,7 @@ function UserMenu({
|
|
|
1532
1564
|
},
|
|
1533
1565
|
account.id
|
|
1534
1566
|
)),
|
|
1535
|
-
(allowAddAccount || !auth.isSignedIn && !expired) && /* @__PURE__ */
|
|
1567
|
+
(allowAddAccount || !auth.isSignedIn && !expired) && /* @__PURE__ */ jsxs(
|
|
1536
1568
|
Menu.Item,
|
|
1537
1569
|
{
|
|
1538
1570
|
className: "basic-menu-item",
|
|
@@ -1540,7 +1572,24 @@ function UserMenu({
|
|
|
1540
1572
|
onClick: () => void action.run(
|
|
1541
1573
|
() => allowAddAccount ? accounts.addAccount({ signIn: true }) : auth.signIn()
|
|
1542
1574
|
),
|
|
1543
|
-
children:
|
|
1575
|
+
children: [
|
|
1576
|
+
/* @__PURE__ */ jsx3(
|
|
1577
|
+
"svg",
|
|
1578
|
+
{
|
|
1579
|
+
className: "basic-menu-icon",
|
|
1580
|
+
width: "16",
|
|
1581
|
+
height: "16",
|
|
1582
|
+
viewBox: "0 0 24 24",
|
|
1583
|
+
fill: "none",
|
|
1584
|
+
stroke: "currentColor",
|
|
1585
|
+
strokeWidth: "1.75",
|
|
1586
|
+
strokeLinecap: "round",
|
|
1587
|
+
"aria-hidden": "true",
|
|
1588
|
+
children: /* @__PURE__ */ jsx3("path", { d: "M12 5v14M5 12h14" })
|
|
1589
|
+
}
|
|
1590
|
+
),
|
|
1591
|
+
"Add account"
|
|
1592
|
+
]
|
|
1544
1593
|
}
|
|
1545
1594
|
)
|
|
1546
1595
|
] }) }) })
|