akanjs 2.3.1 → 2.3.2-rc.1

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/constant/via.ts CHANGED
@@ -129,7 +129,7 @@ const getBaseConstantClass = (field: FieldObject, modelType: ConstantType = "sca
129
129
  static relations: Set<ConstantCls> = new Set();
130
130
  static enums: Set<EnumInstance> = new Set();
131
131
  [immerable] = true;
132
- constructor(obj?: Partial<typeof this>) {
132
+ constructor(obj?: Partial<unknown>) {
133
133
  this.set({
134
134
  ...(this.constructor as ConstantCls).getDefault(),
135
135
  ...((obj ?? {}) as Partial<typeof this>),
package/document/by.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { type Cls, FIELD_META, type MergeAllActionTypes, type UnCls } from "akanjs/base";
1
+ import { type Cls, FIELD_META, type MergeAllActionTypes } from "akanjs/base";
2
2
  import { applyMixins } from "akanjs/common";
3
3
  import {
4
4
  type BaseObject,
5
5
  type ConstantCls,
6
+ type ConstantField,
6
7
  ConstantRegistry,
7
8
  type DocumentModel,
8
9
  type FieldObject,
@@ -22,11 +23,19 @@ type HydratedDocumentWithId<TDocument> = TDocument & { id: string } & DefaultDoc
22
23
  export type Doc<M = any> = HydratedDocumentWithId<DocumentModel<M>>;
23
24
 
24
25
  export const by = <
25
- ModelCls,
26
+ Schema,
27
+ FieldObj extends FieldObject,
26
28
  AddDbModels extends DatabaseCls[],
27
- _DocModel = UnCls<ModelCls> extends BaseObject ? Doc<UnCls<ModelCls>> : DocumentModel<UnCls<ModelCls>>,
29
+ _DatabaseSchema = Schema & {
30
+ [K in keyof FieldObj & keyof Schema as FieldObj[K] extends ConstantField<infer FieldType, any, any, any, any, any>
31
+ ? FieldType extends "hidden"
32
+ ? K
33
+ : never
34
+ : never]: NonNullable<Schema[K]>;
35
+ },
36
+ _DocModel = Schema extends BaseObject ? Doc<_DatabaseSchema> : DocumentModel<_DatabaseSchema>,
28
37
  >(
29
- modelRef: ModelCls,
38
+ modelRef: ConstantCls<Schema, FieldObj>,
30
39
  ...addRefs: AddDbModels
31
40
  ): DatabaseCls<MergeAllActionTypes<AddDbModels, keyof _DocModel & string> & _DocModel> => {
32
41
  const refName = ConstantRegistry.getRefName(modelRef as Cls);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "2.3.1",
3
+ "version": "2.3.2-rc.1",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,5 +1,5 @@
1
- import { type Cls, FIELD_META, type MergeAllActionTypes, type UnCls } from "akanjs/base";
2
- import { type BaseObject, type DocumentModel, type FieldObject } from "akanjs/constant";
1
+ import { type Cls, FIELD_META, type MergeAllActionTypes } from "akanjs/base";
2
+ import { type BaseObject, type ConstantCls, type ConstantField, type DocumentModel, type FieldObject } from "akanjs/constant";
3
3
  export type DatabaseCls<Schema = any> = Cls<Schema, {
4
4
  refName: string;
5
5
  [FIELD_META]: FieldObject;
@@ -16,5 +16,5 @@ type HydratedDocumentWithId<TDocument> = TDocument & {
16
16
  id: string;
17
17
  } & DefaultDocMtds<TDocument>;
18
18
  export type Doc<M = any> = HydratedDocumentWithId<DocumentModel<M>>;
19
- export declare const by: <ModelCls, AddDbModels extends DatabaseCls[], _DocModel = UnCls<ModelCls> extends BaseObject ? Doc<UnCls<ModelCls>> : DocumentModel<UnCls<ModelCls>>>(modelRef: ModelCls, ...addRefs: AddDbModels) => DatabaseCls<MergeAllActionTypes<AddDbModels, keyof _DocModel & string> & _DocModel>;
19
+ export declare const by: <Schema, FieldObj extends FieldObject, AddDbModels extends DatabaseCls[], _DatabaseSchema = Schema & { [K in keyof FieldObj & keyof Schema as FieldObj[K] extends ConstantField<infer FieldType, any, any, any, any, any> ? FieldType extends "hidden" ? K : never : never]: NonNullable<Schema[K]>; }, _DocModel = Schema extends BaseObject ? Doc<_DatabaseSchema> : DocumentModel<_DatabaseSchema>>(modelRef: ConstantCls<Schema, FieldObj>, ...addRefs: AddDbModels) => DatabaseCls<MergeAllActionTypes<AddDbModels, keyof _DocModel & string> & _DocModel>;
20
20
  export {};
package/ui/Field.tsx CHANGED
@@ -1345,10 +1345,7 @@ const ParentId = <T extends string, State, Input, Full extends { id: string }, L
1345
1345
  labelClassName={labelClassName}
1346
1346
  selectClassName={selectClassName}
1347
1347
  value={value}
1348
- options={modelList.map((model) => {
1349
- const label = renderOption?.(model) ?? model.id;
1350
- return { label: typeof label === "string" ? label : model.id, value: model.id };
1351
- })}
1348
+ options={modelList.map((model) => model.id)}
1352
1349
  renderOption={(renderId) => {
1353
1350
  if (!renderId) return null;
1354
1351
  const model = modelList.get(renderId);