@eqtylab/equality 5.0.0 → 5.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/CHANGELOG.md +24 -0
- package/dist/index.cjs +85 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +85 -8
- package/dist/index.js.map +1 -1
- package/dist/nav.module.module.css.module.css +42 -2
- package/dist/skeleton.module.module.css.module.css +4 -1
- package/dist/spinner.module.module.css.module.css +2 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1681,7 +1681,7 @@ interface NavSwitcherAction {
|
|
|
1681
1681
|
/** Runs once the list has closed */
|
|
1682
1682
|
onSelect: () => void;
|
|
1683
1683
|
}
|
|
1684
|
-
interface
|
|
1684
|
+
interface NavSwitcherBaseProps {
|
|
1685
1685
|
/** Shows a placeholder at the switcher's height while the current item loads */
|
|
1686
1686
|
loading?: false;
|
|
1687
1687
|
/** The current item's name, shown as the panel's heading */
|
|
@@ -1703,6 +1703,19 @@ interface NavSwitcherLoadedProps {
|
|
|
1703
1703
|
/** A command at the bottom of the list, kept while searching, such as "Create Project" */
|
|
1704
1704
|
action?: NavSwitcherAction;
|
|
1705
1705
|
}
|
|
1706
|
+
type NavSwitcherRetryProps = {
|
|
1707
|
+
error?: false;
|
|
1708
|
+
retrying?: never;
|
|
1709
|
+
onRetry?: never;
|
|
1710
|
+
} | {
|
|
1711
|
+
/** The list failed to load: the list says so and offers Retry */
|
|
1712
|
+
error: boolean;
|
|
1713
|
+
/** A retry is in flight: the Retry row reads "Retrying..." */
|
|
1714
|
+
retrying?: boolean;
|
|
1715
|
+
/** Called when Retry is picked; the list stays open */
|
|
1716
|
+
onRetry: () => void;
|
|
1717
|
+
};
|
|
1718
|
+
type NavSwitcherLoadedProps = NavSwitcherBaseProps & NavSwitcherRetryProps;
|
|
1706
1719
|
interface NavSwitcherLoadingProps {
|
|
1707
1720
|
loading: true;
|
|
1708
1721
|
}
|
|
@@ -1719,6 +1732,9 @@ type NavSwitcherProps = NavSwitcherLoadedProps | NavSwitcherLoadingProps;
|
|
|
1719
1732
|
* - `onHighlight?: (value: string) => void` — Hover or focus on an option, for a caller that preloads its destination
|
|
1720
1733
|
* - `onHighlightEnd?: () => void` — Hover or focus leaves an option, for a caller that cancels its preload
|
|
1721
1734
|
* - `action?: NavSwitcherAction` — A command at the bottom of the list, kept while searching, such as "Create Project"
|
|
1735
|
+
* - `error?: false | boolean` — The list failed to load: the list says so and offers Retry
|
|
1736
|
+
* - `retrying?: boolean` — A retry is in flight: the Retry row reads "Retrying..."
|
|
1737
|
+
* - `onRetry?: () => void` — Called when Retry is picked; the list stays open
|
|
1722
1738
|
*
|
|
1723
1739
|
* [Nav documentation](https://equality.eqtylab.io/components/nav)
|
|
1724
1740
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1681,7 +1681,7 @@ interface NavSwitcherAction {
|
|
|
1681
1681
|
/** Runs once the list has closed */
|
|
1682
1682
|
onSelect: () => void;
|
|
1683
1683
|
}
|
|
1684
|
-
interface
|
|
1684
|
+
interface NavSwitcherBaseProps {
|
|
1685
1685
|
/** Shows a placeholder at the switcher's height while the current item loads */
|
|
1686
1686
|
loading?: false;
|
|
1687
1687
|
/** The current item's name, shown as the panel's heading */
|
|
@@ -1703,6 +1703,19 @@ interface NavSwitcherLoadedProps {
|
|
|
1703
1703
|
/** A command at the bottom of the list, kept while searching, such as "Create Project" */
|
|
1704
1704
|
action?: NavSwitcherAction;
|
|
1705
1705
|
}
|
|
1706
|
+
type NavSwitcherRetryProps = {
|
|
1707
|
+
error?: false;
|
|
1708
|
+
retrying?: never;
|
|
1709
|
+
onRetry?: never;
|
|
1710
|
+
} | {
|
|
1711
|
+
/** The list failed to load: the list says so and offers Retry */
|
|
1712
|
+
error: boolean;
|
|
1713
|
+
/** A retry is in flight: the Retry row reads "Retrying..." */
|
|
1714
|
+
retrying?: boolean;
|
|
1715
|
+
/** Called when Retry is picked; the list stays open */
|
|
1716
|
+
onRetry: () => void;
|
|
1717
|
+
};
|
|
1718
|
+
type NavSwitcherLoadedProps = NavSwitcherBaseProps & NavSwitcherRetryProps;
|
|
1706
1719
|
interface NavSwitcherLoadingProps {
|
|
1707
1720
|
loading: true;
|
|
1708
1721
|
}
|
|
@@ -1719,6 +1732,9 @@ type NavSwitcherProps = NavSwitcherLoadedProps | NavSwitcherLoadingProps;
|
|
|
1719
1732
|
* - `onHighlight?: (value: string) => void` — Hover or focus on an option, for a caller that preloads its destination
|
|
1720
1733
|
* - `onHighlightEnd?: () => void` — Hover or focus leaves an option, for a caller that cancels its preload
|
|
1721
1734
|
* - `action?: NavSwitcherAction` — A command at the bottom of the list, kept while searching, such as "Create Project"
|
|
1735
|
+
* - `error?: false | boolean` — The list failed to load: the list says so and offers Retry
|
|
1736
|
+
* - `retrying?: boolean` — A retry is in flight: the Retry row reads "Retrying..."
|
|
1737
|
+
* - `onRetry?: () => void` — Called when Retry is picked; the list stays open
|
|
1722
1738
|
*
|
|
1723
1739
|
* [Nav documentation](https://equality.eqtylab.io/components/nav)
|
|
1724
1740
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2667,9 +2667,9 @@ var Input = React15.forwardRef(
|
|
|
2667
2667
|
);
|
|
2668
2668
|
Input.displayName = "Input";
|
|
2669
2669
|
var Spinner = ({ size = "md", variant = "primary" }) => {
|
|
2670
|
-
return /* @__PURE__ */ jsxs("
|
|
2671
|
-
/* @__PURE__ */ jsx("
|
|
2672
|
-
/* @__PURE__ */ jsx("
|
|
2670
|
+
return /* @__PURE__ */ jsxs("span", { className: styles31["spinner-container"], children: [
|
|
2671
|
+
/* @__PURE__ */ jsx("span", { className: cn(styles31["spinner"], styles31[size], styles31[variant]) }),
|
|
2672
|
+
/* @__PURE__ */ jsx("span", { className: cn(styles31["spinner-background"], styles31[size]) })
|
|
2673
2673
|
] });
|
|
2674
2674
|
};
|
|
2675
2675
|
function LoadingOverlay({ isVisible, message = "Loading..." }) {
|
|
@@ -3389,11 +3389,39 @@ function Skeleton({ className, ...props }) {
|
|
|
3389
3389
|
return /* @__PURE__ */ jsx("div", { className: cn(styles39["skeleton"], className), ...props });
|
|
3390
3390
|
}
|
|
3391
3391
|
var NavSwitcherSelect = React15.forwardRef(
|
|
3392
|
-
({
|
|
3392
|
+
({
|
|
3393
|
+
label,
|
|
3394
|
+
noun,
|
|
3395
|
+
collection,
|
|
3396
|
+
options,
|
|
3397
|
+
value,
|
|
3398
|
+
onValueChange,
|
|
3399
|
+
onHighlight,
|
|
3400
|
+
onHighlightEnd,
|
|
3401
|
+
action,
|
|
3402
|
+
error,
|
|
3403
|
+
retrying,
|
|
3404
|
+
onRetry
|
|
3405
|
+
}, ref) => {
|
|
3393
3406
|
const labelId = React15.useId();
|
|
3394
3407
|
const actionValue = React15.useId();
|
|
3408
|
+
const retryValue = React15.useId();
|
|
3409
|
+
const errorId = React15.useId();
|
|
3395
3410
|
const actionPending = React15.useRef(false);
|
|
3396
|
-
|
|
3411
|
+
const [open, setOpen] = React15.useState(false);
|
|
3412
|
+
const keepOpen = React15.useRef(false);
|
|
3413
|
+
const [announcement, setAnnouncement] = React15.useState("");
|
|
3414
|
+
const [listState, setListState] = React15.useState({ error, retrying });
|
|
3415
|
+
if (listState.error !== error || listState.retrying !== retrying) {
|
|
3416
|
+
setListState({ error, retrying });
|
|
3417
|
+
if (error || listState.error) {
|
|
3418
|
+
setAnnouncement(
|
|
3419
|
+
error ? retrying ? "Retrying..." : `Couldn't load ${collection}.` : options.length > 0 ? `Loaded ${collection}.` : `No ${collection} found.`
|
|
3420
|
+
);
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
const empty = options.length === 0 && !action && !error;
|
|
3424
|
+
if (empty && !open) {
|
|
3397
3425
|
return /* @__PURE__ */ jsx("h2", { className: styles40["nav-switcher-heading"], children: /* @__PURE__ */ jsx(
|
|
3398
3426
|
"span",
|
|
3399
3427
|
{
|
|
@@ -3407,9 +3435,24 @@ var NavSwitcherSelect = React15.forwardRef(
|
|
|
3407
3435
|
Select,
|
|
3408
3436
|
{
|
|
3409
3437
|
value,
|
|
3438
|
+
open,
|
|
3439
|
+
onOpenChange: (next) => {
|
|
3440
|
+
if (!next && keepOpen.current) keepOpen.current = false;
|
|
3441
|
+
else {
|
|
3442
|
+
setOpen(next);
|
|
3443
|
+
setAnnouncement("");
|
|
3444
|
+
}
|
|
3445
|
+
},
|
|
3410
3446
|
onValueChange: (next) => {
|
|
3411
3447
|
if (next === actionValue) actionPending.current = true;
|
|
3412
|
-
else
|
|
3448
|
+
else if (next === retryValue) {
|
|
3449
|
+
if (!open) return;
|
|
3450
|
+
keepOpen.current = true;
|
|
3451
|
+
queueMicrotask(() => {
|
|
3452
|
+
keepOpen.current = false;
|
|
3453
|
+
});
|
|
3454
|
+
if (!retrying) onRetry?.();
|
|
3455
|
+
} else onValueChange(next);
|
|
3413
3456
|
},
|
|
3414
3457
|
children: [
|
|
3415
3458
|
/* @__PURE__ */ jsxs(
|
|
@@ -3443,14 +3486,48 @@ var NavSwitcherSelect = React15.forwardRef(
|
|
|
3443
3486
|
action?.onSelect();
|
|
3444
3487
|
},
|
|
3445
3488
|
children: [
|
|
3489
|
+
/* @__PURE__ */ jsx("div", { className: styles40["nav-switcher-status"], role: "status", "aria-live": "polite", children: announcement }),
|
|
3446
3490
|
/* @__PURE__ */ jsx(
|
|
3447
3491
|
SelectSearch,
|
|
3448
3492
|
{
|
|
3449
3493
|
placeholder: `Search ${collection}...`,
|
|
3450
|
-
"aria-label": `Search ${collection}
|
|
3494
|
+
"aria-label": `Search ${collection}`,
|
|
3495
|
+
"aria-describedby": error ? errorId : void 0
|
|
3451
3496
|
}
|
|
3452
3497
|
),
|
|
3453
|
-
/* @__PURE__ */
|
|
3498
|
+
error && /* @__PURE__ */ jsx(
|
|
3499
|
+
SelectItem,
|
|
3500
|
+
{
|
|
3501
|
+
value: retryValue,
|
|
3502
|
+
textValue: `Couldn't load ${collection}. ${retrying ? "Retrying" : "Retry"}`,
|
|
3503
|
+
persistent: true,
|
|
3504
|
+
"aria-disabled": retrying || void 0,
|
|
3505
|
+
className: styles40["nav-switcher-retry"],
|
|
3506
|
+
children: /* @__PURE__ */ jsxs("span", { className: styles40["nav-switcher-error"], children: [
|
|
3507
|
+
/* @__PURE__ */ jsxs("span", { id: errorId, className: styles40["nav-switcher-error-message"], children: [
|
|
3508
|
+
/* @__PURE__ */ jsx(
|
|
3509
|
+
TriangleAlert,
|
|
3510
|
+
{
|
|
3511
|
+
className: styles40["nav-switcher-error-icon"],
|
|
3512
|
+
"aria-hidden": "true"
|
|
3513
|
+
}
|
|
3514
|
+
),
|
|
3515
|
+
"Couldn't load ",
|
|
3516
|
+
collection,
|
|
3517
|
+
"."
|
|
3518
|
+
] }),
|
|
3519
|
+
retrying ? /* @__PURE__ */ jsxs("span", { className: styles40["nav-switcher-error-message"], children: [
|
|
3520
|
+
/* @__PURE__ */ jsx(Spinner, { size: "xs", variant: "neutral" }),
|
|
3521
|
+
"Retrying..."
|
|
3522
|
+
] }) : /* @__PURE__ */ jsx("span", { className: buttonVariants({ variant: "link", size: "sm" }), children: "Retry" })
|
|
3523
|
+
] })
|
|
3524
|
+
}
|
|
3525
|
+
),
|
|
3526
|
+
empty ? /* @__PURE__ */ jsxs("div", { className: styles40["nav-switcher-empty"], children: [
|
|
3527
|
+
"No ",
|
|
3528
|
+
collection,
|
|
3529
|
+
" found"
|
|
3530
|
+
] }) : (!error || options.length > 0) && /* @__PURE__ */ jsxs(SelectEmpty, { children: [
|
|
3454
3531
|
"No ",
|
|
3455
3532
|
collection,
|
|
3456
3533
|
" found"
|