@yongdall/web 0.1.3 → 0.1.4

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/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as dot_request1 from "dot-request";
2
2
  import DotRequest, { default as DotRequest$1 } from "dot-request";
3
- import { ArrayStore, AsyncValidator, AsyncValidator as AsyncValidator$1, ObjectStore, Schema, Schema as Schema$1, Store, Store as Store$1, StoreLayout, StoreLayout as StoreLayout$1, Validator, Validator as Validator$1, renderStore } from "@neeloong/form";
3
+ import { ArrayStore, ObjectStore, Schema, Schema as Schema$1, Store, Store as Store$1, StoreLayout, StoreLayout as StoreLayout$1, renderStore } from "@neeloong/form";
4
4
  import { BootConfiguration, Hook, Indicator, Plugin, Search } from "@yongdall/common";
5
- import { Field, MaybePromise, Permission } from "@yongdall/types";
5
+ import { Field, MaybePromise, Permission, Permissions } from "@yongdall/types";
6
6
  import { Signal as Signal$1 } from "signal-polyfill";
7
7
  export * from "@yongdall/common";
8
8
 
@@ -504,21 +504,21 @@ declare class Page {
504
504
  * @param {AbortSignal} [signal]
505
505
  * @returns
506
506
  */
507
- createHeader(signal?: AbortSignal): PageHeader | null;
507
+ createHeader(signal?: AbortSignal): PageHeader;
508
508
  /**
509
509
  *
510
510
  * @param {AbortSignal} [signal]
511
511
  * @returns
512
512
  */
513
- createFooter(signal?: AbortSignal): PageFooter | null;
513
+ createFooter(signal?: AbortSignal): PageFooter;
514
514
  /**
515
515
  *
516
516
  * @param {'start' | 'end' | 'before' | 'after'} position
517
517
  * @param {boolean} [inserted]
518
518
  * @param {AbortSignal} [signal]
519
- * @returns {PageSection?}
519
+ * @returns {PageSection}
520
520
  */
521
- createSection(position: "start" | "end" | "before" | "after", inserted?: boolean, signal?: AbortSignal): PageSection | null;
521
+ createSection(position: "start" | "end" | "before" | "after", inserted?: boolean, signal?: AbortSignal): PageSection;
522
522
  get signal(): AbortSignal;
523
523
  set siderOpen(open: boolean);
524
524
  get siderOpen(): boolean;
@@ -526,9 +526,9 @@ declare class Page {
526
526
  *
527
527
  * @param {boolean} [inserted]
528
528
  * @param {AbortSignal} [signal]
529
- * @returns {PageSider?}
529
+ * @returns {PageSider}
530
530
  */
531
- createSider(inserted?: boolean, signal?: AbortSignal): PageSider | null;
531
+ createSider(inserted?: boolean, signal?: AbortSignal): PageSider;
532
532
  #private;
533
533
  }
534
534
  //#endregion
@@ -540,25 +540,25 @@ type PageConfiguration = {
540
540
  organization?: string | undefined;
541
541
  workspace?: string | undefined;
542
542
  page?: string | undefined;
543
- widget: string;
544
- title: string;
545
- titlePattern: string;
546
- config: Record<string, any>;
547
- fields: {
543
+ widget?: string | null | undefined;
544
+ title?: string | undefined;
545
+ titlePattern?: string | undefined;
546
+ config?: Record<string, any> | undefined;
547
+ fields?: {
548
548
  field?: string;
549
549
  label?: string;
550
550
  width?: number;
551
551
  pattern?: string;
552
- }[];
553
- sides: {
552
+ }[] | undefined;
553
+ sides?: {
554
554
  widget: string;
555
555
  options: string;
556
- }[];
557
- menuButtons: Menu.Button[];
558
- menus: (Menu | null)[];
559
- forms: Record<string, {
556
+ }[] | undefined;
557
+ menuButtons?: Menu.Button[] | undefined;
558
+ menus?: (Menu | null)[] | undefined;
559
+ forms?: Record<string, {
560
560
  layoutId?: string;
561
- } | null>;
561
+ } | null> | undefined;
562
562
  where?: Search.AndList | undefined;
563
563
  orWhere?: Search.OrList | undefined;
564
564
  defaultQuery?: string | undefined;
@@ -670,9 +670,9 @@ declare namespace PageIdent {
670
670
  * @returns
671
671
  */
672
672
  declare function modelService(model: string): {
673
- then<TResult1 = ModelConfiguration, TResult2 = never>(onfulfilled?: ((value: ModelConfiguration) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
674
- catch<TResult2 = never>(onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<ModelConfiguration | TResult2>;
675
- finally(onfinally?: (() => void) | null | undefined): Promise<ModelConfiguration>;
673
+ then<TResult1 = ModelConfiguration | null, TResult2 = never>(onfulfilled?: ((value: ModelConfiguration | null) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
674
+ catch<TResult2 = never>(onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<ModelConfiguration | TResult2 | null>;
675
+ finally(onfinally?: (() => void) | null | undefined): Promise<ModelConfiguration | null>;
676
676
  /**
677
677
  * @param {Search.Param} [options]
678
678
  * @returns {Promise<{documents: any[]; total: number}>}
@@ -749,22 +749,10 @@ declare function modelService(model: string): {
749
749
  get: () => Promise<any>;
750
750
  };
751
751
  };
752
- loadModel: (force?: boolean) => Promise<ModelConfiguration>;
753
- loadScript: (force?: boolean) => Promise<ModelScriptConfiguration>;
752
+ loadModel: (force?: boolean) => Promise<ModelConfiguration | null>;
753
+ loadScript: (force?: boolean) => Promise<ModelScriptConfiguration | null>;
754
754
  getModel: () => ModelConfiguration | null;
755
755
  getScript: () => ModelScriptConfiguration | null;
756
- page: (page: string, workspace?: string | null) => {
757
- load: (force?: boolean) => Promise<PageConfiguration>;
758
- /**
759
- * @template [TResult1=PageConfiguration]
760
- * @template [TResult2=never]
761
- * @param {((value: PageConfiguration) => TResult1 | PromiseLike<TResult1>)?} [onfulfilled]
762
- * @param {((reason: any) => TResult2 | PromiseLike<TResult2>)?} [onrejected]
763
- * @returns {Promise<TResult1 | TResult2>};
764
- */
765
- then<TResult1 = PageConfiguration, TResult2 = never>(onfulfilled?: ((value: PageConfiguration) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
766
- configuration(): Promise<false | Record<string, any>>;
767
- };
768
756
  };
769
757
  type ModelConfiguration = {
770
758
  id?: string | undefined;
@@ -799,6 +787,10 @@ type ModelConfiguration = {
799
787
  options?: Record<string, unknown> | null | undefined;
800
788
  /**
801
789
  * 关联前端脚本
790
+ */
791
+ scripts?: (string | [string, object])[] | null | undefined;
792
+ /**
793
+ * 关联默认页面
802
794
  * // TODO: 查询配置
803
795
  * // TODO: 前端按钮配置
804
796
  * // TODO: 是否可销毁、可创建、更新、保存、upsert
@@ -807,7 +799,7 @@ type ModelConfiguration = {
807
799
  * // TODO: 操作事件
808
800
  * // TODO: 是否分页
809
801
  */
810
- scripts?: (string | [string, object])[] | null | undefined;
802
+ pages?: Record<string, string | object | null> | null | undefined;
811
803
  };
812
804
  type FieldScriptConfiguration = Omit<Field, "scripts" | "type"> & {
813
805
  script?: Omit<FieldScript, "subFields">;
@@ -868,13 +860,13 @@ type FieldScript = {
868
860
  step?: ((store: Store$1) => string) | null | undefined;
869
861
  max?: ((store: Store$1) => string) | null | undefined;
870
862
  min?: ((store: Store$1) => string) | null | undefined;
871
- validator?: Validator$1 | Validator$1[] | null | undefined;
863
+ validator?: Schema$1.Validator | Schema$1.Validator[] | null | undefined;
872
864
  validators?: {
873
- input?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
874
- change?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
875
- click?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
876
- focus?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
877
- blur?: AsyncValidator$1 | AsyncValidator$1[] | null | undefined;
865
+ input?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
866
+ change?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
867
+ click?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
868
+ focus?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
869
+ blur?: Schema$1.AsyncValidator | Schema$1.AsyncValidator[] | null | undefined;
878
870
  } | undefined;
879
871
  };
880
872
  //#endregion
@@ -1037,9 +1029,13 @@ declare namespace User {
1037
1029
  const session: User | null;
1038
1030
  const target: User | null;
1039
1031
  const current: User | null;
1040
- const permissions: Set<string> | null;
1041
- const organizationPermissions: Record<string, Set<string>> | null;
1042
- const allOrganizationPermissions: Set<string> | null;
1032
+ /** @param {string} permission */
1033
+ function hasPermission(permission: string): boolean;
1034
+ /** @param {string} permission @param {string} [organization] */
1035
+ function hasOrganizationPermission(permission: string, organization?: string): boolean;
1036
+ const permissions: Permissions;
1037
+ const organizationPermissions: Record<string, Permissions>;
1038
+ const allOrganizationPermissions: Permissions;
1043
1039
  const waitLogin: boolean;
1044
1040
  /**
1045
1041
  * @template {Record<string, any>} T
@@ -1161,10 +1157,6 @@ interface FieldStyle {
1161
1157
  /** 是否为设计模式 */
1162
1158
  design?: boolean;
1163
1159
  }
1164
- interface RendererFieldStyle extends FieldStyle {
1165
- /** 是否为编辑模式 */
1166
- editable?: boolean;
1167
- }
1168
1160
  interface FieldShowHandle {
1169
1161
  readonly root: HTMLElement;
1170
1162
  destroy(): void;
@@ -1218,10 +1210,19 @@ interface FormFieldHook {
1218
1210
  filters: Record<string, FieldFilterComponent | [FieldFilterComponent, string?]>;
1219
1211
  }
1220
1212
  declare namespace FromRenderer {
1221
- interface Options extends StoreLayout$1 {}
1213
+ interface Options {
1214
+ model?: ModelScriptConfiguration | null;
1215
+ layout?: StoreLayout$1<any> | null;
1216
+ editable?: boolean;
1217
+ signal?: AbortSignal;
1218
+ /** 是否启用链接 */
1219
+ enableLink?: boolean;
1220
+ /** 是否为设计模式 */
1221
+ design?: boolean;
1222
+ }
1222
1223
  }
1223
1224
  interface FromRenderer {
1224
- render(model: ModelScriptConfiguration, store: Store$1<any, any>, root: HTMLElement, style: RendererFieldStyle, options?: FromRenderer.Options | null): () => void;
1225
+ render(store: Store$1<any, any>, root: HTMLElement, options?: FromRenderer.Options): void;
1225
1226
  }
1226
1227
  interface UserHook {
1227
1228
  permissions(userPlugin: Record<string, any>, user: User): Set<string> | null;
@@ -1324,36 +1325,39 @@ declare class PageContext extends GeneralContext {
1324
1325
  /**
1325
1326
  *
1326
1327
  * @param {AbortSignal} [signal]
1327
- * @returns {PageHeader?}
1328
+ * @returns {PageHeader}
1328
1329
  */
1329
- createHeader(signal?: AbortSignal): PageHeader | null;
1330
+ createHeader(signal?: AbortSignal): PageHeader;
1330
1331
  /**
1331
1332
  *
1332
1333
  * @param {AbortSignal} [signal]
1333
- * @returns {PageFooter?}
1334
+ * @returns {PageFooter}
1334
1335
  */
1335
- createFooter(signal?: AbortSignal): PageFooter | null;
1336
+ createFooter(signal?: AbortSignal): PageFooter;
1336
1337
  /**
1337
1338
  *
1338
1339
  * @param {boolean} [inserted]
1339
1340
  * @param {AbortSignal} [signal]
1340
1341
  * @returns
1341
1342
  */
1342
- createSider(inserted?: boolean, signal?: AbortSignal): PageSider | null;
1343
+ createSider(inserted?: boolean, signal?: AbortSignal): PageSider;
1343
1344
  /**
1344
1345
  *
1345
1346
  * @param {'start' | 'end' | 'before' | 'after'} position
1346
1347
  * @param {boolean} [inserted]
1347
1348
  * @param {AbortSignal} [signal]
1348
- * @returns {PageSection?}
1349
+ * @returns {PageSection}
1349
1350
  */
1350
- createSection(position: "start" | "end" | "before" | "after", inserted?: boolean, signal?: AbortSignal): PageSection | null;
1351
+ createSection(position: "start" | "end" | "before" | "after", inserted?: boolean, signal?: AbortSignal): PageSection;
1351
1352
  /**
1352
1353
  *
1353
- * @param {PageConfiguration['sides']} sides
1354
+ * @param {{widget: string; options: string}[]} sides
1354
1355
  * @param {PageSectionParam} param
1355
1356
  */
1356
- renderSides(sides: PageConfiguration["sides"], param: PageSectionParam): void;
1357
+ renderSides(sides: {
1358
+ widget: string;
1359
+ options: string;
1360
+ }[], param: PageSectionParam): void;
1357
1361
  /**
1358
1362
  * @param {string} url
1359
1363
  * @param {string | PageIdent} [page]
@@ -1525,25 +1529,29 @@ declare function toSchema(fields: Record<string, FieldScriptConfiguration>, comp
1525
1529
  //#region packages/web/form/renderForm.d.mts
1526
1530
  /**
1527
1531
  *
1528
- * @param {ModelConfiguration} model
1529
- * @param {Store} store
1532
+ * @param {Store<any, any>} store
1530
1533
  * @param {HTMLElement} root
1531
- * @param {RendererFieldStyle} style
1532
- * @param {FromRenderer.Options?} [options]
1533
- * @param {string?} [type]
1534
+ * @param {FromRenderer.Options & {type?: string}} [options]
1535
+ * @returns {void}
1534
1536
  */
1535
- declare function _default$1(model: ModelConfiguration, store: Store$1, root: HTMLElement, style: RendererFieldStyle, options?: FromRenderer.Options | null, type?: string | null): () => void;
1537
+ declare function _default$1(store: Store$1<any, any>, root: HTMLElement, options?: FromRenderer.Options & {
1538
+ type?: string;
1539
+ }): void;
1536
1540
  //#endregion
1537
- //#region packages/web/form/renderGridForm.d.mts
1541
+ //#region packages/web/form/renderStoreForm.d.mts
1538
1542
  /**
1539
1543
  *
1540
- * @param {ModelConfiguration} model
1541
- * @param {Store} store
1544
+ * @param {Store<any, any>} store
1542
1545
  * @param {HTMLElement} root
1543
- * @param {RendererFieldStyle} style
1544
- * @param {StoreLayout?} [options]
1546
+ * @param {FromRenderer.Options} [options]
1545
1547
  */
1546
- declare function _default$2(model: ModelConfiguration, store: Store$1, root: HTMLElement, style: RendererFieldStyle, options?: StoreLayout$1 | null): () => void;
1548
+ declare function _default$2(store: Store$1<any, any>, root: HTMLElement, {
1549
+ enableLink,
1550
+ design,
1551
+ layout,
1552
+ editable,
1553
+ signal
1554
+ }?: FromRenderer.Options): void;
1547
1555
  //#endregion
1548
1556
  //#region packages/web/form/createStore.d.mts
1549
1557
  /**
@@ -1601,10 +1609,11 @@ declare function showFilterDialog(modelDefine: ModelScriptConfiguration, value?:
1601
1609
  *
1602
1610
  * @param {Store} store
1603
1611
  * @param {FieldStyle} style
1612
+ * @param {any} [renderer]
1604
1613
  * @param {StoreLayout.Options?} [options]
1605
- * @returns {[HTMLElement, () => void]?}
1614
+ * @returns {HTMLElement?}
1606
1615
  */
1607
- declare function createStoreField(store: Store$1, style: FieldStyle, options?: StoreLayout$1.Options | null): [HTMLElement, () => void] | null;
1616
+ declare function createStoreField(store: Store$1, style: FieldStyle, renderer?: any, options?: StoreLayout$1.Options | null): HTMLElement | null;
1608
1617
  //#endregion
1609
1618
  //#region packages/web/utils/toUrl.d.mts
1610
1619
  /**
@@ -1662,22 +1671,22 @@ declare function formLayoutsService(layout: string): {
1662
1671
  then<TResult1 = {
1663
1672
  layout: any;
1664
1673
  type?: string;
1665
- }, TResult2 = never>(onfulfilled?: ((value: {
1674
+ } | null, TResult2 = never>(onfulfilled?: ((value: {
1666
1675
  layout: any;
1667
1676
  type?: string;
1668
- }) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
1677
+ } | null) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
1669
1678
  catch<TResult2 = never>(onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<{
1670
1679
  layout: any;
1671
1680
  type?: string;
1672
- } | TResult2>;
1681
+ } | TResult2 | null>;
1673
1682
  finally(onfinally?: (() => void) | null | undefined): Promise<{
1674
1683
  layout: any;
1675
1684
  type?: string;
1676
- }>;
1685
+ } | null>;
1677
1686
  load: (force?: boolean) => Promise<{
1678
1687
  layout: any;
1679
1688
  type?: string;
1680
- }>;
1689
+ } | null>;
1681
1690
  get: () => {
1682
1691
  layout: any;
1683
1692
  type?: string;
@@ -2188,4 +2197,4 @@ declare function updateHooks(hooks: Record<string, Hook.Define<Hooks>>): void;
2188
2197
  /** @type {Hook<Hooks>} */
2189
2198
  declare const allHooks: Hook<Hooks>;
2190
2199
  //#endregion
2191
- export { ArrayStore, type AsyncValidator, Authenticator, Command, ConfiguratorComponent, ConfiguratorContext, type ContinuationDefine, DotRequest, FieldComponent, FieldComponentEvent, FieldComponents, FieldContext, FieldDefine, FieldFilterComponent, FieldFilterContext, FieldFilterStyle, type FieldScript, type FieldScriptConfiguration, FieldShowHandle, FieldStyle, FormFieldHook, FromRenderer, GeneralContext, type HomeContext, Hooks, IconDefine, Ident_d_exports as Ident, List, type Match, Menu, type ModelConfiguration, ModelIndicator, type ModelScript, type ModelScriptConfiguration, ObjectStore, Option, Page, type PageContext, type PageError, PageFooter, type PageHandle, PageHeader, type PageIdent, type PageManager, type PageRenderer, PageSection, PageSectionParam, PageSider, Pagination, RendererFieldStyle, ResponseError, type Schema, Signal$1 as Signal, State, Store, type StoreLayout, SubmodelsLayoutEvent, Theme, User, UserHook, type Validator, VerifyContext, VerifyError, type WorkspaceDefine, addManager, allHooks, buildPlugin, configuration, createComputed, createFilters, createIcon, createQuickFilters, createShowField, createState, createStore, createStoreField, effect, enumerationsService, execScript, filterPermission, findConfigurator, formLayoutsService, getAuthorizations, getField, getFieldFilter, getFieldFilterOperators, getPages, getPrimaryFields, hasField, hasFieldFilter, importStyle, importWidget, isPluginId, loadMenu, loadOptions, modelService, neverAbortedSignal, pathRoots, _default as permissionsService, plugins, _default$1 as renderForm, _default$2 as renderGridForm, renderStore, request, root$1 as root, selectFile, setIcon, showFilterDialog, single, start, testPermission, testPermissionConstraints, toFileLink, toFileURL, toId, toSchema, toUrl, updateHooks, userMenus, waitAbortSignal, watch, webRoot };
2200
+ export { ArrayStore, Authenticator, Command, ConfiguratorComponent, ConfiguratorContext, type ContinuationDefine, DotRequest, FieldComponent, FieldComponentEvent, FieldComponents, FieldContext, FieldDefine, FieldFilterComponent, FieldFilterContext, FieldFilterStyle, type FieldScript, type FieldScriptConfiguration, FieldShowHandle, FieldStyle, FormFieldHook, FromRenderer, GeneralContext, type HomeContext, Hooks, IconDefine, Ident_d_exports as Ident, List, type Match, Menu, type ModelConfiguration, ModelIndicator, type ModelScript, type ModelScriptConfiguration, ObjectStore, Option, Page, type PageContext, type PageError, PageFooter, type PageHandle, PageHeader, type PageIdent, type PageManager, type PageRenderer, PageSection, PageSectionParam, PageSider, Pagination, ResponseError, type Schema, Signal$1 as Signal, State, Store, type StoreLayout, SubmodelsLayoutEvent, Theme, User, UserHook, VerifyContext, VerifyError, type WorkspaceDefine, addManager, allHooks, buildPlugin, configuration, createComputed, createFilters, createIcon, createQuickFilters, createShowField, createState, createStore, createStoreField, effect, enumerationsService, execScript, filterPermission, findConfigurator, formLayoutsService, getAuthorizations, getField, getFieldFilter, getFieldFilterOperators, getPages, getPrimaryFields, hasField, hasFieldFilter, importStyle, importWidget, isPluginId, loadMenu, loadOptions, modelService, neverAbortedSignal, pathRoots, _default as permissionsService, plugins, _default$1 as renderForm, renderStore, _default$2 as renderStoreForm, request, root$1 as root, selectFile, setIcon, showFilterDialog, single, start, testPermission, testPermissionConstraints, toFileLink, toFileURL, toId, toSchema, toUrl, updateHooks, userMenus, waitAbortSignal, watch, webRoot };