Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
456ebf7
feat: selectable-item move padding to child option-content
SpyZzey Nov 21, 2025
72f67d4
fix: incorrect bottom padding
SpyZzey Nov 21, 2025
0ef250b
fix: padding
SpyZzey Nov 24, 2025
c92571d
fix: padding
SpyZzey Nov 24, 2025
6bbd824
feat: add no-content-padding
SpyZzey Nov 24, 2025
4d9ed48
refactor: remove stylelint-disable, move no-content-padding styling c…
SpyZzey Nov 25, 2025
edbdcf8
refactor: rename disableContentPadding -> disableContentPaddings
SpyZzey Nov 25, 2025
08c816f
refactor: remove default value for disableContentPaddings
SpyZzey Nov 25, 2025
a47c0d8
fix: padding
SpyZzey Nov 26, 2025
1a5e12d
feat: change disableContentPadding to disableContentStyling
SpyZzey Nov 26, 2025
fea65f8
fix: disabled color set when no-content-styling enabled
SpyZzey Nov 27, 2025
537bdcf
fix: padding too small on non-interactive elements
SpyZzey Nov 27, 2025
2c100cd
fix: padding on non-interactiveGroup parent
SpyZzey Nov 27, 2025
931e7dc
fix: remove disableContentStyling=true
SpyZzey Nov 27, 2025
aae6750
test: add disableContentStyling to selectable-item permutations
SpyZzey Nov 28, 2025
aa6681a
fix: disable state not correct color
SpyZzey Dec 1, 2025
d3fcd3d
refactor: add padding to selectable-item-content instead of option-co…
SpyZzey Dec 2, 2025
858ad32
fix: font-weight bold not on interactiveGroups
SpyZzey Dec 3, 2025
1c79026
fix: padding
SpyZzey Dec 3, 2025
5ec8b6b
test: move disable-content-styling prop to custom permutations page
SpyZzey Dec 4, 2025
0f14628
fix: disableContentStyling default value to false
SpyZzey Dec 4, 2025
bc825d9
fix: rename disable-content-styling.permutations.tsx to include .page
SpyZzey Dec 4, 2025
233b313
fix: disabled color set when no-content-styling enabled
SpyZzey Nov 27, 2025
092e173
feat: add renderOption api to autosuggest
SpyZzey Nov 25, 2025
5ca204b
feat: add renderOption api to select and multiselect
SpyZzey Nov 25, 2025
c0a2f3e
feat: arbitrary content for select, multiselect
SpyZzey Nov 27, 2025
fbbecd6
Revert "feat: add renderOption api to autosuggest"
SpyZzey Nov 27, 2025
c4292c1
chore: remove two examples in pages
SpyZzey Nov 27, 2025
7537dc7
feat: improve api
SpyZzey Nov 27, 2025
c8a1de1
test: update snapshots
SpyZzey Nov 27, 2025
d9dd5a4
revert: checkbox style class
SpyZzey Nov 27, 2025
8a0cecb
test: add support for test-utils, add data-test-indices to multiselec…
SpyZzey Nov 28, 2025
61f8581
test: add tests for select + multiselect renderOption
SpyZzey Nov 28, 2025
256a14c
fix: workaround for documenter bug
SpyZzey Dec 1, 2025
4faca5a
refactor: move renderOption-content to Option-component
SpyZzey Dec 4, 2025
a0d1304
chore: update snapshots
SpyZzey Dec 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions pages/multiselect/custom-render-option.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import * as React from 'react';

import { Multiselect, MultiselectProps } from '~components';
import Box from '~components/box';
import CheckboxIcon from '~components/internal/components/checkbox-icon';
import { SelectProps } from '~components/select';

