diff --git a/npm/ng-packs/package.json b/npm/ng-packs/package.json index 694e07af4a8..4129477fb8e 100644 --- a/npm/ng-packs/package.json +++ b/npm/ng-packs/package.json @@ -124,10 +124,10 @@ "should-quote": "^1.0.0", "ts-jest": "29.1.0", "ts-node": "10.9.1", - "ts-toolbelt": "6.15.4", + "ts-toolbelt": "^9.0.0", "tslib": "^2.0.0", "tslint": "~6.1.0", - "typescript": "~5.3.0", + "typescript": "~5.4.0", "zone.js": "~0.14.0" }, "lint-staged": { diff --git a/npm/ng-packs/packages/components/extensible/README.md b/npm/ng-packs/packages/components/extensible/README.md deleted file mode 100644 index 7a14a85f7c3..00000000000 --- a/npm/ng-packs/packages/components/extensible/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# @abp/ng.components/extensible - -Secondary entry point of `@abp/ng.components`. It can be used by importing from `@abp/ng.components/extensible`. diff --git a/npm/ng-packs/packages/components/extensible/src/lib/models/actions.ts b/npm/ng-packs/packages/components/extensible/src/lib/models/actions.ts index 07e3c0b91ee..57a8e26bf05 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/models/actions.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/models/actions.ts @@ -1,6 +1,5 @@ import { LinkedList } from '@abp/utils'; import { InjectFlags, InjectionToken, InjectOptions, Type } from '@angular/core'; -import { O } from 'ts-toolbelt'; export abstract class ActionList> extends LinkedList {} @@ -22,7 +21,7 @@ export abstract class ActionData { } } -export type ReadonlyActionData = O.Readonly, 'data'>>; +export type ReadonlyActionData = Readonly, 'data'>>; export abstract class Action { constructor( diff --git a/npm/ng-packs/packages/components/extensible/src/lib/models/entity-actions.ts b/npm/ng-packs/packages/components/extensible/src/lib/models/entity-actions.ts index eb103cb1bdf..1de7a5e76e5 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/models/entity-actions.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/models/entity-actions.ts @@ -1,5 +1,4 @@ import { Type } from '@angular/core'; -import { O } from 'ts-toolbelt'; import { Action, ActionContributorCallback, @@ -9,6 +8,7 @@ import { ActionsFactory, } from './actions'; import { FormPropTooltip } from './form-props'; +import { FilteredWithOptions, PartialWithOptions } from '../utils/model.utils'; export class EntityActionList extends ActionList> {} @@ -47,10 +47,9 @@ export class EntityAction extends Action { } } -export type EntityActionOptions = O.Optional< - O.Writable>, - 'permission' | 'visible' | 'icon' ->; +type OptionalKeys = 'permission' | 'visible' | 'icon'; +export type EntityActionOptions = PartialWithOptions, OptionalKeys> & + FilteredWithOptions, OptionalKeys>; export type EntityActionDefaults = Record[]>; export type EntityActionContributorCallback = ActionContributorCallback< diff --git a/npm/ng-packs/packages/components/extensible/src/lib/models/entity-props.ts b/npm/ng-packs/packages/components/extensible/src/lib/models/entity-props.ts index 7692457cd84..8964bd9090d 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/models/entity-props.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/models/entity-props.ts @@ -1,7 +1,6 @@ import { ABP, escapeHtmlChars } from '@abp/ng.core'; import { InjectFlags, InjectOptions, InjectionToken, Type } from '@angular/core'; import { Observable, of } from 'rxjs'; -import { O } from 'ts-toolbelt'; import { ActionCallback } from './actions'; import { Prop, @@ -13,6 +12,7 @@ import { PropsFactory, } from './props'; import { FormPropTooltip } from './form-props'; +import { FilteredWithOptions, PartialWithOptions } from '../utils/model.utils'; export class EntityPropList extends PropList> {} @@ -71,8 +71,7 @@ export class EntityProp extends Prop { } } -export type EntityPropOptions = O.Optional< - O.Writable>, +type OptionalKeys = | 'permission' | 'visible' | 'columnVisible' @@ -83,8 +82,9 @@ export type EntityPropOptions = O.Optional< | 'valueResolver' | 'action' | 'component' - | 'enumList' ->; + | 'enumList'; +export type EntityPropOptions = PartialWithOptions, OptionalKeys> & + FilteredWithOptions, OptionalKeys>; export type EntityPropDefaults = Record[]>; export type EntityPropContributorCallback = PropContributorCallback>; diff --git a/npm/ng-packs/packages/components/extensible/src/lib/models/form-props.ts b/npm/ng-packs/packages/components/extensible/src/lib/models/form-props.ts index c1b8cacbe28..f99aa016236 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/models/form-props.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/models/form-props.ts @@ -2,7 +2,6 @@ import { ABP } from '@abp/ng.core'; import { Injector, Type } from '@angular/core'; import { AsyncValidatorFn, ValidatorFn } from '@angular/forms'; import { Observable } from 'rxjs'; -import { O } from 'ts-toolbelt'; import { Prop, PropCallback, @@ -15,6 +14,7 @@ import { Props, PropsFactory, } from './props'; +import { FilteredWithOptions, PartialWithOptions } from '../utils/model.utils'; export class FormPropList extends PropList> {} @@ -131,8 +131,7 @@ export class FormPropData extends PropData { } } -export type FormPropOptions = O.Optional< - O.Writable>, +type OptionalKeys = | 'permission' | 'visible' | 'displayName' @@ -147,8 +146,9 @@ export type FormPropOptions = O.Optional< | 'id' | 'displayTextResolver' | 'formText' - | 'tooltip' ->; + | 'tooltip'; +export type FormPropOptions = PartialWithOptions, OptionalKeys> & + FilteredWithOptions, OptionalKeys>; export type CreateFormPropDefaults = Record[]>; export type CreateFormPropContributorCallback = PropContributorCallback>; diff --git a/npm/ng-packs/packages/components/extensible/src/lib/models/props.ts b/npm/ng-packs/packages/components/extensible/src/lib/models/props.ts index 2c88bd99398..7b1e2b7949e 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/models/props.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/models/props.ts @@ -1,6 +1,5 @@ import { LinkedList } from '@abp/utils'; import { InjectFlags, InjectionToken, InjectOptions, Type } from '@angular/core'; -import { O } from 'ts-toolbelt'; import { ePropType } from '../enums/props.enum'; import { FormPropTooltip } from './form-props'; @@ -24,7 +23,7 @@ export abstract class PropData { } } -export type ReadonlyPropData = O.Readonly, 'data'>>; +export type ReadonlyPropData = Readonly, 'data'>>; export abstract class Prop { constructor( diff --git a/npm/ng-packs/packages/components/extensible/src/lib/models/toolbar-actions.ts b/npm/ng-packs/packages/components/extensible/src/lib/models/toolbar-actions.ts index 02b26a81735..676b839bfd0 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/models/toolbar-actions.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/models/toolbar-actions.ts @@ -1,5 +1,4 @@ import { Injector, Type } from '@angular/core'; -import { O } from 'ts-toolbelt'; import { Action, ActionContributorCallback, @@ -10,6 +9,7 @@ import { ActionsFactory, ReadonlyActionData, } from './actions'; +import { FilteredWithOptions, PartialWithOptions } from '../utils/model.utils'; export class ToolbarActionList extends ActionList> {} @@ -61,15 +61,19 @@ export class ToolbarComponent extends Action { } } -export type ToolbarActionOptions = O.Optional< - O.Writable>, - 'permission' | 'visible' | 'icon' | 'btnClass' ->; - -export type ToolbarComponentOptions = O.Optional< - O.Writable>, - 'permission' | 'visible' | 'action' ->; +type OptionalActionKeys = 'permission' | 'visible' | 'icon' | 'btnClass'; +export type ToolbarActionOptions = PartialWithOptions< + ToolbarAction, + OptionalActionKeys +> & + FilteredWithOptions, OptionalActionKeys>; + +type OptionalComponentKeys = 'permission' | 'visible' | 'action'; +export type ToolbarComponentOptions = PartialWithOptions< + ToolbarComponent, + OptionalComponentKeys +> & + FilteredWithOptions, OptionalComponentKeys>; export type ToolbarActionDefault = ToolbarAction | ToolbarComponent; diff --git a/npm/ng-packs/packages/components/extensible/src/lib/utils/form-props.util.ts b/npm/ng-packs/packages/components/extensible/src/lib/utils/form-props.util.ts index ab7c669d477..75b8487b313 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/utils/form-props.util.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/utils/form-props.util.ts @@ -1,10 +1,10 @@ import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; -import { DateTimeAdapter,DateAdapter,TimeAdapter } from '@abp/ng.theme.shared'; +import { DateTimeAdapter, DateAdapter, TimeAdapter } from '@abp/ng.theme.shared'; import { EXTRA_PROPERTIES_KEY } from '../constants/extra-properties'; import { ePropType } from '../enums/props.enum'; -import { FormPropList } from "../models/form-props"; -import { PropData } from "../models/props"; +import { FormPropList } from '../models/form-props'; +import { PropData } from '../models/props'; import { ExtensionsService } from '../services/extensions.service'; import { EXTENSIONS_IDENTIFIER } from '../tokens/extensions.token'; diff --git a/npm/ng-packs/packages/components/extensible/src/lib/utils/model.utils.ts b/npm/ng-packs/packages/components/extensible/src/lib/utils/model.utils.ts new file mode 100644 index 00000000000..c7b7c6426aa --- /dev/null +++ b/npm/ng-packs/packages/components/extensible/src/lib/utils/model.utils.ts @@ -0,0 +1,2 @@ +export type PartialWithOptions = Partial>; +export type FilteredWithOptions = Omit; diff --git a/npm/ng-packs/packages/components/extensible/src/lib/utils/props.util.ts b/npm/ng-packs/packages/components/extensible/src/lib/utils/props.util.ts index 24360dccc17..72078580360 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/utils/props.util.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/utils/props.util.ts @@ -47,26 +47,29 @@ export function mergeWithDefaultProps>( ); }); } -type InferredPropDefaults = F extends EntityPropsFactory - ? EntityPropDefaults - : F extends CreateFormPropsFactory - ? CreateFormPropDefaults - : F extends EditFormPropsFactory - ? EditFormPropDefaults - : never; +type InferredPropDefaults = + F extends EntityPropsFactory + ? EntityPropDefaults + : F extends CreateFormPropsFactory + ? CreateFormPropDefaults + : F extends EditFormPropsFactory + ? EditFormPropDefaults + : never; -type InferredPropContributorCallbacks = F extends EntityPropsFactory - ? EntityPropContributorCallbacks - : F extends CreateFormPropsFactory - ? CreateFormPropContributorCallbacks - : F extends EditFormPropsFactory - ? EditFormPropContributorCallbacks - : never; +type InferredPropContributorCallbacks = + F extends EntityPropsFactory + ? EntityPropContributorCallbacks + : F extends CreateFormPropsFactory + ? CreateFormPropContributorCallbacks + : F extends EditFormPropsFactory + ? EditFormPropContributorCallbacks + : never; -type InferredProps = F extends EntityPropsFactory - ? EntityProps - : F extends CreateFormPropsFactory - ? FormProps - : F extends EditFormPropsFactory - ? FormProps - : never; +type InferredProps = + F extends EntityPropsFactory + ? EntityProps + : F extends CreateFormPropsFactory + ? FormProps + : F extends EditFormPropsFactory + ? FormProps + : never; diff --git a/npm/ng-packs/packages/components/extensible/src/lib/utils/typeahead.util.ts b/npm/ng-packs/packages/components/extensible/src/lib/utils/typeahead.util.ts index eec592ad0c2..baf41aacdb6 100644 --- a/npm/ng-packs/packages/components/extensible/src/lib/utils/typeahead.util.ts +++ b/npm/ng-packs/packages/components/extensible/src/lib/utils/typeahead.util.ts @@ -39,10 +39,10 @@ export function createTypeaheadOptions( } export function getTypeaheadType(lookup: ExtensionPropertyUiLookupDto, name: string) { - if (!!lookup.url) { - return ePropType.Typeahead; - } else { + if (!lookup.url) { return name.endsWith(TYPEAHEAD_TEXT_SUFFIX) ? ePropType.Hidden : undefined; + } else { + return ePropType.Typeahead; } } diff --git a/npm/ng-packs/packages/components/extensible/src/public-api.ts b/npm/ng-packs/packages/components/extensible/src/public-api.ts index abcc3a1a0cd..35e4696d49b 100644 --- a/npm/ng-packs/packages/components/extensible/src/public-api.ts +++ b/npm/ng-packs/packages/components/extensible/src/public-api.ts @@ -62,8 +62,9 @@ export * from './lib/pipes/create-injector.pipe'; export * from './lib/services/extensions.service'; export * from './lib/tokens/extensions.token'; export * from './lib/tokens/extensible-form-view-provider.token'; - export * from './lib/utils/actions.util'; +export * from './lib/utils/actions.util'; export * from './lib/utils/form-props.util'; export * from './lib/utils/props.util'; export * from './lib/utils/state.util'; +export * from './lib/utils/model.utils'; export * from './lib/extensible.module'; diff --git a/npm/ng-packs/packages/core/package.json b/npm/ng-packs/packages/core/package.json index cbce846954b..84ab284baaf 100644 --- a/npm/ng-packs/packages/core/package.json +++ b/npm/ng-packs/packages/core/package.json @@ -10,7 +10,7 @@ "@abp/utils": "~8.3.0-rc.1", "just-clone": "^6.0.0", "just-compare": "^2.0.0", - "ts-toolbelt": "6.15.4", + "ts-toolbelt": "^9.0.0", "tslib": "^2.0.0" }, "publishConfig": { diff --git a/npm/ng-packs/packages/core/src/lib/models/environment.ts b/npm/ng-packs/packages/core/src/lib/models/environment.ts index 78a9294525f..c67d4a687eb 100644 --- a/npm/ng-packs/packages/core/src/lib/models/environment.ts +++ b/npm/ng-packs/packages/core/src/lib/models/environment.ts @@ -20,7 +20,7 @@ export interface ApplicationInfo { export interface HasAdditional { [key: string]: string; } -export interface ApiConfig extends Partial{ +export interface ApiConfig extends Partial { url: string; rootNamespace?: string; }