@workday/canvas-kit-docs 15.0.0-alpha.0060-next.0 → 15.0.0-alpha.0074-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es6/lib/docs.js +90 -2575
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/mdx/14.0-UPGRADE-GUIDE.mdx +4 -4
- package/dist/mdx/15.0-UPGRADE-GUIDE.mdx +39 -2
- package/dist/mdx/CODEMODS.mdx +2 -2
- package/dist/mdx/react/action-bar/ActionBar.mdx +3 -3
- package/dist/mdx/react/button/button/Button.mdx +6 -7
- package/dist/mdx/react/expandable/Expandable.mdx +49 -2
- package/dist/mdx/react/expandable/examples/HoistedModel.tsx +24 -17
- package/dist/mdx/react/menu/Menu.mdx +63 -26
- package/dist/mdx/react/menu/examples/SelectableMenu.tsx +13 -2
- package/package.json +6 -6
- package/dist/mdx/labs-react/combobox/Combobox.mdx +0 -68
- package/dist/mdx/labs-react/combobox/examples/Basic.tsx +0 -88
- package/dist/mdx/labs-react/combobox/examples/DisabledItem.tsx +0 -88
- package/dist/mdx/labs-react/combobox/examples/GroupOfResult.tsx +0 -88
- package/dist/mdx/labs-react/combobox/examples/Grow.tsx +0 -88
- package/dist/mdx/labs-react/combobox/examples/NoClearButton.tsx +0 -88
- package/dist/mdx/labs-react/combobox/examples/RTL.tsx +0 -90
- package/dist/mdx/labs-react/search-form/SearchForm.mdx +0 -92
- package/dist/mdx/labs-react/search-form/examples/Basic.tsx +0 -63
- package/dist/mdx/labs-react/search-form/examples/Collapsed.tsx +0 -64
- package/dist/mdx/labs-react/search-form/examples/CustomStyles.tsx +0 -91
- package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +0 -73
- package/dist/mdx/labs-react/search-form/examples/Grow.tsx +0 -64
- package/dist/mdx/labs-react/search-form/examples/RTL.tsx +0 -66
- package/dist/mdx/labs-react/search-form/examples/Theming.tsx +0 -66
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
-
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {
|
|
4
|
-
Combobox,
|
|
5
|
-
ComboboxProps,
|
|
6
|
-
ComboBoxMenuItemGroup,
|
|
7
|
-
} from '@workday/canvas-kit-labs-react/combobox';
|
|
8
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
9
|
-
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
10
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
11
|
-
|
|
12
|
-
const autocompleteResult = (
|
|
13
|
-
textModifier: number,
|
|
14
|
-
disabled: boolean
|
|
15
|
-
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
-
<StyledMenuItem aria-disabled={disabled}>
|
|
17
|
-
Result
|
|
18
|
-
<span>
|
|
19
|
-
num<span>ber</span>
|
|
20
|
-
</span>
|
|
21
|
-
{textModifier}
|
|
22
|
-
</StyledMenuItem>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const simpleAutoComplete = (count: number, showDisabledItems, total = 5) =>
|
|
26
|
-
Array.apply(null, Array(count))
|
|
27
|
-
.map((_, i) => autocompleteResult(i, showDisabledItems && i === 0))
|
|
28
|
-
.splice(0, total);
|
|
29
|
-
|
|
30
|
-
const groupOfResults = (
|
|
31
|
-
count: number,
|
|
32
|
-
showDisabledItems: boolean,
|
|
33
|
-
groupHeading: ReactNode = 'Group'
|
|
34
|
-
): ComboBoxMenuItemGroup => ({
|
|
35
|
-
header: (
|
|
36
|
-
<StyledMenuItem>
|
|
37
|
-
<strong>{groupHeading}</strong>
|
|
38
|
-
</StyledMenuItem>
|
|
39
|
-
),
|
|
40
|
-
items: simpleAutoComplete(count, showDisabledItems, 10),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const Autocomplete: FC<
|
|
44
|
-
Omit<ComboboxProps, 'children'> & {
|
|
45
|
-
group?: boolean;
|
|
46
|
-
showDisabledItems?: boolean;
|
|
47
|
-
}
|
|
48
|
-
> = ({showClearButton, group, showDisabledItems = false, ...props}) => {
|
|
49
|
-
const [currentText, setCurrentText] = React.useState('');
|
|
50
|
-
|
|
51
|
-
const autocompleteCallback = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
52
|
-
setCurrentText(event.target.value);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const textLength = currentText.length;
|
|
56
|
-
const groupLength = Math.floor(textLength / 2);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<Combobox
|
|
60
|
-
autocompleteItems={
|
|
61
|
-
group
|
|
62
|
-
? [
|
|
63
|
-
groupOfResults(groupLength, showDisabledItems, <em>Animals</em>),
|
|
64
|
-
groupOfResults(Math.min(1, groupLength), showDisabledItems, 'Cars'),
|
|
65
|
-
]
|
|
66
|
-
: simpleAutoComplete(textLength, showDisabledItems, 10)
|
|
67
|
-
}
|
|
68
|
-
onChange={autocompleteCallback}
|
|
69
|
-
showClearButton={showClearButton == null ? true : showClearButton}
|
|
70
|
-
labelId="autocomplete-123"
|
|
71
|
-
initialValue="Test"
|
|
72
|
-
{...props}
|
|
73
|
-
>
|
|
74
|
-
<TextInput placeholder="Autocomplete" />
|
|
75
|
-
</Combobox>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default () => {
|
|
80
|
-
return (
|
|
81
|
-
<FormField id="autocomplete-123">
|
|
82
|
-
<FormField.Label>Autocomplete example</FormField.Label>
|
|
83
|
-
<FormField.Field>
|
|
84
|
-
<FormField.Input as={Autocomplete} />
|
|
85
|
-
</FormField.Field>
|
|
86
|
-
</FormField>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
-
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {
|
|
4
|
-
Combobox,
|
|
5
|
-
ComboboxProps,
|
|
6
|
-
ComboBoxMenuItemGroup,
|
|
7
|
-
} from '@workday/canvas-kit-labs-react/combobox';
|
|
8
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
9
|
-
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
10
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
11
|
-
|
|
12
|
-
const autocompleteResult = (
|
|
13
|
-
textModifier: number,
|
|
14
|
-
disabled: boolean
|
|
15
|
-
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
-
<StyledMenuItem aria-disabled={disabled}>
|
|
17
|
-
Result
|
|
18
|
-
<span>
|
|
19
|
-
num<span>ber</span>
|
|
20
|
-
</span>
|
|
21
|
-
{textModifier}
|
|
22
|
-
</StyledMenuItem>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const simpleAutoComplete = (count: number, showDisabledItems, total = 5) =>
|
|
26
|
-
Array.apply(null, Array(count))
|
|
27
|
-
.map((_, i) => autocompleteResult(i, showDisabledItems && i === 0))
|
|
28
|
-
.splice(0, total);
|
|
29
|
-
|
|
30
|
-
const groupOfResults = (
|
|
31
|
-
count: number,
|
|
32
|
-
showDisabledItems: boolean,
|
|
33
|
-
groupHeading: ReactNode = 'Group'
|
|
34
|
-
): ComboBoxMenuItemGroup => ({
|
|
35
|
-
header: (
|
|
36
|
-
<StyledMenuItem>
|
|
37
|
-
<strong>{groupHeading}</strong>
|
|
38
|
-
</StyledMenuItem>
|
|
39
|
-
),
|
|
40
|
-
items: simpleAutoComplete(count, showDisabledItems, 10),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const Autocomplete: FC<
|
|
44
|
-
Omit<ComboboxProps, 'children'> & {
|
|
45
|
-
group?: boolean;
|
|
46
|
-
showDisabledItems?: boolean;
|
|
47
|
-
}
|
|
48
|
-
> = ({showClearButton, group, showDisabledItems = false, ...props}) => {
|
|
49
|
-
const [currentText, setCurrentText] = React.useState('');
|
|
50
|
-
|
|
51
|
-
const autocompleteCallback = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
52
|
-
setCurrentText(event.target.value);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const textLength = currentText.length;
|
|
56
|
-
const groupLength = Math.floor(textLength / 2);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<Combobox
|
|
60
|
-
autocompleteItems={
|
|
61
|
-
group
|
|
62
|
-
? [
|
|
63
|
-
groupOfResults(groupLength, showDisabledItems, <em>Animals</em>),
|
|
64
|
-
groupOfResults(Math.min(1, groupLength), showDisabledItems, 'Cars'),
|
|
65
|
-
]
|
|
66
|
-
: simpleAutoComplete(textLength, showDisabledItems, 10)
|
|
67
|
-
}
|
|
68
|
-
onChange={autocompleteCallback}
|
|
69
|
-
showClearButton={showClearButton == null ? true : showClearButton}
|
|
70
|
-
labelId="autocomplete-123"
|
|
71
|
-
initialValue="Test"
|
|
72
|
-
{...props}
|
|
73
|
-
>
|
|
74
|
-
<TextInput placeholder="Autocomplete" />
|
|
75
|
-
</Combobox>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default () => {
|
|
80
|
-
return (
|
|
81
|
-
<FormField id="autocomplete-123">
|
|
82
|
-
<FormField.Label>Group of results</FormField.Label>
|
|
83
|
-
<FormField.Field>
|
|
84
|
-
<FormField.Input as={Autocomplete} showDisabledItems={true} />
|
|
85
|
-
</FormField.Field>
|
|
86
|
-
</FormField>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
-
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {
|
|
4
|
-
Combobox,
|
|
5
|
-
ComboboxProps,
|
|
6
|
-
ComboBoxMenuItemGroup,
|
|
7
|
-
} from '@workday/canvas-kit-labs-react/combobox';
|
|
8
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
9
|
-
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
10
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
11
|
-
|
|
12
|
-
const autocompleteResult = (
|
|
13
|
-
textModifier: number,
|
|
14
|
-
disabled: boolean
|
|
15
|
-
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
-
<StyledMenuItem aria-disabled={disabled}>
|
|
17
|
-
Result{' '}
|
|
18
|
-
<span>
|
|
19
|
-
num<span>ber</span>
|
|
20
|
-
</span>{' '}
|
|
21
|
-
{textModifier}
|
|
22
|
-
</StyledMenuItem>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const simpleAutoComplete = (count: number, showDisabledItems, total = 5) =>
|
|
26
|
-
Array.apply(null, Array(count))
|
|
27
|
-
.map((_, i) => autocompleteResult(i, showDisabledItems && i === 0))
|
|
28
|
-
.splice(0, total);
|
|
29
|
-
|
|
30
|
-
const groupOfResults = (
|
|
31
|
-
count: number,
|
|
32
|
-
showDisabledItems: boolean,
|
|
33
|
-
groupHeading: ReactNode = 'Group'
|
|
34
|
-
): ComboBoxMenuItemGroup => ({
|
|
35
|
-
header: (
|
|
36
|
-
<StyledMenuItem>
|
|
37
|
-
<strong>{groupHeading}</strong>
|
|
38
|
-
</StyledMenuItem>
|
|
39
|
-
),
|
|
40
|
-
items: simpleAutoComplete(count, showDisabledItems, 10),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const Autocomplete: FC<
|
|
44
|
-
Omit<ComboboxProps, 'children'> & {
|
|
45
|
-
group?: boolean;
|
|
46
|
-
showDisabledItems?: boolean;
|
|
47
|
-
}
|
|
48
|
-
> = ({showClearButton, group, showDisabledItems = false, ...props}) => {
|
|
49
|
-
const [currentText, setCurrentText] = React.useState('');
|
|
50
|
-
|
|
51
|
-
const autocompleteCallback = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
52
|
-
setCurrentText(event.target.value);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const textLength = currentText.length;
|
|
56
|
-
const groupLength = Math.floor(textLength / 2);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<Combobox
|
|
60
|
-
autocompleteItems={
|
|
61
|
-
group
|
|
62
|
-
? [
|
|
63
|
-
groupOfResults(groupLength, showDisabledItems, <em>Animals</em>),
|
|
64
|
-
groupOfResults(Math.min(1, groupLength), showDisabledItems, 'Cars'),
|
|
65
|
-
]
|
|
66
|
-
: simpleAutoComplete(textLength, showDisabledItems, 10)
|
|
67
|
-
}
|
|
68
|
-
onChange={autocompleteCallback}
|
|
69
|
-
showClearButton={showClearButton == null ? true : showClearButton}
|
|
70
|
-
labelId="autocomplete-123"
|
|
71
|
-
initialValue="Test"
|
|
72
|
-
{...props}
|
|
73
|
-
>
|
|
74
|
-
<TextInput placeholder="Autocomplete" />
|
|
75
|
-
</Combobox>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default () => {
|
|
80
|
-
return (
|
|
81
|
-
<FormField id="autocomplete-123">
|
|
82
|
-
<FormField.Label>Group of results</FormField.Label>
|
|
83
|
-
<FormField.Field>
|
|
84
|
-
<FormField.Input as={Autocomplete} group={true} />
|
|
85
|
-
</FormField.Field>
|
|
86
|
-
</FormField>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
-
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {
|
|
4
|
-
Combobox,
|
|
5
|
-
ComboboxProps,
|
|
6
|
-
ComboBoxMenuItemGroup,
|
|
7
|
-
} from '@workday/canvas-kit-labs-react/combobox';
|
|
8
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
9
|
-
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
10
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
11
|
-
|
|
12
|
-
const autocompleteResult = (
|
|
13
|
-
textModifier: number,
|
|
14
|
-
disabled: boolean
|
|
15
|
-
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
-
<StyledMenuItem aria-disabled={disabled}>
|
|
17
|
-
Result
|
|
18
|
-
<span>
|
|
19
|
-
num<span>ber</span>
|
|
20
|
-
</span>
|
|
21
|
-
{textModifier}
|
|
22
|
-
</StyledMenuItem>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const simpleAutoComplete = (count: number, showDisabledItems, total = 5) =>
|
|
26
|
-
Array.apply(null, Array(count))
|
|
27
|
-
.map((_, i) => autocompleteResult(i, showDisabledItems && i === 0))
|
|
28
|
-
.splice(0, total);
|
|
29
|
-
|
|
30
|
-
const groupOfResults = (
|
|
31
|
-
count: number,
|
|
32
|
-
showDisabledItems: boolean,
|
|
33
|
-
groupHeading: ReactNode = 'Group'
|
|
34
|
-
): ComboBoxMenuItemGroup => ({
|
|
35
|
-
header: (
|
|
36
|
-
<StyledMenuItem>
|
|
37
|
-
<strong>{groupHeading}</strong>
|
|
38
|
-
</StyledMenuItem>
|
|
39
|
-
),
|
|
40
|
-
items: simpleAutoComplete(count, showDisabledItems, 10),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const Autocomplete: FC<
|
|
44
|
-
Omit<ComboboxProps, 'children'> & {
|
|
45
|
-
group?: boolean;
|
|
46
|
-
showDisabledItems?: boolean;
|
|
47
|
-
}
|
|
48
|
-
> = ({showClearButton, group, showDisabledItems = false, ...props}) => {
|
|
49
|
-
const [currentText, setCurrentText] = React.useState('');
|
|
50
|
-
|
|
51
|
-
const autocompleteCallback = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
52
|
-
setCurrentText(event.target.value);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const textLength = currentText.length;
|
|
56
|
-
const groupLength = Math.floor(textLength / 2);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<Combobox
|
|
60
|
-
autocompleteItems={
|
|
61
|
-
group
|
|
62
|
-
? [
|
|
63
|
-
groupOfResults(groupLength, showDisabledItems, <em>Animals</em>),
|
|
64
|
-
groupOfResults(Math.min(1, groupLength), showDisabledItems, 'Cars'),
|
|
65
|
-
]
|
|
66
|
-
: simpleAutoComplete(textLength, showDisabledItems, 10)
|
|
67
|
-
}
|
|
68
|
-
onChange={autocompleteCallback}
|
|
69
|
-
showClearButton={showClearButton == null ? true : showClearButton}
|
|
70
|
-
labelId="autocomplete-123"
|
|
71
|
-
initialValue="Test"
|
|
72
|
-
{...props}
|
|
73
|
-
>
|
|
74
|
-
<TextInput data-width="ck-formfield-width" placeholder="Autocomplete" />
|
|
75
|
-
</Combobox>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default () => {
|
|
80
|
-
return (
|
|
81
|
-
<FormField grow={true} id="autocomplete-123">
|
|
82
|
-
<FormField.Label>Grow example</FormField.Label>
|
|
83
|
-
<FormField.Field>
|
|
84
|
-
<FormField.Input as={Autocomplete} />
|
|
85
|
-
</FormField.Field>
|
|
86
|
-
</FormField>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
-
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {
|
|
4
|
-
Combobox,
|
|
5
|
-
ComboboxProps,
|
|
6
|
-
ComboBoxMenuItemGroup,
|
|
7
|
-
} from '@workday/canvas-kit-labs-react/combobox';
|
|
8
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
9
|
-
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
10
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
11
|
-
|
|
12
|
-
const autocompleteResult = (
|
|
13
|
-
textModifier: number,
|
|
14
|
-
disabled: boolean
|
|
15
|
-
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
-
<StyledMenuItem aria-disabled={disabled}>
|
|
17
|
-
Result
|
|
18
|
-
<span>
|
|
19
|
-
num<span>ber</span>
|
|
20
|
-
</span>
|
|
21
|
-
{textModifier}
|
|
22
|
-
</StyledMenuItem>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const simpleAutoComplete = (count: number, showDisabledItems, total = 5) =>
|
|
26
|
-
Array.apply(null, Array(count))
|
|
27
|
-
.map((_, i) => autocompleteResult(i, showDisabledItems && i === 0))
|
|
28
|
-
.splice(0, total);
|
|
29
|
-
|
|
30
|
-
const groupOfResults = (
|
|
31
|
-
count: number,
|
|
32
|
-
showDisabledItems: boolean,
|
|
33
|
-
groupHeading: ReactNode = 'Group'
|
|
34
|
-
): ComboBoxMenuItemGroup => ({
|
|
35
|
-
header: (
|
|
36
|
-
<StyledMenuItem>
|
|
37
|
-
<strong>{groupHeading}</strong>
|
|
38
|
-
</StyledMenuItem>
|
|
39
|
-
),
|
|
40
|
-
items: simpleAutoComplete(count, showDisabledItems, 10),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const Autocomplete: FC<
|
|
44
|
-
Omit<ComboboxProps, 'children'> & {
|
|
45
|
-
group?: boolean;
|
|
46
|
-
showDisabledItems?: boolean;
|
|
47
|
-
}
|
|
48
|
-
> = ({showClearButton, group, showDisabledItems = false, ...props}) => {
|
|
49
|
-
const [currentText, setCurrentText] = React.useState('');
|
|
50
|
-
|
|
51
|
-
const autocompleteCallback = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
52
|
-
setCurrentText(event.target.value);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const textLength = currentText.length;
|
|
56
|
-
const groupLength = Math.floor(textLength / 2);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<Combobox
|
|
60
|
-
autocompleteItems={
|
|
61
|
-
group
|
|
62
|
-
? [
|
|
63
|
-
groupOfResults(groupLength, showDisabledItems, <em>Animals</em>),
|
|
64
|
-
groupOfResults(Math.min(1, groupLength), showDisabledItems, 'Cars'),
|
|
65
|
-
]
|
|
66
|
-
: simpleAutoComplete(textLength, showDisabledItems, 10)
|
|
67
|
-
}
|
|
68
|
-
onChange={autocompleteCallback}
|
|
69
|
-
showClearButton={showClearButton == null ? true : showClearButton}
|
|
70
|
-
labelId="autocomplete-123"
|
|
71
|
-
initialValue="Test"
|
|
72
|
-
{...props}
|
|
73
|
-
>
|
|
74
|
-
<TextInput placeholder="Autocomplete" />
|
|
75
|
-
</Combobox>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default () => {
|
|
80
|
-
return (
|
|
81
|
-
<FormField id="autocomplete-123">
|
|
82
|
-
<FormField.Label>No clear button</FormField.Label>
|
|
83
|
-
<FormField.Field>
|
|
84
|
-
<FormField.Input as={Autocomplete} showClearButton={false} />
|
|
85
|
-
</FormField.Field>
|
|
86
|
-
</FormField>
|
|
87
|
-
);
|
|
88
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Combobox,
|
|
4
|
-
ComboboxProps,
|
|
5
|
-
ComboBoxMenuItemGroup,
|
|
6
|
-
} from '@workday/canvas-kit-labs-react/combobox';
|
|
7
|
-
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
8
|
-
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
9
|
-
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
10
|
-
import {CanvasProvider, ExtractProps} from '@workday/canvas-kit-react/common';
|
|
11
|
-
|
|
12
|
-
const autocompleteResult = (
|
|
13
|
-
textModifier: number,
|
|
14
|
-
disabled: boolean
|
|
15
|
-
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
-
<StyledMenuItem isDisabled={disabled}>
|
|
17
|
-
Result
|
|
18
|
-
<span>
|
|
19
|
-
num<span>ber</span>
|
|
20
|
-
</span>
|
|
21
|
-
{textModifier}
|
|
22
|
-
</StyledMenuItem>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const simpleAutoComplete = (count: number, showDisabledItems, total = 5) =>
|
|
26
|
-
Array.apply(null, Array(count))
|
|
27
|
-
.map((_, i) => autocompleteResult(i, showDisabledItems && i === 0))
|
|
28
|
-
.splice(0, total);
|
|
29
|
-
|
|
30
|
-
const groupOfResults = (
|
|
31
|
-
count: number,
|
|
32
|
-
showDisabledItems: boolean,
|
|
33
|
-
groupHeading: ReactNode = 'Group'
|
|
34
|
-
): ComboBoxMenuItemGroup => ({
|
|
35
|
-
header: (
|
|
36
|
-
<StyledMenuItem>
|
|
37
|
-
<strong>{groupHeading}</strong>
|
|
38
|
-
</StyledMenuItem>
|
|
39
|
-
),
|
|
40
|
-
items: simpleAutoComplete(count, showDisabledItems, 10),
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const Autocomplete: FC<
|
|
44
|
-
Omit<ComboboxProps, 'children'> & {
|
|
45
|
-
group?: boolean;
|
|
46
|
-
showDisabledItems?: boolean;
|
|
47
|
-
}
|
|
48
|
-
> = ({showClearButton, group, showDisabledItems = false, ...props}) => {
|
|
49
|
-
const [currentText, setCurrentText] = React.useState('');
|
|
50
|
-
|
|
51
|
-
const autocompleteCallback = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
52
|
-
setCurrentText(event.target.value);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const textLength = currentText.length;
|
|
56
|
-
const groupLength = Math.floor(textLength / 2);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<Combobox
|
|
60
|
-
autocompleteItems={
|
|
61
|
-
group
|
|
62
|
-
? [
|
|
63
|
-
groupOfResults(groupLength, showDisabledItems, <em>Animals</em>),
|
|
64
|
-
groupOfResults(Math.min(1, groupLength), showDisabledItems, 'Cars'),
|
|
65
|
-
]
|
|
66
|
-
: simpleAutoComplete(textLength, showDisabledItems, 10)
|
|
67
|
-
}
|
|
68
|
-
onChange={autocompleteCallback}
|
|
69
|
-
showClearButton={showClearButton == null ? true : showClearButton}
|
|
70
|
-
labelId="autocomplete-123"
|
|
71
|
-
initialValue="Test"
|
|
72
|
-
{...props}
|
|
73
|
-
>
|
|
74
|
-
<TextInput placeholder="Autocomplete" />
|
|
75
|
-
</Combobox>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default () => {
|
|
80
|
-
return (
|
|
81
|
-
<CanvasProvider dir="rtl">
|
|
82
|
-
<FormField id="rtl-autocomplete-123">
|
|
83
|
-
<FormField.Label>RTL Autocomplete example</FormField.Label>
|
|
84
|
-
<FormField.Field>
|
|
85
|
-
<FormField.Input as={Autocomplete} />
|
|
86
|
-
</FormField.Field>
|
|
87
|
-
</FormField>
|
|
88
|
-
</CanvasProvider>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {ExampleCodeBlock, SymbolDoc, StorybookStatusIndicator} from '@workday/canvas-kit-docs';
|
|
2
|
-
import {InformationHighlight} from '@workday/canvas-kit-react/information-highlight';import Basic from './examples/Basic';
|
|
3
|
-
import Collapsed from './examples/Collapsed';
|
|
4
|
-
import CustomTheme from './examples/CustomTheme';
|
|
5
|
-
import Grow from './examples/Grow';
|
|
6
|
-
import RTL from './examples/RTL';
|
|
7
|
-
import Theming from './examples/Theming';
|
|
8
|
-
import CustomStyles from './examples/CustomStyles';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# Canvas Kit Search Form <StorybookStatusIndicator type="deprecated" />
|
|
12
|
-
|
|
13
|
-
<InformationHighlight className="sb-unstyled" variant="caution" cs={{p: {marginBlock: 0}}}>
|
|
14
|
-
<InformationHighlight.Icon />
|
|
15
|
-
<InformationHighlight.Body>
|
|
16
|
-
`SearchForm` in Labs has been deprecated and will be removed in a future major version. Please
|
|
17
|
-
use `Combobox` in Main instead.
|
|
18
|
-
</InformationHighlight.Body>
|
|
19
|
-
<InformationHighlight.Link href="https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs#usage">
|
|
20
|
-
View Autocomplete Example
|
|
21
|
-
</InformationHighlight.Link>
|
|
22
|
-
</InformationHighlight>
|
|
23
|
-
|
|
24
|
-
`SearchForm` is a search form that contains a `Combobox` for rendering search results. It's
|
|
25
|
-
primarily intended to be used within a `Header`.
|
|
26
|
-
|
|
27
|
-
## Installation
|
|
28
|
-
|
|
29
|
-
```sh
|
|
30
|
-
yarn add @workday/canvas-kit-labs-react
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Usage
|
|
34
|
-
|
|
35
|
-
### Basic Example
|
|
36
|
-
|
|
37
|
-
You will most likely use `SearchForm` within the context of a `Header` component, but it's helpful
|
|
38
|
-
to see its functionality as a standalone component. Below is a basic example that filters results
|
|
39
|
-
based on search input.
|
|
40
|
-
|
|
41
|
-
<ExampleCodeBlock code={Basic} />
|
|
42
|
-
|
|
43
|
-
### Grow
|
|
44
|
-
|
|
45
|
-
If you'd like `SearchForm` to grow to the width of its container, set the `grow` prop to `true`.
|
|
46
|
-
|
|
47
|
-
<ExampleCodeBlock code={Grow} />
|
|
48
|
-
|
|
49
|
-
### Theming
|
|
50
|
-
|
|
51
|
-
`SearchForm` can be themed to use one of the preset `SearchThemes`: `Light`, `Dark`, or
|
|
52
|
-
`Transparent`. Below is an example of `SearchForm` using the `Dark` theme.
|
|
53
|
-
|
|
54
|
-
<ExampleCodeBlock code={Theming} />
|
|
55
|
-
|
|
56
|
-
You can also provide more specific theming values by providing specific `SearchThemeAttributes`.
|
|
57
|
-
|
|
58
|
-
<ExampleCodeBlock code={CustomTheme} />
|
|
59
|
-
|
|
60
|
-
Below is a table of attributes that can be supplied to `SearchForm`:
|
|
61
|
-
|
|
62
|
-
<SymbolDoc name="SearchThemeAttributes" fileName="/labs-react/" />
|
|
63
|
-
|
|
64
|
-
### RTL (Right-To-Left)
|
|
65
|
-
|
|
66
|
-
`SearchForm` provides bidirectional support out of the box. You shouldn't need to provide any
|
|
67
|
-
additional configuration.
|
|
68
|
-
|
|
69
|
-
<ExampleCodeBlock code={RTL} />
|
|
70
|
-
|
|
71
|
-
### Collapsed
|
|
72
|
-
|
|
73
|
-
<ExampleCodeBlock code={Collapsed} />
|
|
74
|
-
|
|
75
|
-
### Custom Styles
|
|
76
|
-
|
|
77
|
-
You can apply custom styles to the component via the `cs` prop. The example below uses CSS Variables
|
|
78
|
-
and
|
|
79
|
-
[createStencil](https://workday.github.io/canvas-kit/?path=/docs/styling-guides-customizing-styles--docs#stencils)
|
|
80
|
-
to create a custom style for the `SearchForm` component.
|
|
81
|
-
|
|
82
|
-
<ExampleCodeBlock code={CustomStyles} />
|
|
83
|
-
|
|
84
|
-
Learn more in our
|
|
85
|
-
[Styling](https://workday.github.io/canvas-kit/?path=/docs/styling-guides-customizing-styles--docs)
|
|
86
|
-
docs.
|
|
87
|
-
|
|
88
|
-
## Component API
|
|
89
|
-
|
|
90
|
-
### SearchForm
|
|
91
|
-
|
|
92
|
-
<SymbolDoc name="SearchForm" fileName="/labs-react/" />
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
3
|
-
import {SearchForm} from '@workday/canvas-kit-labs-react/search-form';
|
|
4
|
-
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
5
|
-
|
|
6
|
-
const initialWineList = [
|
|
7
|
-
'Beaujolais',
|
|
8
|
-
'Bordeaux',
|
|
9
|
-
'Cabernet Sauvignon',
|
|
10
|
-
'Champagne',
|
|
11
|
-
'Chardonnay',
|
|
12
|
-
'Chianti',
|
|
13
|
-
'Malbec',
|
|
14
|
-
'Merlot',
|
|
15
|
-
'Pinot Grigio',
|
|
16
|
-
'Pinot Gris',
|
|
17
|
-
'Pinot Noir',
|
|
18
|
-
'Primitivo',
|
|
19
|
-
'Prosecco',
|
|
20
|
-
'Riesling',
|
|
21
|
-
'Rioja',
|
|
22
|
-
'Rosé',
|
|
23
|
-
'Sauvignon Blanc',
|
|
24
|
-
'Syrah',
|
|
25
|
-
'Zinfandel',
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
export default () => {
|
|
29
|
-
const [wineList, setWineList] = React.useState(initialWineList);
|
|
30
|
-
// Tracking the input value for onSubmit
|
|
31
|
-
const [searchInput, setSearchInput] = React.useState('');
|
|
32
|
-
const menuItems = wineList.map(wine => <StyledMenuItem key={wine}>{wine}</StyledMenuItem>);
|
|
33
|
-
|
|
34
|
-
const filterMenuItems = e => {
|
|
35
|
-
setSearchInput(e.target.value);
|
|
36
|
-
const formattedValue = e.target.value.toLowerCase();
|
|
37
|
-
|
|
38
|
-
// Reset the list if the input is cleared
|
|
39
|
-
if (!formattedValue.length) {
|
|
40
|
-
setWineList(initialWineList);
|
|
41
|
-
} else {
|
|
42
|
-
const filteredItems = initialWineList.filter(wine =>
|
|
43
|
-
wine.toLowerCase().includes(formattedValue)
|
|
44
|
-
);
|
|
45
|
-
setWineList(filteredItems);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const handleSubmit = () => {
|
|
50
|
-
// We don't need to prevent the default event because SearchForm handles that internally
|
|
51
|
-
console.log(`Searching for: ${searchInput}`);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return (
|
|
55
|
-
<Flex minHeight={200} alignItems="flex-start" padding="xs">
|
|
56
|
-
<SearchForm
|
|
57
|
-
autocompleteItems={menuItems}
|
|
58
|
-
onInputChange={filterMenuItems}
|
|
59
|
-
onSubmit={handleSubmit}
|
|
60
|
-
/>
|
|
61
|
-
</Flex>
|
|
62
|
-
);
|
|
63
|
-
};
|