@workday/canvas-kit-react 9.0.0-alpha.359-next.4 → 9.0.0-alpha.362-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/collection/lib/useCursorListModel.tsx +1 -1
- package/collection/lib/useListItemRovingFocus.tsx +2 -5
- package/dist/commonjs/collection/lib/useCursorListModel.js +1 -1
- package/dist/commonjs/collection/lib/useListItemRovingFocus.d.ts.map +1 -1
- package/dist/commonjs/collection/lib/useListItemRovingFocus.js +2 -3
- package/dist/commonjs/popup/lib/PopupCloseIcon.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/PopupCloseIcon.js +2 -7
- package/dist/commonjs/toast/index.d.ts +1 -0
- package/dist/commonjs/toast/index.d.ts.map +1 -1
- package/dist/commonjs/toast/index.js +1 -0
- package/dist/commonjs/toast/lib/Toast.d.ts +56 -22
- package/dist/commonjs/toast/lib/Toast.d.ts.map +1 -1
- package/dist/commonjs/toast/lib/Toast.js +95 -56
- 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 +38 -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 +26 -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 +5 -0
- package/dist/commonjs/toast/lib/ToastLink.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/ToastLink.js +38 -0
- package/dist/commonjs/toast/lib/ToastMessage.d.ts +12 -0
- package/dist/commonjs/toast/lib/ToastMessage.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/ToastMessage.js +38 -0
- package/dist/commonjs/toast/lib/hooks/useToastModel.d.ts +75 -0
- package/dist/commonjs/toast/lib/hooks/useToastModel.d.ts.map +1 -0
- package/dist/commonjs/toast/lib/hooks/useToastModel.js +37 -0
- package/dist/es6/collection/lib/useCursorListModel.js +1 -1
- package/dist/es6/collection/lib/useListItemRovingFocus.d.ts.map +1 -1
- package/dist/es6/collection/lib/useListItemRovingFocus.js +2 -3
- package/dist/es6/popup/lib/PopupCloseIcon.d.ts.map +1 -1
- package/dist/es6/popup/lib/PopupCloseIcon.js +3 -8
- package/dist/es6/toast/index.d.ts +1 -0
- package/dist/es6/toast/index.d.ts.map +1 -1
- package/dist/es6/toast/index.js +1 -0
- package/dist/es6/toast/lib/Toast.d.ts +56 -22
- package/dist/es6/toast/lib/Toast.d.ts.map +1 -1
- package/dist/es6/toast/lib/Toast.js +92 -37
- 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 +32 -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 +20 -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 +5 -0
- package/dist/es6/toast/lib/ToastLink.d.ts.map +1 -0
- package/dist/es6/toast/lib/ToastLink.js +32 -0
- package/dist/es6/toast/lib/ToastMessage.d.ts +12 -0
- package/dist/es6/toast/lib/ToastMessage.d.ts.map +1 -0
- package/dist/es6/toast/lib/ToastMessage.js +32 -0
- package/dist/es6/toast/lib/hooks/useToastModel.d.ts +75 -0
- package/dist/es6/toast/lib/hooks/useToastModel.d.ts.map +1 -0
- package/dist/es6/toast/lib/hooks/useToastModel.js +34 -0
- package/package.json +3 -3
- package/popup/lib/PopupCloseIcon.tsx +14 -15
- package/toast/LICENSE +1 -0
- package/toast/README.md +3 -5
- package/toast/index.ts +1 -0
- package/toast/lib/Toast.tsx +104 -109
- package/toast/lib/ToastBody.tsx +28 -0
- package/toast/lib/ToastCloseIcon.tsx +14 -0
- package/toast/lib/ToastIcon.tsx +23 -0
- package/toast/lib/ToastLink.tsx +17 -0
- package/toast/lib/ToastMessage.tsx +24 -0
- package/toast/lib/hooks/useToastModel.tsx +29 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export declare type AriaRoleMode = 'dialog' | 'status' | 'alert';
|
|
2
|
+
export declare const useToastModel: (<TT_Special_Generic>(config?: (Partial<{
|
|
3
|
+
/**
|
|
4
|
+
* Sets the correct aria attributes for the Toast.
|
|
5
|
+
* Alert toasts are used to convey urgency and important information. The `role` is set to `alert`
|
|
6
|
+
* Status toasts are used to convey a message or a successful action. The `role` is set to `status`
|
|
7
|
+
* Dialog toasts are used when there's an action to be taken. The `role` is set to `dialog`.
|
|
8
|
+
* If you use this mode, you must add an aria-label to the main `Toast` component.
|
|
9
|
+
* The aria-label should provide additional information to the contents of the `Toast`.
|
|
10
|
+
* @default 'status'
|
|
11
|
+
*/
|
|
12
|
+
mode: AriaRoleMode;
|
|
13
|
+
/**
|
|
14
|
+
* When the Toast has a `mode="dialog"` this adds a unique id to `Toast.Message` so that the message gets read out for screen readers.
|
|
15
|
+
*/
|
|
16
|
+
id: string;
|
|
17
|
+
}> & {} & {}) | undefined) => {
|
|
18
|
+
state: {
|
|
19
|
+
id: string;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the correct aria attributes for the Toast.
|
|
22
|
+
* Alert toasts are used to convey urgency and important information. The `role` is set to `alert`
|
|
23
|
+
* Status toasts are used to convey a message or a successful action. The `role` is set to `status`
|
|
24
|
+
* Dialog toasts are used when there's an action to be taken. The `role` is set to `dialog`.
|
|
25
|
+
* If you use this mode, you must add an aria-label to the main `Toast` component.
|
|
26
|
+
* The aria-label should provide additional information to the contents of the `Toast`.
|
|
27
|
+
* @default 'status'
|
|
28
|
+
*/
|
|
29
|
+
mode: AriaRoleMode;
|
|
30
|
+
};
|
|
31
|
+
events: {};
|
|
32
|
+
}) & import("@workday/canvas-kit-react/common").ModelExtras<{
|
|
33
|
+
/**
|
|
34
|
+
* Sets the correct aria attributes for the Toast.
|
|
35
|
+
* Alert toasts are used to convey urgency and important information. The `role` is set to `alert`
|
|
36
|
+
* Status toasts are used to convey a message or a successful action. The `role` is set to `status`
|
|
37
|
+
* Dialog toasts are used when there's an action to be taken. The `role` is set to `dialog`.
|
|
38
|
+
* If you use this mode, you must add an aria-label to the main `Toast` component.
|
|
39
|
+
* The aria-label should provide additional information to the contents of the `Toast`.
|
|
40
|
+
* @default 'status'
|
|
41
|
+
*/
|
|
42
|
+
mode: AriaRoleMode;
|
|
43
|
+
/**
|
|
44
|
+
* When the Toast has a `mode="dialog"` this adds a unique id to `Toast.Message` so that the message gets read out for screen readers.
|
|
45
|
+
*/
|
|
46
|
+
id: string;
|
|
47
|
+
}, {}, {
|
|
48
|
+
id: string;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the correct aria attributes for the Toast.
|
|
51
|
+
* Alert toasts are used to convey urgency and important information. The `role` is set to `alert`
|
|
52
|
+
* Status toasts are used to convey a message or a successful action. The `role` is set to `status`
|
|
53
|
+
* Dialog toasts are used when there's an action to be taken. The `role` is set to `dialog`.
|
|
54
|
+
* If you use this mode, you must add an aria-label to the main `Toast` component.
|
|
55
|
+
* The aria-label should provide additional information to the contents of the `Toast`.
|
|
56
|
+
* @default 'status'
|
|
57
|
+
*/
|
|
58
|
+
mode: AriaRoleMode;
|
|
59
|
+
}, {}, {
|
|
60
|
+
state: {
|
|
61
|
+
id: string;
|
|
62
|
+
/**
|
|
63
|
+
* Sets the correct aria attributes for the Toast.
|
|
64
|
+
* Alert toasts are used to convey urgency and important information. The `role` is set to `alert`
|
|
65
|
+
* Status toasts are used to convey a message or a successful action. The `role` is set to `status`
|
|
66
|
+
* Dialog toasts are used when there's an action to be taken. The `role` is set to `dialog`.
|
|
67
|
+
* If you use this mode, you must add an aria-label to the main `Toast` component.
|
|
68
|
+
* The aria-label should provide additional information to the contents of the `Toast`.
|
|
69
|
+
* @default 'status'
|
|
70
|
+
*/
|
|
71
|
+
mode: AriaRoleMode;
|
|
72
|
+
};
|
|
73
|
+
events: {};
|
|
74
|
+
}>;
|
|
75
|
+
//# sourceMappingURL=useToastModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useToastModel.d.ts","sourceRoot":"","sources":["../../../../../toast/lib/hooks/useToastModel.tsx"],"names":[],"mappings":"AACA,oBAAY,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEzD,eAAO,MAAM,aAAa;IAEtB;;;;;;;;OAQG;;IAEH;;OAEG;;;;;QAZH;;;;;;;;WAQG;;;;;IARH;;;;;;;;OAQG;;IAEH;;OAEG;;;;IAZH;;;;;;;;OAQG;;;;;QARH;;;;;;;;WAQG;;;;EAeL,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.useToastModel = void 0;
|
|
15
|
+
var common_1 = require("@workday/canvas-kit-react/common");
|
|
16
|
+
exports.useToastModel = common_1.createModelHook({
|
|
17
|
+
defaultConfig: {
|
|
18
|
+
/**
|
|
19
|
+
* Sets the correct aria attributes for the Toast.
|
|
20
|
+
* Alert toasts are used to convey urgency and important information. The `role` is set to `alert`
|
|
21
|
+
* Status toasts are used to convey a message or a successful action. The `role` is set to `status`
|
|
22
|
+
* Dialog toasts are used when there's an action to be taken. The `role` is set to `dialog`.
|
|
23
|
+
* If you use this mode, you must add an aria-label to the main `Toast` component.
|
|
24
|
+
* The aria-label should provide additional information to the contents of the `Toast`.
|
|
25
|
+
* @default 'status'
|
|
26
|
+
*/
|
|
27
|
+
mode: 'status',
|
|
28
|
+
/**
|
|
29
|
+
* When the Toast has a `mode="dialog"` this adds a unique id to `Toast.Message` so that the message gets read out for screen readers.
|
|
30
|
+
*/
|
|
31
|
+
id: '',
|
|
32
|
+
},
|
|
33
|
+
})(function (config) {
|
|
34
|
+
var id = common_1.useUniqueId(config.id);
|
|
35
|
+
var state = __assign(__assign({}, config), { id: id });
|
|
36
|
+
return { state: state, events: {} };
|
|
37
|
+
});
|
|
@@ -278,7 +278,7 @@ export var useCursorListModel = createModelHook({
|
|
|
278
278
|
var _b = React.useState(config.initialCursorId), cursorId = _b[0], setCursorId = _b[1];
|
|
279
279
|
var columnCount = config.columnCount || 0;
|
|
280
280
|
var list = useBaseListModel(config);
|
|
281
|
-
var initialCurrentRef = React.useRef(config.initialCursorId || (((_a = config.items) === null || _a === void 0 ? void 0 : _a.length) ? getId(
|
|
281
|
+
var initialCurrentRef = React.useRef(config.initialCursorId || (((_a = config.items) === null || _a === void 0 ? void 0 : _a.length) ? getId(list.state.items[0]) : ''));
|
|
282
282
|
var navigation = config.navigation;
|
|
283
283
|
var state = __assign(__assign({}, list.state), {
|
|
284
284
|
/** The id of the list item the cursor is pointing to */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useListItemRovingFocus.d.ts","sourceRoot":"","sources":["../../../../collection/lib/useListItemRovingFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;CAqBpB,CAAC;AA+BX;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useListItemRovingFocus.d.ts","sourceRoot":"","sources":["../../../../collection/lib/useListItemRovingFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;CAqBpB,CAAC;AA+BX;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAkCZ,mBAAmB;;;;;;;;;OA+CzC,CAAC"}
|
|
@@ -66,12 +66,11 @@ var hasOwnKey = function (obj, key) { return obj.hasOwnProperty(key); };
|
|
|
66
66
|
```
|
|
67
67
|
*/
|
|
68
68
|
export var useListItemRovingFocus = createElemPropsHook(useCursorListModel)(function (_a, ref, elemProps) {
|
|
69
|
-
var state = _a.state, events = _a.events,
|
|
69
|
+
var state = _a.state, events = _a.events, navigation = _a.navigation;
|
|
70
70
|
if (elemProps === void 0) { elemProps = {}; }
|
|
71
71
|
// Tracks when this element has focus. If this item is removed while still focused, we have to
|
|
72
72
|
// inform the model to move the cursor to the next item.
|
|
73
73
|
var focusRef = React.useRef(false);
|
|
74
|
-
var getIdRef = React.useRef(getId);
|
|
75
74
|
// Create a ref out of state. We don't want to watch state on unmount, so we use a ref to get the
|
|
76
75
|
// current value at the time of unmounting. Otherwise, `state.items` would be a cached value of an
|
|
77
76
|
// empty array
|
|
@@ -88,7 +87,7 @@ export var useListItemRovingFocus = createElemPropsHook(useCursorListModel)(func
|
|
|
88
87
|
requestAnimationFrame(function () {
|
|
89
88
|
var _a;
|
|
90
89
|
(_a = document
|
|
91
|
-
.querySelector("[data-focus-id=\"" + (state.id + "-" +
|
|
90
|
+
.querySelector("[data-focus-id=\"" + (state.id + "-" + item_1.id) + "\"]")) === null || _a === void 0 ? void 0 : _a.focus();
|
|
92
91
|
});
|
|
93
92
|
keyDownRef.current = false;
|
|
94
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupCloseIcon.d.ts","sourceRoot":"","sources":["../../../../popup/lib/PopupCloseIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,
|
|
1
|
+
{"version":3,"file":"PopupCloseIcon.d.ts","sourceRoot":"","sources":["../../../../popup/lib/PopupCloseIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAqB,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAKhE,MAAM,WAAW,mBAAoB,SAAQ,YAAY,CAAC,OAAO,cAAc,EAAE,KAAK,CAAC;CAAG;AAE1F,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;EAiBzB,CAAC"}
|
|
@@ -22,20 +22,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import { xIcon } from '@workday/canvas-system-icons-web';
|
|
25
|
-
import {
|
|
25
|
+
import { createSubcomponent } from '@workday/canvas-kit-react/common';
|
|
26
26
|
import { TertiaryButton } from '@workday/canvas-kit-react/button';
|
|
27
|
+
import { space } from '@workday/canvas-kit-react/tokens';
|
|
27
28
|
import { usePopupCloseButton, usePopupModel } from './hooks';
|
|
28
|
-
var closeIconSpacing = 4;
|
|
29
|
-
var StyledCloseIcon = styled(TertiaryButton)({
|
|
30
|
-
position: 'absolute',
|
|
31
|
-
right: closeIconSpacing,
|
|
32
|
-
top: closeIconSpacing,
|
|
33
|
-
});
|
|
34
29
|
export var PopupCloseIcon = createSubcomponent('button')({
|
|
35
30
|
displayName: 'Popup.CloseIcon',
|
|
36
31
|
modelHook: usePopupModel,
|
|
37
32
|
elemPropsHook: usePopupCloseButton,
|
|
38
33
|
})(function (_a, Element) {
|
|
39
34
|
var children = _a.children, elemProps = __rest(_a, ["children"]);
|
|
40
|
-
return React.createElement(
|
|
35
|
+
return (React.createElement(TertiaryButton, __assign({ as: Element, size: "medium", icon: xIcon, type: "button", position: "absolute", right: space.xxxs, top: space.xxxs }, elemProps)));
|
|
41
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../toast/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../toast/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC"}
|
package/dist/es6/toast/index.js
CHANGED
|
@@ -1,34 +1,68 @@
|
|
|
1
|
-
import { Popup } from '@workday/canvas-kit-react/popup';
|
|
2
|
-
import { CanvasColor } from '@workday/canvas-kit-react/tokens';
|
|
3
|
-
import { CanvasSystemIcon } from '@workday/design-assets-types';
|
|
4
1
|
import { ExtractProps } from '@workday/canvas-kit-react/common';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { Popup } from '@workday/canvas-kit-react/popup';
|
|
3
|
+
export interface ToastProps extends Omit<ExtractProps<typeof Popup.Card, never>, 'model'> {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Toast is a compound component that has different modes based on its contents. The modes add the proper aria attributes for accessibility
|
|
7
|
+
*
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { Toast } from "@workday/canvas-kit-react/toast";
|
|
10
|
+
*
|
|
11
|
+
* const MyToast = (props: CardProps) => (
|
|
12
|
+
* <Toast mode="dialog" aria-label="notifcation">
|
|
13
|
+
* <Toast.Icon icon={checkIcon} color={colors.greenApple400} />
|
|
14
|
+
* <Toast.Body>
|
|
15
|
+
* <Toast.Message>Your workbook was successfully processed.</Toast.Message>
|
|
16
|
+
* <Toast.Link href="#hreflink">Custom Link</Toast.Link>
|
|
17
|
+
* </Toast.Body>
|
|
18
|
+
* <Toast.CloseIcon aria-label="Close" onClick={handleClose} />
|
|
19
|
+
* </Toast>
|
|
20
|
+
* );
|
|
21
|
+
*```
|
|
22
|
+
*/
|
|
23
|
+
export declare const Toast: import("@workday/canvas-kit-react/common").ElementComponentM<"div", ToastProps & Partial<{
|
|
24
|
+
mode: import("./hooks/useToastModel").AriaRoleMode;
|
|
25
|
+
id: string;
|
|
26
|
+
}> & {} & {}, {
|
|
27
|
+
state: {
|
|
28
|
+
id: string;
|
|
29
|
+
mode: import("./hooks/useToastModel").AriaRoleMode;
|
|
30
|
+
};
|
|
31
|
+
events: {};
|
|
32
|
+
}> & {
|
|
11
33
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
34
|
+
* `Toast.Body` should container `Toast.Message` and `Toast.Link`. This ensures proper styling and spacing between elements.
|
|
35
|
+
*
|
|
36
|
+
* ```tsx
|
|
37
|
+
* <Toast.Body>
|
|
38
|
+
* <Toast.Message>Your workbook was successfully processed.</Toast.Message>
|
|
39
|
+
* <Toast.Link href="#hreflink">Custom Link</Toast.Link>
|
|
40
|
+
* </Toast.Body>
|
|
41
|
+
* ```
|
|
14
42
|
*/
|
|
15
|
-
|
|
43
|
+
Body: import("@workday/canvas-kit-react/common").ElementComponent<"div", import("./ToastBody").ToastBodyProps>;
|
|
16
44
|
/**
|
|
17
|
-
*
|
|
45
|
+
* `Toast.CloseIcon` renders a {@link PopupCloseIcon}. You can pass an `onClick` when used with `Popper` to dismiss the `Toast`.
|
|
18
46
|
*/
|
|
19
|
-
|
|
47
|
+
CloseIcon: import("@workday/canvas-kit-react/common").ElementComponent<"button", import("./ToastCloseIcon").ToastCloseIconProps>;
|
|
20
48
|
/**
|
|
21
|
-
*
|
|
49
|
+
* `ToastIcon` renders a `SystemIcon` where you have access to all styling properties from `SystemIcon`.
|
|
22
50
|
*/
|
|
23
|
-
|
|
51
|
+
Icon: import("@workday/canvas-kit-react/common").ElementComponent<"div", import("./ToastIcon").ToastIconProps>;
|
|
24
52
|
/**
|
|
25
|
-
*
|
|
53
|
+
* `Toast.Message` renders our `Subtext` component where you can style however way you'd like with style properties.
|
|
54
|
+
* This component also has an `id` so that when the `Toast` has a prop of `mode="dialog"` the message is read out by screen readers by adding an `aria-describedby` on the main `Toast` component.
|
|
26
55
|
*/
|
|
27
|
-
|
|
56
|
+
Message: import("@workday/canvas-kit-react/common").ElementComponentM<"p", import("./ToastMessage").ToastMessageProps, {
|
|
57
|
+
state: {
|
|
58
|
+
id: string;
|
|
59
|
+
mode: import("./hooks/useToastModel").AriaRoleMode;
|
|
60
|
+
};
|
|
61
|
+
events: {};
|
|
62
|
+
}>;
|
|
28
63
|
/**
|
|
29
|
-
*
|
|
64
|
+
* `Toast.Link` renders our `Hyperlink` component. If you need to link to more information, use this component.
|
|
30
65
|
*/
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
export declare const Toast: import("@workday/canvas-kit-react/common").ElementComponent<"div", ToastProps>;
|
|
66
|
+
Link: import("@workday/canvas-kit-react/common").ElementComponent<"a", import("./ToastLink").ToastLinkProps>;
|
|
67
|
+
};
|
|
34
68
|
//# sourceMappingURL=Toast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../../toast/lib/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"Toast.d.ts","sourceRoot":"","sources":["../../../../toast/lib/Toast.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkB,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAC;AAStD,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC;CAAG;AAkC5F;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;IAId;;;;;;;;;OASG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;;;;;;;IAEH;;OAEG;;CAiBL,CAAC"}
|
|
@@ -20,44 +20,99 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import { createContainer } from '@workday/canvas-kit-react/common';
|
|
25
|
+
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
24
26
|
import { Popup } from '@workday/canvas-kit-react/popup';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
import { ToastCloseIcon } from './ToastCloseIcon';
|
|
28
|
+
import { ToastIcon } from './ToastIcon';
|
|
29
|
+
import { ToastMessage } from './ToastMessage';
|
|
30
|
+
import { ToastLink } from './ToastLink';
|
|
31
|
+
import { ToastBody } from './ToastBody';
|
|
32
|
+
import { useToastModel } from './hooks/useToastModel';
|
|
33
|
+
/**
|
|
34
|
+
* The function helps set the correct aria attributes based on the mode
|
|
35
|
+
* @param mode Defines what aria attributes will be added to the main container
|
|
36
|
+
* @param id Used to tie the Toast to Toast.Message for screen readers
|
|
37
|
+
*/
|
|
38
|
+
var getAriaAttributes = function (mode, id) {
|
|
39
|
+
switch (mode) {
|
|
40
|
+
case 'dialog':
|
|
41
|
+
return {
|
|
42
|
+
'aria-describedby': id,
|
|
43
|
+
// This is added by Popup.Card, so overwriting to remove it
|
|
44
|
+
'aria-labelledby': undefined,
|
|
45
|
+
role: 'dialog',
|
|
46
|
+
};
|
|
47
|
+
case 'alert':
|
|
48
|
+
return {
|
|
49
|
+
role: 'alert',
|
|
50
|
+
'aria-live': 'assertive',
|
|
51
|
+
'aria-atomic': true,
|
|
52
|
+
};
|
|
53
|
+
case 'status':
|
|
54
|
+
return {
|
|
55
|
+
role: 'status',
|
|
56
|
+
'aria-live': 'polite',
|
|
57
|
+
'aria-atomic': true,
|
|
58
|
+
};
|
|
59
|
+
default: {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Toast is a compound component that has different modes based on its contents. The modes add the proper aria attributes for accessibility
|
|
66
|
+
*
|
|
67
|
+
* ```tsx
|
|
68
|
+
* import { Toast } from "@workday/canvas-kit-react/toast";
|
|
69
|
+
*
|
|
70
|
+
* const MyToast = (props: CardProps) => (
|
|
71
|
+
* <Toast mode="dialog" aria-label="notifcation">
|
|
72
|
+
* <Toast.Icon icon={checkIcon} color={colors.greenApple400} />
|
|
73
|
+
* <Toast.Body>
|
|
74
|
+
* <Toast.Message>Your workbook was successfully processed.</Toast.Message>
|
|
75
|
+
* <Toast.Link href="#hreflink">Custom Link</Toast.Link>
|
|
76
|
+
* </Toast.Body>
|
|
77
|
+
* <Toast.CloseIcon aria-label="Close" onClick={handleClose} />
|
|
78
|
+
* </Toast>
|
|
79
|
+
* );
|
|
80
|
+
*```
|
|
81
|
+
*/
|
|
82
|
+
export var Toast = createContainer('div')({
|
|
47
83
|
displayName: 'Toast',
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
modelHook: useToastModel,
|
|
85
|
+
subComponents: {
|
|
86
|
+
/**
|
|
87
|
+
* `Toast.Body` should container `Toast.Message` and `Toast.Link`. This ensures proper styling and spacing between elements.
|
|
88
|
+
*
|
|
89
|
+
* ```tsx
|
|
90
|
+
* <Toast.Body>
|
|
91
|
+
* <Toast.Message>Your workbook was successfully processed.</Toast.Message>
|
|
92
|
+
* <Toast.Link href="#hreflink">Custom Link</Toast.Link>
|
|
93
|
+
* </Toast.Body>
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
Body: ToastBody,
|
|
97
|
+
/**
|
|
98
|
+
* `Toast.CloseIcon` renders a {@link PopupCloseIcon}. You can pass an `onClick` when used with `Popper` to dismiss the `Toast`.
|
|
99
|
+
*/
|
|
100
|
+
CloseIcon: ToastCloseIcon,
|
|
101
|
+
/**
|
|
102
|
+
* `ToastIcon` renders a `SystemIcon` where you have access to all styling properties from `SystemIcon`.
|
|
103
|
+
*/
|
|
104
|
+
Icon: ToastIcon,
|
|
105
|
+
/**
|
|
106
|
+
* `Toast.Message` renders our `Subtext` component where you can style however way you'd like with style properties.
|
|
107
|
+
* This component also has an `id` so that when the `Toast` has a prop of `mode="dialog"` the message is read out by screen readers by adding an `aria-describedby` on the main `Toast` component.
|
|
108
|
+
*/
|
|
109
|
+
Message: ToastMessage,
|
|
110
|
+
/**
|
|
111
|
+
* `Toast.Link` renders our `Hyperlink` component. If you need to link to more information, use this component.
|
|
112
|
+
*/
|
|
113
|
+
Link: ToastLink,
|
|
62
114
|
},
|
|
115
|
+
})(function (_a, _, model) {
|
|
116
|
+
var children = _a.children, elemProps = __rest(_a, ["children"]);
|
|
117
|
+
return (React.createElement(Popup.Card, __assign({ as: Flex, width: 360, padding: "0" }, getAriaAttributes(model.state.mode, model.state.id), { flexDirection: "row", gap: "xxxs" }, elemProps), children));
|
|
63
118
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExtractProps } from '@workday/canvas-kit-react/common';
|
|
2
|
+
import { Popup } from '@workday/canvas-kit-react/popup';
|
|
3
|
+
export interface ToastBodyProps extends ExtractProps<typeof Popup.Body> {
|
|
4
|
+
}
|
|
5
|
+
export declare const ToastBody: import("@workday/canvas-kit-react/common").ElementComponent<"div", ToastBodyProps>;
|
|
6
|
+
//# sourceMappingURL=ToastBody.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastBody.d.ts","sourceRoot":"","sources":["../../../../toast/lib/ToastBody.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAkB,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAC;AAGtD,MAAM,WAAW,cAAe,SAAQ,YAAY,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC;CAAG;AAE1E,eAAO,MAAM,SAAS,oFAmBpB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
25
|
+
import { Flex } from '@workday/canvas-kit-react/layout';
|
|
26
|
+
export var ToastBody = createComponent('div')({
|
|
27
|
+
displayName: 'Toast.Body',
|
|
28
|
+
Component: function (_a, ref, Element) {
|
|
29
|
+
var children = _a.children, elemProps = __rest(_a, ["children"]);
|
|
30
|
+
return (React.createElement(Flex, __assign({ alignItems: "flex-start", flexDirection: "column", justifyContent: "center", paddingY: "s", ref: ref, as: Element, flexGrow: 1, gap: "xxxs" }, elemProps), children));
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExtractProps } from '@workday/canvas-kit-react/common';
|
|
2
|
+
import { Popup } from '@workday/canvas-kit-react/popup';
|
|
3
|
+
export interface ToastCloseIconProps extends ExtractProps<typeof Popup.CloseIcon, never> {
|
|
4
|
+
}
|
|
5
|
+
export declare const ToastCloseIcon: import("@workday/canvas-kit-react/common").ElementComponent<"button", ToastCloseIconProps>;
|
|
6
|
+
//# sourceMappingURL=ToastCloseIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastCloseIcon.d.ts","sourceRoot":"","sources":["../../../../toast/lib/ToastCloseIcon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAkB,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAC;AAEtD,MAAM,WAAW,mBAAoB,SAAQ,YAAY,CAAC,OAAO,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC;CAAG;AAE3F,eAAO,MAAM,cAAc,4FAOzB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
14
|
+
import { Popup } from '@workday/canvas-kit-react/popup';
|
|
15
|
+
export var ToastCloseIcon = createComponent('button')({
|
|
16
|
+
displayName: 'Toast.CloseIcon',
|
|
17
|
+
Component: function (elemProps, ref, Element) {
|
|
18
|
+
return (React.createElement(Popup.CloseIcon, __assign({ as: Element, ref: ref, size: "small", position: "relative" }, elemProps)));
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SystemIconProps } from '@workday/canvas-kit-react/icon';
|
|
2
|
+
export interface ToastIconProps extends Omit<SystemIconProps, 'colorHover'> {
|
|
3
|
+
}
|
|
4
|
+
export declare const ToastIcon: import("@workday/canvas-kit-react/common").ElementComponent<"div", ToastIconProps>;
|
|
5
|
+
//# sourceMappingURL=ToastIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastIcon.d.ts","sourceRoot":"","sources":["../../../../toast/lib/ToastIcon.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAa,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAE3E,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC;CAAG;AAE9E,eAAO,MAAM,SAAS,oFAepB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
14
|
+
import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
15
|
+
export var ToastIcon = createComponent('div')({
|
|
16
|
+
displayName: 'Toast.Icon',
|
|
17
|
+
Component: function (elemProps, ref, Element) {
|
|
18
|
+
return (React.createElement(SystemIcon, __assign({ colorHover: elemProps.color, marginY: "s", marginX: "xs", alignSelf: "start", ref: ref, as: Element }, elemProps)));
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { HyperlinkProps } from '@workday/canvas-kit-react/button';
|
|
2
|
+
export interface ToastLinkProps extends HyperlinkProps {
|
|
3
|
+
}
|
|
4
|
+
export declare const ToastLink: import("@workday/canvas-kit-react/common").ElementComponent<"a", ToastLinkProps>;
|
|
5
|
+
//# sourceMappingURL=ToastLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastLink.d.ts","sourceRoot":"","sources":["../../../../toast/lib/ToastLink.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAY,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAE3E,MAAM,WAAW,cAAe,SAAQ,cAAc;CAAG;AAEzD,eAAO,MAAM,SAAS,kFASpB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React from 'react';
|
|
24
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
25
|
+
import { Hyperlink } from '@workday/canvas-kit-react/button';
|
|
26
|
+
export var ToastLink = createComponent('a')({
|
|
27
|
+
displayName: 'Toast.Link',
|
|
28
|
+
Component: function (_a, ref, Element) {
|
|
29
|
+
var children = _a.children, href = _a.href, elemProps = __rest(_a, ["children", "href"]);
|
|
30
|
+
return (React.createElement(Hyperlink, __assign({ ref: ref, href: href, as: Element }, elemProps), children));
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ExtractProps } from '@workday/canvas-kit-react/common';
|
|
2
|
+
import { Subtext } from '@workday/canvas-kit-react/text';
|
|
3
|
+
export interface ToastMessageProps extends Omit<ExtractProps<typeof Subtext>, 'size'> {
|
|
4
|
+
}
|
|
5
|
+
export declare const ToastMessage: import("@workday/canvas-kit-react/common").ElementComponentM<"p", ToastMessageProps, {
|
|
6
|
+
state: {
|
|
7
|
+
id: string;
|
|
8
|
+
mode: import("./hooks/useToastModel").AriaRoleMode;
|
|
9
|
+
};
|
|
10
|
+
events: {};
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=ToastMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastMessage.d.ts","sourceRoot":"","sources":["../../../../toast/lib/ToastMessage.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAqB,YAAY,EAAC,MAAM,kCAAkC,CAAC;AAElF,OAAO,EAAC,OAAO,EAAC,MAAM,gCAAgC,CAAC;AAEvD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,OAAO,CAAC,EAAE,MAAM,CAAC;CAAG;AAExF,eAAO,MAAM,YAAY;;;;;;EAevB,CAAC"}
|