An open source design system that's fully customizable and agent ready
TypeScript
feat(core)!: BottomSheet pads its content by default, like Dialog (#6884)
Xinzi Zhoub507cdef4dbf
diff --git a/.changeset/bottom-sheet-default-padding.md b/.changeset/bottom-sheet-default-padding.mdnew file mode 100644index 0000000000..cc3ff1544d--- /dev/null+++ b/.changeset/bottom-sheet-default-padding.md@@ -0,0 +1,11 @@+---+'@astryxdesign/core': minor+---++[breaking] BottomSheet pads its content by default, like Dialog. With no `padding` prop and no theme padding, the content box now pads by `--spacing-4` (it had no padding before) and publishes that inset.++A sheet whose only child is a padded `Section` or a `Layout` renders as before, because both escape the inset. Content that supplies its own inset is now padded twice: drop that inset, or pass `padding={0}` to keep the unpadded content box. `astryx upgrade` ships `preserve-bottom-sheet-content-padding`, which adds `padding={0}` where needed.++Migration: pass `padding={0}` to keep the unpadded content box, or drop your own inset to take the default; `astryx upgrade` adds `padding={0}` to every BottomSheet that sets no padding unless its only child is a padded Section or a Layout. An app whose theme already sets `bottom-sheet` padding on every edge is not affected by the new default; the codemod cannot see the theme, so remove the `padding={0}` it adds there to keep the theme inset. A sheet whose content wraps a `Layout` gets a TODO: `padding={0}` also removes the inset between that Layout's regions, which the Layout's own `padding` does not restore.++@imdreamrunnerdiff --git a/.changeset/bottom-sheet-padding-codemod.md b/.changeset/bottom-sheet-padding-codemod.mdnew file mode 100644index 0000000000..9ea764e98f--- /dev/null+++ b/.changeset/bottom-sheet-padding-codemod.md@@ -0,0 +1,7 @@+---+'@astryxdesign/cli': patch+---++[feat] `astryx upgrade` adds `padding={0}` to BottomSheet elements that do not set `padding`, keeping their unpadded content box now that BottomSheet pads like Dialog. Sheets whose only child is a Section or a Layout are left unchanged. A sheet with a Layout anywhere in its content also gets a TODO comment, because `padding={0}` removes the inset between that Layout's regions and the Layout's own `padding` restores only its outer edges. A shadowed `BottomSheet` binding is left alone, and a second run changes nothing.++@imdreamrunnerdiff --git a/apps/storybook/stories/BottomSheet.stories.tsx b/apps/storybook/stories/BottomSheet.stories.tsxindex 46e2d94cf5..d0d29ae649 100644--- a/apps/storybook/stories/BottomSheet.stories.tsx+++ b/apps/storybook/stories/BottomSheet.stories.tsx@@ -83,6 +83,7 @@ export const TextOnly: Story = {const [isOpen, setIsOpen] = useState(true);return (<BottomSheet+ padding={0}{...standaloneArgs}isOpen={isOpen}onOpenChange={setIsOpen}@@ -123,10 +124,10 @@ export const TextOnlyFitting: Story = {};/**- * Content placed directly in a sheet with `padding`. The sheet pads it like- * Dialog, and a full-bleed Divider reaches the sheet's edges because the- * content box publishes its inset. Without `padding` (or a theme's- * bottom-sheet padding) the content box stays unpadded.+ * Content placed directly in a sheet. The sheet pads it like Dialog, by+ * default or at the `padding` step given here, and a full-bleed Divider+ * reaches the sheet's edges because the content box publishes its inset.+ * `padding={0}` restores the unpadded content box.*/export const ContainerPadding: Story = {args: {diff --git a/apps/storybook/stories/Dialog.stories.tsx b/apps/storybook/stories/Dialog.stories.tsxindex 3106dbd82a..adf7bffdeb 100644--- a/apps/storybook/stories/Dialog.stories.tsx+++ b/apps/storybook/stories/Dialog.stories.tsx@@ -1060,7 +1060,8 @@ function PresentationChoice({presentation}: PresentationChoiceProps) {onOpenChange={setIsOpen}label={title}purpose="info"- height="hug">+ height="hug"+ padding={0}><VStack gap={4} style={{padding: 'var(--spacing-4)'}}><Heading level={3}>{title}</Heading><Text type="supporting" color="secondary">diff --git a/apps/storybook/stories/LayerDismissal.stories.tsx b/apps/storybook/stories/LayerDismissal.stories.tsxindex 0c5004f0b9..451c5f7287 100644--- a/apps/storybook/stories/LayerDismissal.stories.tsx+++ b/apps/storybook/stories/LayerDismissal.stories.tsx@@ -540,7 +540,7 @@ function SheetWithHoverTipExample() {activeSheet={activeSheet}onActiveSheetChange={setActiveSheet}hasScrim={false}>- <BottomSheet sheetId="details" label="Details" height="hug">+ <BottomSheet sheetId="details" label="Details" height="hug" padding={0}><VStack gap={3} xstyle={sheetStyles.body}><Text type="body">Hover the button to show the tip, then press Escape. The firstdiff --git a/packages/cli/assets/codemods/transforms/next/__tests__/preserve-bottom-sheet-content-padding.test.mjs b/packages/cli/assets/codemods/transforms/next/__tests__/preserve-bottom-sheet-content-padding.test.mjsnew file mode 100644index 0000000000..fd99f8f8f1--- /dev/null+++ b/packages/cli/assets/codemods/transforms/next/__tests__/preserve-bottom-sheet-content-padding.test.mjs@@ -0,0 +1,178 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++import {describe, expect, it} from 'vitest';+import transform from '../preserve-bottom-sheet-content-padding.mjs';++async function applyTransform(source) {+ const jscodeshift = (await import('jscodeshift')).default;+ const j = jscodeshift.withParser('tsx');+ const api = {jscodeshift: j, stats: () => {}, report: () => {}};+ return transform({source, path: 'test.tsx'}, api) ?? source;+}++describe('preserve-bottom-sheet-content-padding', () => {+ it('adds padding={0} to a sheet with self-padded content', async () => {+ const output =+ await applyTransform(`import {BottomSheet, VStack} from '@astryxdesign/core';+const a = (+ <BottomSheet isOpen={isOpen} onOpenChange={setIsOpen} label="Filters">+ <VStack gap={4} padding={4}>x</VStack>+ </BottomSheet>+);`);++ expect(output).toContain(+ '<BottomSheet isOpen={isOpen} onOpenChange={setIsOpen} label="Filters" padding={0}>',+ );+ });++ it('leaves a sheet whose only child is a core Section unchanged', async () => {+ const source = `import {BottomSheet, Section, VStack} from '@astryxdesign/core';+const a = (+ <BottomSheet isOpen onOpenChange={() => {}} label="Filters">+ {/* filters */}+ <Section padding={4}>+ <VStack gap={4}>x</VStack>+ </Section>+ </BottomSheet>+);`;+ expect(await applyTransform(source)).toBe(source);+ });++ it('leaves a sheet whose only child is a core Layout unchanged', async () => {+ const source = `import {BottomSheet, Layout, LayoutContent} from '@astryxdesign/core';+const a = (+ <BottomSheet isOpen onOpenChange={() => {}} label="Message">+ <Layout content={<LayoutContent>x</LayoutContent>} />+ </BottomSheet>+);`;+ expect(await applyTransform(source)).toBe(source);+ });++ it('flags every nested Layout with a TODO, with or without its own padding', async () => {+ const output =+ await applyTransform(`import {BottomSheet, Layout, VStack} from '@astryxdesign/core';+function A() {+ return (+ <BottomSheet sheetId="a" label="A">+ <VStack>+ <Layout content={x} />+ </VStack>+ </BottomSheet>+ );+}+function B() {+ return (+ <BottomSheet sheetId="b" label="B">+ <VStack>+ <Layout padding={4} content={x} />+ </VStack>+ </BottomSheet>+ );+}`);++ expect(output).toContain('<BottomSheet sheetId="a" label="A" padding={0}>');+ expect(output).toContain('<BottomSheet sheetId="b" label="B" padding={0}>');+ expect(output.match(/TODO\(astryx upgrade\)/g)).toHaveLength(2);+ expect(output.indexOf('TODO(astryx upgrade)')).toBeLessThan(+ output.indexOf('sheetId="a"'),+ );+ expect(output.indexOf('TODO(astryx upgrade)')).toBeGreaterThan(+ output.indexOf('function A'),+ );+ expect(output.lastIndexOf('TODO(astryx upgrade)')).toBeGreaterThan(+ output.indexOf('function B'),+ );+ });++ it('does not flag a Layout from another package or a shadowed Layout binding', async () => {+ const output =+ await applyTransform(`import {BottomSheet} from '@astryxdesign/core';+import {Layout} from './my-layout';+export function A() {+ return <BottomSheet isOpen><Layout content={<p>b</p>} /></BottomSheet>;+}+`);+ expect(output).toContain('padding={0}');+ expect(output).not.toContain('TODO');+ });++ it('leaves a BottomSheet that a parameter or local binding shadows alone', async () => {+ const source = `import {BottomSheet} from '@astryxdesign/core';+export function Host({BottomSheet: Sheet}) {+ return <Sheet isOpen><p>own inset</p></Sheet>;+}+export function Local() {+ const BottomSheet = (props) => <div {...props} />;+ return <BottomSheet isOpen><p>own inset</p></BottomSheet>;+}+`;+ expect(await applyTransform(source)).toBe(source);+ });++ it('is idempotent: a second run changes nothing', async () => {+ const once =+ await applyTransform(`import {BottomSheet, Layout, VStack} from '@astryxdesign/core';+export function A() {+ return <BottomSheet isOpen><VStack><p>a</p></VStack></BottomSheet>;+}+export function B() {+ return <BottomSheet isOpen><VStack><Layout content={<p>b</p>} /></VStack></BottomSheet>;+}+`);+ expect(await applyTransform(once)).toBe(once);+ });++ it('pads a sheet when the Section has a sibling or is not from core', async () => {+ const output =+ await applyTransform(`import {BottomSheet} from '@astryxdesign/core';+import {Section} from './local';+import {Section as CoreSection} from '@astryxdesign/core';+const a = <BottomSheet sheetId="a" label="A"><Section>x</Section></BottomSheet>;+const b = (+ <BottomSheet sheetId="b" label="B">+ <CoreSection>x</CoreSection>+ <p>after</p>+ </BottomSheet>+);`);++ expect(output).toContain('<BottomSheet sheetId="a" label="A" padding={0}>');+ expect(output).toContain('<BottomSheet sheetId="b" label="B" padding={0}>');+ });++ it('leaves a sheet that already sets padding unchanged', async () => {+ const source = `import {BottomSheet} from '@astryxdesign/core';+const a = <BottomSheet sheetId="a" label="A" padding={2}>x</BottomSheet>;+const b = <BottomSheet sheetId="b" label="B" padding={value}>x</BottomSheet>;`;+ expect(await applyTransform(source)).toBe(source);+ });++ it('follows aliases, subpath default imports, and namespace imports', async () => {+ const output =+ await applyTransform(`import {BottomSheet as Sheet} from '@astryxdesign/core';+import Panel from '@astryxdesign/core/BottomSheet';+import * as Core from '@astryxdesign/core';+const a = <Sheet sheetId="a" label="A">x</Sheet>;+const b = <Panel sheetId="b" label="B">x</Panel>;+const c = <Core.BottomSheet sheetId="c" label="C">x</Core.BottomSheet>;`);++ expect(output).toContain('<Sheet sheetId="a" label="A" padding={0}>');+ expect(output).toContain('<Panel sheetId="b" label="B" padding={0}>');+ expect(output).toContain(+ '<Core.BottomSheet sheetId="c" label="C" padding={0}>',+ );+ });++ it('puts padding={0} before a spread so a spread padding still wins', async () => {+ const output =+ await applyTransform(`import {BottomSheet} from '@astryxdesign/core';+const a = <BottomSheet label="A" {...args} />;`);++ expect(output).toContain('<BottomSheet label="A" padding={0} {...args} />');+ });++ it('ignores BottomSheet from other packages', async () => {+ const source = `import {BottomSheet} from './prototype';+const a = <BottomSheet title="A">x</BottomSheet>;`;+ expect(await applyTransform(source)).toBe(source);+ });+});diff --git a/packages/cli/assets/codemods/transforms/next/index.mjs b/packages/cli/assets/codemods/transforms/next/index.mjsindex 18e02ea216..255f6217e0 100644--- a/packages/cli/assets/codemods/transforms/next/index.mjs+++ b/packages/cli/assets/codemods/transforms/next/index.mjs@@ -13,6 +13,9 @@ import migrateDeprecatedThemeSurface, {import migrateFieldInputStyling, {meta as migrateFieldInputStylingMeta,} from './migrate-field-input-styling.mjs';+import preserveBottomSheetContentPadding, {+ meta as preserveBottomSheetContentPaddingMeta,+} from './preserve-bottom-sheet-content-padding.mjs';import validateDataTokenOwnership, {meta as validateDataTokenOwnershipMeta,} from './validate-data-token-ownership.mjs';@@ -33,4 +36,9 @@ export default [transform: migrateFieldInputStyling,meta: migrateFieldInputStylingMeta,},+ {+ name: 'preserve-bottom-sheet-content-padding',+ transform: preserveBottomSheetContentPadding,+ meta: preserveBottomSheetContentPaddingMeta,+ },];diff --git a/packages/cli/assets/codemods/transforms/next/preserve-bottom-sheet-content-padding.mjs b/packages/cli/assets/codemods/transforms/next/preserve-bottom-sheet-content-padding.mjsnew file mode 100644index 0000000000..d97648eaf1--- /dev/null+++ b/packages/cli/assets/codemods/transforms/next/preserve-bottom-sheet-content-padding.mjs@@ -0,0 +1,242 @@+// Copyright (c) Meta Platforms, Inc. and affiliates.++/**+ * @file Codemod: preserve BottomSheet content geometry after it became a container+ *+ * BottomSheet now pads its content box like Dialog (theme `bottom-sheet`+ * padding, else `--spacing-4`). Before, the content box had no padding, so+ * callers supplied their own inset. This codemod keeps every existing sheet's+ * geometry by adding `padding={0}` to imported BottomSheet elements that do not+ * set `padding`.+ *+ * Sheets whose only child is a core `Section` or `Layout` are left alone: both+ * escape the inset their container publishes, so they already render exactly+ * as they did in the unpadded box.+ *+ * `padding={0}` goes before the first spread attribute, so a spread that+ * carries `padding` still wins.+ *+ * `padding={0}` also zeroes the inset a nested `Layout` puts between its+ * regions: a Layout's own `padding` restores only its outer edges, and the+ * inner inset comes from the sheet's container chain. Such a sheet still gets+ * `padding={0}`, plus a TODO comment on its statement (api.report is a stub;+ * comments are the only warning channel).+ */++export const meta = {+ title: 'Preserve BottomSheet content padding',+ description:+ 'BottomSheet now pads its content like Dialog. Adds `padding={0}` to ' ++ 'BottomSheet elements that do not set `padding`, keeping their previous ' ++ 'unpadded content box. Sheets whose only child is a Section ' ++ 'or Layout are left unchanged; they render identically. A sheet with a ' ++ 'nested Layout anywhere in its content also gets a TODO comment, because ' ++ "padding={0} removes the inset between that Layout's regions and the " ++ "Layout's own padding restores only its outer edges. Remove " ++ '`padding={0}` and your own inset to adopt the theme padding. An app ' ++ 'whose theme already sets `bottom-sheet` padding on every edge is not ' ++ 'affected by the new default; the transform cannot see the theme, so ' ++ 'remove the added `padding={0}` there to keep the theme inset.',+};++const CORE_IMPORT_RE = /^@(astryxdesign|xds)\/core(?:\/|$)/;++const TODO_COMMENT =+ ' TODO(astryx upgrade): BottomSheet now pads its content like Dialog. ' ++ 'padding={0} keeps the unpadded content box, but it also removes the inset ' ++ "between a nested Layout's regions, which the Layout's own padding does " ++ "not restore. Drop padding={0} and the sheet content's own inset, or give " ++ 'the Layout its inset another way. ';++/**+ * Local JSX names bound to core components, by imported name.+ * @param {any} root+ * @param {any} j+ * @param {string} component+ * @returns {{direct: Set<string>, namespaces: Set<string>}}+ */+function findBindings(root, j, component) {+ const direct = new Set();+ const namespaces = new Set();+ root.find(j.ImportDeclaration).forEach((/** @type {any} */ importPath) => {+ const source = importPath.node.source.value;+ if (+ importPath.node.importKind === 'type' ||+ typeof source !== 'string' ||+ !CORE_IMPORT_RE.test(source)+ ) {+ return;+ }+ const subpath = source.split('/').at(-1);+ for (const specifier of importPath.node.specifiers ?? []) {+ if (specifier.importKind === 'type') continue;+ if (specifier.type === 'ImportSpecifier') {+ const imported = specifier.imported?.name ?? specifier.imported?.value;+ if (imported === component) {+ direct.add(specifier.local?.name ?? imported);+ }+ } else if (+ specifier.type === 'ImportDefaultSpecifier' &&+ subpath === component+ ) {+ direct.add(specifier.local.name);+ } else if (specifier.type === 'ImportNamespaceSpecifier') {+ namespaces.add(specifier.local.name);+ }+ }+ });+ return {direct, namespaces};+}++/**+ * @param {any} name JSX element name node+ * @param {{direct: Set<string>, namespaces: Set<string>}} bindings+ * @param {string} component+ */+function nameMatches(name, bindings, component) {+ if (name?.type === 'JSXIdentifier') {+ return bindings.direct.has(name.name);+ }+ return (+ name?.type === 'JSXMemberExpression' &&+ name.object?.type === 'JSXIdentifier' &&+ bindings.namespaces.has(name.object.name) &&+ name.property?.name === component+ );+}++// A parameter or local declaration with the imported name shadows the module+// binding (same rule as transform-prop.mjs): only a tag whose root binding+// resolves to the Program scope is the imported component.+/** @param {any} elementPath @param {any} name */+function isModuleBinding(elementPath, name) {+ const localName =+ name?.type === 'JSXIdentifier'+ ? name.name+ : name?.type === 'JSXMemberExpression' &&+ name.object?.type === 'JSXIdentifier'+ ? name.object.name+ : null;+ if (localName == null) return false;+ const scope = elementPath.scope?.lookup(localName);+ return scope?.path?.node?.type === 'Program';+}++/**+ * Children that render something: drops whitespace-only text and empty+ * `{}` / `{/* comment *\/}` containers.+ * @param {any[]} children+ */+function meaningfulChildren(children) {+ return children.filter((/** @type {any} */ child) => {+ if (child.type === 'JSXText') {+ return child.value.trim() !== '';+ }+ if (child.type === 'JSXExpressionContainer') {+ return child.expression?.type !== 'JSXEmptyExpression';+ }+ return true;+ });+}++/**+ * Attach the TODO to the nearest enclosing statement: a comment on a JSX node+ * inside JSX children would print as text.+ * @param {any} j+ * @param {any} elementPath+ */+function addTodo(j, elementPath) {+ let path = elementPath;+ while (path && !j.Statement.check(path.node)) {+ path = path.parent;+ }+ if (!path) return;+ const host = path.node;+ host.comments = host.comments ?? [];+ if (host.comments.some((/** @type {any} */ c) => c.value === TODO_COMMENT)) {+ return;+ }+ host.comments.push(j.commentBlock(TODO_COMMENT, true, false));+}++/**+ * @param {import('../../../../authoring/codemod/type').AstryxCodemodFile} file+ * @param {import('../../../../authoring/codemod/type').CodemodTransformApi} api+ * @returns {string | null | undefined}+ */+export default function transformer(file, api) {+ if (!file.source.includes('BottomSheet')) return undefined;+ const j = api.jscodeshift;+ const root = j(file.source);+ const sheets = findBindings(root, j, 'BottomSheet');+ if (sheets.direct.size === 0 && sheets.namespaces.size === 0) {+ return undefined;+ }+ const sections = findBindings(root, j, 'Section');+ const layouts = findBindings(root, j, 'Layout');+ let hasChanges = false;++ root.find(j.JSXElement).forEach((/** @type {any} */ elementPath) => {+ const opening = elementPath.node.openingElement;+ if (!nameMatches(opening.name, sheets, 'BottomSheet')) return;+ if (!isModuleBinding(elementPath, opening.name)) return;++ const attributes = opening.attributes ?? [];+ const setsPadding = attributes.some(+ (/** @type {any} */ attribute) =>+ attribute.type === 'JSXAttribute' && attribute.name?.name === 'padding',+ );+ if (setsPadding) return;++ const children = meaningfulChildren(elementPath.node.children ?? []);+ const hasChildrenAttribute = attributes.some(+ (/** @type {any} */ attribute) =>+ attribute.type === 'JSXAttribute' &&+ attribute.name?.name === 'children',+ );+ if (+ !hasChildrenAttribute &&+ children.length === 1 &&+ children[0].type === 'JSXElement' &&+ (nameMatches(children[0].openingElement.name, sections, 'Section') ||+ nameMatches(children[0].openingElement.name, layouts, 'Layout')) &&+ isModuleBinding(+ elementPath.get('children', 0),+ children[0].openingElement.name,+ )+ ) {+ return;+ }++ const padding = j.jsxAttribute(+ j.jsxIdentifier('padding'),+ j.jsxExpressionContainer(j.numericLiteral(0)),+ );+ const firstSpread = attributes.findIndex(+ (/** @type {any} */ attribute) => attribute.type === 'JSXSpreadAttribute',+ );+ if (firstSpread === -1) {+ attributes.push(padding);+ } else {+ attributes.splice(firstSpread, 0, padding);+ }+ opening.attributes = attributes;+ hasChanges = true;++ // Any nested core Layout loses the inset between its regions, with or+ // without its own padding, so every one gets the TODO.+ const hasNestedLayout =+ j(elementPath)+ .find(j.JSXOpeningElement)+ .filter(+ (/** @type {any} */ openingPath) =>+ nameMatches(openingPath.node.name, layouts, 'Layout') &&+ isModuleBinding(openingPath, openingPath.node.name),+ ).length > 0;+ if (hasNestedLayout) {+ addTodo(j, elementPath);+ }+ });++ return hasChanges ? root.toSource() : undefined;+}diff --git a/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetHeights.tsx b/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetHeights.tsxindex f9d4ca802e..8b3f280913 100644--- a/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetHeights.tsx+++ b/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetHeights.tsx@@ -34,7 +34,7 @@ export default function BottomSheetHeights() {onOpenChange={isOpen => !isOpen && setHeight(null)}label={`${height ?? 'Hug'} height`}height={height ?? 'hug'}>- <VStack gap={4} style={{padding: 'var(--spacing-4)'}}>+ <VStack gap={4}><Heading level={3}>{height ?? 'Hug'} height</Heading><Divider /><Text type="body">{descriptions[height ?? 'hug']}</Text>diff --git a/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetMobileKeyboard.tsx b/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetMobileKeyboard.tsxindex a86f56aeb5..578e3fa9e8 100644--- a/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetMobileKeyboard.tsx+++ b/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetMobileKeyboard.tsx@@ -51,7 +51,7 @@ export default function BottomSheetMobileKeyboard() {event.preventDefault();setIsOpen(false);}}>- <VStack gap={4} style={{padding: 'var(--spacing-4)'}}>+ <VStack gap={4}><Heading level={3}>Edit profile</Heading><Divider /><Text type="supporting" color="secondary">diff --git a/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetNoScrim.tsx b/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetNoScrim.tsxindex 1e16f3b1a4..0568a70fc0 100644--- a/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetNoScrim.tsx+++ b/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetNoScrim.tsx@@ -33,7 +33,7 @@ export default function BottomSheetNoScrim() {label="Place details"height="hug"hasScrim={false}>- <VStack gap={4} style={{padding: 'var(--spacing-4)'}}>+ <VStack gap={4}><Heading level={3}>Central Park</Heading><Divider /><Text type="body">diff --git a/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.tsx b/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.tsxindex c74e80f456..ff5c72e7c4 100644--- a/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.tsx+++ b/packages/cli/assets/templates/blocks/components/BottomSheet/BottomSheetSnapPoints.tsx@@ -122,7 +122,7 @@ export default function BottomSheetSnapPoints() {label="Directions to the Ferry Building"height="tall"snapPoints={SNAP_POINTS}>- <VStack gap={4} padding={4}>+ <VStack gap={4}><VStack gap={1}><Heading level={3}>Ferry Building</Heading><HStack gap={2}>diff --git a/packages/cli/assets/templates/blocks/components/Dialog/DialogAdaptivePresentation.tsx b/packages/cli/assets/templates/blocks/components/Dialog/DialogAdaptivePresentation.tsxindex 5e33f6ad20..8fc55918ed 100644--- a/packages/cli/assets/templates/blocks/components/Dialog/DialogAdaptivePresentation.tsx+++ b/packages/cli/assets/templates/blocks/components/Dialog/DialogAdaptivePresentation.tsx@@ -68,7 +68,7 @@ function AdaptiveDialog({label={title}purpose={purpose}height={bottomSheetHeight}>- <VStack gap={4} style={{padding: 'var(--spacing-4)'}}>+ <VStack gap={4}><Heading level={3}>{title}</Heading>{children}{footer}diff --git a/packages/cli/assets/templates/pages/table-filter/page.tsx b/packages/cli/assets/templates/pages/table-filter/page.tsxindex da1f7e339d..04c6bdf1c3 100644--- a/packages/cli/assets/templates/pages/table-filter/page.tsx+++ b/packages/cli/assets/templates/pages/table-filter/page.tsx@@ -2084,7 +2084,8 @@ function FilterOverflow({isOpen={isOpen}onOpenChange={setIsOpen}label={label}- height="hug">+ height="hug"+ padding={0}>{body}</BottomSheet></>@@ -4087,7 +4088,10 @@ export default function TableFilterTemplate() {isOpen={isCompactSurface && isViewOpen}onOpenChange={setIsViewOpen}label="View options"- height="tall">+ height="tall"+ // The tab strip compensates against a container inset, so the sheet+ // publishes none and the wrapper below owns the top band.+ padding={0}>{/* The inset is the wrapper's, so the strip's own box starts at the tabrow and its scroll arrow lands on the tabs rather than above them. */}<VStack gap={0} paddingBlockStart={SHEET_TOP_INSET}>@@ -4313,7 +4317,8 @@ export default function TableFilterTemplate() {isOpen={isCompactSurface && activeJob != null}onOpenChange={open => !open && setActiveJobId(null)}label="Job details"- height="tall">+ height="tall"+ padding={0}>{detailBody}</BottomSheet>);diff --git a/packages/cli/assets/templates/pages/table-inbox/page.tsx b/packages/cli/assets/templates/pages/table-inbox/page.tsxindex b51d88c370..c1990a5450 100644--- a/packages/cli/assets/templates/pages/table-inbox/page.tsx+++ b/packages/cli/assets/templates/pages/table-inbox/page.tsx@@ -1773,7 +1773,9 @@ function ComposeWindow({// cheaper answer to the same problem: there is not much to drag out of// the way in the first place.height="hug"- hasScrim={false}>+ hasScrim={false}+ // The Layout below owns the inset; the sheet adds none of its own.+ padding={0}>{/* The grab handle floats over the top edge, out of flow, about 12pxdown. The Layout's own padding is not quite enough to clear it — theheading came up level with the pill, four pixels under it — so thediff --git a/packages/core/src/BottomSheet/BottomSheet.doc.mjs b/packages/core/src/BottomSheet/BottomSheet.doc.mjsindex 1d193a1f28..baef1d9493 100644--- a/packages/core/src/BottomSheet/BottomSheet.doc.mjs+++ b/packages/core/src/BottomSheet/BottomSheet.doc.mjs@@ -19,7 +19,7 @@ const anatomy = [name: 'Content area',required: true,description:- 'Scrollable container that presents the caller-provided sheet content, padded when padding or a theme sets it.',+ 'Padded, scrollable container that presents the caller-provided sheet content.',},{name: 'Handle',@@ -95,7 +95,7 @@ export const docs = {derived: [{property: 'padding', expand: 'container'}],},description:- "A mobile touch sheet that rises from the bottom edge, with animated entrance and exit, a grab handle, optional drag-to-resize snap points, and purpose-controlled dismissal. Like Dialog, it is a container: set padding (or a theme's bottom-sheet padding) and a lone Section child or bleed children such as Table and Divider align against that inset. By default the content area has no padding. A standalone sheet owns a native <dialog>; inside BottomSheetSwitcher it renders a panel in the switcher's shared dialog. In both modes, ref and shared DOM props target the visual panel <div>.",+ "A mobile touch sheet that rises from the bottom edge, with animated entrance and exit, a grab handle, optional drag-to-resize snap points, and purpose-controlled dismissal. Like Dialog, it is a padded container: content starts at the theme's bottom-sheet padding (--spacing-4 by default), and a lone Section child or bleed children such as Table and Divider align against it. A standalone sheet owns a native <dialog>; inside BottomSheetSwitcher it renders a panel in the switcher's shared dialog. In both modes, ref and shared DOM props target the visual panel <div>.",props: [{name: 'isOpen',@@ -146,7 +146,7 @@ export const docs = {name: 'padding',type: '0 | 0.5 | 1 | 1.5 | 2 | 3 | 4 | 5 | 6 | 8 | 10',description:- 'Internal padding of the sheet content using the spacing scale, matching Dialog. When omitted, uses the theme default for bottom sheets: no padding unless the theme sets padding on bottom-sheet. A lone Section child escapes the padding, and bleed children such as Table and Divider compensate against it.',+ 'Internal padding of the sheet content using the spacing scale, matching Dialog. When omitted, uses the theme default for bottom sheets (--spacing-4 unless the theme sets padding on bottom-sheet). A lone Section child escapes the padding, and bleed children such as Table and Divider compensate against it. Use 0 for edge-to-edge content that supplies its own inset.',},{name: 'height',@@ -320,7 +320,7 @@ export const docs = {/** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */export const docsDense = {description:- 'mobile touch sheet rising from the bottom edge (native <dialog>): grab handle, opt-in transform-based drag-to-resize snap points (snapPoints: viewport fraction, percent or px length), scrolling area resizes to the snapped visible height on release (a peek stop, a quarter of the sheet or less, keeps the full height and slides instead), Dialog-aligned dismissal purpose (info/form/required), purpose-gated swipe-to-dismiss, fully-expanded Tall visual-viewport mobile-keyboard handling, named height scale, Dialog-like container padding (padding prop or theme bottom-sheet padding; none by default), modal (default) or non-modal (hasScrim={false}) presentation',+ 'mobile touch sheet rising from the bottom edge (native <dialog>): grab handle, opt-in transform-based drag-to-resize snap points (snapPoints: viewport fraction, percent or px length), scrolling area resizes to the snapped visible height on release (a peek stop, a quarter of the sheet or less, keeps the full height and slides instead), Dialog-aligned dismissal purpose (info/form/required), purpose-gated swipe-to-dismiss, fully-expanded Tall visual-viewport mobile-keyboard handling, named height scale, Dialog-like container padding (padding prop, theme bottom-sheet padding, default --spacing-4), modal (default) or non-modal (hasScrim={false}) presentation',usage: {anatomy,description:diff --git a/packages/core/src/BottomSheet/BottomSheet.tsx b/packages/core/src/BottomSheet/BottomSheet.tsxindex f6996e6d09..7a595de25b 100644--- a/packages/core/src/BottomSheet/BottomSheet.tsx+++ b/packages/core/src/BottomSheet/BottomSheet.tsx@@ -146,10 +146,11 @@ interface BottomSheetSharedProps extends BaseProps<HTMLDivElement> {/*** Internal padding of the sheet content using the spacing scale, matching* Dialog. Accepts numeric spacing steps: 0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10.- * When omitted, uses the theme default for bottom sheets: no padding unless- * the theme sets `padding` on `bottom-sheet`. The content box is a- * container: a Section that is its only child escapes the padding, and bleed- * children such as Table and Divider compensate against it.+ * When omitted, uses the theme default for bottom sheets (`--spacing-4`+ * unless the theme sets `padding` on `bottom-sheet`), matching Dialog. The+ * content box is a container: a Section that is its only child escapes the+ * padding, and bleed children such as Table and Divider compensate against+ * it. Pass `0` for content that supplies its own inset.*/padding?: SpacingStep;diff --git a/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx b/packages/core/src/BottomSheet/BottomSheetPanel.test.tsxindex d16577122d..197b9e8e05 100644--- a/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx+++ b/packages/core/src/BottomSheet/BottomSheetPanel.test.tsx@@ -432,7 +432,7 @@ describe('BottomSheetPanel', () => {return getComputedStyle(screen.getByTestId('sheet-child').parentElement!);}- it('keeps the released unpadded default and publishes the theme chain', () => {+ it("pads by Dialog's default chain and publishes the inset it applies", () => {const computed = renderWithPadding();for (const [edge, property] of EDGES) {const published = computed@@ -441,10 +441,8 @@ describe('BottomSheetPanel', () => {expect(published, edge).toContain(`var(--astryx-bottom-sheet-padding-${edge}`,);- // No theme padding resolves to no inset, as before the sheet was a- // container.expect(published, edge).toContain(- 'var(--astryx-bottom-sheet-padding,0px)',+ 'var(--astryx-bottom-sheet-padding,var(--spacing-4))',);// Applied padding reads the published value, so bleed children// subtract exactly the inset they sit in.@@ -452,17 +450,16 @@ describe('BottomSheetPanel', () => {`var(--container-padding-${edge})`,);}- // The Layout insets have no terminal value: unthemed, they stay invalid- // and a Layout inside the sheet keeps its own default padding.for (const name of ['--layout-padding-outer-x','--layout-padding-outer-y','--layout-padding-inner-x','--layout-padding-inner-y',]) {- const value = computed.getPropertyValue(name).replace(/\s+/g, '');- expect(value, name).toContain('var(--astryx-bottom-sheet-padding)');- expect(value, name).not.toMatch(/0px|--spacing-/);+ expect(+ computed.getPropertyValue(name).replace(/\s+/g, ''),+ name,+ ).toContain('var(--astryx-bottom-sheet-padding,var(--spacing-4))');}});diff --git a/packages/core/src/BottomSheet/BottomSheetPanel.tsx b/packages/core/src/BottomSheet/BottomSheetPanel.tsxindex ce92cb8b32..fd08cb5bc7 100644--- a/packages/core/src/BottomSheet/BottomSheetPanel.tsx+++ b/packages/core/src/BottomSheet/BottomSheetPanel.tsx@@ -256,7 +256,6 @@ const styles = stylex.create({// observed box grow with async content beyond a fixed-height viewport.// This box is also the sheet's container: it carries the padding and// publishes it, so a lone Section child escapes it exactly as in Dialog.- // Unpadded unless the prop or the theme sets padding.display: 'flow-root',boxSizing: 'border-box',height: '100%',@@ -303,7 +302,7 @@ interface BottomSheetPanelProps extends BaseProps<HTMLDivElement> {children: ReactNode;/*** Content padding on the spacing scale. Omitted, the content box reads the- * theme's bottom-sheet padding, else none (the released default).+ * theme's bottom-sheet padding, then --spacing-4 (Dialog's default).*/padding?: SpacingStep;snapPoints?: ReadonlyArray<BottomSheetSnapPoint>;@@ -627,7 +626,7 @@ export function BottomSheetPanel({}, [motion]);// Same lowering as Dialog: with no padding prop the content box reads the- // theme's --astryx-bottom-sheet-padding chain (no padding when unset), else+ // theme's --astryx-bottom-sheet-padding chain (--spacing-4 when unset), else// the explicit step.const usesThemePadding = padding == null;const effectivePadding = padding ?? 4;diff --git a/packages/core/src/DateInput/TouchDateField.tsx b/packages/core/src/DateInput/TouchDateField.tsxindex eba4404ae4..4781cebc15 100644--- a/packages/core/src/DateInput/TouchDateField.tsx+++ b/packages/core/src/DateInput/TouchDateField.tsx@@ -1296,7 +1296,9 @@ export function TouchDateField({label={t('@astryx.dateInput.dialogLabel')}// The picker is a fixed height by construction, so the sheet should be// exactly as tall as it is rather than claiming a viewport budget.- height="hug">+ height="hug"+ // sheetBody owns the inset, including the band under the grab handle.+ padding={0}><div {...stylex.props(styles.sheetBody)}>{surface}</div></BottomSheet>{showsDisabledMessage &&diff --git a/packages/core/src/DateTimeInput/TouchDateTimeField.tsx b/packages/core/src/DateTimeInput/TouchDateTimeField.tsxindex 54bc6b1aea..ded6ad91aa 100644--- a/packages/core/src/DateTimeInput/TouchDateTimeField.tsx+++ b/packages/core/src/DateTimeInput/TouchDateTimeField.tsx@@ -1478,7 +1478,10 @@ export function TouchDateTimeField({isOpen={isSheetOpen}onOpenChange={handleSheetOpenChange}label={t('@astryx.dateTimeInput.dialogLabel')}- height="hug">+ height="hug"+ // touchSheetBody owns the inset, including the band under the grab+ // handle.+ padding={0}><div {...stylex.props(styles.touchSheetBody)}>{surface}</div></BottomSheet>{showsDisabledMessage &&diff --git a/packages/core/src/Layout/container.stylex.ts b/packages/core/src/Layout/container.stylex.tsindex 011092f0b3..58963ec75a 100644--- a/packages/core/src/Layout/container.stylex.ts+++ b/packages/core/src/Layout/container.stylex.ts@@ -19,10 +19,8 @@* --astryx-card-padding-block-end** Read order per level: `var(--astryx-…, <next level>)`, terminating at- * `--spacing-4`. Same pattern for section, dialog, and the Lab drawer.- * Bottom-sheet keeps its released unpadded default: its edges terminate at 0px- * and its Layout insets at no value, so an unthemed sheet changes nothing for- * descendants.+ * `--spacing-4`. Same pattern for section, dialog, bottom-sheet, and the Lab+ * drawer.** ```ts* components: {@@ -141,19 +139,11 @@ const dialogInlineEnd = `var(--astryx-dialog-padding-inline-end, ${dialogInline}const dialogBlockStart = `var(--astryx-dialog-padding-block-start, ${dialogShorthand})`;const dialogBlockEnd = `var(--astryx-dialog-padding-block-end, ${dialogShorthand})`;-// Bottom sheet padding chains: --astryx-* then the next specificity level.-// Unlike card/section/dialog, the sheet's released default is no padding, so-// the edge chains terminate at 0px. The Layout inset chains have NO terminal-// value: with no theme padding they are invalid at computed-value time, which-// leaves the overlay reset in force and lets a Layout inside the sheet fall-// back to its own default, exactly as before the sheet was a container. Built-// as chained const strings (no function calls) so StyleX can statically-// analyze them; see naming.ts for the prefix policy.-const bottomSheetThemeShorthand = 'var(--astryx-bottom-sheet-padding)';-const bottomSheetThemeInline = `var(--astryx-bottom-sheet-padding-inline, ${bottomSheetThemeShorthand})`;-const bottomSheetThemeInlineStart = `var(--astryx-bottom-sheet-padding-inline-start, ${bottomSheetThemeInline})`;-const bottomSheetThemeBlockStart = `var(--astryx-bottom-sheet-padding-block-start, ${bottomSheetThemeShorthand})`;-const bottomSheetShorthand = 'var(--astryx-bottom-sheet-padding, 0px)';+// Bottom sheet padding chains: --astryx-* then the next specificity level,+// terminating at --spacing-4 like Dialog. Built as chained const strings (no+// function calls) so StyleX can statically analyze them; see naming.ts for the+// prefix policy.+const bottomSheetShorthand = `var(--astryx-bottom-sheet-padding, ${SP4})`;const bottomSheetInline = `var(--astryx-bottom-sheet-padding-inline, ${bottomSheetShorthand})`;const bottomSheetInlineStart = `var(--astryx-bottom-sheet-padding-inline-start, ${bottomSheetInline})`;const bottomSheetInlineEnd = `var(--astryx-bottom-sheet-padding-inline-end, ${bottomSheetInline})`;@@ -266,16 +256,16 @@ const bottomSheetDefaultPaddingStyles = stylex.create({'--container-padding-block-end': bottomSheetBlockEnd,},layoutPaddingOuterX: {- '--layout-padding-outer-x': bottomSheetThemeInlineStart,+ '--layout-padding-outer-x': bottomSheetInlineStart,},layoutPaddingOuterY: {- '--layout-padding-outer-y': bottomSheetThemeBlockStart,+ '--layout-padding-outer-y': bottomSheetBlockStart,},layoutPaddingInnerX: {- '--layout-padding-inner-x': bottomSheetThemeInlineStart,+ '--layout-padding-inner-x': bottomSheetInlineStart,},layoutPaddingInnerY: {- '--layout-padding-inner-y': bottomSheetThemeBlockStart,+ '--layout-padding-inner-y': bottomSheetBlockStart,},});diff --git a/packages/core/src/TimeInput/TouchTimeField.tsx b/packages/core/src/TimeInput/TouchTimeField.tsxindex 6570b0cc3f..7e858ef983 100644--- a/packages/core/src/TimeInput/TouchTimeField.tsx+++ b/packages/core/src/TimeInput/TouchTimeField.tsx@@ -506,7 +506,9 @@ export function TouchTimeField({isOpen={isSheetOpen}onOpenChange={setIsSheetOpen}label={label}- height="hug">+ height="hug"+ // sheetBody owns the inset, including the band under the grab handle.+ padding={0}><div {...stylex.props(styles.sheetBody)}><div {...stylex.props(styles.wheels)}><Wheeldiff --git a/packages/lab/src/MobileTokenizer/MobileTokenizer.tsx b/packages/lab/src/MobileTokenizer/MobileTokenizer.tsxindex e55d1d0cf6..af0d26561f 100644--- a/packages/lab/src/MobileTokenizer/MobileTokenizer.tsx+++ b/packages/lab/src/MobileTokenizer/MobileTokenizer.tsx@@ -399,7 +399,7 @@ export function MobileTokenizer<T extends SearchableItem>({<BottomSheetSwitcheractiveSheet={activeSheet}onActiveSheetChange={id => setActiveSheet(id as SheetId | null)}>- <BottomSheet sheetId="manage" label={label} height="tall">+ <BottomSheet sheetId="manage" label={label} height="tall" padding={0}><div {...stylex.props(styles.sheetBody)}><div {...stylex.props(styles.filterRow)}><TextInput