@trackunit/react-components 2.10.3-alpha-472d410e126.0 → 2.10.4
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 +206 -0
- package/index.esm.js +206 -1
- package/package.json +6 -6
- package/src/components/Sidebar/Sidebar.d.ts +6 -0
- package/src/components/SidebarContentLayout/SidebarContentLayout.d.ts +70 -0
- package/src/components/SidebarContentLayout/SidebarContentLayout.variants.d.ts +87 -0
- package/src/index.d.ts +1 -0
- package/migrations/entry.js.map +0 -1
- package/migrations/utils/jsx-utils.js.map +0 -1
- package/migrations/v2-0-0/breadcrumb-remove-deprecated-props.js.map +0 -1
- package/migrations/v2-0-0/cardheader-onclickclose-to-actions.js.map +0 -1
- package/migrations/v2-0-0/iconbutton-add-required-name.js.map +0 -1
- package/migrations/v2-0-0/kpi-tooltiplabel-to-wrapper.js.map +0 -1
- package/migrations/v2-0-0/notice-tooltiplabel-to-wrapper.js.map +0 -1
- package/migrations/v2-0-0/pagination-add-required-titles.js.map +0 -1
- package/migrations/v2-0-0/tag-add-removetaglabel.js.map +0 -1
- package/migrations/v2-0-0/togglegroup-remove-item-style.js.map +0 -1
- package/migrations/v3-0-0/menulist-rename-to-menucontent.js.map +0 -1
package/index.cjs.js
CHANGED
|
@@ -11178,6 +11178,12 @@ const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id"
|
|
|
11178
11178
|
* ### When to use
|
|
11179
11179
|
* Use Sidebar for secondary in-page navigation (e.g., switching between views within a page). Works well with `Tabs` for page-level navigation.
|
|
11180
11180
|
*
|
|
11181
|
+
* If you need a persistent nav column beside a content region (a page-level sidebar+content
|
|
11182
|
+
* layout, e.g. Site Home, Administration, Asset Home), use `SidebarContentLayout` instead - it
|
|
11183
|
+
* composes `Sidebar` internally and keeps its stacking breakpoint in sync with the content grid.
|
|
11184
|
+
* Use `Sidebar` directly only for a standalone collapsing nav list with no content pane (e.g.
|
|
11185
|
+
* inside a `PageHeader`'s `tabsList`, see `Tabs.stories.tsx`'s `ResponsivenessTwo`/`Three`).
|
|
11186
|
+
*
|
|
11181
11187
|
* ### When not to use
|
|
11182
11188
|
* Do not use Sidebar for primary app navigation (the main menu). For top-level navigation, use the app shell navigation.
|
|
11183
11189
|
*
|
|
@@ -11237,6 +11243,205 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
11237
11243
|
}) })) })) : null] }));
|
|
11238
11244
|
};
|
|
11239
11245
|
|
|
11246
|
+
// Responsive-switch mechanism decision (GLU-1576 spike)
|
|
11247
|
+
// ------------------------------------------------------
|
|
11248
|
+
// Three mechanisms were considered for the stack<->side-by-side switch:
|
|
11249
|
+
//
|
|
11250
|
+
// 1. Native CSS `@container` (the `layout-dual-column-sections` precedent in
|
|
11251
|
+
// `libs/css/core/src/generators/generate-css-theme.ts`) - responds to this component's own
|
|
11252
|
+
// available space rather than the viewport, which is what the parent spec asks for as a
|
|
11253
|
+
// best-effort goal. Rejected for two reasons:
|
|
11254
|
+
// a. It cannot be meaningfully unit-tested in this repo's test environment. Vitest here runs
|
|
11255
|
+
// against jsdom, which has no layout engine and does not evaluate `@container` conditions -
|
|
11256
|
+
// the class list would be identical regardless of the (fake) container width, so a test
|
|
11257
|
+
// asserting "stacks below the breakpoint" vs. "side-by-side above it" would pass or fail for
|
|
11258
|
+
// reasons unrelated to the actual behavior it's meant to guard.
|
|
11259
|
+
// b. More fundamentally, `Sidebar`'s own internal tab-bar<->vertical-list switch
|
|
11260
|
+
// (`cvaSidebarChildContainer` in `../Sidebar/Sidebar.variants`) is hard-wired to viewport-based
|
|
11261
|
+
// Tailwind breakpoint classes (`lg:grid-cols-1` etc.), not container queries. Changing only
|
|
11262
|
+
// this component to a container query would let the two switches disagree whenever this
|
|
11263
|
+
// component's own width diverges from the viewport's - precisely the scenario a future side
|
|
11264
|
+
// panel would create by narrowing this component without narrowing the viewport. Migrating
|
|
11265
|
+
// `Sidebar` itself to `@container` is out of scope for this phase (blast radius across every
|
|
11266
|
+
// existing `Sidebar` consumer, not just this one).
|
|
11267
|
+
// 2. `useContainerBreakpoints` (`../../hooks/useContainerBreakpoints`) - real container-width-based
|
|
11268
|
+
// and unit-testable (it's backed by a mockable `ResizeObserver`, see its own spec file), but
|
|
11269
|
+
// suffers from the exact same mechanism-mismatch problem as (1): `Sidebar`'s own switch still
|
|
11270
|
+
// only reacts to viewport width, so "passing a consistent breakpoint value through" would only
|
|
11271
|
+
// guarantee a shared prop *label*, not a shared trigger *condition*.
|
|
11272
|
+
// 3. Viewport-based Tailwind breakpoint classes (chosen) - matches `Sidebar`'s own existing
|
|
11273
|
+
// mechanism byte-for-byte, so both switches are driven by the identical `@media (min-width: ...)`
|
|
11274
|
+
// condition for the identical breakpoint token and can never disagree, by construction. This is
|
|
11275
|
+
// the specification's explicitly-sanctioned final fallback ("non-blocking... acceptable if both
|
|
11276
|
+
// above prove impractical"). It also keeps this component a genuinely pure-presentation one - no
|
|
11277
|
+
// refs, no ResizeObserver, no effects - which matches `HostPage`'s own hook-free design.
|
|
11278
|
+
//
|
|
11279
|
+
// Trade-off: this does not satisfy the parent spec's best-effort "respond to own available space"
|
|
11280
|
+
// user story. That gap is accepted deliberately (the spec tracks it as "a known gap rather than a
|
|
11281
|
+
// blocker") rather than solved by a mechanism that would make the two breakpoint switches capable
|
|
11282
|
+
// of disagreeing with each other.
|
|
11283
|
+
/**
|
|
11284
|
+
* The root grid. `min-h-0 flex-1` opts this into an ancestor `HostPage`'s height-cascading flex-col
|
|
11285
|
+
* fill contract (see `HostPage.tsx`), so it gets a real, bounded height instead of an auto-height
|
|
11286
|
+
* block. No `gap-*` utility is applied here, ever: the single visible gap between sidebar and
|
|
11287
|
+
* content at the side-by-side breakpoint is contributed entirely by the content cell's own
|
|
11288
|
+
* `p-content-space` left padding (see `cvaSidebarContentLayoutContent`) - a grid gap on top of that
|
|
11289
|
+
* would silently double it.
|
|
11290
|
+
*
|
|
11291
|
+
* Below the breakpoint (stacked, single column), `grid-rows-[min-content_minmax(0px,1fr)]` pins the
|
|
11292
|
+
* sidebar's row to its own content height and gives the content row every pixel of leftover space.
|
|
11293
|
+
* Without an explicit row template, both rows default to `auto` sizing, and this grid's own bounded
|
|
11294
|
+
* height (from the `flex-1` fill contract above) is almost always taller than the two rows' combined
|
|
11295
|
+
* natural content height - `align-content`'s default `normal` computes to `stretch` for a grid
|
|
11296
|
+
* container, so that leftover space gets distributed *proportionally across every `auto` row*, not
|
|
11297
|
+
* just content's. That silently inflates the sidebar's row (and thus its box) well past its own
|
|
11298
|
+
* content's height, leaving a blank gap below the nav items before content starts - a stacked-only
|
|
11299
|
+
* sibling of the `minmax(min-content,1fr)` grid-blowout class of bug already fixed once for Asset
|
|
11300
|
+
* Home's own internal grid (GLU-1562/Phase 17). `{breakpoint}:grid-rows-none` resets this back to a
|
|
11301
|
+
* single implicit `auto` row at/above the breakpoint, where sidebar and content share one grid row
|
|
11302
|
+
* (as two columns) and must both keep stretching to the full available height per `{bp}:h-full`.
|
|
11303
|
+
*
|
|
11304
|
+
* Each breakpoint's arbitrary-value class is spelled out in full (rather than built via string
|
|
11305
|
+
* interpolation) because Tailwind's build-time scanner extracts candidate class names via a static
|
|
11306
|
+
* regex over each source file's raw text, not by evaluating JavaScript - an interpolated class name
|
|
11307
|
+
* would never appear as a complete literal string anywhere in this file and so would silently fail
|
|
11308
|
+
* to generate any CSS at all.
|
|
11309
|
+
*/
|
|
11310
|
+
const cvaSidebarContentLayout = cssClassVarianceUtilities.cvaMerge(["grid", "min-h-0", "flex-1", "grid-rows-[min-content_minmax(0px,1fr)]"], {
|
|
11311
|
+
variants: {
|
|
11312
|
+
breakpoint: {
|
|
11313
|
+
xs: ["grid-cols-1", "xs:grid-cols-[200px_minmax(0px,1fr)]", "xs:grid-rows-none"],
|
|
11314
|
+
sm: ["grid-cols-1", "sm:grid-cols-[200px_minmax(0px,1fr)]", "sm:grid-rows-none"],
|
|
11315
|
+
md: ["grid-cols-1", "md:grid-cols-[200px_minmax(0px,1fr)]", "md:grid-rows-none"],
|
|
11316
|
+
lg: ["grid-cols-1", "lg:grid-cols-[200px_minmax(0px,1fr)]", "lg:grid-rows-none"],
|
|
11317
|
+
xl: ["grid-cols-1", "xl:grid-cols-[200px_minmax(0px,1fr)]", "xl:grid-rows-none"],
|
|
11318
|
+
"2xl": ["grid-cols-1", "2xl:grid-cols-[200px_minmax(0px,1fr)]", "2xl:grid-rows-none"],
|
|
11319
|
+
"3xl": ["grid-cols-1", "3xl:grid-cols-[200px_minmax(0px,1fr)]", "3xl:grid-rows-none"],
|
|
11320
|
+
},
|
|
11321
|
+
},
|
|
11322
|
+
defaultVariants: {
|
|
11323
|
+
breakpoint: "lg",
|
|
11324
|
+
},
|
|
11325
|
+
});
|
|
11326
|
+
/**
|
|
11327
|
+
* The sidebar's own grid cell. `pt-4 pl-4` give it a fixed top/left inset (matching
|
|
11328
|
+
* `p-content-space`'s own `spacing-4`) now that there's no ambient ancestor padding left to inherit
|
|
11329
|
+
* one from.
|
|
11330
|
+
*
|
|
11331
|
+
* The right edge is a genuinely different edge depending on the breakpoint, so it's handled
|
|
11332
|
+
* accordingly rather than uniformly:
|
|
11333
|
+
* - Below the breakpoint, the grid is a single column (see `cvaSidebarContentLayout`), so the
|
|
11334
|
+
* sidebar spans the grid's full width and this edge is a true page edge, exactly like the left
|
|
11335
|
+
* edge - it gets the same `pr-4` inset.
|
|
11336
|
+
* - At/above the breakpoint, this edge instead borders the content column, and *most* of it is
|
|
11337
|
+
* owned entirely by content's own `p-content-space` left padding (see module doc comment above and
|
|
11338
|
+
* `cvaSidebarContentLayoutContent`) - stacking this cell's own `pr-4` on top of that would silently
|
|
11339
|
+
* double the gap. `{breakpoint}:pr-2` cancels *most*, but not all, of it there - see below for the
|
|
11340
|
+
* deliberate remainder.
|
|
11341
|
+
*
|
|
11342
|
+
* `h-full min-h-0 overflow-y-auto` (applied only from the breakpoint upward, matching `Sidebar`'s
|
|
11343
|
+
* own vertical-list mode) give the sidebar its own bounded height and local scroll: `Sidebar`'s
|
|
11344
|
+
* vertical nav list is unclipped by default, so a long list could otherwise be taller than the
|
|
11345
|
+
* grid row's available height, silently growing the row (the classic CSS grid "blowout") instead of
|
|
11346
|
+
* scrolling locally.
|
|
11347
|
+
*
|
|
11348
|
+
* `[scrollbar-gutter:stable]` rides along with that same `overflow-y-auto`, reserving genuine,
|
|
11349
|
+
* platform-correct scrollbar space (0 on overlay-scrollbar platforms like macOS, the native width
|
|
11350
|
+
* elsewhere) on the same edge, so a long enough nav list's scrollbar never overlaps the items - and
|
|
11351
|
+
* so the sidebar's rendered width stays consistent whether or not a *particular* page's item list
|
|
11352
|
+
* happens to be long enough to overflow. Supported by every evergreen browser (Chrome/Edge 94+,
|
|
11353
|
+
* Firefox 97+, Safari 18.2+); a no-op elsewhere, i.e. today's pre-fix behavior, so no regression risk.
|
|
11354
|
+
*
|
|
11355
|
+
* That reservation alone butts the items directly against the scrollbar track with zero breathing
|
|
11356
|
+
* room, though - `scrollbar-gutter` only guarantees no *overlap*, it isn't a visual gap. `{bp}:pr-2`
|
|
11357
|
+
* is the deliberate small remainder of the otherwise-cancelled `pr-4` that supplies that breathing
|
|
11358
|
+
* room, sized independently of both the scrollbar's own width (which the browser already reserves via
|
|
11359
|
+
* `scrollbar-gutter`) and of the sidebar/content gap above (which is `p-content-space`'s job, not
|
|
11360
|
+
* this padding's) - it exists purely so the sidebar's own content doesn't look glued to the sidebar's
|
|
11361
|
+
* own scrollbar. Keeping it a small fraction of the full `pr-4` (rather than restoring all of it, or
|
|
11362
|
+
* clawing space back from the reserved gutter) avoids meaningfully inflating the sidebar/content gap
|
|
11363
|
+
* `p-content-space` already owns - it is deliberately *not* zero, but not enough to look like a second
|
|
11364
|
+
* gap either.
|
|
11365
|
+
*/
|
|
11366
|
+
const cvaSidebarContentLayoutSidebar = cssClassVarianceUtilities.cvaMerge(["pt-4", "pl-4", "pr-4"], {
|
|
11367
|
+
variants: {
|
|
11368
|
+
breakpoint: {
|
|
11369
|
+
xs: ["xs:pr-2", "xs:h-full", "xs:min-h-0", "xs:overflow-y-auto", "xs:[scrollbar-gutter:stable]"],
|
|
11370
|
+
sm: ["sm:pr-2", "sm:h-full", "sm:min-h-0", "sm:overflow-y-auto", "sm:[scrollbar-gutter:stable]"],
|
|
11371
|
+
md: ["md:pr-2", "md:h-full", "md:min-h-0", "md:overflow-y-auto", "md:[scrollbar-gutter:stable]"],
|
|
11372
|
+
lg: ["lg:pr-2", "lg:h-full", "lg:min-h-0", "lg:overflow-y-auto", "lg:[scrollbar-gutter:stable]"],
|
|
11373
|
+
xl: ["xl:pr-2", "xl:h-full", "xl:min-h-0", "xl:overflow-y-auto", "xl:[scrollbar-gutter:stable]"],
|
|
11374
|
+
"2xl": ["2xl:pr-2", "2xl:h-full", "2xl:min-h-0", "2xl:overflow-y-auto", "2xl:[scrollbar-gutter:stable]"],
|
|
11375
|
+
"3xl": ["3xl:pr-2", "3xl:h-full", "3xl:min-h-0", "3xl:overflow-y-auto", "3xl:[scrollbar-gutter:stable]"],
|
|
11376
|
+
},
|
|
11377
|
+
},
|
|
11378
|
+
defaultVariants: {
|
|
11379
|
+
breakpoint: "lg",
|
|
11380
|
+
},
|
|
11381
|
+
});
|
|
11382
|
+
/**
|
|
11383
|
+
* The content's own grid cell: `relative` (a positioning context for a future side panel/drawer to
|
|
11384
|
+
* anchor into), a definite height (`h-full`, chained from the root grid's own fill contract) with
|
|
11385
|
+
* its own local `overflow-y-auto` (this cell's content may be a third-party iframe, which must
|
|
11386
|
+
* contain its own overflow rather than bubbling it up).
|
|
11387
|
+
*
|
|
11388
|
+
* `p-content-space` is applied here by default (`contentSpace: true`): the padding decision is
|
|
11389
|
+
* exposed on the component that owns the content's box, not silently forced by some invisible
|
|
11390
|
+
* ancestor. Callers rendering a route that must sit flush (e.g. a full-page extension iframe) opt
|
|
11391
|
+
* out with `contentSpace={false}`.
|
|
11392
|
+
*/
|
|
11393
|
+
const cvaSidebarContentLayoutContent = cssClassVarianceUtilities.cvaMerge(["relative", "h-full", "min-h-0", "overflow-y-auto"], {
|
|
11394
|
+
variants: {
|
|
11395
|
+
contentSpace: {
|
|
11396
|
+
true: ["p-content-space"],
|
|
11397
|
+
false: [],
|
|
11398
|
+
},
|
|
11399
|
+
},
|
|
11400
|
+
defaultVariants: {
|
|
11401
|
+
contentSpace: true,
|
|
11402
|
+
},
|
|
11403
|
+
});
|
|
11404
|
+
|
|
11405
|
+
/**
|
|
11406
|
+
* SidebarContentLayout is the shared page shell for any screen built from a persistent navigation
|
|
11407
|
+
* sidebar next to a main content area - the pattern behind Site Home, Administration, and Asset
|
|
11408
|
+
* Home. It keeps that pairing consistent everywhere it's used: the same breakpoint decides both
|
|
11409
|
+
* when the sidebar collapses to a tab bar and when content drops below it, so the two can never
|
|
11410
|
+
* disagree, and every page gets identical spacing without reimplementing it by hand.
|
|
11411
|
+
*
|
|
11412
|
+
* The content slot renders whatever it's given untouched - a routed `Outlet`, a form, a table - and
|
|
11413
|
+
* never imposes padding on it from the outside (see `contentSpace` to opt out of this component's
|
|
11414
|
+
* own default inset, e.g. for a full-page extension iframe that needs to sit flush to the edges).
|
|
11415
|
+
*
|
|
11416
|
+
* ### When to use
|
|
11417
|
+
* Use as the layout directly inside a `HostPage` for any page that needs a persistent navigation
|
|
11418
|
+
* sidebar alongside routed/tabbed content (e.g. Site Home, Administration, Asset Home).
|
|
11419
|
+
*
|
|
11420
|
+
* ### When not to use
|
|
11421
|
+
* Do not use for pages without a persistent sidebar - use `HostPage` directly instead.
|
|
11422
|
+
*
|
|
11423
|
+
* @example SidebarContentLayout with navigation items and routed content
|
|
11424
|
+
* ```tsx
|
|
11425
|
+
* import { SidebarContentLayout, SidebarItemProps } from "@trackunit/react-components";
|
|
11426
|
+
*
|
|
11427
|
+
* const SitePage = () => (
|
|
11428
|
+
* <SidebarContentLayout
|
|
11429
|
+
* content={<Outlet />}
|
|
11430
|
+
* sidebar={
|
|
11431
|
+
* <Button id="overview" variant="ghost-neutral">
|
|
11432
|
+
* Overview
|
|
11433
|
+
* </Button>
|
|
11434
|
+
* }
|
|
11435
|
+
* />
|
|
11436
|
+
* );
|
|
11437
|
+
* ```
|
|
11438
|
+
* @param {SidebarContentLayoutProps} props - The props for the SidebarContentLayout component
|
|
11439
|
+
* @returns {ReactElement} SidebarContentLayout component
|
|
11440
|
+
*/
|
|
11441
|
+
const SidebarContentLayout = ({ breakpoint = "lg", className, content, contentSpace = true, "data-testid": dataTestId = "sidebar-content-layout", sidebar, style, ref, }) => {
|
|
11442
|
+
return (jsxRuntime.jsxs("div", { className: cvaSidebarContentLayout({ breakpoint, className }), "data-testid": dataTestId, ref: ref, style: style, children: [jsxRuntime.jsx("div", { className: cvaSidebarContentLayoutSidebar({ breakpoint }), "data-testid": `${dataTestId}-sidebar`, children: jsxRuntime.jsx(Sidebar, { breakpoint: breakpoint, children: sidebar }) }), jsxRuntime.jsx("div", { className: cvaSidebarContentLayoutContent({ contentSpace }), "data-testid": `${dataTestId}-content`, children: content })] }));
|
|
11443
|
+
};
|
|
11444
|
+
|
|
11240
11445
|
const cvaTabsRoot = cssClassVarianceUtilities.cvaMerge([]);
|
|
11241
11446
|
const cvaTabList = cssClassVarianceUtilities.cvaMerge([
|
|
11242
11447
|
"flex",
|
|
@@ -14395,6 +14600,7 @@ exports.SectionHeader = SectionHeader;
|
|
|
14395
14600
|
exports.SegmentedValueBar = SegmentedValueBar;
|
|
14396
14601
|
exports.Sheet = Sheet;
|
|
14397
14602
|
exports.Sidebar = Sidebar;
|
|
14603
|
+
exports.SidebarContentLayout = SidebarContentLayout;
|
|
14398
14604
|
exports.SkeletonBlock = SkeletonBlock;
|
|
14399
14605
|
exports.SkeletonLabel = SkeletonLabel;
|
|
14400
14606
|
exports.SkeletonLines = SkeletonLines;
|
package/index.esm.js
CHANGED
|
@@ -11177,6 +11177,12 @@ const useOverflowItems = ({ threshold = 1, childUniqueIdentifierAttribute = "id"
|
|
|
11177
11177
|
* ### When to use
|
|
11178
11178
|
* Use Sidebar for secondary in-page navigation (e.g., switching between views within a page). Works well with `Tabs` for page-level navigation.
|
|
11179
11179
|
*
|
|
11180
|
+
* If you need a persistent nav column beside a content region (a page-level sidebar+content
|
|
11181
|
+
* layout, e.g. Site Home, Administration, Asset Home), use `SidebarContentLayout` instead - it
|
|
11182
|
+
* composes `Sidebar` internally and keeps its stacking breakpoint in sync with the content grid.
|
|
11183
|
+
* Use `Sidebar` directly only for a standalone collapsing nav list with no content pane (e.g.
|
|
11184
|
+
* inside a `PageHeader`'s `tabsList`, see `Tabs.stories.tsx`'s `ResponsivenessTwo`/`Three`).
|
|
11185
|
+
*
|
|
11180
11186
|
* ### When not to use
|
|
11181
11187
|
* Do not use Sidebar for primary app navigation (the main menu). For top-level navigation, use the app shell navigation.
|
|
11182
11188
|
*
|
|
@@ -11236,6 +11242,205 @@ const Sidebar = ({ childContainerClassName, children, breakpoint = "lg", classNa
|
|
|
11236
11242
|
}) })) })) : null] }));
|
|
11237
11243
|
};
|
|
11238
11244
|
|
|
11245
|
+
// Responsive-switch mechanism decision (GLU-1576 spike)
|
|
11246
|
+
// ------------------------------------------------------
|
|
11247
|
+
// Three mechanisms were considered for the stack<->side-by-side switch:
|
|
11248
|
+
//
|
|
11249
|
+
// 1. Native CSS `@container` (the `layout-dual-column-sections` precedent in
|
|
11250
|
+
// `libs/css/core/src/generators/generate-css-theme.ts`) - responds to this component's own
|
|
11251
|
+
// available space rather than the viewport, which is what the parent spec asks for as a
|
|
11252
|
+
// best-effort goal. Rejected for two reasons:
|
|
11253
|
+
// a. It cannot be meaningfully unit-tested in this repo's test environment. Vitest here runs
|
|
11254
|
+
// against jsdom, which has no layout engine and does not evaluate `@container` conditions -
|
|
11255
|
+
// the class list would be identical regardless of the (fake) container width, so a test
|
|
11256
|
+
// asserting "stacks below the breakpoint" vs. "side-by-side above it" would pass or fail for
|
|
11257
|
+
// reasons unrelated to the actual behavior it's meant to guard.
|
|
11258
|
+
// b. More fundamentally, `Sidebar`'s own internal tab-bar<->vertical-list switch
|
|
11259
|
+
// (`cvaSidebarChildContainer` in `../Sidebar/Sidebar.variants`) is hard-wired to viewport-based
|
|
11260
|
+
// Tailwind breakpoint classes (`lg:grid-cols-1` etc.), not container queries. Changing only
|
|
11261
|
+
// this component to a container query would let the two switches disagree whenever this
|
|
11262
|
+
// component's own width diverges from the viewport's - precisely the scenario a future side
|
|
11263
|
+
// panel would create by narrowing this component without narrowing the viewport. Migrating
|
|
11264
|
+
// `Sidebar` itself to `@container` is out of scope for this phase (blast radius across every
|
|
11265
|
+
// existing `Sidebar` consumer, not just this one).
|
|
11266
|
+
// 2. `useContainerBreakpoints` (`../../hooks/useContainerBreakpoints`) - real container-width-based
|
|
11267
|
+
// and unit-testable (it's backed by a mockable `ResizeObserver`, see its own spec file), but
|
|
11268
|
+
// suffers from the exact same mechanism-mismatch problem as (1): `Sidebar`'s own switch still
|
|
11269
|
+
// only reacts to viewport width, so "passing a consistent breakpoint value through" would only
|
|
11270
|
+
// guarantee a shared prop *label*, not a shared trigger *condition*.
|
|
11271
|
+
// 3. Viewport-based Tailwind breakpoint classes (chosen) - matches `Sidebar`'s own existing
|
|
11272
|
+
// mechanism byte-for-byte, so both switches are driven by the identical `@media (min-width: ...)`
|
|
11273
|
+
// condition for the identical breakpoint token and can never disagree, by construction. This is
|
|
11274
|
+
// the specification's explicitly-sanctioned final fallback ("non-blocking... acceptable if both
|
|
11275
|
+
// above prove impractical"). It also keeps this component a genuinely pure-presentation one - no
|
|
11276
|
+
// refs, no ResizeObserver, no effects - which matches `HostPage`'s own hook-free design.
|
|
11277
|
+
//
|
|
11278
|
+
// Trade-off: this does not satisfy the parent spec's best-effort "respond to own available space"
|
|
11279
|
+
// user story. That gap is accepted deliberately (the spec tracks it as "a known gap rather than a
|
|
11280
|
+
// blocker") rather than solved by a mechanism that would make the two breakpoint switches capable
|
|
11281
|
+
// of disagreeing with each other.
|
|
11282
|
+
/**
|
|
11283
|
+
* The root grid. `min-h-0 flex-1` opts this into an ancestor `HostPage`'s height-cascading flex-col
|
|
11284
|
+
* fill contract (see `HostPage.tsx`), so it gets a real, bounded height instead of an auto-height
|
|
11285
|
+
* block. No `gap-*` utility is applied here, ever: the single visible gap between sidebar and
|
|
11286
|
+
* content at the side-by-side breakpoint is contributed entirely by the content cell's own
|
|
11287
|
+
* `p-content-space` left padding (see `cvaSidebarContentLayoutContent`) - a grid gap on top of that
|
|
11288
|
+
* would silently double it.
|
|
11289
|
+
*
|
|
11290
|
+
* Below the breakpoint (stacked, single column), `grid-rows-[min-content_minmax(0px,1fr)]` pins the
|
|
11291
|
+
* sidebar's row to its own content height and gives the content row every pixel of leftover space.
|
|
11292
|
+
* Without an explicit row template, both rows default to `auto` sizing, and this grid's own bounded
|
|
11293
|
+
* height (from the `flex-1` fill contract above) is almost always taller than the two rows' combined
|
|
11294
|
+
* natural content height - `align-content`'s default `normal` computes to `stretch` for a grid
|
|
11295
|
+
* container, so that leftover space gets distributed *proportionally across every `auto` row*, not
|
|
11296
|
+
* just content's. That silently inflates the sidebar's row (and thus its box) well past its own
|
|
11297
|
+
* content's height, leaving a blank gap below the nav items before content starts - a stacked-only
|
|
11298
|
+
* sibling of the `minmax(min-content,1fr)` grid-blowout class of bug already fixed once for Asset
|
|
11299
|
+
* Home's own internal grid (GLU-1562/Phase 17). `{breakpoint}:grid-rows-none` resets this back to a
|
|
11300
|
+
* single implicit `auto` row at/above the breakpoint, where sidebar and content share one grid row
|
|
11301
|
+
* (as two columns) and must both keep stretching to the full available height per `{bp}:h-full`.
|
|
11302
|
+
*
|
|
11303
|
+
* Each breakpoint's arbitrary-value class is spelled out in full (rather than built via string
|
|
11304
|
+
* interpolation) because Tailwind's build-time scanner extracts candidate class names via a static
|
|
11305
|
+
* regex over each source file's raw text, not by evaluating JavaScript - an interpolated class name
|
|
11306
|
+
* would never appear as a complete literal string anywhere in this file and so would silently fail
|
|
11307
|
+
* to generate any CSS at all.
|
|
11308
|
+
*/
|
|
11309
|
+
const cvaSidebarContentLayout = cvaMerge(["grid", "min-h-0", "flex-1", "grid-rows-[min-content_minmax(0px,1fr)]"], {
|
|
11310
|
+
variants: {
|
|
11311
|
+
breakpoint: {
|
|
11312
|
+
xs: ["grid-cols-1", "xs:grid-cols-[200px_minmax(0px,1fr)]", "xs:grid-rows-none"],
|
|
11313
|
+
sm: ["grid-cols-1", "sm:grid-cols-[200px_minmax(0px,1fr)]", "sm:grid-rows-none"],
|
|
11314
|
+
md: ["grid-cols-1", "md:grid-cols-[200px_minmax(0px,1fr)]", "md:grid-rows-none"],
|
|
11315
|
+
lg: ["grid-cols-1", "lg:grid-cols-[200px_minmax(0px,1fr)]", "lg:grid-rows-none"],
|
|
11316
|
+
xl: ["grid-cols-1", "xl:grid-cols-[200px_minmax(0px,1fr)]", "xl:grid-rows-none"],
|
|
11317
|
+
"2xl": ["grid-cols-1", "2xl:grid-cols-[200px_minmax(0px,1fr)]", "2xl:grid-rows-none"],
|
|
11318
|
+
"3xl": ["grid-cols-1", "3xl:grid-cols-[200px_minmax(0px,1fr)]", "3xl:grid-rows-none"],
|
|
11319
|
+
},
|
|
11320
|
+
},
|
|
11321
|
+
defaultVariants: {
|
|
11322
|
+
breakpoint: "lg",
|
|
11323
|
+
},
|
|
11324
|
+
});
|
|
11325
|
+
/**
|
|
11326
|
+
* The sidebar's own grid cell. `pt-4 pl-4` give it a fixed top/left inset (matching
|
|
11327
|
+
* `p-content-space`'s own `spacing-4`) now that there's no ambient ancestor padding left to inherit
|
|
11328
|
+
* one from.
|
|
11329
|
+
*
|
|
11330
|
+
* The right edge is a genuinely different edge depending on the breakpoint, so it's handled
|
|
11331
|
+
* accordingly rather than uniformly:
|
|
11332
|
+
* - Below the breakpoint, the grid is a single column (see `cvaSidebarContentLayout`), so the
|
|
11333
|
+
* sidebar spans the grid's full width and this edge is a true page edge, exactly like the left
|
|
11334
|
+
* edge - it gets the same `pr-4` inset.
|
|
11335
|
+
* - At/above the breakpoint, this edge instead borders the content column, and *most* of it is
|
|
11336
|
+
* owned entirely by content's own `p-content-space` left padding (see module doc comment above and
|
|
11337
|
+
* `cvaSidebarContentLayoutContent`) - stacking this cell's own `pr-4` on top of that would silently
|
|
11338
|
+
* double the gap. `{breakpoint}:pr-2` cancels *most*, but not all, of it there - see below for the
|
|
11339
|
+
* deliberate remainder.
|
|
11340
|
+
*
|
|
11341
|
+
* `h-full min-h-0 overflow-y-auto` (applied only from the breakpoint upward, matching `Sidebar`'s
|
|
11342
|
+
* own vertical-list mode) give the sidebar its own bounded height and local scroll: `Sidebar`'s
|
|
11343
|
+
* vertical nav list is unclipped by default, so a long list could otherwise be taller than the
|
|
11344
|
+
* grid row's available height, silently growing the row (the classic CSS grid "blowout") instead of
|
|
11345
|
+
* scrolling locally.
|
|
11346
|
+
*
|
|
11347
|
+
* `[scrollbar-gutter:stable]` rides along with that same `overflow-y-auto`, reserving genuine,
|
|
11348
|
+
* platform-correct scrollbar space (0 on overlay-scrollbar platforms like macOS, the native width
|
|
11349
|
+
* elsewhere) on the same edge, so a long enough nav list's scrollbar never overlaps the items - and
|
|
11350
|
+
* so the sidebar's rendered width stays consistent whether or not a *particular* page's item list
|
|
11351
|
+
* happens to be long enough to overflow. Supported by every evergreen browser (Chrome/Edge 94+,
|
|
11352
|
+
* Firefox 97+, Safari 18.2+); a no-op elsewhere, i.e. today's pre-fix behavior, so no regression risk.
|
|
11353
|
+
*
|
|
11354
|
+
* That reservation alone butts the items directly against the scrollbar track with zero breathing
|
|
11355
|
+
* room, though - `scrollbar-gutter` only guarantees no *overlap*, it isn't a visual gap. `{bp}:pr-2`
|
|
11356
|
+
* is the deliberate small remainder of the otherwise-cancelled `pr-4` that supplies that breathing
|
|
11357
|
+
* room, sized independently of both the scrollbar's own width (which the browser already reserves via
|
|
11358
|
+
* `scrollbar-gutter`) and of the sidebar/content gap above (which is `p-content-space`'s job, not
|
|
11359
|
+
* this padding's) - it exists purely so the sidebar's own content doesn't look glued to the sidebar's
|
|
11360
|
+
* own scrollbar. Keeping it a small fraction of the full `pr-4` (rather than restoring all of it, or
|
|
11361
|
+
* clawing space back from the reserved gutter) avoids meaningfully inflating the sidebar/content gap
|
|
11362
|
+
* `p-content-space` already owns - it is deliberately *not* zero, but not enough to look like a second
|
|
11363
|
+
* gap either.
|
|
11364
|
+
*/
|
|
11365
|
+
const cvaSidebarContentLayoutSidebar = cvaMerge(["pt-4", "pl-4", "pr-4"], {
|
|
11366
|
+
variants: {
|
|
11367
|
+
breakpoint: {
|
|
11368
|
+
xs: ["xs:pr-2", "xs:h-full", "xs:min-h-0", "xs:overflow-y-auto", "xs:[scrollbar-gutter:stable]"],
|
|
11369
|
+
sm: ["sm:pr-2", "sm:h-full", "sm:min-h-0", "sm:overflow-y-auto", "sm:[scrollbar-gutter:stable]"],
|
|
11370
|
+
md: ["md:pr-2", "md:h-full", "md:min-h-0", "md:overflow-y-auto", "md:[scrollbar-gutter:stable]"],
|
|
11371
|
+
lg: ["lg:pr-2", "lg:h-full", "lg:min-h-0", "lg:overflow-y-auto", "lg:[scrollbar-gutter:stable]"],
|
|
11372
|
+
xl: ["xl:pr-2", "xl:h-full", "xl:min-h-0", "xl:overflow-y-auto", "xl:[scrollbar-gutter:stable]"],
|
|
11373
|
+
"2xl": ["2xl:pr-2", "2xl:h-full", "2xl:min-h-0", "2xl:overflow-y-auto", "2xl:[scrollbar-gutter:stable]"],
|
|
11374
|
+
"3xl": ["3xl:pr-2", "3xl:h-full", "3xl:min-h-0", "3xl:overflow-y-auto", "3xl:[scrollbar-gutter:stable]"],
|
|
11375
|
+
},
|
|
11376
|
+
},
|
|
11377
|
+
defaultVariants: {
|
|
11378
|
+
breakpoint: "lg",
|
|
11379
|
+
},
|
|
11380
|
+
});
|
|
11381
|
+
/**
|
|
11382
|
+
* The content's own grid cell: `relative` (a positioning context for a future side panel/drawer to
|
|
11383
|
+
* anchor into), a definite height (`h-full`, chained from the root grid's own fill contract) with
|
|
11384
|
+
* its own local `overflow-y-auto` (this cell's content may be a third-party iframe, which must
|
|
11385
|
+
* contain its own overflow rather than bubbling it up).
|
|
11386
|
+
*
|
|
11387
|
+
* `p-content-space` is applied here by default (`contentSpace: true`): the padding decision is
|
|
11388
|
+
* exposed on the component that owns the content's box, not silently forced by some invisible
|
|
11389
|
+
* ancestor. Callers rendering a route that must sit flush (e.g. a full-page extension iframe) opt
|
|
11390
|
+
* out with `contentSpace={false}`.
|
|
11391
|
+
*/
|
|
11392
|
+
const cvaSidebarContentLayoutContent = cvaMerge(["relative", "h-full", "min-h-0", "overflow-y-auto"], {
|
|
11393
|
+
variants: {
|
|
11394
|
+
contentSpace: {
|
|
11395
|
+
true: ["p-content-space"],
|
|
11396
|
+
false: [],
|
|
11397
|
+
},
|
|
11398
|
+
},
|
|
11399
|
+
defaultVariants: {
|
|
11400
|
+
contentSpace: true,
|
|
11401
|
+
},
|
|
11402
|
+
});
|
|
11403
|
+
|
|
11404
|
+
/**
|
|
11405
|
+
* SidebarContentLayout is the shared page shell for any screen built from a persistent navigation
|
|
11406
|
+
* sidebar next to a main content area - the pattern behind Site Home, Administration, and Asset
|
|
11407
|
+
* Home. It keeps that pairing consistent everywhere it's used: the same breakpoint decides both
|
|
11408
|
+
* when the sidebar collapses to a tab bar and when content drops below it, so the two can never
|
|
11409
|
+
* disagree, and every page gets identical spacing without reimplementing it by hand.
|
|
11410
|
+
*
|
|
11411
|
+
* The content slot renders whatever it's given untouched - a routed `Outlet`, a form, a table - and
|
|
11412
|
+
* never imposes padding on it from the outside (see `contentSpace` to opt out of this component's
|
|
11413
|
+
* own default inset, e.g. for a full-page extension iframe that needs to sit flush to the edges).
|
|
11414
|
+
*
|
|
11415
|
+
* ### When to use
|
|
11416
|
+
* Use as the layout directly inside a `HostPage` for any page that needs a persistent navigation
|
|
11417
|
+
* sidebar alongside routed/tabbed content (e.g. Site Home, Administration, Asset Home).
|
|
11418
|
+
*
|
|
11419
|
+
* ### When not to use
|
|
11420
|
+
* Do not use for pages without a persistent sidebar - use `HostPage` directly instead.
|
|
11421
|
+
*
|
|
11422
|
+
* @example SidebarContentLayout with navigation items and routed content
|
|
11423
|
+
* ```tsx
|
|
11424
|
+
* import { SidebarContentLayout, SidebarItemProps } from "@trackunit/react-components";
|
|
11425
|
+
*
|
|
11426
|
+
* const SitePage = () => (
|
|
11427
|
+
* <SidebarContentLayout
|
|
11428
|
+
* content={<Outlet />}
|
|
11429
|
+
* sidebar={
|
|
11430
|
+
* <Button id="overview" variant="ghost-neutral">
|
|
11431
|
+
* Overview
|
|
11432
|
+
* </Button>
|
|
11433
|
+
* }
|
|
11434
|
+
* />
|
|
11435
|
+
* );
|
|
11436
|
+
* ```
|
|
11437
|
+
* @param {SidebarContentLayoutProps} props - The props for the SidebarContentLayout component
|
|
11438
|
+
* @returns {ReactElement} SidebarContentLayout component
|
|
11439
|
+
*/
|
|
11440
|
+
const SidebarContentLayout = ({ breakpoint = "lg", className, content, contentSpace = true, "data-testid": dataTestId = "sidebar-content-layout", sidebar, style, ref, }) => {
|
|
11441
|
+
return (jsxs("div", { className: cvaSidebarContentLayout({ breakpoint, className }), "data-testid": dataTestId, ref: ref, style: style, children: [jsx("div", { className: cvaSidebarContentLayoutSidebar({ breakpoint }), "data-testid": `${dataTestId}-sidebar`, children: jsx(Sidebar, { breakpoint: breakpoint, children: sidebar }) }), jsx("div", { className: cvaSidebarContentLayoutContent({ contentSpace }), "data-testid": `${dataTestId}-content`, children: content })] }));
|
|
11442
|
+
};
|
|
11443
|
+
|
|
11239
11444
|
const cvaTabsRoot = cvaMerge([]);
|
|
11240
11445
|
const cvaTabList = cvaMerge([
|
|
11241
11446
|
"flex",
|
|
@@ -14325,4 +14530,4 @@ const useWindowActivity = ({ onFocus, onBlur, skip = false } = { onBlur: undefin
|
|
|
14325
14530
|
*/
|
|
14326
14531
|
setupLibraryTranslations();
|
|
14327
14532
|
|
|
14328
|
-
export { Alert, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyButton, CopyableText, DEFAULT_SKELETON_PREFERENCE_CARD_PROPS, DetailsList, EmptyState, EmptyValue, ExternalLink, GridAreas, Heading, Highlight, HorizontalOverflowScroller, Icon, IconButton, Indicator, KPI, KPICard, KPICardSkeleton, KPISkeleton, LabeledValue, LabeledValueList, List, ListItem, MAX_HASH_LENGTH, MAX_URL_LENGTH, MenuContent, MenuDivider, MenuItem, MenuTree, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, PageHeaderKpiMetrics, PageHeaderSecondaryActions, PageHeaderTitle, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, PreferenceCard, PreferenceCardSkeleton, Prompt, ROLE_CARD, SHEET_TRANSITION_DURATION, SHEET_TRANSITION_DURATION_MS, SHEET_TRANSITION_EASING, SectionHeader, SegmentedValueBar, Sheet, Sidebar, SkeletonBlock, SkeletonLabel, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, Tooltip, TrendIndicator, TrendIndicators, ValueBar, ZStack, createGrid, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaContainerStyles, cvaContentContainer, cvaContentWrapper, cvaDescriptionCard, cvaIconBackground, cvaIconButton, cvaImgStyles, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInputContainer, cvaInteractableItem, cvaList, cvaListContainer, cvaListItem$1 as cvaListItem, cvaMenu, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, cvaMenuList, cvaMenuListDivider, cvaMenuListItem, cvaMenuListMultiSelect, cvaPageHeader, cvaPageHeaderContainer, cvaPageHeaderHeading, cvaPreferenceCard, cvaTitleCard, cvaToggleGroup, cvaToggleGroupWithSlidingBackground, cvaToggleItem, cvaToggleItemContent, cvaToggleItemText, cvaZStackContainer, cvaZStackItem, defaultPageSize, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, noPagination, preferenceCardGrid, useBidirectionalScroll, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useCopyToClipboard, useCursorUrlSync, useCustomEncoding, useDebounce, useDevicePixelRatio, useElevatedReducer, useElevatedState, useGridAreas, useHashParamSync, useHover, useInfiniteScroll, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useKeyboardShortcut, useList, useListItemHeight, useLocalStorage, useLocalStorageReducer, useMeasure, useMenuTree, useMergeRefs, useModifierKey, useOptionalPopoverContext, useOverflowBorder, useOverflowItems, usePersistedState, usePopoverContext, usePrevious, usePrompt, useRandomCSSLengths, useRelayPagination, useResize, useScrollBlock, useScrollDetection, useSearchParamSync, useSelfUpdatingRef, useSessionStorage, useSessionStorageReducer, useSheet, useSheetSnap, useStorageKey, useTextSearch, useTimeout, useViewportBreakpoints, useWatch, useWindowActivity };
|
|
14533
|
+
export { Alert, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyButton, CopyableText, DEFAULT_SKELETON_PREFERENCE_CARD_PROPS, DetailsList, EmptyState, EmptyValue, ExternalLink, GridAreas, Heading, Highlight, HorizontalOverflowScroller, Icon, IconButton, Indicator, KPI, KPICard, KPICardSkeleton, KPISkeleton, LabeledValue, LabeledValueList, List, ListItem, MAX_HASH_LENGTH, MAX_URL_LENGTH, MenuContent, MenuDivider, MenuItem, MenuTree, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, PageHeaderKpiMetrics, PageHeaderSecondaryActions, PageHeaderTitle, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, PreferenceCard, PreferenceCardSkeleton, Prompt, ROLE_CARD, SHEET_TRANSITION_DURATION, SHEET_TRANSITION_DURATION_MS, SHEET_TRANSITION_EASING, SectionHeader, SegmentedValueBar, Sheet, Sidebar, SidebarContentLayout, SkeletonBlock, SkeletonLabel, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, Tooltip, TrendIndicator, TrendIndicators, ValueBar, ZStack, createGrid, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaContainerStyles, cvaContentContainer, cvaContentWrapper, cvaDescriptionCard, cvaIconBackground, cvaIconButton, cvaImgStyles, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInputContainer, cvaInteractableItem, cvaList, cvaListContainer, cvaListItem$1 as cvaListItem, cvaMenu, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, cvaMenuList, cvaMenuListDivider, cvaMenuListItem, cvaMenuListMultiSelect, cvaPageHeader, cvaPageHeaderContainer, cvaPageHeaderHeading, cvaPreferenceCard, cvaTitleCard, cvaToggleGroup, cvaToggleGroupWithSlidingBackground, cvaToggleItem, cvaToggleItemContent, cvaToggleItemText, cvaZStackContainer, cvaZStackItem, defaultPageSize, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, noPagination, preferenceCardGrid, useBidirectionalScroll, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useCopyToClipboard, useCursorUrlSync, useCustomEncoding, useDebounce, useDevicePixelRatio, useElevatedReducer, useElevatedState, useGridAreas, useHashParamSync, useHover, useInfiniteScroll, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useKeyboardShortcut, useList, useListItemHeight, useLocalStorage, useLocalStorageReducer, useMeasure, useMenuTree, useMergeRefs, useModifierKey, useOptionalPopoverContext, useOverflowBorder, useOverflowItems, usePersistedState, usePopoverContext, usePrevious, usePrompt, useRandomCSSLengths, useRelayPagination, useResize, useScrollBlock, useScrollDetection, useSearchParamSync, useSelfUpdatingRef, useSessionStorage, useSessionStorageReducer, useSheet, useSheetSnap, useStorageKey, useTextSearch, useTimeout, useViewportBreakpoints, useWatch, useWindowActivity };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.4",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"@floating-ui/react": "^0.26.25",
|
|
15
15
|
"string-ts": "^2.0.0",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.15.
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "1.14.
|
|
19
|
-
"@trackunit/shared-utils": "1.16.
|
|
20
|
-
"@trackunit/ui-icons": "1.14.
|
|
17
|
+
"@trackunit/ui-design-tokens": "1.15.6",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "1.14.17",
|
|
19
|
+
"@trackunit/shared-utils": "1.16.20",
|
|
20
|
+
"@trackunit/ui-icons": "1.14.16",
|
|
21
21
|
"es-toolkit": "^1.39.10",
|
|
22
22
|
"@tanstack/react-virtual": "^3.14.3",
|
|
23
23
|
"dequal": "^2.0.3",
|
|
24
24
|
"fflate": "^0.8.2",
|
|
25
25
|
"zod": "^3.25.76",
|
|
26
|
-
"@trackunit/i18n-library-translation": "2.4.
|
|
26
|
+
"@trackunit/i18n-library-translation": "2.4.13"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"react": "^19.0.0",
|
|
@@ -58,6 +58,12 @@ export interface SidebarProps extends CommonProps, Styleable, Refable<HTMLDivEle
|
|
|
58
58
|
* ### When to use
|
|
59
59
|
* Use Sidebar for secondary in-page navigation (e.g., switching between views within a page). Works well with `Tabs` for page-level navigation.
|
|
60
60
|
*
|
|
61
|
+
* If you need a persistent nav column beside a content region (a page-level sidebar+content
|
|
62
|
+
* layout, e.g. Site Home, Administration, Asset Home), use `SidebarContentLayout` instead - it
|
|
63
|
+
* composes `Sidebar` internally and keeps its stacking breakpoint in sync with the content grid.
|
|
64
|
+
* Use `Sidebar` directly only for a standalone collapsing nav list with no content pane (e.g.
|
|
65
|
+
* inside a `PageHeader`'s `tabsList`, see `Tabs.stories.tsx`'s `ResponsivenessTwo`/`Three`).
|
|
66
|
+
*
|
|
61
67
|
* ### When not to use
|
|
62
68
|
* Do not use Sidebar for primary app navigation (the main menu). For top-level navigation, use the app shell navigation.
|
|
63
69
|
*
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { CommonProps } from "../../common/CommonProps";
|
|
3
|
+
import { Refable } from "../../common/Refable";
|
|
4
|
+
import type { Styleable } from "../../common/Styleable";
|
|
5
|
+
import { Breakpoints, SidebarItemProps } from "../Sidebar/Sidebar";
|
|
6
|
+
export interface SidebarContentLayoutProps extends CommonProps, Styleable, Refable<HTMLDivElement> {
|
|
7
|
+
/**
|
|
8
|
+
* The sidebar's own navigation items, rendered through the shared `Sidebar` component. Passed as
|
|
9
|
+
* `Sidebar`'s `children` internally - see `Sidebar`'s own docs for the expected item shape.
|
|
10
|
+
*/
|
|
11
|
+
sidebar: Array<ReactElement<SidebarItemProps>> | ReactElement<SidebarItemProps>;
|
|
12
|
+
/**
|
|
13
|
+
* The main content, rendered in a bare, unpadded grid cell. Whatever is passed here owns its own
|
|
14
|
+
* padding - this component never mutates or wraps it in a way that would strip a class it applies
|
|
15
|
+
* to itself (see `contentSpace` for this component's own opt-in inset).
|
|
16
|
+
*/
|
|
17
|
+
content: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* The breakpoint at which sidebar and content switch from stacked to side-by-side. Passed straight
|
|
20
|
+
* through to `Sidebar`'s own `breakpoint` prop, so the grid's own switch and `Sidebar`'s internal
|
|
21
|
+
* tab-bar/vertical-list switch are driven by the identical condition and can never disagree.
|
|
22
|
+
*
|
|
23
|
+
* @default "lg"
|
|
24
|
+
*/
|
|
25
|
+
breakpoint?: Breakpoints;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the content cell applies its own `p-content-space` inset. Set to `false` for routes that
|
|
28
|
+
* must render flush against this cell's true edges (e.g. a full-page extension iframe).
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
contentSpace?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* SidebarContentLayout is the shared page shell for any screen built from a persistent navigation
|
|
36
|
+
* sidebar next to a main content area - the pattern behind Site Home, Administration, and Asset
|
|
37
|
+
* Home. It keeps that pairing consistent everywhere it's used: the same breakpoint decides both
|
|
38
|
+
* when the sidebar collapses to a tab bar and when content drops below it, so the two can never
|
|
39
|
+
* disagree, and every page gets identical spacing without reimplementing it by hand.
|
|
40
|
+
*
|
|
41
|
+
* The content slot renders whatever it's given untouched - a routed `Outlet`, a form, a table - and
|
|
42
|
+
* never imposes padding on it from the outside (see `contentSpace` to opt out of this component's
|
|
43
|
+
* own default inset, e.g. for a full-page extension iframe that needs to sit flush to the edges).
|
|
44
|
+
*
|
|
45
|
+
* ### When to use
|
|
46
|
+
* Use as the layout directly inside a `HostPage` for any page that needs a persistent navigation
|
|
47
|
+
* sidebar alongside routed/tabbed content (e.g. Site Home, Administration, Asset Home).
|
|
48
|
+
*
|
|
49
|
+
* ### When not to use
|
|
50
|
+
* Do not use for pages without a persistent sidebar - use `HostPage` directly instead.
|
|
51
|
+
*
|
|
52
|
+
* @example SidebarContentLayout with navigation items and routed content
|
|
53
|
+
* ```tsx
|
|
54
|
+
* import { SidebarContentLayout, SidebarItemProps } from "@trackunit/react-components";
|
|
55
|
+
*
|
|
56
|
+
* const SitePage = () => (
|
|
57
|
+
* <SidebarContentLayout
|
|
58
|
+
* content={<Outlet />}
|
|
59
|
+
* sidebar={
|
|
60
|
+
* <Button id="overview" variant="ghost-neutral">
|
|
61
|
+
* Overview
|
|
62
|
+
* </Button>
|
|
63
|
+
* }
|
|
64
|
+
* />
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
* @param {SidebarContentLayoutProps} props - The props for the SidebarContentLayout component
|
|
68
|
+
* @returns {ReactElement} SidebarContentLayout component
|
|
69
|
+
*/
|
|
70
|
+
export declare const SidebarContentLayout: ({ breakpoint, className, content, contentSpace, "data-testid": dataTestId, sidebar, style, ref, }: SidebarContentLayoutProps) => ReactElement;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The root grid. `min-h-0 flex-1` opts this into an ancestor `HostPage`'s height-cascading flex-col
|
|
3
|
+
* fill contract (see `HostPage.tsx`), so it gets a real, bounded height instead of an auto-height
|
|
4
|
+
* block. No `gap-*` utility is applied here, ever: the single visible gap between sidebar and
|
|
5
|
+
* content at the side-by-side breakpoint is contributed entirely by the content cell's own
|
|
6
|
+
* `p-content-space` left padding (see `cvaSidebarContentLayoutContent`) - a grid gap on top of that
|
|
7
|
+
* would silently double it.
|
|
8
|
+
*
|
|
9
|
+
* Below the breakpoint (stacked, single column), `grid-rows-[min-content_minmax(0px,1fr)]` pins the
|
|
10
|
+
* sidebar's row to its own content height and gives the content row every pixel of leftover space.
|
|
11
|
+
* Without an explicit row template, both rows default to `auto` sizing, and this grid's own bounded
|
|
12
|
+
* height (from the `flex-1` fill contract above) is almost always taller than the two rows' combined
|
|
13
|
+
* natural content height - `align-content`'s default `normal` computes to `stretch` for a grid
|
|
14
|
+
* container, so that leftover space gets distributed *proportionally across every `auto` row*, not
|
|
15
|
+
* just content's. That silently inflates the sidebar's row (and thus its box) well past its own
|
|
16
|
+
* content's height, leaving a blank gap below the nav items before content starts - a stacked-only
|
|
17
|
+
* sibling of the `minmax(min-content,1fr)` grid-blowout class of bug already fixed once for Asset
|
|
18
|
+
* Home's own internal grid (GLU-1562/Phase 17). `{breakpoint}:grid-rows-none` resets this back to a
|
|
19
|
+
* single implicit `auto` row at/above the breakpoint, where sidebar and content share one grid row
|
|
20
|
+
* (as two columns) and must both keep stretching to the full available height per `{bp}:h-full`.
|
|
21
|
+
*
|
|
22
|
+
* Each breakpoint's arbitrary-value class is spelled out in full (rather than built via string
|
|
23
|
+
* interpolation) because Tailwind's build-time scanner extracts candidate class names via a static
|
|
24
|
+
* regex over each source file's raw text, not by evaluating JavaScript - an interpolated class name
|
|
25
|
+
* would never appear as a complete literal string anywhere in this file and so would silently fail
|
|
26
|
+
* to generate any CSS at all.
|
|
27
|
+
*/
|
|
28
|
+
export declare const cvaSidebarContentLayout: (props?: ({
|
|
29
|
+
breakpoint?: "sm" | "xs" | "md" | "lg" | "xl" | "2xl" | "3xl" | null | undefined;
|
|
30
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
31
|
+
/**
|
|
32
|
+
* The sidebar's own grid cell. `pt-4 pl-4` give it a fixed top/left inset (matching
|
|
33
|
+
* `p-content-space`'s own `spacing-4`) now that there's no ambient ancestor padding left to inherit
|
|
34
|
+
* one from.
|
|
35
|
+
*
|
|
36
|
+
* The right edge is a genuinely different edge depending on the breakpoint, so it's handled
|
|
37
|
+
* accordingly rather than uniformly:
|
|
38
|
+
* - Below the breakpoint, the grid is a single column (see `cvaSidebarContentLayout`), so the
|
|
39
|
+
* sidebar spans the grid's full width and this edge is a true page edge, exactly like the left
|
|
40
|
+
* edge - it gets the same `pr-4` inset.
|
|
41
|
+
* - At/above the breakpoint, this edge instead borders the content column, and *most* of it is
|
|
42
|
+
* owned entirely by content's own `p-content-space` left padding (see module doc comment above and
|
|
43
|
+
* `cvaSidebarContentLayoutContent`) - stacking this cell's own `pr-4` on top of that would silently
|
|
44
|
+
* double the gap. `{breakpoint}:pr-2` cancels *most*, but not all, of it there - see below for the
|
|
45
|
+
* deliberate remainder.
|
|
46
|
+
*
|
|
47
|
+
* `h-full min-h-0 overflow-y-auto` (applied only from the breakpoint upward, matching `Sidebar`'s
|
|
48
|
+
* own vertical-list mode) give the sidebar its own bounded height and local scroll: `Sidebar`'s
|
|
49
|
+
* vertical nav list is unclipped by default, so a long list could otherwise be taller than the
|
|
50
|
+
* grid row's available height, silently growing the row (the classic CSS grid "blowout") instead of
|
|
51
|
+
* scrolling locally.
|
|
52
|
+
*
|
|
53
|
+
* `[scrollbar-gutter:stable]` rides along with that same `overflow-y-auto`, reserving genuine,
|
|
54
|
+
* platform-correct scrollbar space (0 on overlay-scrollbar platforms like macOS, the native width
|
|
55
|
+
* elsewhere) on the same edge, so a long enough nav list's scrollbar never overlaps the items - and
|
|
56
|
+
* so the sidebar's rendered width stays consistent whether or not a *particular* page's item list
|
|
57
|
+
* happens to be long enough to overflow. Supported by every evergreen browser (Chrome/Edge 94+,
|
|
58
|
+
* Firefox 97+, Safari 18.2+); a no-op elsewhere, i.e. today's pre-fix behavior, so no regression risk.
|
|
59
|
+
*
|
|
60
|
+
* That reservation alone butts the items directly against the scrollbar track with zero breathing
|
|
61
|
+
* room, though - `scrollbar-gutter` only guarantees no *overlap*, it isn't a visual gap. `{bp}:pr-2`
|
|
62
|
+
* is the deliberate small remainder of the otherwise-cancelled `pr-4` that supplies that breathing
|
|
63
|
+
* room, sized independently of both the scrollbar's own width (which the browser already reserves via
|
|
64
|
+
* `scrollbar-gutter`) and of the sidebar/content gap above (which is `p-content-space`'s job, not
|
|
65
|
+
* this padding's) - it exists purely so the sidebar's own content doesn't look glued to the sidebar's
|
|
66
|
+
* own scrollbar. Keeping it a small fraction of the full `pr-4` (rather than restoring all of it, or
|
|
67
|
+
* clawing space back from the reserved gutter) avoids meaningfully inflating the sidebar/content gap
|
|
68
|
+
* `p-content-space` already owns - it is deliberately *not* zero, but not enough to look like a second
|
|
69
|
+
* gap either.
|
|
70
|
+
*/
|
|
71
|
+
export declare const cvaSidebarContentLayoutSidebar: (props?: ({
|
|
72
|
+
breakpoint?: "sm" | "xs" | "md" | "lg" | "xl" | "2xl" | "3xl" | null | undefined;
|
|
73
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
74
|
+
/**
|
|
75
|
+
* The content's own grid cell: `relative` (a positioning context for a future side panel/drawer to
|
|
76
|
+
* anchor into), a definite height (`h-full`, chained from the root grid's own fill contract) with
|
|
77
|
+
* its own local `overflow-y-auto` (this cell's content may be a third-party iframe, which must
|
|
78
|
+
* contain its own overflow rather than bubbling it up).
|
|
79
|
+
*
|
|
80
|
+
* `p-content-space` is applied here by default (`contentSpace: true`): the padding decision is
|
|
81
|
+
* exposed on the component that owns the content's box, not silently forced by some invisible
|
|
82
|
+
* ancestor. Callers rendering a route that must sit flush (e.g. a full-page extension iframe) opt
|
|
83
|
+
* out with `contentSpace={false}`.
|
|
84
|
+
*/
|
|
85
|
+
export declare const cvaSidebarContentLayoutContent: (props?: ({
|
|
86
|
+
contentSpace?: boolean | null | undefined;
|
|
87
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
package/src/index.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export { useSheet } from "./components/Sheet/useSheet";
|
|
|
89
89
|
export { useSheetSnap } from "./components/Sheet/useSheetSnap";
|
|
90
90
|
export * from "./components/Sidebar/Sidebar";
|
|
91
91
|
export * from "./components/Sidebar/useOverflowItems";
|
|
92
|
+
export * from "./components/SidebarContentLayout/SidebarContentLayout";
|
|
92
93
|
export { useRandomCSSLengths } from "./components/Skeleton/Skeleton.helpers";
|
|
93
94
|
export type { CSSLength, CSSLengthUnit } from "./components/Skeleton/Skeleton.helpers";
|
|
94
95
|
export { SkeletonBlock } from "./components/Skeleton/SkeletonBlock/SkeletonBlock";
|
package/migrations/entry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-utils.js","sourceRoot":"","sources":["../../../../../../libs/react/components/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AAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAD7E,QAAA,QAAQ,YACqE;AAK1F;;;GAGG;AACI,MAAM,UAAU,GAAG,CAAC,aAAqB,EAAE,OAAe,EAAE,kBAA2B,EAAQ,EAAE;IACtG,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;QAClB,eAAM,CAAC,IAAI,CAAC,KAAK,aAAa,oBAAoB,CAAC,CAAC;QACpD,OAAO;IACT,CAAC;IACD,MAAM,YAAY,GAChB,kBAAkB,KAAK,SAAS,IAAI,kBAAkB,GAAG,CAAC;QACxD,CAAC,CAAC,KAAK,kBAAkB,kCAAkC;QAC3D,CAAC,CAAC,EAAE,CAAC;IACT,eAAM,CAAC,IAAI,CAAC,KAAK,aAAa,aAAa,OAAO,WAAW,YAAY,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC;AAVW,QAAA,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 { tsquery } from \"@phenomnomnominal/tsquery\";\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/** Re-exported for codemods that need direct AST queries. */\nexport { tsquery };\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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,C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AAC,CAAC;IACzD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;GAKG;AACI,MAAM,+BAA+B,GAAG,CAAC,IAAU,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,uDAAiC;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,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IACvE,CAAC;IAED,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC,GAAG,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,CAA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AAQ,EAAE;IAC5D,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,YAAY,EAAE,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,uDAAiC;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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AAwB,4BAGnC;AAEF,kBAAe,gCAAwB,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 = \"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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,uDAAiC;AACjC,kDAO4B;AAE5B,M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AKG;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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,C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AAG,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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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,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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,uDAAiC;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,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,UAAU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EF,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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"menulist-rename-to-menucontent.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v3-0-0/menulist-rename-to-menucontent.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AACjC,kDAA6F;AAE7F,MAAM,YAAY,GAAG,6BAA6B,CAAC;AAEnD,MAAM,OAAO,GAAkE;IAC7E,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,aAAa,EAAE;IACvC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE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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"]}
|