@trackunit/react-components 3.5.6 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +132 -42
- package/index.esm.js +132 -43
- package/migrations/entry.js.map +1 -0
- package/migrations/utils/jsx-utils.js.map +1 -0
- package/migrations/v2-0-0/breadcrumb-remove-deprecated-props.js.map +1 -0
- package/migrations/v2-0-0/cardheader-onclickclose-to-actions.js.map +1 -0
- package/migrations/v2-0-0/iconbutton-add-required-name.js.map +1 -0
- package/migrations/v2-0-0/kpi-tooltiplabel-to-wrapper.js.map +1 -0
- package/migrations/v2-0-0/notice-tooltiplabel-to-wrapper.js.map +1 -0
- package/migrations/v2-0-0/pagination-add-required-titles.js.map +1 -0
- package/migrations/v2-0-0/tag-add-removetaglabel.js.map +1 -0
- package/migrations/v2-0-0/togglegroup-remove-item-style.js.map +1 -0
- package/migrations/v3-0-0/copyabletext-to-text-copybutton.js.map +1 -0
- package/migrations/v3-0-0/menulist-rename-to-menucontent.js.map +1 -0
- package/package.json +6 -6
- package/src/common/StorybookProps.d.ts +1 -1
- package/src/components/CopyButton/CopyButton.d.ts +14 -15
- package/src/components/CopyableValue/CopyableValue.d.ts +86 -0
- package/src/components/CopyableValue/CopyableValue.variants.d.ts +60 -0
- package/src/index.d.ts +1 -0
- package/translation.cjs.js +1 -0
- package/translation.esm.js +1 -0
- package/translation10.cjs.js +1 -0
- package/translation10.esm.js +1 -0
- package/translation11.cjs.js +1 -0
- package/translation11.esm.js +1 -0
- package/translation12.cjs.js +1 -0
- package/translation12.esm.js +1 -0
- package/translation13.cjs.js +1 -0
- package/translation13.esm.js +1 -0
- package/translation14.cjs.js +1 -0
- package/translation14.esm.js +1 -0
- package/translation15.cjs.js +1 -0
- package/translation15.esm.js +1 -0
- package/translation16.cjs.js +1 -0
- package/translation16.esm.js +1 -0
- package/translation17.cjs.js +1 -0
- package/translation17.esm.js +1 -0
- package/translation2.cjs.js +1 -0
- package/translation2.esm.js +1 -0
- package/translation3.cjs.js +1 -0
- package/translation3.esm.js +1 -0
- package/translation4.cjs.js +1 -0
- package/translation4.esm.js +1 -0
- package/translation5.cjs.js +1 -0
- package/translation5.esm.js +1 -0
- package/translation6.cjs.js +1 -0
- package/translation6.esm.js +1 -0
- package/translation7.cjs.js +1 -0
- package/translation7.esm.js +1 -0
- package/translation8.cjs.js +1 -0
- package/translation8.esm.js +1 -0
- package/translation9.cjs.js +1 -0
- package/translation9.esm.js +1 -0
package/index.cjs.js
CHANGED
|
@@ -28,6 +28,7 @@ var zod = require('zod');
|
|
|
28
28
|
var defaultTranslations = {
|
|
29
29
|
"breadcrumb.backButton": "Back",
|
|
30
30
|
"breadcrumb.expandButton": "expand",
|
|
31
|
+
"copyableValue.copyValue": "Copy {{value}}",
|
|
31
32
|
"copyButton.copied": "Copied!",
|
|
32
33
|
"copyButton.copy": "Copy",
|
|
33
34
|
"horizontalOverflowScroller.scrollLeft": "Scroll left",
|
|
@@ -4773,28 +4774,27 @@ const useCopyToClipboard = () => {
|
|
|
4773
4774
|
* element, so the button can be placed next to plain (non-clickable) text.
|
|
4774
4775
|
*
|
|
4775
4776
|
* ### When to use
|
|
4776
|
-
* - Icon-only (default): the copyable value is displayed as plain text (e.g. in a table cell or
|
|
4777
|
-
* row) and only a dedicated icon should trigger the copy, keeping the rest of the row clickable.
|
|
4778
4777
|
* - Labelled (`label` set): copying is the primary action of a panel or section — e.g. an invite
|
|
4779
4778
|
* link — and deserves a full button that is itself the click target.
|
|
4779
|
+
* - Icon-only (default): a copy control on its own, where no value is displayed next to it — e.g.
|
|
4780
|
+
* in the corner of a code block.
|
|
4780
4781
|
*
|
|
4781
4782
|
* ### When not to use
|
|
4782
|
-
*
|
|
4783
|
-
*
|
|
4783
|
+
* - To show a value with a copy button beside it, use `CopyableValue` — it owns the layout,
|
|
4784
|
+
* truncation and hover highlight. Do not pair `Text` and `CopyButton` by hand.
|
|
4785
|
+
* - Do not hand-roll copy affordances (custom icons, click-to-copy text) — use this component or
|
|
4786
|
+
* `CopyableValue` instead.
|
|
4784
4787
|
*
|
|
4785
4788
|
* ### Empty values
|
|
4786
4789
|
* CopyButton renders nothing when `value` is empty, so consumers never present a copy control
|
|
4787
4790
|
* that has no meaningful result.
|
|
4788
4791
|
*
|
|
4789
|
-
* @example
|
|
4792
|
+
* @example Labelled button for an invite link
|
|
4790
4793
|
* ```tsx
|
|
4791
|
-
* import { CopyButton
|
|
4794
|
+
* import { CopyButton } from "@trackunit/react-components";
|
|
4792
4795
|
*
|
|
4793
|
-
* const
|
|
4794
|
-
* <
|
|
4795
|
-
* <Text type="span">{code}</Text>
|
|
4796
|
-
* <CopyButton value={code} />
|
|
4797
|
-
* </div>
|
|
4796
|
+
* const CopyInviteLink = ({ link }: { link: string }) => (
|
|
4797
|
+
* <CopyButton label="Copy link" value={link} variant="secondary" />
|
|
4798
4798
|
* );
|
|
4799
4799
|
* ```
|
|
4800
4800
|
* @param {CopyButtonProps} props - The props for the CopyButton component
|
|
@@ -4826,7 +4826,7 @@ const CopyButton = ({ value, copyLabel, copiedLabel, size = "small", label, vari
|
|
|
4826
4826
|
setShowCopied(true);
|
|
4827
4827
|
clearTimeout(resetTimerRef.current);
|
|
4828
4828
|
resetTimerRef.current = setTimeout(() => setShowCopied(false), COPIED_FEEDBACK_DURATION_MS);
|
|
4829
|
-
onCopy?.();
|
|
4829
|
+
onCopy?.(value);
|
|
4830
4830
|
}, () => undefined);
|
|
4831
4831
|
};
|
|
4832
4832
|
const buttonSize = toButtonSize(size);
|
|
@@ -4844,6 +4844,125 @@ const CopyButton = ({ value, copyLabel, copiedLabel, size = "small", label, vari
|
|
|
4844
4844
|
CopyButton.displayName = "CopyButton";
|
|
4845
4845
|
const COPIED_FEEDBACK_DURATION_MS = 2000;
|
|
4846
4846
|
|
|
4847
|
+
const cvaEmptyValue = cssClassVarianceUtilities.cva({ base: ["text-neutral-400"] });
|
|
4848
|
+
|
|
4849
|
+
/**
|
|
4850
|
+
* EmptyValue renders a consistent dash symbol ("–") to represent missing, null, undefined, or not applicable values.
|
|
4851
|
+
* It is primarily used in tables and detail lists to maintain visual consistency when data is absent.
|
|
4852
|
+
*
|
|
4853
|
+
* ### When to use
|
|
4854
|
+
* Use EmptyValue as a placeholder in table cells, detail lists, or any data display where values may be missing.
|
|
4855
|
+
*
|
|
4856
|
+
* ### When not to use
|
|
4857
|
+
* Do not use EmptyValue for empty pages or sections — use `EmptyState` instead.
|
|
4858
|
+
*
|
|
4859
|
+
* @example Empty value in a details row
|
|
4860
|
+
* ```tsx
|
|
4861
|
+
* import { EmptyValue, Text } from "@trackunit/react-components";
|
|
4862
|
+
*
|
|
4863
|
+
* const AssetDetail = ({ value }: { value?: string }) => (
|
|
4864
|
+
* <div className="flex justify-between">
|
|
4865
|
+
* <Text weight="bold">Serial Number</Text>
|
|
4866
|
+
* {value ? <Text>{value}</Text> : <EmptyValue />}
|
|
4867
|
+
* </div>
|
|
4868
|
+
* );
|
|
4869
|
+
* ```
|
|
4870
|
+
* @param {EmptyValueProps} props - The props for the EmptyValue component
|
|
4871
|
+
* @returns {ReactElement} EmptyValue component
|
|
4872
|
+
*/
|
|
4873
|
+
const EmptyValue = ({ className, "data-testid": dataTestId, style, ref }) => {
|
|
4874
|
+
return (jsxRuntime.jsx("div", { className: cvaEmptyValue({ className }), "data-testid": dataTestId, ref: ref, style: style, children: "-" }));
|
|
4875
|
+
};
|
|
4876
|
+
|
|
4877
|
+
// Named group so the highlight only reacts to this pair's own button, even when pairs are nested
|
|
4878
|
+
// inside other `group` scopes (table rows, cards).
|
|
4879
|
+
// `-ml-1` offsets the value's `pl-1`, so the text lines up with plain text and column headers while
|
|
4880
|
+
// the highlight's left padding reaches into the surrounding space (e.g. the cell padding); the
|
|
4881
|
+
// widened max width keeps the right edge where it was.
|
|
4882
|
+
const cvaCopyableValue = cssClassVarianceUtilities.cva({
|
|
4883
|
+
base: ["group/copyable-value", "items-center", "-ml-1", "max-w-[calc(100%+0.25rem)]"],
|
|
4884
|
+
variants: {
|
|
4885
|
+
inline: {
|
|
4886
|
+
// `overflow-hidden` + the max width defeat the grid/flex `min-width: auto` blowout, so the
|
|
4887
|
+
// value truncates inside table cells instead of widening them.
|
|
4888
|
+
false: ["flex", "min-w-0", "overflow-hidden"],
|
|
4889
|
+
true: ["inline-flex"],
|
|
4890
|
+
},
|
|
4891
|
+
},
|
|
4892
|
+
defaultVariants: {
|
|
4893
|
+
inline: false,
|
|
4894
|
+
},
|
|
4895
|
+
});
|
|
4896
|
+
// The value stretches to the button's height and tints while the button is hovered or keyboard-
|
|
4897
|
+
// focused, so value and button read as one fused control. `focus-visible` (not `focus`) keeps the
|
|
4898
|
+
// tint from sticking on a row after a mouse click. Anchors inside the value do not trigger it.
|
|
4899
|
+
const cvaCopyableValueText = cssClassVarianceUtilities.cva({
|
|
4900
|
+
base: [
|
|
4901
|
+
"min-w-0",
|
|
4902
|
+
"self-stretch",
|
|
4903
|
+
"content-center",
|
|
4904
|
+
"rounded-l-md",
|
|
4905
|
+
"pl-1",
|
|
4906
|
+
"pr-0.5",
|
|
4907
|
+
"transition-colors",
|
|
4908
|
+
"group-has-[button:hover]/copyable-value:bg-primary-100",
|
|
4909
|
+
"group-has-[button:focus-visible]/copyable-value:bg-primary-100",
|
|
4910
|
+
],
|
|
4911
|
+
variants: {
|
|
4912
|
+
inline: {
|
|
4913
|
+
false: ["truncate"],
|
|
4914
|
+
// Lets values without spaces (URLs, tokens) wrap inside their box instead of running under
|
|
4915
|
+
// the button.
|
|
4916
|
+
true: ["[overflow-wrap:anywhere]"],
|
|
4917
|
+
},
|
|
4918
|
+
},
|
|
4919
|
+
defaultVariants: {
|
|
4920
|
+
inline: false,
|
|
4921
|
+
},
|
|
4922
|
+
});
|
|
4923
|
+
// Squares the button's left edge against the value and matches the value's tint, completing the
|
|
4924
|
+
// fused look. The tint is owned here, inside the DS, rather than at call sites — the same way
|
|
4925
|
+
// CopyButton composes Button through cvaIconButton.
|
|
4926
|
+
const cvaCopyableValueButton = cssClassVarianceUtilities.cva({
|
|
4927
|
+
base: ["shrink-0", "rounded-l-none", "hover:bg-primary-100", "focus-visible:bg-primary-100"],
|
|
4928
|
+
});
|
|
4929
|
+
|
|
4930
|
+
/**
|
|
4931
|
+
* CopyableValue displays a value as plain (non-clickable) text with a copy button beside it. While the
|
|
4932
|
+
* button is hovered or focused, the value is highlighted together with it, so the two read as one control
|
|
4933
|
+
* and it is clear what will be copied.
|
|
4934
|
+
*
|
|
4935
|
+
* ### When to use
|
|
4936
|
+
* Use CopyableValue whenever a value such as an ID, short code, URL or token is shown and should be
|
|
4937
|
+
* copyable — in table cells, detail lists, cards and drawers. Long values truncate to the available
|
|
4938
|
+
* width while the full value is still copied.
|
|
4939
|
+
*
|
|
4940
|
+
* ### When not to use
|
|
4941
|
+
* - Do not hand-roll a `Text` + `CopyButton` pair — this component owns the layout, truncation and highlight.
|
|
4942
|
+
* - When copying is the primary action of a panel (e.g. an invite link), use `CopyButton` with a `label` instead.
|
|
4943
|
+
* - Do not make the value itself click-to-copy — only the button copies, so the surrounding row or
|
|
4944
|
+
* card stays clickable.
|
|
4945
|
+
*
|
|
4946
|
+
* @example Copyable account ID in a table cell
|
|
4947
|
+
* ```tsx
|
|
4948
|
+
* import { CopyableValue } from "@trackunit/react-components";
|
|
4949
|
+
*
|
|
4950
|
+
* const AccountIdCell = ({ accountId }: { accountId: string }) => (
|
|
4951
|
+
* <CopyableValue size="extraSmall" value={accountId} />
|
|
4952
|
+
* );
|
|
4953
|
+
* ```
|
|
4954
|
+
* @param {CopyableValueProps} props - The props for the CopyableValue component
|
|
4955
|
+
* @returns {ReactElement} CopyableValue component
|
|
4956
|
+
*/
|
|
4957
|
+
const CopyableValue = ({ value, children, copyLabel, copiedLabel, size = "small", textSize = "medium", inline = false, onCopy, className, style, "data-testid": dataTestId, ref, }) => {
|
|
4958
|
+
const [t] = useTranslation();
|
|
4959
|
+
if (value === "" && children === undefined) {
|
|
4960
|
+
return (jsxRuntime.jsx(EmptyValue, { className: className, "data-testid": dataTestId ? `${dataTestId}-empty` : undefined, style: style }));
|
|
4961
|
+
}
|
|
4962
|
+
return (jsxRuntime.jsxs("span", { className: cvaCopyableValue({ inline, className }), "data-testid": dataTestId, ref: ref, style: style, children: [jsxRuntime.jsx(Text, { className: cvaCopyableValueText({ inline }), size: textSize, type: "span", children: children ?? value }), jsxRuntime.jsx(CopyButton, { className: cvaCopyableValueButton(), copiedLabel: copiedLabel, copyLabel: copyLabel ?? t("copyableValue.copyValue", { value }), "data-testid": dataTestId ? `${dataTestId}-button` : undefined, onCopy: onCopy, size: size, value: value })] }));
|
|
4963
|
+
};
|
|
4964
|
+
CopyableValue.displayName = "CopyableValue";
|
|
4965
|
+
|
|
4847
4966
|
const cvaContainerStyles = cssClassVarianceUtilities.cva({
|
|
4848
4967
|
base: [
|
|
4849
4968
|
"flex",
|
|
@@ -4979,36 +5098,6 @@ const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customIma
|
|
|
4979
5098
|
return (jsxRuntime.jsx("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId ?? "empty-state", ref: ref, style: style, children: loading ? (jsxRuntime.jsxs("div", { className: "flex w-full flex-col items-center gap-4", children: [jsxRuntime.jsx(Spinner, { centering: "centered", "data-testid": "spinner" }), jsxRuntime.jsx(SkeletonLabel, { textSize: "text-base", width: "clamp(20%, 200px, 80%)" })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [customImageSrc !== null && customImageSrc !== undefined ? (typeof customImageSrc === "string" ? (jsxRuntime.jsx("img", { alt: altText, className: cvaImgStyles(), height: 200, src: customImageSrc, width: 200 })) : (customImageSrc)) : (typeof ImageSource !== "undefined" && (jsxRuntime.jsx(ImageSource, { "data-testid": "empty-state-image", height: 200, width: 200 }, image))), description !== undefined && description !== "" ? (jsxRuntime.jsx(Text, { align: "center", size: "medium", children: description })) : null, jsxRuntime.jsxs("div", { className: "mt-4 grid gap-3", children: [jsxRuntime.jsxs("div", { className: "flex gap-3", children: [secondaryAction ? (jsxRuntime.jsx(Button, { "data-testid": "empty-state-secondary-button", disabled: secondaryAction.disabled, onClick: secondaryAction.onClick, variant: "secondary", children: secondaryAction.to ? (jsxRuntime.jsx(reactRouter.Link, { params: secondaryAction.to.parameters, to: secondaryAction.to.pathname, children: secondaryAction.title })) : (secondaryAction.title) })) : null, primaryAction ? (jsxRuntime.jsx(Button, { "data-testid": "empty-state-primary-button", disabled: primaryAction.disabled, onClick: primaryAction.onClick, children: primaryAction.to ? (jsxRuntime.jsx(reactRouter.Link, { params: primaryAction.to.parameters, to: primaryAction.to.pathname, children: primaryAction.title })) : (primaryAction.title) })) : null] }), additionalHelpAction?.to ? (jsxRuntime.jsx(Button, { asChild: true, "data-testid": "empty-state-additional-button", disabled: additionalHelpAction.disabled, onClick: additionalHelpAction.onClick, suffix: jsxRuntime.jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" }), variant: "ghost", children: jsxRuntime.jsx(reactRouter.Link, { params: additionalHelpAction.to.parameters, target: additionalHelpAction.to.target, to: additionalHelpAction.to.pathname, children: additionalHelpAction.title }) })) : null] })] })) }));
|
|
4980
5099
|
};
|
|
4981
5100
|
|
|
4982
|
-
const cvaEmptyValue = cssClassVarianceUtilities.cva({ base: ["text-neutral-400"] });
|
|
4983
|
-
|
|
4984
|
-
/**
|
|
4985
|
-
* EmptyValue renders a consistent dash symbol ("–") to represent missing, null, undefined, or not applicable values.
|
|
4986
|
-
* It is primarily used in tables and detail lists to maintain visual consistency when data is absent.
|
|
4987
|
-
*
|
|
4988
|
-
* ### When to use
|
|
4989
|
-
* Use EmptyValue as a placeholder in table cells, detail lists, or any data display where values may be missing.
|
|
4990
|
-
*
|
|
4991
|
-
* ### When not to use
|
|
4992
|
-
* Do not use EmptyValue for empty pages or sections — use `EmptyState` instead.
|
|
4993
|
-
*
|
|
4994
|
-
* @example Empty value in a details row
|
|
4995
|
-
* ```tsx
|
|
4996
|
-
* import { EmptyValue, Text } from "@trackunit/react-components";
|
|
4997
|
-
*
|
|
4998
|
-
* const AssetDetail = ({ value }: { value?: string }) => (
|
|
4999
|
-
* <div className="flex justify-between">
|
|
5000
|
-
* <Text weight="bold">Serial Number</Text>
|
|
5001
|
-
* {value ? <Text>{value}</Text> : <EmptyValue />}
|
|
5002
|
-
* </div>
|
|
5003
|
-
* );
|
|
5004
|
-
* ```
|
|
5005
|
-
* @param {EmptyValueProps} props - The props for the EmptyValue component
|
|
5006
|
-
* @returns {ReactElement} EmptyValue component
|
|
5007
|
-
*/
|
|
5008
|
-
const EmptyValue = ({ className, "data-testid": dataTestId, style, ref }) => {
|
|
5009
|
-
return (jsxRuntime.jsx("div", { className: cvaEmptyValue({ className }), "data-testid": dataTestId, ref: ref, style: style, children: "-" }));
|
|
5010
|
-
};
|
|
5011
|
-
|
|
5012
5101
|
const cvaExternalLink = cssClassVarianceUtilities.cva({
|
|
5013
5102
|
base: ["underline", "decoration-[1.5px]", "underline-offset-2", "text-sm"],
|
|
5014
5103
|
variants: {
|
|
@@ -15830,6 +15919,7 @@ exports.CardHeader = CardHeader;
|
|
|
15830
15919
|
exports.Collapse = Collapse;
|
|
15831
15920
|
exports.CompletionStatusIndicator = CompletionStatusIndicator;
|
|
15832
15921
|
exports.CopyButton = CopyButton;
|
|
15922
|
+
exports.CopyableValue = CopyableValue;
|
|
15833
15923
|
exports.DEFAULT_SKELETON_PREFERENCE_CARD_PROPS = DEFAULT_SKELETON_PREFERENCE_CARD_PROPS;
|
|
15834
15924
|
exports.DetailsList = DetailsList;
|
|
15835
15925
|
exports.EmptyState = EmptyState;
|
package/index.esm.js
CHANGED
|
@@ -27,6 +27,7 @@ import { z } from 'zod';
|
|
|
27
27
|
var defaultTranslations = {
|
|
28
28
|
"breadcrumb.backButton": "Back",
|
|
29
29
|
"breadcrumb.expandButton": "expand",
|
|
30
|
+
"copyableValue.copyValue": "Copy {{value}}",
|
|
30
31
|
"copyButton.copied": "Copied!",
|
|
31
32
|
"copyButton.copy": "Copy",
|
|
32
33
|
"horizontalOverflowScroller.scrollLeft": "Scroll left",
|
|
@@ -4772,28 +4773,27 @@ const useCopyToClipboard = () => {
|
|
|
4772
4773
|
* element, so the button can be placed next to plain (non-clickable) text.
|
|
4773
4774
|
*
|
|
4774
4775
|
* ### When to use
|
|
4775
|
-
* - Icon-only (default): the copyable value is displayed as plain text (e.g. in a table cell or
|
|
4776
|
-
* row) and only a dedicated icon should trigger the copy, keeping the rest of the row clickable.
|
|
4777
4776
|
* - Labelled (`label` set): copying is the primary action of a panel or section — e.g. an invite
|
|
4778
4777
|
* link — and deserves a full button that is itself the click target.
|
|
4778
|
+
* - Icon-only (default): a copy control on its own, where no value is displayed next to it — e.g.
|
|
4779
|
+
* in the corner of a code block.
|
|
4779
4780
|
*
|
|
4780
4781
|
* ### When not to use
|
|
4781
|
-
*
|
|
4782
|
-
*
|
|
4782
|
+
* - To show a value with a copy button beside it, use `CopyableValue` — it owns the layout,
|
|
4783
|
+
* truncation and hover highlight. Do not pair `Text` and `CopyButton` by hand.
|
|
4784
|
+
* - Do not hand-roll copy affordances (custom icons, click-to-copy text) — use this component or
|
|
4785
|
+
* `CopyableValue` instead.
|
|
4783
4786
|
*
|
|
4784
4787
|
* ### Empty values
|
|
4785
4788
|
* CopyButton renders nothing when `value` is empty, so consumers never present a copy control
|
|
4786
4789
|
* that has no meaningful result.
|
|
4787
4790
|
*
|
|
4788
|
-
* @example
|
|
4791
|
+
* @example Labelled button for an invite link
|
|
4789
4792
|
* ```tsx
|
|
4790
|
-
* import { CopyButton
|
|
4793
|
+
* import { CopyButton } from "@trackunit/react-components";
|
|
4791
4794
|
*
|
|
4792
|
-
* const
|
|
4793
|
-
* <
|
|
4794
|
-
* <Text type="span">{code}</Text>
|
|
4795
|
-
* <CopyButton value={code} />
|
|
4796
|
-
* </div>
|
|
4795
|
+
* const CopyInviteLink = ({ link }: { link: string }) => (
|
|
4796
|
+
* <CopyButton label="Copy link" value={link} variant="secondary" />
|
|
4797
4797
|
* );
|
|
4798
4798
|
* ```
|
|
4799
4799
|
* @param {CopyButtonProps} props - The props for the CopyButton component
|
|
@@ -4825,7 +4825,7 @@ const CopyButton = ({ value, copyLabel, copiedLabel, size = "small", label, vari
|
|
|
4825
4825
|
setShowCopied(true);
|
|
4826
4826
|
clearTimeout(resetTimerRef.current);
|
|
4827
4827
|
resetTimerRef.current = setTimeout(() => setShowCopied(false), COPIED_FEEDBACK_DURATION_MS);
|
|
4828
|
-
onCopy?.();
|
|
4828
|
+
onCopy?.(value);
|
|
4829
4829
|
}, () => undefined);
|
|
4830
4830
|
};
|
|
4831
4831
|
const buttonSize = toButtonSize(size);
|
|
@@ -4843,6 +4843,125 @@ const CopyButton = ({ value, copyLabel, copiedLabel, size = "small", label, vari
|
|
|
4843
4843
|
CopyButton.displayName = "CopyButton";
|
|
4844
4844
|
const COPIED_FEEDBACK_DURATION_MS = 2000;
|
|
4845
4845
|
|
|
4846
|
+
const cvaEmptyValue = cva({ base: ["text-neutral-400"] });
|
|
4847
|
+
|
|
4848
|
+
/**
|
|
4849
|
+
* EmptyValue renders a consistent dash symbol ("–") to represent missing, null, undefined, or not applicable values.
|
|
4850
|
+
* It is primarily used in tables and detail lists to maintain visual consistency when data is absent.
|
|
4851
|
+
*
|
|
4852
|
+
* ### When to use
|
|
4853
|
+
* Use EmptyValue as a placeholder in table cells, detail lists, or any data display where values may be missing.
|
|
4854
|
+
*
|
|
4855
|
+
* ### When not to use
|
|
4856
|
+
* Do not use EmptyValue for empty pages or sections — use `EmptyState` instead.
|
|
4857
|
+
*
|
|
4858
|
+
* @example Empty value in a details row
|
|
4859
|
+
* ```tsx
|
|
4860
|
+
* import { EmptyValue, Text } from "@trackunit/react-components";
|
|
4861
|
+
*
|
|
4862
|
+
* const AssetDetail = ({ value }: { value?: string }) => (
|
|
4863
|
+
* <div className="flex justify-between">
|
|
4864
|
+
* <Text weight="bold">Serial Number</Text>
|
|
4865
|
+
* {value ? <Text>{value}</Text> : <EmptyValue />}
|
|
4866
|
+
* </div>
|
|
4867
|
+
* );
|
|
4868
|
+
* ```
|
|
4869
|
+
* @param {EmptyValueProps} props - The props for the EmptyValue component
|
|
4870
|
+
* @returns {ReactElement} EmptyValue component
|
|
4871
|
+
*/
|
|
4872
|
+
const EmptyValue = ({ className, "data-testid": dataTestId, style, ref }) => {
|
|
4873
|
+
return (jsx("div", { className: cvaEmptyValue({ className }), "data-testid": dataTestId, ref: ref, style: style, children: "-" }));
|
|
4874
|
+
};
|
|
4875
|
+
|
|
4876
|
+
// Named group so the highlight only reacts to this pair's own button, even when pairs are nested
|
|
4877
|
+
// inside other `group` scopes (table rows, cards).
|
|
4878
|
+
// `-ml-1` offsets the value's `pl-1`, so the text lines up with plain text and column headers while
|
|
4879
|
+
// the highlight's left padding reaches into the surrounding space (e.g. the cell padding); the
|
|
4880
|
+
// widened max width keeps the right edge where it was.
|
|
4881
|
+
const cvaCopyableValue = cva({
|
|
4882
|
+
base: ["group/copyable-value", "items-center", "-ml-1", "max-w-[calc(100%+0.25rem)]"],
|
|
4883
|
+
variants: {
|
|
4884
|
+
inline: {
|
|
4885
|
+
// `overflow-hidden` + the max width defeat the grid/flex `min-width: auto` blowout, so the
|
|
4886
|
+
// value truncates inside table cells instead of widening them.
|
|
4887
|
+
false: ["flex", "min-w-0", "overflow-hidden"],
|
|
4888
|
+
true: ["inline-flex"],
|
|
4889
|
+
},
|
|
4890
|
+
},
|
|
4891
|
+
defaultVariants: {
|
|
4892
|
+
inline: false,
|
|
4893
|
+
},
|
|
4894
|
+
});
|
|
4895
|
+
// The value stretches to the button's height and tints while the button is hovered or keyboard-
|
|
4896
|
+
// focused, so value and button read as one fused control. `focus-visible` (not `focus`) keeps the
|
|
4897
|
+
// tint from sticking on a row after a mouse click. Anchors inside the value do not trigger it.
|
|
4898
|
+
const cvaCopyableValueText = cva({
|
|
4899
|
+
base: [
|
|
4900
|
+
"min-w-0",
|
|
4901
|
+
"self-stretch",
|
|
4902
|
+
"content-center",
|
|
4903
|
+
"rounded-l-md",
|
|
4904
|
+
"pl-1",
|
|
4905
|
+
"pr-0.5",
|
|
4906
|
+
"transition-colors",
|
|
4907
|
+
"group-has-[button:hover]/copyable-value:bg-primary-100",
|
|
4908
|
+
"group-has-[button:focus-visible]/copyable-value:bg-primary-100",
|
|
4909
|
+
],
|
|
4910
|
+
variants: {
|
|
4911
|
+
inline: {
|
|
4912
|
+
false: ["truncate"],
|
|
4913
|
+
// Lets values without spaces (URLs, tokens) wrap inside their box instead of running under
|
|
4914
|
+
// the button.
|
|
4915
|
+
true: ["[overflow-wrap:anywhere]"],
|
|
4916
|
+
},
|
|
4917
|
+
},
|
|
4918
|
+
defaultVariants: {
|
|
4919
|
+
inline: false,
|
|
4920
|
+
},
|
|
4921
|
+
});
|
|
4922
|
+
// Squares the button's left edge against the value and matches the value's tint, completing the
|
|
4923
|
+
// fused look. The tint is owned here, inside the DS, rather than at call sites — the same way
|
|
4924
|
+
// CopyButton composes Button through cvaIconButton.
|
|
4925
|
+
const cvaCopyableValueButton = cva({
|
|
4926
|
+
base: ["shrink-0", "rounded-l-none", "hover:bg-primary-100", "focus-visible:bg-primary-100"],
|
|
4927
|
+
});
|
|
4928
|
+
|
|
4929
|
+
/**
|
|
4930
|
+
* CopyableValue displays a value as plain (non-clickable) text with a copy button beside it. While the
|
|
4931
|
+
* button is hovered or focused, the value is highlighted together with it, so the two read as one control
|
|
4932
|
+
* and it is clear what will be copied.
|
|
4933
|
+
*
|
|
4934
|
+
* ### When to use
|
|
4935
|
+
* Use CopyableValue whenever a value such as an ID, short code, URL or token is shown and should be
|
|
4936
|
+
* copyable — in table cells, detail lists, cards and drawers. Long values truncate to the available
|
|
4937
|
+
* width while the full value is still copied.
|
|
4938
|
+
*
|
|
4939
|
+
* ### When not to use
|
|
4940
|
+
* - Do not hand-roll a `Text` + `CopyButton` pair — this component owns the layout, truncation and highlight.
|
|
4941
|
+
* - When copying is the primary action of a panel (e.g. an invite link), use `CopyButton` with a `label` instead.
|
|
4942
|
+
* - Do not make the value itself click-to-copy — only the button copies, so the surrounding row or
|
|
4943
|
+
* card stays clickable.
|
|
4944
|
+
*
|
|
4945
|
+
* @example Copyable account ID in a table cell
|
|
4946
|
+
* ```tsx
|
|
4947
|
+
* import { CopyableValue } from "@trackunit/react-components";
|
|
4948
|
+
*
|
|
4949
|
+
* const AccountIdCell = ({ accountId }: { accountId: string }) => (
|
|
4950
|
+
* <CopyableValue size="extraSmall" value={accountId} />
|
|
4951
|
+
* );
|
|
4952
|
+
* ```
|
|
4953
|
+
* @param {CopyableValueProps} props - The props for the CopyableValue component
|
|
4954
|
+
* @returns {ReactElement} CopyableValue component
|
|
4955
|
+
*/
|
|
4956
|
+
const CopyableValue = ({ value, children, copyLabel, copiedLabel, size = "small", textSize = "medium", inline = false, onCopy, className, style, "data-testid": dataTestId, ref, }) => {
|
|
4957
|
+
const [t] = useTranslation();
|
|
4958
|
+
if (value === "" && children === undefined) {
|
|
4959
|
+
return (jsx(EmptyValue, { className: className, "data-testid": dataTestId ? `${dataTestId}-empty` : undefined, style: style }));
|
|
4960
|
+
}
|
|
4961
|
+
return (jsxs("span", { className: cvaCopyableValue({ inline, className }), "data-testid": dataTestId, ref: ref, style: style, children: [jsx(Text, { className: cvaCopyableValueText({ inline }), size: textSize, type: "span", children: children ?? value }), jsx(CopyButton, { className: cvaCopyableValueButton(), copiedLabel: copiedLabel, copyLabel: copyLabel ?? t("copyableValue.copyValue", { value }), "data-testid": dataTestId ? `${dataTestId}-button` : undefined, onCopy: onCopy, size: size, value: value })] }));
|
|
4962
|
+
};
|
|
4963
|
+
CopyableValue.displayName = "CopyableValue";
|
|
4964
|
+
|
|
4846
4965
|
const cvaContainerStyles = cva({
|
|
4847
4966
|
base: [
|
|
4848
4967
|
"flex",
|
|
@@ -4978,36 +5097,6 @@ const EmptyState = ({ description, altText, image = "SEARCH_DOCUMENT", customIma
|
|
|
4978
5097
|
return (jsx("div", { className: cvaContainerStyles({ className }), "data-testid": dataTestId ?? "empty-state", ref: ref, style: style, children: loading ? (jsxs("div", { className: "flex w-full flex-col items-center gap-4", children: [jsx(Spinner, { centering: "centered", "data-testid": "spinner" }), jsx(SkeletonLabel, { textSize: "text-base", width: "clamp(20%, 200px, 80%)" })] })) : (jsxs(Fragment, { children: [customImageSrc !== null && customImageSrc !== undefined ? (typeof customImageSrc === "string" ? (jsx("img", { alt: altText, className: cvaImgStyles(), height: 200, src: customImageSrc, width: 200 })) : (customImageSrc)) : (typeof ImageSource !== "undefined" && (jsx(ImageSource, { "data-testid": "empty-state-image", height: 200, width: 200 }, image))), description !== undefined && description !== "" ? (jsx(Text, { align: "center", size: "medium", children: description })) : null, jsxs("div", { className: "mt-4 grid gap-3", children: [jsxs("div", { className: "flex gap-3", children: [secondaryAction ? (jsx(Button, { "data-testid": "empty-state-secondary-button", disabled: secondaryAction.disabled, onClick: secondaryAction.onClick, variant: "secondary", children: secondaryAction.to ? (jsx(Link, { params: secondaryAction.to.parameters, to: secondaryAction.to.pathname, children: secondaryAction.title })) : (secondaryAction.title) })) : null, primaryAction ? (jsx(Button, { "data-testid": "empty-state-primary-button", disabled: primaryAction.disabled, onClick: primaryAction.onClick, children: primaryAction.to ? (jsx(Link, { params: primaryAction.to.parameters, to: primaryAction.to.pathname, children: primaryAction.title })) : (primaryAction.title) })) : null] }), additionalHelpAction?.to ? (jsx(Button, { asChild: true, "data-testid": "empty-state-additional-button", disabled: additionalHelpAction.disabled, onClick: additionalHelpAction.onClick, suffix: jsx(Icon, { name: "ArrowTopRightOnSquare", size: "small" }), variant: "ghost", children: jsx(Link, { params: additionalHelpAction.to.parameters, target: additionalHelpAction.to.target, to: additionalHelpAction.to.pathname, children: additionalHelpAction.title }) })) : null] })] })) }));
|
|
4979
5098
|
};
|
|
4980
5099
|
|
|
4981
|
-
const cvaEmptyValue = cva({ base: ["text-neutral-400"] });
|
|
4982
|
-
|
|
4983
|
-
/**
|
|
4984
|
-
* EmptyValue renders a consistent dash symbol ("–") to represent missing, null, undefined, or not applicable values.
|
|
4985
|
-
* It is primarily used in tables and detail lists to maintain visual consistency when data is absent.
|
|
4986
|
-
*
|
|
4987
|
-
* ### When to use
|
|
4988
|
-
* Use EmptyValue as a placeholder in table cells, detail lists, or any data display where values may be missing.
|
|
4989
|
-
*
|
|
4990
|
-
* ### When not to use
|
|
4991
|
-
* Do not use EmptyValue for empty pages or sections — use `EmptyState` instead.
|
|
4992
|
-
*
|
|
4993
|
-
* @example Empty value in a details row
|
|
4994
|
-
* ```tsx
|
|
4995
|
-
* import { EmptyValue, Text } from "@trackunit/react-components";
|
|
4996
|
-
*
|
|
4997
|
-
* const AssetDetail = ({ value }: { value?: string }) => (
|
|
4998
|
-
* <div className="flex justify-between">
|
|
4999
|
-
* <Text weight="bold">Serial Number</Text>
|
|
5000
|
-
* {value ? <Text>{value}</Text> : <EmptyValue />}
|
|
5001
|
-
* </div>
|
|
5002
|
-
* );
|
|
5003
|
-
* ```
|
|
5004
|
-
* @param {EmptyValueProps} props - The props for the EmptyValue component
|
|
5005
|
-
* @returns {ReactElement} EmptyValue component
|
|
5006
|
-
*/
|
|
5007
|
-
const EmptyValue = ({ className, "data-testid": dataTestId, style, ref }) => {
|
|
5008
|
-
return (jsx("div", { className: cvaEmptyValue({ className }), "data-testid": dataTestId, ref: ref, style: style, children: "-" }));
|
|
5009
|
-
};
|
|
5010
|
-
|
|
5011
5100
|
const cvaExternalLink = cva({
|
|
5012
5101
|
base: ["underline", "decoration-[1.5px]", "underline-offset-2", "text-sm"],
|
|
5013
5102
|
variants: {
|
|
@@ -15814,4 +15903,4 @@ const useWindowActivity = ({ onFocus, onBlur, skip = false } = { onBlur: undefin
|
|
|
15814
15903
|
*/
|
|
15815
15904
|
setupLibraryTranslations();
|
|
15816
15905
|
|
|
15817
|
-
export { Alert, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyButton, DEFAULT_SKELETON_PREFERENCE_CARD_PROPS, DetailsList, EmptyState, EmptyValue, ExternalLink, GridAreas, Heading, Highlight, HorizontalOverflowScroller, Icon, IconButton, IdentityCard, IdentityCardSkeleton, 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, useHold, useHover, useInfiniteScroll, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useKeyboardShortcut, useList, useListItemHeight, useLocalStorage, useLocalStorageReducer, useMeasure, useMenuSearchField, useMenuTree, useMergeRefs, useModifierKey, useOptionalPopoverContext, useOverflowBorder, useOverflowItems, usePersistedState, usePopoverContext, usePrevious, usePrompt, useRandomCSSLengths, useRelayPagination, useResize, useScrollBlock, useScrollDetection, useSearchParamSync, useSelfUpdatingRef, useSessionStorage, useSessionStorageReducer, useSheet, useSheetSnap, useStorageKey, useStripForeignIdentityHash, useTextSearch, useTimeout, useViewportBreakpoints, useWatch, useWindowActivity };
|
|
15906
|
+
export { Alert, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyButton, CopyableValue, DEFAULT_SKELETON_PREFERENCE_CARD_PROPS, DetailsList, EmptyState, EmptyValue, ExternalLink, GridAreas, Heading, Highlight, HorizontalOverflowScroller, Icon, IconButton, IdentityCard, IdentityCardSkeleton, 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, useHold, useHover, useInfiniteScroll, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useKeyboardShortcut, useList, useListItemHeight, useLocalStorage, useLocalStorageReducer, useMeasure, useMenuSearchField, useMenuTree, useMergeRefs, useModifierKey, useOptionalPopoverContext, useOverflowBorder, useOverflowItems, usePersistedState, usePopoverContext, usePrevious, usePrompt, useRandomCSSLengths, useRelayPagination, useResize, useScrollBlock, useScrollDetection, useSearchParamSync, useSelfUpdatingRef, useSessionStorage, useSessionStorageReducer, useSheet, useSheetSnap, useStorageKey, useStripForeignIdentityHash, useTextSearch, useTimeout, useViewportBreakpoints, useWatch, useWindowActivity };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/components/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["// Migration entry point for @nx/js:tsc build target.\n// Migrations are registered in ../migrations.json and resolved by NX at runtime.\nexport {};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-utils.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/utils/jsx-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAqE;AACrE,+CAAiC;AAEjC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AACjD,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAEvD,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAW,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AACpG,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAW,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAElG,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAW,EAAE,CACvD,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;AAE9E,MAAM,WAAW,GAAG,CAAC,QAAgB,EAAW,EAAE,CAChD,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,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AC,CAAC;AARW,QAAA,6BAA6B,iCAQxC","sourcesContent":["import { logger, type Tree, visitNotIgnoredFiles } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\n\nconst TSX_EXTENSIONS = [\".tsx\", \".jsx\"] as const;\nconst TS_EXTENSIONS = [\".ts\", \".tsx\", \".jsx\"] as const;\n\nconst isTsxFile = (filePath: string): boolean => TSX_EXTENSIONS.some(ext => filePath.endsWith(ext));\nconst isTsFile = (filePath: string): boolean => TS_EXTENSIONS.some(ext => filePath.endsWith(ext));\n\nconst isUnderNodeModules = (filePath: string): boolean =>\n filePath.includes(\"/node_modules/\") || filePath.startsWith(\"node_modules/\");\n\nconst isUnderDist = (filePath: string): boolean =>\n filePath.includes(\"/dist/\") || filePath.startsWith(\"dist/\") || filePath.includes(\"/.nx/\");\n\n/**\n * Visits every `.tsx`/`.jsx` file under the workspace root and invokes the\n * callback with the file path and its current contents. Files that don't\n * include the marker substring are skipped, which makes large workspaces\n * cheap to scan.\n */\nexport const visitTsxFiles = (\n tree: Tree,\n marker: string,\n callback: (filePath: string, content: string) => string | null | undefined\n): number => {\n let touched = 0;\n visitNotIgnoredFiles(tree, \"/\", filePath => {\n if (!isTsxFile(filePath)) return;\n if (isUnderNodeModules(filePath) || isUnderDist(filePath)) return;\n const content = tree.read(filePath, \"utf-8\");\n if (content === null) return;\n if (!content.includes(marker)) return;\n const updated = callback(filePath, content);\n if (updated !== null && updated !== undefined && updated !== content) {\n tree.write(filePath, updated);\n touched += 1;\n }\n });\n return touched;\n};\n\n/**\n * Same as {@link visitTsxFiles} but also includes plain `.ts` files. Use this\n * when the codemod also rewrites non-JSX files such as helpers or hooks.\n */\nexport const visitTsFiles = (\n tree: Tree,\n marker: string,\n callback: (filePath: string, content: string) => string | null | undefined\n): number => {\n let touched = 0;\n visitNotIgnoredFiles(tree, \"/\", filePath => {\n if (!isTsFile(filePath)) return;\n if (isUnderNodeModules(filePath) || isUnderDist(filePath)) return;\n const content = tree.read(filePath, \"utf-8\");\n if (content === null) return;\n if (!content.includes(marker)) return;\n const updated = callback(filePath, content);\n if (updated !== null && updated !== undefined && updated !== content) {\n tree.write(filePath, updated);\n touched += 1;\n }\n });\n return touched;\n};\n\n/**\n * Mapping of imported component aliases to their original names for a given\n * package. For `import { IconButton as Btn } from \"@trackunit/react-components\"`\n * this returns `{ Btn: \"IconButton\" }`.\n *\n * Returns `null` when the file imports nothing from the package, which lets\n * callers short-circuit before parsing JSX.\n */\nexport const getImportedAliases = (sourceFile: ts.SourceFile, packageName: string): Record<string, string> | null => {\n const result: Record<string, string> = {};\n let found = false;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier)) continue;\n if (moduleSpecifier.text !== packageName) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n for (const element of namedBindings.elements) {\n const localName = element.name.text;\n const importedName = element.propertyName?.text ?? localName;\n result[localName] = importedName;\n found = true;\n }\n }\n\n return found ? result : null;\n};\n\n/**\n * Returns the local alias used in this file for `originalName` when imported\n * from `packageName`, or `null` if the component is not imported.\n */\nexport const getLocalAliasFor = (\n sourceFile: ts.SourceFile,\n packageName: string,\n originalName: string\n): string | null => {\n const aliases = getImportedAliases(sourceFile, packageName);\n if (aliases === null) return null;\n for (const [local, original] of Object.entries(aliases)) {\n if (original === originalName) return local;\n }\n return null;\n};\n\nexport type JsxElementMatch = {\n /** The opening JSX element (the one carrying the attributes). */\n openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement;\n /** The full element including children, or the self-closing element. */\n element: ts.JsxElement | ts.JsxSelfClosingElement;\n};\n\n/**\n * Finds every JSX element whose tag name resolves to one of `tagNames`\n * (typically the local aliases returned by {@link getImportedAliases}).\n *\n * The result intentionally includes both opening and full elements so callers\n * can manipulate attributes (via `openingElement`) or wrap/replace the whole\n * element (via `element`).\n */\nexport const findJsxElements = (\n sourceFile: ts.SourceFile,\n tagNames: ReadonlyArray<string>\n): ReadonlyArray<JsxElementMatch> => {\n const matches: Array<JsxElementMatch> = [];\n const tagSet = new Set(tagNames);\n\n const visit = (node: ts.Node): void => {\n if (ts.isJsxSelfClosingElement(node)) {\n if (ts.isIdentifier(node.tagName) && tagSet.has(node.tagName.text)) {\n matches.push({ openingElement: node, element: node });\n }\n } else if (ts.isJsxElement(node)) {\n const opening = node.openingElement;\n if (ts.isIdentifier(opening.tagName) && tagSet.has(opening.tagName.text)) {\n matches.push({ openingElement: opening, element: node });\n }\n }\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n return matches;\n};\n\n/**\n * Looks up a named JSX attribute on the opening element. Returns `null` when\n * the attribute is missing or part of a spread attribute (which we cannot\n * statically inspect).\n */\nexport const findJsxAttribute = (\n openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement,\n attributeName: string\n): ts.JsxAttribute | null => {\n for (const attr of openingElement.attributes.properties) {\n if (!ts.isJsxAttribute(attr)) continue;\n if (!ts.isIdentifier(attr.name)) continue;\n if (attr.name.text === attributeName) return attr;\n }\n return null;\n};\n\n/**\n * `true` when the element forwards a spread expression such as `{...rest}`,\n * which means we can't be sure which attributes are actually set.\n */\nexport const hasSpreadAttribute = (openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement): boolean => {\n return openingElement.attributes.properties.some(prop => ts.isJsxSpreadAttribute(prop));\n};\n\n/**\n * Parses the file as TSX so JSX is recognised. We do not need a full program\n * here; tsquery's `ast` helper produces a script-kind source file which loses\n * JSX context, so we go through `createSourceFile` directly.\n */\nexport const parseTsx = (content: string, fileName = \"file.tsx\"): ts.SourceFile =>\n ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);\n\n/**\n * Helper for codemods to log a one-line summary at the end of a run. Migration\n * runners aggregate logs per migration, so this keeps output focused.\n */\nexport const logSummary = (migrationName: string, touched: number, manualReviewNeeded?: number): void => {\n if (touched === 0) {\n logger.info(` ${migrationName}: no files changed`);\n return;\n }\n const reviewSuffix =\n manualReviewNeeded !== undefined && manualReviewNeeded > 0\n ? ` (${manualReviewNeeded} location(s) need manual review)`\n : \"\";\n logger.info(` ${migrationName}: updated ${touched} file(s)${reviewSuffix}`);\n};\n\n/**\n * Inserts an attribute string immediately after the tag name (so the new\n * attribute appears first). Returns the resulting source content.\n *\n * The added attribute is rendered verbatim, so callers are responsible for\n * including the leading space (e.g. ` title=\"Close\"`).\n */\nexport const insertAttributeIntoOpeningTag = (\n content: string,\n openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement,\n attributeText: string\n): string => {\n const tagName = openingElement.tagName;\n const insertPos = tagName.getEnd();\n return `${content.slice(0, insertPos)} ${attributeText}${content.slice(insertPos)}`;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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,QAA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C,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAEzC,IAAI,OAAO,GAAG,OAAO,CAAC;IACtB,KAAK,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,MAAM,EAAE,CAAC;QACpC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardheader-onclickclose-to-actions.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/cardheader-onclickclose-to-actions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,kDAO4B;AAE5B,MAAM,YA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,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAExC,IAAI,OAAO,GAAG,OAAO,CAAC;IACtB,KAAK,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,KAAK,EAAE,CAAC;QAChD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconbutton-add-required-name.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/iconbutton-add-required-name.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAQ4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,MAAM,iBAAiB,GAAG,0CAA0C,CAAC;AAErE,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAiB,EAAE;IACpF,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,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ACtB,KAAK,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;;;;;;;GAOG;AACI,MAAM,yBAAyB,GAAG,CAAC,IAAU,EAAQ,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kpi-tooltiplabel-to-wrapper.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/kpi-tooltiplabel-to-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE;IACtD,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM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F,CAAC;IAED,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAEvC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;GAIG;AACI,MAAM,wBAAwB,GAAG,CAAC,IAAU,EAAQ,EAAE;IAC3D,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAC;IACvE,IAAA,sBAAU,EAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC,CAAC;AAHW,QAAA,wBAAwB,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notice-tooltiplabel-to-wrapper.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/notice-tooltiplabel-to-wrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAiC;AACjC,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEhC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE;IACtD,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,OAAO,CAAC;IAEnF,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QACzC,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAAE,SAAS;QAC5C,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC7C,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,eAAe,CAAC,IAAI,KAAK,YAAY;YAAE,SAAS;QAE5F,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC;QACvD,IAAI,aAAa,KAAK,SAAS,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC;YAAE,SAAS;QAE/E,MAAM,Y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AAkB,GAAG,IAAI,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,uEAAuE;YACvE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,mBAAmB,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACvG,CAAC;IACH,CAAC;IAED,IAAI,kBAAkB,EAAE,CAAC;QACvB,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,CAAC,IAAU,EAAQ,EAAE;IAC9D,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACpE,IAAA,sBAAU,EAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC,CAAC;AAHW,QAAA,2BAA2B,+BAGtC;AAEF,kBAAe,mCAA2B,CAAC","sourcesContent":["import { type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"Notice\";\n\nconst ensureTooltipImport = (content: string): string => {\n const sourceFile = parseTsx(content, \"source.tsx\");\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases !== null && Object.values(aliases).includes(\"Tooltip\")) return content;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== PACKAGE_NAME) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n const elementsText = namedBindings.elements.map(el => el.getText()).join(\", \");\n const merged = `${elementsText}, Tooltip`;\n const before = content.slice(0, namedBindings.getStart());\n const after = content.slice(namedBindings.getEnd());\n return `${before}{ ${merged} }${after}`;\n }\n\n return `import { Tooltip } from \"${PACKAGE_NAME}\";\\n${content}`;\n};\n\nconst transformNoticeUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = {\n elementStart: number;\n elementEnd: number;\n elementText: string;\n label: string | null;\n attrEdits: Array<{ start: number; end: number }>;\n };\n const edits: Array<Edit> = [];\n\n for (const { openingElement, element } of matches) {\n const tooltipLabelAttr = findJsxAttribute(openingElement, \"tooltipLabel\");\n const withTooltipAttr = findJsxAttribute(openingElement, \"withTooltip\");\n if (tooltipLabelAttr === null && withTooltipAttr === null) continue;\n\n let label: string | null = null;\n if (tooltipLabelAttr !== null) {\n const initializer = tooltipLabelAttr.initializer;\n if (initializer !== undefined) {\n if (ts.isStringLiteral(initializer)) {\n label = `\"${initializer.text}\"`;\n } else if (ts.isJsxExpression(initializer) && initializer.expression !== undefined) {\n label = `{${initializer.expression.getText()}}`;\n }\n }\n }\n\n const attrEdits: Array<{ start: number; end: number }> = [];\n for (const attr of [tooltipLabelAttr, withTooltipAttr]) {\n if (attr === null) continue;\n attrEdits.push({ start: attr.getFullStart(), end: attr.getEnd() });\n }\n\n edits.push({\n elementStart: element.getStart(),\n elementEnd: element.getEnd(),\n elementText: content.slice(element.getStart(), element.getEnd()),\n label,\n attrEdits,\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => b.elementStart - a.elementStart);\n\n let updated = content;\n let needsTooltipImport = false;\n\n for (const edit of edits) {\n // Remove the tooltipLabel/withTooltip attributes from the element first.\n let elementWithoutAttrs = edit.elementText;\n const sortedAttrEdits = [...edit.attrEdits].sort((a, b) => b.start - a.start);\n for (const { start, end } of sortedAttrEdits) {\n elementWithoutAttrs =\n elementWithoutAttrs.slice(0, start - edit.elementStart) + elementWithoutAttrs.slice(end - edit.elementStart);\n }\n\n if (edit.label !== null) {\n const wrapped = `<Tooltip label=${edit.label} placement=\"bottom\">${elementWithoutAttrs}</Tooltip>`;\n updated = updated.slice(0, edit.elementStart) + wrapped + updated.slice(edit.elementEnd);\n needsTooltipImport = true;\n } else {\n // No label to forward (e.g. only `withTooltip`); just strip the props.\n updated = updated.slice(0, edit.elementStart) + elementWithoutAttrs + updated.slice(edit.elementEnd);\n }\n }\n\n if (needsTooltipImport) {\n updated = ensureTooltipImport(updated);\n }\n\n return updated;\n};\n\n/**\n * Removes the deprecated `withTooltip`/`tooltipLabel` props from `<Notice>`\n * usages. When a label is present the element is wrapped in `<Tooltip>` to\n * preserve hover behaviour; when only `withTooltip` was set the props are\n * dropped because they had no remaining effect.\n */\nexport const noticeTooltipLabelToWrapper = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"Notice\", transformNoticeUsage);\n logSummary(\"notice-tooltiplabel-to-wrapper\", touched);\n};\n\nexport default noticeTooltipLabelToWrapper;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination-add-required-titles.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/pagination-add-required-titles.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAQ4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,MAAM,YAAY,GAA2B;IAC3C,iBAAiB,EAAE,eAAe;IAClC,aAAa,EAAE,WAAW;CAC3B,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAi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AAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAExE,IAAI,OAAO,GAAG,OAAO,CAAC;IACtB,KAAK,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;;;;;;;;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"]}
|