@workday/canvas-kit-docs 7.0.0-alpha.96-next.22 → 7.0.0-alpha.97-next.23
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.
|
@@ -785,6 +785,65 @@ anyway since the buttons will no longer scroll with overflowed `Body` content.
|
|
|
785
785
|
</Modal.Card>
|
|
786
786
|
```
|
|
787
787
|
|
|
788
|
+
#### Popup Model
|
|
789
|
+
|
|
790
|
+
In addition to the other [Model Changes](#model-changes), the `show` and `hide` events of all
|
|
791
|
+
disclosure-type models have been updated to remove the extra event wrapper. This change allows
|
|
792
|
+
developers to directly attach the `show` and `hide` events to React event handlers.
|
|
793
|
+
|
|
794
|
+
The following models were affected:
|
|
795
|
+
|
|
796
|
+
- `useDisclosureModel`
|
|
797
|
+
- `usePopupModel`
|
|
798
|
+
- `useModalModel`
|
|
799
|
+
- `useDisclosureModel`
|
|
800
|
+
|
|
801
|
+
```tsx
|
|
802
|
+
// v6
|
|
803
|
+
<button onClick={() => model.events.show()} /> // most use-cases look like this
|
|
804
|
+
<button onClick={event => model.events.show({event})} />
|
|
805
|
+
|
|
806
|
+
// v7
|
|
807
|
+
<button onClick={model.events.show} />
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
Removing the object wrapper around the `event` allows us to directly pass the `show` or `hide` event
|
|
811
|
+
to the `onClick` handler which is much more convenient. We couldn't find many uses of the `event` in
|
|
812
|
+
the wild, so the impact will be minimal. Most usage of `show` or `hide` events are called without
|
|
813
|
+
`event`, so this change will not impact most people. There is **no** codemod for this change,
|
|
814
|
+
because the usage is very difficult to detect since most people pass a callback that doesn't take
|
|
815
|
+
parameters.
|
|
816
|
+
|
|
817
|
+
Guards and callback signatures have also changed to remove the object wrapper around the `event`.
|
|
818
|
+
The following v6 example includes the [Model Changes](#model-changes) which this change compounds
|
|
819
|
+
upon.
|
|
820
|
+
|
|
821
|
+
```tsx
|
|
822
|
+
// v6
|
|
823
|
+
const model = usePopupModel({
|
|
824
|
+
shouldShow({data: {event}, state}) {
|
|
825
|
+
console.log(event, state);
|
|
826
|
+
},
|
|
827
|
+
onShow({data: {event}, prevState}) {
|
|
828
|
+
console.log(event, prevState);
|
|
829
|
+
},
|
|
830
|
+
});
|
|
831
|
+
|
|
832
|
+
// v7
|
|
833
|
+
const model = usePopupModel({
|
|
834
|
+
shouldShow(event, state) {
|
|
835
|
+
console.log(event, state);
|
|
836
|
+
},
|
|
837
|
+
onShow(event, prevState) {
|
|
838
|
+
console.log(event, prevState);
|
|
839
|
+
},
|
|
840
|
+
});
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
🤖 The codemod will update all inline guards and callbacks defined like they are in this example. If
|
|
844
|
+
a guard or callback was defined outside the model config block, it will not be covered by the
|
|
845
|
+
codemod.
|
|
846
|
+
|
|
788
847
|
---
|
|
789
848
|
|
|
790
849
|
### Segmented Control
|
|
@@ -19,9 +19,9 @@ const ContextMenuTarget = createComponent('div')({
|
|
|
19
19
|
|
|
20
20
|
const onContextMenu = (event: React.MouseEvent) => {
|
|
21
21
|
if (model.state.visibility === 'visible') {
|
|
22
|
-
model.events.hide(
|
|
22
|
+
model.events.hide(event);
|
|
23
23
|
} else if (model.state.visibility === 'hidden') {
|
|
24
|
-
model.events.show(
|
|
24
|
+
model.events.show(event);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Prevent the default context menu from showing to avoid double menus
|
|
@@ -17,7 +17,7 @@ const CookieBanner = createComponent('div')({
|
|
|
17
17
|
subComponents: {Item: CookieBannerItem},
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
export
|
|
20
|
+
export const Basic = () => {
|
|
21
21
|
const DefaultNotice = `We use cookies to ensure that we give you the best experience on our website.
|
|
22
22
|
If you continue without changing your settings, we'll assume that you are willing to receive cookies.`;
|
|
23
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.97-next.23+36224fdd",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@storybook/csf": "0.0.1",
|
|
44
|
-
"@workday/canvas-kit-react": "^7.0.0-alpha.
|
|
44
|
+
"@workday/canvas-kit-react": "^7.0.0-alpha.97-next.23+36224fdd"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"fs-extra": "^10.0.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"mkdirp": "^1.0.3",
|
|
50
50
|
"typescript": "4.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "36224fddf0e1c2382b1cbbeb1a2a2d356bfd22a3"
|
|
53
53
|
}
|