@actinc/dls
Version:
Design Language System (DLS) for ACT & Encoura front-end projects.
79 lines • 2.91 kB
JavaScript
/**
* Copyright (c) ACT, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
// const cleanPropType = (prop: PropType): void => {
// if (get(prop, 'type.name')) {
// // eslint-disable-next-line no-param-reassign
// prop.type.name = prop.type.name.replace(' | undefined', '');
// }
// };
var playgroundGroup = 'Common';
var eventsGroup = 'Events';
var ariaGroup = 'Aria';
var elseGroup = 'Everything Else';
/**
* Create a dictionary of StoryBook arg types. Be default the type and control
* will be automatically inferred and this helper does an ok job of setting up
* a default UI.
*
* This method also groups the parameters specified in the args param in the
* Playground group and then puts all methods that start with on* in the events
* group, all props starting with aria* in the aria group and everthing else in
* an Everthing Else group.
*
* @param args The arguments to put in the Playground group.
* @param type The base type of the arguments. If passed will group all
* arguments by some basic rules.
*/
export var Playground = function (args, type) {
var _a;
// eslint-disable-next-line no-loops/no-loops, no-restricted-syntax
for (var key in args) {
if (!key.startsWith('on')) {
// eslint-disable-next-line no-param-reassign
args[key].table = { category: playgroundGroup };
}
}
if (type) {
var docType = type;
// eslint-disable-next-line no-underscore-dangle
var props = (_a = docType.__docgenInfo) === null || _a === void 0 ? void 0 : _a.props;
// eslint-disable-next-line guard-for-in, no-loops/no-loops, no-restricted-syntax
for (var key in props) {
// cleanPropType(props[key]);
var category = elseGroup;
if (args[key] && !key.startsWith('on')) {
category = playgroundGroup;
}
else if (key.startsWith('aria')) {
category = ariaGroup;
}
else if (key.startsWith('on')) {
category = eventsGroup;
}
// eslint-disable-next-line no-param-reassign
args[key] = __assign(__assign({}, args[key]), {
// ...props[key],
table: {
category: category,
} });
}
}
return args;
};
export default Playground;
//# sourceMappingURL=playground.js.map