Skip to content

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

TypeScript

feat(lab)!: drop TransferListSelector's contentXstyle (#4992)

Cindy Zhange3559bbaf4da
diff --git a/apps/storybook/stories/TransferList.stories.tsx b/apps/storybook/stories/TransferList.stories.tsx
index 837ee3f88c..7e6f08e907 100644
--- a/apps/storybook/stories/TransferList.stories.tsx
+++ b/apps/storybook/stories/TransferList.stories.tsx
@@ -65,12 +65,6 @@ const styles = stylex.create({
padding: 0,
overflow: 'hidden',
},
- narrowSelectorContent: {
- width: 'min(360px, calc(100vw - 32px))',
- maxWidth: 'min(360px, calc(100vw - 32px))',
- maxHeight: 'calc(100vh - 32px)',
- padding: 0,
- },
viewOptionsSurface: {
display: 'flex',
flexDirection: 'column',
@@ -345,7 +339,6 @@ function NarrowContainerExample() {
triggerLabel={`${value.length} visible fields`}
width="min(360px, calc(100vw - 32px))"
placement="below"
- contentXstyle={styles.narrowSelectorContent}
selectedLabel="Visible"
availableLabel="Available"
isReorderable={false}
diff --git a/packages/lab/src/TransferList/TransferList.doc.mjs b/packages/lab/src/TransferList/TransferList.doc.mjs
index 8d3846d871..bc11325893 100644
--- a/packages/lab/src/TransferList/TransferList.doc.mjs
+++ b/packages/lab/src/TransferList/TransferList.doc.mjs
@@ -187,7 +187,7 @@ export const docs = {
name: 'width',
type: 'SizeValue',
description:
- 'Width of the external field. Its default matches the responsive popup width; use contentXstyle to override the popup.',
+ 'Width of the field and its popup — both track this one value.',
default: "'min(41rem, calc(100vw - 32px))'",
},
{
@@ -238,12 +238,6 @@ export const docs = {
description:
'Optional async action run after each immediate commit or a changed staged Apply; drives optimistic and busy state.',
},
- {
- name: 'contentXstyle',
- type: 'StyleXStyles',
- description:
- 'StyleX styles composed after the default zero-padding, clipped popover content style.',
- },
{
name: 'xstyle',
type: 'StyleXStyles',
@@ -710,7 +704,6 @@ export const docsDense = {
labelTooltip: 'Field-label tooltip.',
changeAction:
'Async action after each immediate commit or changed staged Apply.',
- contentXstyle: 'Popover-content StyleX override.',
xstyle: 'External field StyleX override.',
className: 'External field class name.',
style: 'External field inline styles.',
diff --git a/packages/lab/src/TransferList/TransferListSelector.tsx b/packages/lab/src/TransferList/TransferListSelector.tsx
index ab45bf742c..6c7465b581 100644
--- a/packages/lab/src/TransferList/TransferListSelector.tsx
+++ b/packages/lab/src/TransferList/TransferListSelector.tsx
@@ -28,14 +28,16 @@ import {TransferList, type TransferListProps} from './TransferList';
const DEFAULT_SELECTOR_WIDTH = 'min(41rem, calc(100vw - 32px))';
const styles = stylex.create({
- content: {
- width: DEFAULT_SELECTOR_WIDTH,
- maxWidth: DEFAULT_SELECTOR_WIDTH,
+ // Width tracks the `width` prop, so the field and its popup are one
+ // measurement rather than two that can disagree.
+ content: (width: string) => ({
+ width,
+ maxWidth: width,
maxHeight: 'calc(100vh - 32px)',
padding: 0,
overflow: 'hidden',
borderRadius: 'inherit',
- },
+ }),
surface: {
display: 'flex',
flexDirection: 'column',
@@ -80,7 +82,6 @@ type TransferListSelectorShellProp =
| 'size'
| 'width'
| 'placement'
- | 'contentXstyle'
| 'xstyle'
| 'className'
| 'style'
@@ -183,7 +184,6 @@ export function TransferListSelector<T extends string = string>({
isDisabled,
isLoading,
width,
- contentXstyle,
applyLabel = 'Apply',
cancelLabel = 'Cancel',
selectedLabel,
@@ -223,6 +223,11 @@ export function TransferListSelector<T extends string = string>({
previousCommitBehaviorRef.current = commitBehavior;
}, [commitBehavior, resetDraft]);
+ const resolvedWidth =
+ typeof width === 'number'
+ ? `${width}px`
+ : (width ?? DEFAULT_SELECTOR_WIDTH);
+
return (
<ComplexSelector
{...selectorProps}
@@ -234,8 +239,8 @@ export function TransferListSelector<T extends string = string>({
triggerLabel={triggerLabel ?? `${value.length} selected`}
isDisabled={isDisabled}
isLoading={isLoading}
- width={width ?? DEFAULT_SELECTOR_WIDTH}
- contentXstyle={[styles.content, contentXstyle]}>
+ width={resolvedWidth}
+ contentXstyle={styles.content(resolvedWidth)}>
{(appliedValue, commit, close, state) => {
const isStaged = commitBehavior === 'staged';
const transferListValue = isStaged ? draftValue : appliedValue;