sonamu 0.7.53 → 0.8.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.
- package/dist/api/config.d.ts +9 -1
- package/dist/api/config.d.ts.map +1 -1
- package/dist/api/config.js +1 -1
- package/dist/api/sonamu.d.ts +21 -1
- package/dist/api/sonamu.d.ts.map +1 -1
- package/dist/api/sonamu.js +159 -65
- package/dist/auth/plugins/entity-definitions/anonymous.d.ts +10 -0
- package/dist/auth/plugins/entity-definitions/anonymous.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/anonymous.js +23 -0
- package/dist/auth/plugins/entity-definitions/api-key.d.ts +9 -0
- package/dist/auth/plugins/entity-definitions/api-key.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/api-key.js +199 -0
- package/dist/auth/plugins/entity-definitions/index.d.ts +6 -0
- package/dist/auth/plugins/entity-definitions/index.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/index.js +20 -2
- package/dist/auth/plugins/entity-definitions/jwt.d.ts +9 -0
- package/dist/auth/plugins/entity-definitions/jwt.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/jwt.js +67 -0
- package/dist/auth/plugins/entity-definitions/organization.d.ts +9 -0
- package/dist/auth/plugins/entity-definitions/organization.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/organization.js +424 -0
- package/dist/auth/plugins/entity-definitions/passkey.d.ts +10 -0
- package/dist/auth/plugins/entity-definitions/passkey.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/passkey.js +129 -0
- package/dist/auth/plugins/entity-definitions/sso.d.ts +10 -0
- package/dist/auth/plugins/entity-definitions/sso.d.ts.map +1 -0
- package/dist/auth/plugins/entity-definitions/sso.js +110 -0
- package/dist/auth/plugins/entity-definitions/types.d.ts +1 -1
- package/dist/auth/plugins/entity-definitions/types.d.ts.map +1 -1
- package/dist/auth/plugins/entity-definitions/types.js +1 -1
- package/dist/auth/plugins/wrappers/admin.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/admin.js +2 -4
- package/dist/auth/plugins/wrappers/anonymous.d.ts +18 -0
- package/dist/auth/plugins/wrappers/anonymous.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/anonymous.js +26 -0
- package/dist/auth/plugins/wrappers/api-key.d.ts +18 -0
- package/dist/auth/plugins/wrappers/api-key.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/api-key.js +38 -0
- package/dist/auth/plugins/wrappers/index.d.ts +6 -0
- package/dist/auth/plugins/wrappers/index.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/index.js +7 -1
- package/dist/auth/plugins/wrappers/jwt.d.ts +18 -0
- package/dist/auth/plugins/wrappers/jwt.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/jwt.js +30 -0
- package/dist/auth/plugins/wrappers/organization.d.ts +18 -0
- package/dist/auth/plugins/wrappers/organization.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/organization.js +67 -0
- package/dist/auth/plugins/wrappers/passkey.d.ts +18 -0
- package/dist/auth/plugins/wrappers/passkey.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/passkey.js +32 -0
- package/dist/auth/plugins/wrappers/phone-number.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/phone-number.js +2 -4
- package/dist/auth/plugins/wrappers/sso.d.ts +853 -0
- package/dist/auth/plugins/wrappers/sso.d.ts.map +1 -0
- package/dist/auth/plugins/wrappers/sso.js +36 -0
- package/dist/auth/plugins/wrappers/two-factor.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/two-factor.js +2 -4
- package/dist/auth/plugins/wrappers/username.d.ts.map +1 -1
- package/dist/auth/plugins/wrappers/username.js +2 -4
- package/dist/bin/build-config.d.ts +2 -2
- package/dist/bin/build-config.js +6 -7
- package/dist/bin/cli.js +417 -32
- package/dist/bin/fixture.d.ts +27 -0
- package/dist/bin/fixture.d.ts.map +1 -0
- package/dist/bin/fixture.js +245 -0
- package/dist/cache/decorator.d.ts +4 -3
- package/dist/cache/decorator.d.ts.map +1 -1
- package/dist/cache/decorator.js +5 -4
- package/dist/cone/cone-generator.d.ts +33 -0
- package/dist/cone/cone-generator.d.ts.map +1 -0
- package/dist/cone/cone-generator.js +286 -0
- package/dist/database/_batch_update.d.ts.map +1 -1
- package/dist/database/_batch_update.js +16 -2
- package/dist/database/puri-subset.test-d.js +1 -1
- package/dist/database/puri-subset.types.d.ts +1 -1
- package/dist/database/puri-subset.types.d.ts.map +1 -1
- package/dist/database/puri-subset.types.js +1 -1
- package/dist/database/puri.d.ts +4 -0
- package/dist/database/puri.d.ts.map +1 -1
- package/dist/database/puri.js +20 -2
- package/dist/database/upsert-builder.d.ts.map +1 -1
- package/dist/database/upsert-builder.js +19 -3
- package/dist/dict/en.d.ts +15 -0
- package/dist/dict/en.d.ts.map +1 -1
- package/dist/dict/en.js +2 -1
- package/dist/dict/ko.d.ts +15 -0
- package/dist/dict/ko.d.ts.map +1 -1
- package/dist/dict/ko.js +2 -1
- package/dist/dict/rc-keys.d.ts +28 -0
- package/dist/dict/rc-keys.d.ts.map +1 -1
- package/dist/dict/rc-keys.js +31 -1
- package/dist/dict/sd.d.ts.map +1 -1
- package/dist/dict/sd.js +20 -4
- package/dist/entity/entity-manager.d.ts +298 -2
- package/dist/entity/entity-manager.d.ts.map +1 -1
- package/dist/entity/entity-manager.js +4 -1
- package/dist/entity/entity-template-cone.d.ts +14 -0
- package/dist/entity/entity-template-cone.d.ts.map +1 -0
- package/dist/entity/entity-template-cone.js +222 -0
- package/dist/entity/entity.d.ts +47 -2
- package/dist/entity/entity.d.ts.map +1 -1
- package/dist/entity/entity.js +161 -14
- package/dist/ssr/renderer.js +3 -3
- package/dist/syncer/api-parser.js +12 -1
- package/dist/syncer/checksum.d.ts +0 -14
- package/dist/syncer/checksum.d.ts.map +1 -1
- package/dist/syncer/checksum.js +1 -23
- package/dist/syncer/syncer-actions.d.ts.map +1 -1
- package/dist/syncer/syncer-actions.js +8 -2
- package/dist/syncer/syncer.d.ts +1 -1
- package/dist/syncer/syncer.d.ts.map +1 -1
- package/dist/syncer/syncer.js +17 -10
- package/dist/tasks/workflow-manager.d.ts +13 -1
- package/dist/tasks/workflow-manager.d.ts.map +1 -1
- package/dist/tasks/workflow-manager.js +18 -1
- package/dist/template/entity-converter.js +4 -4
- package/dist/template/helpers.d.ts +10 -0
- package/dist/template/helpers.d.ts.map +1 -1
- package/dist/template/helpers.js +48 -1
- package/dist/template/implementations/entry-server.template.d.ts +1 -1
- package/dist/template/implementations/entry-server.template.js +7 -2
- package/dist/template/implementations/generated.template.d.ts.map +1 -1
- package/dist/template/implementations/generated.template.js +5 -1
- package/dist/template/implementations/generated_http.template.d.ts +1 -0
- package/dist/template/implementations/generated_http.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_http.template.js +6 -2
- package/dist/template/implementations/generated_sso.template.d.ts.map +1 -1
- package/dist/template/implementations/generated_sso.template.js +29 -8
- package/dist/template/implementations/queries.template.d.ts.map +1 -1
- package/dist/template/implementations/queries.template.js +9 -1
- package/dist/template/implementations/sd.template.d.ts +1 -1
- package/dist/template/implementations/sd.template.d.ts.map +1 -1
- package/dist/template/implementations/sd.template.js +28 -4
- package/dist/template/implementations/services.template.d.ts.map +1 -1
- package/dist/template/implementations/services.template.js +12 -12
- package/dist/template/implementations/view_form.template.d.ts +11 -7
- package/dist/template/implementations/view_form.template.d.ts.map +1 -1
- package/dist/template/implementations/view_form.template.js +97 -87
- package/dist/template/implementations/view_list.template.d.ts +3 -3
- package/dist/template/implementations/view_list.template.d.ts.map +1 -1
- package/dist/template/implementations/view_list.template.js +115 -109
- package/dist/template/implementations/view_search_input.template.d.ts.map +1 -1
- package/dist/template/implementations/view_search_input.template.js +18 -14
- package/dist/template/zod-converter.d.ts.map +1 -1
- package/dist/template/zod-converter.js +95 -7
- package/dist/testing/_relation-graph.js +1 -1
- package/dist/testing/data-explorer.d.ts +61 -0
- package/dist/testing/data-explorer.d.ts.map +1 -0
- package/dist/testing/data-explorer.js +274 -0
- package/dist/testing/faker-mappings.d.ts +20 -0
- package/dist/testing/faker-mappings.d.ts.map +1 -0
- package/dist/testing/faker-mappings.js +421 -0
- package/dist/testing/fixture-generator.d.ts +161 -0
- package/dist/testing/fixture-generator.d.ts.map +1 -0
- package/dist/testing/fixture-generator.js +954 -0
- package/dist/testing/fixture-manager.d.ts +6 -1
- package/dist/testing/fixture-manager.d.ts.map +1 -1
- package/dist/testing/fixture-manager.js +72 -4
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +4 -1
- package/dist/types/types.d.ts +1520 -26
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js +136 -22
- package/dist/ui/ai-client.d.ts.map +1 -1
- package/dist/ui/ai-client.js +9 -4
- package/dist/ui/api.d.ts.map +1 -1
- package/dist/ui/api.js +303 -24
- package/dist/ui-web/assets/index-CsUr-_pV.js +254 -0
- package/dist/ui-web/assets/index-T42zzs1K.css +1 -0
- package/dist/ui-web/index.html +2 -2
- package/dist/utils/fs-utils.d.ts +2 -1
- package/dist/utils/fs-utils.d.ts.map +1 -1
- package/dist/utils/fs-utils.js +14 -3
- package/package.json +19 -11
- package/src/api/config.ts +12 -1
- package/src/api/sonamu.ts +179 -65
- package/src/auth/plugins/entity-definitions/anonymous.ts +17 -0
- package/src/auth/plugins/entity-definitions/api-key.ts +93 -0
- package/src/auth/plugins/entity-definitions/index.ts +18 -0
- package/src/auth/plugins/entity-definitions/jwt.ts +35 -0
- package/src/auth/plugins/entity-definitions/organization.ts +215 -0
- package/src/auth/plugins/entity-definitions/passkey.ts +64 -0
- package/src/auth/plugins/entity-definitions/sso.ts +62 -0
- package/src/auth/plugins/entity-definitions/types.ts +11 -1
- package/src/auth/plugins/wrappers/admin.ts +1 -3
- package/src/auth/plugins/wrappers/anonymous.ts +30 -0
- package/src/auth/plugins/wrappers/api-key.ts +42 -0
- package/src/auth/plugins/wrappers/index.ts +6 -0
- package/src/auth/plugins/wrappers/jwt.ts +34 -0
- package/src/auth/plugins/wrappers/organization.ts +73 -0
- package/src/auth/plugins/wrappers/passkey.ts +36 -0
- package/src/auth/plugins/wrappers/phone-number.ts +1 -3
- package/src/auth/plugins/wrappers/sso.ts +40 -0
- package/src/auth/plugins/wrappers/two-factor.ts +1 -3
- package/src/auth/plugins/wrappers/username.ts +1 -3
- package/src/bin/build-config.ts +6 -6
- package/src/bin/cli.ts +452 -31
- package/src/bin/fixture.ts +302 -0
- package/src/cache/decorator.ts +4 -3
- package/src/cone/cone-generator.ts +363 -0
- package/src/database/_batch_update.ts +11 -0
- package/src/database/puri-subset.test-d.ts +13 -13
- package/src/database/puri-subset.types.ts +1 -1
- package/src/database/puri.ts +43 -1
- package/src/database/upsert-builder.ts +16 -2
- package/src/dict/en.ts +1 -0
- package/src/dict/ko.ts +1 -0
- package/src/dict/rc-keys.ts +32 -0
- package/src/dict/sd.ts +23 -3
- package/src/entity/entity-manager.ts +4 -0
- package/src/entity/entity-template-cone.ts +298 -0
- package/src/entity/entity.ts +189 -13
- package/src/shared/app.shared.ts.txt +5 -0
- package/src/shared/web.shared.ts.txt +9 -5
- package/src/skills/project/README.md +21 -0
- package/src/skills/project/architecture.md +373 -0
- package/src/skills/project/business-logic.md +270 -0
- package/src/skills/project/requirements.md +160 -0
- package/src/skills/sonamu/SKILL.md +168 -3
- package/src/skills/sonamu/api.md +102 -0
- package/src/skills/sonamu/database.md +220 -1
- package/src/skills/sonamu/entity-relations.md +89 -1
- package/src/skills/sonamu/fixture-cli.md +501 -0
- package/src/skills/sonamu/frontend.md +214 -0
- package/src/skills/sonamu/i18n.md +95 -0
- package/src/skills/sonamu/model.md +153 -0
- package/src/skills/sonamu/project-init.md +178 -8
- package/src/skills/sonamu/scaffolding.md +112 -0
- package/src/skills/sonamu/subset.md +9 -3
- package/src/skills/sonamu/testing.md +287 -2
- package/src/skills/sonamu/workflow.md +70 -5
- package/src/ssr/renderer.ts +2 -2
- package/src/syncer/api-parser.ts +12 -0
- package/src/syncer/checksum.ts +0 -38
- package/src/syncer/syncer-actions.ts +7 -1
- package/src/syncer/syncer.ts +16 -5
- package/src/tasks/workflow-manager.ts +29 -8
- package/src/template/entity-converter.ts +3 -3
- package/src/template/helpers.ts +49 -0
- package/src/template/implementations/entry-server.template.ts +1 -1
- package/src/template/implementations/generated.template.ts +4 -0
- package/src/template/implementations/generated_http.template.ts +1 -0
- package/src/template/implementations/generated_sso.template.ts +40 -11
- package/src/template/implementations/queries.template.ts +8 -0
- package/src/template/implementations/sd.template.ts +22 -3
- package/src/template/implementations/services.template.ts +11 -10
- package/src/template/implementations/view_form.template.ts +111 -101
- package/src/template/implementations/view_list.template.ts +120 -119
- package/src/template/implementations/view_search_input.template.ts +17 -13
- package/src/template/zod-converter.ts +103 -6
- package/src/testing/_relation-graph.ts +1 -1
- package/src/testing/data-explorer.ts +427 -0
- package/src/testing/faker-mappings.ts +434 -0
- package/src/testing/fixture-generator.ts +1166 -0
- package/src/testing/fixture-manager.ts +91 -6
- package/src/testing/index.ts +3 -0
- package/src/types/types.ts +222 -26
- package/src/ui/ai-client.ts +9 -1
- package/src/ui/api.ts +429 -23
- package/src/utils/fs-utils.ts +14 -1
- package/dist/template/implementations/view_enums_select.template.d.ts +0 -17
- package/dist/template/implementations/view_enums_select.template.d.ts.map +0 -1
- package/dist/template/implementations/view_enums_select.template.js +0 -62
- package/dist/template/implementations/view_id_async_select.template.d.ts +0 -17
- package/dist/template/implementations/view_id_async_select.template.d.ts.map +0 -1
- package/dist/template/implementations/view_id_async_select.template.js +0 -125
- package/dist/ui-web/assets/index-Bd_2AkLb.css +0 -1
- package/dist/ui-web/assets/index-BpSbhQWo.js +0 -225
- package/src/template/implementations/view_enums_select.template.ts +0 -65
- package/src/template/implementations/view_id_async_select.template.ts +0 -139
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
2
|
-
import type { TemplateOptions } from "../../types/types";
|
|
3
|
-
import { getLabel } from "../helpers";
|
|
4
|
-
import { Template } from "../template";
|
|
5
|
-
|
|
6
|
-
export class Template__view_enums_select extends Template {
|
|
7
|
-
constructor() {
|
|
8
|
-
super("view_enums_select");
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
getTargetAndPath(names: EntityNamesRecord, enumId: string) {
|
|
12
|
-
return {
|
|
13
|
-
target: "web/src/components",
|
|
14
|
-
path: `${names.fs}/${enumId}Select.tsx`,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async render({ entityId, enumId }: TemplateOptions["view_enums_select"]) {
|
|
19
|
-
const names = EntityManager.getNamesFromId(entityId);
|
|
20
|
-
const label = getLabel(entityId, enumId);
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
...this.getTargetAndPath(names, enumId),
|
|
24
|
-
body: `
|
|
25
|
-
import { EnumSelect } from '@sonamu-kit/react-components/components';
|
|
26
|
-
import { ${enumId}, ${enumId}Label } from '@/services/sonamu.generated';
|
|
27
|
-
|
|
28
|
-
export type ${enumId}SelectProps = {
|
|
29
|
-
value?: string;
|
|
30
|
-
onValueChange?: (value: string | null | undefined) => void;
|
|
31
|
-
placeholder?: string;
|
|
32
|
-
textPrefix?: string;
|
|
33
|
-
clearable?: boolean;
|
|
34
|
-
disabled?: boolean;
|
|
35
|
-
className?: string;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export function ${enumId}Select({
|
|
39
|
-
value,
|
|
40
|
-
onValueChange,
|
|
41
|
-
placeholder,
|
|
42
|
-
textPrefix,
|
|
43
|
-
clearable,
|
|
44
|
-
disabled,
|
|
45
|
-
className,
|
|
46
|
-
}: ${enumId}SelectProps) {
|
|
47
|
-
return (
|
|
48
|
-
<EnumSelect
|
|
49
|
-
enum={${enumId}}
|
|
50
|
-
labels={${enumId}Label}
|
|
51
|
-
value={value}
|
|
52
|
-
onValueChange={onValueChange}
|
|
53
|
-
placeholder={placeholder ?? "${label}"}
|
|
54
|
-
textPrefix={textPrefix}
|
|
55
|
-
clearable={clearable}
|
|
56
|
-
disabled={disabled}
|
|
57
|
-
className={className}
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
`.trim(),
|
|
62
|
-
importKeys: [],
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { EntityManager, type EntityNamesRecord } from "../../entity/entity-manager";
|
|
2
|
-
import type { TemplateOptions } from "../../types/types";
|
|
3
|
-
import { Template } from "../template";
|
|
4
|
-
|
|
5
|
-
export class Template__view_id_async_select extends Template {
|
|
6
|
-
constructor() {
|
|
7
|
-
super("view_id_async_select");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
getTargetAndPath(names: EntityNamesRecord) {
|
|
11
|
-
return {
|
|
12
|
-
target: "web/src/components",
|
|
13
|
-
path: `${names.fs}/${names.capital}IdAsyncSelect.tsx`,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
render({ entityId, textField }: TemplateOptions["view_id_async_select"]) {
|
|
18
|
-
const names = EntityManager.getNamesFromId(entityId);
|
|
19
|
-
|
|
20
|
-
const entity = EntityManager.get(entityId);
|
|
21
|
-
|
|
22
|
-
// PK 타입 감지
|
|
23
|
-
const pkType = entity.getPkType();
|
|
24
|
-
const idTsType = pkType === "string" || pkType === "uuid" ? "string" : "number";
|
|
25
|
-
|
|
26
|
-
// textField가 지정되지 않은 경우 모든 subset에 공통으로 있는 필드 찾기
|
|
27
|
-
if (!textField) {
|
|
28
|
-
const subsetKeys = Object.keys(entity.subsets);
|
|
29
|
-
if (subsetKeys.length > 0) {
|
|
30
|
-
// 모든 subset에 공통으로 포함된 직접 필드만 추출
|
|
31
|
-
const commonFields = subsetKeys.reduce(
|
|
32
|
-
(common, key) => {
|
|
33
|
-
const fields = entity.subsets[key]
|
|
34
|
-
.filter((path) => !path.includes(".")) // 직접 필드만
|
|
35
|
-
.map((path) => path);
|
|
36
|
-
return common.filter((field) => fields.includes(field));
|
|
37
|
-
},
|
|
38
|
-
entity.subsets[subsetKeys[0]].filter((path) => !path.includes(".")),
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
// 우선순위: name > title > 첫 번째 string 타입
|
|
42
|
-
const pickedProp = entity.props.find(
|
|
43
|
-
(prop) => ["name", "title"].includes(prop.name) && commonFields.includes(prop.name),
|
|
44
|
-
);
|
|
45
|
-
if (pickedProp) {
|
|
46
|
-
textField = pickedProp.name;
|
|
47
|
-
} else {
|
|
48
|
-
const candidateProp = entity.props.find(
|
|
49
|
-
(prop) => prop.type === "string" && commonFields.includes(prop.name),
|
|
50
|
-
);
|
|
51
|
-
if (candidateProp) {
|
|
52
|
-
textField = candidateProp.name;
|
|
53
|
-
} else {
|
|
54
|
-
// 공통 필드가 없으면 id 사용
|
|
55
|
-
textField = "id";
|
|
56
|
-
console.log(
|
|
57
|
-
`Warning: ${entityId}에 모든 subset에 공통으로 포함된 string 필드가 없어 id를 사용합니다`,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return {
|
|
65
|
-
...this.getTargetAndPath(names),
|
|
66
|
-
body: `
|
|
67
|
-
import { IdAsyncSelect } from "@sonamu-kit/react-components/components";
|
|
68
|
-
import { useCallback, useState } from "react";
|
|
69
|
-
import { ${names.capital}AsyncIdConfig } from "@/services/services.generated";
|
|
70
|
-
import type {
|
|
71
|
-
${names.capital}SearchField,
|
|
72
|
-
${names.capital}SubsetKey,
|
|
73
|
-
${names.capital}SubsetMapping,
|
|
74
|
-
} from "@/services/sonamu.generated";
|
|
75
|
-
import type { ${names.capital}ListParams } from "@/services/${names.fs}/${names.fs}.types";
|
|
76
|
-
|
|
77
|
-
export type ${names.capital}IdAsyncSelectProps<T extends ${names.capital}SubsetKey> = {
|
|
78
|
-
subset: T;
|
|
79
|
-
baseListParams?: ${names.capital}ListParams;
|
|
80
|
-
textField?: keyof ${names.capital}SubsetMapping[T] & string;
|
|
81
|
-
valueField?: keyof ${names.capital}SubsetMapping[T] & string;
|
|
82
|
-
placeholder?: string;
|
|
83
|
-
clearable?: boolean;
|
|
84
|
-
disabled?: boolean;
|
|
85
|
-
className?: string;
|
|
86
|
-
multiple?: boolean;
|
|
87
|
-
value?: ${idTsType} | ${idTsType}[] | null;
|
|
88
|
-
onValueChange?: (value: ${idTsType} | ${idTsType}[] | undefined) => void;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export function ${names.capital}IdAsyncSelect<T extends ${names.capital}SubsetKey>({
|
|
92
|
-
subset,
|
|
93
|
-
value,
|
|
94
|
-
onValueChange,
|
|
95
|
-
baseListParams,
|
|
96
|
-
textField = "${textField || "id"}",
|
|
97
|
-
valueField = "id",
|
|
98
|
-
placeholder = "${entity.title ?? names.constant}",
|
|
99
|
-
clearable,
|
|
100
|
-
disabled,
|
|
101
|
-
className,
|
|
102
|
-
multiple = false,
|
|
103
|
-
}: ${names.capital}IdAsyncSelectProps<T>) {
|
|
104
|
-
const [listParams, setListParams] = useState<${names.capital}ListParams>(baseListParams ?? {});
|
|
105
|
-
|
|
106
|
-
const handleSearch = useCallback(
|
|
107
|
-
(keyword: string) => {
|
|
108
|
-
setListParams((prev) => ({
|
|
109
|
-
...prev,
|
|
110
|
-
search: keyword ? (textField as ${names.capital}SearchField) : undefined,
|
|
111
|
-
keyword: keyword || undefined,
|
|
112
|
-
}));
|
|
113
|
-
},
|
|
114
|
-
[textField],
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<IdAsyncSelect
|
|
119
|
-
config={${names.capital}AsyncIdConfig}
|
|
120
|
-
subset={subset}
|
|
121
|
-
listParams={listParams}
|
|
122
|
-
textField={textField}
|
|
123
|
-
valueField={valueField}
|
|
124
|
-
placeholder={placeholder}
|
|
125
|
-
clearable={clearable}
|
|
126
|
-
disabled={disabled}
|
|
127
|
-
className={className}
|
|
128
|
-
multiple={multiple}
|
|
129
|
-
value={value}
|
|
130
|
-
onValueChange={onValueChange}
|
|
131
|
-
onSearch={handleSearch}
|
|
132
|
-
/>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
`.trim(),
|
|
136
|
-
importKeys: [],
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
}
|