Skip to content

Commit

Permalink
Merge branch 'main' into eslint-plugin-ssr-friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonjoseph committed Mar 20, 2024
2 parents 9e44c41 + 4de1fc6 commit 4d229ba
Show file tree
Hide file tree
Showing 23 changed files with 174 additions and 61 deletions.
8 changes: 8 additions & 0 deletions .all-contributorsrc
Expand Up @@ -1390,6 +1390,14 @@
]
},
{
"login": "onurozkardes",
"name": "Onur Özkardeş",
"avatar_url": "https://avatars.githubusercontent.com/u/38096930?v=4",
"profile": "https://github.com/onurozkardes",
"contributions": [
"code"
]
},
"login": "mattborghi",
"name": "Matias Borghi",
"avatar_url": "https://avatars.githubusercontent.com/u/11933424?v=4",
Expand Down
Expand Up @@ -76,7 +76,7 @@ Array [
"chatAvatarBot",
"chatAvatarUser",
"chatBubbleAgent",
"chatBubbleAgentBorder",
"chatBubbleBorder",
"chatBubbleUser",
"chatButton",
"chatButtonActive",
Expand Down
36 changes: 36 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Expand Up @@ -9700,6 +9700,42 @@ Map {
},
},
},
"unstable__AiSkeletonIcon" => Object {
"propTypes": Object {
"className": Object {
"type": "string",
},
"style": Object {
"type": "object",
},
},
},
"unstable__AiSkeletonPlaceholder" => Object {
"propTypes": Object {
"className": Object {
"type": "string",
},
},
},
"unstable__AiSkeletonText" => Object {
"propTypes": Object {
"className": Object {
"type": "string",
},
"heading": Object {
"type": "bool",
},
"lineCount": Object {
"type": "number",
},
"paragraph": Object {
"type": "bool",
},
"width": Object {
"type": "string",
},
},
},
"unstable__ChatButton" => Object {
"$$typeof": Symbol(react.forward_ref),
"propTypes": Object {
Expand Down
3 changes: 3 additions & 0 deletions packages/react/src/__tests__/index-test.js
Expand Up @@ -246,6 +246,9 @@ describe('Carbon Components React', () => {
"unstable_Pagination",
"unstable_Text",
"unstable_TextDirection",
"unstable__AiSkeletonIcon",
"unstable__AiSkeletonPlaceholder",
"unstable__AiSkeletonText",
"unstable__ChatButton",
"unstable__ChatButtonSkeleton",
"unstable__FluidComboBox",
Expand Down
27 changes: 17 additions & 10 deletions packages/react/src/components/ComboBox/ComboBox.tsx
Expand Up @@ -500,9 +500,9 @@ const ComboBox = forwardRef(
const titleClasses = cx(`${prefix}--label`, {
[`${prefix}--label--disabled`]: disabled,
});
const comboBoxHelperId = !helperText
? undefined
: `combobox-helper-text-${comboBoxInstanceId}`;
const helperTextId = `combobox-helper-text-${comboBoxInstanceId}`;
const warnTextId = `combobox-warn-text-${comboBoxInstanceId}`;
const invalidTextId = `combobox-invalid-text-${comboBoxInstanceId}`;
const helperClasses = cx(`${prefix}--form__helper-text`, {
[`${prefix}--form__helper-text--disabled`]: disabled,
});
Expand Down Expand Up @@ -666,6 +666,15 @@ const ComboBox = forwardRef(
}
: {};

// The input should be described by the appropriate message text id
// when both the message is supplied *and* when the component is in
// the matching state (invalid, warn, etc).
const ariaDescribedBy =
(invalid && invalidText && invalidTextId) ||
(warn && warnText && warnTextId) ||
(helperText && !isFluid && helperTextId) ||
undefined;

return (
<div className={wrapperClasses}>
{titleText && (
Expand All @@ -680,11 +689,13 @@ const ComboBox = forwardRef(
disabled={disabled}
invalid={invalid}
invalidText={invalidText}
invalidTextId={invalidTextId}
isOpen={isOpen}
light={light}
size={size}
warn={warn}
warnText={warnText}>
warnText={warnText}
warnTextId={warnTextId}>
<div className={`${prefix}--list-box__field`}>
<input
role="combobox"
Expand All @@ -703,11 +714,7 @@ const ComboBox = forwardRef(
{...readOnlyEventHandlers}
readOnly={readOnly}
ref={mergeRefs(textInput, ref)}
aria-describedby={
helperText && !invalid && !warn && !isFluid
? comboBoxHelperId
: undefined
}
aria-describedby={ariaDescribedBy}
/>
{invalid && (
<WarningFilled
Expand Down Expand Up @@ -786,7 +793,7 @@ const ComboBox = forwardRef(
</ListBox.Menu>
</ListBox>
{helperText && !invalid && !warn && !isFluid && (
<Text as="div" id={comboBoxHelperId} className={helperClasses}>
<Text as="div" id={helperTextId} className={helperClasses}>
{helperText}
</Text>
)}
Expand Down
32 changes: 29 additions & 3 deletions packages/react/src/components/ListBox/ListBox.tsx
Expand Up @@ -44,6 +44,11 @@ export interface ListBoxProps
*/
invalidText?: React.ReactNode;

/**
* Specify the id to be applied to the element containing the invalid text
*/
invalidTextId?: string;

/**
* Specify if the control should render open
*/
Expand Down Expand Up @@ -78,6 +83,11 @@ export interface ListBoxProps
* Provide the text that is displayed when the control is in warning state
*/
warnText?: React.ReactNode;

/**
* Specify the id to be applied to the element containing the warn text
*/
warnTextId?: string;
}

export type ListBoxComponent = ForwardRefReturn<HTMLDivElement, ListBoxProps>;
Expand All @@ -95,8 +105,10 @@ const ListBox: ListBoxComponent = React.forwardRef(function ListBox(
size,
invalid,
invalidText,
invalidTextId,
warn,
warnText,
warnTextId,
light,
isOpen,
...rest
Expand Down Expand Up @@ -132,10 +144,14 @@ const ListBox: ListBoxComponent = React.forwardRef(function ListBox(
</div>
{isFluid && <hr className={`${prefix}--list-box__divider`} />}
{invalid ? (
<div className={`${prefix}--form-requirement`}>{invalidText}</div>
<div className={`${prefix}--form-requirement`} id={invalidTextId}>
{invalidText}
</div>
) : null}
{showWarning ? (
<div className={`${prefix}--form-requirement`}>{warnText}</div>
<div className={`${prefix}--form-requirement`} id={warnTextId}>
{warnText}
</div>
) : null}
</>
);
Expand Down Expand Up @@ -168,6 +184,11 @@ ListBox.propTypes = {
*/
invalidText: PropTypes.node,

/**
* Specify the id to be applied to the element containing the invalid text
*/
invalidTextId: PropTypes.string,

/**
* Specify if the control should render open
*/
Expand Down Expand Up @@ -202,7 +223,12 @@ ListBox.propTypes = {
/**
* Provide the text that is displayed when the control is in warning state
*/
warnText: PropTypes.node,
warnText: PropTypes.string,

/**
* Specify the id to be applied to the element containing the warn text
*/
warnTextId: PropTypes.string,
};

export default ListBox;
23 changes: 23 additions & 0 deletions packages/react/src/components/Stack/HStack.tsx
@@ -0,0 +1,23 @@
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';

import { Stack, StackProps } from './Stack';

const HStack = React.forwardRef<React.ReactNode, StackProps>(function HStack(
{ children, ...props },
ref
) {
return (
<Stack {...props} ref={ref} orientation="horizontal">
{children}
</Stack>
);
});

export { HStack };
7 changes: 4 additions & 3 deletions packages/react/src/components/Stack/Stack.tsx
Expand Up @@ -5,10 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

import { spacing } from '@carbon/layout';
import React from 'react';
import cx from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';
import { spacing } from '@carbon/layout';

import { usePrefix } from '../../internal/usePrefix';

/**
Expand All @@ -21,7 +22,7 @@ const SPACING_STEPS = Array.from({ length: spacing.length - 1 }).map(
}
);

interface StackProps extends React.HTMLAttributes<HTMLElement> {
export interface StackProps extends React.HTMLAttributes<HTMLElement> {
/**
* Provide a custom element type to render as the outermost element in
* the Stack component. By default, this component will render a `div`.
Expand Down
19 changes: 19 additions & 0 deletions packages/react/src/components/Stack/VStack.tsx
@@ -0,0 +1,19 @@
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';

import { Stack, StackProps } from './Stack';

const VStack = React.forwardRef<React.ReactNode, StackProps>(function VStack(
props,
ref
) {
return <Stack {...props} ref={ref} orientation="vertical" />;
});

export { VStack };
10 changes: 10 additions & 0 deletions packages/react/src/components/Stack/index.ts
@@ -0,0 +1,10 @@
/**
* Copyright IBM Corp. 2016, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

export { HStack } from './HStack';
export { VStack } from './VStack';
export { Stack, type StackProps } from './Stack';
26 changes: 0 additions & 26 deletions packages/react/src/components/Stack/index.tsx

This file was deleted.

6 changes: 6 additions & 0 deletions packages/react/src/index.ts
Expand Up @@ -76,6 +76,7 @@ export * from './components/SkeletonIcon';
export * from './components/SkeletonPlaceholder';
export * from './components/SkeletonText';
export * from './components/Slider';
export * from './components/Stack';
export * from './components/StructuredList';
export * from './components/Switch';
export * from './components/Tab';
Expand Down Expand Up @@ -161,6 +162,11 @@ export {
ChatButton as unstable__ChatButton,
ChatButtonSkeleton as unstable__ChatButtonSkeleton,
} from './components/ChatButton';
export {
AiSkeletonText as unstable__AiSkeletonText,
AiSkeletonIcon as unstable__AiSkeletonIcon,
AiSkeletonPlaceholder as unstable__AiSkeletonPlaceholder,
} from './components/AiSkeleton';
export * from './components/Stack';
export * from './components/Tooltip';
export {
Expand Down
2 changes: 1 addition & 1 deletion packages/styles/scss/__tests__/theme-test.js
Expand Up @@ -153,7 +153,7 @@ describe('@carbon/styles/scss/theme', () => {
"chat-prompt-border-end",
"chat-bubble-user",
"chat-bubble-agent",
"chat-bubble-agent-border",
"chat-bubble-border",
"chat-avatar-bot",
"chat-avatar-agent",
"chat-avatar-user",
Expand Down
4 changes: 2 additions & 2 deletions packages/styles/scss/components/link/_link.scss
Expand Up @@ -65,11 +65,11 @@ $link-focus-text-color: custom-property.get-var(
}

&:visited {
color: $link-visited-text-color;
color: $link-text-color;
}

&:visited:hover {
color: $link-visited-text-color;
color: $link-hover-text-color;
}
}

Expand Down
Expand Up @@ -19,7 +19,8 @@
will-change: margin-left;
}

.#{$prefix}--header ~ .#{$prefix}--content {
.#{$prefix}--header ~ .#{$prefix}--content,
div:has(.#{$prefix}--header) ~ .#{$prefix}--content {
margin-block-start: mini-units(6);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/themes/src/g10.js
Expand Up @@ -243,7 +243,7 @@ export const chatPromptBorderStart = gray10;
export const chatPromptBorderEnd = rgba(gray10, 0);
export const chatBubbleUser = gray20;
export const chatBubbleAgent = white;
export const chatBubbleAgentBorder = gray20;
export const chatBubbleBorder = gray20;
export const chatAvatarBot = gray60;
export const chatAvatarAgent = gray80;
export const chatAvatarUser = blue60;
Expand Down

0 comments on commit 4d229ba

Please sign in to comment.