@trackunit/react-form-components 1.27.5 → 1.27.7
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
CHANGED
|
@@ -2407,6 +2407,14 @@ formatOptionLabel, }) => {
|
|
|
2407
2407
|
// from this ref, so the latest function is always used.
|
|
2408
2408
|
const formatOptionLabelRef = react.useRef(formatOptionLabel);
|
|
2409
2409
|
formatOptionLabelRef.current = formatOptionLabel;
|
|
2410
|
+
const getOptionLabelDescriptionRef = react.useRef(getOptionLabelDescription);
|
|
2411
|
+
getOptionLabelDescriptionRef.current = getOptionLabelDescription;
|
|
2412
|
+
const getOptionPrefixRef = react.useRef(getOptionPrefix);
|
|
2413
|
+
getOptionPrefixRef.current = getOptionPrefix;
|
|
2414
|
+
const resolveOptionPrefixRef = react.useRef(undefined);
|
|
2415
|
+
if (resolveOptionPrefixRef.current === undefined) {
|
|
2416
|
+
resolveOptionPrefixRef.current = (data) => getOptionPrefixRef.current?.(data);
|
|
2417
|
+
}
|
|
2410
2418
|
// perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
|
|
2411
2419
|
// Component functions stay stable (reading from refs), so react-select won't lose focus
|
|
2412
2420
|
const customComponents = react.useMemo(() => {
|
|
@@ -2479,10 +2487,11 @@ formatOptionLabel, }) => {
|
|
|
2479
2487
|
return (jsxRuntime.jsx(ReactSelect.components.NoOptionsMessage, { ...selectNoOptionsMessage, className: cvaSelectNoOptionsMessage({ className: selectNoOptionsMessage.className }), getStyles: getNoStyles, children: selectNoOptionsMessage.children ?? t("select.noOptionsMessage") }));
|
|
2480
2488
|
},
|
|
2481
2489
|
SingleValue: selectSingleValue => {
|
|
2482
|
-
const optionPrefix =
|
|
2490
|
+
const optionPrefix = getOptionPrefixRef.current ? getOptionPrefixRef.current(selectSingleValue.data) : null;
|
|
2491
|
+
const optionLabelDescription = getOptionLabelDescriptionRef.current?.(selectSingleValue.data);
|
|
2483
2492
|
return (jsxRuntime.jsx(ReactSelect.components.SingleValue, { ...selectSingleValue, className: cvaSelectSingleValue({
|
|
2484
2493
|
className: selectSingleValue.className,
|
|
2485
|
-
}), getStyles: getNoStyles, children: jsxRuntime.jsxs("div", { className: "flex items-center gap-1", "data-testid": dataTestId + "-singleValue", children: [optionPrefix !== null ? optionPrefix : null, selectSingleValue.children,
|
|
2494
|
+
}), getStyles: getNoStyles, children: jsxRuntime.jsxs("div", { className: "flex items-center gap-1", "data-testid": dataTestId + "-singleValue", children: [optionPrefix !== null ? optionPrefix : null, selectSingleValue.children, optionLabelDescription !== undefined && optionLabelDescription !== "" ? (jsxRuntime.jsxs("span", { className: "ml-1 text-neutral-400", children: ["(", optionLabelDescription, ")"] })) : null] }) }));
|
|
2486
2495
|
},
|
|
2487
2496
|
MultiValueContainer: ({ children }) => children, // Just pass on the children
|
|
2488
2497
|
MultiValueRemove: () => null, // is built-in to the MultiValue (tag) component
|
|
@@ -2496,7 +2505,7 @@ formatOptionLabel, }) => {
|
|
|
2496
2505
|
return (jsxRuntime.jsx(ReactSelect.components.MultiValue, { ...selectMultiValue, getStyles: getNoStyles, children: jsxRuntime.jsx(MultiValue, { className: cvaSelectMultiValue({
|
|
2497
2506
|
hidden: currentIsComplete && index + 1 > currentVisibleCount, // Hide if doesn't fit
|
|
2498
2507
|
invisible: currentWithCounter && !currentIsComplete, // Make invisible if measuring with counter. When there's a counter, it would otherwise briefly change layout to make room for the "fake" counter
|
|
2499
|
-
}), data: selectMultiValue.data, "data-testid": dataTestId ? `${dataTestId}-multiValue-${index}` : undefined, disabled: Boolean(disabled), fieldSize: fieldSize, getOptionPrefix:
|
|
2508
|
+
}), data: selectMultiValue.data, "data-testid": dataTestId ? `${dataTestId}-multiValue-${index}` : undefined, disabled: Boolean(disabled), fieldSize: fieldSize, getOptionPrefix: getOptionPrefixRef.current ? resolveOptionPrefixRef.current : undefined, onClose: selectMultiValue.removeProps.onClick, ref: setGeometryRef(index), removeTagLabel: t("select.multiValue.remove"), children: selectMultiValue.children }) }));
|
|
2500
2509
|
},
|
|
2501
2510
|
Menu: selectMenu => {
|
|
2502
2511
|
return (jsxRuntime.jsx(ReactSelect.components.Menu, { ...selectMenu, className: cvaSelectMenu({ className: selectMenu.className, placement: selectMenu.placement }), getStyles: getNoStyles, innerProps: {
|
|
@@ -2542,7 +2551,7 @@ formatOptionLabel, }) => {
|
|
|
2542
2551
|
return (jsxRuntime.jsx(ReactSelect.components.Option, { ...selectOption, innerProps: {
|
|
2543
2552
|
...selectOption.innerProps,
|
|
2544
2553
|
role: "option",
|
|
2545
|
-
}, children: selectOption.isMulti ? (jsxRuntime.jsx(MultiSelectMenuItem, { ...componentProps, "data-testid": typeof selectOption.label === "string" ? selectOption.label : undefined, disabled: Boolean(disabled), fieldSize: fieldSize, optionContent: optionContent, optionLabelDescription:
|
|
2554
|
+
}, children: selectOption.isMulti ? (jsxRuntime.jsx(MultiSelectMenuItem, { ...componentProps, "data-testid": typeof selectOption.label === "string" ? selectOption.label : undefined, disabled: Boolean(disabled), fieldSize: fieldSize, optionContent: optionContent, optionLabelDescription: getOptionLabelDescriptionRef.current?.(selectOption.data), optionPrefix: getOptionPrefixRef.current?.(selectOption.data) })) : (jsxRuntime.jsx(SingleSelectMenuItem, { ...componentProps, "data-testid": typeof selectOption.label === "string" ? selectOption.label : undefined, disabled: optionDisabled, fieldSize: fieldSize, optionContent: optionContent, optionLabelDescription: getOptionLabelDescriptionRef.current?.(selectOption.data), optionPrefix: getOptionPrefixRef.current?.(selectOption.data) })) }));
|
|
2546
2555
|
},
|
|
2547
2556
|
};
|
|
2548
2557
|
}, [
|
|
@@ -2563,8 +2572,6 @@ formatOptionLabel, }) => {
|
|
|
2563
2572
|
setCounterRef,
|
|
2564
2573
|
autoComplete,
|
|
2565
2574
|
t,
|
|
2566
|
-
getOptionPrefix,
|
|
2567
|
-
getOptionLabelDescription,
|
|
2568
2575
|
setGeometryRef,
|
|
2569
2576
|
setMenuRef,
|
|
2570
2577
|
]);
|
|
@@ -2605,7 +2612,7 @@ const useSelect = (props) => {
|
|
|
2605
2612
|
options, value, defaultValue,
|
|
2606
2613
|
// Extract callbacks - most are passed through directly to allow recalculation when changed
|
|
2607
2614
|
// Only onMenuOpen and onMenuClose get wrapped with ref pattern (see below)
|
|
2608
|
-
onMenuOpen, onMenuClose, onChange, onInputChange, onFocus, onBlur, getOptionLabel, getOptionValue, filterOption, formatOptionLabel, formatGroupLabel, isOptionDisabled, isOptionSelected, onKeyDown, onMenuScrollToTop, onMenuScrollToBottom,
|
|
2615
|
+
onMenuOpen, onMenuClose, onChange, onInputChange, onFocus, onBlur, getOptionLabel, getOptionValue, filterOption, formatOptionLabel, getOptionLabelDescription, getOptionPrefix, formatGroupLabel, isOptionDisabled, isOptionSelected, onKeyDown, onMenuScrollToTop, onMenuScrollToBottom,
|
|
2609
2616
|
// Extract other props used in final useMemo
|
|
2610
2617
|
label, isSearchable, openMenuOnClick, openMenuOnFocus, isMulti, isClearable, menuPlacement, placeholder, hideSelectedOptions, readOnly,
|
|
2611
2618
|
// Extract commonly-used props to prevent them from ending up in restProps
|
|
@@ -2632,8 +2639,8 @@ const useSelect = (props) => {
|
|
|
2632
2639
|
prefix: stableRestProps.prefix,
|
|
2633
2640
|
hasError: stableRestProps.hasError,
|
|
2634
2641
|
fieldSize: stableRestProps.fieldSize,
|
|
2635
|
-
getOptionLabelDescription
|
|
2636
|
-
getOptionPrefix
|
|
2642
|
+
getOptionLabelDescription,
|
|
2643
|
+
getOptionPrefix,
|
|
2637
2644
|
isMulti: isMulti ?? false,
|
|
2638
2645
|
className: stableRestProps.className,
|
|
2639
2646
|
autoComplete: stableRestProps.autoComplete,
|
package/index.esm.js
CHANGED
|
@@ -2406,6 +2406,14 @@ formatOptionLabel, }) => {
|
|
|
2406
2406
|
// from this ref, so the latest function is always used.
|
|
2407
2407
|
const formatOptionLabelRef = useRef(formatOptionLabel);
|
|
2408
2408
|
formatOptionLabelRef.current = formatOptionLabel;
|
|
2409
|
+
const getOptionLabelDescriptionRef = useRef(getOptionLabelDescription);
|
|
2410
|
+
getOptionLabelDescriptionRef.current = getOptionLabelDescription;
|
|
2411
|
+
const getOptionPrefixRef = useRef(getOptionPrefix);
|
|
2412
|
+
getOptionPrefixRef.current = getOptionPrefix;
|
|
2413
|
+
const resolveOptionPrefixRef = useRef(undefined);
|
|
2414
|
+
if (resolveOptionPrefixRef.current === undefined) {
|
|
2415
|
+
resolveOptionPrefixRef.current = (data) => getOptionPrefixRef.current?.(data);
|
|
2416
|
+
}
|
|
2409
2417
|
// perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
|
|
2410
2418
|
// Component functions stay stable (reading from refs), so react-select won't lose focus
|
|
2411
2419
|
const customComponents = useMemo(() => {
|
|
@@ -2478,10 +2486,11 @@ formatOptionLabel, }) => {
|
|
|
2478
2486
|
return (jsx(components.NoOptionsMessage, { ...selectNoOptionsMessage, className: cvaSelectNoOptionsMessage({ className: selectNoOptionsMessage.className }), getStyles: getNoStyles, children: selectNoOptionsMessage.children ?? t("select.noOptionsMessage") }));
|
|
2479
2487
|
},
|
|
2480
2488
|
SingleValue: selectSingleValue => {
|
|
2481
|
-
const optionPrefix =
|
|
2489
|
+
const optionPrefix = getOptionPrefixRef.current ? getOptionPrefixRef.current(selectSingleValue.data) : null;
|
|
2490
|
+
const optionLabelDescription = getOptionLabelDescriptionRef.current?.(selectSingleValue.data);
|
|
2482
2491
|
return (jsx(components.SingleValue, { ...selectSingleValue, className: cvaSelectSingleValue({
|
|
2483
2492
|
className: selectSingleValue.className,
|
|
2484
|
-
}), getStyles: getNoStyles, children: jsxs("div", { className: "flex items-center gap-1", "data-testid": dataTestId + "-singleValue", children: [optionPrefix !== null ? optionPrefix : null, selectSingleValue.children,
|
|
2493
|
+
}), getStyles: getNoStyles, children: jsxs("div", { className: "flex items-center gap-1", "data-testid": dataTestId + "-singleValue", children: [optionPrefix !== null ? optionPrefix : null, selectSingleValue.children, optionLabelDescription !== undefined && optionLabelDescription !== "" ? (jsxs("span", { className: "ml-1 text-neutral-400", children: ["(", optionLabelDescription, ")"] })) : null] }) }));
|
|
2485
2494
|
},
|
|
2486
2495
|
MultiValueContainer: ({ children }) => children, // Just pass on the children
|
|
2487
2496
|
MultiValueRemove: () => null, // is built-in to the MultiValue (tag) component
|
|
@@ -2495,7 +2504,7 @@ formatOptionLabel, }) => {
|
|
|
2495
2504
|
return (jsx(components.MultiValue, { ...selectMultiValue, getStyles: getNoStyles, children: jsx(MultiValue, { className: cvaSelectMultiValue({
|
|
2496
2505
|
hidden: currentIsComplete && index + 1 > currentVisibleCount, // Hide if doesn't fit
|
|
2497
2506
|
invisible: currentWithCounter && !currentIsComplete, // Make invisible if measuring with counter. When there's a counter, it would otherwise briefly change layout to make room for the "fake" counter
|
|
2498
|
-
}), data: selectMultiValue.data, "data-testid": dataTestId ? `${dataTestId}-multiValue-${index}` : undefined, disabled: Boolean(disabled), fieldSize: fieldSize, getOptionPrefix:
|
|
2507
|
+
}), data: selectMultiValue.data, "data-testid": dataTestId ? `${dataTestId}-multiValue-${index}` : undefined, disabled: Boolean(disabled), fieldSize: fieldSize, getOptionPrefix: getOptionPrefixRef.current ? resolveOptionPrefixRef.current : undefined, onClose: selectMultiValue.removeProps.onClick, ref: setGeometryRef(index), removeTagLabel: t("select.multiValue.remove"), children: selectMultiValue.children }) }));
|
|
2499
2508
|
},
|
|
2500
2509
|
Menu: selectMenu => {
|
|
2501
2510
|
return (jsx(components.Menu, { ...selectMenu, className: cvaSelectMenu({ className: selectMenu.className, placement: selectMenu.placement }), getStyles: getNoStyles, innerProps: {
|
|
@@ -2541,7 +2550,7 @@ formatOptionLabel, }) => {
|
|
|
2541
2550
|
return (jsx(components.Option, { ...selectOption, innerProps: {
|
|
2542
2551
|
...selectOption.innerProps,
|
|
2543
2552
|
role: "option",
|
|
2544
|
-
}, children: selectOption.isMulti ? (jsx(MultiSelectMenuItem, { ...componentProps, "data-testid": typeof selectOption.label === "string" ? selectOption.label : undefined, disabled: Boolean(disabled), fieldSize: fieldSize, optionContent: optionContent, optionLabelDescription:
|
|
2553
|
+
}, children: selectOption.isMulti ? (jsx(MultiSelectMenuItem, { ...componentProps, "data-testid": typeof selectOption.label === "string" ? selectOption.label : undefined, disabled: Boolean(disabled), fieldSize: fieldSize, optionContent: optionContent, optionLabelDescription: getOptionLabelDescriptionRef.current?.(selectOption.data), optionPrefix: getOptionPrefixRef.current?.(selectOption.data) })) : (jsx(SingleSelectMenuItem, { ...componentProps, "data-testid": typeof selectOption.label === "string" ? selectOption.label : undefined, disabled: optionDisabled, fieldSize: fieldSize, optionContent: optionContent, optionLabelDescription: getOptionLabelDescriptionRef.current?.(selectOption.data), optionPrefix: getOptionPrefixRef.current?.(selectOption.data) })) }));
|
|
2545
2554
|
},
|
|
2546
2555
|
};
|
|
2547
2556
|
}, [
|
|
@@ -2562,8 +2571,6 @@ formatOptionLabel, }) => {
|
|
|
2562
2571
|
setCounterRef,
|
|
2563
2572
|
autoComplete,
|
|
2564
2573
|
t,
|
|
2565
|
-
getOptionPrefix,
|
|
2566
|
-
getOptionLabelDescription,
|
|
2567
2574
|
setGeometryRef,
|
|
2568
2575
|
setMenuRef,
|
|
2569
2576
|
]);
|
|
@@ -2604,7 +2611,7 @@ const useSelect = (props) => {
|
|
|
2604
2611
|
options, value, defaultValue,
|
|
2605
2612
|
// Extract callbacks - most are passed through directly to allow recalculation when changed
|
|
2606
2613
|
// Only onMenuOpen and onMenuClose get wrapped with ref pattern (see below)
|
|
2607
|
-
onMenuOpen, onMenuClose, onChange, onInputChange, onFocus, onBlur, getOptionLabel, getOptionValue, filterOption, formatOptionLabel, formatGroupLabel, isOptionDisabled, isOptionSelected, onKeyDown, onMenuScrollToTop, onMenuScrollToBottom,
|
|
2614
|
+
onMenuOpen, onMenuClose, onChange, onInputChange, onFocus, onBlur, getOptionLabel, getOptionValue, filterOption, formatOptionLabel, getOptionLabelDescription, getOptionPrefix, formatGroupLabel, isOptionDisabled, isOptionSelected, onKeyDown, onMenuScrollToTop, onMenuScrollToBottom,
|
|
2608
2615
|
// Extract other props used in final useMemo
|
|
2609
2616
|
label, isSearchable, openMenuOnClick, openMenuOnFocus, isMulti, isClearable, menuPlacement, placeholder, hideSelectedOptions, readOnly,
|
|
2610
2617
|
// Extract commonly-used props to prevent them from ending up in restProps
|
|
@@ -2631,8 +2638,8 @@ const useSelect = (props) => {
|
|
|
2631
2638
|
prefix: stableRestProps.prefix,
|
|
2632
2639
|
hasError: stableRestProps.hasError,
|
|
2633
2640
|
fieldSize: stableRestProps.fieldSize,
|
|
2634
|
-
getOptionLabelDescription
|
|
2635
|
-
getOptionPrefix
|
|
2641
|
+
getOptionLabelDescription,
|
|
2642
|
+
getOptionPrefix,
|
|
2636
2643
|
isMulti: isMulti ?? false,
|
|
2637
2644
|
className: stableRestProps.className,
|
|
2638
2645
|
autoComplete: stableRestProps.autoComplete,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/form-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/form-components/migrations/utils/jsx-utils.ts"],"names":[],"mappings":";;;;AAAA,uCAAqE;AACrE,uDAAoD;AA8L3C,wFA9LA,iBAAO,OA8LA;AA7LhB,uDAAiC;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,CAA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D,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,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,IAAI,aAAa,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionbutton-add-title.js","sourceRoot":"","sources":["../../../../../../libs/react/form-components/migrations/v2-0-0/actionbutton-add-title.ts"],"names":[],"mappings":";;;;AAAA,uCA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AC;AAEF;;;;;GAKG;AACI,MAAM,oBAAoB,GAAG,CAAC,IAAU,EAAQ,EAAE;IACvD,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,cAAc,EAAE,0BAA0B,CAAC,CAAC;IAChF,IAAA,sBAAU,EAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;IAC9C,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,eAAM,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B;AAEF,kBAAe,4BAAoB,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n hasSpreadAttribute,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-form-components\";\nconst COMPONENT_NAME = \"ActionButton\";\n\nconst ACTION_TYPE_TO_TITLE: Record<string, string> = {\n COPY: \"Copy value\",\n EDIT: \"Edit value\",\n EMAIL: \"Send email\",\n PHONE_NUMBER: \"Call number\",\n WEB_ADDRESS: \"Open link\",\n};\n\nconst DEFAULT_TITLE = \"Action\";\n\nconst resolveTitleForType = (typeAttr: ts.JsxAttribute | null): string => {\n if (typeAttr === null) return DEFAULT_TITLE;\n const initializer = typeAttr.initializer;\n if (initializer === undefined) return DEFAULT_TITLE;\n if (ts.isStringLiteral(initializer)) {\n return ACTION_TYPE_TO_TITLE[initializer.text] ?? DEFAULT_TITLE;\n }\n return DEFAULT_TITLE;\n};\n\nconst transformActionButtonUsage = (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 if (findJsxAttribute(openingElement, \"title\") !== null) continue;\n\n const typeAttr = findJsxAttribute(openingElement, \"type\");\n const title = resolveTitleForType(typeAttr);\n edits.push({\n offset: openingElement.tagName.getEnd(),\n text: ` title=\"${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 the now-required `title` prop to `<ActionButton>` usages that don't\n * already provide one. The default value is derived from the `type` prop when\n * possible (e.g. `COPY` → \"Copy value\"); consumers should replace the\n * placeholders with their own localized strings.\n */\nexport const actionButtonAddTitle = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"ActionButton\", transformActionButtonUsage);\n logSummary(\"actionbutton-add-title\", touched);\n if (touched > 0) {\n logger.info(` Replace placeholder ActionButton titles with your own localized strings.`);\n }\n};\n\nexport default actionButtonAddTitle;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.7",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"zod": "^3.25.76",
|
|
17
17
|
"tailwind-merge": "^2.0.0",
|
|
18
18
|
"@trackunit/css-class-variance-utilities": "1.13.7",
|
|
19
|
-
"@trackunit/react-components": "1.26.
|
|
19
|
+
"@trackunit/react-components": "1.26.5",
|
|
20
20
|
"@trackunit/ui-icons": "1.13.7",
|
|
21
21
|
"@trackunit/shared-utils": "1.15.7",
|
|
22
22
|
"@trackunit/ui-design-tokens": "1.13.7",
|