@astryxdesign/cli 0.7.0-canary.e3c1cfd → 0.7.0-canary.e48e2ef

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.
Files changed (70) hide show
  1. package/README.md +61 -61
  2. package/api/integration/pack-check.test.mjs +8 -0
  3. package/api/template/template.doc.mjs +1 -1
  4. package/api/template/template.type.mjs +1 -1
  5. package/api/theme/build/build.d.mts +0 -1
  6. package/api/theme/build/build.mjs +4 -29
  7. package/api/theme/build/family.mjs +1 -1
  8. package/assets/codemods/transforms/next/__tests__/migrate-field-input-styling.test.mjs +108 -0
  9. package/assets/codemods/transforms/next/__tests__/preserve-bottom-sheet-content-padding.test.mjs +178 -0
  10. package/assets/codemods/transforms/next/__tests__/validate-data-token-ownership.test.mjs +84 -0
  11. package/assets/codemods/transforms/next/index.mjs +24 -0
  12. package/assets/codemods/transforms/next/migrate-field-input-styling.mjs +198 -0
  13. package/assets/codemods/transforms/next/preserve-bottom-sheet-content-padding.mjs +242 -0
  14. package/assets/codemods/transforms/next/validate-data-token-ownership.mjs +102 -0
  15. package/assets/docs/author-a-theme.doc.mjs +1 -1
  16. package/assets/docs/spacing.doc.mjs +2 -2
  17. package/assets/docs/tree/tokens-data.doc.mjs +2 -2
  18. package/assets/docs/tree/tokens-spacing.doc.mjs +15 -15
  19. package/assets/docs/tree/tokens-usage.doc.mjs +1 -1
  20. package/assets/templates/blocks/components/BottomSheet/BottomSheetHeights.tsx +1 -1
  21. package/assets/templates/blocks/components/BottomSheet/BottomSheetMobileKeyboard.tsx +1 -1
  22. package/assets/templates/blocks/components/BottomSheet/BottomSheetNoScrim.tsx +1 -1
  23. package/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.tsx +1 -1
  24. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorDeadlinePicker.tsx +1 -1
  25. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorShowcase.tsx +1 -1
  26. package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorTreeSearch.tsx +1 -1
  27. package/assets/templates/blocks/components/Dialog/DialogAdaptivePresentation.tsx +1 -1
  28. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
  29. package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +1 -1
  30. package/assets/templates/blocks/components/Selector/SelectorClearable.tsx +1 -1
  31. package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +2 -2
  32. package/assets/templates/blocks/components/Selector/SelectorShowcase.tsx +1 -1
  33. package/assets/templates/blocks/components/Selector/SelectorWithSections.tsx +1 -1
  34. package/assets/templates/blocks/components/SelectorOption/SelectorOptionBasic.tsx +1 -1
  35. package/assets/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx +1 -1
  36. package/assets/templates/blocks/components/Slider/SliderFormattedValue.tsx +1 -1
  37. package/assets/templates/blocks/components/Slider/SliderRangeSlider.tsx +1 -1
  38. package/assets/templates/blocks/components/Slider/SliderShowcase.tsx +1 -1
  39. package/assets/templates/blocks/components/Slider/SliderWithMarks.tsx +1 -1
  40. package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +1 -1
  41. package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +2 -2
  42. package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +1 -1
  43. package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +1 -1
  44. package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +1 -1
  45. package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +2 -2
  46. package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +1 -1
  47. package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +4 -4
  48. package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +1 -1
  49. package/assets/templates/pages/canvas-editor/page.tsx +2 -2
  50. package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
  51. package/assets/templates/pages/payment-form/page.tsx +1 -1
  52. package/assets/templates/pages/table-filter/page.tsx +11 -6
  53. package/assets/templates/pages/table-inbox/page.tsx +3 -1
  54. package/assets/templates/pages/theme-showcase/page.tsx +2 -2
  55. package/assets/templates/themes/butter/butterTheme.ts +12 -0
  56. package/assets/templates/themes/chocolate/chocolateTheme.ts +12 -0
  57. package/assets/templates/themes/matcha/matchaTheme.ts +14 -14
  58. package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +10 -9
  59. package/assets/templates/themes/neutral/neutralTheme.ts +12 -0
  60. package/assets/templates/themes/stone/stoneTheme.ts +12 -0
  61. package/assets/templates/themes/y2k/y2kTheme.ts +10 -10
  62. package/assets/theme.template.ts +1 -1
  63. package/clients/cli/commands/build-theme.color-scheme.test.mjs +10 -6
  64. package/clients/cli/commands/build-theme.data-tokens.test.mjs +23 -75
  65. package/foundation/discovery/template-needs.mjs +93 -11
  66. package/foundation/discovery/template-needs.test.mjs +106 -3
  67. package/foundation/env/package-manager.d.mts +13 -0
  68. package/foundation/env/package-manager.mjs +106 -63
  69. package/foundation/response/response-types.doc.mjs +1 -2
  70. package/package.json +9 -9
