@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
|
@@ -4,37 +4,56 @@
|
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
///** Create the guard fn
|
|
7
|
-
|
|
7
|
+
const source = fs
|
|
8
8
|
.readFileSync(path.join(__dirname, '../../../node_modules/typescript/lib/typescript.d.ts'))
|
|
9
9
|
.toString();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
pairs === null || pairs === void 0 ? void 0 : pairs.forEach(
|
|
15
|
-
|
|
10
|
+
const lines = source.split('\n');
|
|
11
|
+
const syntaxKinds = source.match(/export enum SyntaxKind \{([^}]+)\}/m);
|
|
12
|
+
const pairs = syntaxKinds[1].match(/([a-z]+) = [\d]+/gi);
|
|
13
|
+
const guardPairs = [];
|
|
14
|
+
pairs === null || pairs === void 0 ? void 0 : pairs.forEach(pair => {
|
|
15
|
+
const matches = pair.match(/([a-z]+) = [0-9]+/i);
|
|
16
16
|
if (matches) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const syntaxKind = matches[1];
|
|
18
|
+
const lineIndex = lines.findIndex(l => l.includes(`kind: SyntaxKind.${syntaxKind};`));
|
|
19
19
|
if (lineIndex > 0) {
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
guardPairs.push([
|
|
20
|
+
const matches = lines[lineIndex - 1].match(/export interface ([a-z]+)\s/i);
|
|
21
|
+
if (matches) {
|
|
22
|
+
guardPairs.push([syntaxKind, matches[1]]);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
27
|
+
const guardFns = guardPairs.map(([kind, typeName]) => {
|
|
28
|
+
return `is${kind}(node: ts.Node): node is ts.${typeName} {
|
|
29
|
+
return node.kind === ts.SyntaxKind.${kind};
|
|
30
|
+
}`;
|
|
30
31
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return kind + ": {} as any as ts." + typeName;
|
|
32
|
+
const kindMap = guardPairs.map(([kind, typeName]) => {
|
|
33
|
+
return `${kind}: {} as any as ts.${typeName}`;
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return "[ts.SyntaxKind." + kind + "]: '" + kind + "'";
|
|
35
|
+
const kindToString = guardPairs.map(([kind]) => {
|
|
36
|
+
return `[ts.SyntaxKind.${kind}]: '${kind}'`;
|
|
38
37
|
});
|
|
39
|
-
|
|
38
|
+
const output = `
|
|
39
|
+
// This file is auto-generated from the createTraversals.ts file. Do not modify contents
|
|
40
|
+
import ts from 'typescript';
|
|
41
|
+
|
|
42
|
+
export const guards = {
|
|
43
|
+
${guardFns.join(',\n ')}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const kindsMap = {
|
|
47
|
+
${kindMap.join(',\n ')}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const kindToString = {
|
|
51
|
+
${kindToString.join(',\n ')}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function getKindNameFromNode(node: ts.Node): string {
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
return kindToString[node.kind] || String(node.kind);
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
40
59
|
fs.writeFileSync(path.join(__dirname, 'traversals.ts'), output);
|