@trackunit/react-components 6.0.45 → 6.1.2-alpha-fbcc0881f4f.0
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/migrations/entry.js.map +1 -0
- package/migrations/utils/jsx-utils.js.map +1 -0
- package/migrations/utils/move-named-imports.js.map +1 -0
- package/migrations/utils/package-json-utils.js.map +1 -0
- package/migrations/v2-0-0/breadcrumb-remove-deprecated-props.js.map +1 -0
- package/migrations/v2-0-0/cardheader-onclickclose-to-actions.js.map +1 -0
- package/migrations/v2-0-0/iconbutton-add-required-name.js.map +1 -0
- package/migrations/v2-0-0/kpi-tooltiplabel-to-wrapper.js.map +1 -0
- package/migrations/v2-0-0/notice-tooltiplabel-to-wrapper.js.map +1 -0
- package/migrations/v2-0-0/pagination-add-required-titles.js.map +1 -0
- package/migrations/v2-0-0/tag-add-removetaglabel.js.map +1 -0
- package/migrations/v2-0-0/togglegroup-remove-item-style.js.map +1 -0
- package/migrations/v2-6-0/menulist-rename-to-menucontent.js.map +1 -0
- package/migrations/v3-0-0/copyabletext-to-text-copybutton.js.map +1 -0
- package/migrations/v4-0-0/move-to-router-components.js.map +1 -0
- 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.51-alpha-fbcc0881f4f.0",
|
|
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.0
|
|
13
|
-
"@trackunit/react-drawer": "2.17.
|
|
14
|
-
"@trackunit/shared-utils": "1.22.
|
|
10
|
+
"@trackunit/css-class-variance-utilities": "2.6.51-alpha-fbcc0881f4f.0",
|
|
11
|
+
"@trackunit/i18n-library-translation": "2.14.44-alpha-fbcc0881f4f.0",
|
|
12
|
+
"@trackunit/react-components": "6.1.2-alpha-fbcc0881f4f.0",
|
|
13
|
+
"@trackunit/react-drawer": "2.17.49-alpha-fbcc0881f4f.0",
|
|
14
|
+
"@trackunit/shared-utils": "1.22.51-alpha-fbcc0881f4f.0",
|
|
15
15
|
"dequal": "^2.0.3",
|
|
16
16
|
"zod": "^3.25.76"
|
|
17
17
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/components/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["// Migration entry point for @nx/js:tsc build target.\n// Migrations are registered in ../migrations.json and resolved by NX at runtime.\nexport {};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-utils.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/utils/jsx-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAqE;AACrE,+CAAiC;AAEjC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AACjD,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAEvD,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAW,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AACpG,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAW,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAA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AA,UAAU,cAUrB;AAEF;;;;;;GAMG;AACI,MAAM,6BAA6B,GAAG,CAC3C,OAAe,EACf,cAA+D,EAC/D,aAAqB,EACb,EAAE;IACV,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;IACvC,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IACnC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;AACtF,CAAC,CAAC;AARW,QAAA,6BAA6B,iCAQxC","sourcesContent":["import { logger, type Tree, visitNotIgnoredFiles } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\n\nconst TSX_EXTENSIONS = [\".tsx\", \".jsx\"] as const;\nconst TS_EXTENSIONS = [\".ts\", \".tsx\", \".jsx\"] as const;\n\nconst isTsxFile = (filePath: string): boolean => TSX_EXTENSIONS.some(ext => filePath.endsWith(ext));\nconst isTsFile = (filePath: string): boolean => TS_EXTENSIONS.some(ext => filePath.endsWith(ext));\n\nconst isUnderNodeModules = (filePath: string): boolean =>\n filePath.includes(\"/node_modules/\") || filePath.startsWith(\"node_modules/\");\n\nconst isUnderDist = (filePath: string): boolean =>\n filePath.includes(\"/dist/\") || filePath.startsWith(\"dist/\") || filePath.includes(\"/.nx/\");\n\n/**\n * Visits every `.tsx`/`.jsx` file under the workspace root and invokes the\n * callback with the file path and its current contents. Files that don't\n * include the marker substring are skipped, which makes large workspaces\n * cheap to scan.\n */\nexport const visitTsxFiles = (\n tree: Tree,\n marker: string,\n callback: (filePath: string, content: string) => string | null | undefined\n): number => {\n let touched = 0;\n visitNotIgnoredFiles(tree, \"/\", filePath => {\n if (!isTsxFile(filePath)) return;\n if (isUnderNodeModules(filePath) || isUnderDist(filePath)) return;\n const content = tree.read(filePath, \"utf-8\");\n if (content === null) return;\n if (!content.includes(marker)) return;\n const updated = callback(filePath, content);\n if (updated !== null && updated !== undefined && updated !== content) {\n tree.write(filePath, updated);\n touched += 1;\n }\n });\n return touched;\n};\n\n/**\n * Same as {@link visitTsxFiles} but also includes plain `.ts` files. Use this\n * when the codemod also rewrites non-JSX files such as helpers or hooks.\n */\nexport const visitTsFiles = (\n tree: Tree,\n marker: string,\n callback: (filePath: string, content: string) => string | null | undefined\n): number => {\n let touched = 0;\n visitNotIgnoredFiles(tree, \"/\", filePath => {\n if (!isTsFile(filePath)) return;\n if (isUnderNodeModules(filePath) || isUnderDist(filePath)) return;\n const content = tree.read(filePath, \"utf-8\");\n if (content === null) return;\n if (!content.includes(marker)) return;\n const updated = callback(filePath, content);\n if (updated !== null && updated !== undefined && updated !== content) {\n tree.write(filePath, updated);\n touched += 1;\n }\n });\n return touched;\n};\n\n/**\n * Mapping of imported component aliases to their original names for a given\n * package. For `import { IconButton as Btn } from \"@trackunit/react-components\"`\n * this returns `{ Btn: \"IconButton\" }`.\n *\n * Returns `null` when the file imports nothing from the package, which lets\n * callers short-circuit before parsing JSX.\n */\nexport const getImportedAliases = (sourceFile: ts.SourceFile, packageName: string): Record<string, string> | null => {\n const result: Record<string, string> = {};\n let found = false;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier)) continue;\n if (moduleSpecifier.text !== packageName) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n for (const element of namedBindings.elements) {\n const localName = element.name.text;\n const importedName = element.propertyName?.text ?? localName;\n result[localName] = importedName;\n found = true;\n }\n }\n\n return found ? result : null;\n};\n\n/**\n * Returns the local alias used in this file for `originalName` when imported\n * from `packageName`, or `null` if the component is not imported.\n */\nexport const getLocalAliasFor = (\n sourceFile: ts.SourceFile,\n packageName: string,\n originalName: string\n): string | null => {\n const aliases = getImportedAliases(sourceFile, packageName);\n if (aliases === null) return null;\n for (const [local, original] of Object.entries(aliases)) {\n if (original === originalName) return local;\n }\n return null;\n};\n\nexport type JsxElementMatch = {\n /** The opening JSX element (the one carrying the attributes). */\n openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement;\n /** The full element including children, or the self-closing element. */\n element: ts.JsxElement | ts.JsxSelfClosingElement;\n};\n\n/**\n * Finds every JSX element whose tag name resolves to one of `tagNames`\n * (typically the local aliases returned by {@link getImportedAliases}).\n *\n * The result intentionally includes both opening and full elements so callers\n * can manipulate attributes (via `openingElement`) or wrap/replace the whole\n * element (via `element`).\n */\nexport const findJsxElements = (\n sourceFile: ts.SourceFile,\n tagNames: ReadonlyArray<string>\n): ReadonlyArray<JsxElementMatch> => {\n const matches: Array<JsxElementMatch> = [];\n const tagSet = new Set(tagNames);\n\n const visit = (node: ts.Node): void => {\n if (ts.isJsxSelfClosingElement(node)) {\n if (ts.isIdentifier(node.tagName) && tagSet.has(node.tagName.text)) {\n matches.push({ openingElement: node, element: node });\n }\n } else if (ts.isJsxElement(node)) {\n const opening = node.openingElement;\n if (ts.isIdentifier(opening.tagName) && tagSet.has(opening.tagName.text)) {\n matches.push({ openingElement: opening, element: node });\n }\n }\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n return matches;\n};\n\n/**\n * Looks up a named JSX attribute on the opening element. Returns `null` when\n * the attribute is missing or part of a spread attribute (which we cannot\n * statically inspect).\n */\nexport const findJsxAttribute = (\n openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement,\n attributeName: string\n): ts.JsxAttribute | null => {\n for (const attr of openingElement.attributes.properties) {\n if (!ts.isJsxAttribute(attr)) continue;\n if (!ts.isIdentifier(attr.name)) continue;\n if (attr.name.text === attributeName) return attr;\n }\n return null;\n};\n\n/**\n * `true` when the element forwards a spread expression such as `{...rest}`,\n * which means we can't be sure which attributes are actually set.\n */\nexport const hasSpreadAttribute = (openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement): boolean => {\n return openingElement.attributes.properties.some(prop => ts.isJsxSpreadAttribute(prop));\n};\n\n/**\n * Parses the file as TSX so JSX is recognised. We do not need a full program\n * here; tsquery's `ast` helper produces a script-kind source file which loses\n * JSX context, so we go through `createSourceFile` directly.\n */\nexport const parseTsx = (content: string, fileName = \"file.tsx\"): ts.SourceFile =>\n ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);\n\n/**\n * Helper for codemods to log a one-line summary at the end of a run. Migration\n * runners aggregate logs per migration, so this keeps output focused.\n */\nexport const logSummary = (migrationName: string, touched: number, manualReviewNeeded?: number): void => {\n if (touched === 0) {\n logger.info(` ${migrationName}: no files changed`);\n return;\n }\n const reviewSuffix =\n manualReviewNeeded !== undefined && manualReviewNeeded > 0\n ? ` (${manualReviewNeeded} location(s) need manual review)`\n : \"\";\n logger.info(` ${migrationName}: updated ${touched} file(s)${reviewSuffix}`);\n};\n\n/**\n * Inserts an attribute string immediately after the tag name (so the new\n * attribute appears first). Returns the resulting source content.\n *\n * The added attribute is rendered verbatim, so callers are responsible for\n * including the leading space (e.g. ` title=\"Close\"`).\n */\nexport const insertAttributeIntoOpeningTag = (\n content: string,\n openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement,\n attributeText: string\n): string => {\n const tagName = openingElement.tagName;\n const insertPos = tagName.getEnd();\n return `${content.slice(0, insertPos)} ${attributeText}${content.slice(insertPos)}`;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-named-imports.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/utils/move-named-imports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA+C;AAC/C,+CAAiC;AACjC,2CAA2C;AAyC3C,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAClE,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC;IAChD,MAAM;IACN,QAAQ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AEF;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAU,EAAE,OAAgC,EAA0B,EAAE;IACvG,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,MAAM,YAAY,GAA4B,EAAE,CAAC;IAEjD,IAAA,wBAAY,EAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE;QAC3D,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAChE,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QAC1C,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO;YAAE,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AACxC,CAAC,CAAC;AAbW,QAAA,gBAAgB,oBAa3B;AAEF,mFAAmF;AAC5E,MAAM,eAAe,GAAG,CAAC,aAAqB,EAAE,KAAsC,EAAQ,EAAE;IACrG,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;QAC3C,eAAM,CAAC,IAAI,CAAC,KAAK,aAAa,6BAA6B,IAAI,IAAI,IAAI,MAAM,MAAM,EAAE,CAAC,CAAC;IACzF,CAAC;AACH,CAAC,CAAC;AAJW,QAAA,eAAe,mBAI1B","sourcesContent":["import { logger, type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport { visitTsFiles } from \"./jsx-utils\";\n\n/**\n * Names to move. A list keeps every name; a record maps each old exported\n * name to its new exported name in the target module.\n */\nexport type MovedNames = ReadonlyArray<string> | Readonly<Record<string, string>>;\n\nexport type MoveNamedImportsOptions = {\n /** Module the names are imported from today, e.g. `@trackunit/ui-connected-components`. */\n readonly fromModule: string;\n /** Module that exports the names now, e.g. `@trackunit/react-router-components`. */\n readonly toModule: string;\n readonly names: MovedNames;\n};\n\nexport type ManualReviewItem = {\n readonly file: string;\n /** 1-based line of the usage. */\n readonly line: number;\n readonly reason: string;\n};\n\nexport type MoveNamedImportsResult = {\n readonly changedFiles: ReadonlyArray<string>;\n /** Usages the codemod could not rewrite safely. They are left as-is and must be fixed by hand. */\n readonly manualReview: ReadonlyArray<ManualReviewItem>;\n};\n\ntype Edit = { start: number; end: number; text: string };\n\n/** A moved specifier as it should be written against the target module. */\ntype MovedSpecifier = {\n /** Exported name in the target module. */\n readonly imported: string;\n /** Local binding (imports) or public name (re-exports). */\n readonly local: string;\n /** `true` for an inline `type` modifier, or any specifier of an `import type` / `export type`. */\n readonly isTypeOnly: boolean;\n};\n\nconst MOCK_OBJECTS: ReadonlySet<string> = new Set([\"vi\", \"jest\"]);\nconst MOCK_METHODS: ReadonlySet<string> = new Set([\n \"mock\",\n \"doMock\",\n \"unmock\",\n \"doUnmock\",\n \"importActual\",\n \"importMock\",\n \"requireActual\",\n \"requireMock\",\n]);\n\nconst toRenameMap = (names: MovedNames): ReadonlyMap<string, string> =>\n Array.isArray(names) ? new Map(names.map(name => [name, name])) : new Map(Object.entries(names));\n\nconst parseSource = (filePath: string, content: string): ts.SourceFile =>\n ts.createSourceFile(\n filePath,\n content,\n ts.ScriptTarget.Latest,\n true,\n filePath.endsWith(\".ts\") ? ts.ScriptKind.TS : ts.ScriptKind.TSX\n );\n\nconst isModule = (node: ts.Expression | undefined, moduleName: string): boolean =>\n node !== undefined &&\n (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) &&\n node.text === moduleName;\n\n/** Renders `moduleName` with the quote style of an existing specifier. */\nconst quoteLike = (specifier: ts.Expression, moduleName: string): string => {\n const quote = specifier.getText().startsWith(\"'\") ? \"'\" : '\"';\n return `${quote}${moduleName}${quote}`;\n};\n\nconst renderSpecifier = ({ imported, local, isTypeOnly }: MovedSpecifier, withTypePrefix: boolean): string =>\n `${withTypePrefix && isTypeOnly ? \"type \" : \"\"}${imported === local ? imported : `${imported} as ${local}`}`;\n\nconst statementTerminator = (statement: ts.Statement): string => (statement.getText().endsWith(\";\") ? \";\" : \"\");\n\nconst lineOf = (sourceFile: ts.SourceFile, node: ts.Node): number =>\n sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;\n\n/** `true` when `node` is a property-like key (`a.X`, `{ X: 1 }`, `<C X=\"\" />`) rather than a reference to a binding. */\nconst isPropertyKey = (node: ts.Identifier): boolean => {\n const parent = node.parent;\n if (ts.isPropertyAccessExpression(parent) || ts.isQualifiedName(parent)) {\n return ts.isPropertyAccessExpression(parent) ? parent.name === node : parent.right === node;\n }\n if (ts.isBindingElement(parent)) return parent.propertyName === node;\n if (\n ts.isPropertyAssignment(parent) ||\n ts.isPropertyDeclaration(parent) ||\n ts.isPropertySignature(parent) ||\n ts.isMethodDeclaration(parent) ||\n ts.isMethodSignature(parent) ||\n ts.isGetAccessorDeclaration(parent) ||\n ts.isSetAccessorDeclaration(parent) ||\n ts.isEnumMember(parent) ||\n ts.isJsxAttribute(parent)\n ) {\n return parent.name === node;\n }\n return false;\n};\n\n/** `true` when `node` declares a new binding (variable, parameter, function, class, type...). */\nconst isBindingDeclaration = (node: ts.Identifier): boolean => {\n const parent = node.parent;\n if (ts.isBindingElement(parent)) return parent.name === node;\n if (\n ts.isVariableDeclaration(parent) ||\n ts.isParameter(parent) ||\n ts.isFunctionDeclaration(parent) ||\n ts.isFunctionExpression(parent) ||\n ts.isClassDeclaration(parent) ||\n ts.isClassExpression(parent) ||\n ts.isInterfaceDeclaration(parent) ||\n ts.isTypeAliasDeclaration(parent) ||\n ts.isEnumDeclaration(parent) ||\n ts.isTypeParameterDeclaration(parent) ||\n ts.isImportSpecifier(parent) ||\n ts.isImportClause(parent) ||\n ts.isNamespaceImport(parent) ||\n ts.isImportEqualsDeclaration(parent)\n ) {\n return parent.name === node;\n }\n return false;\n};\n\n/** Import and re-export statements are rewritten as a whole, so their identifiers are never edited one by one. */\nconst isInsideModuleStatement = (node: ts.Node): boolean =>\n ts.findAncestor(\n node,\n ancestor =>\n ts.isImportDeclaration(ancestor) || (ts.isExportDeclaration(ancestor) && ancestor.moduleSpecifier !== undefined)\n ) !== undefined;\n\nconst collectIdentifiers = (sourceFile: ts.SourceFile): ReadonlyArray<ts.Identifier> => {\n const identifiers: Array<ts.Identifier> = [];\n const visit = (node: ts.Node): void => {\n if (ts.isIdentifier(node)) identifiers.push(node);\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return identifiers;\n};\n\n/**\n * Edits that rename every reference to the local binding `oldName` to\n * `newName`, or `null` when that can't be done safely (the new name is\n * already used in the file, or `oldName` is redeclared and might be shadowed).\n */\nconst renameReferenceEdits = (\n sourceFile: ts.SourceFile,\n identifiers: ReadonlyArray<ts.Identifier>,\n oldName: string,\n newName: string\n): Array<Edit> | null => {\n if (identifiers.some(id => id.text === newName)) return null;\n const outside = identifiers.filter(id => id.text === oldName && !isInsideModuleStatement(id));\n if (outside.some(isBindingDeclaration)) return null;\n\n const edits: Array<Edit> = [];\n for (const id of outside) {\n if (isPropertyKey(id)) continue;\n const start = id.getStart(sourceFile);\n const end = id.getEnd();\n const parent = id.parent;\n if (ts.isShorthandPropertyAssignment(parent)) {\n edits.push({ start, end, text: `${oldName}: ${newName}` });\n } else if (ts.isExportSpecifier(parent)) {\n if (parent.propertyName === undefined) edits.push({ start, end, text: `${newName} as ${oldName}` });\n else if (parent.propertyName === id) edits.push({ start, end, text: newName });\n } else {\n edits.push({ start, end, text: newName });\n }\n }\n return edits;\n};\n\n/**\n * Usages of `fromModule` the codemod can't rewrite statically. They are only\n * reported when the file references a moved name at all, so e.g. a\n * `vi.mock(fromModule, ...)` in a spec that never touches a moved name is not\n * noise. `export *` is always reported: the moved names silently drop out of it.\n */\nconst findManualReviewItems = (\n sourceFile: ts.SourceFile,\n identifiers: ReadonlyArray<ts.Identifier>,\n fromModule: string,\n toModule: string,\n renames: ReadonlyMap<string, string>\n): Array<ManualReviewItem> => {\n const items: Array<ManualReviewItem> = [];\n const file = sourceFile.fileName;\n const mentionsMovedName =\n identifiers.some(id => renames.has(id.text)) || sourceFile.text.split(/[\"'`]/).some(chunk => renames.has(chunk));\n const movedList = [...renames.keys()].join(\", \");\n const hint = `moved names (${movedList}) now come from \"${toModule}\"`;\n\n const report = (node: ts.Node, what: string): void => {\n items.push({ file, line: lineOf(sourceFile, node), reason: `${what} of \"${fromModule}\"; ${hint}` });\n };\n\n const visit = (node: ts.Node): void => {\n if (ts.isImportDeclaration(node) && isModule(node.moduleSpecifier, fromModule)) {\n const bindings = node.importClause?.namedBindings;\n if (bindings !== undefined && ts.isNamespaceImport(bindings) && mentionsMovedName) {\n report(node, `namespace import \\`* as ${bindings.name.text}\\``);\n }\n } else if (ts.isExportDeclaration(node) && isModule(node.moduleSpecifier, fromModule)) {\n if (node.exportClause === undefined) report(node, \"`export *`\");\n else if (ts.isNamespaceExport(node.exportClause)) report(node, \"`export * as`\");\n } else if (ts.isImportEqualsDeclaration(node) && mentionsMovedName) {\n const reference = node.moduleReference;\n if (ts.isExternalModuleReference(reference) && isModule(reference.expression, fromModule)) {\n report(node, \"`import = require()`\");\n }\n } else if (ts.isImportTypeNode(node) && mentionsMovedName) {\n const argument = node.argument;\n if (ts.isLiteralTypeNode(argument) && isModule(argument.literal, fromModule)) report(node, \"`import()` type\");\n } else if (ts.isCallExpression(node) && mentionsMovedName && isModule(node.arguments[0], fromModule)) {\n const callee = node.expression;\n if (callee.kind === ts.SyntaxKind.ImportKeyword) {\n report(node, \"dynamic import()\");\n } else if (ts.isIdentifier(callee) && callee.text === \"require\") {\n report(node, \"require()\");\n } else if (\n ts.isPropertyAccessExpression(callee) &&\n ts.isIdentifier(callee.expression) &&\n MOCK_OBJECTS.has(callee.expression.text) &&\n MOCK_METHODS.has(callee.name.text)\n ) {\n report(node, `${callee.expression.text}.${callee.name.text}()`);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return items;\n};\n\ntype TargetImport = {\n readonly statement: ts.ImportDeclaration;\n readonly elements: ts.NodeArray<ts.ImportSpecifier>;\n readonly additions: Array<MovedSpecifier>;\n};\n\nconst findTargetImport = (sourceFile: ts.SourceFile, toModule: string, typeOnly: boolean): TargetImport | null => {\n for (const statement of sourceFile.statements) {\n if (!ts.isImportDeclaration(statement) || !isModule(statement.moduleSpecifier, toModule)) continue;\n const clause = statement.importClause;\n if (clause === undefined || clause.isTypeOnly !== typeOnly) continue;\n const bindings = clause.namedBindings;\n if (bindings === undefined || !ts.isNamedImports(bindings)) continue;\n return { statement, elements: bindings.elements, additions: [] };\n }\n return null;\n};\n\nconst specifierKey = ({ imported, local }: MovedSpecifier): string => `${imported} as ${local}`;\n\nconst specifierOf = (element: ts.ImportSpecifier, parentTypeOnly: boolean): MovedSpecifier => ({\n imported: (element.propertyName ?? element.name).text,\n local: element.name.text,\n isTypeOnly: parentTypeOnly || element.isTypeOnly,\n});\n\nconst rewriteFile = (\n filePath: string,\n content: string,\n { fromModule, toModule }: MoveNamedImportsOptions,\n renames: ReadonlyMap<string, string>\n): { content: string; manualReview: Array<ManualReviewItem> } => {\n const sourceFile = parseSource(filePath, content);\n const identifiers = collectIdentifiers(sourceFile);\n const manualReview = findManualReviewItems(sourceFile, identifiers, fromModule, toModule, renames);\n\n const edits: Array<Edit> = [];\n const valueTarget = findTargetImport(sourceFile, toModule, false);\n const typeTarget = findTargetImport(sourceFile, toModule, true);\n\n const targetFor = (spec: MovedSpecifier): TargetImport | null => {\n if (!spec.isTypeOnly) return valueTarget;\n return typeTarget ?? valueTarget;\n };\n\n const replaceStatement = (statement: ts.Statement, kept: string | null, added: ReadonlyArray<string>): void => {\n const parts = [...(kept === null ? [] : [kept]), ...added];\n const start = statement.getStart(sourceFile);\n let end = statement.getEnd();\n if (parts.length === 0) {\n if (content.startsWith(\"\\r\\n\", end)) end += 2;\n else if (content.startsWith(\"\\n\", end)) end += 1;\n const leading = content.slice(statement.getFullStart(), start);\n if (leading.includes(\"eslint-disable\")) {\n manualReview.push({\n file: filePath,\n line: lineOf(sourceFile, statement),\n reason: `removed import of \"${fromModule}\" had an eslint-disable comment, which now applies to the next line`,\n });\n }\n }\n edits.push({ start, end, text: parts.join(\"\\n\") });\n };\n\n /**\n * Moved names with no existing target import, keyed by whether they came\n * from an `import type`. Each kind is written as one new import at the\n * first statement that needed it, so several old imports never become\n * several imports of `toModule`.\n */\n type CreatedImport = { readonly anchor: ts.ImportDeclaration; readonly specs: Array<MovedSpecifier> };\n const createdImports = new Map<boolean, CreatedImport>();\n const deferredImports: Array<{ statement: ts.ImportDeclaration; keptText: string | null }> = [];\n\n for (const statement of sourceFile.statements) {\n if (ts.isImportDeclaration(statement) && isModule(statement.moduleSpecifier, fromModule)) {\n const clause = statement.importClause;\n const bindings = clause?.namedBindings;\n if (clause === undefined || bindings === undefined || !ts.isNamedImports(bindings)) continue;\n const moved = bindings.elements.filter(element => renames.has((element.propertyName ?? element.name).text));\n if (moved.length === 0) continue;\n\n const kept = bindings.elements.filter(element => !moved.includes(element));\n const createdKind = clause.isTypeOnly;\n const addCreated = (spec: MovedSpecifier): void => {\n const created = createdImports.get(createdKind) ?? { anchor: statement, specs: [] };\n createdImports.set(createdKind, created);\n if (!created.specs.some(existing => specifierKey(existing) === specifierKey(spec))) created.specs.push(spec);\n };\n for (const element of moved) {\n const original = specifierOf(element, clause.isTypeOnly);\n const newName = renames.get(original.imported) ?? original.imported;\n let local = original.local;\n if (newName !== original.imported && original.local === original.imported) {\n const renameEdits = renameReferenceEdits(sourceFile, identifiers, original.local, newName);\n if (renameEdits !== null) {\n edits.push(...renameEdits);\n local = newName;\n }\n }\n const spec: MovedSpecifier = { imported: newName, local, isTypeOnly: original.isTypeOnly };\n const target = targetFor(spec);\n if (target === null) {\n addCreated(spec);\n continue;\n }\n const existing = new Set([\n ...target.elements.map(e => specifierKey(specifierOf(e, false))),\n ...target.additions.map(specifierKey),\n ]);\n if (!existing.has(specifierKey(spec))) target.additions.push(spec);\n }\n\n const terminator = statementTerminator(statement);\n const defaultName = clause.name?.text;\n const keptText =\n kept.length === 0 && defaultName === undefined\n ? null\n : `import ${clause.isTypeOnly ? \"type \" : \"\"}${[\n ...(defaultName === undefined ? [] : [defaultName]),\n ...(kept.length === 0 ? [] : [`{ ${kept.map(e => e.getText(sourceFile)).join(\", \")} }`]),\n ].join(\", \")} from ${statement.moduleSpecifier.getText(sourceFile)}${terminator}`;\n deferredImports.push({ statement, keptText });\n } else if (\n ts.isExportDeclaration(statement) &&\n isModule(statement.moduleSpecifier, fromModule) &&\n statement.moduleSpecifier !== undefined &&\n statement.exportClause !== undefined &&\n ts.isNamedExports(statement.exportClause)\n ) {\n const elements = statement.exportClause.elements;\n const moved = elements.filter(element => renames.has((element.propertyName ?? element.name).text));\n if (moved.length === 0) continue;\n const kept = elements.filter(element => !moved.includes(element));\n const typePrefix = statement.isTypeOnly ? \"type \" : \"\";\n const terminator = statementTerminator(statement);\n const specs = moved.map(element => {\n const imported = (element.propertyName ?? element.name).text;\n return renderSpecifier(\n { imported: renames.get(imported) ?? imported, local: element.name.text, isTypeOnly: element.isTypeOnly },\n true\n );\n });\n replaceStatement(\n statement,\n kept.length === 0\n ? null\n : `export ${typePrefix}{ ${kept.map(e => e.getText(sourceFile)).join(\", \")} } from ${statement.moduleSpecifier.getText(sourceFile)}${terminator}`,\n [\n `export ${typePrefix}{ ${specs.join(\", \")} } from ${quoteLike(statement.moduleSpecifier, toModule)}${terminator}`,\n ]\n );\n }\n }\n\n for (const { statement, keptText } of deferredImports) {\n const createdText = [...createdImports.entries()]\n .filter(([, created]) => created.anchor === statement)\n .map(\n ([typeOnly, created]) =>\n `import ${typeOnly ? \"type \" : \"\"}{ ${created.specs\n .map(spec => renderSpecifier(spec, !typeOnly))\n .join(\", \")} } from ${quoteLike(statement.moduleSpecifier, toModule)}${statementTerminator(statement)}`\n );\n replaceStatement(statement, keptText, createdText);\n }\n\n for (const target of [valueTarget, typeTarget]) {\n if (target === null || target.additions.length === 0) continue;\n const typeOnly = target.statement.importClause?.isTypeOnly === true;\n const bindings = target.statement.importClause?.namedBindings;\n if (bindings === undefined) continue;\n const merged = [\n ...target.elements.map(e => e.getText(sourceFile)),\n ...target.additions.map(spec => renderSpecifier(spec, !typeOnly)),\n ];\n edits.push({ start: bindings.getStart(sourceFile), end: bindings.getEnd(), text: `{ ${merged.join(\", \")} }` });\n }\n\n if (edits.length === 0) return { content, manualReview };\n edits.sort((a, b) => b.start - a.start);\n let updated = content;\n for (const { start, end, text } of edits) {\n updated = updated.slice(0, start) + text + updated.slice(end);\n }\n return { content: updated, manualReview };\n};\n\n/**\n * Moves named imports and named re-exports of `names` from `fromModule` to\n * `toModule` across every `.ts`/`.tsx`/`.jsx` file in the tree.\n *\n * - Mixed imports are split; names that didn't move stay on `fromModule`.\n * - Aliases (`as`), `import type` and inline `type` modifiers are preserved.\n * - Moved names are merged into an existing named import of `toModule`, or\n * else into one new import per kind (value / `import type`).\n * - With a rename record, an unaliased import has its references renamed too;\n * when that isn't safe (name clash or shadowing) it is imported as\n * `{ NewName as OldName }` instead. Re-exports keep their public name.\n * - Namespace imports, `export *`, dynamic `import()`, `require()` and\n * `vi`/`jest` mocks of `fromModule` are left untouched and returned in\n * `manualReview`, never skipped silently.\n *\n * Synchronous and format-free, so it can run inside a `run-migrations`\n * migration; callers format changed files themselves (e.g. `formatFiles`).\n */\nexport const moveNamedImports = (tree: Tree, options: MoveNamedImportsOptions): MoveNamedImportsResult => {\n const renames = toRenameMap(options.names);\n const changedFiles: Array<string> = [];\n const manualReview: Array<ManualReviewItem> = [];\n\n visitTsFiles(tree, options.fromModule, (filePath, content) => {\n const result = rewriteFile(filePath, content, options, renames);\n manualReview.push(...result.manualReview);\n if (result.content !== content) changedFiles.push(filePath);\n return result.content;\n });\n\n return { changedFiles, manualReview };\n};\n\n/** Logs each manual-review item as a warning, prefixed with the migration name. */\nexport const logManualReview = (migrationName: string, items: ReadonlyArray<ManualReviewItem>): void => {\n for (const { file, line, reason } of items) {\n logger.warn(` ${migrationName}: manual review needed at ${file}:${line} - ${reason}`);\n }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-json-utils.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/utils/package-json-utils.ts"],"names":[],"mappings":";;;AAAA,uCAAqG;AACrG,qCAAmD;AAEnD,gGAAgG;AAChG,MAAM,8BAA8B,GAAG,oBAAoB,CAAC;AAyB5D;;;;;GAKG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAU,EAAE,OAAgC,EAA0B,EAAE;IACvG,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE,eAAe,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;IACxF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;QAAE,OAAO,iBAAiB,CAAC;IAE5D,MAAM,WAAW,GAAG,IAAA,iBAAQ,EAAc,IAAI,EAAE,eAAe,CAAC,CAAC;IACjE,IAAI,WAAW,CAAC,IAAI,KAAK,8BAA8B;QAAE,OAAO,mBAAmB,CAAC;IACpF,IACE,WAAW,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,KAAK,SAAS;QACrD,WAAW,CAAC,eAAe,EAAE,CAAC,WAAW,CAAC,KAAK,SAAS,EACxD,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,MAAM,eAAe,GACnB,aAAa,KAAK,SAAS;QAC3B,WAAW,CAAC,YAAY,EAAE,CAAC,aAAa,CAAC,KAAK,SAAS;QACvD,WAAW,CAAC,eAAe,EAAE,CAAC,aAAa,CAAC,KAAK,SAAS,CAAC;IAC7D,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE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C,IAAI,CAAC,IAAA,oBAAU,EAAC,aAAa,CAAC;YAAE,SAAS;QACzC,MAAM,WAAW,GAAgB,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;QAClF,IAAI,WAAW,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,QAAQ,IAAI,WAAW,CAAC,OAAO,KAAK,EAAE,EAAE,CAAC;YAC9G,OAAO,WAAW,CAAC,OAAO,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,iCAAiC,WAAW,gBAAgB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC3G,CAAC,CAAC;AATW,QAAA,oBAAoB,wBAS/B","sourcesContent":["import { addDependenciesToPackageJson, readJson, type Tree, visitNotIgnoredFiles } from \"@nx/devkit\";\nimport { existsSync, readFileSync } from \"node:fs\";\n\n/** Root package name of the manager monorepo, where `@trackunit/*` versions are owned by CI. */\nconst MANAGER_WORKSPACE_PACKAGE_NAME = \"@trackunit/manager\";\n\ntype PackageJson = {\n readonly name?: string;\n readonly version?: string;\n readonly dependencies?: Readonly<Record<string, string>>;\n readonly devDependencies?: Readonly<Record<string, string>>;\n readonly peerDependencies?: Readonly<Record<string, string>>;\n};\n\nexport type EnsureDependencyOptions = {\n readonly packageName: string;\n /** Range written when the dependency is added, e.g. `^1.2.0`. */\n readonly range: string;\n /**\n * Put the dependency in the same field as this package: `devDependencies`\n * when it is only a devDependency, otherwise `dependencies`.\n */\n readonly besidePackage?: string;\n /** Defaults to the workspace root `package.json`. */\n readonly packageJsonPath?: string;\n};\n\nexport type EnsureDependencyResult = \"added\" | \"already-present\" | \"no-package-json\" | \"manager-workspace\";\n\n/**\n * Adds `packageName@range` to a package.json unless it is already declared\n * in `dependencies` or `devDependencies` (an existing entry is never\n * changed). Does nothing in the manager monorepo itself. Doesn't install;\n * the consumer has to re-install afterwards.\n */\nexport const ensureDependency = (tree: Tree, options: EnsureDependencyOptions): EnsureDependencyResult => {\n const { packageName, range, besidePackage, packageJsonPath = \"package.json\" } = options;\n if (!tree.exists(packageJsonPath)) return \"no-package-json\";\n\n const packageJson = readJson<PackageJson>(tree, packageJsonPath);\n if (packageJson.name === MANAGER_WORKSPACE_PACKAGE_NAME) return \"manager-workspace\";\n if (\n packageJson.dependencies?.[packageName] !== undefined ||\n packageJson.devDependencies?.[packageName] !== undefined\n ) {\n return \"already-present\";\n }\n\n const asDevDependency =\n besidePackage !== undefined &&\n packageJson.dependencies?.[besidePackage] === undefined &&\n packageJson.devDependencies?.[besidePackage] !== undefined;\n const entry = { [packageName]: range };\n addDependenciesToPackageJson(tree, asDevDependency ? {} : entry, asDevDependency ? entry : {}, packageJsonPath, true);\n return \"added\";\n};\n\n/**\n * Every package.json except the root one (and anything under\n * `node_modules`) that declares `packageName` as a dependency, devDependency\n * or peerDependency.\n */\nexport const findPackageJsonsDeclaring = (tree: Tree, packageName: string): Array<string> => {\n const found: Array<string> = [];\n visitNotIgnoredFiles(tree, \"/\", filePath => {\n if (filePath === \"package.json\" || !filePath.endsWith(\"/package.json\")) return;\n if (filePath.startsWith(\"node_modules/\") || filePath.includes(\"/node_modules/\")) return;\n const packageJson = readJson<PackageJson>(tree, filePath);\n if (\n packageJson.dependencies?.[packageName] !== undefined ||\n packageJson.devDependencies?.[packageName] !== undefined ||\n packageJson.peerDependencies?.[packageName] !== undefined\n ) {\n found.push(filePath);\n }\n });\n return found;\n};\n\n/**\n * Version of a companion package, read from the first of `candidatePaths`\n * (absolute file-system paths, not tree paths) that is the package.json of\n * `packageName`. Throws when none is, so a migration fails and stays pending\n * instead of writing a wrong range.\n */\nexport const readCompanionVersion = (packageName: string, candidatePaths: ReadonlyArray<string>): string => {\n for (const candidatePath of candidatePaths) {\n if (!existsSync(candidatePath)) continue;\n const packageJson: PackageJson = JSON.parse(readFileSync(candidatePath, \"utf-8\"));\n if (packageJson.name === packageName && typeof packageJson.version === \"string\" && packageJson.version !== \"\") {\n return packageJson.version;\n }\n }\n throw new Error(`Could not find the version of ${packageName}. Looked in: ${candidatePaths.join(\", \")}`);\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"breadcrumb-remove-deprecated-props.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/breadcrumb-remove-deprecated-props.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,qBAAqB,EAAE,2BAA2B,CAAU,CAAC;AACpG,MAAM,eAAe,GAAG,CAAC,iBAAiB,EAAE,2BAA2B,CAAU,CAAC;AAElF,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAiB,EAAE;IAChF,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,aAAa,GAAkB,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACxD,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;YACpD,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE5C,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC3D,IAA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AU,EAAQ,EAAE;IAClE,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAC;IACxE,IAAA,sBAAU,EAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;IAC1D,eAAM,CAAC,IAAI,CACT,kJAAkJ,CACnJ,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,+BAA+B,mCAM1C;AAEF,kBAAe,uCAA+B,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAMES = [\"Breadcrumb\", \"BreadcrumbContainer\", \"BreadcrumbForMediumScreen\"] as const;\nconst PROPS_TO_REMOVE = [\"backButtonTitle\", \"expandCollapsedItemsTitle\"] as const;\n\nconst stripDeprecatedProps = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localTagNames: Array<string> = [];\n for (const [local, original] of Object.entries(aliases)) {\n if (COMPONENT_NAMES.some(name => name === original)) {\n localTagNames.push(local);\n }\n }\n if (localTagNames.length === 0) return null;\n\n const matches = findJsxElements(sourceFile, localTagNames);\n if (matches.length === 0) return null;\n\n // Collect every (start, end) range we want to delete. We process them in\n // reverse so earlier offsets stay valid while we splice.\n const ranges: Array<{ start: number; end: number }> = [];\n for (const { openingElement } of matches) {\n for (const propName of PROPS_TO_REMOVE) {\n const attr = findJsxAttribute(openingElement, propName);\n if (attr === null) continue;\n\n // Drop trailing whitespace + the attribute itself so we don't leave a\n // dangling space inside the opening tag. e.g. `<X foo=\"a\" bar=\"b\" />`\n // becomes `<X foo=\"a\" />` and `<X bar=\"b\" />` becomes `<X />`.\n let start = attr.getFullStart();\n const end = attr.getEnd();\n // getFullStart includes leading whitespace which is what we want.\n // Guard against negative ranges if multiple props collapse later.\n if (start < 0) start = attr.getStart();\n ranges.push({ start, end });\n }\n }\n\n if (ranges.length === 0) return null;\n\n ranges.sort((a, b) => b.start - a.start);\n\n let updated = content;\n for (const { start, end } of ranges) {\n updated = updated.slice(0, start) + updated.slice(end);\n }\n\n return updated;\n};\n\n/**\n * Removes the no-longer-supported `backButtonTitle` and\n * `expandCollapsedItemsTitle` props from `<Breadcrumb>`,\n * `<BreadcrumbContainer>`, and `<BreadcrumbForMediumScreen>`. Their accessible\n * names are now sourced from the `react-components` library translations.\n */\nexport const breadcrumbRemoveDeprecatedProps = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"Breadcrumb\", stripDeprecatedProps);\n logSummary(\"breadcrumb-remove-deprecated-props\", touched);\n logger.info(\n \" Ensure the host application registers the @trackunit/react-components library translations so the back/expand buttons render localized labels.\"\n );\n};\n\nexport default breadcrumbRemoveDeprecatedProps;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardheader-onclickclose-to-actions.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/cardheader-onclickclose-to-actions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,MAAM,kBAAkB,GAAG,CAAC,YAAY,EAAE,MAAM,CAAU,CAAC;AAE3D,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAE,SAAiB,EAAE,eAAuB,EAAU,EAAE,CACpG,IAAI,eAAe,WAAW,SAAS,2CAA2C,WAAW,4CAA4C,CAAC;AAE5I,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAE,WAAmB,EAAE,UAAiC,EAAU,EAAE;IAC5G,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAA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AG,kBAAkB,CAAC,CAAC,CAAC;IAE5E,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACI,MAAM,+BAA+B,GAAG,CAAC,IAAU,EAAQ,EAAE;IAClE,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,YAAY,EAAE,wBAAwB,CAAC,CAAC;IAC5E,IAAA,sBAAU,EAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC,CAAC;AAHW,QAAA,+BAA+B,mCAG1C;AAEF,kBAAe,uCAA+B,CAAC","sourcesContent":["import { type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"CardHeader\";\n\nconst CLOSE_BUTTON_NAMES = [\"IconButton\", \"Icon\"] as const;\n\nconst renderCloseButton = (handlerExpr: string, iconAlias: string, iconButtonAlias: string): string =>\n `<${iconButtonAlias} icon={<${iconAlias} name=\"XMark\" size=\"small\" />} onClick={${handlerExpr}} title=\"Close\" variant=\"ghost-neutral\" />`;\n\nconst ensureNamedImport = (content: string, packageName: string, namesToAdd: ReadonlyArray<string>): string => {\n const sourceFile = parseTsx(content, \"source.tsx\");\n const aliases = getImportedAliases(sourceFile, packageName) ?? {};\n\n const missing = namesToAdd.filter(name => !Object.values(aliases).includes(name));\n if (missing.length === 0) return content;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== packageName) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n const elementsText = namedBindings.elements.map(el => el.getText()).join(\", \");\n const merged = [elementsText, ...missing].join(\", \");\n const before = content.slice(0, namedBindings.getStart());\n const after = content.slice(namedBindings.getEnd());\n return `${before}{ ${merged} }${after}`;\n }\n\n // No existing import from the package; add a fresh line near the top.\n const importLine = `import { ${missing.join(\", \")} } from \"${packageName}\";\\n`;\n return importLine + content;\n};\n\nconst transformCardHeaderUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const cardHeaderAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (cardHeaderAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [cardHeaderAlias]);\n if (matches.length === 0) return null;\n\n type Edit = { start: number; end: number; replacement: string };\n const edits: Array<Edit> = [];\n\n for (const { openingElement } of matches) {\n const onClickCloseAttr = findJsxAttribute(openingElement, \"onClickClose\");\n if (onClickCloseAttr === null) continue;\n\n const initializer = onClickCloseAttr.initializer;\n if (initializer === undefined) continue;\n\n let handlerExpr: string;\n if (ts.isJsxExpression(initializer) && initializer.expression !== undefined) {\n handlerExpr = initializer.expression.getText();\n } else if (ts.isStringLiteral(initializer)) {\n handlerExpr = `\"${initializer.text}\"`;\n } else {\n continue;\n }\n\n const actionsAttr = findJsxAttribute(openingElement, \"actions\");\n if (actionsAttr !== null) {\n // Don't try to merge with an existing actions prop; flag and skip.\n continue;\n }\n\n const replacement = `actions={${renderCloseButton(handlerExpr, \"Icon\", \"IconButton\")}}`;\n edits.push({\n start: onClickCloseAttr.getStart(),\n end: onClickCloseAttr.getEnd(),\n replacement,\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => b.start - a.start);\n\n let updated = content;\n for (const { start, end, replacement } of edits) {\n updated = updated.slice(0, start) + replacement + updated.slice(end);\n }\n\n updated = ensureNamedImport(updated, PACKAGE_NAME, [...CLOSE_BUTTON_NAMES]);\n\n return updated;\n};\n\n/**\n * Replaces the removed `onClickClose` prop on `<CardHeader>` with the\n * equivalent action rendered through the `actions` slot using `IconButton` +\n * the `XMark` icon.\n *\n * Cards that already declared `actions` are skipped to avoid clobbering\n * existing markup.\n */\nexport const cardHeaderOnClickCloseToActions = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"CardHeader\", transformCardHeaderUsage);\n logSummary(\"cardheader-onclickclose-to-actions\", touched);\n};\n\nexport default cardHeaderOnClickCloseToActions;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconbutton-add-required-name.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/iconbutton-add-required-name.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAQ4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,MAAM,iBAAiB,GAAG,0CAA0C,CAAC;AAErE,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAiB,EAAE;IACpF,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5F,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAE1C,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAGtC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AAE,wBAAwB,CAAC,CAAC;IAC5E,IAAA,sBAAU,EAAC,8BAA8B,EAAE,OAAO,CAAC,CAAC;IACpD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,eAAM,CAAC,IAAI,CACT,8BAA8B,iBAAiB,6EAA6E,CAC7H,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AARW,QAAA,yBAAyB,6BAQpC;AAEF,kBAAe,iCAAyB,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n hasSpreadAttribute,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"IconButton\";\n\nconst PLACEHOLDER_TITLE = \"TODO Replace with localized button title\";\n\nconst transformIconButtonUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = { offset: number; text: string };\n const edits: Array<Edit> = [];\n\n for (const { openingElement } of matches) {\n if (hasSpreadAttribute(openingElement)) continue;\n\n const hasTitle = findJsxAttribute(openingElement, \"title\") !== null;\n const hasAriaLabel = findJsxAttribute(openingElement, \"ariaLabel\") !== null;\n if (hasTitle || hasAriaLabel) continue;\n\n edits.push({\n offset: openingElement.tagName.getEnd(),\n text: ` title=\"${PLACEHOLDER_TITLE}\"`,\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => (a.offset === b.offset ? 0 : b.offset - a.offset));\n\n let updated = content;\n for (const { offset, text } of edits) {\n updated = updated.slice(0, offset) + text + updated.slice(offset);\n }\n return updated;\n};\n\n/**\n * Adds a placeholder `title` to `<IconButton>` usages that don't already\n * provide either `title` or `ariaLabel`. The new accessible name requirement\n * means every icon button must carry one of these two props.\n *\n * Usages with a spread attribute (e.g. `<IconButton {...props} />`) are\n * skipped because we cannot tell whether `title`/`ariaLabel` is forwarded.\n */\nexport const iconButtonAddRequiredName = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"IconButton\", transformIconButtonUsage);\n logSummary(\"iconbutton-add-required-name\", touched);\n if (touched > 0) {\n logger.info(\n ` Replace the placeholder \"${PLACEHOLDER_TITLE}\" titles with localized strings (or switch to ariaLabel where appropriate).`\n );\n }\n};\n\nexport default iconButtonAddRequiredName;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kpi-tooltiplabel-to-wrapper.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/kpi-tooltiplabel-to-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE;IACtD,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,OAAO,CAAC;IAEnF,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QACzC,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAAE,SAAS;QAC5C,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC7C,IAAI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AAC","sourcesContent":["import { type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"KPI\";\n\nconst ensureTooltipImport = (content: string): string => {\n const sourceFile = parseTsx(content, \"source.tsx\");\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases !== null && Object.values(aliases).includes(\"Tooltip\")) return content;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== PACKAGE_NAME) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n const elementsText = namedBindings.elements.map(el => el.getText()).join(\", \");\n const merged = `${elementsText}, Tooltip`;\n const before = content.slice(0, namedBindings.getStart());\n const after = content.slice(namedBindings.getEnd());\n return `${before}{ ${merged} }${after}`;\n }\n\n return `import { Tooltip } from \"${PACKAGE_NAME}\";\\n${content}`;\n};\n\nconst renderTooltipExpression = (label: string): string => label;\n\nconst transformKpiUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = {\n elementStart: number;\n elementEnd: number;\n attrStart: number;\n attrEnd: number;\n label: string;\n elementText: string;\n };\n const edits: Array<Edit> = [];\n\n for (const { openingElement, element } of matches) {\n const tooltipLabelAttr = findJsxAttribute(openingElement, \"tooltipLabel\");\n if (tooltipLabelAttr === null) continue;\n\n const initializer = tooltipLabelAttr.initializer;\n if (initializer === undefined) continue;\n\n let label: string;\n if (ts.isStringLiteral(initializer)) {\n label = `\"${initializer.text}\"`;\n } else if (ts.isJsxExpression(initializer) && initializer.expression !== undefined) {\n label = `{${initializer.expression.getText()}}`;\n } else {\n continue;\n }\n\n edits.push({\n elementStart: element.getStart(),\n elementEnd: element.getEnd(),\n attrStart: tooltipLabelAttr.getFullStart(),\n attrEnd: tooltipLabelAttr.getEnd(),\n label,\n elementText: content.slice(element.getStart(), element.getEnd()),\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => b.elementStart - a.elementStart);\n\n let updated = content;\n for (const edit of edits) {\n // Remove the tooltipLabel attribute first (it's inside the element).\n const elementWithoutAttr =\n edit.elementText.slice(0, edit.attrStart - edit.elementStart) +\n edit.elementText.slice(edit.attrEnd - edit.elementStart);\n const wrapped = `<Tooltip label=${renderTooltipExpression(edit.label)} placement=\"bottom\">${elementWithoutAttr}</Tooltip>`;\n updated = updated.slice(0, edit.elementStart) + wrapped + updated.slice(edit.elementEnd);\n }\n\n updated = ensureTooltipImport(updated);\n\n return updated;\n};\n\n/**\n * Replaces the removed `tooltipLabel` prop on `<KPI>` with an explicit\n * `<Tooltip>` wrapper. The `KPICard` variant is intentionally not touched\n * because it still owns its own `tooltipLabel` prop.\n */\nexport const kpiTooltipLabelToWrapper = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"tooltipLabel\", transformKpiUsage);\n logSummary(\"kpi-tooltiplabel-to-wrapper\", touched);\n};\n\nexport default kpiTooltipLabelToWrapper;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notice-tooltiplabel-to-wrapper.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/notice-tooltiplabel-to-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,kDAO4B;AAE5B,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GAKG;AACI,MAAM,2BAA2B,GAAG,CAAC,IAAU,EAAQ,EAAE;IAC9D,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACpE,IAAA,sBAAU,EAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC,CAAC;AAHW,QAAA,2BAA2B,+BAGtC;AAEF,kBAAe,mCAA2B,CAAC","sourcesContent":["import { type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"Notice\";\n\nconst ensureTooltipImport = (content: string): string => {\n const sourceFile = parseTsx(content, \"source.tsx\");\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases !== null && Object.values(aliases).includes(\"Tooltip\")) return content;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== PACKAGE_NAME) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n const elementsText = namedBindings.elements.map(el => el.getText()).join(\", \");\n const merged = `${elementsText}, Tooltip`;\n const before = content.slice(0, namedBindings.getStart());\n const after = content.slice(namedBindings.getEnd());\n return `${before}{ ${merged} }${after}`;\n }\n\n return `import { Tooltip } from \"${PACKAGE_NAME}\";\\n${content}`;\n};\n\nconst transformNoticeUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = {\n elementStart: number;\n elementEnd: number;\n elementText: string;\n label: string | null;\n attrEdits: Array<{ start: number; end: number }>;\n };\n const edits: Array<Edit> = [];\n\n for (const { openingElement, element } of matches) {\n const tooltipLabelAttr = findJsxAttribute(openingElement, \"tooltipLabel\");\n const withTooltipAttr = findJsxAttribute(openingElement, \"withTooltip\");\n if (tooltipLabelAttr === null && withTooltipAttr === null) continue;\n\n let label: string | null = null;\n if (tooltipLabelAttr !== null) {\n const initializer = tooltipLabelAttr.initializer;\n if (initializer !== undefined) {\n if (ts.isStringLiteral(initializer)) {\n label = `\"${initializer.text}\"`;\n } else if (ts.isJsxExpression(initializer) && initializer.expression !== undefined) {\n label = `{${initializer.expression.getText()}}`;\n }\n }\n }\n\n const attrEdits: Array<{ start: number; end: number }> = [];\n for (const attr of [tooltipLabelAttr, withTooltipAttr]) {\n if (attr === null) continue;\n attrEdits.push({ start: attr.getFullStart(), end: attr.getEnd() });\n }\n\n edits.push({\n elementStart: element.getStart(),\n elementEnd: element.getEnd(),\n elementText: content.slice(element.getStart(), element.getEnd()),\n label,\n attrEdits,\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => b.elementStart - a.elementStart);\n\n let updated = content;\n let needsTooltipImport = false;\n\n for (const edit of edits) {\n // Remove the tooltipLabel/withTooltip attributes from the element first.\n let elementWithoutAttrs = edit.elementText;\n const sortedAttrEdits = [...edit.attrEdits].sort((a, b) => b.start - a.start);\n for (const { start, end } of sortedAttrEdits) {\n elementWithoutAttrs =\n elementWithoutAttrs.slice(0, start - edit.elementStart) + elementWithoutAttrs.slice(end - edit.elementStart);\n }\n\n if (edit.label !== null) {\n const wrapped = `<Tooltip label=${edit.label} placement=\"bottom\">${elementWithoutAttrs}</Tooltip>`;\n updated = updated.slice(0, edit.elementStart) + wrapped + updated.slice(edit.elementEnd);\n needsTooltipImport = true;\n } else {\n // No label to forward (e.g. only `withTooltip`); just strip the props.\n updated = updated.slice(0, edit.elementStart) + elementWithoutAttrs + updated.slice(edit.elementEnd);\n }\n }\n\n if (needsTooltipImport) {\n updated = ensureTooltipImport(updated);\n }\n\n return updated;\n};\n\n/**\n * Removes the deprecated `withTooltip`/`tooltipLabel` props from `<Notice>`\n * usages. When a label is present the element is wrapped in `<Tooltip>` to\n * preserve hover behaviour; when only `withTooltip` was set the props are\n * dropped because they had no remaining effect.\n */\nexport const noticeTooltipLabelToWrapper = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"Notice\", transformNoticeUsage);\n logSummary(\"notice-tooltiplabel-to-wrapper\", touched);\n};\n\nexport default noticeTooltipLabelToWrapper;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination-add-required-titles.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/pagination-add-required-titles.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAQ4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,MAAM,YAAY,GAA2B;IAC3C,iBAAiB,EAAE,eAAe;IAClC,aAAa,EAAE,WAAW;CAC3B,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAiB,EAAE;IACpF,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,EAAE,CAAC,CAAC,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GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACI,MAAM,2BAA2B,GAAG,CAAC,IAAU,EAAQ,EAAE;IAC9D,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,YAAY,EAAE,wBAAwB,CAAC,CAAC;IAC5E,IAAA,sBAAU,EAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;IACtD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,eAAM,CAAC,IAAI,CAAC,+FAA+F,CAAC,CAAC;IAC/G,CAAC;AACH,CAAC,CAAC;AANW,QAAA,2BAA2B,+BAMtC;AAEF,kBAAe,mCAA2B,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n hasSpreadAttribute,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"Pagination\";\n\nconst PLACEHOLDERS: Record<string, string> = {\n previousPageTitle: \"Previous page\",\n nextPageTitle: \"Next page\",\n};\n\nconst transformPaginationUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = { offset: number; text: string };\n const edits: Array<Edit> = [];\n\n for (const { openingElement } of matches) {\n if (hasSpreadAttribute(openingElement)) continue;\n\n for (const [propName, placeholder] of Object.entries(PLACEHOLDERS)) {\n if (findJsxAttribute(openingElement, propName) !== null) continue;\n edits.push({\n offset: openingElement.tagName.getEnd(),\n text: ` ${propName}=\"${placeholder}\"`,\n });\n }\n }\n\n if (edits.length === 0) return null;\n\n // Apply in reverse so earlier offsets stay valid; keep order at the same\n // offset so attributes appear in declaration order in the source.\n edits.sort((a, b) => (a.offset === b.offset ? 0 : b.offset - a.offset));\n\n let updated = content;\n for (const { offset, text } of edits) {\n updated = updated.slice(0, offset) + text + updated.slice(offset);\n }\n return updated;\n};\n\n/**\n * Adds the now-required `previousPageTitle` and `nextPageTitle` props to\n * `<Pagination>` usages that don't already provide them. The values default\n * to the English strings \"Previous page\"/\"Next page\"; consumers should\n * replace them with their own localized strings.\n *\n * Usages with a spread attribute (e.g. `<Pagination {...props} />`) are\n * skipped because we cannot tell whether the props are already provided.\n */\nexport const paginationAddRequiredTitles = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"Pagination\", transformPaginationUsage);\n logSummary(\"pagination-add-required-titles\", touched);\n if (touched > 0) {\n logger.info(` Replace the placeholder \"Previous page\"/\"Next page\" strings with your own localized values.`);\n }\n};\n\nexport default paginationAddRequiredTitles;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag-add-removetaglabel.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/tag-add-removetaglabel.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAQ4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,4BAA4B,GAAG,YAAY,CAAC;AAElD,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAiB,EAAE;IAC7E,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC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K,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC;QACrC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;GAKG;AACI,MAAM,oBAAoB,GAAG,CAAC,IAAU,EAAQ,EAAE;IACvD,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;IAC9D,IAAA,sBAAU,EAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;IAC9C,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,eAAM,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B;AAEF,kBAAe,4BAAoB,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n hasSpreadAttribute,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"Tag\";\n\nconst REMOVE_TAG_LABEL_PLACEHOLDER = \"Remove tag\";\n\nconst transformTagUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = { offset: number; text: string };\n const edits: Array<Edit> = [];\n\n for (const { openingElement } of matches) {\n if (hasSpreadAttribute(openingElement)) continue;\n\n // Only act when the tag is dismissible (has onClickClose) and missing the\n // newly required label.\n if (findJsxAttribute(openingElement, \"onClickClose\") === null) continue;\n if (findJsxAttribute(openingElement, \"removeTagLabel\") !== null) continue;\n\n edits.push({\n offset: openingElement.tagName.getEnd(),\n text: ` removeTagLabel=\"${REMOVE_TAG_LABEL_PLACEHOLDER}\"`,\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => (a.offset === b.offset ? 0 : b.offset - a.offset));\n\n let updated = content;\n for (const { offset, text } of edits) {\n updated = updated.slice(0, offset) + text + updated.slice(offset);\n }\n return updated;\n};\n\n/**\n * Adds the now-required `removeTagLabel` prop to dismissible `<Tag>` usages\n * (those with `onClickClose`) when it is missing. Default value is the English\n * string \"Remove tag\"; consumers should replace it with their own localized\n * label.\n */\nexport const tagAddRemoveTagLabel = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"Tag\", transformTagUsage);\n logSummary(\"tag-add-removetaglabel\", touched);\n if (touched > 0) {\n logger.info(` Replace the placeholder \"Remove tag\" string with your own localized value.`);\n }\n};\n\nexport default tagAddRemoveTagLabel;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"togglegroup-remove-item-style.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/togglegroup-remove-item-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA+C;AAC/C,+CAAiC;AACjC,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,aAAa,CAAC;AAIrC,MAAM,6BAA6B,GAAG,CAAC,YAAuC,EAA0B,EAAE;IACxG,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC5C,IAAI,CAAC,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC;YAAE,SAAS;QACrD,K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CAAC;AAlBW,QAAA,0BAA0B,8BAkBrC;AAEF,kBAAe,kCAA0B,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"ToggleGroup\";\n\ntype Removal = { start: number; end: number };\n\nconst collectStyleRemovalsFromArray = (arrayLiteral: ts.ArrayLiteralExpression): ReadonlyArray<Removal> => {\n const removals: Array<Removal> = [];\n for (const element of arrayLiteral.elements) {\n if (!ts.isObjectLiteralExpression(element)) continue;\n for (const prop of element.properties) {\n if (\n (ts.isPropertyAssignment(prop) || ts.isShorthandPropertyAssignment(prop)) &&\n ts.isIdentifier(prop.name) &&\n prop.name.text === \"style\"\n ) {\n removals.push({ start: prop.getFullStart(), end: prop.getEnd() });\n }\n }\n }\n return removals;\n};\n\nconst transformToggleGroupUsage = (\n filePath: string,\n content: string\n): { content: string | null; skippedNonInline: number } => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return { content: null, skippedNonInline: 0 };\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return { content: null, skippedNonInline: 0 };\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return { content: null, skippedNonInline: 0 };\n\n const removals: Array<Removal> = [];\n let skippedNonInline = 0;\n\n for (const { openingElement } of matches) {\n const listAttr = findJsxAttribute(openingElement, \"list\");\n if (listAttr === null) continue;\n\n const initializer = listAttr.initializer;\n if (initializer === undefined || !ts.isJsxExpression(initializer)) continue;\n const expr = initializer.expression;\n if (expr === undefined) continue;\n\n if (!ts.isArrayLiteralExpression(expr)) {\n // The list is referenced through a variable / function call; we can't\n // safely strip `style` without potentially editing unrelated objects.\n skippedNonInline += 1;\n continue;\n }\n\n removals.push(...collectStyleRemovalsFromArray(expr));\n }\n\n if (removals.length === 0) return { content: null, skippedNonInline };\n\n // Remove the property and its trailing comma if present so we don't leave\n // dangling `, ,` sequences.\n const sorted = [...removals].sort((a, b) => b.start - a.start);\n let updated = content;\n for (let { start, end } of sorted) {\n while (start > 0 && (updated[start - 1] === \" \" || updated[start - 1] === \"\\t\")) {\n start -= 1;\n }\n if (updated[end] === \",\") {\n end += 1;\n }\n updated = updated.slice(0, start) + updated.slice(end);\n }\n\n return { content: updated, skippedNonInline };\n};\n\n/**\n * Removes the `style` property from items in `<ToggleGroup list={[...]}>`\n * because `BasicToggleGroupListProps` no longer extends `Styleable`.\n *\n * Only inline array literals are processed; lists pulled in via a variable or\n * function call are left untouched and reported in the migration summary so\n * the developer can review them.\n */\nexport const toggleGroupRemoveItemStyle = (tree: Tree): void => {\n let touched = 0;\n let totalSkipped = 0;\n visitTsxFiles(tree, COMPONENT_NAME, (filePath, content) => {\n const { content: updated, skippedNonInline } = transformToggleGroupUsage(filePath, content);\n totalSkipped += skippedNonInline;\n if (updated !== null && updated !== content) {\n touched += 1;\n return updated;\n }\n return null;\n });\n logSummary(\"togglegroup-remove-item-style\", touched, totalSkipped);\n if (totalSkipped > 0) {\n logger.info(\n ` ${totalSkipped} ToggleGroup usage(s) referenced their list through a variable/function. Remove any 'style' properties from those item objects manually.`\n );\n }\n};\n\nexport default toggleGroupRemoveItemStyle;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menulist-rename-to-menucontent.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-6-0/menulist-rename-to-menucontent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,kDAA6F;AAE7F,MAAM,YAAY,GAAG,6BAA6B,CAAC;AAEnD,MAAM,OAAO,GAAkE;IAC7E,EAAE,IAAI,EAAE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ACN,MAAM,IAAI,GAAG,8BAA8B,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YAChF,IAAI,IAAI,KAAK,IAAI;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEpC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAExC,IAAI,OAAO,GAAG,OAAO,CAAC;IACtB,KAAK,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC;QACzC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;;;;;GAUG;AACI,MAAM,2BAA2B,GAAG,CAAC,IAAU,EAAQ,EAAE;IAC9D,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC;IACxE,IAAA,sBAAU,EAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC,CAAC;AAHW,QAAA,2BAA2B,+BAGtC;AAEF,kBAAe,mCAA2B,CAAC","sourcesContent":["import { type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport { getImportedAliases, logSummary, parseTsx, visitTsxFiles } from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\n\nconst RENAMES: ReadonlyArray<{ readonly from: string; readonly to: string }> = [\n { from: \"MenuList\", to: \"MenuContent\" },\n { from: \"MenuListProps\", to: \"MenuContentProps\" },\n];\n\ntype Edit = { start: number; end: number; text: string };\n\n/**\n * Every `Identifier` node in the file matching `name`. Safe to use as a\n * blanket rename once we've confirmed (via `getImportedAliases`) that `name`\n * is genuinely imported from the target package with no local alias — in\n * that case the import specifier, JSX tag references, and type references\n * all share the same identifier text, so one pass covers every site.\n */\nconst collectIdentifierEdits = (sourceFile: ts.SourceFile, name: string, replacement: string): Array<Edit> => {\n const edits: Array<Edit> = [];\n const visit = (node: ts.Node): void => {\n if (ts.isIdentifier(node) && node.text === name) {\n edits.push({ start: node.getStart(sourceFile), end: node.getEnd(), text: replacement });\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return edits;\n};\n\n/**\n * Locates the `propertyName` of an aliased named import specifier\n * (`{ MenuList as Foo }`) for `importedName`. Only that part needs\n * rewriting — the local binding `Foo` (and therefore every usage site in\n * the file) stays exactly as the author wrote it.\n */\nconst findAliasedImportSpecifierEdit = (\n sourceFile: ts.SourceFile,\n packageName: string,\n importedName: string,\n replacement: string\n): Edit | null => {\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== packageName) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n for (const element of namedBindings.elements) {\n if (element.propertyName === undefined) continue;\n if (element.propertyName.text !== importedName) continue;\n return {\n start: element.propertyName.getStart(sourceFile),\n end: element.propertyName.getEnd(),\n text: replacement,\n };\n }\n }\n return null;\n};\n\nconst transformMenuListUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const edits: Array<Edit> = [];\n\n for (const { from, to } of RENAMES) {\n const localAlias = Object.entries(aliases).find(([, original]) => original === from)?.[0];\n if (localAlias === undefined) continue;\n\n if (localAlias === from) {\n edits.push(...collectIdentifierEdits(sourceFile, from, to));\n } else {\n const edit = findAliasedImportSpecifierEdit(sourceFile, PACKAGE_NAME, from, to);\n if (edit !== null) edits.push(edit);\n }\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => b.start - a.start);\n\n let updated = content;\n for (const { start, end, text } of edits) {\n updated = updated.slice(0, start) + text + updated.slice(end);\n }\n return updated;\n};\n\n/**\n * Renames `MenuList`/`MenuListProps` to `MenuContent`/`MenuContentProps`\n * everywhere they're imported from `@trackunit/react-components` — the\n * import specifier, every JSX tag usage, and every type reference (e.g.\n * `Omit<MenuListProps, \"children\">`).\n *\n * Aliased imports (`{ MenuList as Foo }`) only need the imported name\n * rewritten; the local alias and its usage sites are left untouched.\n * Unrelated same-prefix exports like `cvaMenuList`/`cvaMenuListItem` are\n * never matched since identifier comparisons are exact, not substring.\n */\nexport const menuListRenameToMenuContent = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"MenuList\", transformMenuListUsage);\n logSummary(\"menulist-rename-to-menucontent\", touched);\n};\n\nexport default menuListRenameToMenuContent;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyabletext-to-text-copybutton.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v3-0-0/copyabletext-to-text-copybutton.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,kDAQ4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,cAAc,CAAC;AAEtC,gFAAgF;AAChF,MAAM,aAAa,GAAG,CAAC,IAAqB,EAAiB,EAAE;IAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACrC,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;GA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AC5E,CAAC;IAED,mEAAmE;IACnE,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACpF,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;IACrE,CAAC;SAAM,CAAC;QACN,iBAAiB,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAE3E,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACI,MAAM,4BAA4B,GAAG,CAAC,IAAU,EAAQ,EAAE;IAC/D,iBAAiB,GAAG,CAAC,CAAC;IACtB,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,cAAc,EAAE,0BAA0B,CAAC,CAAC;IAChF,IAAA,sBAAU,EAAC,iCAAiC,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAC5E,CAAC,CAAC;AAJW,QAAA,4BAA4B,gCAIvC;AAEF,kBAAe,oCAA4B,CAAC","sourcesContent":["import { type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n hasSpreadAttribute,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"CopyableText\";\n\n/** Attribute initializer rendered back to source, e.g. `\"abc\"` or `{value}`. */\nconst attributeText = (attr: ts.JsxAttribute): string | null => {\n const initializer = attr.initializer;\n if (initializer === undefined) return null;\n return initializer.getText();\n};\n\n/**\n * The expression the copied text resolves to: `text=\"abc\"` yields `\"abc\"`,\n * `text={value}` yields `value`. Used both as the CopyButton value and as the\n * rendered children, so it must be a side-effect-free expression.\n */\nconst textExpression = (attr: ts.JsxAttribute): string | null => {\n const initializer = attr.initializer;\n if (initializer === undefined) return null;\n if (ts.isStringLiteral(initializer)) return initializer.getText();\n if (ts.isJsxExpression(initializer) && initializer.expression !== undefined) {\n return initializer.expression.getText();\n }\n return null;\n};\n\nconst renderReplacement = ({\n textExpr,\n size,\n copyLabelAttr,\n copiedLabelAttr,\n classNameLiteral,\n styleAttr,\n testIdAttr,\n textAlias,\n copyButtonAlias,\n}: {\n textExpr: string;\n size: \"sm\" | \"xs\";\n copyLabelAttr: string | null;\n copiedLabelAttr: string | null;\n classNameLiteral: string | null;\n styleAttr: string | null;\n testIdAttr: string | null;\n textAlias: string;\n copyButtonAlias: string;\n}): string => {\n const wrapperClasses = [\"flex\", \"min-w-0\", \"max-w-full\", \"items-center\", \"gap-0.5\", classNameLiteral]\n .filter(Boolean)\n .join(\" \");\n\n const wrapperAttrs = [\n `className=\"${wrapperClasses}\"`,\n styleAttr !== null ? `style=${styleAttr}` : null,\n testIdAttr !== null ? `data-testid=${testIdAttr}` : null,\n ]\n .filter(Boolean)\n .join(\" \");\n\n const textProps = [`className=\"min-w-0 truncate\"`, size === \"xs\" ? `size=\"small\"` : null, `type=\"span\"`]\n .filter(Boolean)\n .join(\" \");\n\n const buttonProps = [\n `className=\"shrink-0\"`,\n copiedLabelAttr !== null ? `copiedLabel=${copiedLabelAttr}` : null,\n copyLabelAttr !== null ? `copyLabel=${copyLabelAttr}` : null,\n size === \"xs\" ? `size=\"extraSmall\"` : null,\n `value={${textExpr}}`,\n ]\n .filter(Boolean)\n .join(\" \");\n\n return `<span ${wrapperAttrs}><${textAlias} ${textProps}>{${textExpr}}</${textAlias}><${copyButtonAlias} ${buttonProps} /></span>`;\n};\n\n/** Removes `name` (possibly aliased) from the package's named import list. */\nconst removeNamedImport = (content: string, packageName: string, name: string): string => {\n const sourceFile = parseTsx(content, \"source.tsx\");\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== packageName) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n const remaining = namedBindings.elements.filter(el => (el.propertyName?.text ?? el.name.text) !== name);\n if (remaining.length === namedBindings.elements.length) continue;\n\n if (remaining.length === 0) {\n // The import only carried this component; drop the whole statement.\n const start = stmt.getFullStart();\n const end = stmt.getEnd();\n const trailing = content.slice(end).startsWith(\"\\n\") ? end + 1 : end;\n return `${content.slice(0, start)}${content.slice(trailing)}`;\n }\n\n const elementsText = remaining.map(el => el.getText()).join(\", \");\n return `${content.slice(0, namedBindings.getStart())}{ ${elementsText} }${content.slice(namedBindings.getEnd())}`;\n }\n\n return content;\n};\n\nconst ensureNamedImport = (content: string, packageName: string, namesToAdd: ReadonlyArray<string>): string => {\n const sourceFile = parseTsx(content, \"source.tsx\");\n const aliases = getImportedAliases(sourceFile, packageName) ?? {};\n\n const missing = namesToAdd.filter(name => !Object.values(aliases).includes(name));\n if (missing.length === 0) return content;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== packageName) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n const elementsText = namedBindings.elements.map(el => el.getText()).join(\", \");\n const merged = [elementsText, ...missing].join(\", \");\n return `${content.slice(0, namedBindings.getStart())}{ ${merged} }${content.slice(namedBindings.getEnd())}`;\n }\n\n const importLine = `import { ${missing.join(\", \")} } from \"${packageName}\";\\n`;\n return `${importLine}${content}`;\n};\n\nlet manualReviewCount = 0;\n\nconst transformCopyableTextUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const copyableTextAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (copyableTextAlias === undefined) return null;\n\n // A referenced CopyableTextProps type cannot be rewritten mechanically;\n // leave the whole file for a human so it isn't half-migrated.\n if (Object.values(aliases).includes(\"CopyableTextProps\")) {\n manualReviewCount += 1;\n return null;\n }\n\n const matches = findJsxElements(sourceFile, [copyableTextAlias]);\n if (matches.length === 0) return null;\n\n type Edit = { start: number; end: number; replacement: string };\n const edits: Array<Edit> = [];\n\n for (const { openingElement, element } of matches) {\n if (hasSpreadAttribute(openingElement) || findJsxAttribute(openingElement, \"ref\") !== null) {\n manualReviewCount += 1;\n continue;\n }\n\n const textAttr = findJsxAttribute(openingElement, \"text\");\n const textExpr = textAttr !== null ? textExpression(textAttr) : null;\n if (textExpr === null) {\n manualReviewCount += 1;\n continue;\n }\n\n const sizeAttr = findJsxAttribute(openingElement, \"size\");\n const sizeInitializer = sizeAttr?.initializer;\n const size = sizeInitializer !== undefined && sizeInitializer.getText().includes(\"xs\") ? \"xs\" : \"sm\";\n\n const classNameAttr = findJsxAttribute(openingElement, \"className\");\n let classNameLiteral: string | null = null;\n if (classNameAttr !== null) {\n const initializer = classNameAttr.initializer;\n if (initializer !== undefined && ts.isStringLiteral(initializer)) {\n classNameLiteral = initializer.text;\n } else {\n // Dynamic classNames can't be merged into the wrapper's string safely.\n manualReviewCount += 1;\n continue;\n }\n }\n\n const copyLabelAttr = findJsxAttribute(openingElement, \"copyLabel\");\n const copiedLabelAttr = findJsxAttribute(openingElement, \"copiedLabel\");\n const styleAttr = findJsxAttribute(openingElement, \"style\");\n const testIdAttr = findJsxAttribute(openingElement, \"data-testid\");\n\n const replacement = renderReplacement({\n textExpr,\n size,\n copyLabelAttr: copyLabelAttr !== null ? attributeText(copyLabelAttr) : null,\n copiedLabelAttr: copiedLabelAttr !== null ? attributeText(copiedLabelAttr) : null,\n classNameLiteral,\n styleAttr: styleAttr !== null ? attributeText(styleAttr) : null,\n testIdAttr: testIdAttr !== null ? attributeText(testIdAttr) : null,\n textAlias: \"Text\",\n copyButtonAlias: \"CopyButton\",\n });\n\n edits.push({ start: element.getStart(), end: element.getEnd(), replacement });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => b.start - a.start);\n\n let updated = content;\n for (const { start, end, replacement } of edits) {\n updated = `${updated.slice(0, start)}${replacement}${updated.slice(end)}`;\n }\n\n // Only drop the import when every usage in the file was rewritten.\n const remaining = findJsxElements(parseTsx(updated, filePath), [copyableTextAlias]);\n if (remaining.length === 0) {\n updated = removeNamedImport(updated, PACKAGE_NAME, COMPONENT_NAME);\n } else {\n manualReviewCount += 1;\n }\n\n updated = ensureNamedImport(updated, PACKAGE_NAME, [\"Text\", \"CopyButton\"]);\n\n return updated;\n};\n\n/**\n * Rewrites `<CopyableText text={x} …/>` (removed in v3) into the plain\n * value/copy pair: a `Text` next to a `CopyButton` that copies the same\n * expression. `size=\"xs\"` maps to `Text size=\"small\"` + `CopyButton\n * size=\"extraSmall\"`; `copyLabel`/`copiedLabel` carry over (CopyButton also\n * ships localized defaults). Usages with spreads, refs, dynamic classNames,\n * or a referenced `CopyableTextProps` type are left for manual review.\n */\nexport const copyableTextToTextCopyButton = (tree: Tree): void => {\n manualReviewCount = 0;\n const touched = visitTsxFiles(tree, COMPONENT_NAME, transformCopyableTextUsage);\n logSummary(\"copyabletext-to-text-copybutton\", touched, manualReviewCount);\n};\n\nexport default copyableTextToTextCopyButton;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-to-router-components.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v4-0-0/move-to-router-components.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,yCAAiC;AACjC,kDAAgD;AAChD,oEAAgF;AAChF,oEAAgH;AAEhH,MAA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C,eAAM,CAAC,IAAI,CAAC,KAAK,cAAc,qCAAqC,SAAS,2BAA2B,CAAC,CAAC;QAC5G,CAAC;QAED,IAAI,MAAM,KAAK,mBAAmB,EAAE,CAAC;YACnC,KAAK,MAAM,eAAe,IAAI,IAAA,8CAAyB,EAAC,IAAI,EAAE,WAAW,CAAC,EAAE,CAAC;gBAC3E,eAAM,CAAC,IAAI,CACT,KAAK,cAAc,KAAK,eAAe,aAAa,WAAW,SAAS,SAAS,iDAAiD,CACnI,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAA,sBAAU,EAAC,cAAc,EAAE,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;AACvE,CAAC,CAAC;AAjCW,QAAA,sBAAsB,0BAiCjC;AAEF,kBAAe,8BAAsB,CAAC","sourcesContent":["import { logger, type Tree } from \"@nx/devkit\";\nimport { join } from \"node:path\";\nimport { logSummary } from \"../utils/jsx-utils\";\nimport { logManualReview, moveNamedImports } from \"../utils/move-named-imports\";\nimport { ensureDependency, findPackageJsonsDeclaring, readCompanionVersion } from \"../utils/package-json-utils\";\n\nconst MIGRATION_NAME = \"move-to-router-components\";\nconst FROM_MODULE = \"@trackunit/react-components\";\nconst TO_MODULE = \"@trackunit/react-router-components\";\n\n/** Exports that left `@trackunit/react-components` for `@trackunit/react-router-components`. */\nexport const ROUTER_COMPONENTS_MOVED_NAMES: ReadonlyArray<string> = [\n \"usePersistedState\",\n \"useSearchParamSync\",\n \"useCursorUrlSync\",\n \"MAX_URL_LENGTH\",\n \"UrlPersistenceLocation\",\n \"Breadcrumb\",\n];\n\n/**\n * `^<version>` of `@trackunit/react-router-components`. The published\n * package ships its package.json as a `build-migrations` asset; running from\n * source falls back to the workspace copy.\n */\nexport const resolveRouterComponentsRange = (): string =>\n `^${readCompanionVersion(TO_MODULE, [\n join(__dirname, \"../assets/react-router-components/package.json\"),\n join(__dirname, \"../../../router-components/package.json\"),\n ])}`;\n\n/**\n * Moves imports and re-exports of the router-coupled hooks, constants and components from\n * `@trackunit/react-components` to `@trackunit/react-router-components`.\n *\n * When something was rewritten, `@trackunit/react-router-components` is added\n * to the root package.json next to `@trackunit/react-components` (an\n * existing entry is kept). Per-project package.json files are only reported.\n * Throws before touching any file when the router-components version can't be\n * resolved, so a failed run leaves nothing half-migrated.\n */\nexport const moveToRouterComponents = (tree: Tree, resolveRange: () => string = resolveRouterComponentsRange): void => {\n const range = resolveRange();\n const { changedFiles, manualReview } = moveNamedImports(tree, {\n fromModule: FROM_MODULE,\n toModule: TO_MODULE,\n names: ROUTER_COMPONENTS_MOVED_NAMES,\n });\n logManualReview(MIGRATION_NAME, manualReview);\n\n if (changedFiles.length > 0) {\n const result = ensureDependency(tree, {\n packageName: TO_MODULE,\n range,\n besidePackage: FROM_MODULE,\n });\n if (result === \"added\") {\n logger.info(\n ` ${MIGRATION_NAME}: added ${TO_MODULE} to package.json; re-install dependencies (e.g. \\`yarn\\` or \\`npm install\\`) after running migrations`\n );\n } else if (result === \"no-package-json\") {\n logger.warn(` ${MIGRATION_NAME}: no root package.json found; add ${TO_MODULE} as a dependency yourself`);\n }\n\n if (result !== \"manager-workspace\") {\n for (const packageJsonPath of findPackageJsonsDeclaring(tree, FROM_MODULE)) {\n logger.warn(\n ` ${MIGRATION_NAME}: ${packageJsonPath} declares ${FROM_MODULE}; add ${TO_MODULE} there too if that project uses the moved names`\n );\n }\n }\n }\n\n logSummary(MIGRATION_NAME, changedFiles.length, manualReview.length);\n};\n\nexport default moveToRouterComponents;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.2-alpha-fbcc0881f4f.0",
|
|
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.49-alpha-fbcc0881f4f.0",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "2.6.51-alpha-fbcc0881f4f.0",
|
|
19
|
+
"@trackunit/shared-utils": "1.22.51-alpha-fbcc0881f4f.0",
|
|
20
|
+
"@trackunit/ui-icons": "1.20.49-alpha-fbcc0881f4f.0",
|
|
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.44-alpha-fbcc0881f4f.0"
|
|
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
|