@trackunit/react-components 6.0.45 → 6.1.1
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/index.cjs.js +109 -33
- package/index.esm.js +109 -33
- package/migrations/assets/react-router-components/package.json +6 -6
- package/package.json +6 -6
- package/src/components/AssetIdentity/IdentityCard.d.ts +38 -14
- package/src/components/AssetIdentity/IdentityCard.variants.d.ts +6 -0
- package/src/components/AssetIdentity/IdentityCardAnchor.d.ts +48 -0
- package/src/components/AssetIdentity/IdentityCardSkeleton.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -3190,6 +3190,16 @@ const cvaCardIdentityGroup = cssClassVarianceUtilities.cva({
|
|
|
3190
3190
|
singleLine: false,
|
|
3191
3191
|
},
|
|
3192
3192
|
});
|
|
3193
|
+
const cvaCardLink = cssClassVarianceUtilities.cva({
|
|
3194
|
+
base: [
|
|
3195
|
+
"block",
|
|
3196
|
+
"w-full",
|
|
3197
|
+
"min-w-0",
|
|
3198
|
+
"text-inherit",
|
|
3199
|
+
"no-underline",
|
|
3200
|
+
"focus-visible:outline-none",
|
|
3201
|
+
],
|
|
3202
|
+
});
|
|
3193
3203
|
// Top row inside the identity group: title on the left, connectivity slot
|
|
3194
3204
|
// on the right. Isolating connectivity to this row means the subtitle and
|
|
3195
3205
|
// status rows below get the full text-stack width.
|
|
@@ -3256,6 +3266,72 @@ const cvaCardChevron = cssClassVarianceUtilities.cva({
|
|
|
3256
3266
|
base: ["shrink-0", "self-center", "flex", "items-center", "text-neutral-500"],
|
|
3257
3267
|
});
|
|
3258
3268
|
|
|
3269
|
+
/**
|
|
3270
|
+
* Wraps the content of an `IdentityCard` in a real anchor, following the
|
|
3271
|
+
* `IdentityCell` link pattern: the address resolves asynchronously, a plain
|
|
3272
|
+
* click and Enter navigate through `goto`, and modifier clicks are left to
|
|
3273
|
+
* the browser. Middle-click arrives as `auxclick`, not `click`, so it has its
|
|
3274
|
+
* own handler. The link is named after the card title through
|
|
3275
|
+
* `aria-labelledby`, so the subtitle and slot content do not become part of
|
|
3276
|
+
* the accessible name.
|
|
3277
|
+
*
|
|
3278
|
+
* The `href` is omitted until a non-empty address resolves for the current
|
|
3279
|
+
* `link`: React drops an empty-string `href` with a console error, and a
|
|
3280
|
+
* stale address from a previous `link` must never be offered. While there is
|
|
3281
|
+
* no `href` the anchor stays keyboard-reachable (`role="link"`, Enter) and a
|
|
3282
|
+
* modifier click falls back to `goto`, because the browser has nothing to open.
|
|
3283
|
+
*
|
|
3284
|
+
* A failed address lookup is treated like an empty address.
|
|
3285
|
+
*
|
|
3286
|
+
* @param {IdentityCardAnchorProps} props - The props for the IdentityCardAnchor component
|
|
3287
|
+
* @returns {ReactElement} IdentityCardAnchor component
|
|
3288
|
+
*/
|
|
3289
|
+
const IdentityCardAnchor = ({ link, labelledBy, children }) => {
|
|
3290
|
+
const [resolved, setResolved] = react.useState(undefined);
|
|
3291
|
+
react.useEffect(() => {
|
|
3292
|
+
let isStale = false;
|
|
3293
|
+
void link
|
|
3294
|
+
.href()
|
|
3295
|
+
.catch(() => "")
|
|
3296
|
+
.then(resolvedHref => {
|
|
3297
|
+
if (!isStale) {
|
|
3298
|
+
setResolved({ source: link, href: resolvedHref });
|
|
3299
|
+
}
|
|
3300
|
+
});
|
|
3301
|
+
return () => {
|
|
3302
|
+
isStale = true;
|
|
3303
|
+
};
|
|
3304
|
+
}, [link]);
|
|
3305
|
+
const href = resolved !== undefined && resolved.source === link && resolved.href !== "" ? resolved.href : undefined;
|
|
3306
|
+
const hasHref = href !== undefined;
|
|
3307
|
+
const handleClick = (event) => {
|
|
3308
|
+
event.stopPropagation();
|
|
3309
|
+
if (hasHref && (event.ctrlKey || event.metaKey || event.shiftKey)) {
|
|
3310
|
+
link.onActivate?.();
|
|
3311
|
+
return;
|
|
3312
|
+
}
|
|
3313
|
+
event.preventDefault();
|
|
3314
|
+
void link.goto();
|
|
3315
|
+
link.onActivate?.();
|
|
3316
|
+
};
|
|
3317
|
+
const handleAuxClick = (event) => {
|
|
3318
|
+
if (!hasHref || event.button !== 1) {
|
|
3319
|
+
return;
|
|
3320
|
+
}
|
|
3321
|
+
event.stopPropagation();
|
|
3322
|
+
link.onActivate?.();
|
|
3323
|
+
};
|
|
3324
|
+
const handleKeyDown = (event) => {
|
|
3325
|
+
if (event.repeat || event.key !== "Enter") {
|
|
3326
|
+
return;
|
|
3327
|
+
}
|
|
3328
|
+
event.preventDefault();
|
|
3329
|
+
event.currentTarget.click();
|
|
3330
|
+
};
|
|
3331
|
+
const withoutHrefProps = hasHref ? {} : { role: "link", tabIndex: 0, onKeyDown: handleKeyDown };
|
|
3332
|
+
return (jsxRuntime.jsx("a", { "aria-labelledby": labelledBy, className: cvaCardLink(), href: href, onAuxClick: handleAuxClick, onClick: handleClick, rel: "noreferrer", target: "_blank", ...withoutHrefProps, children: children }));
|
|
3333
|
+
};
|
|
3334
|
+
|
|
3259
3335
|
// Minimum asset-image height (in px). Matches the natural text-stack height
|
|
3260
3336
|
// of a title + subtitle row (h3 `leading-6` + `gap-1` + `text-xs`
|
|
3261
3337
|
// line-height) so a title-only identity never collapses the image to the
|
|
@@ -3322,14 +3398,15 @@ const useIdentityImageSize = (enabled) => {
|
|
|
3322
3398
|
* entity (an asset, site, customer, user, …) from inside a surface whose
|
|
3323
3399
|
* real focus is something else (an alert, service ticket, inspection, …).
|
|
3324
3400
|
*
|
|
3325
|
-
* When `
|
|
3401
|
+
* When `link` is supplied, the whole card becomes one anchor and a
|
|
3326
3402
|
* `ChevronRight` icon is rendered on the right edge to signal navigation.
|
|
3327
|
-
*
|
|
3328
|
-
*
|
|
3329
|
-
*
|
|
3330
|
-
*
|
|
3331
|
-
*
|
|
3332
|
-
*
|
|
3403
|
+
* Linked cards route the user to the referenced entity's own page: a plain
|
|
3404
|
+
* click and Enter navigate in the current tab through `link.goto` (pair it
|
|
3405
|
+
* with `useNavigateInHost` from `@trackunit/react-core-hooks`), while
|
|
3406
|
+
* right-click "Open in new tab" and Cmd/Ctrl/Shift/middle-click open the
|
|
3407
|
+
* resolved `link.href` in a new tab. `onClick` makes the card a
|
|
3408
|
+
* keyboard-operable button instead, but it cannot open a new tab. Without
|
|
3409
|
+
* `link` or `onClick` the card is a static, non-interactive reference.
|
|
3333
3410
|
*
|
|
3334
3411
|
* The card stays presentational: it owns layout only; domain hydration
|
|
3335
3412
|
* (indicator wiring, translations, last-seen formatting,
|
|
@@ -3352,13 +3429,21 @@ const useIdentityImageSize = (enabled) => {
|
|
|
3352
3429
|
* page-level asset header). The card is a reference that lives *inside*
|
|
3353
3430
|
* someone else's content.
|
|
3354
3431
|
*
|
|
3355
|
-
* @example
|
|
3432
|
+
* @example Linked asset reference inside a service ticket panel
|
|
3356
3433
|
* ```tsx
|
|
3357
3434
|
* import { IdentityCard, Highlight } from "@trackunit/react-components";
|
|
3358
3435
|
* import { useNavigateInHost } from "@trackunit/react-core-hooks";
|
|
3436
|
+
* import { useMemo } from "react";
|
|
3359
3437
|
*
|
|
3360
3438
|
* const ServicedAssetRow = ({ assetId }: { assetId: string }) => {
|
|
3361
|
-
* const { gotoAssetHome } = useNavigateInHost();
|
|
3439
|
+
* const { getAssetHomeUrl, gotoAssetHome } = useNavigateInHost();
|
|
3440
|
+
* const link = useMemo(
|
|
3441
|
+
* () => ({
|
|
3442
|
+
* href: async () => (await getAssetHomeUrl(assetId)) ?? "",
|
|
3443
|
+
* goto: () => gotoAssetHome(assetId),
|
|
3444
|
+
* }),
|
|
3445
|
+
* [assetId, getAssetHomeUrl, gotoAssetHome]
|
|
3446
|
+
* );
|
|
3362
3447
|
* return (
|
|
3363
3448
|
* <IdentityCard
|
|
3364
3449
|
* title="Trackunit-AWP343"
|
|
@@ -3375,12 +3460,12 @@ const useIdentityImageSize = (enabled) => {
|
|
|
3375
3460
|
* </Highlight>
|
|
3376
3461
|
* </>
|
|
3377
3462
|
* }
|
|
3378
|
-
*
|
|
3463
|
+
* link={link}
|
|
3379
3464
|
* />
|
|
3380
3465
|
* );
|
|
3381
3466
|
* };
|
|
3382
3467
|
* ```
|
|
3383
|
-
* @example
|
|
3468
|
+
* @example Static reference without a link (chevron omitted)
|
|
3384
3469
|
* ```tsx
|
|
3385
3470
|
* <IdentityCard
|
|
3386
3471
|
* image={<OEMModelImage brandName="Trackunit" model="GS4390" />}
|
|
@@ -3398,13 +3483,13 @@ const useIdentityImageSize = (enabled) => {
|
|
|
3398
3483
|
* thumbnail={<Icon name="ConstructionCone" />}
|
|
3399
3484
|
* thumbnailColor="site_construction_site-500"
|
|
3400
3485
|
* thumbnailBackground="site_construction_site-100"
|
|
3401
|
-
*
|
|
3486
|
+
* link={siteLink}
|
|
3402
3487
|
* />
|
|
3403
3488
|
* ```
|
|
3404
3489
|
* @param {IdentityCardProps} props - The props for the IdentityCard component
|
|
3405
3490
|
* @returns {ReactElement} IdentityCard component
|
|
3406
3491
|
*/
|
|
3407
|
-
const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "info-600", thumbnailBackground = "info-100", statusIndicators, connectivity, onClick, className, "data-testid": dataTestId, style, ref, }) => {
|
|
3492
|
+
const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "info-600", thumbnailBackground = "info-100", statusIndicators, connectivity, onClick, link, className, "data-testid": dataTestId, style, ref, }) => {
|
|
3408
3493
|
const hasSubtitleRow = subtitle !== undefined && subtitle.length > 0;
|
|
3409
3494
|
const showImage = image !== null && image !== undefined;
|
|
3410
3495
|
// `image` and `thumbnail` are mutually exclusive slots — the 14:9 asset
|
|
@@ -3415,7 +3500,10 @@ const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "inf
|
|
|
3415
3500
|
const showThumbnail = !showImage && thumbnail !== undefined;
|
|
3416
3501
|
const hasConnectivitySlot = connectivity !== null && connectivity !== undefined;
|
|
3417
3502
|
const hasStatusSlot = statusIndicators !== null && statusIndicators !== undefined;
|
|
3418
|
-
const
|
|
3503
|
+
const hasLink = link !== undefined;
|
|
3504
|
+
const isClickable = !hasLink && onClick !== undefined;
|
|
3505
|
+
const showChevron = hasLink || isClickable;
|
|
3506
|
+
const titleId = react.useId();
|
|
3419
3507
|
// Single-line layout kicks in when the text stack renders the title row
|
|
3420
3508
|
// only — no subtitle or status row. The `connectivity` slot lives on the
|
|
3421
3509
|
// title row itself, so it doesn't add a line and doesn't disqualify the
|
|
@@ -3427,13 +3515,6 @@ const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "inf
|
|
|
3427
3515
|
// stays in sync — the skeleton → loaded transition jumps otherwise.
|
|
3428
3516
|
const { imageSize, textStackRef } = useIdentityImageSize(showImage);
|
|
3429
3517
|
const imageSlotStyle = showImage && imageSize !== null ? { height: imageSize.height, width: imageSize.width } : undefined;
|
|
3430
|
-
// Keyboard activation for the clickable branch. `Card` renders a `div`
|
|
3431
|
-
// with `role="region"` by default, so on its own it can't be reached with
|
|
3432
|
-
// Tab and Enter/Space wouldn't fire `onClick`. When we're clickable, opt
|
|
3433
|
-
// into button semantics (focusable, activatable) and dispatch a real
|
|
3434
|
-
// click on Enter/Space — the native `.click()` fires our own `onClick`
|
|
3435
|
-
// handler with a genuine `MouseEvent`, so we don't have to fabricate one
|
|
3436
|
-
// from a keyboard event.
|
|
3437
3518
|
const handleKeyDown = (event) => {
|
|
3438
3519
|
if (event.repeat) {
|
|
3439
3520
|
return;
|
|
@@ -3451,20 +3532,15 @@ const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "inf
|
|
|
3451
3532
|
onKeyDown: handleKeyDown,
|
|
3452
3533
|
}
|
|
3453
3534
|
: {};
|
|
3454
|
-
|
|
3535
|
+
const content = (jsxRuntime.jsxs("div", { className: cvaCardContentRow(), children: [jsxRuntime.jsxs("div", { className: cvaCardMain({ singleLine: isSingleLine }), children: [showImage ? (jsxRuntime.jsx("div", { className: cvaCardImage(), "data-testid": dataTestId ? `${dataTestId}-image` : undefined, style: imageSlotStyle, children: image })) : null, showThumbnail ? (jsxRuntime.jsx("div", { className: cvaCardThumbnail({
|
|
3536
|
+
className: `text-${thumbnailColor} bg-${thumbnailBackground}`,
|
|
3537
|
+
}), "data-testid": dataTestId ? `${dataTestId}-thumbnail` : undefined, children: thumbnail })) : null, jsxRuntime.jsxs("div", { className: cvaCardTextStack(), ref: textStackRef, children: [jsxRuntime.jsxs("div", { className: cvaCardIdentityGroup({ singleLine: isSingleLine }), "data-testid": dataTestId ? `${dataTestId}-identity-group` : undefined, children: [jsxRuntime.jsxs("div", { className: cvaCardTitleRow(), children: [jsxRuntime.jsx("div", { className: cvaCardTitleCluster(), children: jsxRuntime.jsx("h3", { className: cvaCardTitle(), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, id: titleId, style: { textWrap: "nowrap" }, title: title, children: title }) }), hasConnectivitySlot ? (jsxRuntime.jsx("div", { className: cvaCardConnectivity(), "data-testid": dataTestId ? `${dataTestId}-connectivity` : undefined, children: connectivity })) : null] }), subtitle !== undefined && subtitle.length > 0 ? (jsxRuntime.jsx(DetailsList, { "data-testid": dataTestId ? `${dataTestId}-subtitle` : undefined, details: subtitle })) : null] }), hasStatusSlot ? (jsxRuntime.jsx("div", { className: cvaCardStatusRow(), "data-testid": dataTestId ? `${dataTestId}-status` : undefined, children: statusIndicators })) : null] })] }), showChevron ? (jsxRuntime.jsx("div", { className: cvaCardChevron(), "data-testid": dataTestId ? `${dataTestId}-chevron` : undefined, children: jsxRuntime.jsx(Icon, { name: "ChevronRight", size: "medium" }) })) : null] }));
|
|
3538
|
+
return (jsxRuntime.jsx(Card, { className: hasLink || isClickable
|
|
3455
3539
|
? cvaInteractableItem({
|
|
3456
3540
|
cursor: "pointer",
|
|
3457
|
-
className: ["focus-visible:outline-native", cvaCardRoot({ className })],
|
|
3541
|
+
className: [...(isClickable ? ["focus-visible:outline-native"] : []), cvaCardRoot({ className })],
|
|
3458
3542
|
})
|
|
3459
|
-
: cvaCardRoot({ className }), "data-testid": dataTestId, onClick: onClick, ref: ref, style: style, ...clickableProps, children:
|
|
3460
|
-
className: `text-${thumbnailColor} bg-${thumbnailBackground}`,
|
|
3461
|
-
}), "data-testid": dataTestId ? `${dataTestId}-thumbnail` : undefined, children: thumbnail })) : null, jsxRuntime.jsxs("div", { className: cvaCardTextStack(), ref: textStackRef, children: [jsxRuntime.jsxs("div", { className: cvaCardIdentityGroup({ singleLine: isSingleLine }), "data-testid": dataTestId ? `${dataTestId}-identity-group` : undefined, children: [jsxRuntime.jsxs("div", { className: cvaCardTitleRow(), children: [jsxRuntime.jsx("div", { className: cvaCardTitleCluster(), children: jsxRuntime.jsx("h3", { className: cvaCardTitle(), "data-testid": dataTestId ? `${dataTestId}-title` : undefined,
|
|
3462
|
-
// Inline text-wrap defeats the unlayered global
|
|
3463
|
-
// `h1,h2,h3,h4 { text-wrap: balance }` rule from
|
|
3464
|
-
// `@trackunit/css-core` — otherwise a wrapping title
|
|
3465
|
-
// fights the `truncate` on the same element and the
|
|
3466
|
-
// ellipsis never appears.
|
|
3467
|
-
style: { textWrap: "nowrap" }, title: title, children: title }) }), hasConnectivitySlot ? (jsxRuntime.jsx("div", { className: cvaCardConnectivity(), "data-testid": dataTestId ? `${dataTestId}-connectivity` : undefined, children: connectivity })) : null] }), subtitle !== undefined && subtitle.length > 0 ? (jsxRuntime.jsx(DetailsList, { "data-testid": dataTestId ? `${dataTestId}-subtitle` : undefined, details: subtitle })) : null] }), hasStatusSlot ? (jsxRuntime.jsx("div", { className: cvaCardStatusRow(), "data-testid": dataTestId ? `${dataTestId}-status` : undefined, children: statusIndicators })) : null] })] }), isClickable ? (jsxRuntime.jsx("div", { className: cvaCardChevron(), "data-testid": dataTestId ? `${dataTestId}-chevron` : undefined, children: jsxRuntime.jsx(Icon, { name: "ChevronRight", size: "medium" }) })) : null] }) }));
|
|
3543
|
+
: cvaCardRoot({ className }), "data-testid": dataTestId, onClick: isClickable ? onClick : undefined, ref: ref, style: style, ...clickableProps, children: hasLink ? (jsxRuntime.jsx(IdentityCardAnchor, { labelledBy: titleId, link: link, children: content })) : (content) }));
|
|
3468
3544
|
};
|
|
3469
3545
|
|
|
3470
3546
|
/**
|
|
@@ -3697,7 +3773,7 @@ SkeletonLabel.displayName = "SkeletonLabel";
|
|
|
3697
3773
|
*
|
|
3698
3774
|
* The slot toggles (`hasImage`, `hasThumbnail`, `hasSubtitle`,
|
|
3699
3775
|
* `hasStatusIndicators`, `hasConnectivity`, `hasChevron`) are the skeleton
|
|
3700
|
-
* counterparts to the loaded `IdentityCard`'s slot props / `onClick` —
|
|
3776
|
+
* counterparts to the loaded `IdentityCard`'s slot props / `link` or `onClick` —
|
|
3701
3777
|
* flip on the slots you'll render once the data resolves.
|
|
3702
3778
|
*
|
|
3703
3779
|
* ### When to use
|
package/index.esm.js
CHANGED
|
@@ -3189,6 +3189,16 @@ const cvaCardIdentityGroup = cva({
|
|
|
3189
3189
|
singleLine: false,
|
|
3190
3190
|
},
|
|
3191
3191
|
});
|
|
3192
|
+
const cvaCardLink = cva({
|
|
3193
|
+
base: [
|
|
3194
|
+
"block",
|
|
3195
|
+
"w-full",
|
|
3196
|
+
"min-w-0",
|
|
3197
|
+
"text-inherit",
|
|
3198
|
+
"no-underline",
|
|
3199
|
+
"focus-visible:outline-none",
|
|
3200
|
+
],
|
|
3201
|
+
});
|
|
3192
3202
|
// Top row inside the identity group: title on the left, connectivity slot
|
|
3193
3203
|
// on the right. Isolating connectivity to this row means the subtitle and
|
|
3194
3204
|
// status rows below get the full text-stack width.
|
|
@@ -3255,6 +3265,72 @@ const cvaCardChevron = cva({
|
|
|
3255
3265
|
base: ["shrink-0", "self-center", "flex", "items-center", "text-neutral-500"],
|
|
3256
3266
|
});
|
|
3257
3267
|
|
|
3268
|
+
/**
|
|
3269
|
+
* Wraps the content of an `IdentityCard` in a real anchor, following the
|
|
3270
|
+
* `IdentityCell` link pattern: the address resolves asynchronously, a plain
|
|
3271
|
+
* click and Enter navigate through `goto`, and modifier clicks are left to
|
|
3272
|
+
* the browser. Middle-click arrives as `auxclick`, not `click`, so it has its
|
|
3273
|
+
* own handler. The link is named after the card title through
|
|
3274
|
+
* `aria-labelledby`, so the subtitle and slot content do not become part of
|
|
3275
|
+
* the accessible name.
|
|
3276
|
+
*
|
|
3277
|
+
* The `href` is omitted until a non-empty address resolves for the current
|
|
3278
|
+
* `link`: React drops an empty-string `href` with a console error, and a
|
|
3279
|
+
* stale address from a previous `link` must never be offered. While there is
|
|
3280
|
+
* no `href` the anchor stays keyboard-reachable (`role="link"`, Enter) and a
|
|
3281
|
+
* modifier click falls back to `goto`, because the browser has nothing to open.
|
|
3282
|
+
*
|
|
3283
|
+
* A failed address lookup is treated like an empty address.
|
|
3284
|
+
*
|
|
3285
|
+
* @param {IdentityCardAnchorProps} props - The props for the IdentityCardAnchor component
|
|
3286
|
+
* @returns {ReactElement} IdentityCardAnchor component
|
|
3287
|
+
*/
|
|
3288
|
+
const IdentityCardAnchor = ({ link, labelledBy, children }) => {
|
|
3289
|
+
const [resolved, setResolved] = useState(undefined);
|
|
3290
|
+
useEffect(() => {
|
|
3291
|
+
let isStale = false;
|
|
3292
|
+
void link
|
|
3293
|
+
.href()
|
|
3294
|
+
.catch(() => "")
|
|
3295
|
+
.then(resolvedHref => {
|
|
3296
|
+
if (!isStale) {
|
|
3297
|
+
setResolved({ source: link, href: resolvedHref });
|
|
3298
|
+
}
|
|
3299
|
+
});
|
|
3300
|
+
return () => {
|
|
3301
|
+
isStale = true;
|
|
3302
|
+
};
|
|
3303
|
+
}, [link]);
|
|
3304
|
+
const href = resolved !== undefined && resolved.source === link && resolved.href !== "" ? resolved.href : undefined;
|
|
3305
|
+
const hasHref = href !== undefined;
|
|
3306
|
+
const handleClick = (event) => {
|
|
3307
|
+
event.stopPropagation();
|
|
3308
|
+
if (hasHref && (event.ctrlKey || event.metaKey || event.shiftKey)) {
|
|
3309
|
+
link.onActivate?.();
|
|
3310
|
+
return;
|
|
3311
|
+
}
|
|
3312
|
+
event.preventDefault();
|
|
3313
|
+
void link.goto();
|
|
3314
|
+
link.onActivate?.();
|
|
3315
|
+
};
|
|
3316
|
+
const handleAuxClick = (event) => {
|
|
3317
|
+
if (!hasHref || event.button !== 1) {
|
|
3318
|
+
return;
|
|
3319
|
+
}
|
|
3320
|
+
event.stopPropagation();
|
|
3321
|
+
link.onActivate?.();
|
|
3322
|
+
};
|
|
3323
|
+
const handleKeyDown = (event) => {
|
|
3324
|
+
if (event.repeat || event.key !== "Enter") {
|
|
3325
|
+
return;
|
|
3326
|
+
}
|
|
3327
|
+
event.preventDefault();
|
|
3328
|
+
event.currentTarget.click();
|
|
3329
|
+
};
|
|
3330
|
+
const withoutHrefProps = hasHref ? {} : { role: "link", tabIndex: 0, onKeyDown: handleKeyDown };
|
|
3331
|
+
return (jsx("a", { "aria-labelledby": labelledBy, className: cvaCardLink(), href: href, onAuxClick: handleAuxClick, onClick: handleClick, rel: "noreferrer", target: "_blank", ...withoutHrefProps, children: children }));
|
|
3332
|
+
};
|
|
3333
|
+
|
|
3258
3334
|
// Minimum asset-image height (in px). Matches the natural text-stack height
|
|
3259
3335
|
// of a title + subtitle row (h3 `leading-6` + `gap-1` + `text-xs`
|
|
3260
3336
|
// line-height) so a title-only identity never collapses the image to the
|
|
@@ -3321,14 +3397,15 @@ const useIdentityImageSize = (enabled) => {
|
|
|
3321
3397
|
* entity (an asset, site, customer, user, …) from inside a surface whose
|
|
3322
3398
|
* real focus is something else (an alert, service ticket, inspection, …).
|
|
3323
3399
|
*
|
|
3324
|
-
* When `
|
|
3400
|
+
* When `link` is supplied, the whole card becomes one anchor and a
|
|
3325
3401
|
* `ChevronRight` icon is rendered on the right edge to signal navigation.
|
|
3326
|
-
*
|
|
3327
|
-
*
|
|
3328
|
-
*
|
|
3329
|
-
*
|
|
3330
|
-
*
|
|
3331
|
-
*
|
|
3402
|
+
* Linked cards route the user to the referenced entity's own page: a plain
|
|
3403
|
+
* click and Enter navigate in the current tab through `link.goto` (pair it
|
|
3404
|
+
* with `useNavigateInHost` from `@trackunit/react-core-hooks`), while
|
|
3405
|
+
* right-click "Open in new tab" and Cmd/Ctrl/Shift/middle-click open the
|
|
3406
|
+
* resolved `link.href` in a new tab. `onClick` makes the card a
|
|
3407
|
+
* keyboard-operable button instead, but it cannot open a new tab. Without
|
|
3408
|
+
* `link` or `onClick` the card is a static, non-interactive reference.
|
|
3332
3409
|
*
|
|
3333
3410
|
* The card stays presentational: it owns layout only; domain hydration
|
|
3334
3411
|
* (indicator wiring, translations, last-seen formatting,
|
|
@@ -3351,13 +3428,21 @@ const useIdentityImageSize = (enabled) => {
|
|
|
3351
3428
|
* page-level asset header). The card is a reference that lives *inside*
|
|
3352
3429
|
* someone else's content.
|
|
3353
3430
|
*
|
|
3354
|
-
* @example
|
|
3431
|
+
* @example Linked asset reference inside a service ticket panel
|
|
3355
3432
|
* ```tsx
|
|
3356
3433
|
* import { IdentityCard, Highlight } from "@trackunit/react-components";
|
|
3357
3434
|
* import { useNavigateInHost } from "@trackunit/react-core-hooks";
|
|
3435
|
+
* import { useMemo } from "react";
|
|
3358
3436
|
*
|
|
3359
3437
|
* const ServicedAssetRow = ({ assetId }: { assetId: string }) => {
|
|
3360
|
-
* const { gotoAssetHome } = useNavigateInHost();
|
|
3438
|
+
* const { getAssetHomeUrl, gotoAssetHome } = useNavigateInHost();
|
|
3439
|
+
* const link = useMemo(
|
|
3440
|
+
* () => ({
|
|
3441
|
+
* href: async () => (await getAssetHomeUrl(assetId)) ?? "",
|
|
3442
|
+
* goto: () => gotoAssetHome(assetId),
|
|
3443
|
+
* }),
|
|
3444
|
+
* [assetId, getAssetHomeUrl, gotoAssetHome]
|
|
3445
|
+
* );
|
|
3361
3446
|
* return (
|
|
3362
3447
|
* <IdentityCard
|
|
3363
3448
|
* title="Trackunit-AWP343"
|
|
@@ -3374,12 +3459,12 @@ const useIdentityImageSize = (enabled) => {
|
|
|
3374
3459
|
* </Highlight>
|
|
3375
3460
|
* </>
|
|
3376
3461
|
* }
|
|
3377
|
-
*
|
|
3462
|
+
* link={link}
|
|
3378
3463
|
* />
|
|
3379
3464
|
* );
|
|
3380
3465
|
* };
|
|
3381
3466
|
* ```
|
|
3382
|
-
* @example
|
|
3467
|
+
* @example Static reference without a link (chevron omitted)
|
|
3383
3468
|
* ```tsx
|
|
3384
3469
|
* <IdentityCard
|
|
3385
3470
|
* image={<OEMModelImage brandName="Trackunit" model="GS4390" />}
|
|
@@ -3397,13 +3482,13 @@ const useIdentityImageSize = (enabled) => {
|
|
|
3397
3482
|
* thumbnail={<Icon name="ConstructionCone" />}
|
|
3398
3483
|
* thumbnailColor="site_construction_site-500"
|
|
3399
3484
|
* thumbnailBackground="site_construction_site-100"
|
|
3400
|
-
*
|
|
3485
|
+
* link={siteLink}
|
|
3401
3486
|
* />
|
|
3402
3487
|
* ```
|
|
3403
3488
|
* @param {IdentityCardProps} props - The props for the IdentityCard component
|
|
3404
3489
|
* @returns {ReactElement} IdentityCard component
|
|
3405
3490
|
*/
|
|
3406
|
-
const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "info-600", thumbnailBackground = "info-100", statusIndicators, connectivity, onClick, className, "data-testid": dataTestId, style, ref, }) => {
|
|
3491
|
+
const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "info-600", thumbnailBackground = "info-100", statusIndicators, connectivity, onClick, link, className, "data-testid": dataTestId, style, ref, }) => {
|
|
3407
3492
|
const hasSubtitleRow = subtitle !== undefined && subtitle.length > 0;
|
|
3408
3493
|
const showImage = image !== null && image !== undefined;
|
|
3409
3494
|
// `image` and `thumbnail` are mutually exclusive slots — the 14:9 asset
|
|
@@ -3414,7 +3499,10 @@ const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "inf
|
|
|
3414
3499
|
const showThumbnail = !showImage && thumbnail !== undefined;
|
|
3415
3500
|
const hasConnectivitySlot = connectivity !== null && connectivity !== undefined;
|
|
3416
3501
|
const hasStatusSlot = statusIndicators !== null && statusIndicators !== undefined;
|
|
3417
|
-
const
|
|
3502
|
+
const hasLink = link !== undefined;
|
|
3503
|
+
const isClickable = !hasLink && onClick !== undefined;
|
|
3504
|
+
const showChevron = hasLink || isClickable;
|
|
3505
|
+
const titleId = useId();
|
|
3418
3506
|
// Single-line layout kicks in when the text stack renders the title row
|
|
3419
3507
|
// only — no subtitle or status row. The `connectivity` slot lives on the
|
|
3420
3508
|
// title row itself, so it doesn't add a line and doesn't disqualify the
|
|
@@ -3426,13 +3514,6 @@ const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "inf
|
|
|
3426
3514
|
// stays in sync — the skeleton → loaded transition jumps otherwise.
|
|
3427
3515
|
const { imageSize, textStackRef } = useIdentityImageSize(showImage);
|
|
3428
3516
|
const imageSlotStyle = showImage && imageSize !== null ? { height: imageSize.height, width: imageSize.width } : undefined;
|
|
3429
|
-
// Keyboard activation for the clickable branch. `Card` renders a `div`
|
|
3430
|
-
// with `role="region"` by default, so on its own it can't be reached with
|
|
3431
|
-
// Tab and Enter/Space wouldn't fire `onClick`. When we're clickable, opt
|
|
3432
|
-
// into button semantics (focusable, activatable) and dispatch a real
|
|
3433
|
-
// click on Enter/Space — the native `.click()` fires our own `onClick`
|
|
3434
|
-
// handler with a genuine `MouseEvent`, so we don't have to fabricate one
|
|
3435
|
-
// from a keyboard event.
|
|
3436
3517
|
const handleKeyDown = (event) => {
|
|
3437
3518
|
if (event.repeat) {
|
|
3438
3519
|
return;
|
|
@@ -3450,20 +3531,15 @@ const IdentityCard = ({ title, subtitle, image, thumbnail, thumbnailColor = "inf
|
|
|
3450
3531
|
onKeyDown: handleKeyDown,
|
|
3451
3532
|
}
|
|
3452
3533
|
: {};
|
|
3453
|
-
|
|
3534
|
+
const content = (jsxs("div", { className: cvaCardContentRow(), children: [jsxs("div", { className: cvaCardMain({ singleLine: isSingleLine }), children: [showImage ? (jsx("div", { className: cvaCardImage(), "data-testid": dataTestId ? `${dataTestId}-image` : undefined, style: imageSlotStyle, children: image })) : null, showThumbnail ? (jsx("div", { className: cvaCardThumbnail({
|
|
3535
|
+
className: `text-${thumbnailColor} bg-${thumbnailBackground}`,
|
|
3536
|
+
}), "data-testid": dataTestId ? `${dataTestId}-thumbnail` : undefined, children: thumbnail })) : null, jsxs("div", { className: cvaCardTextStack(), ref: textStackRef, children: [jsxs("div", { className: cvaCardIdentityGroup({ singleLine: isSingleLine }), "data-testid": dataTestId ? `${dataTestId}-identity-group` : undefined, children: [jsxs("div", { className: cvaCardTitleRow(), children: [jsx("div", { className: cvaCardTitleCluster(), children: jsx("h3", { className: cvaCardTitle(), "data-testid": dataTestId ? `${dataTestId}-title` : undefined, id: titleId, style: { textWrap: "nowrap" }, title: title, children: title }) }), hasConnectivitySlot ? (jsx("div", { className: cvaCardConnectivity(), "data-testid": dataTestId ? `${dataTestId}-connectivity` : undefined, children: connectivity })) : null] }), subtitle !== undefined && subtitle.length > 0 ? (jsx(DetailsList, { "data-testid": dataTestId ? `${dataTestId}-subtitle` : undefined, details: subtitle })) : null] }), hasStatusSlot ? (jsx("div", { className: cvaCardStatusRow(), "data-testid": dataTestId ? `${dataTestId}-status` : undefined, children: statusIndicators })) : null] })] }), showChevron ? (jsx("div", { className: cvaCardChevron(), "data-testid": dataTestId ? `${dataTestId}-chevron` : undefined, children: jsx(Icon, { name: "ChevronRight", size: "medium" }) })) : null] }));
|
|
3537
|
+
return (jsx(Card, { className: hasLink || isClickable
|
|
3454
3538
|
? cvaInteractableItem({
|
|
3455
3539
|
cursor: "pointer",
|
|
3456
|
-
className: ["focus-visible:outline-native", cvaCardRoot({ className })],
|
|
3540
|
+
className: [...(isClickable ? ["focus-visible:outline-native"] : []), cvaCardRoot({ className })],
|
|
3457
3541
|
})
|
|
3458
|
-
: cvaCardRoot({ className }), "data-testid": dataTestId, onClick: onClick, ref: ref, style: style, ...clickableProps, children:
|
|
3459
|
-
className: `text-${thumbnailColor} bg-${thumbnailBackground}`,
|
|
3460
|
-
}), "data-testid": dataTestId ? `${dataTestId}-thumbnail` : undefined, children: thumbnail })) : null, jsxs("div", { className: cvaCardTextStack(), ref: textStackRef, children: [jsxs("div", { className: cvaCardIdentityGroup({ singleLine: isSingleLine }), "data-testid": dataTestId ? `${dataTestId}-identity-group` : undefined, children: [jsxs("div", { className: cvaCardTitleRow(), children: [jsx("div", { className: cvaCardTitleCluster(), children: jsx("h3", { className: cvaCardTitle(), "data-testid": dataTestId ? `${dataTestId}-title` : undefined,
|
|
3461
|
-
// Inline text-wrap defeats the unlayered global
|
|
3462
|
-
// `h1,h2,h3,h4 { text-wrap: balance }` rule from
|
|
3463
|
-
// `@trackunit/css-core` — otherwise a wrapping title
|
|
3464
|
-
// fights the `truncate` on the same element and the
|
|
3465
|
-
// ellipsis never appears.
|
|
3466
|
-
style: { textWrap: "nowrap" }, title: title, children: title }) }), hasConnectivitySlot ? (jsx("div", { className: cvaCardConnectivity(), "data-testid": dataTestId ? `${dataTestId}-connectivity` : undefined, children: connectivity })) : null] }), subtitle !== undefined && subtitle.length > 0 ? (jsx(DetailsList, { "data-testid": dataTestId ? `${dataTestId}-subtitle` : undefined, details: subtitle })) : null] }), hasStatusSlot ? (jsx("div", { className: cvaCardStatusRow(), "data-testid": dataTestId ? `${dataTestId}-status` : undefined, children: statusIndicators })) : null] })] }), isClickable ? (jsx("div", { className: cvaCardChevron(), "data-testid": dataTestId ? `${dataTestId}-chevron` : undefined, children: jsx(Icon, { name: "ChevronRight", size: "medium" }) })) : null] }) }));
|
|
3542
|
+
: cvaCardRoot({ className }), "data-testid": dataTestId, onClick: isClickable ? onClick : undefined, ref: ref, style: style, ...clickableProps, children: hasLink ? (jsx(IdentityCardAnchor, { labelledBy: titleId, link: link, children: content })) : (content) }));
|
|
3467
3543
|
};
|
|
3468
3544
|
|
|
3469
3545
|
/**
|
|
@@ -3696,7 +3772,7 @@ SkeletonLabel.displayName = "SkeletonLabel";
|
|
|
3696
3772
|
*
|
|
3697
3773
|
* The slot toggles (`hasImage`, `hasThumbnail`, `hasSubtitle`,
|
|
3698
3774
|
* `hasStatusIndicators`, `hasConnectivity`, `hasChevron`) are the skeleton
|
|
3699
|
-
* counterparts to the loaded `IdentityCard`'s slot props / `onClick` —
|
|
3775
|
+
* counterparts to the loaded `IdentityCard`'s slot props / `link` or `onClick` —
|
|
3700
3776
|
* flip on the slots you'll render once the data resolves.
|
|
3701
3777
|
*
|
|
3702
3778
|
* ### When to use
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-router-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.50",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/css-class-variance-utilities": "2.6.
|
|
11
|
-
"@trackunit/i18n-library-translation": "2.14.
|
|
12
|
-
"@trackunit/react-components": "6.
|
|
13
|
-
"@trackunit/react-drawer": "2.17.
|
|
14
|
-
"@trackunit/shared-utils": "1.22.
|
|
10
|
+
"@trackunit/css-class-variance-utilities": "2.6.50",
|
|
11
|
+
"@trackunit/i18n-library-translation": "2.14.43",
|
|
12
|
+
"@trackunit/react-components": "6.1.1",
|
|
13
|
+
"@trackunit/react-drawer": "2.17.48",
|
|
14
|
+
"@trackunit/shared-utils": "1.22.50",
|
|
15
15
|
"dequal": "^2.0.3",
|
|
16
16
|
"zod": "^3.25.76"
|
|
17
17
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"@floating-ui/react": "^0.26.25",
|
|
15
15
|
"string-ts": "^2.0.0",
|
|
16
16
|
"tailwind-merge": "^3.7.0",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.21.
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "2.6.
|
|
19
|
-
"@trackunit/shared-utils": "1.22.
|
|
20
|
-
"@trackunit/ui-icons": "1.20.
|
|
17
|
+
"@trackunit/ui-design-tokens": "1.21.48",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "2.6.50",
|
|
19
|
+
"@trackunit/shared-utils": "1.22.50",
|
|
20
|
+
"@trackunit/ui-icons": "1.20.48",
|
|
21
21
|
"es-toolkit": "^1.52.0",
|
|
22
22
|
"@tanstack/react-virtual": "^3.14.13",
|
|
23
23
|
"fflate": "^0.8.3",
|
|
24
24
|
"zod": "^3.25.76",
|
|
25
|
-
"@trackunit/i18n-library-translation": "2.14.
|
|
25
|
+
"@trackunit/i18n-library-translation": "2.14.43"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "^19.0.0",
|
|
@@ -3,6 +3,8 @@ import { MouseEventHandler, ReactElement, ReactNode } from "react";
|
|
|
3
3
|
import { CommonProps } from "../../common/CommonProps";
|
|
4
4
|
import { Refable } from "../../common/Refable";
|
|
5
5
|
import type { Styleable } from "../../common/Styleable";
|
|
6
|
+
import { IdentityCardLink } from "./IdentityCardAnchor";
|
|
7
|
+
export type { IdentityCardLink };
|
|
6
8
|
type ThemeColorShades = `${keyof (typeof tailwindPalette)[keyof typeof tailwindPalette]}`;
|
|
7
9
|
export interface IdentityCardProps extends CommonProps, Styleable, Refable<HTMLDivElement> {
|
|
8
10
|
/**
|
|
@@ -78,6 +80,20 @@ export interface IdentityCardProps extends CommonProps, Styleable, Refable<HTMLD
|
|
|
78
80
|
* Space fire the handler alongside pointer clicks.
|
|
79
81
|
*/
|
|
80
82
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
83
|
+
/**
|
|
84
|
+
* Makes the card a real link to the referenced entity, so right-click
|
|
85
|
+
* "Open in new tab", Cmd/Ctrl-click, Shift-click and middle-click work.
|
|
86
|
+
* Same shape as the `link` of the table `IdentityCell`, plus an optional
|
|
87
|
+
* `onActivate` callback for analytics.
|
|
88
|
+
*
|
|
89
|
+
* The whole card becomes one anchor and the `ChevronRight` affordance is
|
|
90
|
+
* rendered. A plain click and Enter call `link.goto` and stay in the
|
|
91
|
+
* current tab; Space does nothing. `onClick` is not used when `link` is set.
|
|
92
|
+
*
|
|
93
|
+
* Do not place interactive elements in `statusIndicators` or `connectivity`
|
|
94
|
+
* of a linked card: they would be nested inside the anchor.
|
|
95
|
+
*/
|
|
96
|
+
link?: IdentityCardLink;
|
|
81
97
|
}
|
|
82
98
|
/**
|
|
83
99
|
* IdentityCard is the entity-agnostic, `Card`-wrapped identity component.
|
|
@@ -87,14 +103,15 @@ export interface IdentityCardProps extends CommonProps, Styleable, Refable<HTMLD
|
|
|
87
103
|
* entity (an asset, site, customer, user, …) from inside a surface whose
|
|
88
104
|
* real focus is something else (an alert, service ticket, inspection, …).
|
|
89
105
|
*
|
|
90
|
-
* When `
|
|
106
|
+
* When `link` is supplied, the whole card becomes one anchor and a
|
|
91
107
|
* `ChevronRight` icon is rendered on the right edge to signal navigation.
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
108
|
+
* Linked cards route the user to the referenced entity's own page: a plain
|
|
109
|
+
* click and Enter navigate in the current tab through `link.goto` (pair it
|
|
110
|
+
* with `useNavigateInHost` from `@trackunit/react-core-hooks`), while
|
|
111
|
+
* right-click "Open in new tab" and Cmd/Ctrl/Shift/middle-click open the
|
|
112
|
+
* resolved `link.href` in a new tab. `onClick` makes the card a
|
|
113
|
+
* keyboard-operable button instead, but it cannot open a new tab. Without
|
|
114
|
+
* `link` or `onClick` the card is a static, non-interactive reference.
|
|
98
115
|
*
|
|
99
116
|
* The card stays presentational: it owns layout only; domain hydration
|
|
100
117
|
* (indicator wiring, translations, last-seen formatting,
|
|
@@ -117,13 +134,21 @@ export interface IdentityCardProps extends CommonProps, Styleable, Refable<HTMLD
|
|
|
117
134
|
* page-level asset header). The card is a reference that lives *inside*
|
|
118
135
|
* someone else's content.
|
|
119
136
|
*
|
|
120
|
-
* @example
|
|
137
|
+
* @example Linked asset reference inside a service ticket panel
|
|
121
138
|
* ```tsx
|
|
122
139
|
* import { IdentityCard, Highlight } from "@trackunit/react-components";
|
|
123
140
|
* import { useNavigateInHost } from "@trackunit/react-core-hooks";
|
|
141
|
+
* import { useMemo } from "react";
|
|
124
142
|
*
|
|
125
143
|
* const ServicedAssetRow = ({ assetId }: { assetId: string }) => {
|
|
126
|
-
* const { gotoAssetHome } = useNavigateInHost();
|
|
144
|
+
* const { getAssetHomeUrl, gotoAssetHome } = useNavigateInHost();
|
|
145
|
+
* const link = useMemo(
|
|
146
|
+
* () => ({
|
|
147
|
+
* href: async () => (await getAssetHomeUrl(assetId)) ?? "",
|
|
148
|
+
* goto: () => gotoAssetHome(assetId),
|
|
149
|
+
* }),
|
|
150
|
+
* [assetId, getAssetHomeUrl, gotoAssetHome]
|
|
151
|
+
* );
|
|
127
152
|
* return (
|
|
128
153
|
* <IdentityCard
|
|
129
154
|
* title="Trackunit-AWP343"
|
|
@@ -140,12 +165,12 @@ export interface IdentityCardProps extends CommonProps, Styleable, Refable<HTMLD
|
|
|
140
165
|
* </Highlight>
|
|
141
166
|
* </>
|
|
142
167
|
* }
|
|
143
|
-
*
|
|
168
|
+
* link={link}
|
|
144
169
|
* />
|
|
145
170
|
* );
|
|
146
171
|
* };
|
|
147
172
|
* ```
|
|
148
|
-
* @example
|
|
173
|
+
* @example Static reference without a link (chevron omitted)
|
|
149
174
|
* ```tsx
|
|
150
175
|
* <IdentityCard
|
|
151
176
|
* image={<OEMModelImage brandName="Trackunit" model="GS4390" />}
|
|
@@ -163,11 +188,10 @@ export interface IdentityCardProps extends CommonProps, Styleable, Refable<HTMLD
|
|
|
163
188
|
* thumbnail={<Icon name="ConstructionCone" />}
|
|
164
189
|
* thumbnailColor="site_construction_site-500"
|
|
165
190
|
* thumbnailBackground="site_construction_site-100"
|
|
166
|
-
*
|
|
191
|
+
* link={siteLink}
|
|
167
192
|
* />
|
|
168
193
|
* ```
|
|
169
194
|
* @param {IdentityCardProps} props - The props for the IdentityCard component
|
|
170
195
|
* @returns {ReactElement} IdentityCard component
|
|
171
196
|
*/
|
|
172
|
-
export declare const IdentityCard: ({ title, subtitle, image, thumbnail, thumbnailColor, thumbnailBackground, statusIndicators, connectivity, onClick, className, "data-testid": dataTestId, style, ref, }: IdentityCardProps) => ReactElement;
|
|
173
|
-
export {};
|
|
197
|
+
export declare const IdentityCard: ({ title, subtitle, image, thumbnail, thumbnailColor, thumbnailBackground, statusIndicators, connectivity, onClick, link, className, "data-testid": dataTestId, style, ref, }: IdentityCardProps) => ReactElement;
|
|
@@ -82,6 +82,12 @@ export declare const cvaCardIdentityGroup: import("cva").CVAComponent<Omit<{
|
|
|
82
82
|
false: string;
|
|
83
83
|
};
|
|
84
84
|
}>;
|
|
85
|
+
export declare const cvaCardLink: import("cva").CVAComponent<Omit<{
|
|
86
|
+
base: string[];
|
|
87
|
+
}, "defaultVariants"> & {
|
|
88
|
+
variants: unknown;
|
|
89
|
+
defaultVariants: Omit<{}, never>;
|
|
90
|
+
}, unknown>;
|
|
85
91
|
export declare const cvaCardTitleRow: import("cva").CVAComponent<Omit<{
|
|
86
92
|
base: string[];
|
|
87
93
|
}, "defaultVariants"> & {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
export interface IdentityCardLink {
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the address the card links to. Used as the anchor `href`, so the
|
|
5
|
+
* browser can offer "Open in new tab" and handle modifier clicks.
|
|
6
|
+
* Memoize the `link` object to avoid resolving the address on every render.
|
|
7
|
+
*/
|
|
8
|
+
href: () => Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Navigates to the linked entity in the current tab. Called for a plain
|
|
11
|
+
* click and for Enter.
|
|
12
|
+
*/
|
|
13
|
+
goto: () => Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Called once for every activation the page can observe: plain click,
|
|
16
|
+
* Enter, modifier click and middle-click. Use it for analytics. A
|
|
17
|
+
* context-menu "Open in new tab" is not reported, the browser does not
|
|
18
|
+
* notify the page.
|
|
19
|
+
*/
|
|
20
|
+
onActivate?: () => void;
|
|
21
|
+
}
|
|
22
|
+
interface IdentityCardAnchorProps {
|
|
23
|
+
link: IdentityCardLink;
|
|
24
|
+
labelledBy: string;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wraps the content of an `IdentityCard` in a real anchor, following the
|
|
29
|
+
* `IdentityCell` link pattern: the address resolves asynchronously, a plain
|
|
30
|
+
* click and Enter navigate through `goto`, and modifier clicks are left to
|
|
31
|
+
* the browser. Middle-click arrives as `auxclick`, not `click`, so it has its
|
|
32
|
+
* own handler. The link is named after the card title through
|
|
33
|
+
* `aria-labelledby`, so the subtitle and slot content do not become part of
|
|
34
|
+
* the accessible name.
|
|
35
|
+
*
|
|
36
|
+
* The `href` is omitted until a non-empty address resolves for the current
|
|
37
|
+
* `link`: React drops an empty-string `href` with a console error, and a
|
|
38
|
+
* stale address from a previous `link` must never be offered. While there is
|
|
39
|
+
* no `href` the anchor stays keyboard-reachable (`role="link"`, Enter) and a
|
|
40
|
+
* modifier click falls back to `goto`, because the browser has nothing to open.
|
|
41
|
+
*
|
|
42
|
+
* A failed address lookup is treated like an empty address.
|
|
43
|
+
*
|
|
44
|
+
* @param {IdentityCardAnchorProps} props - The props for the IdentityCardAnchor component
|
|
45
|
+
* @returns {ReactElement} IdentityCardAnchor component
|
|
46
|
+
*/
|
|
47
|
+
export declare const IdentityCardAnchor: ({ link, labelledBy, children }: IdentityCardAnchorProps) => ReactElement;
|
|
48
|
+
export {};
|
|
@@ -66,7 +66,7 @@ export interface IdentityCardSkeletonProps extends CommonProps, Styleable, Refab
|
|
|
66
66
|
*
|
|
67
67
|
* The slot toggles (`hasImage`, `hasThumbnail`, `hasSubtitle`,
|
|
68
68
|
* `hasStatusIndicators`, `hasConnectivity`, `hasChevron`) are the skeleton
|
|
69
|
-
* counterparts to the loaded `IdentityCard`'s slot props / `onClick` —
|
|
69
|
+
* counterparts to the loaded `IdentityCard`'s slot props / `link` or `onClick` —
|
|
70
70
|
* flip on the slots you'll render once the data resolves.
|
|
71
71
|
*
|
|
72
72
|
* ### When to use
|