Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

chore(Tokenizer): docs examples, blocks and templates follow the adaptive default (#9883)

Xinzi Zhouda771b3e556f
diff --git a/.changeset/tokenizer-presentation-template-default.md b/.changeset/tokenizer-presentation-template-default.md
new file mode 100644
index 0000000000..b83e3daf17
--- /dev/null
+++ b/.changeset/tokenizer-presentation-template-default.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/cli': patch
+---
+
+[chore] The Tokenizer blocks and the table-inbox and work-item-detail page templates follow Tokenizer's `'adaptive'` default, so on a compact touch screen they show the bottom sheet. Their `endContent` and `renderToken` work there as in the inline field; `hasClear` and the overflow modes apply to the inline field, and the Clear and Overflow blocks say so. The rule: docs examples follow `adaptive`; the stories that are fixtures for inline-field geometry (Caret placement, Logical order, RTL end lane, Long token beside the end lane) keep `presentation="popover"`. The table-inbox and work-item-detail back arrows mirror in right-to-left.
+
+@imdreamrunner
diff --git a/apps/docsite/scripts/generate-scope.mjs b/apps/docsite/scripts/generate-scope.mjs
index 1920dee461..87f62189b9 100644
--- a/apps/docsite/scripts/generate-scope.mjs
+++ b/apps/docsite/scripts/generate-scope.mjs
@@ -294,6 +294,12 @@ lines.push('');
lines.push("import * as Hooks from '@astryxdesign/core/hooks';");
lines.push('');
+// ── Utils ──────────────────────────────────────────────────────────────
+// camelCase too, and skipped for the same reason. Page templates mirror their
+// directional icons in right-to-left with `rtlStyles` from here.
+lines.push("import * as Utils from '@astryxdesign/core/utils';");
+lines.push('');
+
// ── Icon and chart libraries ───────────────────────────────────────────
lines.push("import * as LucideIcons from 'lucide-react';");
lines.push("import * as Recharts from 'recharts';");
@@ -402,6 +408,9 @@ lines.push(" '@astryxdesign/core/theme/tokens.stylex': astryxTokens,");
// hooks (useMediaQuery, etc.)
lines.push(" '@astryxdesign/core/hooks': Hooks,");
+// utils (rtlStyles, etc.)
+lines.push(" '@astryxdesign/core/utils': Utils,");
+
// Per-component and nested-module subpath entries
for (const name of components) {
lines.push(` '@astryxdesign/core/${name}': ${name},`);
diff --git a/apps/storybook/stories/Tokenizer.stories.tsx b/apps/storybook/stories/Tokenizer.stories.tsx
index ade7221ca4..a4923d2900 100644
--- a/apps/storybook/stories/Tokenizer.stories.tsx
+++ b/apps/storybook/stories/Tokenizer.stories.tsx
@@ -139,12 +139,12 @@ export const WithPreselected: Story = {
name: 'Pre-selected Items',
};
+/** On touch screens, clear through the sheet's Clear all. */
export const WithClear: Story = {
...Default,
args: {
...Default.args,
hasClear: true,
- presentation: 'popover',
},
name: 'With Clear All Button',
};
@@ -254,7 +254,6 @@ export const WithEntriesOnFocus: Story = {
value={value}
onChange={items => setValue(items)}
hasEntriesOnFocus
- presentation="popover"
/>
);
},
@@ -265,6 +264,7 @@ export const WithEntriesOnFocus: Story = {
name: 'With Entries On Focus',
};
+/** Overflow modes apply to the inline field. */
export const OverflowInline: Story = {
render: args => {
const [value, setValue] = useState<SearchableItem[]>([
@@ -283,7 +283,6 @@ export const OverflowInline: Story = {
value={value}
onChange={items => setValue(items)}
tokenOverflowBehavior="unfocusedInline"
- presentation="popover"
/>
<p style={{marginTop: 8}}>
This text will shift down when the tokenizer expands on focus.
@@ -298,6 +297,7 @@ export const OverflowInline: Story = {
name: 'Overflow Inline',
};
+/** Overflow modes apply to the inline field. */
export const OverflowLayer: Story = {
render: args => {
const [value, setValue] = useState<SearchableItem[]>([
@@ -316,7 +316,6 @@ export const OverflowLayer: Story = {
value={value}
onChange={items => setValue(items)}
tokenOverflowBehavior="unfocusedLayer"
- presentation="popover"
/>
<p style={{marginTop: 8}}>
This text should not shift when the tokenizer expands on focus.
@@ -341,7 +340,6 @@ export const WithEndContent: Story = {
value={value}
onChange={items => setValue(items)}
endContent={<Button label="Apply" variant="primary" size="sm" />}
- presentation="popover"
/>
);
},
@@ -404,7 +402,6 @@ export const SizeVariants: Story = {
placeholder="Small size"
size="sm"
hasClear
- presentation="popover"
/>
<Tokenizer
label="Medium (32px)"
@@ -414,7 +411,6 @@ export const SizeVariants: Story = {
placeholder="Medium size (default)"
size="md"
hasClear
- presentation="popover"
/>
<Tokenizer
label="Large (36px)"
@@ -424,7 +420,6 @@ export const SizeVariants: Story = {
placeholder="Large size"
size="lg"
hasClear
- presentation="popover"
/>
</div>
);
@@ -445,7 +440,6 @@ export const CreatableWithSearch: Story = {
hasCreate
hasEntriesOnFocus
placeholder="Search or type a new name..."
- presentation="popover"
/>
);
},
@@ -516,7 +510,6 @@ export const Loading: Story = {
onChange={items => setValue(items)}
hasClear
endContent={<span>{value.length} selected</span>}
- presentation="popover"
/>
);
},
@@ -548,6 +541,8 @@ export const LogicalOrder: Story = {
label: 'Team Members',
placeholder: 'Add more...',
hasClear: true,
+ // A fixture for the inline field's end lane and caret, so it keeps the
+ // inline field on every device.
presentation: 'popover',
},
name: 'Logical order',
@@ -570,6 +565,8 @@ export const RtlEndLane: Story = {
value={[users[0]]}
onChange={() => {}}
hasClear
+ // A fixture for the inline field's end lane: the inline field on every
+ // device.
presentation="popover"
/>
),
@@ -599,6 +596,8 @@ export const LongTokenEndLane: Story = {
value={[longToken]}
onChange={() => {}}
hasClear
+ // A fixture for the inline field's end lane: the inline field on every
+ // device.
presentation="popover"
/>
<Tokenizer
@@ -657,6 +656,8 @@ export const CaretPlacement: Story = {
label: 'Team Members',
placeholder: 'Add more...',
hasClear: true,
+ // A fixture for the inline field's end lane and caret, so it keeps the
+ // inline field on every device.
presentation: 'popover',
},
name: 'Caret placement',
@@ -968,6 +969,19 @@ export const SheetPresentationEndContent: Story = {
parameters: {viewport: {defaultViewport: 'mobile2'}},
};
+/**
+ * `presentation="popover"`: the inline combobox with its anchored suggestion
+ * menu on every device, a compact coarse-pointer screen included.
+ */
+export const PopoverPresentation: Story = {
+ render: Default.render,
+ args: {
+ ...Default.args,
+ presentation: 'popover',
+ },
+ name: 'Popover (every device)',
+};
+
/**
* Disabled and at-limit states of the sheet presentation: the disabled
* trigger stays focusable and does not open; at `maxEntries` the sheet's
diff --git a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerClear.doc.mjs b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerClear.doc.mjs
index 2c10f629dc..f46a415894 100644
--- a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerClear.doc.mjs
+++ b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerClear.doc.mjs
@@ -6,7 +6,8 @@ export const doc = {
exampleFor: 'Tokenizer',
name: 'Tokenizer \u2014 Clear',
displayName: 'Tokenizer \u2014 Clear',
- description: 'Tokenizer with a built-in clear-all button for bulk removal of all selected tokens.',
+ description:
+ "Tokenizer with a built-in clear-all button for bulk removal of all selected tokens. On touch screens, clear through the sheet's Clear all.",
isReady: true,
aspectRatio: 16 / 9,
componentsUsed: ['Tokenizer', 'Layout', 'Text'],
diff --git a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx
index 4884c4417f..bf3a5c212f 100644
--- a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx
+++ b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx
@@ -29,7 +29,8 @@ export default function TokenizerClear() {
<div style={{display: 'grid', gridTemplateColumns: 'minmax(0, 400px)'}}>
<Stack direction="vertical" gap={2}>
<Text type="supporting" color="secondary">
- Clear-all button appears when tokens are selected
+ Clear-all button appears when tokens are selected; on touch screens,
+ clear through the sheet's Clear all
</Text>
<Tokenizer
label="Team Members"
@@ -38,7 +39,6 @@ export default function TokenizerClear() {
value={value}
onChange={items => setValue(items)}
hasClear
- presentation="popover"
/>
</Stack>
</div>
diff --git a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx
index d8d004a63d..42012ef16f 100644
--- a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx
+++ b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx
@@ -59,7 +59,6 @@ export default function TokenizerCreatable() {
hasCreate
hasEntriesOnFocus
placeholder="Search or type a new name..."
- presentation="popover"
/>
</Stack>
</Stack>
diff --git a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx
index a21ce0df4e..b4547edb77 100644
--- a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx
+++ b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx
@@ -40,7 +40,6 @@ export default function TokenizerEndContent() {
value={value}
onChange={items => setValue(items)}
endContent={<Button label="Apply" variant="primary" size="sm" />}
- presentation="popover"
/>
</Stack>
</div>
diff --git a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.doc.mjs b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.doc.mjs
index 0e12f065f9..8390d2e8f8 100644
--- a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.doc.mjs
+++ b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.doc.mjs
@@ -6,7 +6,8 @@ export const doc = {
exampleFor: 'Tokenizer',
name: 'Tokenizer \u2014 Overflow',
displayName: 'Tokenizer \u2014 Overflow',
- description: 'Tokenizer with overflow truncation when unfocused. Inline mode pushes content down on expand; layer mode overlays without shifting layout.',
+ description:
+ 'Tokenizer with overflow truncation when unfocused. Inline mode pushes content down on expand; layer mode overlays without shifting layout. Overflow modes apply to the inline field.',
isReady: true,
aspectRatio: 16 / 9,
componentsUsed: ['Tokenizer', 'Layout', 'Text'],
diff --git a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx
index bfaa5fb995..39291741bb 100644
--- a/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx
+++ b/packages/cli/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx
@@ -41,7 +41,6 @@ export default function TokenizerOverflow() {
value={inlineValue}
onChange={items => setInlineValue(items)}
tokenOverflowBehavior="unfocusedInline"
- presentation="popover"
/>
</Stack>
<Stack direction="vertical" gap={1}>
@@ -55,7 +54,6 @@ export default function TokenizerOverflow() {
value={layerValue}
onChange={items => setLayerValue(items)}
tokenOverflowBehavior="unfocusedLayer"
- presentation="popover"
/>
</Stack>
</Stack>
diff --git a/packages/cli/assets/templates/pages/table-inbox/page.tsx b/packages/cli/assets/templates/pages/table-inbox/page.tsx
index 822482978c..c654090620 100644
--- a/packages/cli/assets/templates/pages/table-inbox/page.tsx
+++ b/packages/cli/assets/templates/pages/table-inbox/page.tsx
@@ -82,6 +82,7 @@ import {
StackItem,
VStack,
} from '@astryxdesign/core/Layout';
+import {rtlStyles} from '@astryxdesign/core/utils';
import {
durationVars,
easeVars,
@@ -1391,7 +1392,13 @@ function ConversationPane({
<Button
label="Inbox"
variant="ghost"
- icon={<Icon icon={ArrowLeftIcon} size="sm" />}
+ icon={
+ <Icon
+ icon={ArrowLeftIcon}
+ size="sm"
+ xstyle={rtlStyles.mirror}
+ />
+ }
onClick={onClose}
/>
}
@@ -1840,7 +1847,9 @@ function ComposeWindow({
// than being rejected for not matching anything.
hasCreate
// Stamps data-autofocus, which is what the sheet looks for
- // once the window is actually visible.
+ // once the window is actually visible. It applies to the
+ // inline field: on a compact touch screen the field opens
+ // its own sheet and ignores it.
//
// Deliberately without `hasEntriesOnFocus`: the two together
// mean the window can never open without the full directory
@@ -1874,10 +1883,6 @@ function ComposeWindow({
)}
</>
}
- // The recipient rows read as one header, so all three stay
- // inline fields on every device; the sheet has no end lane
- // for the Cc and Bcc buttons.
- presentation="popover"
/>
{hasCc ? (
<Tokenizer
@@ -1888,7 +1893,6 @@ function ComposeWindow({
value={cc}
onChange={items => setCc(items)}
hasCreate
- presentation="popover"
/>
) : null}
{hasBcc ? (
@@ -1900,7 +1904,6 @@ function ComposeWindow({
value={bcc}
onChange={items => setBcc(items)}
hasCreate
- presentation="popover"
/>
) : null}
<TextInput
diff --git a/packages/cli/assets/templates/pages/work-item-detail/page.tsx b/packages/cli/assets/templates/pages/work-item-detail/page.tsx
index 21f00ff4d5..baa0b80dca 100644
--- a/packages/cli/assets/templates/pages/work-item-detail/page.tsx
+++ b/packages/cli/assets/templates/pages/work-item-detail/page.tsx
@@ -29,6 +29,7 @@ import {MoreMenu} from '@astryxdesign/core/MoreMenu';
import type {DropdownMenuOption} from '@astryxdesign/core/DropdownMenu';
import {Link} from '@astryxdesign/core/Link';
import {Icon} from '@astryxdesign/core/Icon';
+import {rtlStyles} from '@astryxdesign/core/utils';
import {AspectRatio} from '@astryxdesign/core/AspectRatio';
import {Divider} from '@astryxdesign/core/Divider';
import {StatusDot} from '@astryxdesign/core/StatusDot';
@@ -381,7 +382,11 @@ function PageHeader({
<HStack gap={4} vAlign="center" wrap="wrap">
<Link href="#" type="supporting" color="secondary">
<HStack as="span" gap={1} vAlign="center">
- <Icon icon={ArrowLeftIcon} size="sm" />
+ <Icon
+ icon={ArrowLeftIcon}
+ size="sm"
+ xstyle={rtlStyles.mirror}
+ />
All Tasks
</HStack>
</Link>
@@ -463,7 +468,6 @@ function PageHeader({
onRemove={onRemove}
/>
)}
- presentation="popover"
/>
</HStack>
</VStack>
diff --git a/packages/core/src/Field/__tests__/SearchKeyboard.interaction.browser.spec.ts b/packages/core/src/Field/__tests__/SearchKeyboard.interaction.browser.spec.ts
index 042b8d91b0..701ed17474 100644
--- a/packages/core/src/Field/__tests__/SearchKeyboard.interaction.browser.spec.ts
+++ b/packages/core/src/Field/__tests__/SearchKeyboard.interaction.browser.spec.ts
@@ -47,8 +47,8 @@ test('a tap on Typeahead focuses a field that asks for the Search key and no aut
test('a tap on the inline Tokenizer focuses a field that asks for the Search key and no autocorrection', async ({
page,
}) => {
- // The story pins `presentation="popover"`, so the phone keeps the inline field.
- await openStory(page, storybook(), 'core-tokenizer--with-end-content');
+ // `presentation="popover"` keeps the inline field on the phone.
+ await openStory(page, storybook(), 'core-tokenizer--popover-presentation');
await expectSearchKeyboard(page.getByRole('combobox'));
});