@workday/canvas-kit-react 8.0.0-alpha.144-next.0 → 8.0.0-alpha.151-next.3
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/banner/lib/Banner.tsx +3 -6
- package/card/lib/CardBody.tsx +3 -6
- package/card/lib/CardHeading.tsx +13 -10
- package/checkbox/index.ts +0 -1
- package/checkbox/lib/Checkbox.tsx +9 -24
- package/color-picker/index.ts +0 -1
- package/dist/commonjs/banner/lib/Banner.d.ts.map +1 -1
- package/dist/commonjs/banner/lib/Banner.js +2 -4
- package/dist/commonjs/card/lib/Card.d.ts +1 -1
- package/dist/commonjs/card/lib/CardBody.d.ts +1 -1
- package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
- package/dist/commonjs/card/lib/CardBody.js +1 -6
- package/dist/commonjs/card/lib/CardHeading.d.ts.map +1 -1
- package/dist/commonjs/card/lib/CardHeading.js +2 -10
- package/dist/commonjs/checkbox/index.d.ts.map +1 -1
- package/dist/commonjs/checkbox/lib/Checkbox.d.ts.map +1 -1
- package/dist/commonjs/checkbox/lib/Checkbox.js +2 -13
- package/dist/commonjs/color-picker/index.d.ts.map +1 -1
- package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
- package/dist/commonjs/form-field/index.d.ts.map +1 -1
- package/dist/commonjs/form-field/lib/Hint.d.ts.map +1 -1
- package/dist/commonjs/form-field/lib/Hint.js +5 -13
- 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/layout/index.d.ts +4 -0
- package/dist/commonjs/layout/index.d.ts.map +1 -1
- package/dist/commonjs/layout/index.js +3 -0
- package/dist/commonjs/layout/lib/Box.d.ts +4 -2
- package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/Box.js +27 -3
- package/dist/commonjs/layout/lib/Flex.d.ts +1 -1
- package/dist/commonjs/layout/lib/Flex.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/Grid.d.ts +52 -0
- package/dist/commonjs/layout/lib/Grid.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/Grid.js +117 -0
- package/dist/commonjs/layout/lib/Stack.d.ts +4 -4
- package/dist/commonjs/layout/lib/Stack.js +4 -4
- package/dist/commonjs/layout/lib/utils/color.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/color.js +1 -0
- package/dist/commonjs/layout/lib/utils/font.d.ts +29 -0
- package/dist/commonjs/layout/lib/utils/font.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/font.js +57 -0
- package/dist/commonjs/layout/lib/utils/grid.d.ts +58 -0
- package/dist/commonjs/layout/lib/utils/grid.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/grid.js +49 -0
- package/dist/commonjs/layout/lib/utils/gridItem.d.ts +39 -0
- package/dist/commonjs/layout/lib/utils/gridItem.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/gridItem.js +43 -0
- package/dist/commonjs/layout/lib/utils/text.d.ts +35 -0
- package/dist/commonjs/layout/lib/utils/text.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/text.js +48 -0
- package/dist/commonjs/modal/lib/Modal.d.ts +1 -1
- package/dist/commonjs/pagination/lib/Pagination/AdditionalDetails.d.ts.map +1 -1
- package/dist/commonjs/pagination/lib/Pagination/AdditionalDetails.js +5 -4
- package/dist/commonjs/pagination/lib/Pagination/GoTo/Label.d.ts.map +1 -1
- package/dist/commonjs/pagination/lib/Pagination/GoTo/Label.js +2 -4
- package/dist/commonjs/popup/lib/Popup.d.ts +1 -1
- package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -1
- package/dist/commonjs/popup/lib/PopupCard.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/PopupCard.js +2 -2
- package/dist/commonjs/radio/lib/Radio.d.ts.map +1 -1
- package/dist/commonjs/radio/lib/Radio.js +2 -13
- package/dist/commonjs/side-panel/lib/SidePanel.d.ts.map +1 -1
- package/dist/commonjs/side-panel/lib/SidePanel.js +2 -2
- package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/commonjs/text/index.d.ts +4 -0
- package/dist/commonjs/text/index.d.ts.map +1 -0
- package/dist/commonjs/text/index.js +15 -0
- package/dist/commonjs/text/lib/LabelText.d.ts +8 -0
- package/dist/commonjs/text/lib/LabelText.d.ts.map +1 -0
- package/dist/commonjs/text/lib/LabelText.js +51 -0
- package/dist/commonjs/text/lib/Text.d.ts +14 -0
- package/dist/commonjs/text/lib/Text.d.ts.map +1 -0
- package/dist/commonjs/text/lib/Text.js +90 -0
- package/dist/commonjs/text/lib/TypeLevelComponents.d.ts +13 -0
- package/dist/commonjs/text/lib/TypeLevelComponents.d.ts.map +1 -0
- package/dist/commonjs/text/lib/TypeLevelComponents.js +79 -0
- package/dist/commonjs/text-input/index.d.ts.map +1 -1
- package/dist/es6/banner/lib/Banner.d.ts.map +1 -1
- package/dist/es6/banner/lib/Banner.js +2 -4
- package/dist/es6/card/lib/Card.d.ts +1 -1
- package/dist/es6/card/lib/CardBody.d.ts +1 -1
- package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
- package/dist/es6/card/lib/CardBody.js +1 -3
- package/dist/es6/card/lib/CardHeading.d.ts.map +1 -1
- package/dist/es6/card/lib/CardHeading.js +2 -7
- package/dist/es6/checkbox/index.d.ts.map +1 -1
- package/dist/es6/checkbox/lib/Checkbox.d.ts.map +1 -1
- package/dist/es6/checkbox/lib/Checkbox.js +3 -14
- package/dist/es6/color-picker/index.d.ts.map +1 -1
- package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
- package/dist/es6/form-field/index.d.ts.map +1 -1
- package/dist/es6/form-field/lib/Hint.d.ts.map +1 -1
- package/dist/es6/form-field/lib/Hint.js +6 -14
- 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/layout/index.d.ts +4 -0
- package/dist/es6/layout/index.d.ts.map +1 -1
- package/dist/es6/layout/index.js +3 -0
- package/dist/es6/layout/lib/Box.d.ts +4 -2
- package/dist/es6/layout/lib/Box.d.ts.map +1 -1
- package/dist/es6/layout/lib/Box.js +27 -3
- package/dist/es6/layout/lib/Flex.d.ts +1 -1
- package/dist/es6/layout/lib/Flex.d.ts.map +1 -1
- package/dist/es6/layout/lib/Grid.d.ts +52 -0
- package/dist/es6/layout/lib/Grid.d.ts.map +1 -0
- package/dist/es6/layout/lib/Grid.js +92 -0
- package/dist/es6/layout/lib/Stack.d.ts +4 -4
- package/dist/es6/layout/lib/Stack.js +4 -4
- package/dist/es6/layout/lib/utils/color.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/color.js +2 -1
- package/dist/es6/layout/lib/utils/font.d.ts +29 -0
- package/dist/es6/layout/lib/utils/font.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/font.js +53 -0
- package/dist/es6/layout/lib/utils/grid.d.ts +58 -0
- package/dist/es6/layout/lib/utils/grid.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/grid.js +45 -0
- package/dist/es6/layout/lib/utils/gridItem.d.ts +39 -0
- package/dist/es6/layout/lib/utils/gridItem.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/gridItem.js +39 -0
- package/dist/es6/layout/lib/utils/text.d.ts +35 -0
- package/dist/es6/layout/lib/utils/text.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/text.js +44 -0
- package/dist/es6/modal/lib/Modal.d.ts +1 -1
- package/dist/es6/pagination/lib/Pagination/AdditionalDetails.d.ts.map +1 -1
- package/dist/es6/pagination/lib/Pagination/AdditionalDetails.js +6 -5
- package/dist/es6/pagination/lib/Pagination/GoTo/Label.d.ts.map +1 -1
- package/dist/es6/pagination/lib/Pagination/GoTo/Label.js +2 -4
- package/dist/es6/popup/lib/Popup.d.ts +1 -1
- package/dist/es6/popup/lib/PopupBody.d.ts +1 -1
- package/dist/es6/popup/lib/PopupCard.d.ts.map +1 -1
- package/dist/es6/popup/lib/PopupCard.js +2 -2
- package/dist/es6/radio/lib/Radio.d.ts.map +1 -1
- package/dist/es6/radio/lib/Radio.js +3 -14
- package/dist/es6/side-panel/lib/SidePanel.d.ts.map +1 -1
- package/dist/es6/side-panel/lib/SidePanel.js +3 -3
- package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/es6/text/index.d.ts +4 -0
- package/dist/es6/text/index.d.ts.map +1 -0
- package/dist/es6/text/index.js +3 -0
- package/dist/es6/text/lib/LabelText.d.ts +8 -0
- package/dist/es6/text/lib/LabelText.d.ts.map +1 -0
- package/dist/es6/text/lib/LabelText.js +29 -0
- package/dist/es6/text/lib/Text.d.ts +14 -0
- package/dist/es6/text/lib/Text.d.ts.map +1 -0
- package/dist/es6/text/lib/Text.js +68 -0
- package/dist/es6/text/lib/TypeLevelComponents.d.ts +13 -0
- package/dist/es6/text/lib/TypeLevelComponents.d.ts.map +1 -0
- package/dist/es6/text/lib/TypeLevelComponents.js +57 -0
- package/dist/es6/text-input/index.d.ts.map +1 -1
- package/form-field/index.ts +0 -1
- package/form-field/lib/Hint.tsx +8 -19
- package/index.ts +1 -0
- package/layout/index.ts +4 -0
- package/layout/lib/Box.tsx +34 -4
- package/layout/lib/Grid.tsx +88 -0
- package/layout/lib/Stack.tsx +4 -4
- package/layout/lib/utils/color.ts +7 -2
- package/layout/lib/utils/font.ts +67 -0
- package/layout/lib/utils/grid.ts +93 -0
- package/layout/lib/utils/gridItem.ts +68 -0
- package/layout/lib/utils/text.ts +57 -0
- package/package.json +5 -5
- package/pagination/lib/Pagination/AdditionalDetails.tsx +7 -8
- package/pagination/lib/Pagination/GoTo/Label.tsx +3 -11
- package/popup/lib/PopupCard.tsx +2 -1
- package/radio/lib/Radio.tsx +9 -24
- package/side-panel/lib/SidePanel.tsx +7 -7
- package/text/LICENSE +52 -0
- package/text/README.md +5 -0
- package/text/index.ts +3 -0
- package/text/lib/LabelText.tsx +25 -0
- package/text/lib/Text.tsx +66 -0
- package/text/lib/TypeLevelComponents.tsx +43 -0
- package/text/package.json +6 -0
- package/text-input/index.ts +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
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 * as React from 'react';
|
|
24
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
25
|
+
// type changes no need
|
|
26
|
+
import { type } from '@workday/canvas-kit-react/tokens';
|
|
27
|
+
import { Box } from '@workday/canvas-kit-react/layout';
|
|
28
|
+
/**
|
|
29
|
+
* Function returns updated props by token and variant values
|
|
30
|
+
*/
|
|
31
|
+
var validateProps = function (_a) {
|
|
32
|
+
var typeLevel = _a.typeLevel, variant = _a.variant, props = __rest(_a, ["typeLevel", "variant"]);
|
|
33
|
+
var updatedProps = props;
|
|
34
|
+
var tokenPropNames = [
|
|
35
|
+
'color',
|
|
36
|
+
'fontFamily',
|
|
37
|
+
'fontSize',
|
|
38
|
+
'fontWeight',
|
|
39
|
+
'letterSpacing',
|
|
40
|
+
'lineHeight',
|
|
41
|
+
];
|
|
42
|
+
/*
|
|
43
|
+
If token provided it updates undefined values of token styles:
|
|
44
|
+
`fontFamily`, `fontSize`, `lineHeight`, `fontWeight`, `color`
|
|
45
|
+
by replacing them by token value
|
|
46
|
+
*/
|
|
47
|
+
if (typeLevel) {
|
|
48
|
+
var _b = typeLevel.split('.'), level = _b[0], size = _b[1];
|
|
49
|
+
var tokenProps_1 = type.levels[level][size];
|
|
50
|
+
tokenPropNames.forEach(function (item) {
|
|
51
|
+
if (!props[item]) {
|
|
52
|
+
updatedProps[item] = tokenProps_1[item];
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// If variant provided it updates color value by variant color
|
|
57
|
+
if (variant) {
|
|
58
|
+
updatedProps = __assign(__assign({}, updatedProps), type.variants[variant]);
|
|
59
|
+
}
|
|
60
|
+
return updatedProps;
|
|
61
|
+
};
|
|
62
|
+
export var Text = createComponent('span')({
|
|
63
|
+
displayName: 'Text',
|
|
64
|
+
Component: function (_a, ref, Element) {
|
|
65
|
+
var children = _a.children, elemProps = __rest(_a, ["children"]);
|
|
66
|
+
return (React.createElement(Box, __assign({ ref: ref, as: Element }, validateProps(elemProps)), children));
|
|
67
|
+
},
|
|
68
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TextProps } from '@workday/canvas-kit-react/text';
|
|
2
|
+
/**
|
|
3
|
+
* Props interface for type level specific component:
|
|
4
|
+
* Title, Heading, BodyText, Subtext.
|
|
5
|
+
*/
|
|
6
|
+
export interface TypeLevelProps extends Omit<TextProps, 'typeLevel'> {
|
|
7
|
+
size: 'large' | 'medium' | 'small';
|
|
8
|
+
}
|
|
9
|
+
export declare const Subtext: import("../../common").ElementComponent<"p", TypeLevelProps>;
|
|
10
|
+
export declare const BodyText: import("../../common").ElementComponent<"p", TypeLevelProps>;
|
|
11
|
+
export declare const Heading: import("../../common").ElementComponent<"h2", TypeLevelProps>;
|
|
12
|
+
export declare const Title: import("../../common").ElementComponent<"h1", TypeLevelProps>;
|
|
13
|
+
//# sourceMappingURL=TypeLevelComponents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeLevelComponents.d.ts","sourceRoot":"","sources":["../../../../text/lib/TypeLevelComponents.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC;IAClE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,OAAO,8DAMlB,CAAC;AAEH,eAAO,MAAM,QAAQ,8DAMnB,CAAC;AAEH,eAAO,MAAM,OAAO,+DAMlB,CAAC;AAEH,eAAO,MAAM,KAAK,+DAMhB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
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 * as React from 'react';
|
|
24
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
25
|
+
import { Text } from '@workday/canvas-kit-react/text';
|
|
26
|
+
export var Subtext = createComponent('p')({
|
|
27
|
+
displayName: 'Subtext',
|
|
28
|
+
Component: function (_a, ref, Element) {
|
|
29
|
+
var size = _a.size, elemProps = __rest(_a, ["size"]);
|
|
30
|
+
var typeLevel = "subtext." + size;
|
|
31
|
+
return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
export var BodyText = createComponent('p')({
|
|
35
|
+
displayName: 'BodyText',
|
|
36
|
+
Component: function (_a, ref, Element) {
|
|
37
|
+
var size = _a.size, elemProps = __rest(_a, ["size"]);
|
|
38
|
+
var typeLevel = "body." + size;
|
|
39
|
+
return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
export var Heading = createComponent('h2')({
|
|
43
|
+
displayName: 'Heading',
|
|
44
|
+
Component: function (_a, ref, Element) {
|
|
45
|
+
var size = _a.size, elemProps = __rest(_a, ["size"]);
|
|
46
|
+
var typeLevel = "heading." + size;
|
|
47
|
+
return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
export var Title = createComponent('h1')({
|
|
51
|
+
displayName: 'Title',
|
|
52
|
+
Component: function (_a, ref, Element) {
|
|
53
|
+
var size = _a.size, elemProps = __rest(_a, ["size"]);
|
|
54
|
+
var typeLevel = "title." + size;
|
|
55
|
+
return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../text-input/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../text-input/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC"}
|
package/form-field/index.ts
CHANGED
package/form-field/lib/Hint.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {ErrorType,
|
|
3
|
-
import {space
|
|
2
|
+
import {ErrorType, Themeable, styled} from '@workday/canvas-kit-react/common';
|
|
3
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
4
|
+
import {Subtext, Text} from '@workday/canvas-kit-react/text';
|
|
4
5
|
|
|
5
6
|
export interface HintProps extends Themeable, React.HTMLAttributes<HTMLParagraphElement> {
|
|
6
7
|
/**
|
|
@@ -19,20 +20,7 @@ export interface HintProps extends Themeable, React.HTMLAttributes<HTMLParagraph
|
|
|
19
20
|
alertLabel?: string;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
type.levels.subtext.medium,
|
|
24
|
-
{
|
|
25
|
-
fontWeight: type.properties.fontWeights.medium,
|
|
26
|
-
},
|
|
27
|
-
({error, theme}) => error === ErrorType.Error && {color: theme.canvas.palette.error.main}
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const Message = styled('p')<Pick<HintProps, 'error'>>(
|
|
31
|
-
type.levels.subtext.medium,
|
|
32
|
-
{
|
|
33
|
-
margin: `${space.xxs} 0 0`,
|
|
34
|
-
width: '100%',
|
|
35
|
-
},
|
|
23
|
+
const Message = styled(Subtext)<Pick<HintProps, 'error'>>(
|
|
36
24
|
({error, theme}) => error === ErrorType.Error && {color: theme.canvas.palette.error.main}
|
|
37
25
|
);
|
|
38
26
|
|
|
@@ -41,7 +29,6 @@ class Hint extends React.Component<HintProps> {
|
|
|
41
29
|
|
|
42
30
|
public render() {
|
|
43
31
|
const {errorLabel = 'Error', alertLabel = 'Alert', children, error} = this.props;
|
|
44
|
-
|
|
45
32
|
let hintLabel: string | undefined;
|
|
46
33
|
switch (error) {
|
|
47
34
|
case Hint.ErrorType.Error:
|
|
@@ -54,8 +41,10 @@ class Hint extends React.Component<HintProps> {
|
|
|
54
41
|
}
|
|
55
42
|
|
|
56
43
|
return (
|
|
57
|
-
<Message {...this.props}>
|
|
58
|
-
{typeof error !== 'undefined' && hintLabel &&
|
|
44
|
+
<Message size="medium" margin={`${space.xxs} 0 0`} width="100%" {...this.props}>
|
|
45
|
+
{typeof error !== 'undefined' && hintLabel && (
|
|
46
|
+
<Text fontWeight="medium">{hintLabel}: </Text>
|
|
47
|
+
)}
|
|
59
48
|
{children}
|
|
60
49
|
</Message>
|
|
61
50
|
);
|
package/index.ts
CHANGED
package/layout/index.ts
CHANGED
|
@@ -7,10 +7,14 @@ export * from './lib/utils/border';
|
|
|
7
7
|
export * from './lib/utils/color';
|
|
8
8
|
export {DepthStyleProps} from './lib/utils/depth';
|
|
9
9
|
export * from './lib/utils/flexItem';
|
|
10
|
+
export * from './lib/utils/font';
|
|
10
11
|
export * from './lib/utils/layout';
|
|
11
12
|
export * from './lib/utils/position';
|
|
12
13
|
export {SpaceStyleProps} from './lib/utils/space';
|
|
14
|
+
export * from './lib/utils/text';
|
|
13
15
|
export * from './lib/Flex';
|
|
16
|
+
export * from './lib/Grid';
|
|
14
17
|
export * from './lib/Stack';
|
|
15
18
|
export type { FlexStyleProps } from './lib/utils/flex';
|
|
19
|
+
export type { GridStyleProps } from './lib/utils/grid';
|
|
16
20
|
export type { StackSpacing, StackDirection, StackStyleProps } from './lib/utils/stack';
|
package/layout/lib/Box.tsx
CHANGED
|
@@ -8,23 +8,47 @@ import {border, BorderStyleProps} from './utils/border';
|
|
|
8
8
|
import {color, ColorStyleProps} from './utils/color';
|
|
9
9
|
import {depth, DepthStyleProps} from './utils/depth';
|
|
10
10
|
import {flexItem, FlexItemStyleProps} from './utils/flexItem';
|
|
11
|
+
import {font, FontStyleProps} from './utils/font';
|
|
11
12
|
import {layout, LayoutStyleProps} from './utils/layout';
|
|
12
13
|
import {other, OtherStyleProps} from './utils/other';
|
|
13
14
|
import {position, PositionStyleProps} from './utils/position';
|
|
14
15
|
import {space, SpaceStyleProps} from './utils/space';
|
|
16
|
+
import {text, TextStyleProps} from './utils/text';
|
|
15
17
|
|
|
16
18
|
export type BoxProps = BorderStyleProps &
|
|
17
19
|
ColorStyleProps &
|
|
18
20
|
DepthStyleProps &
|
|
19
21
|
FlexItemStyleProps &
|
|
22
|
+
FontStyleProps &
|
|
20
23
|
LayoutStyleProps &
|
|
21
24
|
OtherStyleProps &
|
|
22
25
|
PositionStyleProps &
|
|
23
|
-
SpaceStyleProps &
|
|
26
|
+
SpaceStyleProps &
|
|
27
|
+
TextStyleProps & {
|
|
24
28
|
children?: React.ReactNode;
|
|
25
29
|
};
|
|
26
30
|
|
|
27
|
-
const omittedProps = [
|
|
31
|
+
const omittedProps = [
|
|
32
|
+
'display',
|
|
33
|
+
'color',
|
|
34
|
+
'height',
|
|
35
|
+
'overflow',
|
|
36
|
+
'width',
|
|
37
|
+
'border',
|
|
38
|
+
'background',
|
|
39
|
+
'fontSize',
|
|
40
|
+
'fontWeight',
|
|
41
|
+
'fontFamily',
|
|
42
|
+
'letterSpacing',
|
|
43
|
+
'lineHeight',
|
|
44
|
+
'textAlign',
|
|
45
|
+
'textDecoration',
|
|
46
|
+
'textOverflow',
|
|
47
|
+
'textTransform',
|
|
48
|
+
'textShadow',
|
|
49
|
+
'whiteSpace',
|
|
50
|
+
'wordBreak',
|
|
51
|
+
];
|
|
28
52
|
|
|
29
53
|
const shouldForwardProp = (prop: string) => {
|
|
30
54
|
return isPropValid(prop) && !omittedProps.includes(prop);
|
|
@@ -55,9 +79,11 @@ export const boxStyleFn = <P extends BoxProps>(props: P) => {
|
|
|
55
79
|
color,
|
|
56
80
|
depth,
|
|
57
81
|
flexItem,
|
|
82
|
+
font,
|
|
58
83
|
layout,
|
|
59
84
|
position,
|
|
60
85
|
space,
|
|
86
|
+
text,
|
|
61
87
|
].reduce((result, style) => {
|
|
62
88
|
// @ts-ignore
|
|
63
89
|
const temp = typeof style === 'function' ? style(props) : style;
|
|
@@ -79,9 +105,11 @@ const StyledBoxElement = styled('div', {shouldForwardProp})<StyledType & BoxProp
|
|
|
79
105
|
color,
|
|
80
106
|
depth,
|
|
81
107
|
flexItem,
|
|
108
|
+
font,
|
|
82
109
|
layout,
|
|
83
110
|
position,
|
|
84
|
-
space
|
|
111
|
+
space,
|
|
112
|
+
text
|
|
85
113
|
);
|
|
86
114
|
|
|
87
115
|
// Meant to be used with components. There is no `shouldForwardProps` - all props will be forwarded to the component
|
|
@@ -93,10 +121,12 @@ const StyledBoxComponent = styled('div')<StyledType & BoxProps>(
|
|
|
93
121
|
color,
|
|
94
122
|
depth,
|
|
95
123
|
flexItem,
|
|
124
|
+
font,
|
|
96
125
|
layout,
|
|
97
126
|
other,
|
|
98
127
|
position,
|
|
99
|
-
space
|
|
128
|
+
space,
|
|
129
|
+
text
|
|
100
130
|
);
|
|
101
131
|
|
|
102
132
|
/**
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import {createComponent, StyledType} from '@workday/canvas-kit-react/common';
|
|
4
|
+
import {Box, BoxProps} from './Box';
|
|
5
|
+
|
|
6
|
+
import {grid, GridStyleProps} from './utils/grid';
|
|
7
|
+
import {gridItem, GridItemStyleProps} from './utils/gridItem';
|
|
8
|
+
|
|
9
|
+
export type GridProps = BoxProps & GridStyleProps;
|
|
10
|
+
export type GridItemProps = BoxProps & GridItemStyleProps;
|
|
11
|
+
|
|
12
|
+
const StyledGrid = styled(Box)<StyledType & GridProps>(
|
|
13
|
+
{
|
|
14
|
+
display: 'grid',
|
|
15
|
+
},
|
|
16
|
+
grid
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const StyledGridItem = styled(Box)<StyledType & GridItemProps>(gridItem);
|
|
20
|
+
|
|
21
|
+
const GridItem = createComponent('div')({
|
|
22
|
+
displayName: 'Grid.Item',
|
|
23
|
+
Component: ({children, ...elemProps}: GridItemProps, ref, Element) => {
|
|
24
|
+
return (
|
|
25
|
+
<StyledGridItem as={Element} ref={ref} {...elemProps}>
|
|
26
|
+
{children}
|
|
27
|
+
</StyledGridItem>
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `Grid` is a two-dimensional layout system for the web. It lets you lay content out in rows and columns.
|
|
34
|
+
* It is highly flexible, and can be used on its own or to build other components.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```
|
|
38
|
+
* import { Grid } from '@workday/canvas-kit-react/layout';
|
|
39
|
+
* `Grid` is built on top of `Box` and has access to all `BoxProps`.
|
|
40
|
+
*
|
|
41
|
+
* interface CardProps extends GridProps {
|
|
42
|
+
* // card-specific props
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* // `Card`'s default values are set using `GridProps`
|
|
46
|
+
* const Card = (props: CardProps) => (
|
|
47
|
+
* <Grid gridAutoFlow="row" alignItems="start" depth={1} space="m" {...props}>
|
|
48
|
+
* <h1>Hello, Card!</h1>
|
|
49
|
+
* <p>This card uses grid to set its layout.</p>
|
|
50
|
+
* </Grid>
|
|
51
|
+
* );
|
|
52
|
+
*```
|
|
53
|
+
*/
|
|
54
|
+
export const Grid = createComponent('div')({
|
|
55
|
+
displayName: 'Grid',
|
|
56
|
+
Component: ({children, ...elemProps}: GridProps, ref, Element) => {
|
|
57
|
+
return (
|
|
58
|
+
<StyledGrid as={Element} ref={ref} {...elemProps}>
|
|
59
|
+
{children}
|
|
60
|
+
</StyledGrid>
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
subComponents: {
|
|
64
|
+
/**
|
|
65
|
+
* `<Grid.Item />` is the child specific sub-component to `<Grid/>`. `<Grid.Item />` gets child specific props, whereas `<Grid./>` gets parent container props.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```
|
|
69
|
+
* import { Grid } from '@workday/canvas-kit-react/layout';
|
|
70
|
+
* `Grid` is built on top of `Box` so `<Grid.Item />` gets all `BoxProps` as well.
|
|
71
|
+
*
|
|
72
|
+
* interface CardProps extends GridItemStyleProps {
|
|
73
|
+
* // card-specific props
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* // `Card`'s default values are set using `GridItemStyleProps`
|
|
77
|
+
* const Card = (props: CardProps) => (
|
|
78
|
+
* <Grid.Item gridRowStart="1" gridArea="Card" {...props}>
|
|
79
|
+
* <h1>Hello, Card!</h1>
|
|
80
|
+
* <p>This card uses grid child specific props to set its layout.</p>
|
|
81
|
+
* </Grid.Item>
|
|
82
|
+
* );
|
|
83
|
+
*```
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
Item: GridItem,
|
|
87
|
+
},
|
|
88
|
+
});
|
package/layout/lib/Stack.tsx
CHANGED
|
@@ -62,9 +62,9 @@ export interface HStackProps extends StackProps {
|
|
|
62
62
|
|
|
63
63
|
export const HStack = createComponent('div')({
|
|
64
64
|
displayName: 'HStack',
|
|
65
|
-
Component: ({children, ...elemProps}: HStackProps, ref, Element) => {
|
|
65
|
+
Component: ({children, flexDirection = 'row', ...elemProps}: HStackProps, ref, Element) => {
|
|
66
66
|
return (
|
|
67
|
-
<Stack as={Element} ref={ref} flexDirection=
|
|
67
|
+
<Stack as={Element} ref={ref} flexDirection={flexDirection} {...elemProps}>
|
|
68
68
|
{children}
|
|
69
69
|
</Stack>
|
|
70
70
|
);
|
|
@@ -84,9 +84,9 @@ export interface VStackProps extends StackProps {
|
|
|
84
84
|
|
|
85
85
|
export const VStack = createComponent('div')({
|
|
86
86
|
displayName: 'VStack',
|
|
87
|
-
Component: ({children, ...elemProps}: VStackProps, ref, Element) => {
|
|
87
|
+
Component: ({children, flexDirection = 'column', ...elemProps}: VStackProps, ref, Element) => {
|
|
88
88
|
return (
|
|
89
|
-
<Stack as={Element} ref={ref} flexDirection=
|
|
89
|
+
<Stack as={Element} ref={ref} flexDirection={flexDirection} {...elemProps}>
|
|
90
90
|
{children}
|
|
91
91
|
</Stack>
|
|
92
92
|
);
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// type changes no need
|
|
2
|
+
import {
|
|
3
|
+
colors as colorTokens,
|
|
4
|
+
CanvasColor,
|
|
5
|
+
CanvasTypeVariants,
|
|
6
|
+
} from '@workday/canvas-kit-react/tokens';
|
|
2
7
|
|
|
3
8
|
export type ColorTokens = typeof colorTokens;
|
|
4
9
|
|
|
@@ -26,7 +31,7 @@ const getBackgroundImage = (value: string) => ({
|
|
|
26
31
|
backgroundImage: value,
|
|
27
32
|
});
|
|
28
33
|
|
|
29
|
-
const getColor = (value: CanvasColor | string) => ({
|
|
34
|
+
const getColor = (value: CanvasColor | keyof CanvasTypeVariants | string) => ({
|
|
30
35
|
color: colorTokens[value] || value,
|
|
31
36
|
});
|
|
32
37
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {Property} from 'csstype';
|
|
2
|
+
import {type, CanvasTypeProperties} from '@workday/canvas-kit-react/tokens';
|
|
3
|
+
|
|
4
|
+
export type FontFamilyTokens = keyof CanvasTypeProperties['fontFamilies'];
|
|
5
|
+
export type FontSizeTokens = keyof CanvasTypeProperties['fontSizes'];
|
|
6
|
+
export type FontWeightTokens = keyof CanvasTypeProperties['fontWeights'];
|
|
7
|
+
type FontValue = FontFamilyTokens & FontSizeTokens & FontWeightTokens;
|
|
8
|
+
|
|
9
|
+
/** style props to for color properties */
|
|
10
|
+
export type FontStyleProps = {
|
|
11
|
+
/** sets `font-family` property */
|
|
12
|
+
fontFamily?: Property.FontFamily | FontFamilyTokens;
|
|
13
|
+
/** sets `font-size` property */
|
|
14
|
+
fontSize?: Property.FontSize | FontSizeTokens;
|
|
15
|
+
/** sets `font-style` property */
|
|
16
|
+
fontStyle?: Property.FontStyle;
|
|
17
|
+
/** sets `font-weight` property */
|
|
18
|
+
fontWeight?: Property.FontWeight | FontWeightTokens;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getFontFamily = (value: FontStyleProps['fontFamily']) => ({
|
|
22
|
+
fontFamily: type.properties.fontFamilies[value as FontFamilyTokens] || value,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const getFontSize = (value: FontStyleProps['fontSize']) => ({
|
|
26
|
+
fontSize: type.properties.fontSizes[value as FontSizeTokens] || value,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const getFontStyle = (value: FontStyleProps['fontStyle']) => ({
|
|
30
|
+
fontStyle: value,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const getFontWeight = (value: FontStyleProps['fontWeight']) => ({
|
|
34
|
+
fontWeight: type.properties.fontWeights[value as FontWeightTokens] || value,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const fontProps = {
|
|
38
|
+
fontFamily: getFontFamily,
|
|
39
|
+
fontSize: getFontSize,
|
|
40
|
+
fontWeight: getFontWeight,
|
|
41
|
+
fontStyle: getFontStyle,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A style prop function that takes components props and returns font styles from canvas token values.
|
|
46
|
+
* If no `FontStyleProps` are found, it returns an empty object.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* // You'll most likely use `font` with low-level, styled components
|
|
50
|
+
* const BoxExample = () => (
|
|
51
|
+
* <Box fontFamily="monospace" fontWeight="medium">Hello, fonts!</Box>
|
|
52
|
+
* );
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
export function font<P extends FontStyleProps>(props: P) {
|
|
56
|
+
let styles = {};
|
|
57
|
+
for (const key in props) {
|
|
58
|
+
if (key in fontProps) {
|
|
59
|
+
const value = props[key as keyof FontStyleProps] as FontValue;
|
|
60
|
+
const fontFn = fontProps[key as keyof FontStyleProps];
|
|
61
|
+
const style = fontFn(value);
|
|
62
|
+
styles = {...styles, ...style};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return styles;
|
|
67
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {Property} from 'csstype';
|
|
2
|
+
|
|
3
|
+
/** style props to for grid container properties */
|
|
4
|
+
export type GridStyleProps = {
|
|
5
|
+
/** sets `align-items` property */
|
|
6
|
+
alignItems?: Property.AlignItems;
|
|
7
|
+
/** sets `align-content` property */
|
|
8
|
+
alignContent?: Property.AlignContent;
|
|
9
|
+
/**
|
|
10
|
+
* sets `display` property
|
|
11
|
+
* @default 'grid'
|
|
12
|
+
* */
|
|
13
|
+
display?: 'grid' | 'inline-grid';
|
|
14
|
+
/** sets `justify-items` property */
|
|
15
|
+
justifyItems?: Property.JustifyItems;
|
|
16
|
+
/** sets `justify-content` property */
|
|
17
|
+
justifyContent?: Property.JustifyContent;
|
|
18
|
+
|
|
19
|
+
// Container Types
|
|
20
|
+
/** sets `grid-template` property */
|
|
21
|
+
gridTemplate?: Property.GridTemplate;
|
|
22
|
+
/** sets `grid-template-area` property */
|
|
23
|
+
gridTemplateAreas?: Property.GridTemplateAreas;
|
|
24
|
+
/** sets `grid-template-columns` property */
|
|
25
|
+
gridTemplateColumns?: Property.GridTemplateColumns;
|
|
26
|
+
/** sets `grid-template-rows` property */
|
|
27
|
+
gridTemplateRows?: Property.GridTemplateRows;
|
|
28
|
+
/** sets `gap` property */
|
|
29
|
+
gridGap?: Property.GridGap;
|
|
30
|
+
/** sets `column-gap` property */
|
|
31
|
+
gridColumnGap?: Property.GridColumnGap;
|
|
32
|
+
/** sets `row-gap` property */
|
|
33
|
+
gridRowGap?: Property.GridRowGap;
|
|
34
|
+
/** sets `place-items` property */
|
|
35
|
+
gridPlaceItems?: Property.PlaceItems;
|
|
36
|
+
/** sets `grid-auto-columns` property */
|
|
37
|
+
gridAutoColumns?: Property.GridAutoColumns;
|
|
38
|
+
/** sets `grid-auto-rows` property */
|
|
39
|
+
gridAutoRows?: Property.GridAutoRows;
|
|
40
|
+
/** sets `grid-area` property */
|
|
41
|
+
gridArea?: Property.GridArea;
|
|
42
|
+
/** sets `grid-auto-flow` property */
|
|
43
|
+
gridAutoFlow?: Property.GridAutoFlow;
|
|
44
|
+
/** sets `grid` property */
|
|
45
|
+
grid?: Property.Grid;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const gridProps = {
|
|
49
|
+
alignContent: 'alignContent',
|
|
50
|
+
alignItems: 'alignItems',
|
|
51
|
+
display: 'display',
|
|
52
|
+
justifyContent: 'justifyContent',
|
|
53
|
+
justifyItems: 'justifyItems',
|
|
54
|
+
gridTemplateAreas: 'gridTemplateAreas',
|
|
55
|
+
gridTemplate: 'gridTemplate',
|
|
56
|
+
gridTemplateColumns: 'gridTemplateColumns',
|
|
57
|
+
gridTemplateRows: 'gridTemplateRows',
|
|
58
|
+
gridGap: 'gridGap',
|
|
59
|
+
gridColumnGap: 'gridColumnGap',
|
|
60
|
+
gridRowGap: 'gridRowGap',
|
|
61
|
+
gridPlaceItems: 'gridPlaceItems',
|
|
62
|
+
gridAutoColumns: 'gridAutoColumns',
|
|
63
|
+
gridAutoRows: 'gridAutoRows',
|
|
64
|
+
gridAutoFlow: 'gridAutoFlow',
|
|
65
|
+
gridArea: 'gridArea',
|
|
66
|
+
grid: 'grid',
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A style prop function that takes component props and returns grid styles.
|
|
71
|
+
* If no `GridStyleProps` are found, it returns an empty object.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // You'll most likely use `grid` with low-level, styled components
|
|
75
|
+
* const GridExample = () => (
|
|
76
|
+
* <Grid gridAutoFlow="row" justifyContent="center" alignItems="center">
|
|
77
|
+
* Hello, Grid!
|
|
78
|
+
* </Grid>
|
|
79
|
+
* );
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
export function grid<P extends GridStyleProps>(props: P) {
|
|
83
|
+
const styles = {};
|
|
84
|
+
for (const key in props) {
|
|
85
|
+
if (key in gridProps) {
|
|
86
|
+
const attr = gridProps[key as keyof GridStyleProps];
|
|
87
|
+
const value = props[key];
|
|
88
|
+
// @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
|
|
89
|
+
styles[attr] = value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return styles;
|
|
93
|
+
}
|