import ScreenshotArea from '../utils/screenshot-area';
import { i18nStrings } from './constants';
const lotsOfOptions: SelectProps.Options = [...Array(100)].map((_, index) => ({
value: `Option ${index}`,
label: `Option ${index}`,
}));
const options: SelectProps.Options = [
{ value: 'first', label: 'Simple' },
{ value: 'second', label: 'With small icon', iconName: 'folder' },
{
value: 'third',
label: 'With big icon icon',
description: 'Very big option',
iconName: 'heart',
disabled: true,
disabledReason: 'disabled reason',
tags: ['Cool', 'Intelligent', 'Cat'],
},
{
label: 'Option group',
options: [
{ value: 'forth', label: 'Nested option' },
{ value: 'forth0', label: 'Nested option' },
],
disabledReason: 'disabled reason',
},
{
label: 'Option group',
options: [{ value: 'forth2', label: 'Nested option' }],
disabledReason: 'disabled reason',
},
{ label: 'Last option', disabled: true, disabledReason: 'disabled reason' },
...lotsOfOptions,
];

export default function SelectPage() {
const [selectedOptions, setSelectedOptions] = React.useState<MultiselectProps.Options>([]);
const renderOptionItem: MultiselectProps.MultiselectOptionItemRenderer = ({ item }) => {
if (item.type === 'child') {
return <div>{item.option.label}</div>;
} else {
return (
<div>
<CheckboxIcon checked={item.selected} indeterminate={item.indeterminate}></CheckboxIcon>
{item.option.label}
</div>
);
}
};

return (
<ScreenshotArea>
<Box variant="h1">Select with custom item renderer</Box>
<Box padding="l">
<div style={{ width: '400px' }}>
<Multiselect
enableSelectAll={true}
i18nStrings={{ ...i18nStrings, selectAllText: 'Select all' }}
filteringType={'auto'}
renderOption={renderOptionItem}
placeholder="Choose option"
selectedOptions={selectedOptions}
onChange={event => {
setSelectedOptions(event.detail.selectedOptions);
}}
options={options}
/>
</div>
</Box>
</ScreenshotArea>
);
}
71 changes: 71 additions & 0 deletions pages/select/custom-render-option.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import * as React from 'react';
import { useState } from 'react';

import Box from '~components/box';
import Select, { SelectProps } from '~components/select';

import ScreenshotArea from '../utils/screenshot-area';

const extraOptions = [...Array(10).keys()].map(n => {
const numberToDisplay = (n + 5).toString();
return {
value: numberToDisplay,
label: `Option ${n + 5}`,
};
});

const options: SelectProps.Options = [
{ value: 'first', label: 'Simple' },
{ value: 'second', label: 'With small icon', iconName: 'folder' },
{
value: 'third',
label: 'With big icon icon',
description: 'Very big option',
iconName: 'heart',
disabled: true,
disabledReason: 'disabled reason',
tags: ['Cool', 'Intelligent', 'Cat'],
},
{
label: 'Option group',
options: [{ value: 'forth', label: 'Nested option' }],
disabledReason: 'disabled reason',
},
{
label: 'Option group',
options: [{ value: 'forth2', label: 'Nested option' }],
disabledReason: 'disabled reason',
},
...extraOptions,
{ label: 'Last option', disabled: true, disabledReason: 'disabled reason' },
];

export default function SelectPage() {
const [selectedOption, setSelectedOption] = useState<SelectProps.Option | null>(null);
const renderOptionItem: SelectProps.SelectOptionItemRenderer = ({ item, filterText }) => {
return (
<div>
{item.option.label} + {filterText}
</div>
);
};

return (
<ScreenshotArea>
<Box variant="h1">Select with custom item renderer</Box>
<Box padding="l">
<div style={{ width: '400px' }}>
<Select
renderOption={renderOptionItem}
placeholder="Choose option"
selectedOption={selectedOption}
onChange={({ detail }) => setSelectedOption(detail.selectedOption)}
options={options}
/>
</div>
</Box>
</ScreenshotArea>
);
}
65 changes: 65 additions & 0 deletions pages/selectable-item/common.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import Option from '~components/internal/components/option';
import { SelectableItemProps } from '~components/internal/components/selectable-item';

import { ComponentPermutations } from '../utils/permutations';

