diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index 638c99b2d459..6204f4abaa9e 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -6830,6 +6830,9 @@ Map { "className": Object { "type": "string", }, + "decorator": Object { + "type": "node", + }, "defaultValue": Object { "type": "any", }, @@ -6878,9 +6881,7 @@ Map { ], "type": "oneOf", }, - "slug": Object { - "type": "node", - }, + "slug": [Function], "warn": Object { "type": "bool", }, diff --git a/packages/react/src/components/FluidSelect/FluidSelect.stories.js b/packages/react/src/components/FluidSelect/FluidSelect.stories.js index 9c304367786f..633e9308ab08 100644 --- a/packages/react/src/components/FluidSelect/FluidSelect.stories.js +++ b/packages/react/src/components/FluidSelect/FluidSelect.stories.js @@ -14,7 +14,10 @@ import { ToggletipButton, ToggletipContent, } from '../Toggletip'; -import { Information } from '@carbon/icons-react'; +import Button from '../Button'; +import { AILabel, AILabelContent, AILabelActions } from '../AILabel'; +import { IconButton } from '../IconButton'; +import { Information, View, FolderOpen, Folders } from '@carbon/icons-react'; import mdx from './FluidSelect.mdx'; export default { @@ -113,6 +116,52 @@ export const Default = () => ( ); +const aiLabel = ( + + +
+

AI Explained

+

84%

+

Confidence score

+

+ Lorem ipsum dolor sit amet, di os consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut fsil labore et dolore magna aliqua. +

+
+

Model type

+

Foundation model

+
+ + + + + + + + + + + + +
+
+); + +export const withAILabel = () => ( +
+ + + + + + + +
+); + export const Playground = (args) => (
diff --git a/packages/react/src/components/Form/Form.stories.js b/packages/react/src/components/Form/Form.stories.js index 506a6fe1f75e..c80a3339a377 100644 --- a/packages/react/src/components/Form/Form.stories.js +++ b/packages/react/src/components/Form/Form.stories.js @@ -365,7 +365,7 @@ export const withAILabel = (args) => { id="select-1" labelText="Select an option" helperText="Optional helper text" - slug={aiLabel} + decorator={aiLabel} {...rest}> { />
- + diff --git a/packages/react/src/components/Select/Select.stories.js b/packages/react/src/components/Select/Select.stories.js index 0177dc80ac1f..baf83ad3a3ac 100644 --- a/packages/react/src/components/Select/Select.stories.js +++ b/packages/react/src/components/Select/Select.stories.js @@ -17,6 +17,7 @@ import { AILabel, AILabelContent, AILabelActions } from '../AILabel'; import { IconButton } from '../IconButton'; import { View, FolderOpen, Folders } from '@carbon/icons-react'; import mdx from './Select.mdx'; +import { Tooltip } from '../Tooltip'; export default { title: 'Components/Select', @@ -166,12 +167,12 @@ const aiLabel = ( ); export const withAILabel = () => ( -
+
` */ @@ -410,11 +439,10 @@ Select.propTypes = { */ size: PropTypes.oneOf(['sm', 'md', 'lg']), - /** - * **Experimental**: Provide a `Slug` component to be rendered inside the `Select` component - */ - slug: PropTypes.node, - + slug: deprecate( + PropTypes.node, + 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.' + ), /** * Specify whether the control is currently in warning state */ diff --git a/packages/react/src/components/Select/__tests__/Select-test.js b/packages/react/src/components/Select/__tests__/Select-test.js index d146a59ed08c..f68bf82b5a2d 100644 --- a/packages/react/src/components/Select/__tests__/Select-test.js +++ b/packages/react/src/components/Select/__tests__/Select-test.js @@ -242,6 +242,7 @@ describe('Select', () => { }); it('should respect slug prop', () => { + const spy = jest.spyOn(console, 'warn').mockImplementation(() => {}); const { container } = render( } /> + ); + + expect(container.firstChild.firstChild).toHaveClass( + `${prefix}--select--decorator` + ); }); }); diff --git a/packages/styles/scss/components/fluid-select/_fluid-select.scss b/packages/styles/scss/components/fluid-select/_fluid-select.scss index a2e8e7ca7a75..b9702ca02b7c 100644 --- a/packages/styles/scss/components/fluid-select/_fluid-select.scss +++ b/packages/styles/scss/components/fluid-select/_fluid-select.scss @@ -201,10 +201,14 @@ } // AILabel styles + .#{$prefix}--select--fluid + .#{$prefix}--select--decorator + .#{$prefix}--select__inner-wrapper--decorator + > *, .#{$prefix}--select--fluid .#{$prefix}--select--slug .#{$prefix}--ai-label, .#{$prefix}--select--fluid .#{$prefix}--select--slug .#{$prefix}--slug { inset-block-start: convert.to-rem(42px); - inset-inline-end: $spacing-08; + inset-inline-end: $spacing-09; } .#{$prefix}--select--fluid diff --git a/packages/styles/scss/components/select/_select.scss b/packages/styles/scss/components/select/_select.scss index 3632bfd885f2..614f80415190 100644 --- a/packages/styles/scss/components/select/_select.scss +++ b/packages/styles/scss/components/select/_select.scss @@ -283,6 +283,9 @@ $divider-width: 1px; + .#{$prefix}--select--decorator + .#{$prefix}--select__inner-wrapper--decorator + > *, .#{$prefix}--select--slug .#{$prefix}--ai-label, .#{$prefix}--select--slug .#{$prefix}--slug { position: absolute; @@ -292,6 +295,12 @@ transform: translateY(-50%); } + .#{$prefix}--select--decorator + .#{$prefix}--select__inner-wrapper--decorator + > *::after, + .#{$prefix}--select--decorator + .#{$prefix}--select__inner-wrapper--decorator + > *::before, .#{$prefix}--select--slug .#{$prefix}--ai-label::after, .#{$prefix}--select--slug .#{$prefix}--ai-label::before, .#{$prefix}--select--slug .#{$prefix}--slug::after, @@ -303,48 +312,92 @@ inline-size: convert.to-rem(1px); } + .#{$prefix}--select--decorator + .#{$prefix}--select__inner-wrapper--decorator + > *::before, .#{$prefix}--select--slug .#{$prefix}--ai-label::before, .#{$prefix}--select--slug .#{$prefix}--slug::before { display: none; inset-inline-start: calc(-#{$spacing-03} - #{$divider-width}); } + .#{$prefix}--select--decorator + .#{$prefix}--select__inner-wrapper--decorator + > *::after, .#{$prefix}--select--slug .#{$prefix}--ai-label::after, .#{$prefix}--select--slug .#{$prefix}--slug::after { display: block; + inset-block-start: 0; inset-inline-end: calc(-#{$spacing-03} - #{$divider-width}); } + .#{$prefix}--select--decorator + .#{$prefix}--select__inner-wrapper--decorator + > .#{$prefix}--ai-label--revert::before, + .#{$prefix}--select--slug .#{$prefix}--ai-label--revert::before, + .#{$prefix}--select--slug .#{$prefix}--slug--revert::before { + inset-block-start: 0.5rem; + inset-inline-start: 0; + } + + .#{$prefix}--select--decorator + .#{$prefix}--select__inner-wrapper--decorator + > .#{$prefix}--ai-label--revert, + .#{$prefix}--select--slug .#{$prefix}--ai-label--revert { + inset-inline-end: convert.to-rem(41px); + } + + .#{$prefix}--select--decorator .#{$prefix}--ai-label--revert::after, .#{$prefix}--select--slug .#{$prefix}--ai-label--revert::after, .#{$prefix}--select--slug .#{$prefix}--slug--revert::after { inset-block-start: convert.to-rem(8px); - inset-inline-end: convert.to-rem(-1px); + inset-inline-end: -($divider-width); } - .#{$prefix}--select--slug - .#{$prefix}--select-input:has(~ .#{$prefix}--ai-label):not( - :has(~ .#{$prefix}--ai-label--revert) + .#{$prefix}--select--decorator + .#{$prefix}--select-input:has( + ~ .#{$prefix}--select__inner-wrapper--decorator ), .#{$prefix}--select--slug - .#{$prefix}--select-input:has(~ .#{$prefix}--slug):not( - :has(~ .#{$prefix}--slug--revert) - ) { - @include ai-gradient; - + .#{$prefix}--select-input:has(~ .#{$prefix}--ai-label), + .#{$prefix}--select--slug .#{$prefix}--select-input:has(~ .#{$prefix}--slug) { padding-inline-end: $spacing-10; } + .#{$prefix}--select--decorator:has(.#{$prefix}--select__invalid-icon) + .#{$prefix}--select-input:has( + ~ .#{$prefix}--select__inner-wrapper--decorator + ), .#{$prefix}--select--slug:has(.#{$prefix}--select__invalid-icon) + .#{$prefix}--select-input:has(~ .#{$prefix}--ai-label), + .#{$prefix}--select--slug:has(.#{$prefix}--select__invalid-icon) + .#{$prefix}--select-input:has(~ .#{$prefix}--slug) { + padding-inline-end: $spacing-12; + } + + .#{$prefix}--select--decorator + .#{$prefix}--select-input:has( + ~ .#{$prefix}--select__inner-wrapper--decorator .#{$prefix}--ai-label + ):not( + :has( + ~ .#{$prefix}--select__inner-wrapper--decorator + .#{$prefix}--ai-label--revert + ) + ), + .#{$prefix}--select--slug .#{$prefix}--select-input:has(~ .#{$prefix}--ai-label):not( :has(~ .#{$prefix}--ai-label--revert) ), - .#{$prefix}--select--slug:has(.#{$prefix}--select__invalid-icon) + .#{$prefix}--select--slug .#{$prefix}--select-input:has(~ .#{$prefix}--slug):not( :has(~ .#{$prefix}--slug--revert) ) { - padding-inline-end: $spacing-12; + @include ai-gradient; } + .#{$prefix}--select--decorator:has(.#{$prefix}--select__invalid-icon) + .#{$prefix}--select__inner-wrapper--decorator + > *::before, .#{$prefix}--select--slug:has(.#{$prefix}--select__invalid-icon) .#{$prefix}--ai-label::before, .#{$prefix}--select--slug:has(.#{$prefix}--select__invalid-icon) @@ -352,6 +405,10 @@ display: block; } + .#{$prefix}--select--decorator + .#{$prefix}--select-input__wrapper + .#{$prefix}--select-input + ~ .#{$prefix}--select__invalid-icon, .#{$prefix}--select--slug .#{$prefix}--select-input__wrapper[data-invalid] .#{$prefix}--select-input