@fgv/ts-res-ui-components 5.0.0-10
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/.rush/temp/03c8b056281d9db0a97d8a6e25eea798a160d393.tar.log +271 -0
- package/.rush/temp/chunked-rush-logs/ts-res-ui-components.build.chunks.jsonl +9 -0
- package/.rush/temp/operation/build/all.log +9 -0
- package/.rush/temp/operation/build/log-chunks.jsonl +9 -0
- package/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +1111 -0
- package/README.md +18 -0
- package/REFACTORING_PLAN.md +171 -0
- package/config/jest.config.json +16 -0
- package/config/jest.setup.js +64 -0
- package/config/rig.json +16 -0
- package/lib/components/common/QualifierContextControl.d.ts +14 -0
- package/lib/components/common/QualifierContextControl.d.ts.map +1 -0
- package/lib/components/common/QualifierContextControl.js +78 -0
- package/lib/components/common/QualifierContextControl.js.map +1 -0
- package/lib/components/common/ResourceListView.d.ts +11 -0
- package/lib/components/common/ResourceListView.d.ts.map +1 -0
- package/lib/components/common/ResourceListView.js +20 -0
- package/lib/components/common/ResourceListView.js.map +1 -0
- package/lib/components/common/ResourceTreeView.d.ts +12 -0
- package/lib/components/common/ResourceTreeView.d.ts.map +1 -0
- package/lib/components/common/ResourceTreeView.js +162 -0
- package/lib/components/common/ResourceTreeView.js.map +1 -0
- package/lib/components/forms/HierarchyEditor.d.ts +10 -0
- package/lib/components/forms/HierarchyEditor.d.ts.map +1 -0
- package/lib/components/forms/HierarchyEditor.js +106 -0
- package/lib/components/forms/HierarchyEditor.js.map +1 -0
- package/lib/components/forms/QualifierEditForm.d.ts +11 -0
- package/lib/components/forms/QualifierEditForm.d.ts.map +1 -0
- package/lib/components/forms/QualifierEditForm.js +181 -0
- package/lib/components/forms/QualifierEditForm.js.map +1 -0
- package/lib/components/forms/QualifierTypeEditForm.d.ts +10 -0
- package/lib/components/forms/QualifierTypeEditForm.d.ts.map +1 -0
- package/lib/components/forms/QualifierTypeEditForm.js +172 -0
- package/lib/components/forms/QualifierTypeEditForm.js.map +1 -0
- package/lib/components/forms/ResourceTypeEditForm.d.ts +10 -0
- package/lib/components/forms/ResourceTypeEditForm.d.ts.map +1 -0
- package/lib/components/forms/ResourceTypeEditForm.js +188 -0
- package/lib/components/forms/ResourceTypeEditForm.js.map +1 -0
- package/lib/components/forms/index.d.ts +9 -0
- package/lib/components/forms/index.d.ts.map +1 -0
- package/lib/components/forms/index.js +5 -0
- package/lib/components/forms/index.js.map +1 -0
- package/lib/components/orchestrator/ResourceOrchestrator.d.ts +14 -0
- package/lib/components/orchestrator/ResourceOrchestrator.d.ts.map +1 -0
- package/lib/components/orchestrator/ResourceOrchestrator.js +278 -0
- package/lib/components/orchestrator/ResourceOrchestrator.js.map +1 -0
- package/lib/components/views/CompiledView/index.d.ts +5 -0
- package/lib/components/views/CompiledView/index.d.ts.map +1 -0
- package/lib/components/views/CompiledView/index.js +595 -0
- package/lib/components/views/CompiledView/index.js.map +1 -0
- package/lib/components/views/ConfigurationView/index.d.ts +5 -0
- package/lib/components/views/ConfigurationView/index.d.ts.map +1 -0
- package/lib/components/views/ConfigurationView/index.js +363 -0
- package/lib/components/views/ConfigurationView/index.js.map +1 -0
- package/lib/components/views/FilterView/index.d.ts +5 -0
- package/lib/components/views/FilterView/index.d.ts.map +1 -0
- package/lib/components/views/FilterView/index.js +463 -0
- package/lib/components/views/FilterView/index.js.map +1 -0
- package/lib/components/views/ImportView/index.d.ts +5 -0
- package/lib/components/views/ImportView/index.d.ts.map +1 -0
- package/lib/components/views/ImportView/index.js +514 -0
- package/lib/components/views/ImportView/index.js.map +1 -0
- package/lib/components/views/ResolutionView/EditableJsonView.d.ts +21 -0
- package/lib/components/views/ResolutionView/EditableJsonView.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/EditableJsonView.js +109 -0
- package/lib/components/views/ResolutionView/EditableJsonView.js.map +1 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.d.ts +19 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.js +82 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.js.map +1 -0
- package/lib/components/views/ResolutionView/index.d.ts +5 -0
- package/lib/components/views/ResolutionView/index.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/index.js +255 -0
- package/lib/components/views/ResolutionView/index.js.map +1 -0
- package/lib/components/views/SourceView/index.d.ts +5 -0
- package/lib/components/views/SourceView/index.d.ts.map +1 -0
- package/lib/components/views/SourceView/index.js +316 -0
- package/lib/components/views/SourceView/index.js.map +1 -0
- package/lib/components/views/ZipLoaderView/index.d.ts +5 -0
- package/lib/components/views/ZipLoaderView/index.d.ts.map +1 -0
- package/lib/components/views/ZipLoaderView/index.js +313 -0
- package/lib/components/views/ZipLoaderView/index.js.map +1 -0
- package/lib/hooks/useConfigurationState.d.ts +46 -0
- package/lib/hooks/useConfigurationState.d.ts.map +1 -0
- package/lib/hooks/useConfigurationState.js +239 -0
- package/lib/hooks/useConfigurationState.js.map +1 -0
- package/lib/hooks/useFilterState.d.ts +7 -0
- package/lib/hooks/useFilterState.d.ts.map +1 -0
- package/lib/hooks/useFilterState.js +80 -0
- package/lib/hooks/useFilterState.js.map +1 -0
- package/lib/hooks/useResolutionState.d.ts +8 -0
- package/lib/hooks/useResolutionState.d.ts.map +1 -0
- package/lib/hooks/useResolutionState.js +253 -0
- package/lib/hooks/useResolutionState.js.map +1 -0
- package/lib/hooks/useResourceData.d.ts +19 -0
- package/lib/hooks/useResourceData.d.ts.map +1 -0
- package/lib/hooks/useResourceData.js +368 -0
- package/lib/hooks/useResourceData.js.map +1 -0
- package/lib/hooks/useViewState.d.ts +10 -0
- package/lib/hooks/useViewState.d.ts.map +1 -0
- package/lib/hooks/useViewState.js +29 -0
- package/lib/hooks/useViewState.js.map +1 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +34 -0
- package/lib/index.js.map +1 -0
- package/lib/test/helpers/testDataLoader.d.ts +37 -0
- package/lib/test/helpers/testDataLoader.d.ts.map +1 -0
- package/lib/test/helpers/testDataLoader.js +171 -0
- package/lib/test/helpers/testDataLoader.js.map +1 -0
- package/lib/test/unit/utils/configurationUtils.test.d.ts +2 -0
- package/lib/test/unit/utils/configurationUtils.test.d.ts.map +1 -0
- package/lib/test/unit/utils/configurationUtils.test.js +497 -0
- package/lib/test/unit/utils/configurationUtils.test.js.map +1 -0
- package/lib/test/unit/utils/fileProcessing.test.d.ts +2 -0
- package/lib/test/unit/utils/fileProcessing.test.d.ts.map +1 -0
- package/lib/test/unit/utils/fileProcessing.test.js +321 -0
- package/lib/test/unit/utils/fileProcessing.test.js.map +1 -0
- package/lib/test/unit/utils/filterResources.test.d.ts +2 -0
- package/lib/test/unit/utils/filterResources.test.d.ts.map +1 -0
- package/lib/test/unit/utils/filterResources.test.js +403 -0
- package/lib/test/unit/utils/filterResources.test.js.map +1 -0
- package/lib/test/unit/utils/resolutionEditing.test.d.ts +2 -0
- package/lib/test/unit/utils/resolutionEditing.test.d.ts.map +1 -0
- package/lib/test/unit/utils/resolutionEditing.test.js +439 -0
- package/lib/test/unit/utils/resolutionEditing.test.js.map +1 -0
- package/lib/test/unit/utils/resolutionUtils.test.d.ts +2 -0
- package/lib/test/unit/utils/resolutionUtils.test.d.ts.map +1 -0
- package/lib/test/unit/utils/resolutionUtils.test.js +397 -0
- package/lib/test/unit/utils/resolutionUtils.test.js.map +1 -0
- package/lib/test/unit/utils/tsResIntegration.test.d.ts +2 -0
- package/lib/test/unit/utils/tsResIntegration.test.d.ts.map +1 -0
- package/lib/test/unit/utils/tsResIntegration.test.js +376 -0
- package/lib/test/unit/utils/tsResIntegration.test.js.map +1 -0
- package/lib/types/index.d.ts +251 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -0
- package/lib/utils/configurationUtils.d.ts +74 -0
- package/lib/utils/configurationUtils.d.ts.map +1 -0
- package/lib/utils/configurationUtils.js +359 -0
- package/lib/utils/configurationUtils.js.map +1 -0
- package/lib/utils/fileProcessing.d.ts +18 -0
- package/lib/utils/fileProcessing.d.ts.map +1 -0
- package/lib/utils/fileProcessing.js +142 -0
- package/lib/utils/fileProcessing.js.map +1 -0
- package/lib/utils/filterResources.d.ts +38 -0
- package/lib/utils/filterResources.d.ts.map +1 -0
- package/lib/utils/filterResources.js +153 -0
- package/lib/utils/filterResources.js.map +1 -0
- package/lib/utils/resolutionEditing.d.ts +58 -0
- package/lib/utils/resolutionEditing.d.ts.map +1 -0
- package/lib/utils/resolutionEditing.js +246 -0
- package/lib/utils/resolutionEditing.js.map +1 -0
- package/lib/utils/resolutionUtils.d.ts +28 -0
- package/lib/utils/resolutionUtils.d.ts.map +1 -0
- package/lib/utils/resolutionUtils.js +216 -0
- package/lib/utils/resolutionUtils.js.map +1 -0
- package/lib/utils/tsResIntegration.d.ts +71 -0
- package/lib/utils/tsResIntegration.d.ts.map +1 -0
- package/lib/utils/tsResIntegration.js +294 -0
- package/lib/utils/tsResIntegration.js.map +1 -0
- package/lib/utils/zipLoader/browserZipLoader.d.ts +48 -0
- package/lib/utils/zipLoader/browserZipLoader.d.ts.map +1 -0
- package/lib/utils/zipLoader/browserZipLoader.js +247 -0
- package/lib/utils/zipLoader/browserZipLoader.js.map +1 -0
- package/lib/utils/zipLoader/index.d.ts +8 -0
- package/lib/utils/zipLoader/index.d.ts.map +1 -0
- package/lib/utils/zipLoader/index.js +13 -0
- package/lib/utils/zipLoader/index.js.map +1 -0
- package/lib/utils/zipLoader/nodeZipBuilder.d.ts +55 -0
- package/lib/utils/zipLoader/nodeZipBuilder.d.ts.map +1 -0
- package/lib/utils/zipLoader/nodeZipBuilder.js +98 -0
- package/lib/utils/zipLoader/nodeZipBuilder.js.map +1 -0
- package/lib/utils/zipLoader/types.d.ts +139 -0
- package/lib/utils/zipLoader/types.d.ts.map +1 -0
- package/lib/utils/zipLoader/types.js +2 -0
- package/lib/utils/zipLoader/types.js.map +1 -0
- package/lib/utils/zipLoader/zipUtils.d.ts +53 -0
- package/lib/utils/zipLoader/zipUtils.d.ts.map +1 -0
- package/lib/utils/zipLoader/zipUtils.js +229 -0
- package/lib/utils/zipLoader/zipUtils.js.map +1 -0
- package/package.json +69 -0
- package/rush-logs/ts-res-ui-components.build.cache.log +3 -0
- package/rush-logs/ts-res-ui-components.build.log +9 -0
- package/src/components/common/QualifierContextControl.tsx +151 -0
- package/src/components/common/ResourceListView.tsx +63 -0
- package/src/components/common/ResourceTreeView.tsx +271 -0
- package/src/components/forms/HierarchyEditor.tsx +204 -0
- package/src/components/forms/QualifierEditForm.tsx +355 -0
- package/src/components/forms/QualifierTypeEditForm.tsx +347 -0
- package/src/components/forms/ResourceTypeEditForm.tsx +331 -0
- package/src/components/forms/index.ts +11 -0
- package/src/components/orchestrator/ResourceOrchestrator.tsx +372 -0
- package/src/components/views/CompiledView/index.tsx +922 -0
- package/src/components/views/ConfigurationView/index.tsx +800 -0
- package/src/components/views/FilterView/index.tsx +825 -0
- package/src/components/views/ImportView/index.tsx +717 -0
- package/src/components/views/ResolutionView/EditableJsonView.tsx +214 -0
- package/src/components/views/ResolutionView/ResolutionEditControls.tsx +170 -0
- package/src/components/views/ResolutionView/index.tsx +591 -0
- package/src/components/views/SourceView/index.tsx +536 -0
- package/src/components/views/ZipLoaderView/index.tsx +485 -0
- package/src/hooks/useConfigurationState.ts +374 -0
- package/src/hooks/useFilterState.ts +97 -0
- package/src/hooks/useResolutionState.ts +355 -0
- package/src/hooks/useResourceData.ts +467 -0
- package/src/hooks/useViewState.ts +44 -0
- package/src/index.ts +45 -0
- package/src/test/helpers/testDataLoader.ts +195 -0
- package/src/test/unit/utils/configurationUtils.test.ts +630 -0
- package/src/test/unit/utils/fileProcessing.test.ts +391 -0
- package/src/test/unit/utils/filterResources.test.ts +574 -0
- package/src/test/unit/utils/resolutionEditing.test.ts +556 -0
- package/src/test/unit/utils/resolutionUtils.test.ts +521 -0
- package/src/test/unit/utils/tsResIntegration.test.ts +433 -0
- package/src/types/index.ts +322 -0
- package/src/utils/configurationUtils.ts +424 -0
- package/src/utils/fileProcessing.ts +160 -0
- package/src/utils/filterResources.ts +206 -0
- package/src/utils/resolutionEditing.ts +319 -0
- package/src/utils/resolutionUtils.ts +289 -0
- package/src/utils/tsResIntegration.ts +440 -0
- package/src/utils/zipLoader/browserZipLoader.ts +319 -0
- package/src/utils/zipLoader/index.ts +26 -0
- package/src/utils/zipLoader/nodeZipBuilder.ts +153 -0
- package/src/utils/zipLoader/types.ts +175 -0
- package/src/utils/zipLoader/zipUtils.ts +266 -0
- package/temp/build/typescript/ts_gZid87Hu.json +1 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import React, { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import { XMarkIcon, InformationCircleIcon } from '@heroicons/react/24/outline';
|
|
3
|
+
import { QualifierTypes } from '@fgv/ts-res';
|
|
4
|
+
import { HierarchyEditor } from './HierarchyEditor';
|
|
5
|
+
|
|
6
|
+
export interface QualifierTypeEditFormProps {
|
|
7
|
+
qualifierType?: QualifierTypes.Config.ISystemQualifierTypeConfig;
|
|
8
|
+
onSave: (qualifierType: QualifierTypes.Config.ISystemQualifierTypeConfig) => void;
|
|
9
|
+
onCancel: () => void;
|
|
10
|
+
existingNames?: string[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface FormData {
|
|
14
|
+
name: string;
|
|
15
|
+
systemType: 'language' | 'territory' | 'literal';
|
|
16
|
+
allowContextList: boolean;
|
|
17
|
+
// Literal type specific
|
|
18
|
+
caseSensitive: boolean;
|
|
19
|
+
enumeratedValues: string[];
|
|
20
|
+
// Territory type specific
|
|
21
|
+
acceptLowercase: boolean;
|
|
22
|
+
allowedTerritories: string[];
|
|
23
|
+
// Hierarchy support (for literal and territory types)
|
|
24
|
+
hierarchy: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const QualifierTypeEditForm: React.FC<QualifierTypeEditFormProps> = ({
|
|
28
|
+
qualifierType,
|
|
29
|
+
onSave,
|
|
30
|
+
onCancel,
|
|
31
|
+
existingNames = []
|
|
32
|
+
}) => {
|
|
33
|
+
const [formData, setFormData] = useState<FormData>(() => {
|
|
34
|
+
if (qualifierType) {
|
|
35
|
+
const config = qualifierType.configuration || {};
|
|
36
|
+
// Ensure hierarchy is a plain object with string values
|
|
37
|
+
let hierarchy: Record<string, string> = {};
|
|
38
|
+
const rawHierarchy = (config as any)?.hierarchy;
|
|
39
|
+
if (rawHierarchy && typeof rawHierarchy === 'object' && !Array.isArray(rawHierarchy)) {
|
|
40
|
+
for (const [key, value] of Object.entries(rawHierarchy)) {
|
|
41
|
+
if (typeof value === 'string') {
|
|
42
|
+
hierarchy[key] = value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
name: qualifierType.name,
|
|
49
|
+
systemType: qualifierType.systemType as 'language' | 'territory' | 'literal',
|
|
50
|
+
allowContextList: (config as any)?.allowContextList ?? false,
|
|
51
|
+
caseSensitive: (config as any)?.caseSensitive ?? true,
|
|
52
|
+
enumeratedValues: (config as any)?.enumeratedValues || [],
|
|
53
|
+
acceptLowercase: (config as any)?.acceptLowercase ?? false,
|
|
54
|
+
allowedTerritories: (config as any)?.allowedTerritories || [],
|
|
55
|
+
hierarchy: hierarchy
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
name: '',
|
|
60
|
+
systemType: 'literal',
|
|
61
|
+
allowContextList: false,
|
|
62
|
+
caseSensitive: true,
|
|
63
|
+
enumeratedValues: [],
|
|
64
|
+
acceptLowercase: false,
|
|
65
|
+
allowedTerritories: [],
|
|
66
|
+
hierarchy: {}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const [errors, setErrors] = useState<Record<string, string>>({});
|
|
71
|
+
const [enumeratedValuesText, setEnumeratedValuesText] = useState(formData.enumeratedValues.join(', '));
|
|
72
|
+
const [allowedTerritoriesText, setAllowedTerritoriesText] = useState(
|
|
73
|
+
formData.allowedTerritories.join(', ')
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// Validation
|
|
77
|
+
const validateForm = useCallback((): boolean => {
|
|
78
|
+
const newErrors: Record<string, string> = {};
|
|
79
|
+
|
|
80
|
+
if (!formData.name.trim()) {
|
|
81
|
+
newErrors.name = 'Name is required';
|
|
82
|
+
} else if (existingNames.includes(formData.name) && formData.name !== qualifierType?.name) {
|
|
83
|
+
newErrors.name = 'Name must be unique';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (formData.systemType === 'literal' && formData.enumeratedValues.length === 0) {
|
|
87
|
+
newErrors.enumeratedValues = 'Literal types should have enumerated values';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setErrors(newErrors);
|
|
91
|
+
return Object.keys(newErrors).length === 0;
|
|
92
|
+
}, [formData, existingNames, qualifierType?.name]);
|
|
93
|
+
|
|
94
|
+
// Update enumerated values when text changes
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const values = enumeratedValuesText
|
|
97
|
+
.split(',')
|
|
98
|
+
.map((v) => v.trim())
|
|
99
|
+
.filter((v) => v.length > 0);
|
|
100
|
+
setFormData((prev) => ({ ...prev, enumeratedValues: values }));
|
|
101
|
+
}, [enumeratedValuesText]);
|
|
102
|
+
|
|
103
|
+
// Update allowed territories when text changes
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const territories = allowedTerritoriesText
|
|
106
|
+
.split(',')
|
|
107
|
+
.map((v) => v.trim().toUpperCase())
|
|
108
|
+
.filter((v) => v.length > 0);
|
|
109
|
+
setFormData((prev) => ({ ...prev, allowedTerritories: territories }));
|
|
110
|
+
}, [allowedTerritoriesText]);
|
|
111
|
+
|
|
112
|
+
const handleSave = useCallback(() => {
|
|
113
|
+
if (!validateForm()) return;
|
|
114
|
+
|
|
115
|
+
let configuration: any = {
|
|
116
|
+
allowContextList: formData.allowContextList
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
switch (formData.systemType) {
|
|
120
|
+
case 'literal':
|
|
121
|
+
configuration = {
|
|
122
|
+
...configuration,
|
|
123
|
+
caseSensitive: formData.caseSensitive,
|
|
124
|
+
enumeratedValues: formData.enumeratedValues.length > 0 ? formData.enumeratedValues : undefined
|
|
125
|
+
};
|
|
126
|
+
// Add hierarchy if it has entries
|
|
127
|
+
if (Object.keys(formData.hierarchy).length > 0) {
|
|
128
|
+
configuration.hierarchy = formData.hierarchy;
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case 'territory':
|
|
132
|
+
configuration = {
|
|
133
|
+
...configuration,
|
|
134
|
+
acceptLowercase: formData.acceptLowercase,
|
|
135
|
+
allowedTerritories: formData.allowedTerritories.length > 0 ? formData.allowedTerritories : undefined
|
|
136
|
+
};
|
|
137
|
+
// Add hierarchy if it has entries
|
|
138
|
+
if (Object.keys(formData.hierarchy).length > 0) {
|
|
139
|
+
configuration.hierarchy = formData.hierarchy;
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
case 'language':
|
|
143
|
+
// Language types only have allowContextList
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const result: QualifierTypes.Config.ISystemQualifierTypeConfig = {
|
|
148
|
+
name: formData.name,
|
|
149
|
+
systemType: formData.systemType,
|
|
150
|
+
configuration: Object.keys(configuration).length > 1 ? configuration : undefined
|
|
151
|
+
} as any;
|
|
152
|
+
|
|
153
|
+
onSave(result);
|
|
154
|
+
}, [formData, validateForm, onSave]);
|
|
155
|
+
|
|
156
|
+
const updateField = useCallback(
|
|
157
|
+
(field: keyof FormData, value: any) => {
|
|
158
|
+
setFormData((prev) => ({ ...prev, [field]: value }));
|
|
159
|
+
if (errors[field]) {
|
|
160
|
+
setErrors((prev) => ({ ...prev, [field]: '' }));
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
[errors]
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div className="fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50 p-4">
|
|
168
|
+
<div className="bg-white rounded-lg shadow-xl max-w-2xl w-full h-full max-h-[calc(100vh-2rem)] flex flex-col">
|
|
169
|
+
{/* Fixed Header */}
|
|
170
|
+
<div className="flex items-center justify-between p-6 border-b flex-shrink-0">
|
|
171
|
+
<h3 className="text-lg font-medium text-gray-900">
|
|
172
|
+
{qualifierType ? 'Edit Qualifier Type' : 'Add Qualifier Type'}
|
|
173
|
+
</h3>
|
|
174
|
+
<button onClick={onCancel} className="text-gray-400 hover:text-gray-600">
|
|
175
|
+
<XMarkIcon className="w-6 h-6" />
|
|
176
|
+
</button>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
{/* Scrollable Content */}
|
|
180
|
+
<div className="p-6 space-y-6 overflow-y-auto flex-1 min-h-0">
|
|
181
|
+
{/* Basic Properties */}
|
|
182
|
+
<div className="grid grid-cols-2 gap-4">
|
|
183
|
+
<div>
|
|
184
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">Name *</label>
|
|
185
|
+
<input
|
|
186
|
+
type="text"
|
|
187
|
+
value={formData.name}
|
|
188
|
+
onChange={(e) => updateField('name', e.target.value)}
|
|
189
|
+
className={`w-full px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${
|
|
190
|
+
errors.name ? 'border-red-300' : 'border-gray-300'
|
|
191
|
+
}`}
|
|
192
|
+
placeholder="Enter qualifier type name"
|
|
193
|
+
/>
|
|
194
|
+
{errors.name && <p className="mt-1 text-sm text-red-600">{errors.name}</p>}
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
<div>
|
|
198
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">System Type *</label>
|
|
199
|
+
<select
|
|
200
|
+
value={formData.systemType}
|
|
201
|
+
onChange={(e) =>
|
|
202
|
+
updateField('systemType', e.target.value as 'language' | 'territory' | 'literal')
|
|
203
|
+
}
|
|
204
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500"
|
|
205
|
+
>
|
|
206
|
+
<option value="literal">Literal</option>
|
|
207
|
+
<option value="language">Language</option>
|
|
208
|
+
<option value="territory">Territory</option>
|
|
209
|
+
</select>
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
{/* Allow Context List */}
|
|
214
|
+
<div className="flex items-center">
|
|
215
|
+
<input
|
|
216
|
+
type="checkbox"
|
|
217
|
+
id="allowContextList"
|
|
218
|
+
checked={formData.allowContextList}
|
|
219
|
+
onChange={(e) => updateField('allowContextList', e.target.checked)}
|
|
220
|
+
className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"
|
|
221
|
+
/>
|
|
222
|
+
<label htmlFor="allowContextList" className="ml-2 text-sm text-gray-700">
|
|
223
|
+
Allow Context List
|
|
224
|
+
</label>
|
|
225
|
+
<div className="ml-2 group relative">
|
|
226
|
+
<InformationCircleIcon className="w-4 h-4 text-gray-400" />
|
|
227
|
+
<div className="absolute left-0 bottom-6 hidden group-hover:block bg-gray-800 text-white text-xs rounded py-1 px-2 whitespace-nowrap">
|
|
228
|
+
Allow multiple values separated by commas
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
{/* Literal Type Specific */}
|
|
234
|
+
{formData.systemType === 'literal' && (
|
|
235
|
+
<div className="space-y-4 p-4 bg-blue-50 rounded-lg">
|
|
236
|
+
<h4 className="font-medium text-gray-900">Literal Type Configuration</h4>
|
|
237
|
+
|
|
238
|
+
<div className="flex items-center">
|
|
239
|
+
<input
|
|
240
|
+
type="checkbox"
|
|
241
|
+
id="caseSensitive"
|
|
242
|
+
checked={formData.caseSensitive}
|
|
243
|
+
onChange={(e) => updateField('caseSensitive', e.target.checked)}
|
|
244
|
+
className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"
|
|
245
|
+
/>
|
|
246
|
+
<label htmlFor="caseSensitive" className="ml-2 text-sm text-gray-700">
|
|
247
|
+
Case Sensitive
|
|
248
|
+
</label>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<div>
|
|
252
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">Enumerated Values</label>
|
|
253
|
+
<textarea
|
|
254
|
+
value={enumeratedValuesText}
|
|
255
|
+
onChange={(e) => setEnumeratedValuesText(e.target.value)}
|
|
256
|
+
className={`w-full px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${
|
|
257
|
+
errors.enumeratedValues ? 'border-red-300' : 'border-gray-300'
|
|
258
|
+
}`}
|
|
259
|
+
rows={3}
|
|
260
|
+
placeholder="Enter values separated by commas (e.g., dev, test, prod)"
|
|
261
|
+
/>
|
|
262
|
+
{errors.enumeratedValues && (
|
|
263
|
+
<p className="mt-1 text-sm text-red-600">{errors.enumeratedValues}</p>
|
|
264
|
+
)}
|
|
265
|
+
<p className="mt-1 text-xs text-gray-500">Separate multiple values with commas</p>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
)}
|
|
269
|
+
|
|
270
|
+
{/* Territory Type Specific */}
|
|
271
|
+
{formData.systemType === 'territory' && (
|
|
272
|
+
<div className="space-y-4 p-4 bg-green-50 rounded-lg">
|
|
273
|
+
<h4 className="font-medium text-gray-900">Territory Type Configuration</h4>
|
|
274
|
+
|
|
275
|
+
<div className="flex items-center">
|
|
276
|
+
<input
|
|
277
|
+
type="checkbox"
|
|
278
|
+
id="acceptLowercase"
|
|
279
|
+
checked={formData.acceptLowercase}
|
|
280
|
+
onChange={(e) => updateField('acceptLowercase', e.target.checked)}
|
|
281
|
+
className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"
|
|
282
|
+
/>
|
|
283
|
+
<label htmlFor="acceptLowercase" className="ml-2 text-sm text-gray-700">
|
|
284
|
+
Accept Lowercase Territory Codes
|
|
285
|
+
</label>
|
|
286
|
+
</div>
|
|
287
|
+
|
|
288
|
+
<div>
|
|
289
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">Allowed Territories</label>
|
|
290
|
+
<textarea
|
|
291
|
+
value={allowedTerritoriesText}
|
|
292
|
+
onChange={(e) => setAllowedTerritoriesText(e.target.value)}
|
|
293
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500"
|
|
294
|
+
rows={3}
|
|
295
|
+
placeholder="Enter territory codes separated by commas (e.g., US, CA, GB)"
|
|
296
|
+
/>
|
|
297
|
+
<p className="mt-1 text-xs text-gray-500">
|
|
298
|
+
Separate multiple territory codes with commas. Will be automatically converted to uppercase.
|
|
299
|
+
</p>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
)}
|
|
303
|
+
|
|
304
|
+
{/* Hierarchy Editor for Literal and Territory Types */}
|
|
305
|
+
{(formData.systemType === 'literal' || formData.systemType === 'territory') && (
|
|
306
|
+
<div className="space-y-4">
|
|
307
|
+
<HierarchyEditor
|
|
308
|
+
hierarchy={formData.hierarchy}
|
|
309
|
+
onChange={(hierarchy) => updateField('hierarchy', hierarchy)}
|
|
310
|
+
availableValues={
|
|
311
|
+
formData.systemType === 'literal' ? formData.enumeratedValues : formData.allowedTerritories
|
|
312
|
+
}
|
|
313
|
+
/>
|
|
314
|
+
</div>
|
|
315
|
+
)}
|
|
316
|
+
|
|
317
|
+
{/* Language Type Specific */}
|
|
318
|
+
{formData.systemType === 'language' && (
|
|
319
|
+
<div className="p-4 bg-yellow-50 rounded-lg">
|
|
320
|
+
<h4 className="font-medium text-gray-900">Language Type Configuration</h4>
|
|
321
|
+
<p className="text-sm text-gray-600 mt-2">
|
|
322
|
+
Language qualifier types use BCP47 language tags and only support the "Allow Context List"
|
|
323
|
+
option above.
|
|
324
|
+
</p>
|
|
325
|
+
</div>
|
|
326
|
+
)}
|
|
327
|
+
</div>
|
|
328
|
+
|
|
329
|
+
{/* Fixed Footer */}
|
|
330
|
+
<div className="flex justify-end space-x-3 px-6 py-4 border-t bg-gray-50 flex-shrink-0">
|
|
331
|
+
<button
|
|
332
|
+
onClick={onCancel}
|
|
333
|
+
className="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
|
334
|
+
>
|
|
335
|
+
Cancel
|
|
336
|
+
</button>
|
|
337
|
+
<button
|
|
338
|
+
onClick={handleSave}
|
|
339
|
+
className="px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
|
340
|
+
>
|
|
341
|
+
{qualifierType ? 'Save Changes' : 'Add Qualifier Type'}
|
|
342
|
+
</button>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
</div>
|
|
346
|
+
);
|
|
347
|
+
};
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
|
+
import { XMarkIcon, InformationCircleIcon } from '@heroicons/react/24/outline';
|
|
3
|
+
import { ResourceTypes } from '@fgv/ts-res';
|
|
4
|
+
|
|
5
|
+
export interface ResourceTypeEditFormProps {
|
|
6
|
+
resourceType?: ResourceTypes.Config.IResourceTypeConfig;
|
|
7
|
+
onSave: (resourceType: ResourceTypes.Config.IResourceTypeConfig) => void;
|
|
8
|
+
onCancel: () => void;
|
|
9
|
+
existingNames?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface FormData {
|
|
13
|
+
name: string;
|
|
14
|
+
typeName: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const COMMON_TYPE_NAMES = [
|
|
18
|
+
'string',
|
|
19
|
+
'object',
|
|
20
|
+
'array',
|
|
21
|
+
'number',
|
|
22
|
+
'boolean',
|
|
23
|
+
'localizedString',
|
|
24
|
+
'config',
|
|
25
|
+
'settings',
|
|
26
|
+
'permissions',
|
|
27
|
+
'template',
|
|
28
|
+
'content',
|
|
29
|
+
'metadata'
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
export const ResourceTypeEditForm: React.FC<ResourceTypeEditFormProps> = ({
|
|
33
|
+
resourceType,
|
|
34
|
+
onSave,
|
|
35
|
+
onCancel,
|
|
36
|
+
existingNames = []
|
|
37
|
+
}) => {
|
|
38
|
+
const [formData, setFormData] = useState<FormData>(() => {
|
|
39
|
+
if (resourceType) {
|
|
40
|
+
return {
|
|
41
|
+
name: resourceType.name,
|
|
42
|
+
typeName: resourceType.typeName
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
name: '',
|
|
47
|
+
typeName: 'string'
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const [errors, setErrors] = useState<Record<string, string>>({});
|
|
52
|
+
const [useCustomTypeName, setUseCustomTypeName] = useState(() => {
|
|
53
|
+
if (resourceType) {
|
|
54
|
+
return !COMMON_TYPE_NAMES.includes(resourceType.typeName);
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Validation
|
|
60
|
+
const validateForm = useCallback((): boolean => {
|
|
61
|
+
const newErrors: Record<string, string> = {};
|
|
62
|
+
|
|
63
|
+
if (!formData.name.trim()) {
|
|
64
|
+
newErrors.name = 'Name is required';
|
|
65
|
+
} else if (existingNames.includes(formData.name) && formData.name !== resourceType?.name) {
|
|
66
|
+
newErrors.name = 'Name must be unique';
|
|
67
|
+
} else if (!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(formData.name)) {
|
|
68
|
+
newErrors.name = 'Name must start with a letter and contain only letters, numbers, and underscores';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!formData.typeName.trim()) {
|
|
72
|
+
newErrors.typeName = 'Type name is required';
|
|
73
|
+
} else if (!/^[a-zA-Z][a-zA-Z0-9_]*$/.test(formData.typeName)) {
|
|
74
|
+
newErrors.typeName =
|
|
75
|
+
'Type name must start with a letter and contain only letters, numbers, and underscores';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
setErrors(newErrors);
|
|
79
|
+
return Object.keys(newErrors).length === 0;
|
|
80
|
+
}, [formData, existingNames, resourceType?.name]);
|
|
81
|
+
|
|
82
|
+
const handleSave = useCallback(() => {
|
|
83
|
+
if (!validateForm()) return;
|
|
84
|
+
|
|
85
|
+
const result: ResourceTypes.Config.IResourceTypeConfig = {
|
|
86
|
+
name: formData.name,
|
|
87
|
+
typeName: formData.typeName
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
onSave(result);
|
|
91
|
+
}, [formData, validateForm, onSave]);
|
|
92
|
+
|
|
93
|
+
const updateField = useCallback(
|
|
94
|
+
(field: keyof FormData, value: any) => {
|
|
95
|
+
setFormData((prev) => {
|
|
96
|
+
const updated = { ...prev, [field]: value };
|
|
97
|
+
|
|
98
|
+
// Auto-generate typeName from name for new resource types if using common types
|
|
99
|
+
if (field === 'name' && !resourceType && !useCustomTypeName) {
|
|
100
|
+
const cleanName = value.toLowerCase().replace(/[^a-zA-Z0-9]/g, '');
|
|
101
|
+
const commonType = COMMON_TYPE_NAMES.find(
|
|
102
|
+
(type) => cleanName.includes(type) || type.includes(cleanName)
|
|
103
|
+
);
|
|
104
|
+
if (commonType) {
|
|
105
|
+
updated.typeName = commonType;
|
|
106
|
+
} else {
|
|
107
|
+
updated.typeName = cleanName || 'string';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return updated;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (errors[field]) {
|
|
115
|
+
setErrors((prev) => ({ ...prev, [field]: '' }));
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
[errors, resourceType, useCustomTypeName]
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const handleTypeNameModeChange = useCallback(
|
|
122
|
+
(useCustom: boolean) => {
|
|
123
|
+
setUseCustomTypeName(useCustom);
|
|
124
|
+
if (!useCustom && !resourceType) {
|
|
125
|
+
// Reset to a common type
|
|
126
|
+
updateField('typeName', 'string');
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
[resourceType, updateField]
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const getTypeNameDescription = (typeName: string): string => {
|
|
133
|
+
switch (typeName) {
|
|
134
|
+
case 'string':
|
|
135
|
+
return 'Simple text content (default)';
|
|
136
|
+
case 'object':
|
|
137
|
+
return 'Complex structured data (JSON objects)';
|
|
138
|
+
case 'array':
|
|
139
|
+
return 'List of values or objects';
|
|
140
|
+
case 'number':
|
|
141
|
+
return 'Numeric values';
|
|
142
|
+
case 'boolean':
|
|
143
|
+
return 'True/false values';
|
|
144
|
+
case 'localizedString':
|
|
145
|
+
return 'Text content with localization support';
|
|
146
|
+
case 'config':
|
|
147
|
+
return 'Configuration settings and parameters';
|
|
148
|
+
case 'settings':
|
|
149
|
+
return 'User or application settings';
|
|
150
|
+
case 'permissions':
|
|
151
|
+
return 'Access control and permission data';
|
|
152
|
+
case 'template':
|
|
153
|
+
return 'Template content for rendering';
|
|
154
|
+
case 'content':
|
|
155
|
+
return 'Rich content (HTML, Markdown, etc.)';
|
|
156
|
+
case 'metadata':
|
|
157
|
+
return 'Descriptive information about resources';
|
|
158
|
+
default:
|
|
159
|
+
return 'Custom resource type';
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<div className="fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-50 p-4">
|
|
165
|
+
<div className="bg-white rounded-lg shadow-xl max-w-2xl w-full h-full max-h-[calc(100vh-2rem)] flex flex-col">
|
|
166
|
+
{/* Fixed Header */}
|
|
167
|
+
<div className="flex items-center justify-between p-6 border-b flex-shrink-0">
|
|
168
|
+
<h3 className="text-lg font-medium text-gray-900">
|
|
169
|
+
{resourceType ? 'Edit Resource Type' : 'Add Resource Type'}
|
|
170
|
+
</h3>
|
|
171
|
+
<button onClick={onCancel} className="text-gray-400 hover:text-gray-600">
|
|
172
|
+
<XMarkIcon className="w-6 h-6" />
|
|
173
|
+
</button>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
{/* Scrollable Content */}
|
|
177
|
+
<div className="p-6 space-y-6 overflow-y-auto flex-1 min-h-0">
|
|
178
|
+
{/* Basic Properties */}
|
|
179
|
+
<div>
|
|
180
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">Name *</label>
|
|
181
|
+
<input
|
|
182
|
+
type="text"
|
|
183
|
+
value={formData.name}
|
|
184
|
+
onChange={(e) => updateField('name', e.target.value)}
|
|
185
|
+
className={`w-full px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${
|
|
186
|
+
errors.name ? 'border-red-300' : 'border-gray-300'
|
|
187
|
+
}`}
|
|
188
|
+
placeholder="Enter resource type name (e.g., 'userSettings', 'errorMessages')"
|
|
189
|
+
/>
|
|
190
|
+
{errors.name && <p className="mt-1 text-sm text-red-600">{errors.name}</p>}
|
|
191
|
+
<p className="mt-1 text-xs text-gray-500">
|
|
192
|
+
A descriptive name for this type of resource. This will be used to categorize and identify
|
|
193
|
+
resources.
|
|
194
|
+
</p>
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
{/* Type Name Configuration */}
|
|
198
|
+
<div>
|
|
199
|
+
<label className="block text-sm font-medium text-gray-700 mb-3">Type Name Configuration *</label>
|
|
200
|
+
|
|
201
|
+
<div className="space-y-3">
|
|
202
|
+
<div className="flex items-center">
|
|
203
|
+
<input
|
|
204
|
+
type="radio"
|
|
205
|
+
id="useCommonType"
|
|
206
|
+
name="typeNameMode"
|
|
207
|
+
checked={!useCustomTypeName}
|
|
208
|
+
onChange={() => handleTypeNameModeChange(false)}
|
|
209
|
+
className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300"
|
|
210
|
+
/>
|
|
211
|
+
<label htmlFor="useCommonType" className="ml-2 text-sm text-gray-700">
|
|
212
|
+
Use common type name
|
|
213
|
+
</label>
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
{!useCustomTypeName && (
|
|
217
|
+
<div className="ml-6">
|
|
218
|
+
<select
|
|
219
|
+
value={formData.typeName}
|
|
220
|
+
onChange={(e) => updateField('typeName', e.target.value)}
|
|
221
|
+
className={`w-full px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${
|
|
222
|
+
errors.typeName ? 'border-red-300' : 'border-gray-300'
|
|
223
|
+
}`}
|
|
224
|
+
>
|
|
225
|
+
{COMMON_TYPE_NAMES.map((type) => (
|
|
226
|
+
<option key={type} value={type}>
|
|
227
|
+
{type}
|
|
228
|
+
</option>
|
|
229
|
+
))}
|
|
230
|
+
</select>
|
|
231
|
+
<p className="mt-1 text-xs text-gray-600">{getTypeNameDescription(formData.typeName)}</p>
|
|
232
|
+
</div>
|
|
233
|
+
)}
|
|
234
|
+
|
|
235
|
+
<div className="flex items-center">
|
|
236
|
+
<input
|
|
237
|
+
type="radio"
|
|
238
|
+
id="useCustomType"
|
|
239
|
+
name="typeNameMode"
|
|
240
|
+
checked={useCustomTypeName}
|
|
241
|
+
onChange={() => handleTypeNameModeChange(true)}
|
|
242
|
+
className="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300"
|
|
243
|
+
/>
|
|
244
|
+
<label htmlFor="useCustomType" className="ml-2 text-sm text-gray-700">
|
|
245
|
+
Define custom type name
|
|
246
|
+
</label>
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
{useCustomTypeName && (
|
|
250
|
+
<div className="ml-6">
|
|
251
|
+
<input
|
|
252
|
+
type="text"
|
|
253
|
+
value={formData.typeName}
|
|
254
|
+
onChange={(e) => updateField('typeName', e.target.value)}
|
|
255
|
+
className={`w-full px-3 py-2 border rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500 ${
|
|
256
|
+
errors.typeName ? 'border-red-300' : 'border-gray-300'
|
|
257
|
+
}`}
|
|
258
|
+
placeholder="Enter custom type name"
|
|
259
|
+
/>
|
|
260
|
+
<p className="mt-1 text-xs text-gray-500">
|
|
261
|
+
Define a custom type name for specialized resource handling
|
|
262
|
+
</p>
|
|
263
|
+
</div>
|
|
264
|
+
)}
|
|
265
|
+
</div>
|
|
266
|
+
|
|
267
|
+
{errors.typeName && <p className="mt-1 text-sm text-red-600">{errors.typeName}</p>}
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
{/* Information Panel */}
|
|
271
|
+
<div className="p-4 bg-blue-50 rounded-lg">
|
|
272
|
+
<div className="flex items-start">
|
|
273
|
+
<InformationCircleIcon className="w-5 h-5 text-blue-400 mt-0.5 mr-3 flex-shrink-0" />
|
|
274
|
+
<div className="text-sm text-blue-800">
|
|
275
|
+
<h4 className="font-medium mb-2">About Resource Types</h4>
|
|
276
|
+
<div className="space-y-2">
|
|
277
|
+
<p>
|
|
278
|
+
Resource types define how resources are categorized and processed in your application.
|
|
279
|
+
</p>
|
|
280
|
+
<ul className="list-disc list-inside space-y-1 ml-2">
|
|
281
|
+
<li>
|
|
282
|
+
<strong>Name:</strong> A human-readable identifier for grouping resources
|
|
283
|
+
</li>
|
|
284
|
+
<li>
|
|
285
|
+
<strong>Type Name:</strong> Determines how the resource data is interpreted and
|
|
286
|
+
validated
|
|
287
|
+
</li>
|
|
288
|
+
<li>Common types (string, object, array) provide built-in processing</li>
|
|
289
|
+
<li>Custom types allow specialized handling for domain-specific data</li>
|
|
290
|
+
</ul>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
|
|
296
|
+
{/* Preview */}
|
|
297
|
+
<div className="p-4 bg-gray-50 rounded-lg">
|
|
298
|
+
<h4 className="font-medium text-gray-900 mb-2">Preview</h4>
|
|
299
|
+
<div className="text-sm text-gray-600">
|
|
300
|
+
<p>
|
|
301
|
+
<span className="font-medium">Resource Type:</span> {formData.name || '(name not set)'}
|
|
302
|
+
</p>
|
|
303
|
+
<p>
|
|
304
|
+
<span className="font-medium">Type Name:</span> {formData.typeName}
|
|
305
|
+
</p>
|
|
306
|
+
<p>
|
|
307
|
+
<span className="font-medium">Description:</span> {getTypeNameDescription(formData.typeName)}
|
|
308
|
+
</p>
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
</div>
|
|
312
|
+
|
|
313
|
+
{/* Fixed Footer */}
|
|
314
|
+
<div className="flex justify-end space-x-3 px-6 py-4 border-t bg-gray-50 flex-shrink-0">
|
|
315
|
+
<button
|
|
316
|
+
onClick={onCancel}
|
|
317
|
+
className="px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
|
318
|
+
>
|
|
319
|
+
Cancel
|
|
320
|
+
</button>
|
|
321
|
+
<button
|
|
322
|
+
onClick={handleSave}
|
|
323
|
+
className="px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
|
|
324
|
+
>
|
|
325
|
+
{resourceType ? 'Save Changes' : 'Add Resource Type'}
|
|
326
|
+
</button>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
);
|
|
331
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { QualifierTypeEditForm } from './QualifierTypeEditForm';
|
|
2
|
+
export type { QualifierTypeEditFormProps } from './QualifierTypeEditForm';
|
|
3
|
+
|
|
4
|
+
export { QualifierEditForm } from './QualifierEditForm';
|
|
5
|
+
export type { QualifierEditFormProps } from './QualifierEditForm';
|
|
6
|
+
|
|
7
|
+
export { ResourceTypeEditForm } from './ResourceTypeEditForm';
|
|
8
|
+
export type { ResourceTypeEditFormProps } from './ResourceTypeEditForm';
|
|
9
|
+
|
|
10
|
+
export { HierarchyEditor } from './HierarchyEditor';
|
|
11
|
+
export type { HierarchyEditorProps } from './HierarchyEditor';
|