const simpleOption = <Option option={{ value: 'option 1', label: 'Label 1' }} />;
const iconOption = <Option option={{ value: 'option 1', label: 'Label 1', iconName: 'lock-private' }} />;
const bigOption = (
<Option option={{ value: 'option 2', label: 'Label 2', iconName: 'share', tags: ['tag 1', 'tag 2', 'tag 3'] }} />
);
const optionHasBackground = <Option option={{ value: 'has background' }} />;
const optionGroupHeader = 'group header';
const childOption = 'child option';

export const permutationsConfigs: ComponentPermutations<SelectableItemProps>[] = [
{
selected: [false],
highlighted: [false, true],
disabled: [false, true],
children: [simpleOption],
},
{
selected: [false, true],
highlighted: [false],
disabled: [false, true],
children: [iconOption],
},
{
selected: [false, true],
highlighted: [false],
disabled: [false, true],
children: [bigOption],
},
{
selected: [false, true],
highlighted: [true],
highlightType: ['keyboard'],
disabled: [false],
children: [bigOption],
},
{
selected: [false],
highlighted: [false, true],
disabled: [false],
hasBackground: [true],
children: [optionHasBackground],
},
{
selected: [false],
highlighted: [false],
disabled: [true, false],
isParent: [true],
children: [optionGroupHeader],
},
{
selected: [false, true],
highlighted: [false, true],
isChild: [true],
children: [childOption],
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import SelectableItem, { SelectableItemProps } from '~components/internal/components/selectable-item';
import SpaceBetween from '~components/space-between';

import createPermutations from '../utils/permutations';
import PermutationsView from '../utils/permutations-view';
import ScreenshotArea from '../utils/screenshot-area';
import { permutationsConfigs } from './common';

// Copy permutations and add selectable-items with no-content-styling.
const permutations = createPermutations<SelectableItemProps>(permutationsConfigs);

export default function InputPermutations() {
return (
<>
<h1>Selectable item permutations</h1>
<ScreenshotArea>
<SpaceBetween size="xs">
<ul role="listbox" aria-label="list">
<PermutationsView
permutations={permutations}
render={permutation => <SelectableItem {...permutation} disableContentStyling={true} />}
/>
</ul>
</SpaceBetween>
</ScreenshotArea>
</>
);
}
60 changes: 2 additions & 58 deletions pages/selectable-item/permutations.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,15 @@
// SPDX-License-Identifier: Apache-2.0
import React from 'react';

import Option from '~components/internal/components/option';
import SelectableItem, { SelectableItemProps } from '~components/internal/components/selectable-item';
import SpaceBetween from '~components/space-between';

import createPermutations from '../utils/permutations';
import PermutationsView from '../utils/permutations-view';
import ScreenshotArea from '../utils/screenshot-area';
import { permutationsConfigs } from './common';

const simpleOption = <Option option={{ value: 'option 1', label: 'Label 1' }} />;
const iconOption = <Option option={{ value: 'option 1', label: 'Label 1', iconName: 'lock-private' }} />;
const bigOption = (
<Option option={{ value: 'option 2', label: 'Label 2', iconName: 'share', tags: ['tag 1', 'tag 2', 'tag 3'] }} />
);

const optionHasBackground = <Option option={{ value: 'has background' }} />;
const optionGroupHeader = 'group header';
const childOption = 'child option';

const permutations = createPermutations<SelectableItemProps>([
{
selected: [false],
highlighted: [false, true],
disabled: [false, true],
children: [simpleOption],
},
{
selected: [false, true],
highlighted: [false],
disabled: [false, true],
children: [iconOption],
},
{
selected: [false, true],
highlighted: [false],
disabled: [false, true],
children: [bigOption],
},
{
selected: [false, true],
highlighted: [true],
highlightType: ['keyboard'],
disabled: [false],
children: [bigOption],
},
{
selected: [false],
highlighted: [false, true],
disabled: [false],
hasBackground: [true],
children: [optionHasBackground],
},
{
selected: [false],
highlighted: [false],
disabled: [true, false],
isParent: [true],
children: [optionGroupHeader],
},
{
selected: [false, true],
highlighted: [false, true],
isChild: [true],
children: [childOption],
},
]);
const permutations = createPermutations<SelectableItemProps>(permutationsConfigs);

export default function InputPermutations() {
return (
Expand Down
Loading
Loading