@arpproject/recrate 0.1.14 → 0.1.16

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.
@@ -12,6 +12,7 @@ export declare class ProfileManager {
12
12
  profile?: NormalisedProfile;
13
13
  $key?: number;
14
14
  context?: any;
15
+ propertyDefinitionCache: Map<string, ProfileInput>;
15
16
  constructor({ profile }: {
16
17
  profile?: NormalisedProfile;
17
18
  });
@@ -2,7 +2,7 @@ import { default as React } from 'react';
2
2
  interface RenderLinkedItemProps {
3
3
  entity: {
4
4
  '@id': string;
5
- '@type': string[];
5
+ '@type'?: string[] | string;
6
6
  name?: string;
7
7
  [key: string]: any;
8
8
  };
@@ -30,6 +30,7 @@ export interface DescriboCrateBuilderProps {
30
30
  }) => void;
31
31
  onSaveCrate?: (saveData: {
32
32
  crate: any;
33
+ entityId?: string;
33
34
  }) => void;
34
35
  onSaveEntityTemplate?: (entity: any) => void;
35
36
  onAddNewProfileRequest?: (requested: boolean) => void;
@@ -6164,7 +6164,7 @@ function genStyleUtils(config2) {
6164
6164
  };
6165
6165
  }
6166
6166
  const PresetColors = ["blue", "purple", "cyan", "green", "magenta", "pink", "red", "orange", "yellow", "volcano", "geekblue", "lime", "gold"];
6167
- const version$2 = "5.29.1";
6167
+ const version$2 = "5.29.3";
6168
6168
  function isStableColor(color) {
6169
6169
  return color >= 0 && color <= 255;
6170
6170
  }
