@workday/canvas-kit-docs 15.0.0-alpha.0064-next.0 → 15.0.0-alpha.0075-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 +37756 -40241
- 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 +62 -0
- 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/dist/mdx/{preview-react → react}/pill/Pill.mdx +2 -2
- package/dist/mdx/{preview-react → react}/pill/examples/Basic.tsx +1 -1
- package/dist/mdx/{preview-react → react}/pill/examples/CustomStyles.tsx +1 -1
- package/dist/mdx/{preview-react → react}/pill/examples/WithAvatar.tsx +1 -1
- package/dist/mdx/{preview-react → react}/pill/examples/WithCount.tsx +1 -1
- package/dist/mdx/{preview-react → react}/pill/examples/WithList.tsx +1 -1
- package/dist/mdx/{preview-react → react}/pill/examples/WithReadOnly.tsx +1 -1
- package/dist/mdx/{preview-react → react}/pill/examples/WithRemovable.tsx +1 -1
- 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
- /package/dist/mdx/{preview-react → react}/pill/examples/test-avatar.png +0 -0
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ExampleCodeBlock,
|
|
3
|
-
StorybookStatusIndicator,
|
|
4
|
-
SymbolDoc,
|
|
5
|
-
Specifications,
|
|
6
|
-
} from '@workday/canvas-kit-docs';
|
|
7
|
-
import {InformationHighlight} from '@workday/canvas-kit-react/information-highlight';
|
|
8
|
-
import Basic from './examples/Basic';
|
|
9
|
-
import DisabledItem from './examples/DisabledItem';
|
|
10
|
-
import GroupOfResult from './examples/GroupOfResult';
|
|
11
|
-
import Grow from './examples/Grow';
|
|
12
|
-
import NoClearButton from './examples/NoClearButton';
|
|
13
|
-
import RTL from './examples/RTL';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# Combobox <StorybookStatusIndicator type="deprecated" />
|
|
17
|
-
|
|
18
|
-
<InformationHighlight className="sb-unstyled" variant="caution" cs={{p: {marginBlock: 0}}}>
|
|
19
|
-
<InformationHighlight.Icon />
|
|
20
|
-
<InformationHighlight.Body>
|
|
21
|
-
`Combobox` in Labs has been deprecated and will be removed in a future major version. Please
|
|
22
|
-
use `Combobox` in Main instead.
|
|
23
|
-
</InformationHighlight.Body>
|
|
24
|
-
<InformationHighlight.Link href="https://workday.github.io/canvas-kit/?path=/docs/features-combobox--docs">
|
|
25
|
-
Combobox Docs
|
|
26
|
-
</InformationHighlight.Link>
|
|
27
|
-
</InformationHighlight>
|
|
28
|
-
|
|
29
|
-
The term "Combobox" is based on the
|
|
30
|
-
[Combobox Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/) as defined in the ARIA
|
|
31
|
-
Authoring Practices Guide (APG):
|
|
32
|
-
|
|
33
|
-
> A [combobox](https://w3c.github.io/aria/#combobox) is an input widget with an associated popup
|
|
34
|
-
> that enables users to select a value for the combobox from a collection of possible values.
|
|
35
|
-
|
|
36
|
-
Examples of a "combobox" would be date pickers, autocomplete, and select components.
|
|
37
|
-
|
|
38
|
-
## Installation
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
|
-
yarn add @workday/canvas-kit-react
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Usage
|
|
45
|
-
|
|
46
|
-
### Autocomplete
|
|
47
|
-
|
|
48
|
-
<ExampleCodeBlock code={Basic} />
|
|
49
|
-
|
|
50
|
-
### Grow
|
|
51
|
-
|
|
52
|
-
<ExampleCodeBlock code={Grow} />
|
|
53
|
-
|
|
54
|
-
### No Clear Button
|
|
55
|
-
|
|
56
|
-
<ExampleCodeBlock code={NoClearButton} />
|
|
57
|
-
|
|
58
|
-
### Group Of Result
|
|
59
|
-
|
|
60
|
-
<ExampleCodeBlock code={GroupOfResult} />
|
|
61
|
-
|
|
62
|
-
### Disabled Item
|
|
63
|
-
|
|
64
|
-
<ExampleCodeBlock code={DisabledItem} />
|
|
65
|
-
|
|
66
|
-
### RTL
|
|
67
|
-
|
|
68
|
-
<ExampleCodeBlock code={RTL} />
|
|
@@ -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/" />
|