@workday/canvas-kit-labs-react 8.0.0-alpha.172-next.1 → 8.0.0-alpha.174-next.2
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/index.d.ts +1 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/toast/index.d.ts +3 -0
- package/dist/commonjs/toast/index.d.ts.map +1 -0
- package/dist/commonjs/toast/index.js +14 -0
- package/dist/commonjs/toast/lib/Toast.d.ts +36 -0
- package/dist/commonjs/toast/lib/Toast.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/Toast.js +77 -0
- package/dist/commonjs/toast/lib/ToastBody.d.ts +6 -0
- package/dist/commonjs/toast/lib/ToastBody.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/ToastBody.js +39 -0
- package/dist/commonjs/toast/lib/ToastCloseIcon.d.ts +6 -0
- package/dist/commonjs/toast/lib/ToastCloseIcon.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/ToastCloseIcon.js +43 -0
- package/dist/commonjs/toast/lib/ToastIcon.d.ts +5 -0
- package/dist/commonjs/toast/lib/ToastIcon.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/ToastIcon.js +26 -0
- package/dist/commonjs/toast/lib/ToastLink.d.ts +9 -0
- package/dist/commonjs/toast/lib/ToastLink.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/ToastLink.js +41 -0
- package/dist/commonjs/toast/lib/ToastMessage.d.ts +11 -0
- package/dist/commonjs/toast/lib/ToastMessage.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/ToastMessage.js +43 -0
- package/dist/commonjs/toast/lib/hooks/useToastModel.d.ts +65 -0
- package/dist/commonjs/toast/lib/hooks/useToastModel.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/hooks/useToastModel.js +35 -0
- package/dist/es6/index.d.ts +1 -0
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +1 -0
- package/dist/es6/toast/index.d.ts +3 -0
- package/dist/es6/toast/index.d.ts.map +1 -0
- package/dist/es6/toast/index.js +2 -0
- package/dist/es6/toast/lib/Toast.d.ts +36 -0
- package/dist/es6/toast/lib/Toast.d.ts.map +1 -0
- package/dist/es6/toast/lib/Toast.js +71 -0
- package/dist/es6/toast/lib/ToastBody.d.ts +6 -0
- package/dist/es6/toast/lib/ToastBody.d.ts.map +1 -0
- package/dist/es6/toast/lib/ToastBody.js +33 -0
- package/dist/es6/toast/lib/ToastCloseIcon.d.ts +6 -0
- package/dist/es6/toast/lib/ToastCloseIcon.d.ts.map +1 -0
- package/dist/es6/toast/lib/ToastCloseIcon.js +37 -0
- package/dist/es6/toast/lib/ToastIcon.d.ts +5 -0
- package/dist/es6/toast/lib/ToastIcon.d.ts.map +1 -0
- package/dist/es6/toast/lib/ToastIcon.js +20 -0
- package/dist/es6/toast/lib/ToastLink.d.ts +9 -0
- package/dist/es6/toast/lib/ToastLink.d.ts.map +1 -0
- package/dist/es6/toast/lib/ToastLink.js +35 -0
- package/dist/es6/toast/lib/ToastMessage.d.ts +11 -0
- package/dist/es6/toast/lib/ToastMessage.d.ts.map +1 -0
- package/dist/es6/toast/lib/ToastMessage.js +37 -0
- package/dist/es6/toast/lib/hooks/useToastModel.d.ts +65 -0
- package/dist/es6/toast/lib/hooks/useToastModel.d.ts.map +1 -0
- package/dist/es6/toast/lib/hooks/useToastModel.js +32 -0
- package/index.ts +1 -0
- package/package.json +3 -3
- package/toast/LICENSE +52 -0
- package/toast/README.md +5 -0
- package/toast/index.ts +2 -0
- package/toast/lib/Toast.tsx +62 -0
- package/toast/lib/ToastBody.tsx +33 -0
- package/toast/lib/ToastCloseIcon.tsx +18 -0
- package/toast/lib/ToastIcon.tsx +24 -0
- package/toast/lib/ToastLink.tsx +26 -0
- package/toast/lib/ToastMessage.tsx +23 -0
- package/toast/lib/hooks/useToastModel.tsx +27 -0
- package/toast/package.json +6 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
4
|
+
import {SystemIcon, SystemIconProps} from '@workday/canvas-kit-react';
|
|
5
|
+
|
|
6
|
+
export interface ToastIconProps extends Omit<SystemIconProps, 'colorHover'> {}
|
|
7
|
+
|
|
8
|
+
export const ToastIcon = createComponent('div')({
|
|
9
|
+
displayName: 'Toast.Icon',
|
|
10
|
+
Component: (elemProps: ToastIconProps, ref, Element) => {
|
|
11
|
+
return (
|
|
12
|
+
<SystemIcon
|
|
13
|
+
colorHover={elemProps.color}
|
|
14
|
+
marginY="s"
|
|
15
|
+
marginInlineEnd="xs"
|
|
16
|
+
marginInlineStart="xs"
|
|
17
|
+
alignSelf="start"
|
|
18
|
+
ref={ref}
|
|
19
|
+
as={Element}
|
|
20
|
+
{...elemProps}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {createComponent, styled, StyledType} from '@workday/canvas-kit-react/common';
|
|
4
|
+
import {Hyperlink, HyperlinkProps, space} from '@workday/canvas-kit-react';
|
|
5
|
+
|
|
6
|
+
export interface ToastLinkProps extends HyperlinkProps {
|
|
7
|
+
/**
|
|
8
|
+
* attribute for the hyperlink URL
|
|
9
|
+
*/
|
|
10
|
+
href: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const StyledHyperLink = styled(Hyperlink)<StyledType>({
|
|
14
|
+
marginTop: space.xxxs,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const ToastLink = createComponent('a')({
|
|
18
|
+
displayName: 'Toast.Link',
|
|
19
|
+
Component: ({children, href, ...elemProps}: ToastLinkProps, ref, Element) => {
|
|
20
|
+
return (
|
|
21
|
+
<StyledHyperLink ref={ref} href={href} as={Element} {...elemProps}>
|
|
22
|
+
{children}
|
|
23
|
+
</StyledHyperLink>
|
|
24
|
+
);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {createSubcomponent, styled, StyledType} from '@workday/canvas-kit-react/common';
|
|
4
|
+
import {Flex, FlexProps} from '@workday/canvas-kit-react/layout';
|
|
5
|
+
import {useToastModel} from './hooks/useToastModel';
|
|
6
|
+
|
|
7
|
+
export interface ToastMessageProps extends FlexProps {}
|
|
8
|
+
|
|
9
|
+
const StyledMessage = styled(Flex)<StyledType>({
|
|
10
|
+
wordBreak: 'break-word',
|
|
11
|
+
// TODO: Remove once we officially drop support for IE11
|
|
12
|
+
wordWrap: 'break-word', // Needed for IE11
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const ToastMessage = createSubcomponent('div')({
|
|
16
|
+
modelHook: useToastModel,
|
|
17
|
+
})<ToastMessageProps>(({children, ...elemProps}, Element, model) => {
|
|
18
|
+
return (
|
|
19
|
+
<StyledMessage flexDirection="column" id={model.state.id} as={Element} {...elemProps}>
|
|
20
|
+
{children}
|
|
21
|
+
</StyledMessage>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {createModelHook, useUniqueId} from '@workday/canvas-kit-react/common';
|
|
2
|
+
export type AriaRoleMode = 'dialog' | 'status' | 'alert';
|
|
3
|
+
|
|
4
|
+
export const useToastModel = createModelHook({
|
|
5
|
+
defaultConfig: {
|
|
6
|
+
/**
|
|
7
|
+
* Sets the correct aria attributes for the Toast.
|
|
8
|
+
* Alert toasts are used to convey urgency and important information. The `role` is set to `alert`
|
|
9
|
+
* Status toasts are used to convey a message or a successful action. The `role` is set to `status`
|
|
10
|
+
* Dialog toasts are used when there's an action to be taken. The `role` is set to `dialog`
|
|
11
|
+
* @default 'status'
|
|
12
|
+
*/
|
|
13
|
+
mode: 'status' as AriaRoleMode,
|
|
14
|
+
/**
|
|
15
|
+
* When the Toast has a `mode="dialog"` this adds a unique id to type the `Toast.Message` to the dialog.
|
|
16
|
+
*/
|
|
17
|
+
id: '',
|
|
18
|
+
},
|
|
19
|
+
})(config => {
|
|
20
|
+
const id = useUniqueId(config.id);
|
|
21
|
+
const state = {
|
|
22
|
+
...config,
|
|
23
|
+
id,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return {state, events: {}};
|
|
27
|
+
});
|