@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.
Files changed (57) hide show
  1. package/dist/es6/docgen/createTraversals.js +41 -22
  2. package/dist/es6/docgen/docParser.js +285 -257
  3. package/dist/es6/docgen/getExternalSymbol.js +2 -2
  4. package/dist/es6/docgen/plugins/componentParser.js +28 -33
  5. package/dist/es6/docgen/plugins/enhancedComponentParser.js +211 -150
  6. package/dist/es6/docgen/plugins/modelParser.js +139 -79
  7. package/dist/es6/docgen/traversals.js +396 -397
  8. package/dist/es6/docgen/traverse.js +8 -9
  9. package/dist/es6/lib/DescriptionTooltip.js +1 -1
  10. package/dist/es6/lib/MDXElements.js +13 -39
  11. package/dist/es6/lib/MoreTooltip.js +21 -41
  12. package/dist/es6/lib/Specifications.js +30 -34
  13. package/dist/es6/lib/StylePropsTable.js +8 -9
  14. package/dist/es6/lib/Table.js +19 -30
  15. package/dist/es6/lib/Value.js +13 -17
  16. package/dist/es6/lib/docs.js +701 -397
  17. package/dist/es6/lib/widgetUtils.js +44 -76
  18. package/dist/es6/lib/widgets/array.js +1 -2
  19. package/dist/es6/lib/widgets/callExpression.js +4 -5
  20. package/dist/es6/lib/widgets/canvasColor.js +2 -2
  21. package/dist/es6/lib/widgets/component.js +1 -2
  22. package/dist/es6/lib/widgets/conditional.js +1 -2
  23. package/dist/es6/lib/widgets/enhancedComponent.js +19 -24
  24. package/dist/es6/lib/widgets/external.js +1 -4
  25. package/dist/es6/lib/widgets/function.js +5 -7
  26. package/dist/es6/lib/widgets/intersection.js +3 -4
  27. package/dist/es6/lib/widgets/model.js +4 -6
  28. package/dist/es6/lib/widgets/object.js +2 -3
  29. package/dist/es6/lib/widgets/parenthesis.js +1 -2
  30. package/dist/es6/lib/widgets/primitives.js +17 -39
  31. package/dist/es6/lib/widgets/qualifiedName.js +1 -2
  32. package/dist/es6/lib/widgets/symbol.js +1 -2
  33. package/dist/es6/lib/widgets/tuple.js +2 -3
  34. package/dist/es6/lib/widgets/typeParameter.js +1 -2
  35. package/dist/es6/lib/widgets/union.js +3 -4
  36. package/dist/es6/mdx/installBlock.js +6 -7
  37. package/dist/es6/mdx/style-props/examples/Background.js +5 -16
  38. package/dist/es6/mdx/style-props/examples/Border.js +5 -16
  39. package/dist/es6/mdx/style-props/examples/Color.js +5 -16
  40. package/dist/es6/mdx/style-props/examples/Depth.js +5 -16
  41. package/dist/es6/mdx/style-props/examples/Flex.js +11 -22
  42. package/dist/es6/mdx/style-props/examples/FlexItem.js +10 -21
  43. package/dist/es6/mdx/style-props/examples/Grid.js +6 -17
  44. package/dist/es6/mdx/style-props/examples/GridItem.js +6 -17
  45. package/dist/es6/mdx/style-props/examples/Layout.js +5 -16
  46. package/dist/es6/mdx/style-props/examples/Other.js +5 -16
  47. package/dist/es6/mdx/style-props/examples/Position.js +5 -16
  48. package/dist/es6/mdx/style-props/examples/Space.js +6 -17
  49. package/dist/es6/mdx/style-props/examples/Text.js +2 -2
  50. package/dist/es6/mdx/welcomePage.js +3 -3
  51. package/dist/mdx/9.0-UPGRADE-GUIDE.mdx +30 -3
  52. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +1 -1
  53. package/dist/mdx/preview-react/text-input/examples/Alert.tsx +1 -1
  54. package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +5 -2
  55. package/dist/mdx/react/banner/examples/StickyAnimation.tsx +7 -5
  56. package/dist/mdx/react/common/examples/ResponsiveViewport.tsx +2 -3
  57. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  // prettier-ignore
