Repository navigation
feat(Tokenizer): the touch sheet presentation is public behind experimental.presentation, and the sheet edits a draft that Save commits - #9708
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
/approve-spec 3bf4a5b |
|
@astracat-bot review |
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Thanks for bringing the touch sheet back to the public Tokenizer. Callers who omit experimental are unaffected. A few things need to change before this can merge:
- The Tokenizer component record is not part of this change and still holds the exposure: DEC-4 says the DEC-3 hold-back stands until the implementation matches. DEC-3, Public concepts and the FR16–FR27 statuses still say the option is not exposed, and
verified_bystill lists the deleted internal test. Please commit the record edit your description lists, and have an engineering owner approve the new head. Tokenizer.ssr.test.tsxline 23 still imports the deleted../internal/tokenizer-presentation.TokenizerBottomSheet.test.tsxlines 2632, 2668, 2684 and 2699 still renderTokenizerWithPresentation. As a result, Core's typecheck fails and two Tokenizer test files fail on this commit.- The description says the record's gap notes and DEC-4's hold-back sentence are removed and that the Tokenizer suite passes 239 tests. Neither is true of the pushed commit, so please push the missing changes or correct the description.
Pointing those five test lines at ./Tokenizer and <Tokenizer should be all the test fix needs. There is one optional inline suggestion on the wording of the overload comment.
[Automated review]
| // The experimental arm first: TypeScript resolves `ComponentProps<typeof | ||
| // Tokenizer>` and a call without `experimental` against the last overload, the | ||
| // stable signature, while a call that passes `experimental` matches this one | ||
| // and may pass the wider `ref`. |
There was a problem hiding this comment.
Optional wording (non-blocking): this is one 31-word sentence with two topics. A shorter version that keeps only the reason:
// Keep this overload first. TypeScript resolves `ComponentProps<typeof
// Tokenizer>` against the last overload, so that type stays the stable props.
// A call that passes `experimental` matches this overload and can pass the
// wider `ref`.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/MobilePowerSearch · Storybook | 169.1 kB (+304 B) · 1.2 kB CSS (−13 B) | 3,169 (+8) | — · ✓ · ✗ |
| Field | 41.4 kB (0) · 8.3 kB CSS (0) | — | ✗ · ✓ · — |
| FieldLabel | 36.0 kB (0) · 5.9 kB CSS (0) | — | ✗ · ✓ · — |
7 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/MobileTokenizer · Storybook | 100.9 kB (+47 B) · 880 B CSS (0) | 1,060 (−26) | — · ✓ · ✓ |
| Tokenizer · Storybook | 70.2 kB (+36 B) · 17.1 kB CSS (0) | 2,111 (+109) | ✓ · ✓ · ✓ |
| richtext/RichTextEditorToolbar | 221.7 kB (+26 B) · 454 B CSS (0) | — | — · — · — |
| Pagination | 85.9 kB (+25 B) · 16.0 kB CSS (0) | — | — · — · — |
| Selector | 76.9 kB (+24 B) · 15.7 kB CSS (0) | — | — · — · — |
| MultiSelector | 72.7 kB (+12 B) · 15.2 kB CSS (0) | — | — · — · — |
| PowerSearch | 184.0 kB (−9 B) · 20.6 kB CSS (0) | — | — · — · — |
Visual changes: 2 snapshots in 1 component
A change is a question for the reviewer, not a failure.
| Component · story | Before | After | Diff |
|---|---|---|---|
| Field · Default (neutral, light) | ![]() |
![]() |
![]() |
| Field · Default (neutral, dark) | ![]() |
![]() |
![]() |
Package size: @astryxdesign/core 6.04 MB packed (+8.6 kB); no new dependencies.
API changes: core +47 · ~3 · −0
Committed API report behind this build: core 50 rows; run pnpm api:report.
50 API changes (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Components · component Tokenizer |
prop experimental: NonNullable<TokenizerProps<T>['experimental']> @experimental |
<Tokenizer experimental="experimental" /> |
| + | core |
. · Types · interface TokenizerProps |
containerClassName?: string |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {containerClassName: …} |
| + | core |
. · Types · interface TokenizerProps |
containerStyle?: CSSProperties |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {containerStyle: …} |
| + | core |
. · Types · interface TokenizerProps |
containerXstyle?: StyleXStyles |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {containerXstyle: …} |
| + | core |
. · Types · interface TokenizerProps |
controlClassName?: string |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {controlClassName: …} |
| + | core |
. · Types · interface TokenizerProps |
controlStyle?: CSSProperties |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {controlStyle: …} |
| + | core |
. · Types · interface TokenizerProps |
controlXstyle?: StyleXStyles |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {controlXstyle: …} |
| + | core |
. · Types · interface TokenizerProps |
debounceMs?: number = 150 |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {debounceMs: …} |
| + | core |
. · Types · interface TokenizerProps |
description?: string |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {description: …} |
| + | core |
. · Types · interface TokenizerProps |
disabledMessage?: string |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {disabledMessage: …} |
| + | core |
. · Types · interface TokenizerProps |
emptySearchText?: ReactNode = 'No results found' |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {emptySearchText: …} |
| + | core |
. · Types · interface TokenizerProps |
endContent?: ReactNode |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {endContent: …} |
| + | core |
. · Types · interface TokenizerProps |
experimental?: { presentation?: 'popover' | 'bottom-sheet' | 'adaptive' } @experimental |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {experimental: …} |
| + | core |
. · Types · interface TokenizerProps |
handleRef?: React.Ref<TokenizerHandle> |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {handleRef: …} |
| + | core |
. · Types · interface TokenizerProps |
hasAutoFocus?: boolean = false |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {hasAutoFocus: …} |
| + | core |
. · Types · interface TokenizerProps |
hasClear?: boolean = false |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {hasClear: …} |
| + | core |
. · Types · interface TokenizerProps |
hasCreate?: boolean = false |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {hasCreate: …} |
| + | core |
. · Types · interface TokenizerProps |
hasEntriesOnFocus?: boolean = false |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {hasEntriesOnFocus: …} |
| + | core |
. · Types · interface TokenizerProps |
htmlName?: string |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {htmlName: …} |
| + | core |
. · Types · interface TokenizerProps |
isDisabled?: boolean = false |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {isDisabled: …} |
| + | core |
. · Types · interface TokenizerProps |
isLabelHidden?: boolean = false |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {isLabelHidden: …} |
| + | core |
. · Types · interface TokenizerProps |
isOptional?: boolean = false |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {isOptional: …} |
| + | core |
. · Types · interface TokenizerProps |
isRequired?: boolean = false |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {isRequired: …} |
| + | core |
. · Types · interface TokenizerProps |
label: string |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {label: …} |
| + | core |
. · Types · interface TokenizerProps |
labelTooltip?: string |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {labelTooltip: …} |
| + | core |
. · Types · interface TokenizerProps |
maxEntries?: number |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {maxEntries: …} |
| + | core |
. · Types · interface TokenizerProps |
maxMenuItems?: number = 10 |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {maxMenuItems: …} |
| + | core |
. · Types · interface TokenizerProps |
menuWidth?: number |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {menuWidth: …} |
| + | core |
. · Types · interface TokenizerProps |
minQueryLength?: number = 1 |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {minQueryLength: …} |
| + | core |
. · Types · interface TokenizerProps |
onBlur?: (e: React.FocusEvent) => void |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {onBlur: …} |
| + | core |
. · Types · interface TokenizerProps |
onChange: (items: T[], change: TokenizerChange<T>) => void |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {onChange: …} |
| + | core |
. · Types · interface TokenizerProps |
onChangeQuery?: (query: string) => void |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {onChangeQuery: …} |
| + | core |
. · Types · interface TokenizerProps |
onFocus?: (e: React.FocusEvent) => void |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {onFocus: …} |
| + | core |
. · Types · interface TokenizerProps |
onKeyDown?: React.KeyboardEventHandler<HTMLElement> |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {onKeyDown: …} |
| + | core |
. · Types · interface TokenizerProps |
placeholder?: string |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {placeholder: …} |
| + | core |
. · Types · interface TokenizerProps |
ref?: React.Ref<HTMLInputElement> |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {ref: …} |
| + | core |
. · Types · interface TokenizerProps |
renderItem?: (item: T) => ReactNode |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {renderItem: …} |
| + | core |
. · Types · interface TokenizerProps |
renderToken?: (item: T, onRemove: () => void) => ReactNode |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {renderToken: …} |
| + | core |
. · Types · interface TokenizerProps |
searchSource: SearchSource<T> |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {searchSource: …} |
| + | core |
. · Types · interface TokenizerProps |
size?: TokenizerSize = 'md' |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {size: …} |
| + | core |
. · Types · interface TokenizerProps |
startIcon?: ReactNode | IconType |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {startIcon: …} |
| + | core |
. · Types · interface TokenizerProps |
status?: InputStatus |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {status: …} |
| + | core |
. · Types · interface TokenizerProps |
statusVariant?: FieldStatusPlacement = 'attached' |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {statusVariant: …} |
| + | core |
. · Types · interface TokenizerProps |
tokenOverflowBehavior?: TokenizerOverflowBehavior = 'none' |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {tokenOverflowBehavior: …} |
| + | core |
. · Types · interface TokenizerProps |
value: T[] |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {value: …} |
| + | core |
. · Types · interface TokenizerProps |
width?: SizeValue |
import type {TokenizerProps} from '@astryxdesign/core'; const x: TokenizerProps = {width: …} |
| + | core |
. · Types · interface TokenizerProps |
inherits AriaAttributes, DOMAttributes, HTMLAttributes |
import type {TokenizerProps} from '@astryxdesign/core' |
| ~ | core |
. · Components · component Tokenizer |
component Tokenizer(props: TokenizerProps) → component Tokenizer(props: TokenizerExperimentalProps) |
<Tokenizer /> |
| ~ | core |
. · Components · component Tokenizer |
prop ref?: React.Ref<HTMLInputElement> → prop ref?: React.Ref<HTMLInputElement | HTMLButtonElement> @experimental |
<Tokenizer ref={…} /> |
| ~ | core |
. · Types · interface TokenizerProps |
interface TokenizerProps<T extends SearchableItem> extends Omit<FieldInputBaseProps<HTMLInputElement>, 'onChange' | 'onFocus' | 'onBlur' | 'onKeyDown'> (props of Tokenizer) → interface TokenizerProps<T extends SearchableItem> extends Omit<FieldInputBaseProps<HTMLInputElement>, 'onChange' | 'onFocus' | 'onBlur' | 'onKeyDown'> |
import type {TokenizerProps} from '@astryxdesign/core' |
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
3bf4a5b to
f40f945
Compare
|
/approve-spec f40f945 |
There was a problem hiding this comment.
Thanks for restoring the touch sheet behind experimental.presentation. The record edit, the owner approval and the test fixes are all in place now, and callers who omit experimental are unaffected. One thing needs to change before this can merge:
- The changeset (
.changeset/tokenizer-experimental-bottom-sheet.md) announces "New@astryx.tokenizer.*catalog keys", which already shipped in 0.7.5, and says the exportedTokenizerPropsinterface is unchanged although this PR addsexperimental?to it, so please drop or reword the catalog sentence and say instead thatTokenizerPropskeeps its releasedreftype and gains only the optionalexperimental(the same parenthetical is inTokenizer.doc.mjs).
Two optional follow-ups: the API report generator reads a component's first overload, so a regenerated core report would show experimental as required and the stable ref as experimental; and the TokenizerExperimentalProps comment could use shorter sentences (inline suggestion).
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [experimental] Tokenizer gains a touch surface behind `experimental={{presentation: 'bottom-sheet' | 'adaptive'}}`. `bottom-sheet` replaces the inline combobox with a trigger that shows the selected tokens and opens one tall modal sheet: a search row on top, full-width checkbox rows that keep their place while the sheet is open and regroup selected-first on the next open, 50-row progressive rendering for long lists, a `Create "…"` row with a trailing Add action under `hasCreate`, and a footer with a confirmed Clear all and Done. `adaptive` uses the sheet on compact coarse-pointer screens and the popover otherwise, resolved the same way Selector resolves it. The sheet surface loads on demand, so a Tokenizer that does not opt in does not carry it. The trigger describes its selected tokens to assistive technology, announcements made while the sheet is open reach assistive technology through a live region inside the sheet, with `experimental` passed the component also accepts a `Ref<HTMLInputElement | HTMLButtonElement>` because `ref` reaches the trigger in the sheet presentation (the exported `TokenizerProps` interface is unchanged), and in development the field warns once about props that have no surface in the sheet presentation (`renderItem`, `renderToken`, `endContent`, `hasClear`, `hasEntriesOnFocus`, `menuWidth`, `tokenOverflowBehavior`, `hasAutoFocus`). New `@astryx.tokenizer.*` catalog keys for the sheet's strings; the sheet's parts expose no theming targets while the option is experimental. Anything inside Tokenizer's `experimental` prop may change or be removed in a patch release; omitting it keeps the stable behavior. |
There was a problem hiding this comment.
Two statements here no longer match what ships. The @astryx.tokenizer.* sheet keys are already in packages/core/locales/en.json on main and went out in 0.7.5, and this PR adds none. TokenizerProps does change: it gains experimental? (Tokenizer.tsx line 338). Suggested wording: drop "New @astryx.tokenizer.* catalog keys for the sheet's strings;" (or say the sheet uses the existing keys), and replace the parenthetical with "(TokenizerProps keeps its released ref type and gains only the optional experimental)". The same parenthetical is in Tokenizer.doc.mjs, in both the English and the Chinese entries.
| * The props the experimental opt-in admits: `TokenizerProps` with | ||
| * `experimental` present and a `ref` that also accepts the sheet | ||
| * presentation's trigger button, the control it stands for there. Reached | ||
| * only through the overload below; `TokenizerProps` — an interface, so | ||
| * `interface X extends TokenizerProps<T>`, `Omit<TokenizerProps<T>, …>` and | ||
| * `ComponentProps<typeof Tokenizer>` keep their released shapes — stays the | ||
| * component's declared props type. |
There was a problem hiding this comment.
Optional (comment style): this block has a 27-word sentence, then a 30-word one with a dashed aside. Suggested:
/**
* The props of the first overload: `TokenizerProps` with `experimental`
* required and a `ref` that also takes the sheet's trigger button.
* `TokenizerProps` stays the declared props type, so `extends`, `Omit` and
* `ComponentProps<typeof Tokenizer>` keep their released shapes.
*/f40f945 to
3d61b04
Compare
|
/approve-spec 3d61b04 |
3d61b04 to
2f84788
Compare
|
/approve-spec 2f84788 |
There was a problem hiding this comment.
Changes requested. Callers who omit experimental are unaffected and an engineering owner approved the record edit, but five things need fixing first:
- Unchecking and re-checking a row makes Escape, scrim or swipe ask "Discard changes?" for a draft that Save treats as unchanged, because
hasSameSelectioninTokenizerBottomSheet.tsxcompares ids by position; compare them as a set and add that case to the FR27 test. SheetConfirmation.tsxanduseDismissSearchOnTouchDrag.tscopy Lab modules that MobileTokenizer and MobilePowerSearch keep using (the Lab drag hook already drops focus to the page body), so please make the Core modules the one owner, reached from Lab through a Core./internal/*subpath, and delete the Lab copies.- The sheet's bordered search field re-declares the shared input box from
Field/inputStyles.stylex.tswithout its forced-colors branch, so under forced colors its border does not change on focus; compose the shared style instead. - The consumer docs (
Tokenizer.doc.mjsin English and Chinese), thepresentationJSDoc and the bottom-sheet story comment still say the sheet closes with Done and never say thatonChangefires once, on Save. - DEC-3's element-count exception still gives the forced bottom-sheet presentation 165 elements open at "e", the figure without the pinned footer's 9 elements.
The changeset now matches what ships. Optional: the API report generator reads a component's first overload, and two new comments could be shorter (inline suggestions).
[Automated review]
| function hasSameSelection<T extends SearchableItem>(a: T[], b: T[]): boolean { | ||
| return ( | ||
| a.length === b.length && a.every((item, index) => item.id === b[index]?.id) | ||
| ); | ||
| } |
There was a problem hiding this comment.
This compares ids by position, and a re-checked row is appended to the draft, so unchecking and re-checking a row makes Escape, scrim or swipe open "Discard changes?" while Save reports nothing. FR27 closes directly while the draft equals the selection at open. Compare as sets, as Lab's hasSameSelection does:
function hasSameSelection<T extends SearchableItem>(a: T[], b: T[]): boolean {
return (
a.length === b.length &&
a.every(item => b.some(candidate => candidate.id === item.id))
);
}| searchField: { | ||
| minHeight: 44, | ||
| paddingBlock: spacingVars['--spacing-2'], | ||
| minHeight: sizeVars['--size-element-lg'], | ||
| paddingBlock: spacingVars['--spacing-1'], | ||
| borderWidth: borderVars['--border-width'], | ||
| borderStyle: 'solid', | ||
| borderColor: { | ||
| default: colorVars['--color-border-emphasized'], | ||
| ':focus-within': colorVars['--color-accent'], | ||
| }, | ||
| borderRadius: radiusVars['--radius-element'], | ||
| backgroundColor: colorVars['--color-background-surface'], | ||
| transitionProperty: 'border-color, box-shadow', | ||
| }, |
There was a problem hiding this comment.
These declarations copy inputWrapperStyles.base from Field/inputStyles.stylex.ts without its @media (forced-colors: active) Highlight branch, so under forced colors this field's border does not change on focus. Compose the shared box style here and keep only the lg height and padding.
| action: {width: '100%'}, | ||
| }); | ||
|
|
||
| export function SheetConfirmation({ |
There was a problem hiding this comment.
This module, and useDismissSearchOnTouchDrag.ts, copy packages/lab/src/internal/MobileSheetConfirmation.tsx and useDismissSearchOnTouchDrag.ts, which Lab's MobileTokenizer and MobilePowerSearch keep using. Make these the one owner (Lab can reach them through a Core ./internal/* subpath) and delete the Lab copies.
| type: "{presentation?: 'popover' | 'bottom-sheet' | 'adaptive'}", | ||
| stability: 'experimental', | ||
| description: | ||
| "Experimental options: anything in this object may change or be removed in a patch release, and omitting it keeps the stable behavior. presentation (default 'popover') chooses how the field presents its choices. popover is the inline combobox with its anchored suggestion menu. bottom-sheet replaces it with a trigger showing the selected tokens that opens one tall modal sheet: a search row on top, full-width checkbox rows that keep their place while the sheet is open, a Create row with hasCreate, and a footer with a confirmed Clear all and Done. adaptive uses the bottom sheet on compact touch screens and the popover otherwise, resolved the same way Selector resolves it. In the sheet presentation the trigger is the control (ref, id, aria-* and data-* reach it; with experimental passed, ref also accepts a Ref<HTMLInputElement | HTMLButtonElement> — an input-only ref still type-checks against that wider type, but with adaptive or bottom-sheet it receives the trigger button at runtime, so type the ref for both elements; TokenizerProps keeps its released ref type and gains only the optional experimental), and renderItem, renderToken, endContent, hasClear, hasEntriesOnFocus, menuWidth, tokenOverflowBehavior and hasAutoFocus have no surface to act on; the field warns once in development when they are passed. For example: <Tokenizer label=\"Tags\" searchSource={tagSource} value={tags} onChange={setTags} hasCreate experimental={{presentation: 'adaptive'}} />.", |
There was a problem hiding this comment.
The sheet's footer now has Save, not Done, and onChange fires once when Save commits the draft. The Chinese entry (「完成」), the presentation JSDoc in Tokenizer.tsx and the story comment say Done too.
| when the implementation matches). The forced `bottom-sheet` presentation | ||
| pending Clear all confirmation adds 20 while it is open; the footer, pinned | ||
| in every state (FR18), adds 9, so the open coarse count at the query "e" is | ||
| 174 with it; the counts are re-measured when either surface changes. The forced `bottom-sheet` presentation | ||
| renders the same elements under either pointer (114 at rest, 165 open at "e", |
There was a problem hiding this comment.
165 open at "e" is the footer-less figure; the paragraph above adds the pinned footer's 9 to the adaptive count. In Chromium the forced story at "e" grows by those 9 elements on this head, so this should read 174 open at "e", its dialog 62.
| // Save reports the whole draft once, with the last edit that still holds | ||
| // as its change: the last toggle, create or clear when its item is in the | ||
| // draft and was not selected at open, or was selected at open and is gone; | ||
| // otherwise, after a removal, a `remove` naming an item that is gone; | ||
| // otherwise an `add` (`create` when the last edit created that item) naming | ||
| // an item that is new; otherwise a `remove` naming an item that is gone. |
There was a problem hiding this comment.
Non-blocking (INV29): this restates the branches below in one long sentence. Suggest: "Save names the last edit that still holds, else the nearest net add or remove."
2f84788 to
886b2d3
Compare
|
/approve-spec 886b2d3 |
There was a problem hiding this comment.
Changes requested. Callers who omit experimental are unaffected, an engineering owner approved the record edit at this head, and the five issues from the previous round are fixed. One thing still needs to change:
packages/core/src/Tokenizer/TokenizerBottomSheet.tsxlines 717–756 copyhandleSavefrom Lab'sMobileTokenizer.tsx(lines 1019–1058) line for line, together with the dismissal guard,SheetDraftChangeandhasSameSelection, so the FR26 Save rule and the FR27 dirty check now live in two copies; move them into one Core-internal module that Lab reaches throughinternal/touch-sheet, asSheetConfirmationalready does, and delete Lab's copies.
Optional: shorten the drag comment at TokenizerBottomSheet.tsx lines 758–761, and update the description, which still says the shared modules have no subpath entry.
[Automated review]
|
|
||
| // Save names the last edit that still holds, else the nearest net add or | ||
| // remove. | ||
| const handleSave = () => { |
There was a problem hiding this comment.
This is handleSave from packages/lab/src/MobileTokenizer/MobileTokenizer.tsx (lines 1019–1058) line for line, and the dismissal handle above, SheetDraftChange and hasSameSelection are copied too, while Lab keeps calling its own. Move the FR26 change rule and the dirty check into one Core-internal module (for example a pure nameSheetDraftChange(valueAtOpen, draft, lastEdit) beside hasSameSelection), re-export it through internal/touch-sheet, call it from both sheets, and delete Lab's copies.
| onCloseSheet(); | ||
| }; | ||
|
|
||
| // A direct drag on the results moves focus from the search field to the |
There was a problem hiding this comment.
Optional (comment style): this is one 41-word sentence with a dashed aside. Suggested:
// Focus moves to the sheet's panel, not the page body behind the modal.
// The keyboard then leaves and the query stays.886b2d3 to
0aa2058
Compare
|
/approve-spec 0aa2058 |
There was a problem hiding this comment.
Changes requested. Callers who omit experimental are unaffected, an engineering owner approved the record edit at this head, and the draft's Save rule and dirty check now live in one Core module that Lab also calls. One thing still needs to change:
- The Chinese consumer docs entry for
experimental(thedocsZhdescription inpackages/core/src/Tokenizer/Tokenizer.doc.mjs) still says 「导出的 TokenizerProps 接口不变」 ("the exported TokenizerProps interface is unchanged"), although this pull request addsexperimental?toTokenizerProps, so please match the English entry, for example 「TokenizerProps 保留已发布的 ref 类型,仅新增可选的 experimental」.
Optional: one assertion in the new draft tests checks for an announcement after a clear that never happens, the option type could be inlined on the prop as the record and Drawer do, and one styles comment could be shorter (inline suggestions).
[Automated review]
| type: "{presentation?: 'popover' | 'bottom-sheet' | 'adaptive'}", | ||
| stability: 'experimental', | ||
| description: | ||
| "实验性选项:此对象中的任何内容都可能在补丁版本中更改或移除;省略它即保持稳定行为。presentation(默认 'popover')决定字段如何呈现选项:popover 为内联组合框及其锚定建议菜单;bottom-sheet 改为一个显示已选标记的触发按钮,点按后打开一个高的模态底部面板——顶部为搜索行,下方为整行复选框行(面板打开期间位置保持不变),hasCreate 时有「创建」行,底部固定显示需确认的「全部清除」和「保存」;面板编辑的是草稿,onChange 仅在「保存」提交时触发一次,草稿有改动时滑动、点击遮罩或按 Escape 关闭会先询问是否放弃;adaptive 在紧凑触摸屏上使用底部面板,其他情况使用 popover,解析方式与 Selector 相同。在底部面板呈现中,触发按钮即为控件(ref、id、aria-* 和 data-* 都作用于它;传入 experimental 后,ref 也接受 Ref<HTMLInputElement | HTMLButtonElement>——仅为输入框类型的 ref 在这个更宽的类型下仍能通过类型检查,但在 adaptive 或 bottom-sheet 下运行时收到的是触发按钮,因此请为两种元素声明 ref 的类型;导出的 TokenizerProps 接口不变);renderItem、renderToken、endContent、hasClear、hasEntriesOnFocus、menuWidth、tokenOverflowBehavior 和 hasAutoFocus 没有作用对象,传入时开发模式下会警告一次。例如:<Tokenizer label=\"标签\" searchSource={tagSource} value={tags} onChange={setTags} hasCreate experimental={{presentation: 'adaptive'}} />。", |
There was a problem hiding this comment.
This entry still ends its ref clause with 「导出的 TokenizerProps 接口不变」 ("the exported TokenizerProps interface is unchanged"), but this pull request adds experimental? to TokenizerProps (Tokenizer.tsx line 341), and the English entry above already says so. Suggested replacement for that clause: 「TokenizerProps 保留已发布的 ref 类型,仅新增可选的 experimental」.
| // A confirmed clear is still announced inside the sheet afterwards. | ||
| expect(modalLiveText(sheet)).not.toContain('All items removed'); |
There was a problem hiding this comment.
Optional: this test never confirms a clear, so the comment's announcement never happens and the assertion that "All items removed" is absent proves nothing. Delete these two lines, or confirm a clear and assert the words are present.
| * @experimental | ||
| */ | ||
| export interface TokenizerPresentationOptions { | ||
| interface TokenizerExperimentalOptions { |
There was a problem hiding this comment.
Optional: the record's Public concepts says "The option type is inlined on the prop". As a named local interface, editor hovers and a regenerated API report show TokenizerExperimentalOptions, a name no entry point exports. Inlining {presentation?: 'popover' | 'bottom-sheet' | 'adaptive'} on experimental, as Drawer.tsx does, keeps them self-describing.
| // PanelSearchInput draws a borderless 32px field, because a dropdown panel | ||
| // is already a bordered box. The sheet is a full-width surface, where the | ||
| // same field reads as unframed, so here it takes the shared input box | ||
| // (`hasInputBox`) at the lg input height, above the sheet's 44px rows. |
There was a problem hiding this comment.
Optional (comment style): the second sentence has 32 words and repeats the hasInputBox JSDoc. Suggested:
// A dropdown panel is already a bordered box, so its search field has no
// border. The sheet is not, so its field takes the shared input box at the
// `lg` height.0aa2058 to
c5a7022
Compare
|
/approve-spec c5a7022 |
There was a problem hiding this comment.
Changes requested. Callers who omit experimental are unaffected, an engineering owner approved the record edit at this head, and the Chinese docs entry from the previous round is fixed. One thing still needs to change:
- The new ownership bullet for the sheet's draft, Save and discard guard (
docs/specs/components/Tokenizer/Tokenizer.spec.mdlines 154–157) sits under Does not own / non-goals while the Owns list leaves it out, so please move it into Owns, for example by extending the touch sheet bullet.
Optional: two new header comments could use shorter sentences (inline suggestion).
[Automated review]
| - The sheet's draft, Save, and the guard that asks before a changed draft is | ||
| discarded (FR26, FR27, DEC-4) — owned here: BottomSheet owns the dismissal | ||
| gesture and its paths, this record owns what the sheet does with a | ||
| dismissal while its draft is changed. |
There was a problem hiding this comment.
This bullet says the record owns the draft, Save and the discard guard, but it sits under Does not own / non-goals, and the touch sheet bullet in Owns still leaves them out. Moving it into Owns fixes both, for example:
- The touch sheet presentation: its trigger, the single searchable sheet, the
in-session row order, progressive long-list rendering, the create row, the
confirmed Clear all, the draft with Save and the guard that asks before a
changed draft is discarded (FR26, FR27, DEC-4), and which Tokenizer props
the sheet honors.
The bullet above can keep the note that BottomSheet owns the dismissal gesture and its paths; its "owns only" sentence then needs to allow for the guard.
| * AlertDialog fixes its purpose to form and its safe action to ghost. A sheet | ||
| * on a touch screen allows scrim dismissal and stacks two separated, | ||
| * full-width large actions, the destructive one first in reading order and | ||
| * the secondary safe one focused first. The alert-dialog theme target stays. |
There was a problem hiding this comment.
Optional (comment style): the second sentence has 30 words and two topics. Suggested:
* AlertDialog fixes its purpose to form and its safe action to ghost. A touch
* sheet's confirmation allows scrim dismissal. Its two full-width large
* actions are stacked and separated: the destructive action first in reading
* order, the safe action focused first. The alert-dialog theme target stays.The header of useDismissSearchOnTouchDrag.ts (lines 12–14) has a 30-word first sentence too.
…mental.presentation, and the sheet edits a draft that Save commits `TokenizerProps` takes back its optional `experimental` object with `presentation: 'popover' | 'bottom-sheet' | 'adaptive'`; the internal entry, its export registration and test are removed; the doc lists the prop and the experimental stories return. The sheet is the recorded flow: one open sheet edits one draft, and `value` changes once, when Save reports the draft with the last edit that still holds; a swipe, scrim or Escape close of a changed draft asks before discarding, and Keep editing returns focus to the search field; Clear all and Save are pinned in every state, Save aria-disabled with the limit as its reason while the draft exceeds maxEntries, which is read against the draft; Clear all and discard share one confirmation with separated, stacked, full-width actions and the safe one focused first; the search field is a bordered input box at the lg height above the 44px rows; a direct drag on the results moves focus from the search field to the sheet's panel, keeping the query. The confirmation and the drag rule are Core-internal modules. The inline presentation is unchanged. The record lifts the hold-back and the rows' gap notes; the confirmation's actions are not yet one action group.
c5a7022 to
a6c0a84
Compare
|
/approve-spec a6c0a84 |
There was a problem hiding this comment.
This looks ready to merge. Callers who omit experimental are unaffected, an engineering owner approved the record edit at this head, and the sheet now edits a draft that Save commits, as component:Tokenizer DEC-4 and FR16–FR27 describe. The ownership placement from the previous round is fixed, so nothing further is needed from you.
[Automated review]






User need
Tokenizer's touch sheet presentation — a trigger that opens one tall modal sheet of checkbox rows instead of the inline combobox — has been in Core behind an internal entry while its user experience was finished on the Lab prototype. That pass is done and its interaction is the record's contract (
component:TokenizerDEC-3, DEC-4, FR16–FR27). Consumers building compact touch flows need the option on the public component, and they need the sheet to behave as the record says — a draft committed by Save, not a selection that changes under the finger on every tap. This PR does both: the option is public again, and the sheet is the recorded flow.Problem and solution fit
One capability — the sheet presentation as recorded — in two inseparable parts:
TokenizerProps.experimental?: {presentation: 'popover' | 'bottom-sheet' | 'adaptive'}is back (the hold-back undone cleanly): the overload that admits the widerrefwithexperimental, the doc prop (en/zh/dense), the three experimental stories, the[experimental]changeset. The internal entryinternal/tokenizer-presentation, itspackage.jsonexport, itssync-exportsregistration and its test are removed; nothing else imported it.TokenizerBottomSheet.tsx:valueAtOpen,draftValue); row toggles, the create row and Clear all change the draft;value/onChangewait for Save, which reports the whole draft once with the last edit that still holds as itschange(the record's fallbacks implemented verbatim). A disabled field at Save reports nothing. Edits are announced when they happen, nothing on Save.aria-disabledwith the limit as its tooltip while the draft exceedsmaxEntries(FR23);maxEntriesis read against the draft, so unchecking makes room before Save.SheetConfirmation(Dialog; title, description, two separated, stacked, full-width large actions, destructive first in reading order, safe action focused first; scrim and Escape take the safe action), replacingAlertDialoghere.lginput height (36px) above the 44px rows: the input border, accent on focus-within, surface, element radius — through a newhasInputBoxprop onPanelSearchInputthat composes the sharedinputWrapperStyles.base(so the forced-colors Highlight branch applies on focus) with the sheet'slgheight and padding viafieldXstyle; the dropdown panels keep their borderless field. This supersedes the open search-border draft (fix(Tokenizer): the touch sheet's search field is a bordered input box #8745), whose 44px height the record no longer states.spec:AST-085/FR4) — so the keyboard leaves and the query stays; taps, shorter moves, multi-touch and the list's own scroll events leave focus alone. The Core-internaluseDismissSearchOnTouchDragowns the rule.en.jsonfrom the prototype's work (save,selectionLimit,discardChangesTitle/Description,keepEditing,discardChanges,alertDialog.cancel);tokenizer.doneis no longer used by the sheet.Shared Core-internal modules:
packages/core/src/internal/SheetConfirmation.tsx(SheetConfirmation,SheetConfirmationProps),packages/core/src/internal/useDismissSearchOnTouchDrag.ts(useDismissSearchOnTouchDrag(getSearchInputs, getFocusTarget?)) andpackages/core/src/internal/sheetDraft.ts(SheetDraftChange,hasSameSelection,nameSheetDraftChange(valueAtOpen, draft, lastEdit)— the FR26 Save rule and the FR27 dirty check, so both live in one place), re-exported by name through the internal entry@astryxdesign/core/internal/touch-sheet(registered inpackage.jsonexports andsync-exports, undocumented, outside the compatibility promise, Core and Lab only by lint — theinternal/touchpattern). Core is the one owner: Lab'sMobileSheetConfirmationanduseDismissSearchOnTouchDragcopies and MobileTokenizer's ownhasSameSelection/Save rule are deleted, and Lab'sMobileTokenizerandMobilePowerSearchimport the entry, passing their sheet panel as the drag's focus target too. Core does not import from Lab.Current specification
component:TokenizerDEC-3 (the experimental option;spec:AST-017/FR21), DEC-4 and FR17–FR27 (the draft-and-Save flow, the confirmation, the pinned footer, the bordered search, the drag rule), FR16 (adaptivethroughspec:AST-094/FR13), AR6 (announcements inside the sheet),spec:AST-085FR1/FR4/FR5,spec:AST-086FR14,family:action-groups(see the one remaining gap). The record's "implemented but not yet exposed" notes and its "Core's sheet does not match this row yet" notes for FR18, FR19, FR22–FR24 and FR26 stop being true with this change and are lifted; FR27 keeps one narrowed gap: the confirmation's two actions are separated Buttons, not yet one action group (family:action-groups; the Lab prototype has the same gap, and whether the group's joined look is wanted is an open owner question). The ownership list gains the draft, Save and the dirty-dismissal guard as this record's; FR18 names the sheet's panel as the drag's focus destination.Public delta and caller burden
experimental?: {presentation?: 'popover' | 'bottom-sheet' | 'adaptive'},@experimental, default'popover'; with it,ref: Ref<HTMLInputElement | HTMLButtonElement>.TokenizerPropsstays an interface whoserefisRef<HTMLInputElement>(type test).onChangefires once per Save with the whole selection and the last holding edit aschange(add|create|remove), instead of once per tap. A caller that counted on per-taponChangein the sheet (none can have: the option was internal) sees the batch.spec:AST-017/FR27).Opting in:
<Tokenizer … experimental={{presentation: 'adaptive'}} />.Design and alternatives
Rejected (recorded in DEC-4): committing each toggle at once; a footer only while the query is empty; a Done that closes without a draft; clearing the query on a results drag. Rejected here: exposing the option before the sheet matched the record (the owner wants one PR that "does it right"); keeping the internal entry beside the public prop; composing the confirmation through ButtonGroup (it draws a joined block, unlike the approved separated look — left to the owner, recorded as FR27's gap).
Desktop no-regression
The bar is that desktop is exactly as on
main:experimentalabsent:presentation = experimental?.presentation ?? 'popover'; the inline path is the same code asmain— the hold-back only dropped the prop before calling the same implementation. The diff touches no line of the inline (popover) path: inTokenizer.tsxit changes the props type, the overloads, the internal export, the sheet host's props (maxEntries,onCommit) and addshandleSheetCommit;handleAdd/handleRemove/handleClearAll, the combobox, the layer mode and the token lane are untouched.adaptiveon a mouse / non-compact screen resolves topopoverthrough the unchangeduseAdaptivePresentationrule (spec:AST-094/FR13); "keeps adaptive presentation inline without compact touch" and the SSR/hydration test pass unchanged.Tokenizer.test.tsx(the inline field, 100+ cases) passes without edits; PowerSearch (which composes the inline Tokenizer) passes unchanged; the sheet suite's edits are the ones the recorded model requires (Done → Save; toggles edit the draft and Save reports; a dirty Escape asks first).experimentalstill loads no sheet code (React.lazybehind the option); the CLIexperimental-isolationgoldens pass; the two internal modules are imported only by the sheet.Evidence
TokenizerBottomSheet.test.tsx): the existing 66 on the draft model, plus 8 ported from the prototype — the shared input box at thelgheight (atomic classes ofinputWrapperStyles.base+ the sheet's own; no 44px height), a row unchecked and re-checked is not a changed draft (Escape closes directly), footer pinned while searching, Save with an unchanged draft reports nothing, thechangerules (create then add →add; an undone add falls back to the holding removal), clean dismissal closes / dirty asks / Keep editing refocuses the search / Discard changes closes with no report andvalueintact, Save over the limitaria-disabledwith "Select up to 1 item" then enabled once within, a results drag moves focus to the sheet panel (not the body) with the query kept.internal/SheetConfirmation.test.tsx(theme target, copy, stacked full-width large actions with the safe one focused),internal/useDismissSearchOnTouchDrag.test.tsx(threshold, ownership, multi-touch, and focus to the caller's target),internal/sheetDraft.test.ts(set comparison; the Save rule's holding edit and its three fallbacks). Lab's MobileTokenizer (24) and MobilePowerSearch (115) pass on the shared entry.Tokenizer.props-type.test.tsx.pnpm check:knowledgealigned.bottom-sheetstory: before/after screenshots in the PR thread (IDs reported there).Writing rubric results
#5804links in DEC-2 are outside this change.Scope
Testing
pnpm exec vitest run packages/core/src/Tokenizer packages/core/src/internal packages/core/src/hooks/useAnnounceRenderedText.adopters.test.tsx packages/cli/test/experimental-isolation.test.mjs;pnpm exec vitest run packages/core/src/PowerSearch packages/core/src/BottomSheet— counts in the PR thread for the headpnpm exec vitest run packages/lab/src/MobileTokenizer packages/lab/src/MobilePowerSearch(Lab on the shared entry)pnpm check:repowithsync-exports --checkandverify-exportson the built dist;pnpm check:knowledge;pnpm check:changesets; Prettier;git diff --check