@arpproject/recrate 0.1.7 → 0.1.9
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 +3 -2
- package/dist/recrate.css +4 -4
- package/dist/recrate.es.js +34674 -114061
- package/package.json +41 -32
- package/.eslintrc.json +0 -37
- package/.storybook/main.ts +0 -40
- package/.storybook/preview.tsx +0 -46
- package/babel.config.json +0 -5
- package/docker-compose.yml +0 -30
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -99
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1448
- package/docs/classes/src_crate_builder_CrateManager_crate_manager.CrateManager.html +0 -240
- package/docs/classes/src_crate_builder_CrateManager_profile_manager.ProfileManager.html +0 -42
- package/docs/classes/src_crate_builder_editor_state.EditorState.html +0 -28
- package/docs/classes/src_crate_builder_types.CrateManagerType.html +0 -57
- package/docs/classes/src_crate_builder_types.ProfileManagerType.html +0 -13
- package/docs/functions/src_crate_builder_CrateManager_lib.isURL.html +0 -2
- package/docs/functions/src_crate_builder_CrateManager_lib.mintNewCrate.html +0 -3
- package/docs/functions/src_crate_builder_CrateManager_lib.normalise.html +0 -5
- package/docs/functions/src_crate_builder_CrateManager_lib.normaliseEntityType.html +0 -1
- package/docs/index.html +0 -58
- package/docs/interfaces/src_crate_builder_types.NormalisedCrate.html +0 -3
- package/docs/interfaces/src_crate_builder_types.NormalisedEntityDefinition.html +0 -4
- package/docs/interfaces/src_crate_builder_types.NormalisedProfile.html +0 -9
- package/docs/interfaces/src_crate_builder_types.ProfileLayout.html +0 -2
- package/docs/interfaces/src_crate_builder_types.ProfileLayoutGroup.html +0 -9
- package/docs/interfaces/src_crate_builder_types.UnverifiedCrate.html +0 -3
- package/docs/interfaces/src_crate_builder_types.UnverifiedEntityDefinition.html +0 -4
- package/docs/modules/src_crate_builder_CrateManager_crate_manager.html +0 -2
- package/docs/modules/src_crate_builder_CrateManager_lib.html +0 -6
- package/docs/modules/src_crate_builder_CrateManager_profile_manager.html +0 -2
- package/docs/modules/src_crate_builder_editor_state.html +0 -2
- package/docs/modules/src_crate_builder_types.html +0 -16
- package/docs/types/src_crate_builder_types.EntityReference.html +0 -1
- package/docs/types/src_crate_builder_types.NormalisedContext.html +0 -1
- package/docs/types/src_crate_builder_types.PrimitiveType.html +0 -1
- package/docs/types/src_crate_builder_types.ProfileAssociation.html +0 -1
- package/docs/types/src_crate_builder_types.ProfileInput.html +0 -1
- package/docs/types/src_crate_builder_types.UnverifiedContext.html +0 -1
- package/docs/variables/src_crate_builder_CrateManager_lib.urlProtocols.html +0 -1
- package/index.html +0 -13
- package/load-data-packs.cjs +0 -38
- package/postcss.config.cjs +0 -6
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/marker-icon.png +0 -0
- package/public/marker-shadow.png +0 -0
- package/public/robots.txt +0 -3
- package/react-app-env.d.ts +0 -1
- package/rollup.config.js +0 -26
- package/src/app/App.tsx +0 -13
- package/src/app/EmbeddedComponent.tsx +0 -432
- package/src/app/index.html +0 -20
- package/src/app/index.tsx +0 -19
- package/src/app/lookup.ts +0 -141
- package/src/app/override-styles.css +0 -96
- package/src/crate-builder/CrateManager/contexts/1.1-context.jsonld +0 -2660
- package/src/crate-builder/CrateManager/contexts/1.2-DRAFT-context.jsonld +0 -2918
- package/src/crate-builder/CrateManager/contexts.ts +0 -42
- package/src/crate-builder/CrateManager/crate-manager-benchmarking.spec.ts +0 -31
- package/src/crate-builder/CrateManager/crate-manager-loading-exporting.spec.ts +0 -431
- package/src/crate-builder/CrateManager/crate-manager-operations.spec.ts +0 -298
- package/src/crate-builder/CrateManager/crate-manager.spec.ts +0 -2336
- package/src/crate-builder/CrateManager/crate-manager.ts +0 -2111
- package/src/crate-builder/CrateManager/lib.spec.ts +0 -133
- package/src/crate-builder/CrateManager/lib.ts +0 -170
- package/src/crate-builder/CrateManager/profile-manager.spec.ts +0 -593
- package/src/crate-builder/CrateManager/profile-manager.ts +0 -367
- package/src/crate-builder/CrateManager/schema-type-definitions.json +0 -35122
- package/src/crate-builder/CrateManager/validate-identifier.spec.ts +0 -82
- package/src/crate-builder/CrateManager/validate-identifier.ts +0 -65
- package/src/crate-builder/RenderEntity/Add.tsx +0 -249
- package/src/crate-builder/RenderEntity/AddControl.stories.tsx +0 -126
- package/src/crate-builder/RenderEntity/AddControl.tsx +0 -84
- package/src/crate-builder/RenderEntity/AutoComplete.tsx +0 -215
- package/src/crate-builder/RenderEntity/BulkAdd.tsx +0 -136
- package/src/crate-builder/RenderEntity/DeleteProperty.tsx +0 -33
- package/src/crate-builder/RenderEntity/DialogAddProperty.tsx +0 -83
- package/src/crate-builder/RenderEntity/DialogBrowseEntities.tsx +0 -136
- package/src/crate-builder/RenderEntity/DialogEditContext.tsx +0 -107
- package/src/crate-builder/RenderEntity/DialogPreviewCrate.tsx +0 -54
- package/src/crate-builder/RenderEntity/DialogSaveCrateAsTemplate.tsx +0 -65
- package/src/crate-builder/RenderEntity/DialogSaveEntityTemplate.tsx +0 -87
- package/src/crate-builder/RenderEntity/DisplayPropertyName.stories.tsx +0 -30
- package/src/crate-builder/RenderEntity/DisplayPropertyName.tsx +0 -21
- package/src/crate-builder/RenderEntity/EntityId.tsx +0 -75
- package/src/crate-builder/RenderEntity/EntityName.tsx +0 -49
- package/src/crate-builder/RenderEntity/EntityProperty.tsx +0 -188
- package/src/crate-builder/RenderEntity/EntityPropertyInstance.tsx +0 -255
- package/src/crate-builder/RenderEntity/EntityType.tsx +0 -95
- package/src/crate-builder/RenderEntity/ItemLink.tsx +0 -37
- package/src/crate-builder/RenderEntity/PaginateLinkedEntities.stories.tsx +0 -43
- package/src/crate-builder/RenderEntity/PaginateLinkedEntities.tsx +0 -141
- package/src/crate-builder/RenderEntity/PropertyHelp.tsx +0 -39
- package/src/crate-builder/RenderEntity/RenderControls.tsx +0 -278
- package/src/crate-builder/RenderEntity/RenderLinkedItem.tsx +0 -139
- package/src/crate-builder/RenderEntity/RenderPropertyHelp.tsx +0 -41
- package/src/crate-builder/RenderEntity/RenderReverseConnections.tsx +0 -150
- package/src/crate-builder/RenderEntity/RenderTypes.tsx +0 -102
- package/src/crate-builder/RenderEntity/Shell2.tsx +0 -576
- package/src/crate-builder/RenderEntity/UnlinkEntity.tsx +0 -30
- package/src/crate-builder/RenderEntity/auto-complete.lib.ts +0 -184
- package/src/crate-builder/RenderEntity/keys.ts +0 -4
- package/src/crate-builder/RenderEntity/layout.spec.js +0 -593
- package/src/crate-builder/RenderEntity/layout.ts +0 -220
- package/src/crate-builder/Shell.tsx +0 -337
- package/src/crate-builder/component.css +0 -65
- package/src/crate-builder/editor-state.ts +0 -114
- package/src/crate-builder/emotionCache.ts +0 -8
- package/src/crate-builder/helpers.ts +0 -16
- package/src/crate-builder/i18n.ts +0 -22
- package/src/crate-builder/lib/validate-iri.js +0 -69
- package/src/crate-builder/lib/validate-iri.ts +0 -57
- package/src/crate-builder/locales/en.js +0 -149
- package/src/crate-builder/locales/hu.js +0 -147
- package/src/crate-builder/primitives/Boolean.stories.tsx +0 -33
- package/src/crate-builder/primitives/Boolean.tsx +0 -67
- package/src/crate-builder/primitives/Date.stories.tsx +0 -32
- package/src/crate-builder/primitives/Date.tsx +0 -58
- package/src/crate-builder/primitives/DateTime.stories.tsx +0 -32
- package/src/crate-builder/primitives/DateTime.tsx +0 -64
- package/src/crate-builder/primitives/Geo.stories.tsx +0 -57
- package/src/crate-builder/primitives/Geo.tsx +0 -225
- package/src/crate-builder/primitives/Map.SelectArea.js +0 -359
- package/src/crate-builder/primitives/Map.stories.tsx +0 -61
- package/src/crate-builder/primitives/Map.tsx +0 -124
- package/src/crate-builder/primitives/Number.stories.tsx +0 -74
- package/src/crate-builder/primitives/Number.tsx +0 -166
- package/src/crate-builder/primitives/Select.stories.tsx +0 -66
- package/src/crate-builder/primitives/Select.tsx +0 -121
- package/src/crate-builder/primitives/SelectObject.stories.tsx +0 -29
- package/src/crate-builder/primitives/SelectObject.tsx +0 -105
- package/src/crate-builder/primitives/SelectUrl.stories.tsx +0 -42
- package/src/crate-builder/primitives/SelectUrl.tsx +0 -110
- package/src/crate-builder/primitives/Text.stories.tsx +0 -106
- package/src/crate-builder/primitives/Text.tsx +0 -197
- package/src/crate-builder/primitives/Time.stories.tsx +0 -38
- package/src/crate-builder/primitives/Time.tsx +0 -71
- package/src/crate-builder/primitives/Url.stories.tsx +0 -43
- package/src/crate-builder/primitives/Url.tsx +0 -75
- package/src/crate-builder/primitives/Value.stories.tsx +0 -37
- package/src/crate-builder/primitives/Value.tsx +0 -30
- package/src/crate-builder/primitives/date-libs.ts +0 -12
- package/src/crate-builder/profile-schema.json +0 -145
- package/src/crate-builder/property-definitions.ts +0 -78
- package/src/crate-builder/recrate.css +0 -3
- package/src/crate-builder/store.ts +0 -14
- package/src/crate-builder/tailwind.css +0 -5
- package/src/crate-builder/types.d.ts +0 -318
- package/src/examples/collection/collections-entity-example.json +0 -131
- package/src/examples/collection/crate-builder-entity-example.json +0 -33
- package/src/examples/item/complex-collection/ro-crate-metadata.json +0 -174
- package/src/examples/item/complex-item/ro-crate-metadata.json +0 -769
- package/src/examples/item/crate-with-language.json +0 -38
- package/src/examples/item/empty/ro-crate-metadata.json +0 -20
- package/src/examples/item/item-with-relationship-and-action/ro-crate-metadata.json +0 -66
- package/src/examples/item/large-crate/ro-crate-metadata.json +0 -5762
- package/src/examples/item/multiple-types/ro-crate-metadata.json +0 -20
- package/src/examples/item/ridiculously-big-collection/ro-crate-metadata.json +0 -162977
- package/src/examples/profile/aroma.complex.profile.json +0 -11098
- package/src/examples/profile/aroma.profile.json +0 -9158
- package/src/examples/profile/nyingarn-item-profile.json +0 -426
- package/src/examples/profile/profile-to-test-inverse-associations.json +0 -73
- package/src/examples/profile/profile-to-test-multiple-types.json +0 -31
- package/src/examples/profile/profile-with-all-primitives-and-groups.json +0 -207
- package/src/examples/profile/profile-with-all-primitives.json +0 -244
- package/src/examples/profile/profile-with-constraints.json +0 -446
- package/src/examples/profile/profile-with-resolve.json +0 -57
- package/src/examples/profile/vocabulary-creation-profile.json +0 -231
- package/src/images.d.ts +0 -5
- package/src/index.ts +0 -12
- package/src/types.ts +0 -104
- package/tailwind.config.js +0 -21
- package/tsconfig.app.json +0 -31
- package/tsconfig.json +0 -26
- package/typedoc.json +0 -11
- package/update-deps.sh +0 -4
- package/vite-env.d.ts +0 -1
- package/vite.config.ts +0 -46
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useContext } from 'react';
|
|
2
|
-
import { Select, Input, Button, Typography } from 'antd';
|
|
3
|
-
import { PlusOutlined } from '@ant-design/icons';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import debounce from 'lodash/debounce';
|
|
6
|
-
import { CrateManagerContext, LookupsContext } from '../Shell';
|
|
7
|
-
import { useStateStore } from '../store';
|
|
8
|
-
import { Lookup, wrapPromise } from './auto-complete.lib';
|
|
9
|
-
|
|
10
|
-
interface AutoCompleteProps {
|
|
11
|
-
type: string;
|
|
12
|
-
onLinkEntity: (data: { json: any }) => void;
|
|
13
|
-
onCreateEntity: (data: { json: any }) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface MatchGroup {
|
|
17
|
-
label: string;
|
|
18
|
-
entities: any[];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const AutoComplete: React.FC<AutoCompleteProps> = ({ type, onLinkEntity, onCreateEntity }) => {
|
|
22
|
-
const { t } = useTranslation();
|
|
23
|
-
const crateManager = useContext(CrateManagerContext);
|
|
24
|
-
const lookupHandler = useContext(LookupsContext);
|
|
25
|
-
const state = useStateStore();
|
|
26
|
-
|
|
27
|
-
const [loading, setLoading] = useState(false);
|
|
28
|
-
const [selection, setSelection] = useState<any>(null);
|
|
29
|
-
const [matches, setMatches] = useState<MatchGroup[]>([]);
|
|
30
|
-
const [inputValue, setInputValue] = useState('');
|
|
31
|
-
|
|
32
|
-
const promiseTimeout = 2500;
|
|
33
|
-
|
|
34
|
-
const querySearch = async (queryString: string) => {
|
|
35
|
-
setLoading(true);
|
|
36
|
-
|
|
37
|
-
const lookup = new Lookup({
|
|
38
|
-
config: crateManager?.profile?.lookup,
|
|
39
|
-
lookup: lookupHandler,
|
|
40
|
-
crateManager,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const newEntity = queryString ? [
|
|
44
|
-
{
|
|
45
|
-
type: 'new',
|
|
46
|
-
'@id': queryString,
|
|
47
|
-
'@type': type,
|
|
48
|
-
name: queryString,
|
|
49
|
-
},
|
|
50
|
-
] : [];
|
|
51
|
-
|
|
52
|
-
const lookups = [];
|
|
53
|
-
|
|
54
|
-
if (crateManager?.getEntities) {
|
|
55
|
-
lookups.push(wrapPromise(lookup.getEntities(type, queryString), promiseTimeout));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (lookupHandler?.dataPacks) {
|
|
59
|
-
lookups.push(
|
|
60
|
-
wrapPromise(lookup.dataPacks(type, queryString), promiseTimeout, {
|
|
61
|
-
reason: 'External Lookup Timeout',
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (lookupHandler?.entityTemplates) {
|
|
67
|
-
lookups.push(
|
|
68
|
-
wrapPromise(lookup.entityTemplates(type, queryString), promiseTimeout, {
|
|
69
|
-
reason: 'External Lookup Timeout',
|
|
70
|
-
})
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (lookupHandler?.entities) {
|
|
75
|
-
lookups.push(
|
|
76
|
-
wrapPromise(lookup.entities(type, queryString), promiseTimeout, {
|
|
77
|
-
reason: 'External Lookup Timeout',
|
|
78
|
-
})
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (['Organisation', 'Organization'].includes(type) || type === 'ANY') {
|
|
83
|
-
lookups.push(
|
|
84
|
-
wrapPromise(lookup.ror(queryString), promiseTimeout, {
|
|
85
|
-
reason: 'ROR Lookup Timeout',
|
|
86
|
-
})
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const responses = await Promise.all(lookups);
|
|
91
|
-
const newMatches: MatchGroup[] = [];
|
|
92
|
-
|
|
93
|
-
responses.forEach((response) => {
|
|
94
|
-
if (response.endpoint === 'internal' && response.documents?.length) {
|
|
95
|
-
newMatches.push({
|
|
96
|
-
label: t('associate_existing_entity'),
|
|
97
|
-
entities: response.documents.map((e) => ({ ...e, type: 'internal' })).slice(0, 5),
|
|
98
|
-
});
|
|
99
|
-
} else if (response.endpoint === 'templates' && response.documents?.length) {
|
|
100
|
-
newMatches.push({
|
|
101
|
-
label: t('associate_entity_from_template'),
|
|
102
|
-
entities: response.documents.map((entity) => ({
|
|
103
|
-
...entity,
|
|
104
|
-
type: 'template',
|
|
105
|
-
})),
|
|
106
|
-
});
|
|
107
|
-
} else if (response.endpoint === 'ror' && response.documents?.length) {
|
|
108
|
-
newMatches.push({
|
|
109
|
-
label: t('associate_organization_from_ror'),
|
|
110
|
-
entities: response.documents.map((entity) => ({ ...entity, type: 'ror' })),
|
|
111
|
-
});
|
|
112
|
-
} else if (response.endpoint === 'entities' && response.documents?.length) {
|
|
113
|
-
newMatches.push({
|
|
114
|
-
label: t('associate_user_created_entity'),
|
|
115
|
-
entities: response.documents.map((entity) => ({ ...entity, type: 'datapack' })),
|
|
116
|
-
});
|
|
117
|
-
} else if (response.endpoint === 'datapacks' && response.documents?.length) {
|
|
118
|
-
newMatches.push({
|
|
119
|
-
label: t('associate_from_datapack'),
|
|
120
|
-
entities: response.documents.map((entity) => ({ ...entity, type: 'datapack' })),
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
if (type !== 'ANY') {
|
|
126
|
-
newMatches.push({
|
|
127
|
-
label: t('create_new_entity'),
|
|
128
|
-
entities: newEntity,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
setMatches(newMatches);
|
|
133
|
-
setLoading(false);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const debouncedQuerySearch = debounce(querySearch, 1000, { leading: true });
|
|
137
|
-
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
querySearch('');
|
|
140
|
-
}, [type]);
|
|
141
|
-
|
|
142
|
-
const handleSelect = (value: string, option: any) => {
|
|
143
|
-
const entity = option.entity;
|
|
144
|
-
if (entity) {
|
|
145
|
-
const updatedEntity = {
|
|
146
|
-
...entity,
|
|
147
|
-
'@type': entity['@type'].split(', ').map((t: string) => t.trim()),
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
if (entity?.type === 'internal') {
|
|
151
|
-
onLinkEntity({ json: updatedEntity });
|
|
152
|
-
} else {
|
|
153
|
-
onCreateEntity({ json: updatedEntity });
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
setSelection(null);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const renderOption = (option: any) => {
|
|
160
|
-
const entity = option.entity;
|
|
161
|
-
if (!entity) return null;
|
|
162
|
-
|
|
163
|
-
if (entity.type === 'new') {
|
|
164
|
-
return (
|
|
165
|
-
<Button
|
|
166
|
-
size="middle"
|
|
167
|
-
variant="solid"
|
|
168
|
-
color="green"
|
|
169
|
-
block
|
|
170
|
-
icon={<PlusOutlined />}
|
|
171
|
-
>
|
|
172
|
-
{t('create_new_of_type', { type: entity['@type'] })}: {entity.name}
|
|
173
|
-
</Button>
|
|
174
|
-
);
|
|
175
|
-
} else if (entity.type === 'datapack') {
|
|
176
|
-
return (
|
|
177
|
-
<div className="flex flex-row space-x-2">
|
|
178
|
-
<Typography.Text>{entity['@type']}:</Typography.Text>
|
|
179
|
-
<Typography.Text>{entity.name} ({entity['@id']})</Typography.Text>
|
|
180
|
-
</div>
|
|
181
|
-
);
|
|
182
|
-
} else {
|
|
183
|
-
return (
|
|
184
|
-
<div className="flex flex-row space-x-2">
|
|
185
|
-
<Typography.Text>{entity['@type']}:</Typography.Text>
|
|
186
|
-
<Typography.Text>{entity.name || entity['@id']}</Typography.Text>
|
|
187
|
-
</div>
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
return (
|
|
193
|
-
<div className={loading ? 'opacity-50' : ''}>
|
|
194
|
-
<Select
|
|
195
|
-
showSearch
|
|
196
|
-
size="middle"
|
|
197
|
-
value={selection}
|
|
198
|
-
placeholder={t('select_existing_or_create_new') || 'select an existing entity or create a new one'}
|
|
199
|
-
defaultActiveFirstOption={false}
|
|
200
|
-
filterOption={false}
|
|
201
|
-
onSearch={debouncedQuerySearch}
|
|
202
|
-
onChange={handleSelect}
|
|
203
|
-
notFoundContent={loading ? 'Loading...' : 'No results'}
|
|
204
|
-
options={matches.flatMap((group) => [
|
|
205
|
-
{ label: <Typography.Text strong>{group.label}</Typography.Text>, options: group.entities.map(entity => ({ label: renderOption({ entity }), value: entity['@id'], entity })) }
|
|
206
|
-
]).flatMap(group => [
|
|
207
|
-
{ label: group.label, options: group.options }
|
|
208
|
-
])}
|
|
209
|
-
optionRender={(option) => option.label}
|
|
210
|
-
/>
|
|
211
|
-
</div>
|
|
212
|
-
);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
export default AutoComplete;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Button, Select, Input, Typography, Flex } from 'antd';
|
|
3
|
-
import { DeleteOutlined, PlusOutlined } from '@ant-design/icons';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
|
|
6
|
-
interface BulkAddProps {
|
|
7
|
-
types: string | string[];
|
|
8
|
-
primitives: string[];
|
|
9
|
-
onCreateEntity: (data: { json: any }) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface DataRow {
|
|
13
|
-
id: string;
|
|
14
|
-
name: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const BulkAdd: React.FC<BulkAddProps> = ({ types, primitives, onCreateEntity }) => {
|
|
18
|
-
const { t } = useTranslation();
|
|
19
|
-
const [selectedType, setSelectedType] = useState<string>('');
|
|
20
|
-
const [data, setData] = useState<DataRow[]>([
|
|
21
|
-
{ id: '', name: '' },
|
|
22
|
-
{ id: '', name: '' },
|
|
23
|
-
{ id: '', name: '' },
|
|
24
|
-
{ id: '', name: '' },
|
|
25
|
-
{ id: '', name: '' },
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
const availableTypes = Array.isArray(types)
|
|
29
|
-
? types.filter(t => !primitives.includes(t) && t !== 'ANY')
|
|
30
|
-
: [];
|
|
31
|
-
|
|
32
|
-
const addRow = () => {
|
|
33
|
-
setData([...data, { id: '', name: '' }]);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const deleteRow = (index: number) => {
|
|
37
|
-
setData(data.filter((_, idx) => idx !== index));
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const updateRow = (index: number, field: keyof DataRow, value: string) => {
|
|
41
|
-
const newData = [...data];
|
|
42
|
-
newData[index] = { ...newData[index], [field]: value };
|
|
43
|
-
setData(newData);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const createEntities = () => {
|
|
47
|
-
data.forEach(entity => {
|
|
48
|
-
if (entity.id && entity.name) {
|
|
49
|
-
onCreateEntity({
|
|
50
|
-
json: {
|
|
51
|
-
'@id': entity.id,
|
|
52
|
-
'@type': selectedType,
|
|
53
|
-
name: entity.name,
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<div className="flex flex-col space-y-2 m-1">
|
|
62
|
-
<Typography.Title level={5} className="my-1 text-lg text-center">
|
|
63
|
-
Note beforehand: This does not lookup existing entities.
|
|
64
|
-
</Typography.Title>
|
|
65
|
-
|
|
66
|
-
<div>
|
|
67
|
-
<Typography.Text>@type</Typography.Text>
|
|
68
|
-
<Select
|
|
69
|
-
value={selectedType}
|
|
70
|
-
onChange={(value) => setSelectedType(value as string)}
|
|
71
|
-
style={{ width: '100%' }}
|
|
72
|
-
placeholder="Select a type"
|
|
73
|
-
size='middle'
|
|
74
|
-
>
|
|
75
|
-
<Select.Option value="">Select a type</Select.Option>
|
|
76
|
-
{availableTypes.map((type) => (
|
|
77
|
-
<Select.Option key={type} value={type}>
|
|
78
|
-
{type}
|
|
79
|
-
</Select.Option>
|
|
80
|
-
))}
|
|
81
|
-
</Select>
|
|
82
|
-
</div>
|
|
83
|
-
|
|
84
|
-
<Flex className="flex-row space-x-1">
|
|
85
|
-
<div className="w-1/2">@id</div>
|
|
86
|
-
<div className="w-1/2">name</div>
|
|
87
|
-
<div className="w-12"></div>
|
|
88
|
-
</Flex>
|
|
89
|
-
|
|
90
|
-
{data.map((row, idx) => (
|
|
91
|
-
<Flex key={idx} className="flex-row space-x-1">
|
|
92
|
-
<Input
|
|
93
|
-
size='small'
|
|
94
|
-
value={row.id}
|
|
95
|
-
onChange={(e) => updateRow(idx, 'id', e.target.value)}
|
|
96
|
-
style={{ flex: 1 }}
|
|
97
|
-
/>
|
|
98
|
-
<Input
|
|
99
|
-
size='small'
|
|
100
|
-
value={row.name}
|
|
101
|
-
onChange={(e) => updateRow(idx, 'name', e.target.value)}
|
|
102
|
-
style={{ flex: 1 }}
|
|
103
|
-
/>
|
|
104
|
-
<Button
|
|
105
|
-
danger
|
|
106
|
-
variant='solid'
|
|
107
|
-
color='red'
|
|
108
|
-
onClick={() => deleteRow(idx)}
|
|
109
|
-
icon={<DeleteOutlined />}
|
|
110
|
-
/>
|
|
111
|
-
</Flex>
|
|
112
|
-
))}
|
|
113
|
-
|
|
114
|
-
<Flex justify="space-between">
|
|
115
|
-
<Button
|
|
116
|
-
type="primary"
|
|
117
|
-
onClick={addRow}
|
|
118
|
-
icon={<PlusOutlined />}
|
|
119
|
-
>
|
|
120
|
-
Add row
|
|
121
|
-
</Button>
|
|
122
|
-
<Button
|
|
123
|
-
size='middle'
|
|
124
|
-
variant='solid'
|
|
125
|
-
color='green'
|
|
126
|
-
onClick={createEntities}
|
|
127
|
-
disabled={!selectedType}
|
|
128
|
-
>
|
|
129
|
-
Create these entities
|
|
130
|
-
</Button>
|
|
131
|
-
</Flex>
|
|
132
|
-
</div>
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export default BulkAdd;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Button } from 'antd';
|
|
3
|
-
import { DeleteOutlined, LinkOutlined } from '@ant-design/icons';
|
|
4
|
-
|
|
5
|
-
interface DeletePropertyProps {
|
|
6
|
-
type?: 'delete' | 'unlink';
|
|
7
|
-
property: string;
|
|
8
|
-
onDeleteProperty: () => void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const DeleteProperty: React.FC<DeletePropertyProps> = ({
|
|
12
|
-
type = 'unlink',
|
|
13
|
-
property,
|
|
14
|
-
onDeleteProperty
|
|
15
|
-
}) => {
|
|
16
|
-
const handleDelete = () => {
|
|
17
|
-
onDeleteProperty();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Button
|
|
22
|
-
danger
|
|
23
|
-
onClick={handleDelete}
|
|
24
|
-
size="middle"
|
|
25
|
-
variant='solid'
|
|
26
|
-
color='red'
|
|
27
|
-
className="describo-delete-property"
|
|
28
|
-
icon={type === 'delete' ? <DeleteOutlined /> : <LinkOutlined />}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export default DeleteProperty;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useContext } from 'react';
|
|
2
|
-
import { Input, Flex, Typography, Drawer, Button } from 'antd';
|
|
3
|
-
import { CloseOutlined, ArrowRightOutlined } from '@ant-design/icons';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { ProfileManagerContext } from '../Shell';
|
|
6
|
-
|
|
7
|
-
interface DialogAddPropertyProps {
|
|
8
|
-
entity: any;
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
open: boolean;
|
|
11
|
-
onAddPropertyPlaceholder: (property: string) => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const DialogAddProperty: React.FC<DialogAddPropertyProps> = ({
|
|
15
|
-
entity,
|
|
16
|
-
onClose,
|
|
17
|
-
open,
|
|
18
|
-
onAddPropertyPlaceholder
|
|
19
|
-
}) => {
|
|
20
|
-
const { t } = useTranslation();
|
|
21
|
-
const profileManager = useContext(ProfileManagerContext);
|
|
22
|
-
const [filter, setFilter] = useState<string>('');
|
|
23
|
-
|
|
24
|
-
const inputs = React.useMemo(() => {
|
|
25
|
-
if (!entity?.['@type']) return [];
|
|
26
|
-
const { inputs } = profileManager.getAllInputs({ entity });
|
|
27
|
-
if (!filter) return inputs;
|
|
28
|
-
return inputs.filter((i: any) => {
|
|
29
|
-
const re = new RegExp(filter, 'i');
|
|
30
|
-
return i?.name?.match(re) || i?.help?.match(re);
|
|
31
|
-
});
|
|
32
|
-
}, [entity, filter, profileManager]);
|
|
33
|
-
|
|
34
|
-
const handlePropertySelection = (item: any) => {
|
|
35
|
-
onAddPropertyPlaceholder(item.name);
|
|
36
|
-
onClose();
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<Drawer
|
|
41
|
-
title={<Typography.Title className='m-2' level={4}>{t("add_properties_to_this_entity") || 'Add properties to this entity'}</Typography.Title>}
|
|
42
|
-
placement="left"
|
|
43
|
-
onClose={onClose}
|
|
44
|
-
open={open}
|
|
45
|
-
width={600} // Equivalent to minWidth: '600px'
|
|
46
|
-
>
|
|
47
|
-
<Flex vertical className="h-full">
|
|
48
|
-
<Flex vertical gap={16} className="overflow-auto flex-grow">
|
|
49
|
-
<Input.Search
|
|
50
|
-
value={filter}
|
|
51
|
-
onChange={(e) => setFilter(e.target.value)}
|
|
52
|
-
placeholder={t('filter_attribute_set') || 'Filter the attribute set'}
|
|
53
|
-
size="middle"
|
|
54
|
-
/>
|
|
55
|
-
{inputs.map((item: any, idx: number) => (
|
|
56
|
-
<div
|
|
57
|
-
key={idx}
|
|
58
|
-
className="cursor-pointer p-2 hover:bg-blue-100 hover:rounded active:bg-blue-400"
|
|
59
|
-
onClick={() => handlePropertySelection(item)}
|
|
60
|
-
>
|
|
61
|
-
<Flex vertical className="text-black">
|
|
62
|
-
<Flex align="center" gap={4} className="border-b border-gray-700">
|
|
63
|
-
{item.label ? (
|
|
64
|
-
<Typography.Text className="text-nowrap">{item.label}</Typography.Text>
|
|
65
|
-
) : (
|
|
66
|
-
<Typography.Text className="text-black">{item.name}</Typography.Text>
|
|
67
|
-
)}
|
|
68
|
-
<ArrowRightOutlined />
|
|
69
|
-
<Typography.Text className="text-balance">
|
|
70
|
-
{Array.isArray(item.type) ? item.type.join(', ') : item.type || ''}
|
|
71
|
-
</Typography.Text>
|
|
72
|
-
</Flex>
|
|
73
|
-
<Typography.Text type="secondary" className="w-full">{item.help}</Typography.Text>
|
|
74
|
-
</Flex>
|
|
75
|
-
</div>
|
|
76
|
-
))}
|
|
77
|
-
</Flex>
|
|
78
|
-
</Flex>
|
|
79
|
-
</Drawer>
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export default DialogAddProperty;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import React, { useState, useContext, useMemo } from 'react';
|
|
2
|
-
import { Input, Select, Pagination, Flex, Drawer, Typography, Button, Card } from 'antd';
|
|
3
|
-
import { CloseOutlined } from '@ant-design/icons';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { compact } from 'lodash';
|
|
6
|
-
import { CrateManagerContext } from '../Shell';
|
|
7
|
-
import ItemLink from './ItemLink';
|
|
8
|
-
|
|
9
|
-
interface DialogBrowseEntitiesProps {
|
|
10
|
-
onClose: () => void;
|
|
11
|
-
open: boolean;
|
|
12
|
-
onLoadEntity: (entity: any) => void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const DialogBrowseEntities: React.FC<DialogBrowseEntitiesProps> = ({
|
|
16
|
-
onClose,
|
|
17
|
-
open,
|
|
18
|
-
onLoadEntity
|
|
19
|
-
}) => {
|
|
20
|
-
const { t } = useTranslation();
|
|
21
|
-
const crateManager = useContext(CrateManagerContext);
|
|
22
|
-
const [data, setData] = useState({
|
|
23
|
-
filterInputModel: '',
|
|
24
|
-
pageSize: 10,
|
|
25
|
-
currentPage: 1,
|
|
26
|
-
total: 0,
|
|
27
|
-
query: '',
|
|
28
|
-
selectedEntityType: undefined as string | undefined,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const entityTypes = useMemo(() =>
|
|
32
|
-
crateManager.getEntityTypes(), [crateManager]);
|
|
33
|
-
|
|
34
|
-
const entities = useMemo(() => {
|
|
35
|
-
const offset = (data.currentPage - 1) * data.pageSize;
|
|
36
|
-
let entities;
|
|
37
|
-
|
|
38
|
-
if (data.query) {
|
|
39
|
-
entities = [
|
|
40
|
-
...crateManager.getEntities({
|
|
41
|
-
type: data.selectedEntityType,
|
|
42
|
-
query: data.query,
|
|
43
|
-
limit: data.pageSize,
|
|
44
|
-
}),
|
|
45
|
-
];
|
|
46
|
-
} else {
|
|
47
|
-
entities = [...crateManager.getEntities({ type: data.selectedEntityType })];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
entities = compact(entities);
|
|
51
|
-
setData(prev => ({ ...prev, total: entities.length }));
|
|
52
|
-
return entities.slice(offset, offset + data.pageSize);
|
|
53
|
-
}, [data.currentPage, data.pageSize, data.query, data.selectedEntityType, crateManager]);
|
|
54
|
-
|
|
55
|
-
const handleLoadEntity = (entity: any) => {
|
|
56
|
-
onLoadEntity({ id: entity['@id'] });
|
|
57
|
-
onClose();
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Drawer
|
|
62
|
-
title={<Typography.Title className='m-2' level={4}>{t('browse_entities') || 'Browse Entities'}</Typography.Title>}
|
|
63
|
-
placement="right"
|
|
64
|
-
onClose={onClose}
|
|
65
|
-
open={open}
|
|
66
|
-
width={600} // Equivalent to minWidth: '600px'
|
|
67
|
-
>
|
|
68
|
-
<Flex vertical className="h-full">
|
|
69
|
-
<Flex vertical gap={16} className="overflow-auto flex-grow">
|
|
70
|
-
<Pagination
|
|
71
|
-
current={data.currentPage}
|
|
72
|
-
pageSize={data.pageSize}
|
|
73
|
-
total={data.total}
|
|
74
|
-
onChange={(page, pageSize) => setData(prev => ({ ...prev, currentPage: page, pageSize: pageSize }))}
|
|
75
|
-
size="default"
|
|
76
|
-
showSizeChanger={false}
|
|
77
|
-
/>
|
|
78
|
-
<Flex gap={8}>
|
|
79
|
-
<Select
|
|
80
|
-
value={data.selectedEntityType || undefined}
|
|
81
|
-
onChange={(value) => setData(prev => ({ ...prev, selectedEntityType: value as string }))}
|
|
82
|
-
style={{ minWidth: 150 }}
|
|
83
|
-
placeholder={t('filter_by_type')}
|
|
84
|
-
size="middle"
|
|
85
|
-
>
|
|
86
|
-
<Select.Option value="">{t('filter_by_type')}</Select.Option>
|
|
87
|
-
{entityTypes.map((t: string) => (
|
|
88
|
-
<Select.Option key={t} value={t}>{t}</Select.Option>
|
|
89
|
-
))}
|
|
90
|
-
</Select>
|
|
91
|
-
<Input.Search
|
|
92
|
-
style={{ flex: 1 }}
|
|
93
|
-
size="middle"
|
|
94
|
-
value={data.filterInputModel}
|
|
95
|
-
onChange={(e) => {
|
|
96
|
-
setData(prev => ({
|
|
97
|
-
...prev,
|
|
98
|
-
filterInputModel: e.target.value,
|
|
99
|
-
currentPage: 1,
|
|
100
|
-
query: e.target.value
|
|
101
|
-
}));
|
|
102
|
-
}}
|
|
103
|
-
placeholder={t('search_for_connection') || 'Search for a connection'}
|
|
104
|
-
/>
|
|
105
|
-
</Flex>
|
|
106
|
-
<div className="flex-grow">
|
|
107
|
-
{entities.map((entity) => (
|
|
108
|
-
<div key={entity['@id']} className="mb-2">
|
|
109
|
-
<Card
|
|
110
|
-
style={{
|
|
111
|
-
backgroundColor: '#e6f0ff',
|
|
112
|
-
cursor: 'pointer',
|
|
113
|
-
transition: 'background-color 0.2s',
|
|
114
|
-
borderLeft: '3px solid #409eff'
|
|
115
|
-
}}
|
|
116
|
-
hoverable
|
|
117
|
-
>
|
|
118
|
-
<Card.Meta
|
|
119
|
-
title={
|
|
120
|
-
<ItemLink
|
|
121
|
-
entity={entity}
|
|
122
|
-
onLoadEntity={() => handleLoadEntity(entity)}
|
|
123
|
-
/>
|
|
124
|
-
}
|
|
125
|
-
/>
|
|
126
|
-
</Card>
|
|
127
|
-
</div>
|
|
128
|
-
))}
|
|
129
|
-
</div>
|
|
130
|
-
</Flex>
|
|
131
|
-
</Flex>
|
|
132
|
-
</Drawer>
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export default DialogBrowseEntities;
|