@@ -0,0 +1,178 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {describe, expect, it} from 'vitest';
4
+ import transform from '../preserve-bottom-sheet-content-padding.mjs';
5
+
6
+ async function applyTransform(source) {
7
+ const jscodeshift = (await import('jscodeshift')).default;
8
+ const j = jscodeshift.withParser('tsx');
9
+ const api = {jscodeshift: j, stats: () => {}, report: () => {}};
10
+ return transform({source, path: 'test.tsx'}, api) ?? source;
11
+ }
12
+
13
+ describe('preserve-bottom-sheet-content-padding', () => {
14
+ it('adds padding={0} to a sheet with self-padded content', async () => {
15
+ const output =
16
+ await applyTransform(`import {BottomSheet, VStack} from '@astryxdesign/core';
17
+ const a = (
18
+ <BottomSheet isOpen={isOpen} onOpenChange={setIsOpen} label="Filters">
19
+ <VStack gap={4} padding={4}>x</VStack>
20
+ </BottomSheet>
21
+ );`);
22
+
23
+ expect(output).toContain(
24
+ '<BottomSheet isOpen={isOpen} onOpenChange={setIsOpen} label="Filters" padding={0}>',
25
+ );
26
+ });
27
+
28
+ it('leaves a sheet whose only child is a core Section unchanged', async () => {
29
+ const source = `import {BottomSheet, Section, VStack} from '@astryxdesign/core';
30
+ const a = (
31
+ <BottomSheet isOpen onOpenChange={() => {}} label="Filters">
32
+ {/* filters */}
33
+ <Section padding={4}>
34
+ <VStack gap={4}>x</VStack>
35
+ </Section>
36
+ </BottomSheet>
37
+ );`;
38
+ expect(await applyTransform(source)).toBe(source);
39
+ });
40
+
41
+ it('leaves a sheet whose only child is a core Layout unchanged', async () => {
42
+ const source = `import {BottomSheet, Layout, LayoutContent} from '@astryxdesign/core';
43
+ const a = (
44
+ <BottomSheet isOpen onOpenChange={() => {}} label="Message">
45
+ <Layout content={<LayoutContent>x</LayoutContent>} />
46
+ </BottomSheet>
47
+ );`;
48
+ expect(await applyTransform(source)).toBe(source);
49
+ });
50
+
51
+ it('flags every nested Layout with a TODO, with or without its own padding', async () => {
52
+ const output =
53
+ await applyTransform(`import {BottomSheet, Layout, VStack} from '@astryxdesign/core';
54
+ function A() {
55
+ return (
56
+ <BottomSheet sheetId="a" label="A">
57
+ <VStack>
58
+ <Layout content={x} />
59
+ </VStack>
60
+ </BottomSheet>
61
+ );
62
+ }
63
+ function B() {
64
+ return (
65
+ <BottomSheet sheetId="b" label="B">
66
+ <VStack>
67
+ <Layout padding={4} content={x} />
68
+ </VStack>
69
+ </BottomSheet>
70
+ );
71
+ }`);
72
+
73
+ expect(output).toContain('<BottomSheet sheetId="a" label="A" padding={0}>');
74
+ expect(output).toContain('<BottomSheet sheetId="b" label="B" padding={0}>');
75
+ expect(output.match(/TODO\(astryx upgrade\)/g)).toHaveLength(2);
76
+ expect(output.indexOf('TODO(astryx upgrade)')).toBeLessThan(
77
+ output.indexOf('sheetId="a"'),
78
+ );
79
+ expect(output.indexOf('TODO(astryx upgrade)')).toBeGreaterThan(
80
+ output.indexOf('function A'),
81
+ );
82
+ expect(output.lastIndexOf('TODO(astryx upgrade)')).toBeGreaterThan(
83
+ output.indexOf('function B'),
84
+ );
85
+ });
86
+
87
+ it('does not flag a Layout from another package or a shadowed Layout binding', async () => {
88
+ const output =
89
+ await applyTransform(`import {BottomSheet} from '@astryxdesign/core';
90
+ import {Layout} from './my-layout';
91
+ export function A() {
92
+ return <BottomSheet isOpen><Layout content={<p>b</p>} /></BottomSheet>;
93
+ }
94
+ `);
95
+ expect(output).toContain('padding={0}');
96
+ expect(output).not.toContain('TODO');
97
+ });
98
+
99
+ it('leaves a BottomSheet that a parameter or local binding shadows alone', async () => {
100
+ const source = `import {BottomSheet} from '@astryxdesign/core';
101
+ export function Host({BottomSheet: Sheet}) {
102
+ return <Sheet isOpen><p>own inset</p></Sheet>;
103
+ }
104
+ export function Local() {
105
+ const BottomSheet = (props) => <div {...props} />;
106
+ return <BottomSheet isOpen><p>own inset</p></BottomSheet>;
107
+ }
108
+ `;
109
+ expect(await applyTransform(source)).toBe(source);
110
+ });
111
+
112
+ it('is idempotent: a second run changes nothing', async () => {
113
+ const once =
114
+ await applyTransform(`import {BottomSheet, Layout, VStack} from '@astryxdesign/core';
115
+ export function A() {
116
+ return <BottomSheet isOpen><VStack><p>a</p></VStack></BottomSheet>;
117
+ }
118
+ export function B() {
119
+ return <BottomSheet isOpen><VStack><Layout content={<p>b</p>} /></VStack></BottomSheet>;
120
+ }
121
+ `);
122
+ expect(await applyTransform(once)).toBe(once);
123
+ });
124
+
125
+ it('pads a sheet when the Section has a sibling or is not from core', async () => {
126
+ const output =
127
+ await applyTransform(`import {BottomSheet} from '@astryxdesign/core';
128
+ import {Section} from './local';
129
+ import {Section as CoreSection} from '@astryxdesign/core';
130
+ const a = <BottomSheet sheetId="a" label="A"><Section>x</Section></BottomSheet>;
131
+ const b = (
132
+ <BottomSheet sheetId="b" label="B">
133
+ <CoreSection>x</CoreSection>
134
+ <p>after</p>
135
+ </BottomSheet>
136
+ );`);
137
+
138
+ expect(output).toContain('<BottomSheet sheetId="a" label="A" padding={0}>');
139
+ expect(output).toContain('<BottomSheet sheetId="b" label="B" padding={0}>');
140
+ });
141
+
142
+ it('leaves a sheet that already sets padding unchanged', async () => {
143
+ const source = `import {BottomSheet} from '@astryxdesign/core';
144
+ const a = <BottomSheet sheetId="a" label="A" padding={2}>x</BottomSheet>;
145
+ const b = <BottomSheet sheetId="b" label="B" padding={value}>x</BottomSheet>;`;
146
+ expect(await applyTransform(source)).toBe(source);
147
+ });
148
+
149
+ it('follows aliases, subpath default imports, and namespace imports', async () => {
150
+ const output =
151
+ await applyTransform(`import {BottomSheet as Sheet} from '@astryxdesign/core';
152
+ import Panel from '@astryxdesign/core/BottomSheet';
153
+ import * as Core from '@astryxdesign/core';
154
+ const a = <Sheet sheetId="a" label="A">x</Sheet>;
155
+ const b = <Panel sheetId="b" label="B">x</Panel>;
156
+ const c = <Core.BottomSheet sheetId="c" label="C">x</Core.BottomSheet>;`);
157
+
158
+ expect(output).toContain('<Sheet sheetId="a" label="A" padding={0}>');
159
+ expect(output).toContain('<Panel sheetId="b" label="B" padding={0}>');
160
+ expect(output).toContain(
161
+ '<Core.BottomSheet sheetId="c" label="C" padding={0}>',
162
+ );
163
+ });
164
+
165
+ it('puts padding={0} before a spread so a spread padding still wins', async () => {
166
+ const output =
167
+ await applyTransform(`import {BottomSheet} from '@astryxdesign/core';
168
+ const a = <BottomSheet label="A" {...args} />;`);
169
+
170
+ expect(output).toContain('<BottomSheet label="A" padding={0} {...args} />');
171
+ });
172
+
173
+ it('ignores BottomSheet from other packages', async () => {
174
+ const source = `import {BottomSheet} from './prototype';
175
+ const a = <BottomSheet title="A">x</BottomSheet>;`;
176
+ expect(await applyTransform(source)).toBe(source);
177
+ });
178
+ });
@@ -0,0 +1,84 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {describe, expect, it} from 'vitest';
4
+ import transform from '../validate-data-token-ownership.mjs';
5
+
6
+ async function run(source, file = 'test.tsx') {
7
+ const jscodeshift = (await import('jscodeshift')).default;
8
+ const parser =
9
+ file.endsWith('.ts') || file.endsWith('.tsx') ? 'tsx' : 'babel';
10
+ const api = {
11
+ jscodeshift: jscodeshift.withParser(parser),
12
+ stats: () => {},
13
+ report: () => {},
14
+ };
15
+ return transform({source, path: file}, api);
16
+ }
17
+
18
+ describe('validate-data-token-ownership', () => {
19
+ it('reports direct string and static-template consumers with both migration paths', async () => {
20
+ for (const source of [
21
+ `const fill = 'var(--color-data-categorical-green)';`,
22
+ 'const fill = `var(--color-data-categorical-green)`;',
23
+ `const border = '1px solid var(--color-data-categorical-green)';`,
24
+ 'const border = `${width}px solid var(--color-data-categorical-green)`;',
25
+ ]) {
26
+ await expect(run(source)).rejects.toThrow(
27
+ /CSS-capable code imports dataVars.*Canvas.*resolveThemeToken/s,
28
+ );
29
+ }
30
+ });
31
+
32
+ it('leaves fallbacks, dataVars access, and comments unchanged', async () => {
33
+ const source = `
34
+ // var(--color-data-categorical-green)
35
+ const fallback = 'var(--color-data-categorical-green, #008000)';
36
+ const fill = dataVars['--color-data-categorical-green'];
37
+ `;
38
+ expect(await run(source)).toBeUndefined();
39
+ });
40
+
41
+ it('reports stale generated theme CSS with root data defaults', async () => {
42
+ const source = `/* @generated by \`astryx theme build\` */
43
+ @layer astryx-base {
44
+ :root { --color-data-categorical-green: #008000; }
45
+ }`;
46
+ await expect(run(source, 'theme.css')).rejects.toThrow(
47
+ /Rebuild it with `astryx theme build`/,
48
+ );
49
+ });
50
+
51
+ it('reports raw stylesheet uses without a fallback', async () => {
52
+ await expect(
53
+ run('.bar { fill: var(--color-data-categorical-green); }', 'chart.css'),
54
+ ).rejects.toThrow(/Raw var\(--color-data-categorical-green\).*line 1/s);
55
+ });
56
+
57
+ it('leaves stylesheet uses with a fallback, and comments, unchanged', async () => {
58
+ expect(
59
+ await run(
60
+ `/* var(--color-data-categorical-green) */
61
+ .bar { fill: var(--color-data-categorical-green, #008000); }`,
62
+ 'chart.css',
63
+ ),
64
+ ).toBeUndefined();
65
+ });
66
+
67
+ it('does not claim ownership of hand-authored CSS or sparse theme overrides', async () => {
68
+ expect(
69
+ await run(
70
+ ':root { --color-data-categorical-green: #008000; }',
71
+ 'app.css',
72
+ ),
73
+ ).toBeUndefined();
74
+ expect(
75
+ await run(
76
+ `/* @generated by \`astryx theme build\` */
77
+ @scope ([data-astryx-theme="ocean"]) {
78
+ :scope { --color-data-categorical-green: #008000; }
79
+ }`,
80
+ 'theme.css',
81
+ ),
82
+ ).toBeUndefined();
83
+ });
84
+ });
@@ -10,6 +10,15 @@
10
10
  import migrateDeprecatedThemeSurface, {
11
11
  meta as migrateDeprecatedThemeSurfaceMeta,
12
12
  } from './migrate-deprecated-theme-surface.mjs';
