@workday/canvas-kit-docs 5.2.7 → 5.3.0-next.9
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/commonjs/lib/specs.js +134 -0
- package/dist/es6/lib/specs.js +134 -0
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +296 -0
- package/dist/mdx/labs-react/search-form/SearchForm.mdx +64 -0
- package/dist/mdx/labs-react/search-form/examples/Basic.tsx +61 -0
- package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +72 -0
- package/dist/mdx/labs-react/search-form/examples/Grow.tsx +62 -0
- package/dist/mdx/labs-react/search-form/examples/PropTables.splitProps.tsx +4 -0
- package/dist/mdx/labs-react/search-form/examples/RTL.tsx +70 -0
- package/dist/mdx/labs-react/search-form/examples/Theming.tsx +64 -0
- package/dist/mdx/labs-react/text-input/TextInput.mdx +123 -0
- package/dist/mdx/labs-react/text-input/examples/Alert.tsx +46 -0
- package/dist/mdx/labs-react/text-input/examples/Basic.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/Error.tsx +43 -0
- package/dist/mdx/labs-react/text-input/examples/Grow.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/HiddenLabel.tsx +17 -0
- package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/LoginForm.tsx +100 -0
- package/dist/mdx/labs-react/text-input/examples/Password.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/RefForwarding.tsx +27 -0
- package/dist/mdx/labs-react/text-input/examples/Required.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +51 -0
- package/dist/mdx/labs-react/text-input/examples/ThemedError.tsx +40 -0
- package/dist/mdx/react/text-area/TextArea.mdx +1 -1
- package/package.json +3 -3
|
@@ -5417,6 +5417,140 @@ module.exports = {specifications: [
|
|
|
5417
5417
|
}
|
|
5418
5418
|
]
|
|
5419
5419
|
},
|
|
5420
|
+
{
|
|
5421
|
+
"type": "file",
|
|
5422
|
+
"name": "TextInputLabs.spec.ts",
|
|
5423
|
+
"children": [
|
|
5424
|
+
{
|
|
5425
|
+
"type": "describe",
|
|
5426
|
+
"name": "TextInput",
|
|
5427
|
+
"children": [
|
|
5428
|
+
{
|
|
5429
|
+
"type": "describe",
|
|
5430
|
+
"name": "given the 'Basic' story is rendered",
|
|
5431
|
+
"children": [
|
|
5432
|
+
{
|
|
5433
|
+
"type": "it",
|
|
5434
|
+
"name": "should not have any axe errors"
|
|
5435
|
+
},
|
|
5436
|
+
{
|
|
5437
|
+
"type": "describe",
|
|
5438
|
+
"name": "when clicked",
|
|
5439
|
+
"children": [
|
|
5440
|
+
{
|
|
5441
|
+
"type": "it",
|
|
5442
|
+
"name": "should be focused"
|
|
5443
|
+
}
|
|
5444
|
+
]
|
|
5445
|
+
},
|
|
5446
|
+
{
|
|
5447
|
+
"type": "describe",
|
|
5448
|
+
"name": "when text is entered",
|
|
5449
|
+
"children": [
|
|
5450
|
+
{
|
|
5451
|
+
"type": "it",
|
|
5452
|
+
"name": "should reflect the text typed"
|
|
5453
|
+
}
|
|
5454
|
+
]
|
|
5455
|
+
}
|
|
5456
|
+
]
|
|
5457
|
+
},
|
|
5458
|
+
{
|
|
5459
|
+
"type": "describe",
|
|
5460
|
+
"name": "given the 'Alert' story is rendered",
|
|
5461
|
+
"children": [
|
|
5462
|
+
{
|
|
5463
|
+
"type": "it",
|
|
5464
|
+
"name": "should not have any axe errors"
|
|
5465
|
+
},
|
|
5466
|
+
{
|
|
5467
|
+
"type": "describe",
|
|
5468
|
+
"name": "when clicked",
|
|
5469
|
+
"children": [
|
|
5470
|
+
{
|
|
5471
|
+
"type": "it",
|
|
5472
|
+
"name": "should be focused"
|
|
5473
|
+
}
|
|
5474
|
+
]
|
|
5475
|
+
},
|
|
5476
|
+
{
|
|
5477
|
+
"type": "describe",
|
|
5478
|
+
"name": "when text is entered",
|
|
5479
|
+
"children": [
|
|
5480
|
+
{
|
|
5481
|
+
"type": "it",
|
|
5482
|
+
"name": "should reflect the text typed"
|
|
5483
|
+
}
|
|
5484
|
+
]
|
|
5485
|
+
}
|
|
5486
|
+
]
|
|
5487
|
+
},
|
|
5488
|
+
{
|
|
5489
|
+
"type": "describe",
|
|
5490
|
+
"name": "given the 'Error' story is rendered",
|
|
5491
|
+
"children": [
|
|
5492
|
+
{
|
|
5493
|
+
"type": "it",
|
|
5494
|
+
"name": "should not have any axe errors"
|
|
5495
|
+
},
|
|
5496
|
+
{
|
|
5497
|
+
"type": "describe",
|
|
5498
|
+
"name": "when clicked",
|
|
5499
|
+
"children": [
|
|
5500
|
+
{
|
|
5501
|
+
"type": "it",
|
|
5502
|
+
"name": "should be focused"
|
|
5503
|
+
}
|
|
5504
|
+
]
|
|
5505
|
+
},
|
|
5506
|
+
{
|
|
5507
|
+
"type": "describe",
|
|
5508
|
+
"name": "when text is entered",
|
|
5509
|
+
"children": [
|
|
5510
|
+
{
|
|
5511
|
+
"type": "it",
|
|
5512
|
+
"name": "should reflect the text typed"
|
|
5513
|
+
}
|
|
5514
|
+
]
|
|
5515
|
+
}
|
|
5516
|
+
]
|
|
5517
|
+
},
|
|
5518
|
+
{
|
|
5519
|
+
"type": "describe",
|
|
5520
|
+
"name": "given the 'Disabled' story is rendered",
|
|
5521
|
+
"children": [
|
|
5522
|
+
{
|
|
5523
|
+
"type": "it",
|
|
5524
|
+
"name": "should not have any axe errors"
|
|
5525
|
+
},
|
|
5526
|
+
{
|
|
5527
|
+
"type": "it",
|
|
5528
|
+
"name": "should be disabled"
|
|
5529
|
+
}
|
|
5530
|
+
]
|
|
5531
|
+
},
|
|
5532
|
+
{
|
|
5533
|
+
"type": "describe",
|
|
5534
|
+
"name": "given the 'Placeholder' story is rendered",
|
|
5535
|
+
"children": [
|
|
5536
|
+
{
|
|
5537
|
+
"type": "it",
|
|
5538
|
+
"name": "should not have any axe errors"
|
|
5539
|
+
},
|
|
5540
|
+
{
|
|
5541
|
+
"type": "it",
|
|
5542
|
+
"name": "should render a placeholder text"
|
|
5543
|
+
},
|
|
5544
|
+
{
|
|
5545
|
+
"type": "it",
|
|
5546
|
+
"name": "should reflect the text typed"
|
|
5547
|
+
}
|
|
5548
|
+
]
|
|
5549
|
+
}
|
|
5550
|
+
]
|
|
5551
|
+
}
|
|
5552
|
+
]
|
|
5553
|
+
},
|
|
5420
5554
|
{
|
|
5421
5555
|
"type": "file",
|
|
5422
5556
|
"name": "Toast.spec.ts",
|
package/dist/es6/lib/specs.js
CHANGED
|
@@ -5417,6 +5417,140 @@ module.exports = {specifications: [
|
|
|
5417
5417
|
}
|
|
5418
5418
|
]
|
|
5419
5419
|
},
|
|
5420
|
+
{
|
|
5421
|
+
"type": "file",
|
|
5422
|
+
"name": "TextInputLabs.spec.ts",
|
|
5423
|
+
"children": [
|
|
5424
|
+
{
|
|
5425
|
+
"type": "describe",
|
|
5426
|
+
"name": "TextInput",
|
|
5427
|
+
"children": [
|
|
5428
|
+
{
|
|
5429
|
+
"type": "describe",
|
|
5430
|
+
"name": "given the 'Basic' story is rendered",
|
|
5431
|
+
"children": [
|
|
5432
|
+
{
|
|
5433
|
+
"type": "it",
|
|
5434
|
+
"name": "should not have any axe errors"
|
|
5435
|
+
},
|
|
5436
|
+
{
|
|
5437
|
+
"type": "describe",
|
|
5438
|
+
"name": "when clicked",
|
|
5439
|
+
"children": [
|
|
5440
|
+
{
|
|
5441
|
+
"type": "it",
|
|
5442
|
+
"name": "should be focused"
|
|
5443
|
+
}
|
|
5444
|
+
]
|
|
5445
|
+
},
|
|
5446
|
+
{
|
|
5447
|
+
"type": "describe",
|
|
5448
|
+
"name": "when text is entered",
|
|
5449
|
+
"children": [
|
|
5450
|
+
{
|
|
5451
|
+
"type": "it",
|
|
5452
|
+
"name": "should reflect the text typed"
|
|
5453
|
+
}
|
|
5454
|
+
]
|
|
5455
|
+
}
|
|
5456
|
+
]
|
|
5457
|
+
},
|
|
5458
|
+
{
|
|
5459
|
+
"type": "describe",
|
|
5460
|
+
"name": "given the 'Alert' story is rendered",
|
|
5461
|
+
"children": [
|
|
5462
|
+
{
|
|
5463
|
+
"type": "it",
|
|
5464
|
+
"name": "should not have any axe errors"
|
|
5465
|
+
},
|
|
5466
|
+
{
|
|
5467
|
+
"type": "describe",
|
|
5468
|
+
"name": "when clicked",
|
|
5469
|
+
"children": [
|
|
5470
|
+
{
|
|
5471
|
+
"type": "it",
|
|
5472
|
+
"name": "should be focused"
|
|
5473
|
+
}
|
|
5474
|
+
]
|
|
5475
|
+
},
|
|
5476
|
+
{
|
|
5477
|
+
"type": "describe",
|
|
5478
|
+
"name": "when text is entered",
|
|
5479
|
+
"children": [
|
|
5480
|
+
{
|
|
5481
|
+
"type": "it",
|
|
5482
|
+
"name": "should reflect the text typed"
|
|
5483
|
+
}
|
|
5484
|
+
]
|
|
5485
|
+
}
|
|
5486
|
+
]
|
|
5487
|
+
},
|
|
5488
|
+
{
|
|
5489
|
+
"type": "describe",
|
|
5490
|
+
"name": "given the 'Error' story is rendered",
|
|
5491
|
+
"children": [
|
|
5492
|
+
{
|
|
5493
|
+
"type": "it",
|
|
5494
|
+
"name": "should not have any axe errors"
|
|
5495
|
+
},
|
|
5496
|
+
{
|
|
5497
|
+
"type": "describe",
|
|
5498
|
+
"name": "when clicked",
|
|
5499
|
+
"children": [
|
|
5500
|
+
{
|
|
5501
|
+
"type": "it",
|
|
5502
|
+
"name": "should be focused"
|
|
5503
|
+
}
|
|
5504
|
+
]
|
|
5505
|
+
},
|
|
5506
|
+
{
|
|
5507
|
+
"type": "describe",
|
|
5508
|
+
"name": "when text is entered",
|
|
5509
|
+
"children": [
|
|
5510
|
+
{
|
|
5511
|
+
"type": "it",
|
|
5512
|
+
"name": "should reflect the text typed"
|
|
5513
|
+
}
|
|
5514
|
+
]
|
|
5515
|
+
}
|
|
5516
|
+
]
|
|
5517
|
+
},
|
|
5518
|
+
{
|
|
5519
|
+
"type": "describe",
|
|
5520
|
+
"name": "given the 'Disabled' story is rendered",
|
|
5521
|
+
"children": [
|
|
5522
|
+
{
|
|
5523
|
+
"type": "it",
|
|
5524
|
+
"name": "should not have any axe errors"
|
|
5525
|
+
},
|
|
5526
|
+
{
|
|
5527
|
+
"type": "it",
|
|
5528
|
+
"name": "should be disabled"
|
|
5529
|
+
}
|
|
5530
|
+
]
|
|
5531
|
+
},
|
|
5532
|
+
{
|
|
5533
|
+
"type": "describe",
|
|
5534
|
+
"name": "given the 'Placeholder' story is rendered",
|
|
5535
|
+
"children": [
|
|
5536
|
+
{
|
|
5537
|
+
"type": "it",
|
|
5538
|
+
"name": "should not have any axe errors"
|
|
5539
|
+
},
|
|
5540
|
+
{
|
|
5541
|
+
"type": "it",
|
|
5542
|
+
"name": "should render a placeholder text"
|
|
5543
|
+
},
|
|
5544
|
+
{
|
|
5545
|
+
"type": "it",
|
|
5546
|
+
"name": "should reflect the text typed"
|
|
5547
|
+
}
|
|
5548
|
+
]
|
|
5549
|
+
}
|
|
5550
|
+
]
|
|
5551
|
+
}
|
|
5552
|
+
]
|
|
5553
|
+
},
|
|
5420
5554
|
{
|
|
5421
5555
|
"type": "file",
|
|
5422
5556
|
"name": "Toast.spec.ts",
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# Canvas Kit 6.0 Migration Guide
|
|
2
|
+
|
|
3
|
+
Below are the breaking changes made in Canvas Kit v6. Please
|
|
4
|
+
[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have
|
|
5
|
+
any questions about the update.
|
|
6
|
+
|
|
7
|
+
- [Codemod](#codemod)
|
|
8
|
+
- [Component Deprecations](#component-deprecations)
|
|
9
|
+
- [Cookie Banner](#cookie-banner)
|
|
10
|
+
- [Header & Global Header](#header--global-header)
|
|
11
|
+
- [Page Header](#page-header)
|
|
12
|
+
- [Component Migrations](#component-migrations)
|
|
13
|
+
- [Search Bar](#search-bar)
|
|
14
|
+
|
|
15
|
+
## Codemod
|
|
16
|
+
|
|
17
|
+
Please use our [codemod package](https://github.com/Workday/canvas-kit/tree/master/modules/codemod)
|
|
18
|
+
to automatically update your code to work with a majority of the breaking changes in the migration
|
|
19
|
+
from Canvas Kit v5 to v6:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
> npx @workday/canvas-kit-codemod v6 [path]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> Note: This codemod only works on `.js`, `.jsx`, `.ts`, and `.tsx` extensions. You may need to make
|
|
26
|
+
> some manual changes in other file types (`.json`, `.mdx`, `.md`, etc.).
|
|
27
|
+
|
|
28
|
+
> Note: You may need to run your linter after executing the codemod, as it's resulting formatting
|
|
29
|
+
> (spacing, quotes, etc.) may not match your project's styling.
|
|
30
|
+
|
|
31
|
+
**Breaking changes accounted for by this codemod will be marked with a 🤖.**
|
|
32
|
+
|
|
33
|
+
**Please verify all changes made by the codemod. As a safety precaution, we recommend committing the
|
|
34
|
+
changes from the codemod as a single isolated commit (separate from other changes) so you can
|
|
35
|
+
rollback more easily if necessary.**
|
|
36
|
+
|
|
37
|
+
[Let us know](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you
|
|
38
|
+
encounter any issues or use cases that we've missed. The `@workday/canvas-kit-codemod` package will
|
|
39
|
+
help us maintain additional codemod transforms to make future migrations easier.
|
|
40
|
+
|
|
41
|
+
## Component Deprecations
|
|
42
|
+
|
|
43
|
+
### Deprecation Types
|
|
44
|
+
|
|
45
|
+
There are two types of deprecations: soft and hard.
|
|
46
|
+
|
|
47
|
+
#### Soft Deprecation
|
|
48
|
+
|
|
49
|
+
A soft-deprecated component is still available with its full functionality, but it will have been
|
|
50
|
+
renamed with a prefix to indicate its soft-deprecated status. It will also include a console warning
|
|
51
|
+
to announce its deprecation. This warning will only be triggered on the component's initial render.
|
|
52
|
+
|
|
53
|
+
Soft-deprecated types and utilities will also be renamed but generally will not trigger a console
|
|
54
|
+
warning.
|
|
55
|
+
|
|
56
|
+
#### Hard Deprecation
|
|
57
|
+
|
|
58
|
+
A hard-deprecated component or package is no longer available. You will need to follow the method
|
|
59
|
+
prescribed in our migration guide to update your application. Please reach out to our team directly
|
|
60
|
+
if you need additional help.
|
|
61
|
+
|
|
62
|
+
### Cookie Banner
|
|
63
|
+
|
|
64
|
+
We are [soft deprecating](#soft-deprecation) `CookieBanner`. It has been renamed to
|
|
65
|
+
`DeprecatedCookieBanner`. Similarly, `CookieBannerProps` has been renamed to
|
|
66
|
+
`DeprecatedCookieBannerProps`. You may continue to use this component exactly as you did in v5, but
|
|
67
|
+
note that we plan to [hard-deprecate](#hard-deprecation) it in Canvas Kit v7.
|
|
68
|
+
|
|
69
|
+
🤖 The codemod will rename `CookieBanner` and `CookieBannerProps` to their deprecated names:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
// v5
|
|
73
|
+
import CookieBanner, {CookieBannerProps} from '@workday/canvas-kit-react/cookie-banner';
|
|
74
|
+
|
|
75
|
+
export const CustomCookieBanner = (props: CookieBannerProps) => {
|
|
76
|
+
return <CookieBanner notice={CookieBanner.DefaultNotice} {...props} />;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// v6
|
|
80
|
+
import DeprecatedCookieBanner, {
|
|
81
|
+
DeprecatedCookieBannerProps,
|
|
82
|
+
} from '@workday/canvas-kit-react/cookie-banner';
|
|
83
|
+
|
|
84
|
+
export const CustomCookieBanner = (props: DeprecatedCookieBannerProps) => {
|
|
85
|
+
return <DeprecatedCookieBanner notice={DeprecatedCookieBanner.DefaultNotice} {...props} />;
|
|
86
|
+
};
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
// v5
|
|
91
|
+
import {CookieBanner, CookieBannerProps} from '@workday/canvas-kit-react';
|
|
92
|
+
|
|
93
|
+
interface CustomCookieBannerProps extends CookieBannerProps {
|
|
94
|
+
// custom page header props
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const CustomCookieBanner = (props: CustomCookieBannerProps) => {
|
|
98
|
+
return <CookieBanner notice={CookieBanner.DefaultNotice} {...props} />;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// v6
|
|
102
|
+
import {DeprecatedCookieBanner, DeprecatedCookieBannerProps} from '@workday/canvas-kit-react';
|
|
103
|
+
|
|
104
|
+
interface CustomCookieBannerProps extends DeprecatedCookieBannerProps {
|
|
105
|
+
// custom page header props
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const CustomCookieBanner = (props: CustomCookieBannerProps) => {
|
|
109
|
+
return <DeprecatedCookieBanner notice={DeprecatedCookieBanner.DefaultNotice} {...props} />;
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Header & Global Header
|
|
114
|
+
|
|
115
|
+
We are [soft deprecating](#soft-deprecation) `Header` and `GlobalHeader` and their related exports.
|
|
116
|
+
They has been renamed to `DeprecatedHeader` and `DeprecatedGlobalHeader`, respectively. You may
|
|
117
|
+
continue to use these components exactly as you did in v5, but note that we plan to
|
|
118
|
+
[hard-deprecate](#hard-deprecation) this package in Canvas Kit v7.
|
|
119
|
+
|
|
120
|
+
> Note: `SearchBar` is not being deprecated but will instead move to its own dedictated package. You
|
|
121
|
+
> can read more [here](#search-bar).
|
|
122
|
+
|
|
123
|
+
🤖 The codemod will handle all these changes automatically:
|
|
124
|
+
|
|
125
|
+
- Rename import specifiers
|
|
126
|
+
- `DubLogoTitle` becomes `DeprecatedDubLogoTitle`
|
|
127
|
+
- `GlobalHeader` becomes `DeprecatedGlobalHeader`
|
|
128
|
+
- `Header` becomes `DeprecatedHeader`
|
|
129
|
+
- `HeaderHeight` becomes `DeprecatedHeaderHeight`
|
|
130
|
+
- `HeaderTheme` becomes `DeprecatedHeaderTheme`
|
|
131
|
+
- `HeaderVariant` becomes `DeprecatedHeaderVariant`
|
|
132
|
+
- `ThemeAttributes` becomes `DeprecatedHeaderThemeAttributes`
|
|
133
|
+
- `Themes` becomes `DeprecatedHeaderThemes`
|
|
134
|
+
- `WorkdayLogoTitle` becomes `DeprecatedWorkdayLogoTitle`
|
|
135
|
+
- `themes` becomes `deprecatedHeaderThemes`
|
|
136
|
+
- Rename JSX identifiers
|
|
137
|
+
- `<DubLogoTitle>` becomes `<DeprecatedDubLogoTitle>`
|
|
138
|
+
- `<GlobalHeader>` becomes `<DeprecatedGlobalHeader>`
|
|
139
|
+
- `<Header>` becomes `<DeprecatedHeader>`
|
|
140
|
+
- `<WorkdayLogoTitle>` becomes `<DeprecatedWorkdayLogoTitle>`
|
|
141
|
+
- Rename type references and interface declarations
|
|
142
|
+
- `type CustomHeaderHeight = HeaderHeight;` becomes
|
|
143
|
+
`type CustomHeaderHeight = DeprecatedHeaderHeight;`
|
|
144
|
+
- `type CustomHeaderTheme = HeaderTheme;` becomes
|
|
145
|
+
`type CustomHeaderTheme = DeprecatedHeaderTheme;`
|
|
146
|
+
- `type CustomHeaderVariant = HeaderVariant;` becomes
|
|
147
|
+
`type CustomHeaderVariant = DeprecatedHeaderVariant;`
|
|
148
|
+
- `type CustomThemeAttributes = ThemeAttributes;` becomes
|
|
149
|
+
`type CustomThemeAttributes = DeprecatedHeaderThemeAttributes;`
|
|
150
|
+
- `type CustomThemes = Themes;` becomes `type CustomThemes = DeprecatedHeaderThemes;`
|
|
151
|
+
- Rename member expressions
|
|
152
|
+
- `HeaderHeight.Small` becomes `DeprecatedHeaderHeight.Small`
|
|
153
|
+
- `HeaderTheme.White` becomes `DeprecatedHeaderTheme.White`
|
|
154
|
+
- `HeaderVariant.Full` becomes `DeprecatedHeaderVariant.Full`
|
|
155
|
+
- `themes.Blue` becomes `deprecatedHeaderThemes.Blue`
|
|
156
|
+
- `Header.Variant.Global` becomes `DeprecatedHeader.Variant.Global`
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
// v5
|
|
160
|
+
import Header, {DubLogoTitle, GlobalHeader} from '@workday/canvas-kit-labs-react/header';
|
|
161
|
+
|
|
162
|
+
const CustomGlobalHeader = props => {
|
|
163
|
+
return (
|
|
164
|
+
<GlobalHeader
|
|
165
|
+
brand={
|
|
166
|
+
<a href="#">
|
|
167
|
+
<DubLogoTitle themeColor={Header.Theme.White} />
|
|
168
|
+
</a>
|
|
169
|
+
}
|
|
170
|
+
{...props}
|
|
171
|
+
/>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// v6
|
|
176
|
+
import DeprecatedHeader, {
|
|
177
|
+
DeprecatedDubLogoTitle,
|
|
178
|
+
DeprecatedGlobalHeader,
|
|
179
|
+
} from '@workday/canvas-kit-labs-react/header';
|
|
180
|
+
|
|
181
|
+
const CustomGlobalHeader = props => {
|
|
182
|
+
return (
|
|
183
|
+
<DeprecatedGlobalHeader
|
|
184
|
+
brand={
|
|
185
|
+
<a href="#">
|
|
186
|
+
<DeprecatedDubLogoTitle themeColor={DeprecatedHeader.Theme.White} />
|
|
187
|
+
</a>
|
|
188
|
+
}
|
|
189
|
+
{...props}
|
|
190
|
+
/>
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Page Header
|
|
196
|
+
|
|
197
|
+
We are [soft-deprecating](#soft-deprecation) `PageHeader`. It has been renamed to
|
|
198
|
+
`DeprecatedPageHeader`. Similarly, `PageHeaderProps` has been renamed to
|
|
199
|
+
`DeprecatedPageHeaderProps`. You may continue to use this component exactly as you did in v5, but
|
|
200
|
+
note that we plan to [hard-deprecate](#hard-deprecation) it in Canvas Kit v7.
|
|
201
|
+
|
|
202
|
+
🤖 The codemod will rename `PageHeader` and `PageHeaderProps` to their deprecated names:
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
// v5
|
|
206
|
+
import PageHeader, {PageHeaderProps} from '@workday/canvas-kit-react/page-header';
|
|
207
|
+
|
|
208
|
+
export const CustomPageHeader = (props: PageHeaderProps) => {
|
|
209
|
+
return <PageHeader {...props} />;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// v6
|
|
213
|
+
import DeprecatedPageHeader, {
|
|
214
|
+
DeprecatedPageHeaderProps,
|
|
215
|
+
} from '@workday/canvas-kit-react/page-header';
|
|
216
|
+
|
|
217
|
+
export const CustomPageHeader = (props: DeprecatedPageHeaderProps) => {
|
|
218
|
+
return <DeprecatedPageHeader {...props} />;
|
|
219
|
+
};
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
// v5
|
|
224
|
+
import {PageHeader, PageHeaderProps} from '@workday/canvas-kit-react';
|
|
225
|
+
|
|
226
|
+
interface CustomPageHeaderProps extends PageHeaderProps {
|
|
227
|
+
// custom page header props
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export const CustomPageHeader = (props: CustomPageHeaderProps) => {
|
|
231
|
+
return <PageHeader {...props} />;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// v6
|
|
235
|
+
import {DeprecatedPageHeader, DeprecatedPageHeaderProps} from '@workday/canvas-kit-react';
|
|
236
|
+
|
|
237
|
+
interface CustomPageHeaderProps extends DeprecatedPageHeaderProps {
|
|
238
|
+
// custom page header props
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export const CustomPageHeader = (props: CustomPageHeaderProps) => {
|
|
242
|
+
return <DeprecatedPageHeader {...props} />;
|
|
243
|
+
};
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Component Migrations
|
|
247
|
+
|
|
248
|
+
### Search Bar
|
|
249
|
+
|
|
250
|
+
`SeachBar` is being renamed to `SearchForm` and is moving out of
|
|
251
|
+
`@workday/canvas-kit-labs-react/header` into its own dedicated package,
|
|
252
|
+
`@workday/canvas-kit-labs-react/search-form`. The component has not been modified and you may
|
|
253
|
+
continue to use this component exactly as you did in v5.
|
|
254
|
+
|
|
255
|
+
🤖 The codemod will handle all these changes automatically:
|
|
256
|
+
|
|
257
|
+
- Rename import sources
|
|
258
|
+
- `@workday/canvas-kit-labs-react/header` becomes `@workday/canvas-kit-labs-react/search-form`
|
|
259
|
+
- Rename import specifiers
|
|
260
|
+
- `SearchBar` becomes `SearchForm`
|
|
261
|
+
- `SearchBarProps` becomes `SearchFormProps`
|
|
262
|
+
- `SearchBarState` becomes `SearchFormState`
|
|
263
|
+
- Rename JSX identifiers
|
|
264
|
+
- `<SearchBar>` becomes `<SearchForm>`
|
|
265
|
+
- Rename type references and interface declarations
|
|
266
|
+
- `type CustomSearchProps = SearchBarProps;` becomes `type CustomSearchProps = SearchFormProps;`
|
|
267
|
+
- `interface CustomSearchProps extends SearchBarProps` becomes
|
|
268
|
+
`interface CustomSearchProps extends SearchFormProps`
|
|
269
|
+
|
|
270
|
+
```tsx
|
|
271
|
+
// v5
|
|
272
|
+
import {
|
|
273
|
+
SearchBar,
|
|
274
|
+
SearchBarProps,
|
|
275
|
+
SearchBarState,
|
|
276
|
+
SearchThemeAttributes,
|
|
277
|
+
SearchTheme,
|
|
278
|
+
} from '@workday/canvas-kit-labs-react/header';
|
|
279
|
+
|
|
280
|
+
const CustomSearchForm = (props: SearchFormProps) => {
|
|
281
|
+
return <SearchForm searchTheme={SearchTheme.Dark} {...props} />;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// v6
|
|
285
|
+
import {
|
|
286
|
+
SearchForm,
|
|
287
|
+
SearchFormProps,
|
|
288
|
+
SearchFormState,
|
|
289
|
+
SearchThemeAttributes,
|
|
290
|
+
SearchTheme,
|
|
291
|
+
} from '@workday/canvas-kit-labs-react/search-form';
|
|
292
|
+
|
|
293
|
+
const CustomSearchForm = (props: SearchFormProps) => {
|
|
294
|
+
return <SearchForm searchTheme={SearchTheme.Dark} {...props} />;
|
|
295
|
+
};
|
|
296
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {SearchForm} from '@workday/canvas-kit-labs-react/search-form';
|
|
2
|
+
// examples
|
|
3
|
+
import Basic from './examples/Basic';
|
|
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 ThemeAttributes from './examples/PropTables.splitProps';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Canvas Kit Search Form
|
|
12
|
+
|
|
13
|
+
`SearchForm` is a search form that contains a `Combobox` for rendering search results. It's
|
|
14
|
+
primarily intended to be used within a `Header`.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
yarn add @workday/canvas-kit-labs-react
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Basic Example
|
|
25
|
+
|
|
26
|
+
You will most likely use `SearchForm` within the context of a `Header` component, but it's helpful
|
|
27
|
+
to see its functionality as a standalone component. Below is a basic example that filters results
|
|
28
|
+
based on search input.
|
|
29
|
+
|
|
30
|
+
<ExampleCodeBlock code={Basic} />
|
|
31
|
+
|
|
32
|
+
### Grow
|
|
33
|
+
|
|
34
|
+
If you'd like `SearchForm` to grow to the width of its container, set the `grow` prop to
|
|
35
|
+
`true`.
|
|
36
|
+
|
|
37
|
+
<ExampleCodeBlock code={Grow} />
|
|
38
|
+
|
|
39
|
+
### Theming
|
|
40
|
+
|
|
41
|
+
`SearchForm` can be themed to use one of the preset `SearchThemes`: `Light`, `Dark`, or
|
|
42
|
+
`Transparent`. Below is an example of `SearchForm` using the `Dark` theme.
|
|
43
|
+
|
|
44
|
+
<ExampleCodeBlock code={Theming} />
|
|
45
|
+
|
|
46
|
+
You can also provide more specific theming values by providing specific `SearchThemeAttributes`.
|
|
47
|
+
|
|
48
|
+
<ExampleCodeBlock code={CustomTheme} />
|
|
49
|
+
|
|
50
|
+
Below is a table of attributes that can be supplied to `SearchForm`:
|
|
51
|
+
|
|
52
|
+
<ArgsTable of={ThemeAttributes} />
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### RTL (Right-To-Left)
|
|
56
|
+
|
|
57
|
+
`SearchForm` provides bidirectional support out of the box. You shouldn't need to provide any
|
|
58
|
+
additional configuration.
|
|
59
|
+
|
|
60
|
+
<ExampleCodeBlock code={RTL} />
|
|
61
|
+
|
|
62
|
+
## Props
|
|
63
|
+
|
|
64
|
+
<ArgsTable of={SearchForm} />
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
3
|
+
import {SearchForm} from '@workday/canvas-kit-labs-react/search-form';
|
|
4
|
+
import {Flex} from '@workday/canvas-kit-labs-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 => <MenuItem key={wine}>{wine}</MenuItem>);
|
|
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 = wineList.filter(wine => wine.toLowerCase().startsWith(formattedValue));
|
|
43
|
+
setWineList(filteredItems);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const handleSubmit = () => {
|
|
48
|
+
// We don't need to prevent the default event because SearchForm handles that internally
|
|
49
|
+
console.log(`Searching for: ${searchInput}`);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Flex minHeight={200} alignItems="flex-start" padding="xs">
|
|
54
|
+
<SearchForm
|
|
55
|
+
autocompleteItems={menuItems}
|
|
56
|
+
onInputChange={filterMenuItems}
|
|
57
|
+
onSubmit={handleSubmit}
|
|
58
|
+
/>
|
|
59
|
+
</Flex>
|
|
60
|
+
);
|
|
61
|
+
};
|