2023-03-31 23:42:09 +00:00
|
|
|
import APIDocs from '@/doc/common/apidoc/index.json';
|
2024-05-13 21:48:50 +00:00
|
|
|
import { $dt } from 'primevue/themes';
|
2023-03-31 23:42:09 +00:00
|
|
|
|
2024-05-13 21:48:50 +00:00
|
|
|
export const getPTOptions = (name) => {
|
2023-08-07 13:14:43 +00:00
|
|
|
const { props } = APIDocs[name.toLowerCase()].interfaces.values[`${name}PassThroughOptions`] || APIDocs[name.toLowerCase()].interfaces.values[`${name}DirectivePassThroughOptions`];
|
2023-08-10 09:07:31 +00:00
|
|
|
const options = APIDocs[name.toLowerCase()].interfaces.values[`${name}PassThroughMethodOptions`];
|
2023-03-31 23:42:09 +00:00
|
|
|
let data = [];
|
|
|
|
|
|
|
|
for (const [i, prop] of props.entries()) {
|
2023-08-10 09:07:31 +00:00
|
|
|
if (options) {
|
2023-12-05 07:06:55 +00:00
|
|
|
let subCompName, subOptions;
|
|
|
|
let hasSubComp = prop.name !== 'hooks' && prop.type.indexOf('TransitionType') === -1 && prop.type.indexOf('<') > -1 && name.toLowerCase() !== prop.type.slice(0, prop.type.indexOf('<')).toLowerCase();
|
|
|
|
|
|
|
|
if (hasSubComp) {
|
|
|
|
subCompName = prop.type.slice(0, prop.type.indexOf('<')).replace('PassThroughOptions', '').replace('PassThroughOptionType', '');
|
|
|
|
subOptions = APIDocs[subCompName.toLowerCase()].interfaces.values[`${subCompName}PassThroughMethodOptions`];
|
|
|
|
const objToReplace = subOptions.props.find((opt) => opt.name === 'parent');
|
|
|
|
|
|
|
|
objToReplace.type = prop.type;
|
|
|
|
}
|
|
|
|
|
2023-08-10 09:07:31 +00:00
|
|
|
data.push({
|
|
|
|
value: i + 1,
|
|
|
|
label: prop.name,
|
2023-12-05 07:06:55 +00:00
|
|
|
options: hasSubComp ? subOptions?.props : options?.props,
|
2023-08-10 09:07:31 +00:00
|
|
|
description: prop.description
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
data.push({
|
|
|
|
value: i + 1,
|
|
|
|
label: prop.name,
|
|
|
|
description: prop.description
|
|
|
|
});
|
|
|
|
}
|
2023-03-31 23:42:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
};
|
2024-05-13 21:48:50 +00:00
|
|
|
|
|
|
|
export const getStyleOptions = (name) => {
|
2024-05-16 14:52:16 +00:00
|
|
|
const { members = [] } = APIDocs[name.toLowerCase() + 'style']?.enumerations?.values?.[`${name}Classes`];
|
2024-05-13 21:48:50 +00:00
|
|
|
let data = [];
|
|
|
|
|
|
|
|
for (const member of members) {
|
2024-05-16 14:05:43 +00:00
|
|
|
const { value, description } = member;
|
2024-05-13 21:48:50 +00:00
|
|
|
|
|
|
|
data.push({
|
|
|
|
class: value.replaceAll('"', ''),
|
|
|
|
description
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
};
|
|
|
|
|
2024-05-23 11:07:36 +00:00
|
|
|
export const getTokenOptions = (name) => {
|
|
|
|
const values = APIDocs[`themes/${name.toLowerCase()}`]?.tokens?.values;
|
2024-05-13 21:48:50 +00:00
|
|
|
let data = [];
|
|
|
|
|
2024-05-16 14:52:16 +00:00
|
|
|
for (const [key, value] of Object.entries(values || {})) {
|
2024-05-13 21:48:50 +00:00
|
|
|
for (const tokens of value?.props) {
|
|
|
|
const { token, description } = tokens;
|
|
|
|
const designToken = $dt(token);
|
|
|
|
|
|
|
|
data.push({
|
|
|
|
token,
|
|
|
|
variable: designToken.name,
|
|
|
|
description: description
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
|
|
|
};
|