@workday/canvas-kit-docs 9.0.0-alpha.368-next.6 → 9.0.0-alpha.382-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es6/docgen/createTraversals.js +41 -22
- package/dist/es6/docgen/docParser.js +285 -257
- package/dist/es6/docgen/getExternalSymbol.js +2 -2
- package/dist/es6/docgen/plugins/componentParser.js +28 -33
- package/dist/es6/docgen/plugins/enhancedComponentParser.js +211 -150
- package/dist/es6/docgen/plugins/modelParser.js +139 -79
- package/dist/es6/docgen/traversals.js +396 -397
- package/dist/es6/docgen/traverse.js +8 -9
- package/dist/es6/lib/DescriptionTooltip.js +1 -1
- package/dist/es6/lib/MDXElements.js +13 -39
- package/dist/es6/lib/MoreTooltip.js +21 -41
- package/dist/es6/lib/Specifications.js +30 -34
- package/dist/es6/lib/StylePropsTable.js +8 -9
- package/dist/es6/lib/Table.js +19 -30
- package/dist/es6/lib/Value.js +13 -17
- package/dist/es6/lib/docs.js +701 -397
- package/dist/es6/lib/widgetUtils.js +44 -76
- package/dist/es6/lib/widgets/array.js +1 -2
- package/dist/es6/lib/widgets/callExpression.js +4 -5
- package/dist/es6/lib/widgets/canvasColor.js +2 -2
- package/dist/es6/lib/widgets/component.js +1 -2
- package/dist/es6/lib/widgets/conditional.js +1 -2
- package/dist/es6/lib/widgets/enhancedComponent.js +19 -24
- package/dist/es6/lib/widgets/external.js +1 -4
- package/dist/es6/lib/widgets/function.js +5 -7
- package/dist/es6/lib/widgets/intersection.js +3 -4
- package/dist/es6/lib/widgets/model.js +4 -6
- package/dist/es6/lib/widgets/object.js +2 -3
- package/dist/es6/lib/widgets/parenthesis.js +1 -2
- package/dist/es6/lib/widgets/primitives.js +17 -39
- package/dist/es6/lib/widgets/qualifiedName.js +1 -2
- package/dist/es6/lib/widgets/symbol.js +1 -2
- package/dist/es6/lib/widgets/tuple.js +2 -3
- package/dist/es6/lib/widgets/typeParameter.js +1 -2
- package/dist/es6/lib/widgets/union.js +3 -4
- package/dist/es6/mdx/installBlock.js +6 -7
- package/dist/es6/mdx/style-props/examples/Background.js +5 -16
- package/dist/es6/mdx/style-props/examples/Border.js +5 -16
- package/dist/es6/mdx/style-props/examples/Color.js +5 -16
- package/dist/es6/mdx/style-props/examples/Depth.js +5 -16
- package/dist/es6/mdx/style-props/examples/Flex.js +11 -22
- package/dist/es6/mdx/style-props/examples/FlexItem.js +10 -21
- package/dist/es6/mdx/style-props/examples/Grid.js +6 -17
- package/dist/es6/mdx/style-props/examples/GridItem.js +6 -17
- package/dist/es6/mdx/style-props/examples/Layout.js +5 -16
- package/dist/es6/mdx/style-props/examples/Other.js +5 -16
- package/dist/es6/mdx/style-props/examples/Position.js +5 -16
- package/dist/es6/mdx/style-props/examples/Space.js +6 -17
- package/dist/es6/mdx/style-props/examples/Text.js +2 -2
- package/dist/es6/mdx/welcomePage.js +3 -3
- package/dist/mdx/9.0-UPGRADE-GUIDE.mdx +30 -3
- package/dist/mdx/preview-react/text-area/examples/Alert.tsx +1 -1
- package/dist/mdx/preview-react/text-input/examples/Alert.tsx +1 -1
- package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +5 -2
- package/dist/mdx/react/banner/examples/StickyAnimation.tsx +7 -5
- package/dist/mdx/react/common/examples/ResponsiveViewport.tsx +2 -3
- package/package.json +5 -5
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import { guards, getKindNameFromNode } from './traversals';
|
|
2
2
|
export function find(node, predicate) {
|
|
3
|
-
|
|
3
|
+
const nodes = [];
|
|
4
4
|
if (!node) {
|
|
5
5
|
return nodes;
|
|
6
6
|
}
|
|
7
7
|
if (predicate(node)) {
|
|
8
8
|
nodes.push(node);
|
|
9
9
|
}
|
|
10
|
-
node.forEachChild(
|
|
11
|
-
nodes.push
|
|
10
|
+
node.forEachChild(n => {
|
|
11
|
+
nodes.push(...find(n, predicate));
|
|
12
12
|
});
|
|
13
13
|
return nodes;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
let t;
|
|
16
16
|
// @ts-ignore
|
|
17
|
-
t =
|
|
17
|
+
t = node => {
|
|
18
18
|
return {
|
|
19
|
-
find
|
|
20
|
-
|
|
21
|
-
return find(node, function (n) { return guards["is" + kind](n) && predicate(n); });
|
|
19
|
+
find(kind, predicate = n => true) {
|
|
20
|
+
return find(node, n => guards[`is${kind}`](n) && predicate(n));
|
|
22
21
|
},
|
|
23
22
|
};
|
|
24
23
|
};
|
|
25
24
|
t.getKindNameFromNode = getKindNameFromNode;
|
|
26
|
-
Object.keys(guards).forEach(
|
|
25
|
+
Object.keys(guards).forEach(key => {
|
|
27
26
|
// @ts-ignore
|
|
28
27
|
t[key] = guards[key];
|
|
29
28
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import { Tooltip } from '@workday/canvas-kit-react/tooltip';
|
|
3
3
|
import { colors } from '@workday/canvas-kit-react/tokens';
|
|
4
|
-
export
|
|
4
|
+
export const DescriptionTooltip = styled(Tooltip)({
|
|
5
5
|
':before': {
|
|
6
6
|
borderWidth: 1,
|
|
7
7
|
borderStyle: 'solid',
|
|
@@ -1,25 +1,3 @@
|
|
|
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
1
|
//@ts-ignore
|
|
24
2
|
import { useMDXComponents } from '@mdx-js/react';
|
|
25
3
|
import React from 'react';
|
|
@@ -31,10 +9,9 @@ import { HeadingLevelContext, SymbolDialog } from './widgetUtils';
|
|
|
31
9
|
* Canvas Site. This means our docs can use the same components used in our MDX files without
|
|
32
10
|
* needing to use MDX directly.
|
|
33
11
|
*/
|
|
34
|
-
export
|
|
35
|
-
Component
|
|
36
|
-
|
|
37
|
-
var components = useMDXComponents();
|
|
12
|
+
export const MDX = createComponent('div')({
|
|
13
|
+
Component({ children, ...elemProps }, _ref, Element) {
|
|
14
|
+
const components = useMDXComponents();
|
|
38
15
|
return React.createElement(components[Element], elemProps, children);
|
|
39
16
|
},
|
|
40
17
|
});
|
|
@@ -42,8 +19,8 @@ export var MDX = createComponent('div')({
|
|
|
42
19
|
* Custom component that allows us to convert any `button` in JSDoc that contains a `[data-symbol]`
|
|
43
20
|
* to a `<SymbolDialog>` component.
|
|
44
21
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
const Button = (props) => {
|
|
23
|
+
const components = useMDXComponents();
|
|
47
24
|
if (props['data-symbol'] !== undefined) {
|
|
48
25
|
return (React.createElement("code", null,
|
|
49
26
|
React.createElement(SymbolDialog, { value: {
|
|
@@ -60,28 +37,25 @@ var Button = function (props) {
|
|
|
60
37
|
* processing. This allows us to convert {@link SymbolName Link Text} to a `<SymbolDialog>`!
|
|
61
38
|
*/
|
|
62
39
|
function convertLinkToSymbolLinks(input) {
|
|
63
|
-
return input.replace(/{@link ([a-z0-9.]+)( [a-z0-9.]+)?}/gi,
|
|
64
|
-
if (text === void 0) { text = ''; }
|
|
65
|
-
return "<button href=\"#\" data-symbol=\"" + text.trim() + "\" class=\"token symbol\">" + symbol + "</button>";
|
|
66
|
-
});
|
|
40
|
+
return input.replace(/{@link ([a-z0-9.]+)( [a-z0-9.]+)?}/gi, (substr, symbol, text = '') => `<button href="#" data-symbol="${text.trim()}" class="token symbol">${symbol}</button>`);
|
|
67
41
|
}
|
|
68
42
|
/**
|
|
69
43
|
* Replace all heading levels in the JSDoc to start at the same heading level as `startingLevel`.
|
|
70
44
|
* This allows JSDoc markdown to seamlessly flow into MDX.
|
|
71
45
|
*/
|
|
72
46
|
function rewriteHeadingLevels(input, startingLevel) {
|
|
73
|
-
|
|
47
|
+
const firstHeadingMatch = input.match(/(#+ )[A-Za-z]/);
|
|
74
48
|
if (!firstHeadingMatch) {
|
|
75
49
|
return input;
|
|
76
50
|
}
|
|
77
|
-
|
|
78
|
-
return input.replace(new RegExp(firstHeadingLevel, 'g'), Array.from({ length: startingLevel },
|
|
51
|
+
const firstHeadingLevel = firstHeadingMatch[1];
|
|
52
|
+
return input.replace(new RegExp(firstHeadingLevel, 'g'), Array.from({ length: startingLevel }, () => '#').join('') + ' ');
|
|
79
53
|
}
|
|
80
54
|
/**
|
|
81
55
|
* Custom MDX to JSX parsing
|
|
82
56
|
*/
|
|
83
|
-
export
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return (React.createElement(MarkdownToJSX, { options: { overrides:
|
|
57
|
+
export const MdxJSToJSX = (props) => {
|
|
58
|
+
const components = useMDXComponents();
|
|
59
|
+
const headingLevel = React.useContext(HeadingLevelContext);
|
|
60
|
+
return (React.createElement(MarkdownToJSX, { options: { overrides: { ...components, button: Button }, forceBlock: true } }, rewriteHeadingLevels(convertLinkToSymbolLinks(props.children), headingLevel)));
|
|
87
61
|
};
|
|
@@ -1,35 +1,12 @@
|
|
|
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
1
|
import * as React from 'react';
|
|
24
2
|
import { getTransformFromPlacement, Popper } from '@workday/canvas-kit-react/popup';
|
|
25
3
|
import { mergeCallback } from '@workday/canvas-kit-react/common';
|
|
26
4
|
import { TooltipContainer, useTooltip } from '@workday/canvas-kit-react/tooltip';
|
|
27
|
-
|
|
5
|
+
const isOverflowed = (element) => {
|
|
28
6
|
return (element.textContent || '').includes('more');
|
|
29
7
|
};
|
|
30
|
-
function mergeCallbacks(elemProps, componentProps, keys) {
|
|
31
|
-
|
|
32
|
-
return keys.reduce(function (mergedProps, key) {
|
|
8
|
+
function mergeCallbacks(elemProps, componentProps, keys = Object.keys(componentProps)) {
|
|
9
|
+
return keys.reduce((mergedProps, key) => {
|
|
33
10
|
if (typeof elemProps[key] === 'function') {
|
|
34
11
|
mergedProps[key] = mergeCallback(componentProps[key], elemProps[key]);
|
|
35
12
|
}
|
|
@@ -42,35 +19,38 @@ function mergeCallbacks(elemProps, componentProps, keys) {
|
|
|
42
19
|
function getTooltipContents(title) {
|
|
43
20
|
if (title instanceof Array) {
|
|
44
21
|
if (title.length && title[0].value) {
|
|
45
|
-
return title.map(
|
|
22
|
+
return title.map(v => v.value).join(', ');
|
|
46
23
|
}
|
|
47
24
|
}
|
|
48
25
|
return '';
|
|
49
26
|
}
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var target = event.currentTarget;
|
|
27
|
+
export const MoreTooltip = ({ placement = 'top', children, title, ...elemProps }) => {
|
|
28
|
+
const [titleText, setTitleText] = React.useState('');
|
|
29
|
+
const { targetProps, popperProps, tooltipProps } = useTooltip({ type: 'describe' });
|
|
30
|
+
const onMouseEnter = (event) => {
|
|
31
|
+
const target = event.currentTarget;
|
|
56
32
|
setTitleText(getTooltipContents(title));
|
|
57
33
|
if (isOverflowed(target)) {
|
|
58
34
|
targetProps.onMouseEnter(event);
|
|
59
35
|
}
|
|
60
36
|
};
|
|
61
|
-
|
|
62
|
-
|
|
37
|
+
const onFocus = (event) => {
|
|
38
|
+
const target = event.currentTarget;
|
|
63
39
|
setTitleText(getTooltipContents(title));
|
|
64
40
|
if (isOverflowed(target)) {
|
|
65
41
|
targetProps.onFocus(event);
|
|
66
42
|
}
|
|
67
43
|
};
|
|
68
44
|
return (React.createElement(React.Fragment, null,
|
|
69
|
-
React.cloneElement(children,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
45
|
+
React.cloneElement(children, {
|
|
46
|
+
...targetProps,
|
|
47
|
+
onMouseEnter,
|
|
48
|
+
onFocus,
|
|
49
|
+
'aria-label': undefined,
|
|
50
|
+
...mergeCallbacks({ ...targetProps, onMouseEnter, onFocus }, children.props),
|
|
51
|
+
}),
|
|
52
|
+
React.createElement(Popper, Object.assign({ placement: placement }, popperProps), ({ placement }) => {
|
|
53
|
+
const transformOrigin = getTransformFromPlacement(placement);
|
|
54
|
+
return (React.createElement(TooltipContainer, Object.assign({ transformOrigin: transformOrigin }, tooltipProps, elemProps), titleText));
|
|
75
55
|
})));
|
|
76
56
|
};
|
|
@@ -1,14 +1,3 @@
|
|
|
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
1
|
/* eslint-disable no-param-reassign */
|
|
13
2
|
import React from 'react';
|
|
14
3
|
import { toId } from '@storybook/csf';
|
|
@@ -16,53 +5,60 @@ import { Table, TableRow } from '@workday/canvas-kit-react/table';
|
|
|
16
5
|
import { Hyperlink } from '@workday/canvas-kit-react/button';
|
|
17
6
|
import { specifications } from './specs';
|
|
18
7
|
import { GithubBranch, GithubUrl, StorybookUrl } from './docs';
|
|
19
|
-
function createTableRows(rows, item, index, children, context) {
|
|
20
|
-
if (context === void 0) { context = { given: [], when: [], then: [], prefix: '' }; }
|
|
8
|
+
function createTableRows(rows, item, index, children, context = { given: [], when: [], then: [], prefix: '' }) {
|
|
21
9
|
if (item.type === 'describe') {
|
|
22
10
|
if (/^given/i.test(item.name)) {
|
|
23
|
-
context =
|
|
11
|
+
context = {
|
|
12
|
+
...context,
|
|
13
|
+
given: context.given.concat(context.prefix ? `${context.prefix} ${item.name}` : item.name),
|
|
14
|
+
};
|
|
24
15
|
context.prefix = '';
|
|
25
16
|
}
|
|
26
17
|
else if (/^[wt]hen/i.test(item.name)) {
|
|
27
|
-
context =
|
|
18
|
+
context = {
|
|
19
|
+
...context,
|
|
20
|
+
when: context.when.concat(context.prefix ? `${context.prefix} ${item.name}` : item.name),
|
|
21
|
+
};
|
|
28
22
|
context.prefix = '';
|
|
29
23
|
}
|
|
30
24
|
else {
|
|
31
|
-
context =
|
|
25
|
+
context = { ...context, prefix: context.prefix ? `${context.prefix} ${item.name}` : item.name };
|
|
32
26
|
}
|
|
33
|
-
item.children.reduce(
|
|
27
|
+
item.children.reduce((rows, item, index, children) => createTableRows(rows, item, index, children, context), rows);
|
|
34
28
|
}
|
|
35
29
|
else {
|
|
36
|
-
context =
|
|
30
|
+
context = {
|
|
31
|
+
...context,
|
|
32
|
+
then: context.then.concat(context.prefix ? `${context.prefix} ${item.name}` : item.name),
|
|
33
|
+
};
|
|
37
34
|
rows.push(context);
|
|
38
35
|
}
|
|
39
36
|
return rows;
|
|
40
37
|
}
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var specFile = specifications.find(function (f) { return f.name === file; });
|
|
38
|
+
export const Specifications = ({ file, name }) => {
|
|
39
|
+
const storybookBaseUrl = React.useContext(StorybookUrl);
|
|
40
|
+
const githubUrl = React.useContext(GithubUrl);
|
|
41
|
+
const githubBranch = React.useContext(GithubBranch);
|
|
42
|
+
const specFile = specifications.find(f => f.name === file);
|
|
47
43
|
if (!specFile) {
|
|
48
44
|
return null;
|
|
49
45
|
}
|
|
50
|
-
|
|
46
|
+
const block = name ? specFile.children.find(d => d.name === name) : specFile.children[0];
|
|
51
47
|
if (!block) {
|
|
52
48
|
return null;
|
|
53
49
|
}
|
|
54
|
-
|
|
50
|
+
const renderGiven = (input) => {
|
|
55
51
|
if (!input) {
|
|
56
|
-
return
|
|
52
|
+
return `Could not find a "given". Check the spec file.`;
|
|
57
53
|
}
|
|
58
|
-
|
|
54
|
+
const matches = input.match(/(.*)(\[[A-Za-z/\s]+), ([A-Za-z\s]+)\](.*)/);
|
|
59
55
|
if (matches == null) {
|
|
60
56
|
return input;
|
|
61
57
|
}
|
|
62
|
-
|
|
58
|
+
const [, first, kind, name, last] = matches;
|
|
63
59
|
return React.createElement(React.Fragment, null,
|
|
64
60
|
first.replace(/given /i, ''),
|
|
65
|
-
React.createElement(Hyperlink, { href: storybookBaseUrl
|
|
61
|
+
React.createElement(Hyperlink, { href: `${storybookBaseUrl}?path=/story/${toId(kind, name.replace('DefaultStory', 'Default Story'))}` }, name.replace('DefaultStory', 'Default')),
|
|
66
62
|
last);
|
|
67
63
|
};
|
|
68
64
|
return block.type === 'describe' ? (React.createElement(React.Fragment, null,
|
|
@@ -72,13 +68,13 @@ export var Specifications = function (_a) {
|
|
|
72
68
|
React.createElement("th", null, "Given"),
|
|
73
69
|
React.createElement("th", null, "When"),
|
|
74
70
|
React.createElement("th", null, "Then"))),
|
|
75
|
-
React.createElement("tbody", null, block.children.reduce(createTableRows, []).map(
|
|
71
|
+
React.createElement("tbody", null, block.children.reduce(createTableRows, []).map((row, index) => (React.createElement(TableRow, { key: index },
|
|
76
72
|
React.createElement("td", null, renderGiven(row.given[0])),
|
|
77
73
|
React.createElement("td", null,
|
|
78
|
-
React.createElement("ul", null, row.when.map(
|
|
74
|
+
React.createElement("ul", null, row.when.map((item, index) => (React.createElement("li", { key: index }, (index !== 0 ? 'AND THEN ' : '') + item.replace(/[tw]hen /i, '')))))),
|
|
79
75
|
React.createElement("td", null,
|
|
80
|
-
React.createElement("ul", null, row.then.map(
|
|
76
|
+
React.createElement("ul", null, row.then.map((item, index) => (React.createElement("li", { key: index }, (item.indexOf('should') === 0 ? 'it ' : '') + item)))))))))),
|
|
81
77
|
"Source:",
|
|
82
78
|
' ',
|
|
83
|
-
React.createElement(Hyperlink, { href: githubUrl
|
|
79
|
+
React.createElement(Hyperlink, { href: `${githubUrl}blob/${githubBranch}/cypress/integration/${file}` }, file))) : null;
|
|
84
80
|
};
|
|
@@ -2,25 +2,24 @@ import React from 'react';
|
|
|
2
2
|
import { Box } from '@workday/canvas-kit-react/layout';
|
|
3
3
|
import { ExternalHyperlink } from '@workday/canvas-kit-react';
|
|
4
4
|
import { Table } from './Table';
|
|
5
|
-
|
|
5
|
+
const camelToKebabCase = (name) => {
|
|
6
6
|
return name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
7
7
|
};
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
var sortedStyleProps = styleProps.sort(function (a, b) { return a.name.localeCompare(b.name); });
|
|
8
|
+
export const StylePropsTable = ({ styleProps = [] }) => {
|
|
9
|
+
const sortedStyleProps = styleProps.sort((a, b) => a.name.localeCompare(b.name));
|
|
11
10
|
return (React.createElement(Table, null,
|
|
12
11
|
React.createElement(Table.Head, null,
|
|
13
12
|
React.createElement(Table.Row, null,
|
|
14
13
|
React.createElement(Table.Header, null, "Prop"),
|
|
15
14
|
React.createElement(Table.Header, null, "CSS Properties"),
|
|
16
15
|
React.createElement(Table.Header, null, "System"))),
|
|
17
|
-
React.createElement(Table.Body, null, sortedStyleProps.map(
|
|
16
|
+
React.createElement(Table.Body, null, sortedStyleProps.map((styleProp, index) => (React.createElement(Table.Row, { key: index },
|
|
18
17
|
React.createElement(Table.Data, { fontFamily: "monospace" }, styleProp.name),
|
|
19
|
-
React.createElement(Table.Data, null, styleProp.properties.map(
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
React.createElement(Table.Data, null, styleProp.properties.map((property, i) => {
|
|
19
|
+
const formattedName = camelToKebabCase(property);
|
|
20
|
+
const mdnUrl = `https://developer.mozilla.org/en-US/docs/Web/CSS/${formattedName}`;
|
|
22
21
|
return (React.createElement(Box, { display: "inline-block", marginInlineEnd: "xxxs" },
|
|
23
22
|
React.createElement(ExternalHyperlink, { href: mdnUrl, key: i }, formattedName)));
|
|
24
23
|
})),
|
|
25
|
-
React.createElement(Table.Data, { fontFamily: "monospace" }, styleProp.system === 'none' ? '---' : styleProp.system)))
|
|
24
|
+
React.createElement(Table.Data, { fontFamily: "monospace" }, styleProp.system === 'none' ? '---' : styleProp.system)))))));
|
|
26
25
|
};
|
package/dist/es6/lib/Table.js
CHANGED
|
@@ -1,54 +1,43 @@
|
|
|
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
1
|
import React from 'react';
|
|
13
2
|
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
14
3
|
import { Box } from '@workday/canvas-kit-react/layout';
|
|
15
4
|
import { Text } from '@workday/canvas-kit-react/text';
|
|
16
5
|
import styled from '@emotion/styled';
|
|
17
6
|
import { type } from '@workday/canvas-kit-react/tokens';
|
|
18
|
-
|
|
19
|
-
Component:
|
|
20
|
-
return React.createElement(Box,
|
|
7
|
+
const TableHead = createComponent('thead')({
|
|
8
|
+
Component: (props, ref, Element) => {
|
|
9
|
+
return React.createElement(Box, Object.assign({ as: Element, ref: ref }, props));
|
|
21
10
|
},
|
|
22
11
|
});
|
|
23
|
-
|
|
24
|
-
Component:
|
|
25
|
-
return React.createElement(Box,
|
|
12
|
+
const TableBody = createComponent('tbody')({
|
|
13
|
+
Component: (props, ref, Element) => {
|
|
14
|
+
return React.createElement(Box, Object.assign({ as: Element, ref: ref }, props));
|
|
26
15
|
},
|
|
27
16
|
});
|
|
28
|
-
|
|
29
|
-
Component:
|
|
30
|
-
return (React.createElement(Box,
|
|
17
|
+
const TableRow = createComponent('tr')({
|
|
18
|
+
Component: (props, ref, Element) => {
|
|
19
|
+
return (React.createElement(Box, Object.assign({ as: Element, ref: ref, borderBottom: "solid 1px", borderBottomColor: "soap400" }, props)));
|
|
31
20
|
},
|
|
32
21
|
});
|
|
33
|
-
|
|
34
|
-
Component:
|
|
35
|
-
return (React.createElement(Text,
|
|
22
|
+
const TableHeader = createComponent('th')({
|
|
23
|
+
Component: (props, ref, Element) => {
|
|
24
|
+
return (React.createElement(Text, Object.assign({ as: Element, ref: ref, fontWeight: "medium", paddingX: "xxs", paddingY: "s", textAlign: "start", typeLevel: "subtext.large" }, props)));
|
|
36
25
|
},
|
|
37
26
|
});
|
|
38
|
-
|
|
27
|
+
const StyledText = styled(Text)({
|
|
39
28
|
code: {
|
|
40
29
|
fontFamily: type.properties.fontFamilies.monospace,
|
|
41
30
|
},
|
|
42
31
|
});
|
|
43
|
-
|
|
44
|
-
Component:
|
|
45
|
-
return (React.createElement(StyledText,
|
|
32
|
+
const TableData = createComponent('td')({
|
|
33
|
+
Component: (props, ref, Element) => {
|
|
34
|
+
return (React.createElement(StyledText, Object.assign({ as: Element, ref: ref, paddingX: "xxs", paddingY: "s", textAlign: "start", typeLevel: "subtext.large" }, props)));
|
|
46
35
|
},
|
|
47
36
|
});
|
|
48
|
-
export
|
|
37
|
+
export const Table = createComponent('table')({
|
|
49
38
|
displayName: 'Table',
|
|
50
|
-
Component:
|
|
51
|
-
return (React.createElement(Box,
|
|
39
|
+
Component: (props, ref, Element) => {
|
|
40
|
+
return (React.createElement(Box, Object.assign({ as: Element, ref: ref, borderCollapse: "collapse", width: "100%" }, props, { marginBottom: "s" })));
|
|
52
41
|
},
|
|
53
42
|
subComponents: {
|
|
54
43
|
Head: TableHead,
|
package/dist/es6/lib/Value.js
CHANGED
|
@@ -5,13 +5,13 @@ import { MdxJSToJSX } from './MDXElements';
|
|
|
5
5
|
import { Table } from './Table';
|
|
6
6
|
import { capitalize, IndentLevelContext, RenderContext, indent } from './widgetUtils';
|
|
7
7
|
import { DescriptionTooltip } from './DescriptionTooltip';
|
|
8
|
-
|
|
8
|
+
const widgets = {};
|
|
9
9
|
export function registerWidget(key, widget) {
|
|
10
|
-
widget.displayName = capitalize(key)
|
|
10
|
+
widget.displayName = `${capitalize(key)}Widget`;
|
|
11
11
|
widgets[key] = widget;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export const Value = (props) => {
|
|
14
|
+
const level = React.useContext(IndentLevelContext);
|
|
15
15
|
if (widgets[props.value.kind]) {
|
|
16
16
|
return React.createElement(widgets[props.value.kind], props);
|
|
17
17
|
}
|
|
@@ -19,15 +19,14 @@ export var Value = function (props) {
|
|
|
19
19
|
"unknown ",
|
|
20
20
|
JSON.stringify(props.value, null, ' ').replace(/\n/g, '\n' + indent(level))));
|
|
21
21
|
};
|
|
22
|
-
export
|
|
23
|
-
var properties = _a.properties;
|
|
22
|
+
export const PropertiesInline = ({ properties }) => {
|
|
24
23
|
if (properties.length === 0) {
|
|
25
24
|
return React.createElement("span", { className: "token punctuation" }, "{}");
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
const level = React.useContext(IndentLevelContext);
|
|
28
27
|
return (React.createElement(React.Fragment, null,
|
|
29
28
|
React.createElement("span", { className: "token punctuation" }, "{"),
|
|
30
|
-
properties.map(
|
|
29
|
+
properties.map((p, index) => {
|
|
31
30
|
return (React.createElement(React.Fragment, { key: index },
|
|
32
31
|
React.createElement("br", null),
|
|
33
32
|
indent(level + 1),
|
|
@@ -47,16 +46,14 @@ export var PropertiesInline = function (_a) {
|
|
|
47
46
|
indent(level),
|
|
48
47
|
React.createElement("span", { className: "token punctuation" }, "}")));
|
|
49
48
|
};
|
|
50
|
-
function getTableRows(properties, showDefault, showRequired, level, index) {
|
|
51
|
-
|
|
52
|
-
if (showRequired === void 0) { showRequired = false; }
|
|
53
|
-
return properties.flatMap(function (property, i) {
|
|
49
|
+
function getTableRows(properties, showDefault = true, showRequired = false, level, index) {
|
|
50
|
+
return properties.flatMap((property, i) => {
|
|
54
51
|
var _a, _b;
|
|
55
52
|
if (!property) {
|
|
56
53
|
return [];
|
|
57
54
|
}
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
const title = (_b = (_a = property.declarations) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.filePath;
|
|
56
|
+
const propName = (React.createElement(Text, { as: "code", whiteSpace: 'nowrap !important' },
|
|
60
57
|
indent(level),
|
|
61
58
|
level > 0 && '\u2514\u00A0',
|
|
62
59
|
property.name,
|
|
@@ -75,12 +72,11 @@ function getTableRows(properties, showDefault, showRequired, level, index) {
|
|
|
75
72
|
];
|
|
76
73
|
});
|
|
77
74
|
}
|
|
78
|
-
export
|
|
79
|
-
var properties = _a.properties, _b = _a.showDefault, showDefault = _b === void 0 ? true : _b, _c = _a.showRequired, showRequired = _c === void 0 ? false : _c;
|
|
75
|
+
export const PropertiesTable = ({ properties, showDefault = true, showRequired = false, }) => {
|
|
80
76
|
if (properties.length === 0) {
|
|
81
77
|
return React.createElement("span", { className: "token punctuation" }, "{}");
|
|
82
78
|
}
|
|
83
|
-
|
|
79
|
+
const tableBody = getTableRows(properties, showDefault, showRequired, 0, 0);
|
|
84
80
|
return (React.createElement(IndentLevelContext.Provider, { value: 0 },
|
|
85
81
|
React.createElement(Table, null,
|
|
86
82
|
React.createElement(Table.Head, null,
|