2
- var externalSymbols = {
2
+ const externalSymbols = {
3
3
  lib: {
4
4
  Promise: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise',
5
5
  Function: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function',
@@ -25,6 +25,6 @@ var externalSymbols = {
25
25
  }
26
26
  };
27
27
  export function getExternalSymbol(key, declarationFile) {
28
- var lib = (declarationFile === null || declarationFile === void 0 ? void 0 : declarationFile.includes('react')) ? 'react' : 'lib';
28
+ const lib = (declarationFile === null || declarationFile === void 0 ? void 0 : declarationFile.includes('react')) ? 'react' : 'lib';
29
29
  return externalSymbols[lib][key] || undefined;
30
30
  }
@@ -1,7 +1,7 @@
1
1
  import ts from 'typescript';
2
2
  import { createParserPlugin, filterObjectProperties, getValueDeclaration, getDefaultFromTags, isObject, isExportedSymbol, getValidDefaultFromNode, } from '../docParser';
3
3
  import t from '../traverse';
4
- export var componentParser = createParserPlugin(function (node, parser) {
4
+ export const componentParser = createParserPlugin((node, parser) => {
5
5
  var _a, _b;
6
6
  /**
7
7
  * We'll look for class components that extend from `React.Component` or `Component`
@@ -17,7 +17,7 @@ export var componentParser = createParserPlugin(function (node, parser) {
17
17
  node.heritageClauses[0] &&
18
18
  t.isHeritageClause(node.heritageClauses[0]) &&
19
19
  node.heritageClauses[0].types[0]) {
20
- var clause = node.heritageClauses[0].types[0];
20
+ const clause = node.heritageClauses[0].types[0];
21
21
  if ((clause &&
22
22
  // `class A extends Component`
23
23
  t.isExpressionWithTypeArguments(clause) &&
@@ -33,23 +33,19 @@ export var componentParser = createParserPlugin(function (node, parser) {
33
33
  if (clause.typeArguments &&
34
34
  clause.typeArguments[0] &&
35
35
  t.isTypeReference(clause.typeArguments[0])) {
36
- var type = parser.checker.getTypeAtLocation(clause.typeArguments[0]);
37
- var defaultPropNode = (_a = node.members.find(function (m) {
38
- return t.isPropertyDeclaration(m) && t.isIdentifier(m.name) && m.name.text === 'defaultProps';
39
- })) === null || _a === void 0 ? void 0 : _a.initializer;
40
- var defaultProps = getDefaultsFromDefaultProps(parser, defaultPropNode);
41
- var props = getComponentProps(parser, type, defaultProps);
36
+ const type = parser.checker.getTypeAtLocation(clause.typeArguments[0]);
37
+ const defaultPropNode = (_a = node.members.find(m => t.isPropertyDeclaration(m) && t.isIdentifier(m.name) && m.name.text === 'defaultProps')) === null || _a === void 0 ? void 0 : _a.initializer;
38
+ const defaultProps = getDefaultsFromDefaultProps(parser, defaultPropNode);
39
+ const props = getComponentProps(parser, type, defaultProps);
42
40
  /**
43
41
  * Get a displayName if there is one
44
42
  */
45
- var displayName = (_b = node.members.find(function (m) {
46
- return t.isPropertyDeclaration(m) &&
47
- t.isIdentifier(m.name) &&
48
- m.name.text === 'displayName' &&
49
- m.initializer &&
50
- t.isStringLiteral(m.initializer);
51
- })) === null || _b === void 0 ? void 0 : _b.initializer.text;
52
- return { kind: 'component', props: props, displayName: displayName };
43
+ const displayName = (_b = node.members.find(m => t.isPropertyDeclaration(m) &&
44
+ t.isIdentifier(m.name) &&
45
+ m.name.text === 'displayName' &&
46
+ m.initializer &&
47
+ t.isStringLiteral(m.initializer))) === null || _b === void 0 ? void 0 : _b.initializer.text;
48
+ return { kind: 'component', props, displayName };
53
49
  }
54
50
  // We couldn't find any props
55
51
  return {
@@ -127,7 +123,7 @@ export function isComponent(returnType) {
127
123
  return returnType.types.some(isComponent);
128
124
  }
129
125
  if (isObject(returnType)) {
130
- return returnType.getProperties().some(function (s) { return s.name === 'props'; });
126
+ return returnType.getProperties().some(s => s.name === 'props');
131
127
  }
132
128
  return false;
133
129
  }
@@ -141,13 +137,12 @@ export function isComponent(returnType) {
141
137
  * @param type The type of the props. We use a type because there are many ways the prop interface
142
138
  * @param defaultProps Optional record of found default props could be created
143
139
  */
144
- export function getComponentProps(parser, type, defaultProps) {
145
- if (defaultProps === void 0) { defaultProps = {}; }
146
- var props = type
140
+ export function getComponentProps(parser, type, defaultProps = {}) {
141
+ const props = type
147
142
  .getProperties()
148
- .map(function (symbol) {
149
- var defaultValue = defaultProps[symbol.name] || getDefaultFromTags(symbol.getJsDocTags());
150
- var value = parser.getValueFromNode(getValueDeclaration(symbol));
143
+ .map(symbol => {
144
+ const defaultValue = defaultProps[symbol.name] || getDefaultFromTags(symbol.getJsDocTags());
145
+ const value = parser.getValueFromNode(getValueDeclaration(symbol));
151
146
  if (value.kind === 'property') {
152
147
  value.defaultValue = defaultValue;
153
148
  }
@@ -162,7 +157,7 @@ export function getComponentProps(parser, type, defaultProps) {
162
157
  */
163
158
  export function getDefaultsFromDefaultProps(parser, node) {
164
159
  if (node && t.isObjectLiteralExpression(node)) {
165
- return node.properties.reduce(function (result, property) {
160
+ return node.properties.reduce((result, property) => {
166
161
  if (t.isPropertyAssignment(property) && t.isIdentifier(property.name)) {
167
162
  result[property.name.text] = parser.getValueFromNode(property.initializer);
168
163
  }
@@ -179,9 +174,9 @@ export function getDefaultsFromDefaultProps(parser, node) {
179
174
  */
180
175
  export function getDefaultsFromObjectBindingPattern(parser, node) {
181
176
  if (t.isObjectBindingPattern(node)) {
182
- return node.elements.reduce(function (result, element) {
177
+ return node.elements.reduce((result, element) => {
183
178
  if (t.isBindingElement(element) && t.isIdentifier(element.name) && element.initializer) {
184
- var defaultValue = getValidDefaultFromNode(parser, element.initializer);
179
+ const defaultValue = getValidDefaultFromNode(parser, element.initializer);
185
180
  if (defaultValue) {
186
181
  result[element.name.text] = defaultValue;
187
182
  }
@@ -197,24 +192,24 @@ function getComponentFromFunction(parser, node) {
197
192
  */
198
193
  if (ts.isFunctionLike(node)) {
199
194
  // Get a signature and test the return type for JSX props
200
- var signature = parser.checker.getSignatureFromDeclaration(node);
195
+ const signature = parser.checker.getSignatureFromDeclaration(node);
201
196
  if (signature) {
202
- var returnType = signature.getReturnType();
197
+ const returnType = signature.getReturnType();
203
198
  if (isComponent(returnType)) {
204
199
  if (signature.parameters[0]) {
205
- var declaration = getValueDeclaration(signature.parameters[0]);
200
+ const declaration = getValueDeclaration(signature.parameters[0]);
206
201
  if (declaration && t.isParameter(declaration)) {
207
- var type = parser.checker.getTypeAtLocation(declaration);
202
+ const type = parser.checker.getTypeAtLocation(declaration);
208
203
  if (!isObject(type) && !type.isIntersection()) {
209
204
  // This is not a component. We may still get some false positives, but this decreases
210
205
  // the likelihood
211
206
  return undefined;
212
207
  }
213
- var defaults = getDefaultsFromObjectBindingPattern(parser, declaration.name);
214
- var props = getComponentProps(parser, type, defaults);
208
+ const defaults = getDefaultsFromObjectBindingPattern(parser, declaration.name);
209
+ const props = getComponentProps(parser, type, defaults);
215
210
  return {
216
211
  kind: 'component',
217
- props: props,
212
+ props,
218
213
  };
219
214
  }
220
215
  }