Skip to content

Commit a7218a2

Browse files
Merge branch 'support-slds-2' into support-slds-2-dropdown-menu-dropdown-button
2 parents f1baf01 + afd0bc4 commit a7218a2

37 files changed

+673
-229
lines changed

src/scripts/Badge.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,25 @@ import classnames from 'classnames';
55
*
66
*/
77
export type BadgeProps = {
8-
type?: 'default' | 'shade' | 'inverse';
8+
type?: 'inverse' | 'lightest' | 'success' | 'warning' | 'error';
99
label?: string;
1010
} & HTMLAttributes<HTMLSpanElement>;
1111

1212
/**
1313
*
1414
*/
1515
export const Badge: FC<BadgeProps> = ({ type, label, ...props }) => {
16-
const typeClassName = type ? `slds-theme_${type}` : null;
17-
const badgeClassNames = classnames('slds-badge', typeClassName);
16+
const typeClassName = /^(inverse|lightest)$/.test(type ?? '')
17+
? `slds-badge_${type}`
18+
: null;
19+
const themeClassName = /^(success|warning|error)$/.test(type ?? '')
20+
? `slds-theme_${type}`
21+
: null;
22+
const badgeClassNames = classnames(
23+
'slds-badge',
24+
typeClassName,
25+
themeClassName
26+
);
1827
return (
1928
<span className={badgeClassNames} {...props}>
2029
{label || props.children}

src/scripts/BreadCrumbs.tsx

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ export const Crumb: FC<CrumbProps> = ({
1818
...props
1919
}) => {
2020
const text = children;
21-
const cClassName = classnames(
22-
'slds-list__item slds-text-heading_label',
23-
className
24-
);
21+
const cClassName = classnames('slds-breadcrumb__item', className);
2522

2623
return (
2724
<li {...props} className={cClassName}>
@@ -33,34 +30,26 @@ export const Crumb: FC<CrumbProps> = ({
3330
/**
3431
*
3532
*/
36-
export type BreadCrumbsProps = {
37-
label?: string;
38-
} & HTMLAttributes<HTMLElement>;
33+
export type BreadCrumbsProps = HTMLAttributes<HTMLElement>;
3934

4035
/**
4136
*
4237
*/
4338
export const BreadCrumbs: FC<BreadCrumbsProps> = ({
44-
label,
4539
className,
4640
children,
4741
...props
4842
}) => {
4943
const oClassName = classnames(
50-
'slds-breadcrumb slds-list_horizontal',
44+
'slds-breadcrumb',
45+
'slds-list_horizontal',
46+
'slds-wrap',
5147
className
5248
);
5349

5450
return (
55-
<nav {...props} role='navigation'>
56-
{label ? (
57-
<p id='bread-crumb-label' className='slds-assistive-text'>
58-
{label}
59-
</p>
60-
) : null}
61-
<ol className={oClassName} aria-labelledby='bread-crumb-label'>
62-
{children}
63-
</ol>
51+
<nav {...props} role='navigation' aria-label='Breadcrumbs'>
52+
<ol className={oClassName}>{children}</ol>
6453
</nav>
6554
);
6655
};

src/scripts/Checkbox.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import React, { FC, InputHTMLAttributes, Ref, useContext } from 'react';
1+
import React, {
2+
FC,
3+
InputHTMLAttributes,
4+
Ref,
5+
useContext,
6+
ReactNode,
7+
} from 'react';
28
import classnames from 'classnames';
39
import { FormElement, FormElementProps } from './FormElement';
410
import { CheckboxGroupContext, CheckboxValueType } from './CheckboxGroup';
@@ -15,6 +21,8 @@ export type CheckboxProps = {
1521
value?: CheckboxValueType;
1622
checked?: boolean;
1723
defaultChecked?: boolean;
24+
tooltip?: ReactNode;
25+
tooltipIcon?: string;
1826
elementRef?: Ref<HTMLDivElement>;
1927
inputRef?: Ref<HTMLInputElement>;
2028
} & InputHTMLAttributes<HTMLInputElement>;
@@ -30,13 +38,22 @@ export const Checkbox: FC<CheckboxProps> = (props) => {
3038
required,
3139
error,
3240
cols,
41+
tooltip,
42+
tooltipIcon,
3343
elementRef,
3444
inputRef,
3545
children,
3646
...rprops
3747
} = props;
3848
const { grouped } = useContext(CheckboxGroupContext);
39-
const formElemProps = { required, error, cols, elementRef };
49+
const formElemProps = {
50+
required,
51+
error,
52+
cols,
53+
tooltip,
54+
tooltipIcon,
55+
elementRef,
56+
};
4057
const checkClassNames = classnames(className, 'slds-checkbox');
4158
const check = (
4259
<label className={checkClassNames}>

src/scripts/CheckboxGroup.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import React, {
55
useContext,
66
useMemo,
77
useRef,
8+
ReactNode,
89
} from 'react';
910
import classnames from 'classnames';
1011
import { FormElementProps } from './FormElement';
1112
import { FieldSetColumnContext } from './FieldSet';
13+
import { TooltipContent } from './TooltipContent';
1214
import { useEventCallback } from './hooks';
1315
import { createFC } from './common';
1416
import { Bivariant } from './typeUtils';
@@ -32,6 +34,8 @@ export type CheckboxGroupProps = {
3234
error?: FormElementProps['error'];
3335
name?: string;
3436
cols?: number;
37+
tooltip?: ReactNode;
38+
tooltipIcon?: string;
3539
elementRef?: Ref<HTMLFieldSetElement>;
3640
onValueChange?: Bivariant<(values: CheckboxValueType[]) => void>;
3741
} & FieldsetHTMLAttributes<HTMLFieldSetElement>;
@@ -51,6 +55,8 @@ export const CheckboxGroup = createFC<
5155
style,
5256
required,
5357
error,
58+
tooltip,
59+
tooltipIcon,
5460
elementRef,
5561
onValueChange,
5662
onChange: onChange_,
@@ -118,6 +124,11 @@ export const CheckboxGroup = createFC<
118124
</abbr>
119125
) : undefined}
120126
{label}
127+
{tooltip ? (
128+
<span className='slds-m-left_x-small'>
129+
<TooltipContent icon={tooltipIcon}>{tooltip}</TooltipContent>
130+
</span>
131+
) : null}
121132
</legend>
122133
<div className='slds-form-element__control' ref={controlElRef}>
123134
<CheckboxGroupContext.Provider value={grpCtx}>

src/scripts/DateInput.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import React, {
88
useRef,
99
useState,
1010
useContext,
11+
ReactNode,
1112
} from 'react';
1213
import classnames from 'classnames';
1314
import dayjs from 'dayjs';
@@ -118,6 +119,8 @@ export type DateInputProps = {
118119
minDate?: string;
119120
maxDate?: string;
120121
menuAlign?: 'left' | 'right';
122+
tooltip?: ReactNode;
123+
tooltipIcon?: string;
121124
elementRef?: Ref<HTMLDivElement>;
122125
datepickerRef?: Ref<HTMLDivElement>;
123126
onBlur?: () => void;
@@ -149,6 +152,8 @@ export const DateInput = createFC<DateInputProps, { isFormElement: boolean }>(
149152
minDate,
150153
maxDate,
151154
extensionRenderer,
155+
tooltip,
156+
tooltipIcon,
152157
elementRef: elementRef_,
153158
inputRef: inputRef_,
154159
datepickerRef: datepickerRef_,
@@ -316,7 +321,16 @@ export const DateInput = createFC<DateInputProps, { isFormElement: boolean }>(
316321
}
317322
});
318323

319-
const formElemProps = { id, cols, label, required, error, elementRef };
324+
const formElemProps = {
325+
id,
326+
cols,
327+
label,
328+
required,
329+
error,
330+
tooltip,
331+
tooltipIcon,
332+
elementRef,
333+
};
320334
return (
321335
<FormElement {...formElemProps}>
322336
<div className={classnames(className, 'slds-dropdown-trigger')}>

src/scripts/Grid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function adjustCols(colNum: number, large?: boolean) {
6767
*/
6868
export type ColProps = {
6969
padded?: boolean | 'medium' | 'large';
70-
align?: 'top' | 'medium' | 'bottom';
70+
align?: 'top' | 'middle' | 'bottom';
7171
noFlex?: boolean;
7272
order?: number;
7373
orderSmall?: number;

src/scripts/Input.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import React, {
77
useContext,
88
Ref,
99
useRef,
10+
ReactNode,
1011
} from 'react';
1112
import classnames from 'classnames';
1213
import keycoder from 'keycoder';
@@ -92,6 +93,8 @@ export type InputProps = {
9293
iconRight?: string | JSX.Element;
9394
addonLeft?: string;
9495
addonRight?: string;
96+
tooltip?: ReactNode;
97+
tooltipIcon?: string;
9598
elementRef?: Ref<HTMLDivElement>;
9699
inputRef?: Ref<HTMLInputElement>;
97100
onValueChange?: (value: string, prevValue?: string) => void;
@@ -120,6 +123,8 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
120123
addonLeft,
121124
addonRight,
122125
symbolPattern,
126+
tooltip,
127+
tooltipIcon,
123128
elementRef,
124129
inputRef,
125130
onKeyDown: onKeyDown_,
@@ -207,6 +212,8 @@ export const Input = createFC<InputProps, { isFormElement: boolean }>(
207212
error,
208213
readOnly,
209214
cols,
215+
tooltip,
216+
tooltipIcon,
210217
elementRef,
211218
};
212219
return <FormElement {...formElemProps}>{contentElem}</FormElement>;

src/scripts/Lookup.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import React, {
1111
useState,
1212
useEffect,
1313
EventHandler,
14+
ReactNode,
1415
} from 'react';
1516
import classnames from 'classnames';
1617
import { AutoAlign, AutoAlignInjectedProps, AutoAlignProps } from './AutoAlign';
@@ -571,6 +572,8 @@ export type LookupProps = {
571572
targetScope?: string;
572573
defaultTargetScope?: string;
573574
cols?: number;
575+
tooltip?: ReactNode;
576+
tooltipIcon?: string;
574577

575578
elementRef?: Ref<HTMLDivElement>;
576579
inputRef?: Ref<HTMLDivElement>;
@@ -619,6 +622,8 @@ export const Lookup = createFC<LookupProps, { isFormElement: boolean }>(
619622
listFooter,
620623
data,
621624
scopes,
625+
tooltip,
626+
tooltipIcon,
622627
onSelect: onSelect_,
623628
onScopeMenuClick: onScopeMenuClick_,
624629
onScopeSelect: onScopeSelect_,
@@ -763,7 +768,15 @@ export const Lookup = createFC<LookupProps, { isFormElement: boolean }>(
763768
{ 'slds-has-selection': selected },
764769
className
765770
);
766-
const formElemProps = { id, cols, label, required, error };
771+
const formElemProps = {
772+
id,
773+
cols,
774+
label,
775+
required,
776+
error,
777+
tooltip,
778+
tooltipIcon,
779+
};
767780
return (
768781
<FormElement {...formElemProps}>
769782
<div

src/scripts/MediaObject.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,23 @@ import classnames from 'classnames';
77
export type MediaObjectProps = {
88
figureLeft?: ReactNode;
99
figureRight?: ReactNode;
10-
figureCenter?: ReactNode;
10+
centered?: boolean;
1111
children?: ReactNode;
1212
} & HTMLAttributes<HTMLDivElement>;
1313

1414
/**
1515
*
1616
*/
1717
export const MediaObject: FC<MediaObjectProps> = (props) => {
18-
const {
19-
className,
20-
figureLeft,
21-
figureRight,
22-
figureCenter,
23-
children,
24-
...rprops
25-
} = props;
26-
const mediaClassNames = classnames('slds-media', className);
18+
const { className, figureLeft, figureRight, centered, children, ...rprops } =
19+
props;
20+
const mediaClassNames = classnames(
21+
'slds-media',
22+
{ 'slds-media_center': centered },
23+
className
24+
);
2725
return (
2826
<div className={mediaClassNames} {...rprops}>
29-
{figureCenter ? (
30-
<div className='slds-media__figure'>{figureCenter}</div>
31-
) : undefined}
3227
{figureLeft ? (
3328
<div className='slds-media__figure'>{figureLeft}</div>
3429
) : undefined}

0 commit comments

Comments
 (0)