@astryxdesign/cli 0.7.0-canary.1180dee → 0.7.0-canary.19b1c00
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/assets/codemods/transforms/next/__tests__/migrate-field-input-styling.test.mjs +108 -0
- package/assets/codemods/transforms/next/__tests__/preserve-bottom-sheet-content-padding.test.mjs +178 -0
- package/assets/codemods/transforms/next/index.mjs +16 -0
- package/assets/codemods/transforms/next/migrate-field-input-styling.mjs +198 -0
- package/assets/codemods/transforms/next/preserve-bottom-sheet-content-padding.mjs +242 -0
- package/assets/docs/spacing.doc.mjs +2 -2
- package/assets/docs/tree/tokens-spacing.doc.mjs +15 -15
- package/assets/templates/blocks/components/BottomSheet/BottomSheetHeights.tsx +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetMobileKeyboard.tsx +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetNoScrim.tsx +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.tsx +1 -1
- package/assets/templates/blocks/components/Dialog/DialogAdaptivePresentation.tsx +1 -1
- package/assets/templates/pages/table-filter/page.tsx +8 -3
- package/assets/templates/pages/table-inbox/page.tsx +3 -1
- package/assets/templates/themes/butter/butterTheme.ts +12 -0
- package/assets/templates/themes/chocolate/chocolateTheme.ts +12 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +14 -14
- package/assets/templates/themes/neutral/neutralTheme.ts +12 -0
- package/assets/templates/themes/stone/stoneTheme.ts +12 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +10 -10
- package/assets/theme.template.ts +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {describe, expect, it} from 'vitest';
|
|
4
|
+
import jscodeshift from 'jscodeshift';
|
|
5
|
+
import transform from '../migrate-field-input-styling.mjs';
|
|
6
|
+
|
|
7
|
+
const j = jscodeshift.withParser('tsx');
|
|
8
|
+
const api = {jscodeshift: j, stats: () => {}, report: () => {}};
|
|
9
|
+
|
|
10
|
+
/** @param {string} source */
|
|
11
|
+
function apply(source) {
|
|
12
|
+
return transform({source, path: 'test.tsx'}, api) ?? source;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe('migrate-field-input-styling', () => {
|
|
16
|
+
it('moves control-box members to control*', () => {
|
|
17
|
+
const input = `import {TextInput, Selector, DateInput} from '@astryxdesign/core';
|
|
18
|
+
const a = <TextInput label="Name" xstyle={styles.input} className="name" style={{width: 200}} />;
|
|
19
|
+
const b = <Selector label="Fruit" options={options} xstyle={styles.selector} />;
|
|
20
|
+
const c = <DateInput label="Due" className="due" />;`;
|
|
21
|
+
const output = apply(input);
|
|
22
|
+
expect(output).toContain(
|
|
23
|
+
'<TextInput label="Name" controlXstyle={styles.input} controlClassName="name" controlStyle={{width: 200}} />',
|
|
24
|
+
);
|
|
25
|
+
expect(output).toContain('controlXstyle={styles.selector}');
|
|
26
|
+
expect(output).toContain(
|
|
27
|
+
'<DateInput label="Due" controlClassName="due" />',
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('moves Field-root members to container*', () => {
|
|
32
|
+
const input = `import {Typeahead} from '@astryxdesign/core/Typeahead';
|
|
33
|
+
import {RadioList, Slider} from '@astryxdesign/core';
|
|
34
|
+
const a = <Typeahead label="Fruit" xstyle={styles.wide} />;
|
|
35
|
+
const b = <RadioList label="Plan" style={{marginTop: 8}}>{items}</RadioList>;
|
|
36
|
+
const c = <Slider label="Volume" className="volume" value={1} />;`;
|
|
37
|
+
const output = apply(input);
|
|
38
|
+
expect(output).toContain('containerXstyle={styles.wide}');
|
|
39
|
+
expect(output).toContain('containerStyle={{marginTop: 8}}');
|
|
40
|
+
expect(output).toContain('containerClassName="volume"');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('moves a Typeahead inside InputGroup to control*, where its root styling painted the surface', () => {
|
|
44
|
+
const input = `import {InputGroup, Typeahead} from '@astryxdesign/core';
|
|
45
|
+
const a = (
|
|
46
|
+
<InputGroup label="Produce">
|
|
47
|
+
<Typeahead label="Fruit" className="grouped" />
|
|
48
|
+
</InputGroup>
|
|
49
|
+
);
|
|
50
|
+
const b = <Typeahead label="Fruit" className="standalone" />;`;
|
|
51
|
+
const output = apply(input);
|
|
52
|
+
expect(output).toContain('controlClassName="grouped"');
|
|
53
|
+
expect(output).toContain('containerClassName="standalone"');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('follows aliased and namespace imports', () => {
|
|
57
|
+
const input = `import {TextArea as Notes} from '@astryxdesign/core';
|
|
58
|
+
import * as Astryx from '@astryxdesign/core';
|
|
59
|
+
const a = <Notes label="Notes" className="notes" />;
|
|
60
|
+
const b = <Astryx.Tokenizer label="Tags" xstyle={styles.tags} />;`;
|
|
61
|
+
const output = apply(input);
|
|
62
|
+
expect(output).toContain(
|
|
63
|
+
'<Notes label="Notes" controlClassName="notes" />',
|
|
64
|
+
);
|
|
65
|
+
expect(output).toContain(
|
|
66
|
+
'<Astryx.Tokenizer label="Tags" containerXstyle={styles.tags} />',
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('leaves unrelated components, other packages, nested JSX, and spreads alone', () => {
|
|
71
|
+
const input = `import {TextInput} from 'some-other-library';
|
|
72
|
+
import {Button, NumberInput} from '@astryxdesign/core';
|
|
73
|
+
const a = <TextInput className="kept" />;
|
|
74
|
+
const b = <Button xstyle={styles.button} />;
|
|
75
|
+
const c = <NumberInput label="Qty" {...rest} startIcon={<Icon className="icon" />} />;`;
|
|
76
|
+
expect(apply(input)).toBe(input);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('leaves tags whose name is shadowed by a local binding', () => {
|
|
80
|
+
const input = `import {TextInput} from '@astryxdesign/core';
|
|
81
|
+
import * as Astryx from '@astryxdesign/core';
|
|
82
|
+
function Row({TextInput}) {
|
|
83
|
+
return <TextInput className="kept" />;
|
|
84
|
+
}
|
|
85
|
+
function Other(Astryx) {
|
|
86
|
+
return <Astryx.Typeahead className="kept" />;
|
|
87
|
+
}`;
|
|
88
|
+
expect(apply(input)).toBe(input);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('marks a conflict with a TODO instead of dropping a value', () => {
|
|
92
|
+
const input = `import {TextInput} from '@astryxdesign/core';
|
|
93
|
+
const a = <TextInput label="Name" className="old" controlClassName="new" />;`;
|
|
94
|
+
const output = apply(input);
|
|
95
|
+
expect(output).toContain('controlClassName="new"');
|
|
96
|
+
expect(output).toContain('className="old"');
|
|
97
|
+
expect(output).toContain('TODO(astryx upgrade)');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('is idempotent', () => {
|
|
101
|
+
const input = `import {TextInput, CheckboxList} from '@astryxdesign/core';
|
|
102
|
+
const a = <TextInput label="Name" className="old" controlClassName="new" />;
|
|
103
|
+
const b = <TextInput label="Email" xstyle={styles.email} />;
|
|
104
|
+
const c = <CheckboxList label="Prefs" style={{margin: 4}}>{items}</CheckboxList>;`;
|
|
105
|
+
const once = apply(input);
|
|
106
|
+
expect(apply(once)).toBe(once);
|
|
107
|
+
});
|
|
108
|
+
});
|
package/assets/codemods/transforms/next/__tests__/preserve-bottom-sheet-content-padding.test.mjs
ADDED
|
@@ -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
|
+
});
|
|
@@ -10,6 +10,12 @@
|
|
|
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';
|
|
13
19
|
import validateDataTokenOwnership, {
|
|
14
20
|
meta as validateDataTokenOwnershipMeta,
|
|
15
21
|
} from './validate-data-token-ownership.mjs';
|
|
@@ -25,4 +31,14 @@ export default [
|
|
|
25
31
|
transform: validateDataTokenOwnership,
|
|
26
32
|
meta: validateDataTokenOwnershipMeta,
|
|
27
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
|
+
},
|
|
28
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
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Codemod: preserve BottomSheet content geometry after it became a container
|
|
5
|
+
*
|
|
6
|
+
* BottomSheet now pads its content box like Dialog (theme `bottom-sheet`
|
|
7
|
+
* padding, else `--spacing-4`). Before, the content box had no padding, so
|
|
8
|
+
* callers supplied their own inset. This codemod keeps every existing sheet's
|
|
9
|
+
* geometry by adding `padding={0}` to imported BottomSheet elements that do not
|
|
10
|
+
* set `padding`.
|
|
11
|
+
*
|
|
12
|
+
* Sheets whose only child is a core `Section` or `Layout` are left alone: both
|
|
13
|
+
* escape the inset their container publishes, so they already render exactly
|
|
14
|
+
* as they did in the unpadded box.
|
|
15
|
+
*
|
|
16
|
+
* `padding={0}` goes before the first spread attribute, so a spread that
|
|
17
|
+
* carries `padding` still wins.
|
|
18
|
+
*
|
|
19
|
+
* `padding={0}` also zeroes the inset a nested `Layout` puts between its
|
|
20
|
+
* regions: a Layout's own `padding` restores only its outer edges, and the
|
|
21
|
+
* inner inset comes from the sheet's container chain. Such a sheet still gets
|
|
22
|
+
* `padding={0}`, plus a TODO comment on its statement (api.report is a stub;
|
|
23
|
+
* comments are the only warning channel).
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export const meta = {
|
|
27
|
+
title: 'Preserve BottomSheet content padding',
|
|
28
|
+
description:
|
|
29
|
+
'BottomSheet now pads its content like Dialog. Adds `padding={0}` to ' +
|
|
30
|
+
'BottomSheet elements that do not set `padding`, keeping their previous ' +
|
|
31
|
+
'unpadded content box. Sheets whose only child is a Section ' +
|
|
32
|
+
'or Layout are left unchanged; they render identically. A sheet with a ' +
|
|
33
|
+
'nested Layout anywhere in its content also gets a TODO comment, because ' +
|
|
34
|
+
"padding={0} removes the inset between that Layout's regions and the " +
|
|
35
|
+
"Layout's own padding restores only its outer edges. Remove " +
|
|
36
|
+
'`padding={0}` and your own inset to adopt the theme padding. An app ' +
|
|
37
|
+
'whose theme already sets `bottom-sheet` padding on every edge is not ' +
|
|
38
|
+
'affected by the new default; the transform cannot see the theme, so ' +
|
|
39
|
+
'remove the added `padding={0}` there to keep the theme inset.',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const CORE_IMPORT_RE = /^@(astryxdesign|xds)\/core(?:\/|$)/;
|
|
43
|
+
|
|
44
|
+
const TODO_COMMENT =
|
|
45
|
+
' TODO(astryx upgrade): BottomSheet now pads its content like Dialog. ' +
|
|
46
|
+
'padding={0} keeps the unpadded content box, but it also removes the inset ' +
|
|
47
|
+
"between a nested Layout's regions, which the Layout's own padding does " +
|
|
48
|
+
"not restore. Drop padding={0} and the sheet content's own inset, or give " +
|
|
49
|
+
'the Layout its inset another way. ';
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Local JSX names bound to core components, by imported name.
|
|
53
|
+
* @param {any} root
|
|
54
|
+
* @param {any} j
|
|
55
|
+
* @param {string} component
|
|
56
|
+
* @returns {{direct: Set<string>, namespaces: Set<string>}}
|
|
57
|
+
*/
|
|
58
|
+
function findBindings(root, j, component) {
|
|
59
|
+
const direct = new Set();
|
|
60
|
+
const namespaces = new Set();
|
|
61
|
+
root.find(j.ImportDeclaration).forEach((/** @type {any} */ importPath) => {
|
|
62
|
+
const source = importPath.node.source.value;
|
|
63
|
+
if (
|
|
64
|
+
importPath.node.importKind === 'type' ||
|
|
65
|
+
typeof source !== 'string' ||
|
|
66
|
+
!CORE_IMPORT_RE.test(source)
|
|
67
|
+
) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const subpath = source.split('/').at(-1);
|
|
71
|
+
for (const specifier of importPath.node.specifiers ?? []) {
|
|
72
|
+
if (specifier.importKind === 'type') continue;
|
|
73
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
74
|
+
const imported = specifier.imported?.name ?? specifier.imported?.value;
|
|
75
|
+
if (imported === component) {
|
|
76
|
+
direct.add(specifier.local?.name ?? imported);
|
|
77
|
+
}
|
|
78
|
+
} else if (
|
|
79
|
+
specifier.type === 'ImportDefaultSpecifier' &&
|
|
80
|
+
subpath === component
|
|
81
|
+
) {
|
|
82
|
+
direct.add(specifier.local.name);
|
|
83
|
+
} else if (specifier.type === 'ImportNamespaceSpecifier') {
|
|
84
|
+
namespaces.add(specifier.local.name);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return {direct, namespaces};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @param {any} name JSX element name node
|
|
93
|
+
* @param {{direct: Set<string>, namespaces: Set<string>}} bindings
|
|
94
|
+
* @param {string} component
|
|
95
|
+
*/
|
|
96
|
+
function nameMatches(name, bindings, component) {
|
|
97
|
+
if (name?.type === 'JSXIdentifier') {
|
|
98
|
+
return bindings.direct.has(name.name);
|
|
99
|
+
}
|
|
100
|
+
return (
|
|
101
|
+
name?.type === 'JSXMemberExpression' &&
|
|
102
|
+
name.object?.type === 'JSXIdentifier' &&
|
|
103
|
+
bindings.namespaces.has(name.object.name) &&
|
|
104
|
+
name.property?.name === component
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// A parameter or local declaration with the imported name shadows the module
|
|
109
|
+
// binding (same rule as transform-prop.mjs): only a tag whose root binding
|
|
110
|
+
// resolves to the Program scope is the imported component.
|
|
111
|
+
/** @param {any} elementPath @param {any} name */
|
|
112
|
+
function isModuleBinding(elementPath, name) {
|
|
113
|
+
const localName =
|
|
114
|
+
name?.type === 'JSXIdentifier'
|
|
115
|
+
? name.name
|
|
116
|
+
: name?.type === 'JSXMemberExpression' &&
|
|
117
|
+
name.object?.type === 'JSXIdentifier'
|
|
118
|
+
? name.object.name
|
|
119
|
+
: null;
|
|
120
|
+
if (localName == null) return false;
|
|
121
|
+
const scope = elementPath.scope?.lookup(localName);
|
|
122
|
+
return scope?.path?.node?.type === 'Program';
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Children that render something: drops whitespace-only text and empty
|
|
127
|
+
* `{}` / `{/* comment *\/}` containers.
|
|
128
|
+
* @param {any[]} children
|
|
129
|
+
*/
|
|
130
|
+
function meaningfulChildren(children) {
|
|
131
|
+
return children.filter((/** @type {any} */ child) => {
|
|
132
|
+
if (child.type === 'JSXText') {
|
|
133
|
+
return child.value.trim() !== '';
|
|
134
|
+
}
|
|
135
|
+
if (child.type === 'JSXExpressionContainer') {
|
|
136
|
+
return child.expression?.type !== 'JSXEmptyExpression';
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Attach the TODO to the nearest enclosing statement: a comment on a JSX node
|
|
144
|
+
* inside JSX children would print as text.
|
|
145
|
+
* @param {any} j
|
|
146
|
+
* @param {any} elementPath
|
|
147
|
+
*/
|
|
148
|
+
function addTodo(j, elementPath) {
|
|
149
|
+
let path = elementPath;
|
|
150
|
+
while (path && !j.Statement.check(path.node)) {
|
|
151
|
+
path = path.parent;
|
|
152
|
+
}
|
|
153
|
+
if (!path) return;
|
|
154
|
+
const host = path.node;
|
|
155
|
+
host.comments = host.comments ?? [];
|
|
156
|
+
if (host.comments.some((/** @type {any} */ c) => c.value === TODO_COMMENT)) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
host.comments.push(j.commentBlock(TODO_COMMENT, true, false));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @param {import('../../../../authoring/codemod/type').AstryxCodemodFile} file
|
|
164
|
+
* @param {import('../../../../authoring/codemod/type').CodemodTransformApi} api
|
|
165
|
+
* @returns {string | null | undefined}
|
|
166
|
+
*/
|
|
167
|
+
export default function transformer(file, api) {
|
|
168
|
+
if (!file.source.includes('BottomSheet')) return undefined;
|
|
169
|
+
const j = api.jscodeshift;
|
|
170
|
+
const root = j(file.source);
|
|
171
|
+
const sheets = findBindings(root, j, 'BottomSheet');
|
|
172
|
+
if (sheets.direct.size === 0 && sheets.namespaces.size === 0) {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
const sections = findBindings(root, j, 'Section');
|
|
176
|
+
const layouts = findBindings(root, j, 'Layout');
|
|
177
|
+
let hasChanges = false;
|
|
178
|
+
|
|
179
|
+
root.find(j.JSXElement).forEach((/** @type {any} */ elementPath) => {
|
|
180
|
+
const opening = elementPath.node.openingElement;
|
|
181
|
+
if (!nameMatches(opening.name, sheets, 'BottomSheet')) return;
|
|
182
|
+
if (!isModuleBinding(elementPath, opening.name)) return;
|
|
183
|
+
|
|
184
|
+
const attributes = opening.attributes ?? [];
|
|
185
|
+
const setsPadding = attributes.some(
|
|
186
|
+
(/** @type {any} */ attribute) =>
|
|
187
|
+
attribute.type === 'JSXAttribute' && attribute.name?.name === 'padding',
|
|
188
|
+
);
|
|
189
|
+
if (setsPadding) return;
|
|
190
|
+
|
|
191
|
+
const children = meaningfulChildren(elementPath.node.children ?? []);
|
|
192
|
+
const hasChildrenAttribute = attributes.some(
|
|
193
|
+
(/** @type {any} */ attribute) =>
|
|
194
|
+
attribute.type === 'JSXAttribute' &&
|
|
195
|
+
attribute.name?.name === 'children',
|
|
196
|
+
);
|
|
197
|
+
if (
|
|
198
|
+
!hasChildrenAttribute &&
|
|
199
|
+
children.length === 1 &&
|
|
200
|
+
children[0].type === 'JSXElement' &&
|
|
201
|
+
(nameMatches(children[0].openingElement.name, sections, 'Section') ||
|
|
202
|
+
nameMatches(children[0].openingElement.name, layouts, 'Layout')) &&
|
|
203
|
+
isModuleBinding(
|
|
204
|
+
elementPath.get('children', 0),
|
|
205
|
+
children[0].openingElement.name,
|
|
206
|
+
)
|
|
207
|
+
) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const padding = j.jsxAttribute(
|
|
212
|
+
j.jsxIdentifier('padding'),
|
|
213
|
+
j.jsxExpressionContainer(j.numericLiteral(0)),
|
|
214
|
+
);
|
|
215
|
+
const firstSpread = attributes.findIndex(
|
|
216
|
+
(/** @type {any} */ attribute) => attribute.type === 'JSXSpreadAttribute',
|
|
217
|
+
);
|
|
218
|
+
if (firstSpread === -1) {
|
|
219
|
+
attributes.push(padding);
|
|
220
|
+
} else {
|
|
221
|
+
attributes.splice(firstSpread, 0, padding);
|
|
222
|
+
}
|
|
223
|
+
opening.attributes = attributes;
|
|
224
|
+
hasChanges = true;
|
|
225
|
+
|
|
226
|
+
// Any nested core Layout loses the inset between its regions, with or
|
|
227
|
+
// without its own padding, so every one gets the TODO.
|
|
228
|
+
const hasNestedLayout =
|
|
229
|
+
j(elementPath)
|
|
230
|
+
.find(j.JSXOpeningElement)
|
|
231
|
+
.filter(
|
|
232
|
+
(/** @type {any} */ openingPath) =>
|
|
233
|
+
nameMatches(openingPath.node.name, layouts, 'Layout') &&
|
|
234
|
+
isModuleBinding(openingPath, openingPath.node.name),
|
|
235
|
+
).length > 0;
|
|
236
|
+
if (hasNestedLayout) {
|
|
237
|
+
addTodo(j, elementPath);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
return hasChanges ? root.toSource() : undefined;
|
|
242
|
+
}
|
|
@@ -18,7 +18,7 @@ export const docs = {
|
|
|
18
18
|
content: [
|
|
19
19
|
{
|
|
20
20
|
type: 'prose',
|
|
21
|
-
text: 'The design system uses a 4px base-unit spacing scale. Component gap props accept step values that map to these tokens. The scale provides fine-grained control at the small end (2px, 4px, 6px) and consistent rhythm at larger sizes (multiples of 4px).',
|
|
21
|
+
text: 'The design system uses a 4px base-unit spacing scale, written in rem so gaps and padding grow with the reader\'s browser font size the way text does: each step is 0.25rem, which is 4px at the default 16px root. Component gap props accept step values that map to these tokens. The scale provides fine-grained control at the small end (2px, 4px, 6px) and consistent rhythm at larger sizes (multiples of 4px).',
|
|
22
22
|
},
|
|
23
23
|
],
|
|
24
24
|
},
|
|
@@ -28,7 +28,7 @@ export const docs = {
|
|
|
28
28
|
content: [
|
|
29
29
|
{
|
|
30
30
|
type: 'prose',
|
|
31
|
-
text: 'Fifteen spacing tokens, from 0px to 48px.',
|
|
31
|
+
text: 'Fifteen spacing tokens, from 0 to 3rem (0px to 48px at the default 16px root).',
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
type: 'token-ref',
|
|
@@ -35,63 +35,63 @@ export const docs = {
|
|
|
35
35
|
"rows": [
|
|
36
36
|
[
|
|
37
37
|
"--spacing-0",
|
|
38
|
-
"
|
|
38
|
+
"0rem"
|
|
39
39
|
],
|
|
40
40
|
[
|
|
41
41
|
"--spacing-0-5",
|
|
42
|
-
"
|
|
42
|
+
"0.125rem"
|
|
43
43
|
],
|
|
44
44
|
[
|
|
45
45
|
"--spacing-1",
|
|
46
|
-
"
|
|
46
|
+
"0.25rem"
|
|
47
47
|
],
|
|
48
48
|
[
|
|
49
49
|
"--spacing-1-5",
|
|
50
|
-
"
|
|
50
|
+
"0.375rem"
|
|
51
51
|
],
|
|
52
52
|
[
|
|
53
53
|
"--spacing-2",
|
|
54
|
-
"
|
|
54
|
+
"0.5rem"
|
|
55
55
|
],
|
|
56
56
|
[
|
|
57
57
|
"--spacing-3",
|
|
58
|
-
"
|
|
58
|
+
"0.75rem"
|
|
59
59
|
],
|
|
60
60
|
[
|
|
61
61
|
"--spacing-4",
|
|
62
|
-
"
|
|
62
|
+
"1rem"
|
|
63
63
|
],
|
|
64
64
|
[
|
|
65
65
|
"--spacing-5",
|
|
66
|
-
"
|
|
66
|
+
"1.25rem"
|
|
67
67
|
],
|
|
68
68
|
[
|
|
69
69
|
"--spacing-6",
|
|
70
|
-
"
|
|
70
|
+
"1.5rem"
|
|
71
71
|
],
|
|
72
72
|
[
|
|
73
73
|
"--spacing-7",
|
|
74
|
-
"
|
|
74
|
+
"1.75rem"
|
|
75
75
|
],
|
|
76
76
|
[
|
|
77
77
|
"--spacing-8",
|
|
78
|
-
"
|
|
78
|
+
"2rem"
|
|
79
79
|
],
|
|
80
80
|
[
|
|
81
81
|
"--spacing-9",
|
|
82
|
-
"
|
|
82
|
+
"2.25rem"
|
|
83
83
|
],
|
|
84
84
|
[
|
|
85
85
|
"--spacing-10",
|
|
86
|
-
"
|
|
86
|
+
"2.5rem"
|
|
87
87
|
],
|
|
88
88
|
[
|
|
89
89
|
"--spacing-11",
|
|
90
|
-
"
|
|
90
|
+
"2.75rem"
|
|
91
91
|
],
|
|
92
92
|
[
|
|
93
93
|
"--spacing-12",
|
|
94
|
-
"
|
|
94
|
+
"3rem"
|
|
95
95
|
]
|
|
96
96
|
]
|
|
97
97
|
}
|
|
@@ -34,7 +34,7 @@ export default function BottomSheetHeights() {
|
|
|
34
34
|
onOpenChange={isOpen => !isOpen && setHeight(null)}
|
|
35
35
|
label={`${height ?? 'Hug'} height`}
|
|
36
36
|
height={height ?? 'hug'}>
|
|
37
|
-
<VStack gap={4}
|
|
37
|
+
<VStack gap={4}>
|
|
38
38
|
<Heading level={3}>{height ?? 'Hug'} height</Heading>
|
|
39
39
|
<Divider />
|
|
40
40
|
<Text type="body">{descriptions[height ?? 'hug']}</Text>
|
|
@@ -51,7 +51,7 @@ export default function BottomSheetMobileKeyboard() {
|
|
|
51
51
|
event.preventDefault();
|
|
52
52
|
setIsOpen(false);
|
|
53
53
|
}}>
|
|
54
|
-
<VStack gap={4}
|
|
54
|
+
<VStack gap={4}>
|
|
55
55
|
<Heading level={3}>Edit profile</Heading>
|
|
56
56
|
<Divider />
|
|
57
57
|
<Text type="supporting" color="secondary">
|
|
@@ -33,7 +33,7 @@ export default function BottomSheetNoScrim() {
|
|
|
33
33
|
label="Place details"
|
|
34
34
|
height="hug"
|
|
35
35
|
hasScrim={false}>
|
|
36
|
-
<VStack gap={4}
|
|
36
|
+
<VStack gap={4}>
|
|
37
37
|
<Heading level={3}>Central Park</Heading>
|
|
38
38
|
<Divider />
|
|
39
39
|
<Text type="body">
|
|
@@ -122,7 +122,7 @@ export default function BottomSheetSnapPoints() {
|
|
|
122
122
|
label="Directions to the Ferry Building"
|
|
123
123
|
height="tall"
|
|
124
124
|
snapPoints={SNAP_POINTS}>
|
|
125
|
-
<VStack gap={4}
|
|
125
|
+
<VStack gap={4}>
|
|
126
126
|
<VStack gap={1}>
|
|
127
127
|
<Heading level={3}>Ferry Building</Heading>
|
|
128
128
|
<HStack gap={2}>
|
|
@@ -2084,7 +2084,8 @@ function FilterOverflow({
|
|
|
2084
2084
|
isOpen={isOpen}
|
|
2085
2085
|
onOpenChange={setIsOpen}
|
|
2086
2086
|
label={label}
|
|
2087
|
-
height="hug"
|
|
2087
|
+
height="hug"
|
|
2088
|
+
padding={0}>
|
|
2088
2089
|
{body}
|
|
2089
2090
|
</BottomSheet>
|
|
2090
2091
|
</>
|
|
@@ -4087,7 +4088,10 @@ export default function TableFilterTemplate() {
|
|
|
4087
4088
|
isOpen={isCompactSurface && isViewOpen}
|
|
4088
4089
|
onOpenChange={setIsViewOpen}
|
|
4089
4090
|
label="View options"
|
|
4090
|
-
height="tall"
|
|
4091
|
+
height="tall"
|
|
4092
|
+
// The tab strip compensates against a container inset, so the sheet
|
|
4093
|
+
// publishes none and the wrapper below owns the top band.
|
|
4094
|
+
padding={0}>
|
|
4091
4095
|
{/* The inset is the wrapper's, so the strip's own box starts at the tab
|
|
4092
4096
|
row and its scroll arrow lands on the tabs rather than above them. */}
|
|
4093
4097
|
<VStack gap={0} paddingBlockStart={SHEET_TOP_INSET}>
|
|
@@ -4313,7 +4317,8 @@ export default function TableFilterTemplate() {
|
|
|
4313
4317
|
isOpen={isCompactSurface && activeJob != null}
|
|
4314
4318
|
onOpenChange={open => !open && setActiveJobId(null)}
|
|
4315
4319
|
label="Job details"
|
|
4316
|
-
height="tall"
|
|
4320
|
+
height="tall"
|
|
4321
|
+
padding={0}>
|
|
4317
4322
|
{detailBody}
|
|
4318
4323
|
</BottomSheet>
|
|
4319
4324
|
);
|
|
@@ -1773,7 +1773,9 @@ function ComposeWindow({
|
|
|
1773
1773
|
// cheaper answer to the same problem: there is not much to drag out of
|
|
1774
1774
|
// the way in the first place.
|
|
1775
1775
|
height="hug"
|
|
1776
|
-
hasScrim={false}
|
|
1776
|
+
hasScrim={false}
|
|
1777
|
+
// The Layout below owns the inset; the sheet adds none of its own.
|
|
1778
|
+
padding={0}>
|
|
1777
1779
|
{/* The grab handle floats over the top edge, out of flow, about 12px
|
|
1778
1780
|
down. The Layout's own padding is not quite enough to clear it — the
|
|
1779
1781
|
heading came up level with the pill, four pixels under it — so the
|
|
@@ -65,6 +65,18 @@ export const butterTheme = defineTheme({
|
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
67
|
|
|
68
|
+
// Touch + narrow (Mobile Type, Pin): floor base to the 16px floor and
|
|
69
|
+
// re-derive the ratio so Display 1 keeps its desktop size:
|
|
70
|
+
// ratio' = 1.25 * (14/16)^(1/6) ~= 1.2225. Body 14 -> 16px, display-1 stays 53px.
|
|
71
|
+
adaptations: {
|
|
72
|
+
rules: [
|
|
73
|
+
{
|
|
74
|
+
when: {pointer: 'coarse', width: {below: 'lg'}},
|
|
75
|
+
value: {typography: {scale: {base: 16, ratio: 1.2225}}},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
|
|
68
80
|
motion: {fast: 125, medium: 300, slow: 700, ratio: 0.75},
|
|
69
81
|
|
|
70
82
|
syntax: butterSyntax,
|
|
@@ -55,6 +55,18 @@ export const chocolateTheme = defineTheme({
|
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
|
|
58
|
+
// Touch + narrow (Mobile Type, Pin): floor base to the 16px floor and
|
|
59
|
+
// re-derive the ratio so Display 1 keeps its desktop size:
|
|
60
|
+
// ratio' = 1.2 * (14/16)^(1/6) ~= 1.1736. Body 14 -> 16px, display-1 stays 42px.
|
|
61
|
+
adaptations: {
|
|
62
|
+
rules: [
|
|
63
|
+
{
|
|
64
|
+
when: {pointer: 'coarse', width: {below: 'lg'}},
|
|
65
|
+
value: {typography: {scale: {base: 16, ratio: 1.1736}}},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
|
|
58
70
|
motion: {fast: 125, medium: 300, slow: 700, ratio: 0.75},
|
|
59
71
|
|
|
60
72
|
syntax: chocolateSyntax,
|
|
@@ -180,20 +180,20 @@ export const matchaTheme = defineTheme({
|
|
|
180
180
|
// =========================================================================
|
|
181
181
|
// Spacing
|
|
182
182
|
// =========================================================================
|
|
183
|
-
'--spacing-0-5': '
|
|
184
|
-
'--spacing-1': '
|
|
185
|
-
'--spacing-1-5': '
|
|
186
|
-
'--spacing-2': '
|
|
187
|
-
'--spacing-3': '
|
|
188
|
-
'--spacing-4': '
|
|
189
|
-
'--spacing-5': '
|
|
190
|
-
'--spacing-6': '
|
|
191
|
-
'--spacing-7': '
|
|
192
|
-
'--spacing-8': '
|
|
193
|
-
'--spacing-9': '
|
|
194
|
-
'--spacing-10': '
|
|
195
|
-
'--spacing-11': '
|
|
196
|
-
'--spacing-12': '
|
|
183
|
+
'--spacing-0-5': '0.1875rem',
|
|
184
|
+
'--spacing-1': '0.375rem',
|
|
185
|
+
'--spacing-1-5': '0.5625rem',
|
|
186
|
+
'--spacing-2': '0.75rem',
|
|
187
|
+
'--spacing-3': '1.125rem',
|
|
188
|
+
'--spacing-4': '1.5rem',
|
|
189
|
+
'--spacing-5': '1.875rem',
|
|
190
|
+
'--spacing-6': '2.25rem',
|
|
191
|
+
'--spacing-7': '2.625rem',
|
|
192
|
+
'--spacing-8': '3rem',
|
|
193
|
+
'--spacing-9': '3.375rem',
|
|
194
|
+
'--spacing-10': '3.75rem',
|
|
195
|
+
'--spacing-11': '4.125rem',
|
|
196
|
+
'--spacing-12': '4.5rem',
|
|
197
197
|
|
|
198
198
|
// =========================================================================
|
|
199
199
|
// Radius — soft and rounded
|
|
@@ -95,6 +95,18 @@ export const neutralTheme = defineTheme({
|
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
97
|
|
|
98
|
+
// Touch + narrow (Mobile Type, Pin): floor base to the 16px floor and
|
|
99
|
+
// re-derive the ratio so Display 1 keeps its desktop size:
|
|
100
|
+
// ratio' = 1.2 * (14/16)^(1/6) ~= 1.1736. Body 14 -> 16px, display-1 stays 42px.
|
|
101
|
+
adaptations: {
|
|
102
|
+
rules: [
|
|
103
|
+
{
|
|
104
|
+
when: {pointer: 'coarse', width: {below: 'lg'}},
|
|
105
|
+
value: {typography: {scale: {base: 16, ratio: 1.1736}}},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
|
|
98
110
|
// Motion: snappier than default to match shadcn/Tailwind conventions.
|
|
99
111
|
// Produces: fast-min=95ms, fast=125ms, fast-max=165ms,
|
|
100
112
|
// medium-min=225ms, medium=300ms, medium-max=400ms.
|
|
@@ -81,6 +81,18 @@ export const stoneTheme = defineTheme({
|
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
83
|
|
|
84
|
+
// Touch + narrow (Mobile Type, Pin): floor base to the 16px floor and
|
|
85
|
+
// re-derive the ratio so Display 1 keeps its desktop size:
|
|
86
|
+
// ratio' = 1.25 * (14/16)^(1/6) ~= 1.2225. Body 14 -> 16px, display-1 stays 53px.
|
|
87
|
+
adaptations: {
|
|
88
|
+
rules: [
|
|
89
|
+
{
|
|
90
|
+
when: {pointer: 'coarse', width: {below: 'lg'}},
|
|
91
|
+
value: {typography: {scale: {base: 16, ratio: 1.2225}}},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
|
|
84
96
|
motion: {fast: 125, medium: 300, slow: 700, ratio: 0.75},
|
|
85
97
|
|
|
86
98
|
syntax: stoneSyntax,
|
|
@@ -63,16 +63,16 @@ export const y2kTheme = defineTheme({
|
|
|
63
63
|
// =========================================================================
|
|
64
64
|
// Spacing — comfortable preset (base=6)
|
|
65
65
|
// =========================================================================
|
|
66
|
-
'--spacing-0-5': '
|
|
67
|
-
'--spacing-1': '
|
|
68
|
-
'--spacing-1-5': '
|
|
69
|
-
'--spacing-2': '
|
|
70
|
-
'--spacing-3': '
|
|
71
|
-
'--spacing-4': '
|
|
72
|
-
'--spacing-5': '
|
|
73
|
-
'--spacing-6': '
|
|
74
|
-
'--spacing-7': '
|
|
75
|
-
'--spacing-8': '
|
|
66
|
+
'--spacing-0-5': '0.1875rem',
|
|
67
|
+
'--spacing-1': '0.375rem',
|
|
68
|
+
'--spacing-1-5': '0.5625rem',
|
|
69
|
+
'--spacing-2': '0.75rem',
|
|
70
|
+
'--spacing-3': '1.125rem',
|
|
71
|
+
'--spacing-4': '1.5rem',
|
|
72
|
+
'--spacing-5': '1.875rem',
|
|
73
|
+
'--spacing-6': '2.25rem',
|
|
74
|
+
'--spacing-7': '2.625rem',
|
|
75
|
+
'--spacing-8': '3rem',
|
|
76
76
|
|
|
77
77
|
// Size — comfortable preset
|
|
78
78
|
'--size-element-sm': '32px',
|
package/assets/theme.template.ts
CHANGED
|
@@ -373,7 +373,7 @@ export const myTheme = defineTheme({
|
|
|
373
373
|
// {
|
|
374
374
|
// // Narrow at every pointer precision.
|
|
375
375
|
// when: {width: {below: 'md'}},
|
|
376
|
-
// value: {tokens: {'--spacing-4': '
|
|
376
|
+
// value: {tokens: {'--spacing-4': '0.75rem'}},
|
|
377
377
|
// },
|
|
378
378
|
// {
|
|
379
379
|
// // Taller controls under a finger or stylus at every width.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.0-canary.
|
|
3
|
+
"version": "0.7.0-canary.19b1c00",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -101,10 +101,10 @@
|
|
|
101
101
|
"zod": "^4.4.3"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@astryxdesign/charts": "0.7.0-canary.
|
|
105
|
-
"@astryxdesign/core": "0.7.0-canary.
|
|
106
|
-
"@astryxdesign/lab": "0.7.0-canary.
|
|
107
|
-
"@astryxdesign/theme-neutral": "0.7.0-canary.
|
|
104
|
+
"@astryxdesign/charts": "0.7.0-canary.19b1c00",
|
|
105
|
+
"@astryxdesign/core": "0.7.0-canary.19b1c00",
|
|
106
|
+
"@astryxdesign/lab": "0.7.0-canary.19b1c00",
|
|
107
|
+
"@astryxdesign/theme-neutral": "0.7.0-canary.19b1c00"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
110
110
|
"@astryxdesign/charts": {
|
|
@@ -121,10 +121,10 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"@astryxdesign/charts": "0.7.0-canary.
|
|
125
|
-
"@astryxdesign/core": "0.7.0-canary.
|
|
126
|
-
"@astryxdesign/lab": "0.7.0-canary.
|
|
127
|
-
"@astryxdesign/theme-neutral": "0.7.0-canary.
|
|
124
|
+
"@astryxdesign/charts": "0.7.0-canary.19b1c00",
|
|
125
|
+
"@astryxdesign/core": "0.7.0-canary.19b1c00",
|
|
126
|
+
"@astryxdesign/lab": "0.7.0-canary.19b1c00",
|
|
127
|
+
"@astryxdesign/theme-neutral": "0.7.0-canary.19b1c00",
|
|
128
128
|
"@heroicons/react": "^2.2.0",
|
|
129
129
|
"@stylexjs/stylex": "^0.19.0",
|
|
130
130
|
"@types/babel__core": "^7.20.5",
|