@toolmain/components 1.2.14 → 1.2.15

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.
package/dist/index.d.ts CHANGED
@@ -248,7 +248,7 @@ export declare type BaseComponentSerialized = {
248
248
  children: BaseComponentSerialized[];
249
249
  };
250
250
 
251
- declare interface BaseConfigProps {
251
+ export declare interface BaseConfigProps {
252
252
  /**
253
253
  * 当属性存在多种类型时,要选择最终的类型
254
254
  */
@@ -275,7 +275,7 @@ declare interface BaseConfigProps {
275
275
  disabled?: boolean;
276
276
  }
277
277
 
278
- declare interface BaseProps extends BaseConfigProps {
278
+ export declare interface BaseProps extends BaseConfigProps {
279
279
  /**
280
280
  * 默认预设值
281
281
  */
@@ -390,11 +390,11 @@ export declare type CameraConf = {
390
390
  };
391
391
  };
392
392
 
393
- declare interface ColorProps extends BaseProps {
393
+ export declare interface ColorProps extends BaseProps {
394
394
  type: PropsType.Color;
395
395
  }
396
396
 
397
- declare type CombArray<T> = T | T[];
397
+ export declare type CombArray<T> = T | T[];
398
398
 
399
399
  /**
400
400
  * UI组件拥有的默认事件
@@ -530,7 +530,15 @@ export declare interface ComponentProvider extends EventBus<ProviderEv> {
530
530
  getVarState: () => ComponentVarState;
531
531
  }
532
532
 
533
- declare interface ComponentVarState {
533
+ export declare type ComponentUIGroup = {
534
+ label: string;
535
+ list: Array<{
536
+ label: string;
537
+ icon?: string | VNode;
538
+ }>;
539
+ };
540
+
541
+ export declare interface ComponentVarState {
534
542
  dispose: () => void;
535
543
  createVariable: (config: VariableStatic) => Variable;
536
544
  delVariable: (varId: string) => Variable | undefined;
@@ -623,6 +631,11 @@ declare interface DebugPanel {
623
631
  node: VNode | Component | string;
624
632
  }
625
633
 
634
+ /**
635
+ * 元素默认属性
636
+ */
637
+ export declare const defaultProps: () => Record<string, Props>;
638
+
626
639
  export declare type DeliverParam = {
627
640
  instanceId?: string;
628
641
  raw?: RawComponent;
@@ -711,7 +724,7 @@ export declare interface ElRect {
711
724
  y: number;
712
725
  }
713
726
 
714
- declare interface EnumProps extends BaseProps {
727
+ export declare interface EnumProps extends BaseProps {
715
728
  type: PropsType.Enum;
716
729
  enums: Array<string | number | boolean>;
717
730
  }
@@ -768,12 +781,12 @@ export declare interface EventMap {
768
781
  moving: (pos: DragAttr) => void;
769
782
  }
770
783
 
771
- declare interface ExtendProps extends BaseProps {
784
+ export declare interface ExtendProps extends BaseProps {
772
785
  type: PropsType.Extend;
773
786
  extendType: string;
774
787
  }
775
788
 
776
- declare interface ExtendPropsParser {
789
+ export declare interface ExtendPropsParser {
777
790
  parse(value: Props): PropsValue;
778
791
  extendType(): string;
779
792
  }
@@ -791,7 +804,7 @@ declare type FixedArray<T, L extends number> = Pick<T[], Exclude<keyof T[], ArrM
791
804
  readonly length: L;
792
805
  };
793
806
 
794
- declare interface FunctionProps extends BaseProps {
807
+ export declare interface FunctionProps extends BaseProps {
795
808
  type: PropsType.Function;
796
809
  /**
797
810
  * 实际的参数字符串会被传送到`Function`的参数中
@@ -817,6 +830,11 @@ export declare class GeneralLibrary implements ComponentLibrary {
817
830
  isPlaceHolder(raw: RawComponent): boolean;
818
831
  }
819
832
 
833
+ /**
834
+ * 推算出当前属性的最终类型
835
+ */
836
+ export declare function getFinalType(props: Props): PropsType | undefined;
837
+
820
838
  export declare function getModel(url: string, onProgress?: (progress: LoadProgressData) => void): Promise<{
821
839
  code: number;
822
840
  msg: string;
@@ -840,7 +858,7 @@ export declare const htmlTextConfig: (label: string, libraryId: string) => RawCo
840
858
 
841
859
  export declare const htmlTextLabel: string[];
842
860
 
843
- declare interface IconProps extends BaseProps {
861
+ export declare interface IconProps extends BaseProps {
844
862
  type: PropsType.Icon;
845
863
  }
846
864
 
@@ -850,7 +868,32 @@ export declare function initRect(): Rect;
850
868
 
851
869
  export declare type InitType = "auto" | "inherit" | "initial" | "unset";
852
870
 
853
- declare interface JSONProps extends BaseProps {
871
+ export declare function isColorProps(props: Props): props is ColorProps;
872
+
873
+ export declare function isEnumProps(props: Props): props is EnumProps;
874
+
875
+ export declare function isExtendProps(props: Props): props is ExtendProps;
876
+
877
+ export declare function isFunctionProps(props: Props): props is FunctionProps;
878
+
879
+ export declare function isIconProps(props: Props): props is IconProps;
880
+
881
+ export declare function isJSONProps(props: Props): props is JSONProps;
882
+
883
+ /**
884
+ * 判断是否是基本数据类型
885
+ */
886
+ export declare function isPrimitive(type: unknown): type is Primitive;
887
+
888
+ export declare function isPrimitiveProps(props: Props): props is PrimitiveProps;
889
+
890
+ export declare function isTimeProps(props: Props): props is TimeProps;
891
+
892
+ export declare function isType(src: unknown, target: PropsType): boolean;
893
+
894
+ export declare function isVueProps(props: Props): props is VueProps;
895
+
896
+ export declare interface JSONProps extends BaseProps {
854
897
  type: PropsType.JSON;
855
898
  }
856
899
 
@@ -989,7 +1032,7 @@ export declare interface LoadProgressData {
989
1032
  describe?: string;
990
1033
  }
991
1034
 
992
- declare type MixedProps = BaseProps & Partial<Omit<PrimitiveProps, "type">> & Partial<Omit<ColorProps, "type">> & Partial<Omit<JSONProps, "type">> & Partial<Omit<TimeProps, "type">> & Partial<Omit<EnumProps, "type">> & Partial<Omit<FunctionProps, "type">> & Partial<Omit<VueProps, "type">> & Partial<Omit<ExtendProps, "type">> & Partial<Omit<IconProps, "type">> & {
1035
+ export declare type MixedProps = BaseProps & Partial<Omit<PrimitiveProps, "type">> & Partial<Omit<ColorProps, "type">> & Partial<Omit<JSONProps, "type">> & Partial<Omit<TimeProps, "type">> & Partial<Omit<EnumProps, "type">> & Partial<Omit<FunctionProps, "type">> & Partial<Omit<VueProps, "type">> & Partial<Omit<ExtendProps, "type">> & Partial<Omit<IconProps, "type">> & {
993
1036
  type: Array<PropsType>;
994
1037
  };
995
1038
 
@@ -1076,6 +1119,13 @@ declare class NodeTree {
1076
1119
 
1077
1120
  export declare const ParentView: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
1078
1121
 
1122
+ export declare function parseProp(propKey: string, prop: Props, parser: PropsGenerator, provider: ComponentProvider): unknown;
1123
+
1124
+ /**
1125
+ * @param [withoutUndefined=false] 是否过滤掉undefined的属性,default:false
1126
+ */
1127
+ export declare function parseProps(newProps: Record<string, Props>, parser: PropsGenerator, provider: ComponentProvider, withoutUndefined?: boolean): Record<string, unknown>;
1128
+
1079
1129
  export declare const placeholderNode: () => VNode<RendererNode, RendererElement, {
1080
1130
  [key: string]: any;
1081
1131
  }>;
@@ -1088,13 +1138,13 @@ export declare const placeholderRaw: () => RawComponent;
1088
1138
  /**
1089
1139
  * 基础数据类型的单个或者数组结构类型
1090
1140
  */
1091
- declare interface PrimitiveProps extends BaseProps {
1141
+ export declare interface PrimitiveProps extends BaseProps {
1092
1142
  type: CombArray<PropsType.Number | PropsType.String | PropsType.Boolean | PropsType.Undefined | PropsType.Null | PropsType.Symbol | PropsType.BigInt>;
1093
1143
  }
1094
1144
 
1095
- declare type Props = PrimitiveProps | ColorProps | JSONProps | TimeProps | EnumProps | FunctionProps | VueProps | ExtendProps | IconProps | MixedProps;
1145
+ export declare type Props = PrimitiveProps | ColorProps | JSONProps | TimeProps | EnumProps | FunctionProps | VueProps | ExtendProps | IconProps | MixedProps;
1096
1146
 
1097
- declare interface PropsGenerator {
1147
+ export declare interface PropsGenerator {
1098
1148
  addParser(parser: PropsParser): this;
1099
1149
  addExtendParser(extendParser: ExtendPropsParser): this;
1100
1150
  getParsers(): PropsParser[];
@@ -1112,12 +1162,12 @@ export declare class PropsGeneratorImpl implements PropsGenerator {
1112
1162
  parse(props: Props): PropsValue | undefined;
1113
1163
  }
1114
1164
 
1115
- declare interface PropsParser {
1165
+ export declare interface PropsParser {
1116
1166
  parse(value: Props): PropsValue;
1117
1167
  propsType(): PropsType;
1118
1168
  }
1119
1169
 
1120
- declare enum PropsType {
1170
+ export declare enum PropsType {
1121
1171
  Number = "Number",
1122
1172
  String = "String",
1123
1173
  Boolean = "Boolean",
@@ -1141,7 +1191,7 @@ declare enum PropsType {
1141
1191
  Extend = "Extend"
1142
1192
  }
1143
1193
 
1144
- declare type PropsValue = Props & {
1194
+ export declare type PropsValue = Props & {
1145
1195
  value: unknown;
1146
1196
  };
1147
1197
 
@@ -1267,6 +1317,11 @@ export declare interface Rect {
1267
1317
  y: number;
1268
1318
  }
1269
1319
 
1320
+ /**
1321
+ * 注册默认UI组件内部事件
1322
+ */
1323
+ export declare const registerEvents: (instanceId: string, raw: RawComponent, provider?: ComponentProvider) => Record<string, CallBackFn>;
1324
+
1270
1325
  /**
1271
1326
  * 远程资源,贴图,视频等
1272
1327
  */
@@ -1618,7 +1673,7 @@ export declare type ThreePanelConf = {
1618
1673
  lights: Array<LightMeta>;
1619
1674
  };
1620
1675
 
1621
- declare interface TimeProps extends BaseProps {
1676
+ export declare interface TimeProps extends BaseProps {
1622
1677
  type: PropsType.Time;
1623
1678
  format?: string;
1624
1679
  }
@@ -1716,7 +1771,7 @@ export declare function useTarget(): Target;
1716
1771
 
1717
1772
  export declare const useVarState: () => ComponentVarState;
1718
1773
 
1719
- declare enum ValueType {
1774
+ export declare enum ValueType {
1720
1775
  /**
1721
1776
  * 属性值为静态值
1722
1777
  */
@@ -1731,7 +1786,7 @@ declare enum ValueType {
1731
1786
  Remote = "Remote"
1732
1787
  }
1733
1788
 
1734
- declare interface Variable {
1789
+ export declare interface Variable {
1735
1790
  /**
1736
1791
  * 唯一ID
1737
1792
  */
@@ -1755,11 +1810,11 @@ declare interface Variable {
1755
1810
  value: Ref<unknown> | Reactive<Array<unknown> | Record<string, unknown>>;
1756
1811
  }
1757
1812
 
1758
- declare type VariableSerialized = Omit<Variable, "value"> & {
1813
+ export declare type VariableSerialized = Omit<Variable, "value"> & {
1759
1814
  value: any;
1760
1815
  };
1761
1816
 
1762
- declare type VariableStatic = Omit<Variable, "id" | "value" | "type"> & Partial<Pick<Variable, "id">> & {
1817
+ export declare type VariableStatic = Omit<Variable, "id" | "value" | "type"> & Partial<Pick<Variable, "id">> & {
1763
1818
  value?: any;
1764
1819
  };
1765
1820
 
@@ -1774,13 +1829,13 @@ export declare class VarState implements ComponentVarState {
1774
1829
  deserialize(data: VariableSerialized[]): Variable[];
1775
1830
  }
1776
1831
 
1777
- declare enum VarsType {
1832
+ export declare enum VarsType {
1778
1833
  Primitive = "Primitive",
1779
1834
  Object = "Object",
1780
1835
  Array = "Array"
1781
1836
  }
1782
1837
 
1783
- declare interface VueProps extends BaseProps {
1838
+ export declare interface VueProps extends BaseProps {
1784
1839
  type: PropsType.Vue;
1785
1840
  }
1786
1841
 
package/dist/index.js CHANGED
@@ -12644,6 +12644,16 @@ const wi = _e({ name: "ep-loading", render: th }), nh = /* @__PURE__ */ lt({
12644
12644
  }
12645
12645
  }), Bb = /* @__PURE__ */ Yt(nh, [["__scopeId", "data-v-cbef7acf"]]);
12646
12646
  var W = /* @__PURE__ */ ((s) => (s.NULL = "NULL", s.PLACEHOLDER = "PLACEHOLDER", s.PLAIN = "PLAIN", s))(W || {}), In = /* @__PURE__ */ ((s) => (s.Static = "Static", s.Variable = "Variable", s.Remote = "Remote", s))(In || {}), u = /* @__PURE__ */ ((s) => (s.Number = "Number", s.String = "String", s.Boolean = "Boolean", s.Undefined = "Undefined", s.Null = "Null", s.Symbol = "Symbol", s.BigInt = "BigInt", s.Time = "Time", s.Color = "Color", s.JSON = "JSON", s.Enum = "Enum", s.Function = "Function", s.Icon = "Icon", s.Vue = "Vue", s.Extend = "Extend", s))(u || {});
12647
+ function zb(s, e) {
12648
+ return s === e;
12649
+ }
12650
+ function Fb(s) {
12651
+ return typeof s == "string" || typeof s == "number" || typeof s == "boolean" || typeof s == "bigint" || typeof s == "symbol" || s === void 0 || s === null;
12652
+ }
12653
+ function Ub(s) {
12654
+ const e = (t) => t === "Boolean" || t === "Number" || t === "String" || t === "BigInt" || t === "Symbol" || t === "Undefined" || t === "Null";
12655
+ return Array.isArray(s.type) ? s.type.every(e) : e(s.type);
12656
+ }
12647
12657
  function rh(s) {
12648
12658
  return s.finalType === "Color";
12649
12659
  }
@@ -12659,6 +12669,9 @@ function ih(s) {
12659
12669
  function sh(s) {
12660
12670
  return s.finalType === "Function";
12661
12671
  }
12672
+ function Hb(s) {
12673
+ return s.finalType === "Vue";
12674
+ }
12662
12675
  function lh(s) {
12663
12676
  return s.finalType === "Extend";
12664
12677
  }
@@ -12747,7 +12760,7 @@ const uh = [
12747
12760
  }
12748
12761
  }
12749
12762
  }), dh = () => oe("div");
12750
- class zb {
12763
+ class $b {
12751
12764
  #e;
12752
12765
  constructor() {
12753
12766
  this.#e = new Map(
@@ -13468,7 +13481,7 @@ function Mh(s, e, t) {
13468
13481
  }
13469
13482
  const kh = {
13470
13483
  name: "RecursiveRenderer"
13471
- }, Fb = /* @__PURE__ */ lt({
13484
+ }, Kb = /* @__PURE__ */ lt({
13472
13485
  ...kh,
13473
13486
  props: {
13474
13487
  data: {},
@@ -13692,7 +13705,7 @@ const kh = {
13692
13705
  __proto__: null,
13693
13706
  default: Bh
13694
13707
  }, Symbol.toStringTag, { value: "Module" })), Zl = "EpComponent";
13695
- class Ub {
13708
+ class Xb {
13696
13709
  extendType() {
13697
13710
  return Zl;
13698
13711
  }
@@ -19494,7 +19507,7 @@ function Q1(s, e) {
19494
19507
  }, null, -1)
19495
19508
  ])]);
19496
19509
  }
19497
- const eb = _e({ name: "ep-watermelon", render: Q1 }), Hb = /* @__PURE__ */ lt({
19510
+ const eb = _e({ name: "ep-watermelon", render: Q1 }), Gb = /* @__PURE__ */ lt({
19498
19511
  __name: "index",
19499
19512
  props: {
19500
19513
  lib: {},
@@ -19636,7 +19649,7 @@ const eb = _e({ name: "ep-watermelon", render: Q1 }), Hb = /* @__PURE__ */ lt({
19636
19649
  node: c
19637
19650
  });
19638
19651
  });
19639
- class $b {
19652
+ class Yb {
19640
19653
  #e;
19641
19654
  constructor() {
19642
19655
  this.#e = /* @__PURE__ */ new Map(), nb(tb, this.#e), this.#e.set("el-default", { raw: oi, node: oe("i") });
@@ -20039,7 +20052,7 @@ class ab {
20039
20052
  }));
20040
20053
  }
20041
20054
  }
20042
- class Kb {
20055
+ class qb {
20043
20056
  #e;
20044
20057
  #t;
20045
20058
  #r;
@@ -20127,10 +20140,10 @@ export {
20127
20140
  Vb as DialogPanel,
20128
20141
  Vp as El,
20129
20142
  Zl as EpComponentFlag,
20130
- Ub as EpComponentParser,
20131
- $b as EpLibrary,
20132
- Hb as EpLibraryUI,
20133
- zb as GeneralLibrary,
20143
+ Xb as EpComponentParser,
20144
+ Yb as EpLibrary,
20145
+ Gb as EpLibraryUI,
20146
+ $b as GeneralLibrary,
20134
20147
  $o as HandleEv,
20135
20148
  _t as KeyCode,
20136
20149
  $t as LightType,
@@ -20139,8 +20152,9 @@ export {
20139
20152
  Ii as Loader,
20140
20153
  gb as ParentView,
20141
20154
  Eh as PropsGeneratorImpl,
20142
- Kb as Provider,
20143
- Fb as Renderer,
20155
+ u as PropsType,
20156
+ qb as Provider,
20157
+ Kb as Renderer,
20144
20158
  gi as ScaleEv,
20145
20159
  mb as ScalePanel,
20146
20160
  Xp as Scene,
@@ -20148,10 +20162,14 @@ export {
20148
20162
  Bb as Spinner,
20149
20163
  Il as Status,
20150
20164
  Nb as ThreePanel,
20165
+ In as ValueType,
20151
20166
  ob as VarState,
20167
+ qn as VarsType,
20152
20168
  Rb as a2r,
20153
20169
  ro as db,
20170
+ fh as defaultProps,
20154
20171
  Np as fetchRemote,
20172
+ Jl as getFinalType,
20155
20173
  ql as getModel,
20156
20174
  Ab as gradientColor,
20157
20175
  Zs as hex2rgb,
@@ -20159,9 +20177,23 @@ export {
20159
20177
  uh as htmlTextLabel,
20160
20178
  Ss as initDragAttr,
20161
20179
  Es as initRect,
20180
+ rh as isColorProps,
20181
+ ih as isEnumProps,
20182
+ lh as isExtendProps,
20183
+ sh as isFunctionProps,
20184
+ ch as isIconProps,
20185
+ ah as isJSONProps,
20186
+ Fb as isPrimitive,
20187
+ Ub as isPrimitiveProps,
20188
+ oh as isTimeProps,
20189
+ zb as isType,
20190
+ Hb as isVueProps,
20191
+ Wl as parseProp,
20192
+ tl as parseProps,
20162
20193
  dh as placeholderNode,
20163
20194
  Ri as placeholderRaw,
20164
20195
  Db as r2a,
20196
+ ph as registerEvents,
20165
20197
  Ib as rgb2Hex,
20166
20198
  kb as useCSS2DRenderer,
20167
20199
  kp as useCollider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolmain/components",
3
- "version": "1.2.14",
3
+ "version": "1.2.15",
4
4
  "description": "Convient components base on vue3",
5
5
  "license": "MIT",
6
6
  "type": "module",