@@ -12413,20 +12413,25 @@ const InternalCompoundedButton = /* @__PURE__ */ React__default.forwardRef((prop
12413
12413
  const fullStyle = Object.assign(Object.assign({}, contextStyle), customStyle);
12414
12414
  const iconClasses = classNames(customClassNames === null || customClassNames === void 0 ? void 0 : customClassNames.icon, contextClassNames.icon);
12415
12415
  const iconStyle = Object.assign(Object.assign({}, (styles2 === null || styles2 === void 0 ? void 0 : styles2.icon) || {}), contextStyles.icon || {});
12416
- const iconNode = icon2 && !innerLoading ? /* @__PURE__ */ React__default.createElement(IconWrapper, {
12416
+ const iconWrapperElement = (child) => /* @__PURE__ */ React__default.createElement(IconWrapper, {
12417
12417
  prefixCls,
12418
12418
  className: iconClasses,
12419
12419
  style: iconStyle
12420
- }, icon2) : loading && typeof loading === "object" && loading.icon ? /* @__PURE__ */ React__default.createElement(IconWrapper, {
12421
- prefixCls,
12422
- className: iconClasses,
12423
- style: iconStyle
12424
- }, loading.icon) : /* @__PURE__ */ React__default.createElement(DefaultLoadingIcon, {
12420
+ }, child);
12421
+ const defaultLoadingIconElement = () => /* @__PURE__ */ React__default.createElement(DefaultLoadingIcon, {
12425
12422
  existIcon: !!icon2,
12426
12423
  prefixCls,
12427
12424
  loading: innerLoading,
12428
12425
  mount: isMountRef.current
12429
12426
  });
12427
+ let iconNode;
12428
+ if (icon2 && !innerLoading) {
12429
+ iconNode = iconWrapperElement(icon2);
12430
+ } else if (loading && typeof loading === "object" && loading.icon) {
12431
+ iconNode = iconWrapperElement(loading.icon);
12432
+ } else {
12433
+ iconNode = defaultLoadingIconElement();
12434
+ }
12430
12435
  const kids = children || children === 0 ? spaceChildren(children, needInserted && mergedInsertSpace) : null;
12431
12436
  if (linkButtonRestProps.href !== void 0) {
12432
12437
  return wrapCSSVar(/* @__PURE__ */ React__default.createElement("a", Object.assign({}, linkButtonRestProps, {
@@ -18400,18 +18405,18 @@ const genNoticeStyle = (token2) => {
18400
18405
  borderRadius: borderRadiusLG,
18401
18406
  overflow: "hidden",
18402
18407
  // Type-specific background colors
18403
- "&-success": {
18408
+ "&-success": colorSuccessBg ? {
18404
18409
  background: colorSuccessBg
18405
- },
18406
- "&-error": {
18410
+ } : {},
18411
+ "&-error": colorErrorBg ? {
18407
18412
  background: colorErrorBg
18408
- },
18409
- "&-info": {
18413
+ } : {},
18414
+ "&-info": colorInfoBg ? {
18410
18415
  background: colorInfoBg
18411
- },
18412
- "&-warning": {
18416
+ } : {},
18417
+ "&-warning": colorWarningBg ? {
18413
18418
  background: colorWarningBg
18414
- }
18419
+ } : {}
18415
18420
  },
18416
18421
  [`${noticeCls}-message`]: {
18417
18422
  color: colorTextHeading,
@@ -18592,10 +18597,13 @@ const genNotificationStyle = (token2) => {
18592
18597
  const prepareComponentToken$h = (token2) => ({
18593
18598
  zIndexPopup: token2.zIndexPopupBase + CONTAINER_MAX_OFFSET + 50,
18594
18599
  width: 384,
18595
- colorSuccessBg: token2.colorSuccessBg,
18596
- colorErrorBg: token2.colorErrorBg,
18597
- colorInfoBg: token2.colorInfoBg,
18598
- colorWarningBg: token2.colorWarningBg
18600
+ // Fix notification background color issue
18601
+ // https://github.com/ant-design/ant-design/issues/55649
18602
+ // https://github.com/ant-design/ant-design/issues/56055
18603
+ colorSuccessBg: void 0,
18604
+ colorErrorBg: void 0,
18605
+ colorInfoBg: void 0,
18606
+ colorWarningBg: void 0
18599
18607
  });
18600
18608
  const prepareNotificationToken = (token2) => {
18601
18609
  const notificationPaddingVertical = token2.paddingMD;
@@ -41624,15 +41632,19 @@ const Input$1 = /* @__PURE__ */ forwardRef((props, ref) => {
41624
41632
  rootClassName,
41625
41633
  onChange: onChange2,
41626
41634
  classNames: classNames$1,
41627
- variant: customVariant
41628
- } = props, rest = __rest$q(props, ["prefixCls", "bordered", "status", "size", "disabled", "onBlur", "onFocus", "suffix", "allowClear", "addonAfter", "addonBefore", "className", "style", "styles", "rootClassName", "onChange", "classNames", "variant"]);
41635
+ variant: customVariant,
41636
+ _skipAddonWarning
41637
+ } = props, rest = __rest$q(props, ["prefixCls", "bordered", "status", "size", "disabled", "onBlur", "onFocus", "suffix", "allowClear", "addonAfter", "addonBefore", "className", "style", "styles", "rootClassName", "onChange", "classNames", "variant", "_skipAddonWarning"]);
41629
41638
  if (process.env.NODE_ENV !== "production") {
41630
41639
  const {
41631
41640
  deprecated
41632
41641
  } = devUseWarning("Input");
41633
- [["bordered", "variant"], ["addonAfter", "Space.Compact"], ["addonBefore", "Space.Compact"]].forEach(([prop, newProp]) => {
41634
- deprecated(!(prop in props), prop, newProp);
41635
- });
41642
+ deprecated(!("bordered" in props), "bordered", "variant");
41643
+ if (!_skipAddonWarning) {
41644
+ [["addonAfter", "Space.Compact"], ["addonBefore", "Space.Compact"]].forEach(([prop, newProp]) => {
41645
+ deprecated(!(prop in props), prop, newProp);
41646
+ });
41647
+ }
41636
41648
  }
41637
41649
  const {
41638
41650
  getPrefixCls,
@@ -45657,7 +45669,8 @@ const Search = /* @__PURE__ */ React.forwardRef((props, ref) => {
45657
45669
  addonAfter: button,
45658
45670
  suffix,
45659
45671
  onChange: onChange2,
45660
- disabled: disabled2
45672
+ disabled: disabled2,
45673
+ _skipAddonWarning: true
45661
45674
  });
45662
45675
  return /* @__PURE__ */ React.createElement(Input$1, Object.assign({
45663
45676
  ref: composeRef(inputRef, ref)
@@ -54411,7 +54424,7 @@ function requireLodash() {
54411
54424
  (function(module2, exports$1) {
54412
54425
  (function() {
54413
54426
  var undefined$1;
54414
- var VERSION = "4.17.21";
54427
+ var VERSION = "4.17.23";
54415
54428
  var LARGE_ARRAY_SIZE = 200;
54416
54429
  var CORE_ERROR_TEXT = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", FUNC_ERROR_TEXT = "Expected a function", INVALID_TEMPL_VAR_ERROR_TEXT = "Invalid `variable` option passed into `_.template`";
54417
54430
  var HASH_UNDEFINED = "__lodash_hash_undefined__";
@@ -56339,8 +56352,28 @@ function requireLodash() {
56339
56352
  }
56340
56353
  function baseUnset(object4, path2) {
56341
56354
  path2 = castPath(path2, object4);
56342
- object4 = parent(object4, path2);
56343
- return object4 == null || delete object4[toKey(last(path2))];
56355
+ var index2 = -1, length2 = path2.length;
56356
+ if (!length2) {
56357
+ return true;
56358
+ }
56359
+ var isRootPrimitive = object4 == null || typeof object4 !== "object" && typeof object4 !== "function";
56360
+ while (++index2 < length2) {
56361
+ var key = path2[index2];
56362
+ if (typeof key !== "string") {
56363
+ continue;
56364
+ }
56365
+ if (key === "__proto__" && !hasOwnProperty.call(object4, "__proto__")) {
56366
+ return false;
56367
+ }
56368
+ if (key === "constructor" && index2 + 1 < length2 && typeof path2[index2 + 1] === "string" && path2[index2 + 1] === "prototype") {
56369
+ if (isRootPrimitive && index2 === 0) {
56370
+ continue;
56371
+ }
56372
+ return false;
56373
+ }
56374
+ }
56375
+ var obj = parent(object4, path2);
56376
+ return obj == null || delete obj[toKey(last(path2))];
56344
56377
  }
56345
56378
  function baseUpdate(object4, path2, updater, customizer) {
56346
56379
  return baseSet(object4, path2, updater(baseGet(object4, path2)), customizer);
@@ -79550,13 +79583,61 @@ const RenderLinkedItem = ({
79550
79583
  const crateManager = useContext(CrateManagerContext);
79551
79584
  const profileManager = useContext(ProfileManagerContext);
79552
79585
  const [associations, setAssociations] = useState([]);
79586
+ const effectiveEntity = useMemo$1(() => {
79587
+ const hasTypes = Boolean(entity == null ? void 0 : entity["@type"]);
79588
+ const hasName = Boolean(entity == null ? void 0 : entity.name);
79589
+ if (hasTypes && hasName) {
79590
+ return entity;
79591
+ }
79592
+ const resolved = crateManager.getEntity({
79593
+ id: entity["@id"],
79594
+ link: false,
79595
+ materialise: false
79596
+ });
79597
+ if (!resolved) {
79598
+ return entity;
79599
+ }
79600
+ return {
79601
+ ...resolved,
79602
+ ...entity,
79603
+ "@type": (entity == null ? void 0 : entity["@type"]) ?? resolved["@type"],
79604
+ name: (entity == null ? void 0 : entity.name) ?? resolved.name
79605
+ };
79606
+ }, [crateManager, entity]);
79553
79607
  const showMap = useMemo$1(() => {
79554
- return (entity == null ? void 0 : entity["@type"].join(", ").match(/Geo/)) ? true : false;
79555
- }, [entity]);
79608
+ const rawTypes = effectiveEntity == null ? void 0 : effectiveEntity["@type"];
79609
+ const typeList = Array.isArray(rawTypes) ? rawTypes : typeof rawTypes === "string" ? [rawTypes] : [];
79610
+ return typeList.some((type4) => String(type4).includes("Geo"));
79611
+ }, [effectiveEntity]);
79556
79612
  const resolveAssociations = () => {
79557
- const profile = profileManager.profile;
79613
+ const profile = profileManager == null ? void 0 : profileManager.profile;
79614
+ const resolveConfiguration = Array.isArray(profile == null ? void 0 : profile.resolve) ? profile.resolve : [];
79615
+ if (resolveConfiguration.length === 0) {
79616
+ setAssociations([]);
79617
+ return;
79618
+ }
79619
+ const rawTypes = entity == null ? void 0 : entity["@type"];
79620
+ const typeList = Array.isArray(rawTypes) ? rawTypes.map((type4) => String(type4)) : typeof rawTypes === "string" ? [rawTypes] : [];
79621
+ const hasResolveMatch = typeList.some(
79622
+ (type4) => resolveConfiguration.some(
79623
+ (entry) => Array.isArray(entry == null ? void 0 : entry.types) && entry.types.includes(type4)
79624
+ )
79625
+ );
79626
+ if (!hasResolveMatch) {
79627
+ setAssociations([]);
79628
+ return;
79629
+ }
79630
+ const sourceEntity = crateManager.getEntity({
79631
+ id: entity["@id"],
79632
+ link: false,
79633
+ materialise: false
79634
+ });
79635
+ if (!sourceEntity) {
79636
+ setAssociations([]);
79637
+ return;
79638
+ }
79558
79639
  const resolvedAssociations = crateManager.resolveLinkedEntityAssociations({
79559
- entity: crateManager.getEntity({ id: entity["@id"] }),
79640
+ entity: sourceEntity,
79560
79641
  profile
79561
79642
  });
79562
79643
  setAssociations(resolvedAssociations);
@@ -79572,6 +79653,15 @@ const RenderLinkedItem = ({
79572
79653
  onUnlinkEntity({ property, tgtEntityId: unlinkData.entity["@id"] });
79573
79654
  }
79574
79655
  };
79656
+ const linkDisplayEntity = useMemo$1(() => {
79657
+ const rawTypes = effectiveEntity == null ? void 0 : effectiveEntity["@type"];
79658
+ const typeList = Array.isArray(rawTypes) ? rawTypes.map((type4) => String(type4)) : typeof rawTypes === "string" ? [rawTypes] : ["Thing"];
79659
+ return {
79660
+ "@id": entity["@id"],
79661
+ "@type": typeList,
79662
+ name: (effectiveEntity == null ? void 0 : effectiveEntity.name) || entity["@id"]
79663
+ };
79664
+ }, [effectiveEntity, entity]);
79575
79665
  if (showMap) {
79576
79666
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { className: "describo-render-item-link py-1 rounded bg-blue-200 hover:text-black hover:bg-blue-300 hover:rounded-r-none", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { vertical: true, className: "space-y-2", children: [
79577
79667
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: "p-2", children: [
@@ -79602,10 +79692,7 @@ const RenderLinkedItem = ({
79602
79692
  /* @__PURE__ */ jsxRuntimeExports.jsx(
79603
79693
  ItemLink,
79604
79694
  {
79605
- entity: {
79606
- ...entity,
79607
- name: entity.name || entity["@id"]
79608
- },
79695
+ entity: linkDisplayEntity,
79609
79696
  onLoadEntity: handleLoadEntity
79610
79697
  }
79611
79698
  ),
@@ -81364,8 +81451,6 @@ const EntityProperty = ({
81364
81451
  const profileManager = useContext(ProfileManagerContext);
81365
81452
  const crateManager = useContext(CrateManagerContext);
81366
81453
  const state = useStateStore();
81367
- const [linkInstances, setLinkInstances] = useState([]);
81368
- const [simpleInstances, setSimpleInstances] = useState([]);
81369
81454
  const propertyDefinition = (_a2 = profileManager == null ? void 0 : profileManager.getPropertyDefinition({
81370
81455
  property,
81371
81456
  entity
@@ -81375,32 +81460,24 @@ const EntityProperty = ({
81375
81460
  const isNotValue = (propertyDefinition == null ? void 0 : propertyDefinition.type) !== "Value";
81376
81461
  const profileWarnMissingProperty = profileManager == null ? void 0 : profileManager.profile.warnMissingProperty;
81377
81462
  const showAddControl = !(propertyDefinition == null ? void 0 : propertyDefinition.readonly) && ((propertyDefinition == null ? void 0 : propertyDefinition.multiple) || !(values == null ? void 0 : values.length));
81378
- const valuesString = JSON.stringify(values);
81379
- useEffect(() => {
81380
- let simpleInsts;
81381
- if ((propertyDefinition == null ? void 0 : propertyDefinition.handlesMultipleValues) === true) {
81382
- simpleInsts = values.length === 0 ? values : [values];
81383
- } else {
81384
- simpleInsts = values;
81385
- }
81386
- setSimpleInstances(
81387
- simpleInsts.map((v2, i) => {
81388
- if (!lodashExports.isPlainObject(v2) || typeof v2 === "boolean") {
81389
- return { idx: i, value: v2 };
81390
- }
81463
+ const simpleInstances = useMemo$1(() => {
81464
+ const simpleInsts = (propertyDefinition == null ? void 0 : propertyDefinition.handlesMultipleValues) === true ? values.length === 0 ? values : [values] : values;
81465
+ return simpleInsts.map((v2, i) => {
81466
+ if (!lodashExports.isPlainObject(v2) || typeof v2 === "boolean") {
81467
+ return { idx: i, value: v2 };
81468
+ }
81469
+ return null;
81470
+ }).filter(Boolean);
81471
+ }, [values, propertyDefinition == null ? void 0 : propertyDefinition.handlesMultipleValues]);
81472
+ const linkInstances = useMemo$1(() => {
81473
+ return lodashExports.orderBy(
81474
+ values.map((v2, i) => {
81475
+ if (lodashExports.isPlainObject(v2) && typeof v2 !== "boolean") return { idx: i, value: v2 };
81391
81476
  return null;
81392
- }).filter(Boolean)
81477
+ }).filter(Boolean),
81478
+ ["value.@id"]
81393
81479
  );
81394
- setLinkInstances(
81395
- lodashExports.orderBy(
81396
- values.map((v2, i) => {
81397
- if (lodashExports.isPlainObject(v2) && typeof v2 !== "boolean") return { idx: i, value: v2 };
81398
- return null;
81399
- }).filter(Boolean),
81400
- "@id"
81401
- )
81402
- );
81403
- }, [valuesString, propertyDefinition == null ? void 0 : propertyDefinition.handlesMultipleValues]);
81480
+ }, [values]);
81404
81481
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
81405
81482
  "div",
81406
81483
  {
@@ -110503,7 +110580,7 @@ const RenderEntity = forwardRef((props, ref) => {
110503
110580
  }, [entity]);
110504
110581
  useEffect(() => {
110505
110582
  if (profileManager && profileManager.$key) {
110506
- const entityObj = crateManager.getEntity({ id: entity["@id"] });
110583
+ const entityObj = crateManager.getEntity({ id: entity["@id"], link: false, materialise: false });
110507
110584
  init2({ entity: entityObj });
110508
110585
  }
110509
110586
  }, [profileManager == null ? void 0 : profileManager.$key]);
@@ -110529,7 +110606,7 @@ const RenderEntity = forwardRef((props, ref) => {
110529
110606
  }
110530
110607
  };
110531
110608
  const refresh = () => {
110532
- const entityObj = crateManager.getEntity({ id: entity["@id"] });
110609
+ const entityObj = crateManager.getEntity({ id: entity["@id"], link: false, materialise: false });
110533
110610
  init2({ entity: entityObj });
110534
110611
  };
110535
110612
  const saveTabToState = (tabName) => {
@@ -110537,8 +110614,6 @@ const RenderEntity = forwardRef((props, ref) => {
110537
110614
  };
110538
110615
  useEffect(() => {
110539
110616
  if (entity == null ? void 0 : entity["@id"]) {
110540
- const entityObj = crateManager.getEntity({ id: entity["@id"] });
110541
- init2({ entity: entityObj });
110542
110617
  refresh();
110543
110618
  }
110544
110619
  }, [extraProperties]);
@@ -111055,30 +111130,23 @@ const RenderEntity = forwardRef((props, ref) => {
111055
111130
  ),
111056
111131
  (_o = tabs.find((tab) => tab.name === "about")) == null ? void 0 : _o.inputs.map((input) => {
111057
111132
  if (!["@id", "@type", "name", "@reverse"].includes(input.name)) {
111058
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
111059
- "div",
111133
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-2 hover:bg-sky-100 ${savedProperty === input.name ? "bg-green-200 hover:bg-green-200" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
111134
+ EntityProperty,
111060
111135
  {
111061
- className: `p-2 hover:bg-sky-100 ${savedProperty === input.name ? "bg-green-200 hover:bg-green-200" : ""}`,
111062
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
111063
- EntityProperty,
111064
- {
111065
- entity: contextEntity,
111066
- property: input.name,
111067
- values: Array.isArray(contextEntity[input.name]) ? contextEntity[input.name] : [contextEntity[input.name]],
111068
- highlightRequired: highlightRequiredProperties,
111069
- savedProperty: savedProperty === input.name,
111070
- onLoadEntity,
111071
- onCreateEntity: handleCreateEntity,
111072
- onLinkEntity: handleLinkEntity,
111073
- onUnlinkEntity: handleUnlinkEntity,
111074
- onCreateProperty: handleCreateProperty,
111075
- onSaveProperty: handleUpdateEntity,
111076
- onDeleteProperty: handleDeleteProperty
111077
- }
111078
- )
111079
- },
111080
- input.name
111081
- );
111136
+ entity: contextEntity,
111137
+ property: input.name,
111138
+ values: Array.isArray(contextEntity[input.name]) ? contextEntity[input.name] : [contextEntity[input.name]],
111139
+ highlightRequired: highlightRequiredProperties,
111140
+ savedProperty: savedProperty === input.name,
111141
+ onLoadEntity,
111142
+ onCreateEntity: handleCreateEntity,
111143
+ onLinkEntity: handleLinkEntity,
111144
+ onUnlinkEntity: handleUnlinkEntity,
111145
+ onCreateProperty: handleCreateProperty,
111146
+ onSaveProperty: handleUpdateEntity,
111147
+ onDeleteProperty: handleDeleteProperty
111148
+ }
111149
+ ) }, input.name);
111082
111150
  }
111083
111151
  return null;
111084
111152
  })
@@ -115389,6 +115457,7 @@ var hasExports = requireHas();
115389
115457
  const has = /* @__PURE__ */ getDefaultExportFromCjs(hasExports);
115390
115458
  class ProfileManager {
115391
115459
  constructor({ profile }) {
115460
+ this.propertyDefinitionCache = /* @__PURE__ */ new Map();
115392
115461
  if (profile) {
115393
115462
  this.profile = profile;
115394
115463
  this.__processInputs();
@@ -115529,6 +115598,12 @@ class ProfileManager {
115529
115598
  property,
115530
115599
  entity
115531
115600
  }) {
115601
+ const typeList = Array.isArray(entity["@type"]) ? entity["@type"] : [entity["@type"]];
115602
+ const cacheKey = `${typeList.slice().sort().join("|")}::${property.toLowerCase()}`;
115603
+ const cachedPropertyDefinition = this.propertyDefinitionCache.get(cacheKey);
115604
+ if (cachedPropertyDefinition) {
115605
+ return { propertyDefinition: cloneDeep(cachedPropertyDefinition) };
115606
+ }
115532
115607
  let propertyDefinition = {};
115533
115608
  let inputs = this.getInputsFromProfile({ entity });
115534
115609
  if (inputs.length) {
@@ -115557,7 +115632,8 @@ class ProfileManager {
115557
115632
  propertyDefinition.type = [propertyDefinition.type];
115558
115633
  }
115559
115634
  if (!has(propertyDefinition, "multiple")) propertyDefinition.multiple = true;
115560
- return { propertyDefinition };
115635
+ this.propertyDefinitionCache.set(cacheKey, cloneDeep(propertyDefinition));
115636
+ return { propertyDefinition: cloneDeep(propertyDefinition) };
115561
115637
  }
115562
115638
  /**
115563
115639
  *
@@ -119457,7 +119533,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
119457
119533
  }) : null
119458
119534
  );
119459
119535
  var CacheProvider = EmotionCacheContext.Provider;
119460
- const version = "0.1.14";
119536
+ const version = "0.1.16";
119461
119537
  const pkg = {
119462
119538
  version
119463
119539
  };
@@ -119495,7 +119571,6 @@ function DescriboCrateBuilder(props) {
119495
119571
  onAddNewProfileRequest,
119496
119572
  onRemoveProfile
119497
119573
  } = props;
119498
- console.log("DescriboCrateBuilder props:", { crate, profile, entityId });
119499
119574
  const [ready, setReady] = useState(false);
119500
119575
  const [error2, setError] = useState(false);
119501
119576
  const [contextEntity, setContextEntity] = useState(null);
@@ -119549,8 +119624,6 @@ function DescriboCrateBuilder(props) {
119549
119624
  lookup
119550
119625
  ]);
119551
119626
  const init2 = useCallback(async () => {
119552
- console.log("Initializing with crate:", crate);
119553
- console.log("Profile loaded:", profile);
119554
119627
  instance.changeLanguage(language2);
119555
119628
  if (!crate || isEmpty(crate)) {
119556
119629
  setReady(false);
@@ -119562,7 +119635,6 @@ function DescriboCrateBuilder(props) {
119562
119635
  crate,
119563
119636
  entityTimestamps: enableEntityTimestamps
119564
119637
  });
119565
- console.log("Entity:", newCm.getEntity({ id: entityId || "./" }));
119566
119638
  const profileClone = profile ? JSON.parse(JSON.stringify(profile)) : {};
119567
119639
  const newPm = new ProfileManager({
119568
119640
  profile: profileClone
@@ -119589,32 +119661,26 @@ function DescriboCrateBuilder(props) {
119589
119661
  setError(false);
119590
119662
  state.configuration = configuration;
119591
119663
  try {
119592
- if (entityId) {
119593
- handleSetCurrentEntity({ id: entityId });
119664
+ const rootEntity = newCm.getEntity({ id: "./", link: false, materialise: false });
119665
+ if (!isEmpty(rootEntity)) {
119666
+ setContextEntity(rootEntity);
119667
+ state.editorState.push({ id: rootEntity["@id"] });
119594
119668
  } else {
119595
- const rootEntity = newCm.getEntity({ id: "./" });
119596
- if (!isEmpty(rootEntity)) {
119597
- setContextEntity(rootEntity);
119598
- state.editorState.push({ id: rootEntity["@id"] });
119599
- } else {
119600
- console.warn("Root entity './' not found");
119601
- setError(true);
119602
- return;
119603
- }
119669
+ setError(true);
119670
+ return;
119604
119671
  }
119605
119672
  setReady(true);
119606
119673
  onReady == null ? void 0 : onReady();
119607
119674
  } catch (error22) {
119608
- console.error("Error setting current entity:", error22);
119609
119675
  setError(true);
119610
119676
  onError == null ? void 0 : onError({ error: "Failed to initialize entity" });
119611
119677
  }
119612
- }, [crate, profile, entityId, lookup, configuration]);
119678
+ }, [crate, profile, lookup, configuration, enableEntityTimestamps, language2, onError, onReady, state.editorState]);
119613
119679
  const handleSetCurrentEntity = useCallback((params) => {
119614
119680
  const { id: id2, updateState = true } = params;
119615
119681
  if (!id2 || !cm) return;
119616
119682
  try {
119617
- const entity = cm.getEntity({ id: id2 });
119683
+ const entity = cm.getEntity({ id: id2, link: false, materialise: false });
119618
119684
  if (!isEmpty(entity)) {
119619
119685
  setContextEntity(entity);
119620
119686
  onNavigation == null ? void 0 : onNavigation({
@@ -119674,7 +119740,8 @@ function DescriboCrateBuilder(props) {
119674
119740
  cm.purgeUnlinkedEntities();
119675
119741
  }
119676
119742
  const exported = cm.exportCrate();
119677
- onSaveCrate == null ? void 0 : onSaveCrate({ crate: exported });
119743
+ const currentEntityId = typeof (contextEntity == null ? void 0 : contextEntity["@id"]) === "string" ? contextEntity["@id"] : void 0;
119744
+ onSaveCrate == null ? void 0 : onSaveCrate({ crate: exported, entityId: currentEntityId });
119678
119745
  };
119679
119746
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "recrate", children: [
119680
119747
  /* @__PURE__ */ jsxRuntimeExports.jsx(CacheProvider, { value: antdCache, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ConfigProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(App, { className: "recrate-ant", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ProfileManagerContext.Provider, { value: pm, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrateManagerContext.Provider, { value: cm, children: /* @__PURE__ */ jsxRuntimeExports.jsx(LookupsContext.Provider, { value: lookups, children: ready && !error2 && contextEntity && /* @__PURE__ */ jsxRuntimeExports.jsx(
package/dist/types.d.ts CHANGED
@@ -27,6 +27,7 @@ export type DescriboCrateBuilderProps = {
27
27
  onError?: (message: string) => void;
28
28
  onSaveCrate?: (saveData: {
29
29
  crate: JSONObject;
30
+ entityId?: string;
30
31
  }) => void;
31
32
  onSaveCrateAsTemplate?: (name: string, crate: JSONObject) => void;
32
33
  onSaveEntityAsTemplate?: (name: string, entity: JSONObject) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arpproject/recrate",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "main": "./dist/recrate.es.js",
6
6
  "module": "./dist/recrate.es.js",