@piying-lib/angular-core 1.0.0
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.
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { computed, viewChild, input, inject, TemplateRef, Component } from '@angular/core';
|
|
4
|
+
import { MatIcon } from '@angular/material/icon';
|
|
5
|
+
import { SelectorlessOutlet } from '@cyia/ngx-common/directive';
|
|
6
|
+
import { PurePipe } from '@cyia/ngx-common/pipe';
|
|
7
|
+
import { PiyingView, PI_INPUT_OPTIONS_TOKEN } from '@piying/view-angular';
|
|
8
|
+
|
|
9
|
+
const DefaultOptionConvert = {
|
|
10
|
+
label: (item) => (typeof item !== 'object' ? item : item.label),
|
|
11
|
+
description: (item) => item.description,
|
|
12
|
+
value: (item) => (typeof item !== 'object' ? item : item.value),
|
|
13
|
+
disabled: (item) => typeof item === 'object' && item.disabled,
|
|
14
|
+
isGroup: (item) => typeof item === 'object' && item.type === 'group',
|
|
15
|
+
type: (item) => (typeof item === 'object' ? item.type : 'option'),
|
|
16
|
+
children: (item) => item.children,
|
|
17
|
+
};
|
|
18
|
+
function transformOptions(options, optionConvert) {
|
|
19
|
+
return options.map((option) => {
|
|
20
|
+
const resolvedItem = {
|
|
21
|
+
...option,
|
|
22
|
+
label: optionConvert.label(option),
|
|
23
|
+
value: optionConvert.value(option),
|
|
24
|
+
disabled: optionConvert.disabled?.(option) ?? false,
|
|
25
|
+
type: 'option',
|
|
26
|
+
description: optionConvert.description(option),
|
|
27
|
+
};
|
|
28
|
+
if (optionConvert.isGroup(option)) {
|
|
29
|
+
resolvedItem.type = 'group';
|
|
30
|
+
resolvedItem.children = transformOptions(optionConvert.children(option), optionConvert);
|
|
31
|
+
return resolvedItem;
|
|
32
|
+
}
|
|
33
|
+
return resolvedItem;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function transformOption(option, optionConvert) {
|
|
37
|
+
const resolvedItem = {
|
|
38
|
+
label: optionConvert.label(option),
|
|
39
|
+
value: optionConvert.value(option),
|
|
40
|
+
disabled: optionConvert.disabled?.(option) ?? false,
|
|
41
|
+
type: optionConvert.type?.(option) ?? 'option',
|
|
42
|
+
description: optionConvert.description(option),
|
|
43
|
+
origin: option,
|
|
44
|
+
};
|
|
45
|
+
if (optionConvert.isGroup(option)) {
|
|
46
|
+
resolvedItem.type = 'group';
|
|
47
|
+
resolvedItem.children = transformOptions(optionConvert.children(option), optionConvert);
|
|
48
|
+
return resolvedItem;
|
|
49
|
+
}
|
|
50
|
+
return resolvedItem;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function computedWithPrev(computation, options) {
|
|
54
|
+
let previous;
|
|
55
|
+
return computed(() => {
|
|
56
|
+
const newValue = computation(previous);
|
|
57
|
+
previous = newValue;
|
|
58
|
+
return newValue;
|
|
59
|
+
}, options);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function isSchema(input) {
|
|
63
|
+
return (input && typeof input === 'object' && '~run' in input && 'kind' in input && 'type' in input);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class StrOrTemplateComponent {
|
|
67
|
+
static __version = 2;
|
|
68
|
+
PiyingView = PiyingView;
|
|
69
|
+
templateRef = viewChild.required('templateRef');
|
|
70
|
+
content = input(...(ngDevMode ? [undefined, { debugName: "content" }] : []));
|
|
71
|
+
context = input(...(ngDevMode ? [undefined, { debugName: "context" }] : []));
|
|
72
|
+
parentPyOptions = inject(PI_INPUT_OPTIONS_TOKEN, { optional: true });
|
|
73
|
+
schemaOptions$$ = computed(() => {
|
|
74
|
+
return {
|
|
75
|
+
...this.parentPyOptions(),
|
|
76
|
+
context: { ...this.parentPyOptions().context, ...this.context() },
|
|
77
|
+
};
|
|
78
|
+
}, ...(ngDevMode ? [{ debugName: "schemaOptions$$" }] : []));
|
|
79
|
+
isString(input) {
|
|
80
|
+
return typeof input === 'string' || typeof input === 'number' || typeof input === 'boolean';
|
|
81
|
+
}
|
|
82
|
+
isTemplateRef(input) {
|
|
83
|
+
return input instanceof TemplateRef;
|
|
84
|
+
}
|
|
85
|
+
isObject(input) {
|
|
86
|
+
return typeof input === 'object';
|
|
87
|
+
}
|
|
88
|
+
isSchema = isSchema;
|
|
89
|
+
piyingInput = (schema, options) => {
|
|
90
|
+
return {
|
|
91
|
+
schema,
|
|
92
|
+
options,
|
|
93
|
+
selectorless: true,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: StrOrTemplateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
97
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.14", type: StrOrTemplateComponent, isStandalone: true, selector: "app-str-or-template", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "context", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "templateRef", first: true, predicate: ["templateRef"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-template #templateRef>\n @let data = $any(content());\n @if (isString | pure: data) {\n {{ data }}\n } @else if (isTemplateRef | pure: data) {\n <ng-container *ngTemplateOutlet=\"$any(data)\"></ng-container>\n } @else if (isSchema | pure: data) {\n <ng-container\n [selectlessOutlet]=\"PiyingView\"\n [selectlessOutletInputs]=\"piyingInput | pure: content : schemaOptions$$\"\n ></ng-container>\n } @else if (isObject | pure: data) {\n @if (data['image']; as image) {\n <img [src]=\"image.src\" [alt]=\"image.alt\" />\n }\n @if (data['icon']; as icon) {\n <mat-icon\n [inline]=\"icon.inline\"\n [fontIcon]=\"icon.fontIcon\"\n [fontSet]=\"icon.fontSet\"\n [svgIcon]=\"icon.svgIcon\"\n ></mat-icon>\n }\n @if (data['title']) {\n <span>\n {{ data['title'] }}\n </span>\n }\n }\n</ng-template>\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: SelectorlessOutlet, selector: "[selectlessOutlet]", inputs: ["selectlessOutlet", "selectlessOutletInputs", "selectlessOutletOutputs", "selectlessOutletDirectives", "selectlessOutletInjector", "selectlessOutletEnvironmentInjector"], exportAs: ["selectlessOutlet"] }, { kind: "pipe", type: PurePipe, name: "pure" }] });
|
|
98
|
+
}
|
|
99
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: StrOrTemplateComponent, decorators: [{
|
|
100
|
+
type: Component,
|
|
101
|
+
args: [{ selector: 'app-str-or-template', imports: [PurePipe, NgTemplateOutlet, MatIcon, SelectorlessOutlet, PiyingView], template: "<ng-template #templateRef>\n @let data = $any(content());\n @if (isString | pure: data) {\n {{ data }}\n } @else if (isTemplateRef | pure: data) {\n <ng-container *ngTemplateOutlet=\"$any(data)\"></ng-container>\n } @else if (isSchema | pure: data) {\n <ng-container\n [selectlessOutlet]=\"PiyingView\"\n [selectlessOutletInputs]=\"piyingInput | pure: content : schemaOptions$$\"\n ></ng-container>\n } @else if (isObject | pure: data) {\n @if (data['image']; as image) {\n <img [src]=\"image.src\" [alt]=\"image.alt\" />\n }\n @if (data['icon']; as icon) {\n <mat-icon\n [inline]=\"icon.inline\"\n [fontIcon]=\"icon.fontIcon\"\n [fontSet]=\"icon.fontSet\"\n [svgIcon]=\"icon.svgIcon\"\n ></mat-icon>\n }\n @if (data['title']) {\n <span>\n {{ data['title'] }}\n </span>\n }\n }\n</ng-template>\n" }]
|
|
102
|
+
}], propDecorators: { templateRef: [{ type: i0.ViewChild, args: ['templateRef', { isSignal: true }] }], content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], context: [{ type: i0.Input, args: [{ isSignal: true, alias: "context", required: false }] }] } });
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Generated bundle index. Do not edit.
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
export { DefaultOptionConvert, StrOrTemplateComponent, computedWithPrev, isSchema, transformOption, transformOptions };
|
|
109
|
+
//# sourceMappingURL=piying-lib-angular-core.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"piying-lib-angular-core.mjs","sources":["../../../projects/core/util/options.ts","../../../projects/core/util/computed-with-prev.ts","../../../projects/core/util/is.ts","../../../projects/core/str-template/component.ts","../../../projects/core/str-template/component.html","../../../projects/core/piying-lib-angular-core.ts"],"sourcesContent":["export interface Option1 {\n label: string;\n value: any;\n disabled?: boolean;\n type?: 'option';\n description?: string;\n}\nexport interface OptionGroup {\n disabled?: boolean;\n label: string;\n children: Option1[];\n type: 'group';\n description?: string;\n}\nexport interface ResolvedOption {\n label: string;\n value: any;\n disabled?: boolean;\n type: 'option' | 'group' | (string & {});\n children?: ResolvedOption[];\n description?: string;\n origin: any;\n}\nexport interface OptionConvert {\n label: (input: any) => string;\n description: (input: any) => string;\n value: (input: any) => any;\n isGroup: (input: any) => boolean;\n children: (input: any) => any[];\n disabled?: (input: any) => boolean;\n type?: (input: any) => string;\n}\nexport type Option2 = string;\n\nexport const DefaultOptionConvert: OptionConvert = {\n label: (item) => (typeof item !== 'object' ? item : item.label),\n description: (item) => item.description,\n value: (item) => (typeof item !== 'object' ? item : item.value),\n disabled: (item) => typeof item === 'object' && item.disabled,\n isGroup: (item) => typeof item === 'object' && item.type === 'group',\n type: (item) => (typeof item === 'object' ? item.type : 'option'),\n children: (item) => item.children,\n};\n\nexport function transformOptions(options: any[], optionConvert: OptionConvert): ResolvedOption[] {\n return options.map((option) => {\n const resolvedItem: ResolvedOption = {\n ...option,\n label: optionConvert.label(option),\n value: optionConvert.value(option),\n disabled: optionConvert.disabled?.(option) ?? false,\n type: 'option',\n description: optionConvert.description(option),\n };\n if (optionConvert.isGroup(option)) {\n resolvedItem.type = 'group';\n resolvedItem.children = transformOptions(optionConvert.children(option), optionConvert);\n return resolvedItem;\n }\n return resolvedItem;\n });\n}\nexport function transformOption(option: any, optionConvert: OptionConvert): ResolvedOption {\n const resolvedItem: ResolvedOption = {\n label: optionConvert.label(option),\n value: optionConvert.value(option),\n disabled: optionConvert.disabled?.(option) ?? false,\n type: optionConvert.type?.(option) ?? 'option',\n description: optionConvert.description(option),\n origin: option,\n };\n if (optionConvert.isGroup(option)) {\n resolvedItem.type = 'group';\n resolvedItem.children = transformOptions(optionConvert.children(option), optionConvert);\n return resolvedItem;\n }\n return resolvedItem;\n}\n\nexport interface SelectOption {\n readonly label?: string;\n readonly value: any;\n readonly description?: string;\n readonly disabled?: boolean;\n /** 样式代替label */\n readonly style?: any;\n}\n","import { computed, CreateComputedOptions, Signal } from '@angular/core';\n\nexport function computedWithPrev<T>(\n computation: (prev: T | undefined) => T,\n options?: CreateComputedOptions<T>,\n): Signal<T> {\n let previous: T | undefined;\n return computed(() => {\n const newValue = computation(previous);\n previous = newValue;\n return newValue;\n }, options);\n}\n","export function isSchema(input: any) {\n return (\n input && typeof input === 'object' && '~run' in input && 'kind' in input && 'type' in input\n );\n}\n","import { NgTemplateOutlet } from '@angular/common';\nimport { Component, computed, inject, input, TemplateRef, viewChild } from '@angular/core';\nimport { MatIcon } from '@angular/material/icon';\nimport { SelectorlessOutlet } from '@cyia/ngx-common/directive';\nimport { PurePipe } from '@cyia/ngx-common/pipe';\nimport { isSchema } from '../util';\nimport { PI_INPUT_OPTIONS_TOKEN, PiyingView } from '@piying/view-angular';\n\n@Component({\n selector: 'app-str-or-template',\n templateUrl: './component.html',\n imports: [PurePipe, NgTemplateOutlet, MatIcon, SelectorlessOutlet, PiyingView],\n})\nexport class StrOrTemplateComponent {\n static __version = 2;\n readonly PiyingView = PiyingView;\n templateRef = viewChild.required('templateRef');\n content = input();\n context = input();\n parentPyOptions = inject(PI_INPUT_OPTIONS_TOKEN, { optional: true });\n schemaOptions$$ = computed(() => {\n return {\n ...this.parentPyOptions!(),\n context: { ...this.parentPyOptions!().context, ...(this.context() as any) },\n };\n });\n\n isString(input: any) {\n return typeof input === 'string' || typeof input === 'number' || typeof input === 'boolean';\n }\n isTemplateRef(input: any) {\n return input instanceof TemplateRef;\n }\n isObject(input: any) {\n return typeof input === 'object';\n }\n isSchema = isSchema;\n piyingInput = (schema: any, options: any) => {\n return {\n schema,\n options,\n selectorless: true,\n };\n };\n}\n","<ng-template #templateRef>\n @let data = $any(content());\n @if (isString | pure: data) {\n {{ data }}\n } @else if (isTemplateRef | pure: data) {\n <ng-container *ngTemplateOutlet=\"$any(data)\"></ng-container>\n } @else if (isSchema | pure: data) {\n <ng-container\n [selectlessOutlet]=\"PiyingView\"\n [selectlessOutletInputs]=\"piyingInput | pure: content : schemaOptions$$\"\n ></ng-container>\n } @else if (isObject | pure: data) {\n @if (data['image']; as image) {\n <img [src]=\"image.src\" [alt]=\"image.alt\" />\n }\n @if (data['icon']; as icon) {\n <mat-icon\n [inline]=\"icon.inline\"\n [fontIcon]=\"icon.fontIcon\"\n [fontSet]=\"icon.fontSet\"\n [svgIcon]=\"icon.svgIcon\"\n ></mat-icon>\n }\n @if (data['title']) {\n <span>\n {{ data['title'] }}\n </span>\n }\n }\n</ng-template>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;AAkCO,MAAM,oBAAoB,GAAkB;IACjD,KAAK,EAAE,CAAC,IAAI,MAAM,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/D,WAAW,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW;IACvC,KAAK,EAAE,CAAC,IAAI,MAAM,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,GAA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K7C,aAAa,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,SAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,SAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEhBhD;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as valibot from 'valibot';
|
|
2
|
+
import * as _piying_view_angular from '@piying/view-angular';
|
|
3
|
+
import { PiyingView } from '@piying/view-angular';
|
|
4
|
+
import * as _piying_valibot_visit from '@piying/valibot-visit';
|
|
5
|
+
import * as _piying_view_angular_core from '@piying/view-angular-core';
|
|
6
|
+
import * as _angular_core from '@angular/core';
|
|
7
|
+
import { CreateComputedOptions, Signal, TemplateRef } from '@angular/core';
|
|
8
|
+
|
|
9
|
+
interface Option1 {
|
|
10
|
+
label: string;
|
|
11
|
+
value: any;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
type?: 'option';
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
interface OptionGroup {
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
label: string;
|
|
19
|
+
children: Option1[];
|
|
20
|
+
type: 'group';
|
|
21
|
+
description?: string;
|
|
22
|
+
}
|
|
23
|
+
interface ResolvedOption {
|
|
24
|
+
label: string;
|
|
25
|
+
value: any;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
type: 'option' | 'group' | (string & {});
|
|
28
|
+
children?: ResolvedOption[];
|
|
29
|
+
description?: string;
|
|
30
|
+
origin: any;
|
|
31
|
+
}
|
|
32
|
+
interface OptionConvert {
|
|
33
|
+
label: (input: any) => string;
|
|
34
|
+
description: (input: any) => string;
|
|
35
|
+
value: (input: any) => any;
|
|
36
|
+
isGroup: (input: any) => boolean;
|
|
37
|
+
children: (input: any) => any[];
|
|
38
|
+
disabled?: (input: any) => boolean;
|
|
39
|
+
type?: (input: any) => string;
|
|
40
|
+
}
|
|
41
|
+
type Option2 = string;
|
|
42
|
+
declare const DefaultOptionConvert: OptionConvert;
|
|
43
|
+
declare function transformOptions(options: any[], optionConvert: OptionConvert): ResolvedOption[];
|
|
44
|
+
declare function transformOption(option: any, optionConvert: OptionConvert): ResolvedOption;
|
|
45
|
+
interface SelectOption {
|
|
46
|
+
readonly label?: string;
|
|
47
|
+
readonly value: any;
|
|
48
|
+
readonly description?: string;
|
|
49
|
+
readonly disabled?: boolean;
|
|
50
|
+
/** 样式代替label */
|
|
51
|
+
readonly style?: any;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | (string & {});
|
|
55
|
+
type Color = 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' | (string & {});
|
|
56
|
+
type AlertColor = 'info' | 'success' | 'warning' | 'error' | (string & {});
|
|
57
|
+
interface IconConfig {
|
|
58
|
+
fontIcon?: string;
|
|
59
|
+
fontSet?: string;
|
|
60
|
+
svgIcon?: string;
|
|
61
|
+
inline?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare function computedWithPrev<T>(computation: (prev: T | undefined) => T, options?: CreateComputedOptions<T>): Signal<T>;
|
|
65
|
+
|
|
66
|
+
declare function isSchema(input: any): any;
|
|
67
|
+
|
|
68
|
+
declare class StrOrTemplateComponent {
|
|
69
|
+
static __version: number;
|
|
70
|
+
readonly PiyingView: typeof PiyingView;
|
|
71
|
+
templateRef: _angular_core.Signal<unknown>;
|
|
72
|
+
content: _angular_core.InputSignal<unknown>;
|
|
73
|
+
context: _angular_core.InputSignal<unknown>;
|
|
74
|
+
parentPyOptions: _angular_core.Signal<Omit<_piying_view_angular_core.SetOptional<Omit<_piying_valibot_visit.ConvertOptions<typeof _piying_view_angular_core.CoreSchemaHandle>, "handle"> & Partial<Pick<_piying_valibot_visit.ConvertOptions<typeof _piying_view_angular_core.CoreSchemaHandle>, "handle">> & {
|
|
75
|
+
builder: typeof _piying_view_angular_core.FormBuilder;
|
|
76
|
+
fieldGlobalConfig?: _piying_view_angular.PiViewConfig;
|
|
77
|
+
}, "handle" | "builder">, "fieldGlobalConfig"> & {
|
|
78
|
+
fieldGlobalConfig?: _piying_view_angular.PiViewConfig;
|
|
79
|
+
}> | null;
|
|
80
|
+
schemaOptions$$: _angular_core.Signal<{
|
|
81
|
+
context: any;
|
|
82
|
+
handle?: typeof _piying_view_angular_core.CoreSchemaHandle | undefined;
|
|
83
|
+
environments?: string[] | undefined;
|
|
84
|
+
defaultMetadataActionsGroup?: Record<string, valibot.BaseMetadata<any>[]> | undefined;
|
|
85
|
+
additionalData?: Record<string, any> | undefined;
|
|
86
|
+
builder?: typeof _piying_view_angular_core.FormBuilder | undefined;
|
|
87
|
+
fieldGlobalConfig?: _piying_view_angular.PiViewConfig;
|
|
88
|
+
}>;
|
|
89
|
+
isString(input: any): input is string | number | boolean;
|
|
90
|
+
isTemplateRef(input: any): input is TemplateRef<any>;
|
|
91
|
+
isObject(input: any): boolean;
|
|
92
|
+
isSchema: typeof isSchema;
|
|
93
|
+
piyingInput: (schema: any, options: any) => {
|
|
94
|
+
schema: any;
|
|
95
|
+
options: any;
|
|
96
|
+
selectorless: boolean;
|
|
97
|
+
};
|
|
98
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<StrOrTemplateComponent, never>;
|
|
99
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<StrOrTemplateComponent, "app-str-or-template", never, { "content": { "alias": "content"; "required": false; "isSignal": true; }; "context": { "alias": "context"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { DefaultOptionConvert, StrOrTemplateComponent, computedWithPrev, isSchema, transformOption, transformOptions };
|
|
103
|
+
export type { AlertColor, Color, IconConfig, Option1, Option2, OptionConvert, OptionGroup, ResolvedOption, SelectOption, Size };
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@piying-lib/angular-core",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^20.3.0",
|
|
6
|
+
"@angular/core": "^20.3.0"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"tslib": "^2.3.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"module": "fesm2022/piying-lib-angular-core.mjs",
|
|
13
|
+
"typings": "index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": {
|
|
16
|
+
"default": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"default": "./fesm2022/piying-lib-angular-core.mjs"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|