Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check_pr_title_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Check PR Title (Conventional Commits)
on:
pull_request:
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
branches: [master]
branches: [master, next-major]

jobs:
check-pr-title:
Expand Down
81 changes: 51 additions & 30 deletions api-generator/api-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -857,40 +857,61 @@ const allowed = (name) => {
);
};

// Handle `typeof SomeArray[number]` — parse the source file and expand string literals to a union.
// Returns null if `t` isn't that shape, or the source array couldn't be resolved.
const expandIndexedAccessArray = (t, project) => {
if (
t?.type !== 'indexedAccess' ||
t.objectType?.type !== 'query' ||
t.indexType?.type !== 'intrinsic' ||
t.indexType?.name !== 'number'
) {
return null;
}

const refName = t.objectType.queryType?.name;
const variable = refName
? project
?.getReflectionsByKind(TypeDoc.ReflectionKind.Variable)
?.find((r) => r.name === refName)
: null;
const sourceFile = variable?.sources?.[0]?.fullFileName;
if (!sourceFile) return null;

try {
const src = fs.readFileSync(sourceFile, 'utf-8');
const arrayMatch = src.match(
new RegExp(
`(?:export\\s+)?const\\s+${refName}\\s*=\\s*\\[([\\s\\S]*?)\\]`,
'm'
)
);
if (arrayMatch) {
const items = [...arrayMatch[1].matchAll(/'([^']+)'/g)].map(
(m) => `'${m[1]}'`
);
if (items.length) return items.join(' | ');
}
} catch (_) {}

return null;
};

