@workday/canvas-kit-react 8.0.0-alpha.208-next.1 → 8.0.0-alpha.216-next.4
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/common/lib/utils/elements.ts +4 -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/common/lib/utils/elements.d.ts +1 -1
- package/dist/commonjs/common/lib/utils/elements.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/elements.js +3 -3
- package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
- package/dist/commonjs/icon/lib/SystemIcon.d.ts +1 -1
- package/dist/commonjs/icon/lib/SystemIcon.d.ts.map +1 -1
- package/dist/commonjs/layout/index.d.ts +8 -4
- package/dist/commonjs/layout/index.d.ts.map +1 -1
- package/dist/commonjs/layout/index.js +10 -2
- package/dist/commonjs/layout/lib/Box.d.ts +6 -4
- package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/Box.js +8 -9
- package/dist/commonjs/layout/lib/Flex.d.ts +5 -2
- package/dist/commonjs/layout/lib/Flex.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/Flex.js +5 -1
- package/dist/commonjs/layout/lib/Grid.d.ts +5 -6
- package/dist/commonjs/layout/lib/Grid.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/Grid.js +2 -2
- package/dist/commonjs/layout/lib/Stack.d.ts +4 -4
- package/dist/commonjs/layout/lib/utils/background.d.ts +44 -0
- package/dist/commonjs/layout/lib/utils/background.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/background.js +57 -0
- package/dist/commonjs/layout/lib/utils/border/color.d.ts +47 -0
- package/dist/commonjs/layout/lib/utils/border/color.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/border/color.js +42 -0
- package/dist/commonjs/layout/lib/utils/border/index.d.ts +26 -0
- package/dist/commonjs/layout/lib/utils/border/index.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/border/index.js +46 -0
- package/dist/commonjs/layout/lib/utils/border/lineStyle.d.ts +38 -0
- package/dist/commonjs/layout/lib/utils/border/lineStyle.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/border/lineStyle.js +52 -0
- package/dist/commonjs/layout/lib/utils/border/radius.d.ts +33 -0
- package/dist/commonjs/layout/lib/utils/border/radius.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/border/radius.js +32 -0
- package/dist/commonjs/layout/lib/utils/border/shorthand.d.ts +34 -0
- package/dist/commonjs/layout/lib/utils/border/shorthand.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/border/shorthand.js +42 -0
- package/dist/commonjs/layout/lib/utils/border/width.d.ts +34 -0
- package/dist/commonjs/layout/lib/utils/border/width.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/border/width.js +42 -0
- package/dist/commonjs/layout/lib/utils/buildStyleFns.d.ts +12 -0
- package/dist/commonjs/layout/lib/utils/buildStyleFns.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/buildStyleFns.js +90 -0
- package/dist/commonjs/layout/lib/utils/color.d.ts +23 -16
- package/dist/commonjs/layout/lib/utils/color.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/color.js +25 -49
- package/dist/commonjs/layout/lib/utils/depth.d.ts +17 -11
- package/dist/commonjs/layout/lib/utils/depth.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/depth.js +20 -20
- package/dist/commonjs/layout/lib/utils/flex.d.ts +31 -12
- package/dist/commonjs/layout/lib/utils/flex.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/flex.js +58 -25
- package/dist/commonjs/layout/lib/utils/flexItem.d.ts +18 -15
- package/dist/commonjs/layout/lib/utils/flexItem.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/flexItem.js +43 -26
- package/dist/commonjs/layout/lib/utils/grid.d.ts +40 -35
- package/dist/commonjs/layout/lib/utils/grid.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/grid.js +99 -72
- package/dist/commonjs/layout/lib/utils/gridItem.d.ts +17 -14
- package/dist/commonjs/layout/lib/utils/gridItem.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/gridItem.js +58 -30
- package/dist/commonjs/layout/lib/utils/layout.d.ts +47 -25
- package/dist/commonjs/layout/lib/utils/layout.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/layout.js +71 -33
- package/dist/commonjs/layout/lib/utils/other.d.ts +44 -2
- package/dist/commonjs/layout/lib/utils/other.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/other.js +101 -17
- package/dist/commonjs/layout/lib/utils/position.d.ts +37 -20
- package/dist/commonjs/layout/lib/utils/position.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/position.js +49 -66
- package/dist/commonjs/layout/lib/utils/space.d.ts +107 -51
- package/dist/commonjs/layout/lib/utils/space.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/space.js +98 -148
- package/dist/commonjs/layout/lib/utils/stack.d.ts +3 -6
- package/dist/commonjs/layout/lib/utils/stack.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/stack.js +13 -39
- package/dist/commonjs/layout/lib/utils/systemProps.d.ts +31 -0
- package/dist/commonjs/layout/lib/utils/systemProps.d.ts.map +1 -0
- package/dist/commonjs/layout/lib/utils/systemProps.js +2 -0
- package/dist/commonjs/layout/lib/utils/text.d.ts +33 -15
- package/dist/commonjs/layout/lib/utils/text.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/utils/text.js +74 -38
- package/dist/commonjs/modal/lib/Modal.d.ts +1 -1
- 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/hooks/useReturnFocus.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/hooks/useReturnFocus.js +72 -1
- package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/commonjs/tokens/lib/colors.types.d.ts +4 -6
- package/dist/commonjs/tokens/lib/colors.types.d.ts.map +1 -1
- 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/common/lib/utils/elements.d.ts +1 -1
- package/dist/es6/common/lib/utils/elements.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/elements.js +3 -3
- package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
- package/dist/es6/icon/lib/SystemIcon.d.ts +1 -1
- package/dist/es6/icon/lib/SystemIcon.d.ts.map +1 -1
- package/dist/es6/layout/index.d.ts +8 -4
- package/dist/es6/layout/index.d.ts.map +1 -1
- package/dist/es6/layout/index.js +7 -1
- package/dist/es6/layout/lib/Box.d.ts +6 -4
- package/dist/es6/layout/lib/Box.d.ts.map +1 -1
- package/dist/es6/layout/lib/Box.js +8 -9
- package/dist/es6/layout/lib/Flex.d.ts +5 -2
- package/dist/es6/layout/lib/Flex.d.ts.map +1 -1
- package/dist/es6/layout/lib/Flex.js +5 -1
- package/dist/es6/layout/lib/Grid.d.ts +5 -6
- package/dist/es6/layout/lib/Grid.d.ts.map +1 -1
- package/dist/es6/layout/lib/Grid.js +2 -2
- package/dist/es6/layout/lib/Stack.d.ts +4 -4
- package/dist/es6/layout/lib/utils/background.d.ts +44 -0
- package/dist/es6/layout/lib/utils/background.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/background.js +54 -0
- package/dist/es6/layout/lib/utils/border/color.d.ts +47 -0
- package/dist/es6/layout/lib/utils/border/color.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/border/color.js +39 -0
- package/dist/es6/layout/lib/utils/border/index.d.ts +26 -0
- package/dist/es6/layout/lib/utils/border/index.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/border/index.js +43 -0
- package/dist/es6/layout/lib/utils/border/lineStyle.d.ts +38 -0
- package/dist/es6/layout/lib/utils/border/lineStyle.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/border/lineStyle.js +49 -0
- package/dist/es6/layout/lib/utils/border/radius.d.ts +33 -0
- package/dist/es6/layout/lib/utils/border/radius.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/border/radius.js +29 -0
- package/dist/es6/layout/lib/utils/border/shorthand.d.ts +34 -0
- package/dist/es6/layout/lib/utils/border/shorthand.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/border/shorthand.js +39 -0
- package/dist/es6/layout/lib/utils/border/width.d.ts +34 -0
- package/dist/es6/layout/lib/utils/border/width.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/border/width.js +39 -0
- package/dist/es6/layout/lib/utils/buildStyleFns.d.ts +12 -0
- package/dist/es6/layout/lib/utils/buildStyleFns.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/buildStyleFns.js +85 -0
- package/dist/es6/layout/lib/utils/color.d.ts +23 -16
- package/dist/es6/layout/lib/utils/color.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/color.js +24 -47
- package/dist/es6/layout/lib/utils/depth.d.ts +17 -11
- package/dist/es6/layout/lib/utils/depth.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/depth.js +19 -18
- package/dist/es6/layout/lib/utils/flex.d.ts +31 -12
- package/dist/es6/layout/lib/utils/flex.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/flex.js +57 -23
- package/dist/es6/layout/lib/utils/flexItem.d.ts +18 -15
- package/dist/es6/layout/lib/utils/flexItem.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/flexItem.js +42 -24
- package/dist/es6/layout/lib/utils/grid.d.ts +40 -35
- package/dist/es6/layout/lib/utils/grid.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/grid.js +98 -70
- package/dist/es6/layout/lib/utils/gridItem.d.ts +17 -14
- package/dist/es6/layout/lib/utils/gridItem.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/gridItem.js +57 -28
- package/dist/es6/layout/lib/utils/layout.d.ts +47 -25
- package/dist/es6/layout/lib/utils/layout.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/layout.js +70 -31
- package/dist/es6/layout/lib/utils/other.d.ts +44 -2
- package/dist/es6/layout/lib/utils/other.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/other.js +100 -15
- package/dist/es6/layout/lib/utils/position.d.ts +37 -20
- package/dist/es6/layout/lib/utils/position.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/position.js +48 -64
- package/dist/es6/layout/lib/utils/space.d.ts +107 -51
- package/dist/es6/layout/lib/utils/space.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/space.js +97 -146
- package/dist/es6/layout/lib/utils/stack.d.ts +3 -6
- package/dist/es6/layout/lib/utils/stack.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/stack.js +13 -39
- package/dist/es6/layout/lib/utils/systemProps.d.ts +31 -0
- package/dist/es6/layout/lib/utils/systemProps.d.ts.map +1 -0
- package/dist/es6/layout/lib/utils/systemProps.js +1 -0
- package/dist/es6/layout/lib/utils/text.d.ts +33 -15
- package/dist/es6/layout/lib/utils/text.d.ts.map +1 -1
- package/dist/es6/layout/lib/utils/text.js +73 -36
- package/dist/es6/modal/lib/Modal.d.ts +1 -1
- 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/hooks/useReturnFocus.d.ts.map +1 -1
- package/dist/es6/popup/lib/hooks/useReturnFocus.js +73 -2
- package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/es6/tokens/lib/colors.types.d.ts +4 -6
- package/dist/es6/tokens/lib/colors.types.d.ts.map +1 -1
- package/icon/lib/SystemIcon.tsx +1 -1
- package/layout/index.ts +8 -4
- package/layout/lib/Box.tsx +10 -36
- package/layout/lib/Flex.tsx +5 -1
- package/layout/lib/Grid.tsx +3 -4
- package/layout/lib/utils/background.ts +83 -0
- package/layout/lib/utils/border/color.ts +85 -0
- package/layout/lib/utils/border/index.ts +49 -0
- package/layout/lib/utils/border/lineStyle.ts +87 -0
- package/layout/lib/utils/border/radius.ts +61 -0
- package/layout/lib/utils/border/shorthand.ts +73 -0
- package/layout/lib/utils/border/width.ts +73 -0
- package/layout/lib/utils/buildStyleFns.ts +117 -0
- package/layout/lib/utils/color.ts +40 -55
- package/layout/lib/utils/depth.ts +28 -24
- package/layout/lib/utils/flex.ts +83 -32
- package/layout/lib/utils/flexItem.ts +54 -36
- package/layout/lib/utils/grid.ts +131 -94
- package/layout/lib/utils/gridItem.ts +69 -41
- package/layout/lib/utils/layout.ts +109 -50
- package/layout/lib/utils/other.ts +142 -15
- package/layout/lib/utils/position.ts +79 -73
- package/layout/lib/utils/space.ts +202 -196
- package/layout/lib/utils/stack.ts +19 -45
- package/layout/lib/utils/systemProps.ts +46 -0
- package/layout/lib/utils/text.ts +99 -34
- package/package.json +3 -3
- package/popup/lib/hooks/useReturnFocus.tsx +82 -3
- package/tokens/lib/colors.types.ts +4 -7
- package/dist/commonjs/layout/lib/utils/border.d.ts +0 -103
- package/dist/commonjs/layout/lib/utils/border.d.ts.map +0 -1
- package/dist/commonjs/layout/lib/utils/border.js +0 -153
- package/dist/commonjs/layout/lib/utils/font.d.ts +0 -29
- package/dist/commonjs/layout/lib/utils/font.d.ts.map +0 -1
- package/dist/commonjs/layout/lib/utils/font.js +0 -57
- package/dist/es6/layout/lib/utils/border.d.ts +0 -103
- package/dist/es6/layout/lib/utils/border.d.ts.map +0 -1
- package/dist/es6/layout/lib/utils/border.js +0 -149
- package/dist/es6/layout/lib/utils/font.d.ts +0 -29
- package/dist/es6/layout/lib/utils/font.d.ts.map +0 -1
- package/dist/es6/layout/lib/utils/font.js +0 -53
- package/layout/lib/utils/border.ts +0 -263
- package/layout/lib/utils/font.ts +0 -67
package/layout/lib/utils/text.ts
CHANGED
|
@@ -1,57 +1,122 @@
|
|
|
1
1
|
import {Property} from 'csstype';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import {buildStyleFns, buildStylePropFn, StyleFnConfig} from './buildStyleFns';
|
|
4
|
+
import {SystemPropValues} from './systemProps';
|
|
5
|
+
|
|
6
|
+
/** style props to for CSS font and text properties */
|
|
4
7
|
export type TextStyleProps = {
|
|
5
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* - sets [CSS font-family property](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family)
|
|
10
|
+
* - system tokens: `font` */
|
|
11
|
+
fontFamily?: Property.FontFamily | SystemPropValues['font'];
|
|
12
|
+
/**
|
|
13
|
+
* - sets [CSS font-size property](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size)
|
|
14
|
+
* - system tokens: `fontSize` */
|
|
15
|
+
fontSize?: Property.FontSize | SystemPropValues['fontSize'];
|
|
16
|
+
/** sets [CSS font-style property](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style) */
|
|
17
|
+
fontStyle?: Property.FontStyle;
|
|
18
|
+
/**
|
|
19
|
+
* - sets [CSS font-weight property](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight)
|
|
20
|
+
* - system tokens: `fontWeight` */
|
|
21
|
+
fontWeight?: Property.FontWeight | SystemPropValues['fontWeight'];
|
|
22
|
+
/** sets [CSS line-height property](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height) */
|
|
6
23
|
lineHeight?: Property.LineHeight;
|
|
7
|
-
/** sets
|
|
24
|
+
/** sets [CSS letter-spacing property](https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing) */
|
|
8
25
|
letterSpacing?: Property.LetterSpacing;
|
|
9
|
-
/** sets
|
|
26
|
+
/** sets [CSS text-align property](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) */
|
|
10
27
|
textAlign?: Property.TextAlign;
|
|
11
|
-
/** sets
|
|
28
|
+
/** sets [CSS text-decoration property](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration) */
|
|
12
29
|
textDecoration?: Property.TextDecoration;
|
|
13
|
-
/** sets
|
|
30
|
+
/** sets [CSS text-overflow property](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow) */
|
|
14
31
|
textOverflow?: Property.TextOverflow;
|
|
15
|
-
/** sets
|
|
32
|
+
/** sets [CSS text-transform property](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform) */
|
|
16
33
|
textTransform?: Property.TextTransform;
|
|
17
|
-
/** sets
|
|
34
|
+
/** sets [CSS text-shadow property](https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow) */
|
|
18
35
|
textShadow?: Property.TextShadow;
|
|
19
|
-
/** sets
|
|
36
|
+
/** sets [CSS white-space property](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space) */
|
|
20
37
|
whiteSpace?: Property.WhiteSpace;
|
|
21
|
-
/** sets
|
|
38
|
+
/** sets [CSS word-break property](https://developer.mozilla.org/en-US/docs/Web/CSS/word-break) */
|
|
22
39
|
wordBreak?: Property.WordBreak;
|
|
23
40
|
};
|
|
24
41
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
export const textStyleFnConfigs: StyleFnConfig[] = [
|
|
43
|
+
{
|
|
44
|
+
name: 'fontFamily',
|
|
45
|
+
properties: ['fontFamily'],
|
|
46
|
+
system: 'font',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'fontSize',
|
|
50
|
+
properties: ['fontSize'],
|
|
51
|
+
system: 'fontSize',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'fontStyle',
|
|
55
|
+
properties: ['fontStyle'],
|
|
56
|
+
system: 'none',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'fontWeight',
|
|
60
|
+
properties: ['fontWeight'],
|
|
61
|
+
system: 'fontWeight',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'lineHeight',
|
|
65
|
+
properties: ['lineHeight'],
|
|
66
|
+
system: 'none',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'letterSpacing',
|
|
70
|
+
properties: ['letterSpacing'],
|
|
71
|
+
system: 'none',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'textAlign',
|
|
75
|
+
properties: ['textAlign'],
|
|
76
|
+
system: 'none',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'textDecoration',
|
|
80
|
+
properties: ['textDecoration'],
|
|
81
|
+
system: 'none',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'textOverflow',
|
|
85
|
+
properties: ['textOverflow'],
|
|
86
|
+
system: 'none',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'textTransform',
|
|
90
|
+
properties: ['textTransform'],
|
|
91
|
+
system: 'none',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'textShadow',
|
|
95
|
+
properties: ['textShadow'],
|
|
96
|
+
system: 'none',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'whiteSpace',
|
|
100
|
+
properties: ['whiteSpace'],
|
|
101
|
+
system: 'none',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'wordBreak',
|
|
105
|
+
properties: ['wordBreak'],
|
|
106
|
+
system: 'none',
|
|
107
|
+
},
|
|
35
108
|
];
|
|
36
109
|
|
|
110
|
+
export const textStyleFns = buildStyleFns(textStyleFnConfigs);
|
|
37
111
|
/**
|
|
38
|
-
* A style prop function that takes
|
|
112
|
+
* A style prop function that takes component props and returns font and text styles.
|
|
39
113
|
* If no `TextStyleProps` are found, it returns an empty object.
|
|
40
114
|
*
|
|
41
115
|
* @example
|
|
42
|
-
*
|
|
116
|
+
* ```
|
|
43
117
|
* const BoxExample = () => (
|
|
44
|
-
* <Box textAlign="center">Hello, alignment!</Box>
|
|
118
|
+
* <Box textAlign="center" fontWeight="medium">Hello, alignment!</Box>
|
|
45
119
|
* );
|
|
46
|
-
*
|
|
120
|
+
* ```
|
|
47
121
|
*/
|
|
48
|
-
export
|
|
49
|
-
let styles = {};
|
|
50
|
-
for (const key in props) {
|
|
51
|
-
if (textProps.includes(key)) {
|
|
52
|
-
const value = props[key as keyof TextStyleProps] as string;
|
|
53
|
-
styles = {...styles, [key]: value};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return styles;
|
|
57
|
-
}
|
|
122
|
+
export const text = buildStylePropFn<TextStyleProps>(textStyleFns);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.216-next.4+df0f1156",
|
|
4
4
|
"description": "The parent module that contains all Workday Canvas Kit React components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@emotion/styled": "^11.6.0",
|
|
50
50
|
"@popperjs/core": "^2.5.4",
|
|
51
51
|
"@workday/canvas-colors-web": "^2.0.0",
|
|
52
|
-
"@workday/canvas-kit-popup-stack": "^8.0.0-alpha.
|
|
52
|
+
"@workday/canvas-kit-popup-stack": "^8.0.0-alpha.216-next.4+df0f1156",
|
|
53
53
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
54
54
|
"@workday/design-assets-types": "^0.2.8",
|
|
55
55
|
"chroma-js": "^2.1.0",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"@workday/canvas-accent-icons-web": "^3.0.0",
|
|
68
68
|
"@workday/canvas-applet-icons-web": "^2.0.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "df0f115637454a88469b36a9686c0c666995290f"
|
|
71
71
|
}
|
|
@@ -1,9 +1,35 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import {changeFocus, createElemPropsHook} from '@workday/canvas-kit-react/common';
|
|
3
|
+
import {changeFocus, createElemPropsHook, isFocusable} from '@workday/canvas-kit-react/common';
|
|
4
4
|
|
|
5
5
|
import {usePopupModel} from './usePopupModel';
|
|
6
6
|
|
|
7
|
+
function getScrollParent(element: HTMLElement): HTMLElement {
|
|
8
|
+
if (element === document.body || !element.parentElement) {
|
|
9
|
+
return element;
|
|
10
|
+
}
|
|
11
|
+
const styles = getComputedStyle(element);
|
|
12
|
+
|
|
13
|
+
if (styles.overflowY === 'scroll' || styles.overflowY === 'auto') {
|
|
14
|
+
return element;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return getScrollParent(element.parentElement);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get a focusable element in an element's tree
|
|
22
|
+
*/
|
|
23
|
+
function getFocusableElement(element: Element | null): Element | null {
|
|
24
|
+
if (element === null || element === document.body || !element.parentElement) {
|
|
25
|
+
return null;
|
|
26
|
+
} else if (isFocusable(element)) {
|
|
27
|
+
return element;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return getFocusableElement(element.parentElement);
|
|
31
|
+
}
|
|
32
|
+
|
|
7
33
|
/**
|
|
8
34
|
* Returns focus to the target element when the popup is hidden. This works well with
|
|
9
35
|
* `useInitialFocus`. This should be used with `useFocusRedirect` or `useFocusTrap` for a complete
|
|
@@ -13,6 +39,7 @@ import {usePopupModel} from './usePopupModel';
|
|
|
13
39
|
*/
|
|
14
40
|
export const useReturnFocus = createElemPropsHook(usePopupModel)(model => {
|
|
15
41
|
const visible = model.state.visibility !== 'hidden';
|
|
42
|
+
const elementRef = React.useRef<Element | null>(null);
|
|
16
43
|
|
|
17
44
|
// This boolean tracks keyboard-driven focus changes. This is required for `useFocusRedirect` as
|
|
18
45
|
// focus redirection needs synchronous focus management and everything else needs asynchronous
|
|
@@ -30,19 +57,62 @@ export const useReturnFocus = createElemPropsHook(usePopupModel)(model => {
|
|
|
30
57
|
requiresFocusChangeRef.current = false;
|
|
31
58
|
}, []);
|
|
32
59
|
|
|
60
|
+
// track mousedown events to determine if the mouse target is a focusable element. If it is, we
|
|
61
|
+
// should not return focus
|
|
62
|
+
const onMouseDown = React.useCallback((event: MouseEvent) => {
|
|
63
|
+
elementRef.current = event.target as Element;
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
const onMouseUp = React.useCallback(() => {
|
|
67
|
+
elementRef.current = null;
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
// We use `useLayoutEffect` because the callback will be called _before_ the browser changes
|
|
71
|
+
// focus. This allows the browser to change focus as normal. For example, if the popup closes
|
|
72
|
+
// because the user hits the tab key when focused on the last focusable element,
|
|
73
|
+
// `useFocusRedirect` will cause the popup to close before the browser is finished processing the
|
|
74
|
+
// `keydown`. The browser's default action of a keydown of a tab key is to advance focus to the
|
|
75
|
+
// next focusable element. This means that the `useFocusRedirect` will change focus back to the
|
|
76
|
+
// target, then the tab key is processed by the browser to focus on the next item after the target
|
|
77
|
+
// without us having to use a focus manager to guess what the next focusable element is.
|
|
78
|
+
//
|
|
79
|
+
// But because we're using `useLayoutEffect` instead of `useEffect`, we cannot use
|
|
80
|
+
// `document.activeElement` (because the focus hasn't changed yet because the browser hasn't
|
|
81
|
+
// triggered a default action yet) to determine if a user clicked on something that can accept
|
|
82
|
+
// focus itself. If we don't short-circuit return focus, the user will intend to click on an
|
|
83
|
+
// `input` element only to get focus changed back. This is annoying to users and unintuitive. Instead,
|
|
84
|
+
// we'll use `mousedown` and `mouseup` to determine if we're closing because of a mouse click.
|
|
33
85
|
React.useLayoutEffect(() => {
|
|
34
86
|
if (!visible) {
|
|
35
87
|
return;
|
|
36
88
|
}
|
|
37
89
|
// capture the element here. The refs will be null by the time the cleanup function is called
|
|
38
90
|
const element = (model.state.returnFocusRef || model.state.targetRef).current as HTMLElement;
|
|
39
|
-
|
|
91
|
+
document.addEventListener('mousedown', onMouseDown, true);
|
|
92
|
+
document.addEventListener('mouseup', onMouseUp, true);
|
|
40
93
|
document.addEventListener('keydown', onKeyDown, true);
|
|
41
94
|
document.addEventListener('keyup', onKeyUp, true);
|
|
42
95
|
|
|
43
96
|
return () => {
|
|
97
|
+
document.removeEventListener('mousedown', onMouseDown, true);
|
|
98
|
+
document.removeEventListener('mouseup', onMouseUp, true);
|
|
44
99
|
document.removeEventListener('keydown', onKeyDown, true);
|
|
45
100
|
document.removeEventListener('keyup', onKeyUp, true);
|
|
101
|
+
const scrollParent = getScrollParent(element);
|
|
102
|
+
const scrollParentRect = scrollParent.getBoundingClientRect();
|
|
103
|
+
const elementRect = element.getBoundingClientRect();
|
|
104
|
+
|
|
105
|
+
// Don't change focus if user focused on a different element like a `input` or the target
|
|
106
|
+
// element isn't on at least halfway rendered on the screen.
|
|
107
|
+
if (
|
|
108
|
+
(elementRef.current && getFocusableElement(elementRef.current)) ||
|
|
109
|
+
elementRect.top + elementRect.height / 2 < scrollParentRect.top ||
|
|
110
|
+
elementRect.bottom - elementRect.height / 2 > scrollParentRect.bottom ||
|
|
111
|
+
elementRect.left + elementRect.width / 2 < scrollParentRect.left ||
|
|
112
|
+
elementRect.right - elementRect.width / 2 > scrollParentRect.right
|
|
113
|
+
) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
46
116
|
|
|
47
117
|
if (requiresFocusChangeRef.current) {
|
|
48
118
|
// We need to change focus _before_ the browser process the default action of picking a new
|
|
@@ -56,8 +126,17 @@ export const useReturnFocus = createElemPropsHook(usePopupModel)(model => {
|
|
|
56
126
|
changeFocus(element);
|
|
57
127
|
});
|
|
58
128
|
}
|
|
129
|
+
elementRef.current = null;
|
|
59
130
|
};
|
|
60
|
-
}, [
|
|
131
|
+
}, [
|
|
132
|
+
model.state.returnFocusRef,
|
|
133
|
+
model.state.targetRef,
|
|
134
|
+
visible,
|
|
135
|
+
onMouseDown,
|
|
136
|
+
onMouseUp,
|
|
137
|
+
onKeyDown,
|
|
138
|
+
onKeyUp,
|
|
139
|
+
]);
|
|
61
140
|
|
|
62
141
|
return {};
|
|
63
142
|
});
|
|
@@ -27,11 +27,8 @@ export enum BrandingColor {
|
|
|
27
27
|
BlackPepper = 'blackPepper',
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} extends {[_ in keyof T]: infer U}
|
|
34
|
-
? U
|
|
35
|
-
: never;
|
|
30
|
+
type RemoveIndex<T> = {
|
|
31
|
+
[ K in keyof T as string extends K ? never : number extends K ? never : K ] : T[K]
|
|
32
|
+
};
|
|
36
33
|
|
|
37
|
-
export type CanvasColor =
|
|
34
|
+
export type CanvasColor = keyof RemoveIndex<typeof colors>;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { CanvasBorderRadiusKeys, CanvasColor } from '@workday/canvas-kit-react/tokens';
|
|
2
|
-
import { PartialEmotionCanvasTheme } from '@workday/canvas-kit-react/common';
|
|
3
|
-
import { Property } from 'csstype';
|
|
4
|
-
/** style props to set the border properties */
|
|
5
|
-
export declare type BorderShorthandStyleProps = {
|
|
6
|
-
/** sets `border` property */
|
|
7
|
-
border?: string;
|
|
8
|
-
/** sets `border-top` property */
|
|
9
|
-
borderTop?: string;
|
|
10
|
-
/** sets `border-right` property (no bidirectional support) */
|
|
11
|
-
borderRight?: string;
|
|
12
|
-
/** sets `border-bottom` property */
|
|
13
|
-
borderBottom?: string;
|
|
14
|
-
/** sets `border-left` property (no bidirectional support) */
|
|
15
|
-
borderLeft?: string;
|
|
16
|
-
};
|
|
17
|
-
/** style props to set the border color properties */
|
|
18
|
-
export declare type BorderColorStyleProps = {
|
|
19
|
-
/** sets `border-color` property */
|
|
20
|
-
borderColor?: CanvasColor | (string & {});
|
|
21
|
-
/** sets `border-top-color` property */
|
|
22
|
-
borderTopColor?: CanvasColor | (string & {});
|
|
23
|
-
/** sets `border-right-color` property (no bidirectional support) */
|
|
24
|
-
borderRightColor?: CanvasColor | (string & {});
|
|
25
|
-
/** sets `border-bottom-color` property */
|
|
26
|
-
borderBottomColor?: CanvasColor | (string & {});
|
|
27
|
-
/** sets `border-left-color` property (no bidirectional support) */
|
|
28
|
-
borderLeftColor?: CanvasColor | (string & {});
|
|
29
|
-
};
|
|
30
|
-
/** style props to set the border radius properties */
|
|
31
|
-
export declare type BorderRadiusStyleProps = {
|
|
32
|
-
/** sets `border-radius` property */
|
|
33
|
-
borderRadius?: CanvasBorderRadiusKeys | number | (string & {});
|
|
34
|
-
/** sets `border-top-left-radius` property */
|
|
35
|
-
borderTopLeftRadius?: CanvasBorderRadiusKeys | number | (string & {});
|
|
36
|
-
/** sets `border-top-right-radius` property */
|
|
37
|
-
borderTopRightRadius?: CanvasBorderRadiusKeys | number | (string & {});
|
|
38
|
-
/** sets `border-bottom-left-radius` property */
|
|
39
|
-
borderBottomLeftRadius?: CanvasBorderRadiusKeys | number | (string & {});
|
|
40
|
-
/** sets `border-bottom-right-radius` property */
|
|
41
|
-
borderBottomRightRadius?: CanvasBorderRadiusKeys | number | (string & {});
|
|
42
|
-
};
|
|
43
|
-
/** style props to set the border style properties */
|
|
44
|
-
export declare type BorderLineStyleProps = {
|
|
45
|
-
/** sets `border-style` property */
|
|
46
|
-
borderStyle?: Property.Border;
|
|
47
|
-
/** sets `border-top-style` property */
|
|
48
|
-
borderTopStyle?: Property.Border;
|
|
49
|
-
/** sets `border-right-style` property (no bidirectional support) */
|
|
50
|
-
borderRightStyle?: Property.Border;
|
|
51
|
-
/** sets `border-bottom-style` property */
|
|
52
|
-
borderBottomStyle?: Property.Border;
|
|
53
|
-
/** sets `border-left-style` property (no bidirectional support) */
|
|
54
|
-
borderLeftStyle?: Property.Border;
|
|
55
|
-
};
|
|
56
|
-
/** style props to set the border width properties */
|
|
57
|
-
export declare type BorderWidthStyleProps = {
|
|
58
|
-
/** sets `border-width` property */
|
|
59
|
-
borderWidth?: string | number;
|
|
60
|
-
/** sets `border-top-width` property */
|
|
61
|
-
borderTopWidth?: string | number;
|
|
62
|
-
/** sets `border-right-width` property (no bidirectional support) */
|
|
63
|
-
borderRightWidth?: string | number;
|
|
64
|
-
/** sets `border-bottom-width` property */
|
|
65
|
-
borderBottomWidth?: string | number;
|
|
66
|
-
/** sets `border-left-width` property (no bidirectional support) */
|
|
67
|
-
borderLeftWidth?: string | number;
|
|
68
|
-
};
|
|
69
|
-
export declare type BorderLogicalStyleProps = {
|
|
70
|
-
/** sets `border-left` property (bidirectional support) */
|
|
71
|
-
borderInlineStart?: string;
|
|
72
|
-
/** sets `border-left-color` property (bidirectional support) */
|
|
73
|
-
borderInlineStartColor?: CanvasColor | (string & {});
|
|
74
|
-
/** sets `border-left-style` property (bidirectional support) */
|
|
75
|
-
borderInlineStartStyle?: Property.Border;
|
|
76
|
-
/** sets `border-left-width` property (bidirectional support) */
|
|
77
|
-
borderInlineStartWidth?: string | number;
|
|
78
|
-
/** sets `border-right` property (bidirectional support) */
|
|
79
|
-
borderInlineEnd?: string;
|
|
80
|
-
/** sets `border-right-color` property (bidirectional support) */
|
|
81
|
-
borderInlineEndColor?: CanvasColor | (string & {});
|
|
82
|
-
/** sets `border-right-style` property (bidirectional support) */
|
|
83
|
-
borderInlineEndStyle?: Property.Border;
|
|
84
|
-
/** sets `border-right-width` property (bidirectional support) */
|
|
85
|
-
borderInlineEndWidth?: string | number;
|
|
86
|
-
};
|
|
87
|
-
/** a collection style props for border properties */
|
|
88
|
-
export declare type BorderStyleProps = BorderShorthandStyleProps & BorderColorStyleProps & BorderRadiusStyleProps & BorderLineStyleProps & BorderWidthStyleProps & BorderLogicalStyleProps;
|
|
89
|
-
/**
|
|
90
|
-
* A style prop function that takes components props and returns border styles. Some props, such as borderRadius and borderColor, are connected to our design tokens.
|
|
91
|
-
* If no `BorderStyleProps` are found, it returns an empty object.
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* // You'll most likely use `border` with low-level, styled components
|
|
95
|
-
* const BoxExample = () => (
|
|
96
|
-
* <Box border={`solid 1px #333333 ${colors.blackPepper400}`}>Hello, border styles!</Box>
|
|
97
|
-
* );
|
|
98
|
-
*
|
|
99
|
-
*/
|
|
100
|
-
export declare function border<P extends BorderStyleProps & {
|
|
101
|
-
theme?: PartialEmotionCanvasTheme;
|
|
102
|
-
}>(props: P): {};
|
|
103
|
-
//# sourceMappingURL=border.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"border.d.ts","sourceRoot":"","sources":["../../../../../layout/lib/utils/border.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.border = void 0;
|
|
4
|
-
var tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
5
|
-
var common_1 = require("@workday/canvas-kit-react/common");
|
|
6
|
-
// border logical prop handlers
|
|
7
|
-
var borderInlineStart = function (isRTL) { return (isRTL ? 'borderRight' : 'borderLeft'); };
|
|
8
|
-
var borderInlineEnd = function (isRTL) { return (isRTL ? 'borderLeft' : 'borderRight'); };
|
|
9
|
-
var borderInlineStartColor = function (isRTL) { return (isRTL ? 'borderRightColor' : 'borderLeftColor'); };
|
|
10
|
-
var borderInlineEndColor = function (isRTL) { return (isRTL ? 'borderLeftColor' : 'borderRightColor'); };
|
|
11
|
-
var borderInlineStartStyle = function (isRTL) { return (isRTL ? 'borderRightStyle' : 'borderLeftStyle'); };
|
|
12
|
-
var borderInlineEndStyle = function (isRTL) { return (isRTL ? 'borderLeftStyle' : 'borderRightStyle'); };
|
|
13
|
-
var borderInlineStartWidth = function (isRTL) { return (isRTL ? 'borderRightWidth' : 'borderLeftWidth'); };
|
|
14
|
-
var borderInlineEndWidth = function (isRTL) { return (isRTL ? 'borderLeftWidth' : 'borderRightWidth'); };
|
|
15
|
-
var borderShorthandProps = {
|
|
16
|
-
border: 'border',
|
|
17
|
-
borderTop: 'borderTop',
|
|
18
|
-
borderRight: 'borderRight',
|
|
19
|
-
borderBottom: 'borderBottom',
|
|
20
|
-
borderLeft: 'borderLeft',
|
|
21
|
-
borderInlineStart: borderInlineStart,
|
|
22
|
-
borderInlineEnd: borderInlineEnd,
|
|
23
|
-
};
|
|
24
|
-
var borderColors = {
|
|
25
|
-
borderColor: 'borderColor',
|
|
26
|
-
borderTopColor: 'borderTopColor',
|
|
27
|
-
borderRightColor: 'borderRightColor',
|
|
28
|
-
borderBottomColor: 'borderBottomColor',
|
|
29
|
-
borderLeftColor: 'borderLeftColor',
|
|
30
|
-
borderInlineStartColor: borderInlineStartColor,
|
|
31
|
-
borderInlineEndColor: borderInlineEndColor,
|
|
32
|
-
};
|
|
33
|
-
var borderRadii = {
|
|
34
|
-
borderRadius: 'borderRadius',
|
|
35
|
-
borderTopLeftRadius: 'borderTopLeftRadius',
|
|
36
|
-
borderTopRightRadius: 'borderTopRightRadius',
|
|
37
|
-
borderBottomLeftRadius: 'borderBottomLeftRadius',
|
|
38
|
-
borderBottomRightRadius: 'borderBottomRightRadius',
|
|
39
|
-
};
|
|
40
|
-
var borderStyles = {
|
|
41
|
-
borderStyle: 'borderStyle',
|
|
42
|
-
borderTopStyle: 'borderTopStyle',
|
|
43
|
-
borderRightStyle: 'borderRightStyle',
|
|
44
|
-
borderBottomStyle: 'borderBottomStyle',
|
|
45
|
-
borderLeftStyle: 'borderLeftStyle',
|
|
46
|
-
borderInlineStartStyle: borderInlineStartStyle,
|
|
47
|
-
borderInlineEndStyle: borderInlineEndStyle,
|
|
48
|
-
};
|
|
49
|
-
var borderWidths = {
|
|
50
|
-
borderWidth: 'borderWidth',
|
|
51
|
-
borderTopWidth: 'borderTopWidth',
|
|
52
|
-
borderRightWidth: 'borderRightWidth',
|
|
53
|
-
borderBottomWidth: 'borderBottomWidth',
|
|
54
|
-
borderLeftWidth: 'borderLeftWidth',
|
|
55
|
-
borderInlineStartWidth: borderInlineStartWidth,
|
|
56
|
-
borderInlineEndWidth: borderInlineEndWidth,
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* A style prop function that takes components props and returns border styles. Some props, such as borderRadius and borderColor, are connected to our design tokens.
|
|
60
|
-
* If no `BorderStyleProps` are found, it returns an empty object.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* // You'll most likely use `border` with low-level, styled components
|
|
64
|
-
* const BoxExample = () => (
|
|
65
|
-
* <Box border={`solid 1px #333333 ${colors.blackPepper400}`}>Hello, border styles!</Box>
|
|
66
|
-
* );
|
|
67
|
-
*
|
|
68
|
-
*/
|
|
69
|
-
function border(props) {
|
|
70
|
-
// border will always be used within the context of a component, but eslint doesn't know that
|
|
71
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
72
|
-
var canvas = common_1.useTheme(props.theme).canvas;
|
|
73
|
-
var isRTL = canvas.direction === common_1.ContentDirection.RTL;
|
|
74
|
-
var styles = {};
|
|
75
|
-
for (var key in props) {
|
|
76
|
-
if (props.hasOwnProperty(key)) {
|
|
77
|
-
if (key in borderShorthandProps) {
|
|
78
|
-
var value = props[key];
|
|
79
|
-
var attr = void 0;
|
|
80
|
-
if (key === 'borderInlineStart') {
|
|
81
|
-
attr = borderInlineStart(isRTL);
|
|
82
|
-
}
|
|
83
|
-
else if (key === 'borderInlineEnd') {
|
|
84
|
-
attr = borderInlineEnd(isRTL);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
attr = borderShorthandProps[key];
|
|
88
|
-
}
|
|
89
|
-
// @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
|
|
90
|
-
styles[attr] = value;
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
if (key in borderColors) {
|
|
94
|
-
var propValue = props[key];
|
|
95
|
-
var value = tokens_1.colors[propValue] || propValue;
|
|
96
|
-
var attr = void 0;
|
|
97
|
-
if (key === 'borderInlineStartColor') {
|
|
98
|
-
attr = borderInlineStartColor(isRTL);
|
|
99
|
-
}
|
|
100
|
-
else if (key === 'borderInlineEndColor') {
|
|
101
|
-
attr = borderInlineEndColor(isRTL);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
attr = borderColors[key];
|
|
105
|
-
}
|
|
106
|
-
// @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
|
|
107
|
-
styles[attr] = value;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (key in borderRadii) {
|
|
111
|
-
var propValue = props[key];
|
|
112
|
-
var value = tokens_1.borderRadius[propValue] || propValue;
|
|
113
|
-
var attr = borderRadii[key];
|
|
114
|
-
// @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
|
|
115
|
-
styles[attr] = value;
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (key in borderStyles) {
|
|
119
|
-
var value = props[key];
|
|
120
|
-
var attr = void 0;
|
|
121
|
-
if (key === 'borderInlineStartStyle') {
|
|
122
|
-
attr = borderInlineStartStyle(isRTL);
|
|
123
|
-
}
|
|
124
|
-
else if (key === 'borderInlineEndStyle') {
|
|
125
|
-
attr = borderInlineEndStyle(isRTL);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
attr = borderStyles[key];
|
|
129
|
-
}
|
|
130
|
-
// @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
|
|
131
|
-
styles[attr] = value;
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
if (key in borderWidths) {
|
|
135
|
-
var value = props[key];
|
|
136
|
-
var attr = void 0;
|
|
137
|
-
if (key === 'borderInlineStartWidth') {
|
|
138
|
-
attr = borderInlineStartWidth(isRTL);
|
|
139
|
-
}
|
|
140
|
-
else if (key === 'borderInlineEndWidth') {
|
|
141
|
-
attr = borderInlineEndWidth(isRTL);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
attr = borderWidths[key];
|
|
145
|
-
}
|
|
146
|
-
// @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
|
|
147
|
-
styles[attr] = value;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return styles;
|
|
152
|
-
}
|
|
153
|
-
exports.border = border;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Property } from 'csstype';
|
|
2
|
-
import { CanvasTypeProperties } from '@workday/canvas-kit-react/tokens';
|
|
3
|
-
export declare type FontFamilyTokens = keyof CanvasTypeProperties['fontFamilies'];
|
|
4
|
-
export declare type FontSizeTokens = keyof CanvasTypeProperties['fontSizes'];
|
|
5
|
-
export declare type FontWeightTokens = keyof CanvasTypeProperties['fontWeights'];
|
|
6
|
-
/** style props to for color properties */
|
|
7
|
-
export declare type FontStyleProps = {
|
|
8
|
-
/** sets `font-family` property */
|
|
9
|
-
fontFamily?: Property.FontFamily | FontFamilyTokens;
|
|
10
|
-
/** sets `font-size` property */
|
|
11
|
-
fontSize?: Property.FontSize | FontSizeTokens;
|
|
12
|
-
/** sets `font-style` property */
|
|
13
|
-
fontStyle?: Property.FontStyle;
|
|
14
|
-
/** sets `font-weight` property */
|
|
15
|
-
fontWeight?: Property.FontWeight | FontWeightTokens;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* A style prop function that takes components props and returns font styles from canvas token values.
|
|
19
|
-
* If no `FontStyleProps` are found, it returns an empty object.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* // You'll most likely use `font` with low-level, styled components
|
|
23
|
-
* const BoxExample = () => (
|
|
24
|
-
* <Box fontFamily="monospace" fontWeight="medium">Hello, fonts!</Box>
|
|
25
|
-
* );
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
export declare function font<P extends FontStyleProps>(props: P): {};
|
|
29
|
-
//# sourceMappingURL=font.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../../../../layout/lib/utils/font.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AACjC,OAAO,EAAO,oBAAoB,EAAC,MAAM,kCAAkC,CAAC;AAE5E,oBAAY,gBAAgB,GAAG,MAAM,oBAAoB,CAAC,cAAc,CAAC,CAAC;AAC1E,oBAAY,cAAc,GAAG,MAAM,oBAAoB,CAAC,WAAW,CAAC,CAAC;AACrE,oBAAY,gBAAgB,GAAG,MAAM,oBAAoB,CAAC,aAAa,CAAC,CAAC;AAGzE,0CAA0C;AAC1C,oBAAY,cAAc,GAAG;IAC3B,kCAAkC;IAClC,UAAU,CAAC,EAAE,QAAQ,CAAC,UAAU,GAAG,gBAAgB,CAAC;IACpD,gCAAgC;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC,QAAQ,GAAG,cAAc,CAAC;IAC9C,iCAAiC;IACjC,SAAS,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;IAC/B,kCAAkC;IAClC,UAAU,CAAC,EAAE,QAAQ,CAAC,UAAU,GAAG,gBAAgB,CAAC;CACrD,CAAC;AAyBF;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,cAAc,EAAE,KAAK,EAAE,CAAC,MAYtD"}
|