13
+ import migrateFieldInputStyling, {
14
+ meta as migrateFieldInputStylingMeta,
15
+ } from './migrate-field-input-styling.mjs';
16
+ import preserveBottomSheetContentPadding, {
17
+ meta as preserveBottomSheetContentPaddingMeta,
18
+ } from './preserve-bottom-sheet-content-padding.mjs';
19
+ import validateDataTokenOwnership, {
20
+ meta as validateDataTokenOwnershipMeta,
21
+ } from './validate-data-token-ownership.mjs';
13
22
 
14
23
  export default [
15
24
  {
@@ -17,4 +26,19 @@ export default [
17
26
  transform: migrateDeprecatedThemeSurface,
18
27
  meta: migrateDeprecatedThemeSurfaceMeta,
19
28
  },
29
+ {
30
+ name: 'validate-data-token-ownership',
31
+ transform: validateDataTokenOwnership,
32
+ meta: validateDataTokenOwnershipMeta,
33
+ },
34
+ {
35
+ name: 'migrate-field-input-styling',
36
+ transform: migrateFieldInputStyling,
37
+ meta: migrateFieldInputStylingMeta,
38
+ },
39
+ {
40
+ name: 'preserve-bottom-sheet-content-padding',
41
+ transform: preserveBottomSheetContentPadding,
42
+ meta: preserveBottomSheetContentPaddingMeta,
43
+ },
20
44
  ];
@@ -0,0 +1,198 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Migrate root styling on Field-composed inputs to their named parts.
5
+ *
6
+ * Field-composed inputs no longer accept root `xstyle`, `className`, or
7
+ * `style` (family:input-fields FR10). Each rename keeps the element the
8
+ * styling reached before: components whose root styling painted the visual
9
+ * control box move to `controlXstyle`/`controlClassName`/`controlStyle`;
10
+ * components whose root styling reached the Field box move to
11
+ * `containerXstyle`/`containerClassName`/`containerStyle`.
12
+ *
13
+ * Only JSX attributes written directly on an element bound to an Astryx import
14
+ * are renamed (named, aliased, or namespace imports). Spread attributes,
15
+ * wrappers that forward their own props, and unrelated components of the same
16
+ * name are left alone; those callsites fail type-checking and are migrated by
17
+ * hand. When the target attribute is already present, the root attribute gets a
18
+ * TODO instead of a rename so no value is silently dropped.
19
+ */
20
+
21
+ import {transformProp} from '../../transform-prop.mjs';
22
+
23
+ export const meta = {
24
+ title: 'Migrate input root styling to container/control parts',
25
+ description:
26
+ 'Renames root `xstyle`/`className`/`style` on Field-composed inputs to the `control*` or `container*` part they styled before.',
27
+ fileExtensions: ['.tsx', '.jsx', '.ts', '.js', '.mjs', '.cjs'],
28
+ };
29
+
30
+ /** Components whose root styling painted the visual control box. */
31
+ const CONTROL_COMPONENTS = [
32
+ 'TextInput',
33
+ 'TextArea',
34
+ 'NumberInput',
35
+ 'FileInput',
36
+ 'DateInput',
37
+ 'DateRangeInput',
38
+ 'DateTimeInput',
39
+ 'TimeInput',
40
+ 'Selector',
41
+ 'MultiSelector',
42
+ 'ComplexSelector',
43
+ ];
44
+
45
+ /** Components whose root styling reached the Field box. */
46
+ const CONTAINER_COMPONENTS = [
47
+ 'Typeahead',
48
+ 'Tokenizer',
49
+ 'CheckboxList',
50
+ 'RadioList',
51
+ 'Slider',
52
+ ];
53
+
54
+ /**
55
+ * Field-root members that also render inside InputGroup. There Field is absent
56
+ * and root styling painted the control surface, so it moves to `control*`.
57
+ */
58
+ const GROUPED_CONTROL_COMPONENTS = new Set(['Typeahead']);
59
+
60
+ /** @type {ReadonlyMap<string, 'control' | 'container'>} */
61
+ const PART_BY_COMPONENT = new Map([
62
+ ...CONTROL_COMPONENTS.map(name => /** @type {const} */ ([name, 'control'])),
63
+ ...CONTAINER_COMPONENTS.map(
64
+ name => /** @type {const} */ ([name, 'container']),
65
+ ),
66
+ ]);
67
+
68
+ const ROOT_STYLE_PROPS = /** @type {const} */ ({
69
+ xstyle: 'Xstyle',
70
+ className: 'ClassName',
71
+ style: 'Style',
72
+ });
73
+
74
+ const PACKAGE_PATTERN = /^@(astryxdesign|xds)\/core(\/[A-Za-z]+)?$/u;
75
+
76
+ const TODO =
77
+ ' TODO(astryx upgrade): root styling is no longer accepted here; merge it into ';
78
+
79
+ /** @type {ReadonlyMap<string, ReadonlySet<string>>} */
80
+ const COMPONENT_PROPS = new Map(
81
+ [...PART_BY_COMPONENT.keys()].map(name => [
82
+ name,
83
+ new Set(Object.keys(ROOT_STYLE_PROPS)),
84
+ ]),
85
+ );
86
+
87
+ /**
88
+ * @param {import('../../../../authoring/codemod/type').AstryxCodemodFile} file
89
+ * @param {import('../../../../authoring/codemod/type').CodemodTransformApi} api
90
+ * @returns {string | undefined}
91
+ */
92
+ export default function migrateFieldInputStyling(file, api) {
93
+ if (!/xstyle|className|style/u.test(file.source)) return undefined;
94
+ if (![...PART_BY_COMPONENT.keys()].some(name => file.source.includes(name))) {
95
+ return undefined;
96
+ }
97
+
98
+ const j = api.jscodeshift;
99
+ const root = j(file.source);
100
+ const matchesImport = (/** @type {string} */ source) =>
101
+ PACKAGE_PATTERN.test(source);
102
+
103
+ // Local names that resolve to an Astryx InputGroup (named or namespace).
104
+ /** @type {Set<string>} */
105
+ const inputGroupNames = new Set();
106
+ /** @type {Set<string>} */
107
+ const namespaceNames = new Set();
108
+ root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
109
+ const source = path.node.source.value;
110
+ if (path.node.importKind === 'type') return;
111
+ if (typeof source !== 'string' || !matchesImport(source)) return;
112
+ for (const specifier of path.node.specifiers ?? []) {
113
+ if (specifier.importKind === 'type') continue;
114
+ if (
115
+ specifier.type === 'ImportSpecifier' &&
116
+ specifier.imported?.name === 'InputGroup'
117
+ ) {
118
+ inputGroupNames.add(specifier.local?.name ?? 'InputGroup');
119
+ } else if (specifier.type === 'ImportNamespaceSpecifier') {
120
+ namespaceNames.add(specifier.local.name);
121
+ }
122
+ }
123
+ });
124
+
125
+ /** @param {any} elementPath a JSXElement path */
126
+ const isInputGroup = elementPath => {
127
+ const name = elementPath.node.openingElement.name;
128
+ let localName;
129
+ if (name.type === 'JSXIdentifier' && inputGroupNames.has(name.name)) {
130
+ localName = name.name;
131
+ } else if (
132
+ name.type === 'JSXMemberExpression' &&
133
+ name.object?.type === 'JSXIdentifier' &&
134
+ name.property?.type === 'JSXIdentifier' &&
135
+ name.property.name === 'InputGroup' &&
136
+ namespaceNames.has(name.object.name)
137
+ ) {
138
+ localName = name.object.name;
139
+ } else {
140
+ return false;
141
+ }
142
+ const scope = elementPath.scope?.lookup(localName);
143
+ return scope?.path.node.type === 'Program';
144
+ };
145
+
146
+ /** @param {any} openingPath a JSXOpeningElement path */
147
+ const isInsideInputGroup = openingPath => {
148
+ for (let p = openingPath.parent?.parent; p; p = p.parent) {
149
+ if (p.node.type === 'JSXElement' && isInputGroup(p)) return true;
150
+ }
151
+ return false;
152
+ };
153
+
154
+ let changed = false;
155
+ transformProp(
156
+ root,
157
+ j,
158
+ {matchesImport, components: COMPONENT_PROPS},
159
+ (propPath, {component}) => {
160
+ const attribute = propPath.node;
161
+ const openingPath = propPath.parent;
162
+ let part = PART_BY_COMPONENT.get(component);
163
+ if (!part) return;
164
+ if (
165
+ part === 'container' &&
166
+ GROUPED_CONTROL_COMPONENTS.has(component) &&
167
+ isInsideInputGroup(openingPath)
168
+ ) {
169
+ part = 'control';
170
+ }
171
+ const name = /** @type {keyof typeof ROOT_STYLE_PROPS} */ (
172
+ attribute.name.name
173
+ );
174
+ const next = part + ROOT_STYLE_PROPS[name];
175
+ const present = (openingPath.node.attributes ?? []).some(
176
+ (/** @type {any} */ a) =>
177
+ a.type === 'JSXAttribute' && a.name?.name === next,
178
+ );
179
+ if (present) {
180
+ const comment = `${TODO}\`${next}\`. `;
181
+ attribute.comments ??= [];
182
+ if (
183
+ !attribute.comments.some(
184
+ (/** @type {any} */ c) => c.value === comment,
185
+ )
186
+ ) {
187
+ attribute.comments.push(j.commentBlock(comment, true, false));
188
+ changed = true;
189
+ }
190
+ return;
191
+ }
192
+ attribute.name = j.jsxIdentifier(next);
193
+ changed = true;
194
+ },
195
+ );
196
+
197
+ return changed ? root.toSource({quote: 'single'}) : undefined;
198
+ }