const getTypesValue = (typeobj, project) => {
const { type, children, indexSignature } = typeobj ?? {};

// 1) Handle `typeof SomeArray[number]` — parse the source file and expand string literals to a union.
if (
type?.type === 'indexedAccess' &&
type.objectType?.type === 'query' &&
type.indexType?.type === 'intrinsic' &&
type.indexType?.name === 'number'
// 1) Handle `typeof SomeArray[number]`, whether it's the whole type or a member of a
// top-level union (e.g. `typeof SomeArray[number] | ''`) — expand just that member.
if (type?.type === 'indexedAccess') {
const expanded = expandIndexedAccessArray(type, project);
if (expanded) return expanded;
} else if (
type?.type === 'union' &&
type.types?.some((member) => member.type === 'indexedAccess')
) {
const refName = type.objectType.queryType?.name;
const variable = refName
? project
?.getReflectionsByKind(TypeDoc.ReflectionKind.Variable)
?.find((r) => r.name === refName)
: null;
const sourceFile = variable?.sources?.[0]?.fullFileName;
if (sourceFile) {
try {
const src = fs.readFileSync(sourceFile, 'utf-8');
const arrayMatch = src.match(
new RegExp(
`(?:export\\s+)?const\\s+${refName}\\s*=\\s*\\[([\\s\\S]*?)\\]`,
'm'
)
);
if (arrayMatch) {
const items = [...arrayMatch[1].matchAll(/'([^']+)'/g)].map(
(m) => `'${m[1]}'`
);
if (items.length) return items.join(' | ');
}
} catch (_) {}
}
return type.types
.map((member) => expandIndexedAccessArray(member, project) ?? `${member}`)
.join(' | ');
}

// 2) Handle index signatures (e.g., { [key: string]: number })
Expand Down
4 changes: 2 additions & 2 deletions projects/composition/src/app/api-data/cps-autocomplete.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@
"name": "prefixIcon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Icon before input value."
},
{
"name": "prefixIconSize",
"optional": false,
"readonly": false,
"type": "iconSizeType",
"type": "CpsIconSizeType",
"default": "1.125rem",
"description": "Size of icon before input value."
},
Expand Down
2 changes: 1 addition & 1 deletion projects/composition/src/app/api-data/cps-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"name": "icon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Name of the icon on the button."
},
Expand Down
2 changes: 1 addition & 1 deletion projects/composition/src/app/api-data/cps-checkbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"name": "icon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Name of the icon."
},
Expand Down
2 changes: 1 addition & 1 deletion projects/composition/src/app/api-data/cps-chip.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"name": "icon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Name of the icon."
},
Expand Down
2 changes: 1 addition & 1 deletion projects/composition/src/app/api-data/cps-dialog.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"name": "headerIcon",
"optional": true,
"readonly": false,
"type": "string",
"type": "CpsIconType",
"description": "Header icon."
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"name": "prefixIcon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Name of the icon in front of the title."
}
Expand Down
14 changes: 7 additions & 7 deletions projects/composition/src/app/api-data/cps-icon.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"name": "icon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Name of the icon."
},
{
"name": "size",
"optional": false,
"readonly": false,
"type": "iconSizeType",
"type": "CpsIconSizeType",
"default": "small",
"description": "Size of the icon, it can be of type number denoting pixels, string or 'fill', 'xsmall', 'small', 'normal' or 'large'."
},
Expand Down Expand Up @@ -45,14 +45,14 @@
"description": "Defines the custom types used by the component or service.",
"values": [
{
"name": "IconType",
"value": "'access' | 'access-denied' | 'access-lock' | 'access-unlock' | 'add' | 'add-domain' | 'angle-left' | 'angle-right' | 'attribute' | 'avatar' | 'avatar-top-menu' | 'bell' | 'book' | 'bookmark' | 'browse' | 'burger' | 'burger-arrow' | 'caret-down' | 'change' | 'checked' | 'chevron-down' | 'chevron-down-2' | 'circle' | 'cleansing' | 'close-x' | 'close-x-2' | 'columns' | 'construction' | 'controls' | 'copy' | 'csv' | 'cube' | 'database' | 'datafeed' | 'datepicker' | 'delete' | 'dislike' | 'domain' | 'dots' | 'download' | 'dq' | 'dropdown-menu' | 'edit' | 'expand' | 'export' | 'eye' | 'filter' | 'filter_2' | 'filter-funnel' | 'filter-funnel-filled' | 'follow' | 'graph' | 'grid' | 'grid-view' | 'health' | 'heart' | 'help-circle' | 'home' | 'info-circle' | 'insight' | 'issues' | 'jpeg' | 'json' | 'kafka' | 'kris' | 'last-seen-product' | 'left' | 'like' | 'line-vertical' | 'lock' | 'logout' | 'maximize' | 'measurement' | 'menu-expand' | 'menu-shrink' | 'minimize' | 'minus' | 'moon' | 'move-grabber' | 'open' | 'ownership' | 'path' | 'pdf' | 'pending' | 'plus' | 'projects' | 'question' | 'questions' | 'rectangle-rounded' | 'refresh' | 'remove' | 'right' | 'save' | 'schema' | 'schema_filter' | 'search' | 'settings' | 'smart' | 'sort-icon-asc' | 'sort-icon-desc' | 'star' | 'stepper-completed' | 'success' | 'suggestion' | 'sun' | 'survivorship' | 'table-row-error' | 'table-row-success' | 'table-row-warning' | 'toast-error' | 'toast-info' | 'toast-success' | 'toast-warning' | 'tools' | 'user' | 'users' | 'vector' | 'vector-down' | 'vector-right' | 'vector-up' | 'wallet' | 'warning' | 'widget-button-icon' | 'xls'",
"description": "IconType is used to define the type of the icon."
"name": "CpsIconType",
"value": "'access' | 'access-denied' | 'access-lock' | 'access-unlock' | 'add' | 'add-domain' | 'angle-left' | 'angle-right' | 'attribute' | 'avatar' | 'avatar-top-menu' | 'bell' | 'book' | 'bookmark' | 'browse' | 'burger' | 'burger-arrow' | 'caret-down' | 'change' | 'checked' | 'chevron-down' | 'chevron-down-2' | 'circle' | 'cleansing' | 'close-x' | 'close-x-2' | 'columns' | 'construction' | 'controls' | 'copy' | 'csv' | 'cube' | 'database' | 'datafeed' | 'datepicker' | 'delete' | 'dislike' | 'domain' | 'dots' | 'download' | 'dq' | 'dropdown-menu' | 'edit' | 'expand' | 'export' | 'eye' | 'filter' | 'filter_2' | 'filter-funnel' | 'filter-funnel-filled' | 'follow' | 'graph' | 'grid' | 'grid-view' | 'health' | 'heart' | 'help-circle' | 'home' | 'info-circle' | 'insight' | 'issues' | 'jpeg' | 'json' | 'kafka' | 'kris' | 'last-seen-product' | 'left' | 'like' | 'line-vertical' | 'lock' | 'logout' | 'maximize' | 'measurement' | 'menu-expand' | 'menu-shrink' | 'minimize' | 'minus' | 'moon' | 'move-grabber' | 'open' | 'ownership' | 'path' | 'pdf' | 'pending' | 'plus' | 'projects' | 'question' | 'questions' | 'rectangle-rounded' | 'refresh' | 'remove' | 'right' | 'save' | 'schema' | 'schema_filter' | 'search' | 'settings' | 'smart' | 'sort-icon-asc' | 'sort-icon-desc' | 'star' | 'stepper-completed' | 'success' | 'suggestion' | 'sun' | 'survivorship' | 'table-row-error' | 'table-row-success' | 'table-row-warning' | 'toast-error' | 'toast-info' | 'toast-success' | 'toast-warning' | 'tools' | 'user' | 'users' | 'vector' | 'vector-down' | 'vector-right' | 'vector-up' | 'wallet' | 'warning' | 'widget-button-icon' | 'xls' | \"\"",
"description": "CpsIconType is used to define the type of the icon."
},
{
"name": "iconSizeType",
"name": "CpsIconSizeType",
"value": "number | string | \"fill\" | \"xsmall\" | \"small\" | \"normal\" | \"large\"",
"description": "iconSizeType is used to define the size of the icon."
"description": "CpsIconSizeType is used to define the size of the icon."
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"name": "size",
"optional": false,
"readonly": false,
"type": "iconSizeType",
"type": "CpsIconSizeType",
"default": "small",
"description": "Size of the icon, it can be of type number denoting pixels, string or 'fill', 'xsmall', 'small', 'normal' or 'large'."
},
Expand Down
4 changes: 2 additions & 2 deletions projects/composition/src/app/api-data/cps-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"name": "prefixIcon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Icon before input value."
},
Expand All @@ -153,7 +153,7 @@
"name": "prefixIconSize",
"optional": false,
"readonly": false,
"type": "iconSizeType",
"type": "CpsIconSizeType",
"default": "1.125rem",
"description": "Size of icon before input value."
},
Expand Down
4 changes: 2 additions & 2 deletions projects/composition/src/app/api-data/cps-select.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@
"name": "prefixIcon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Icon before input value."
},
{
"name": "prefixIconSize",
"optional": false,
"readonly": false,
"type": "iconSizeType",
"type": "CpsIconSizeType",
"default": "1.125rem",
"description": "Size of icon before input value."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"values": [
{
"name": "CpsSidebarMenuItem",
"value": "{\n \"title\": \"string\",\n \"icon\": \"string\",\n \"url?\": \"string\",\n \"target?\": \"string\",\n \"disabled?\": \"boolean\",\n \"items?\": \"CpsMenuItem[]\"\n}",
"value": "{\n \"title\": \"string\",\n \"icon\": \"CpsIconType\",\n \"url?\": \"string\",\n \"target?\": \"string\",\n \"disabled?\": \"boolean\",\n \"items?\": \"CpsMenuItem[]\"\n}",
"description": "CpsSidebarMenuItem is used to define the items of the CpsSidebarMenuComponent."
}
]
Expand Down
6 changes: 3 additions & 3 deletions projects/composition/src/app/api-data/cps-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
"name": "toolbarIcon",
"optional": false,
"readonly": false,
"type": "string",
"type": "CpsIconType",
"default": "",
"description": "Toolbar icon name."
},
Expand Down Expand Up @@ -432,7 +432,7 @@
"name": "additionalBtnOnSelectIcon",
"optional": false,
"readonly": false,
"type": "string",
"type": "CpsIconType",
"default": "",
"description": "AdditionalBtnOnSelect icon."
},
Expand Down Expand Up @@ -464,7 +464,7 @@
"name": "actionBtnIcon",
"optional": false,
"readonly": false,
"type": "string",
"type": "CpsIconType",
"default": "",
"description": "Action button icon."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@
"name": "prefixIcon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Icon before input value."
},
{
"name": "prefixIconSize",
"optional": false,
"readonly": false,
"type": "iconSizeType",
"type": "CpsIconSizeType",
"default": "1.125rem",
"description": "Size of icon before input value, of type number, string, 'fill', 'xsmall', 'small', 'normal' or 'large'."
},
Expand Down
4 changes: 2 additions & 2 deletions projects/composition/src/app/api-data/cps-tree-select.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@
"name": "prefixIcon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Icon before input value."
},
{
"name": "prefixIconSize",
"optional": false,
"readonly": false,
"type": "iconSizeType",
"type": "CpsIconSizeType",
"default": "1.125rem",
"description": "Size of icon before input value, of type number, string, 'fill', 'xsmall', 'small', 'normal' or 'large'."
},
Expand Down
6 changes: 3 additions & 3 deletions projects/composition/src/app/api-data/cps-tree-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
"name": "toolbarIcon",
"optional": false,
"readonly": false,
"type": "string",
"type": "CpsIconType",
"default": "",
"description": "Toolbar icon name."
},
Expand Down Expand Up @@ -432,7 +432,7 @@
"name": "additionalBtnOnSelectIcon",
"optional": false,
"readonly": false,
"type": "string",
"type": "CpsIconType",
"default": "",
"description": "AdditionalBtnOnSelect icon."
},
Expand Down Expand Up @@ -464,7 +464,7 @@
"name": "actionBtnIcon",
"optional": false,
"readonly": false,
"type": "string",
"type": "CpsIconType",
"default": "",
"description": "Action button icon."
},
Expand Down
4 changes: 2 additions & 2 deletions projects/composition/src/app/api-data/internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,15 @@
"name": "prefixIcon",
"optional": false,
"readonly": false,
"type": "IconType",
"type": "CpsIconType",
"default": "",
"description": "Icon before input value."
},
{
"name": "prefixIconSize",
"optional": false,
"readonly": false,
"type": "iconSizeType",
"type": "CpsIconSizeType",
"default": "1.125rem",
"description": "Size of icon before input value, of type number, string, 'fill', 'xsmall', 'small', 'normal' or 'large'."
},
Expand Down
4 changes: 2 additions & 2 deletions projects/composition/src/app/api-data/types_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"CpsDatepickerAppearanceType": "datepicker",
"CpsDatepickerDateFormat": "datepicker",
"CpsDividerType": "divider",
"IconType": "icon",
"iconSizeType": "icon",
"CpsIconType": "icon",
"CpsIconSizeType": "icon",
"CpsInputAppearanceType": "input",
"CpsMenuItem": "menu",
"CpsMenuAttachPosition": "menu",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
CpsButtonComponent,
CpsDialogConfig,
CpsDialogRef,
CpsIconComponent
CpsIconComponent,
type CpsIconType
} from 'cps-ui-kit';

@Component({
Expand All @@ -12,9 +13,9 @@
templateUrl: './dialog-content.component.html',
styleUrls: ['./dialog-content.component.scss']
})
export class DialogContentComponent implements OnInit {
info = '';
icon = '';
icon: CpsIconType = '';

Check warning on line 18 in projects/composition/src/app/components/dialog-content/dialog-content.component.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

closeDisabled = false;

Expand Down
Loading
Loading