@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,20 +1,9 @@
|
|
|
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 { createParserPlugin, getValueDeclaration, defaultJSDoc, getSymbolFromNode, getFullJsDocComment, } from '../docParser';
|
|
13
2
|
import t from '../traverse';
|
|
14
3
|
function capitalize(string) {
|
|
15
4
|
return string[0].toUpperCase() + string.substring(1);
|
|
16
5
|
}
|
|
17
|
-
export
|
|
6
|
+
export const modelParser = createParserPlugin((node, parser) => {
|
|
18
7
|
var _a;
|
|
19
8
|
/**
|
|
20
9
|
* Replace submenus with symbols rather than types.
|
|
@@ -52,17 +41,17 @@ export var modelParser = createParserPlugin(function (node, parser) {
|
|
|
52
41
|
* ```
|
|
53
42
|
*/
|
|
54
43
|
if (t.isShorthandPropertyAssignment(node)) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
const { checker } = parser;
|
|
45
|
+
const symbol = getSymbolFromNode(checker, node);
|
|
46
|
+
const declaration = getValueDeclaration(symbol);
|
|
47
|
+
const name = (symbol === null || symbol === void 0 ? void 0 : symbol.name) || t.isIdentifier(node.name) ? node.name.text : '';
|
|
59
48
|
if (declaration && declaration.getSourceFile()) {
|
|
60
49
|
// ShorthandPropertyAssignment doesn't give the original variable declaration
|
|
61
|
-
|
|
50
|
+
const originalDeclaration = t(declaration.getSourceFile())
|
|
62
51
|
.find('VariableDeclaration')
|
|
63
|
-
.map(
|
|
52
|
+
.map(node => {
|
|
64
53
|
if (t.isIdentifier(node.name) &&
|
|
65
|
-
node.name.text ===
|
|
54
|
+
node.name.text === name &&
|
|
66
55
|
node.initializer &&
|
|
67
56
|
t.isCallExpression(node.initializer) &&
|
|
68
57
|
t.isIdentifier(node.initializer.expression) &&
|
|
@@ -74,10 +63,17 @@ export var modelParser = createParserPlugin(function (node, parser) {
|
|
|
74
63
|
}
|
|
75
64
|
return;
|
|
76
65
|
})
|
|
77
|
-
.filter(
|
|
66
|
+
.filter(v => !!v)[0];
|
|
78
67
|
if (originalDeclaration) {
|
|
79
|
-
|
|
80
|
-
return
|
|
68
|
+
const jsDoc = symbol ? getFullJsDocComment(checker, symbol) : defaultJSDoc;
|
|
69
|
+
return {
|
|
70
|
+
kind: 'property',
|
|
71
|
+
name,
|
|
72
|
+
defaultValue: undefined,
|
|
73
|
+
type: originalDeclaration,
|
|
74
|
+
required: false,
|
|
75
|
+
...jsDoc,
|
|
76
|
+
};
|
|
81
77
|
}
|
|
82
78
|
}
|
|
83
79
|
}
|
|
@@ -109,9 +105,9 @@ export var modelParser = createParserPlugin(function (node, parser) {
|
|
|
109
105
|
* ```
|
|
110
106
|
*/
|
|
111
107
|
if (t.isTypeReference(node)) {
|
|
112
|
-
|
|
108
|
+
const firstArgument = (_a = node.typeArguments) === null || _a === void 0 ? void 0 : _a[0];
|
|
113
109
|
if (firstArgument && t.isTypeQuery(firstArgument) && t.isIdentifier(firstArgument.exprName)) {
|
|
114
|
-
|
|
110
|
+
const modelName = firstArgument.exprName.text;
|
|
115
111
|
return { kind: 'symbol', name: modelName };
|
|
116
112
|
}
|
|
117
113
|
}
|
|
@@ -124,12 +120,19 @@ export var modelParser = createParserPlugin(function (node, parser) {
|
|
|
124
120
|
t.isIdentifier(node.initializer.type.exprName.right) &&
|
|
125
121
|
// TConfig is special from models
|
|
126
122
|
node.initializer.type.exprName.right.text === 'TConfig') {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return
|
|
123
|
+
const symbol = getSymbolFromNode(parser.checker, node);
|
|
124
|
+
const jsDoc = (symbol && getFullJsDocComment(parser.checker, symbol)) || defaultJSDoc;
|
|
125
|
+
return {
|
|
126
|
+
kind: 'property',
|
|
127
|
+
name: node.name.text,
|
|
128
|
+
defaultValue: parser.getValueFromNode(node.initializer.expression),
|
|
129
|
+
required: false,
|
|
130
|
+
type: {
|
|
130
131
|
kind: 'symbol',
|
|
131
132
|
name: node.initializer.type.exprName.left.text.replace('use', '') + 'Config',
|
|
132
|
-
}
|
|
133
|
+
},
|
|
134
|
+
...jsDoc,
|
|
135
|
+
};
|
|
133
136
|
}
|
|
134
137
|
/**
|
|
135
138
|
* This parsing matcher handles models created using `createModelHook` and adds additional symbols
|
|
@@ -173,109 +176,166 @@ export var modelParser = createParserPlugin(function (node, parser) {
|
|
|
173
176
|
t.isIdentifier(node.initializer.expression.expression) &&
|
|
174
177
|
node.initializer.expression.expression.text === 'createModelHook') {
|
|
175
178
|
// we have a model
|
|
176
|
-
|
|
179
|
+
const modelName = node.name.text.replace('use', '');
|
|
177
180
|
// get the symbol for the model hook
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
const symbol = getSymbolFromNode(parser.checker, node);
|
|
182
|
+
const jsDoc = symbol ? getFullJsDocComment(parser.checker, symbol) : defaultJSDoc;
|
|
183
|
+
const options = node.initializer.expression.arguments[0];
|
|
184
|
+
const optionsType = parser.checker.getTypeAtLocation(options);
|
|
185
|
+
const configProps = optionsType.getProperties().reduce((result, symbol) => {
|
|
183
186
|
if (['defaultConfig', 'requiredConfig'].includes(symbol.getName())) {
|
|
184
187
|
// The declaration of the config
|
|
185
|
-
|
|
188
|
+
const declaration = getValueDeclaration(symbol);
|
|
186
189
|
if (declaration) {
|
|
187
190
|
result[symbol.getName()] = parser.checker
|
|
188
191
|
.getTypeAtLocation(declaration)
|
|
189
192
|
.getProperties()
|
|
190
|
-
.map(
|
|
193
|
+
.map(p => {
|
|
191
194
|
// Each property of the config
|
|
192
|
-
|
|
193
|
-
return
|
|
195
|
+
const prop = getValueDeclaration(p);
|
|
196
|
+
return {
|
|
197
|
+
...parser.getValueFromNode(prop),
|
|
198
|
+
required: symbol.getName() === 'requiredConfig',
|
|
199
|
+
};
|
|
194
200
|
});
|
|
195
201
|
}
|
|
196
202
|
}
|
|
197
203
|
return result;
|
|
198
204
|
}, {});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
type.getCallSignatures().forEach(
|
|
205
|
+
const modelProps = {};
|
|
206
|
+
const returnProps = {};
|
|
207
|
+
const type = parser.checker.getTypeAtLocation(node.initializer.arguments[0]);
|
|
208
|
+
type.getCallSignatures().forEach(signature => {
|
|
203
209
|
signature
|
|
204
210
|
.getReturnType()
|
|
205
211
|
.getProperties()
|
|
206
|
-
.forEach(
|
|
207
|
-
|
|
212
|
+
.forEach(property => {
|
|
213
|
+
const declaration = getValueDeclaration(property);
|
|
208
214
|
if (declaration) {
|
|
209
215
|
if (['state', 'events'].includes(property.getName())) {
|
|
210
|
-
|
|
216
|
+
modelProps[property.getName()] = parser.checker
|
|
211
217
|
.getTypeAtLocation(declaration)
|
|
212
218
|
.getProperties()
|
|
213
|
-
.map(
|
|
214
|
-
return
|
|
219
|
+
.map(prop => {
|
|
220
|
+
return {
|
|
221
|
+
...parser.getValueFromNode(getValueDeclaration(prop)),
|
|
222
|
+
defaultValue: undefined, // no defaults for state/events
|
|
223
|
+
};
|
|
215
224
|
});
|
|
216
225
|
}
|
|
217
226
|
else {
|
|
218
|
-
|
|
227
|
+
returnProps[property.getName()] = parser.getValueFromNode(declaration);
|
|
219
228
|
}
|
|
220
229
|
}
|
|
221
230
|
});
|
|
222
231
|
});
|
|
223
|
-
|
|
224
|
-
|
|
232
|
+
const { state, events } = modelProps;
|
|
233
|
+
const fileName = node.getSourceFile().fileName;
|
|
225
234
|
// Add special symbols
|
|
226
235
|
// Model
|
|
227
|
-
parser.symbols.push(
|
|
236
|
+
parser.symbols.push({
|
|
237
|
+
name: modelName,
|
|
238
|
+
fileName,
|
|
239
|
+
...jsDoc,
|
|
240
|
+
type: {
|
|
228
241
|
kind: 'model',
|
|
229
|
-
state
|
|
230
|
-
events
|
|
231
|
-
modelProperties: Object.keys(
|
|
232
|
-
}
|
|
242
|
+
state,
|
|
243
|
+
events,
|
|
244
|
+
modelProperties: Object.keys(returnProps).map(p => returnProps[p]),
|
|
245
|
+
},
|
|
246
|
+
});
|
|
233
247
|
// Model config
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
var type = event.type;
|
|
248
|
+
const eventConfig = (events || []).reduce((result, event) => {
|
|
249
|
+
const type = event.type;
|
|
237
250
|
// callback of the event
|
|
238
|
-
result.push(
|
|
239
|
-
|
|
251
|
+
result.push({
|
|
252
|
+
...event,
|
|
253
|
+
defaultValue: undefined,
|
|
254
|
+
name: `on${capitalize(event.name)}`,
|
|
255
|
+
required: false,
|
|
256
|
+
type: {
|
|
257
|
+
...type,
|
|
258
|
+
parameters: [
|
|
259
|
+
{
|
|
260
|
+
...defaultJSDoc,
|
|
261
|
+
kind: 'parameter',
|
|
262
|
+
name: 'state',
|
|
263
|
+
required: true,
|
|
264
|
+
type: {
|
|
240
265
|
kind: 'symbol',
|
|
241
|
-
name:
|
|
242
|
-
fileName
|
|
243
|
-
}
|
|
244
|
-
|
|
266
|
+
name: `${modelName}State`,
|
|
267
|
+
fileName,
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
].concat(...type.parameters),
|
|
271
|
+
returnType: {
|
|
245
272
|
kind: 'primitive',
|
|
246
273
|
value: 'void',
|
|
247
|
-
}
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
});
|
|
248
277
|
// guard of the event
|
|
249
|
-
result.push(
|
|
250
|
-
|
|
278
|
+
result.push({
|
|
279
|
+
...event,
|
|
280
|
+
defaultValue: undefined,
|
|
281
|
+
name: `should${capitalize(event.name)}`,
|
|
282
|
+
required: false,
|
|
283
|
+
type: {
|
|
284
|
+
...type,
|
|
285
|
+
parameters: [
|
|
286
|
+
{
|
|
287
|
+
...defaultJSDoc,
|
|
288
|
+
kind: 'parameter',
|
|
289
|
+
name: 'state',
|
|
290
|
+
required: true,
|
|
291
|
+
type: {
|
|
251
292
|
kind: 'symbol',
|
|
252
|
-
name:
|
|
253
|
-
fileName
|
|
254
|
-
}
|
|
255
|
-
|
|
293
|
+
name: `${modelName}State`,
|
|
294
|
+
fileName,
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
].concat(...type.parameters),
|
|
298
|
+
returnType: {
|
|
256
299
|
kind: 'primitive',
|
|
257
300
|
value: 'boolean',
|
|
258
|
-
}
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
});
|
|
259
304
|
return result;
|
|
260
305
|
}, []);
|
|
261
|
-
parser.symbols.push(
|
|
306
|
+
parser.symbols.push({
|
|
307
|
+
name: `${modelName}Config`,
|
|
308
|
+
fileName,
|
|
309
|
+
...jsDoc,
|
|
310
|
+
type: {
|
|
262
311
|
kind: 'object',
|
|
263
312
|
properties: (configProps['defaultConfig'] || []).concat(configProps['requiredConfig'], eventConfig),
|
|
264
|
-
}
|
|
313
|
+
},
|
|
314
|
+
});
|
|
265
315
|
// Model State
|
|
266
|
-
parser.symbols.push(
|
|
316
|
+
parser.symbols.push({
|
|
317
|
+
name: `${modelName}State`,
|
|
318
|
+
fileName,
|
|
319
|
+
...defaultJSDoc,
|
|
320
|
+
type: {
|
|
267
321
|
kind: 'object',
|
|
268
322
|
properties: state,
|
|
269
|
-
}
|
|
323
|
+
},
|
|
324
|
+
});
|
|
270
325
|
// Model Events
|
|
271
|
-
parser.symbols.push(
|
|
326
|
+
parser.symbols.push({
|
|
327
|
+
name: `${modelName}Events`,
|
|
328
|
+
fileName,
|
|
329
|
+
...defaultJSDoc,
|
|
330
|
+
type: {
|
|
272
331
|
kind: 'object',
|
|
273
332
|
properties: events,
|
|
274
|
-
}
|
|
333
|
+
},
|
|
334
|
+
});
|
|
275
335
|
// Model Hook
|
|
276
336
|
return {
|
|
277
337
|
kind: 'modelHook',
|
|
278
|
-
name:
|
|
338
|
+
name: `use${modelName}`,
|
|
279
339
|
defaultConfig: configProps['defaultConfig'] || [],
|
|
280
340
|
requiredConfig: configProps['requiredConfig'] || [],
|
|
281
341
|
};
|