@arpproject/recrate 0.1.10 → 0.1.12

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.
@@ -10,6 +10,7 @@ interface RenderEntityProps {
10
10
  onWarning: () => void;
11
11
  onError: () => void;
12
12
  onAddNewProfileRequest?: (requested: boolean) => void;
13
+ onRemoveProfile?: (data: any) => void;
13
14
  }
14
15
  declare const RenderEntity: React.ForwardRefExoticComponent<RenderEntityProps & React.RefAttributes<any>>;
15
16
  export default RenderEntity;
@@ -33,6 +33,7 @@ export interface DescriboCrateBuilderProps {
33
33
  }) => void;
34
34
  onSaveEntityTemplate?: (entity: any) => void;
35
35
  onAddNewProfileRequest?: (requested: boolean) => void;
36
+ onRemoveProfile?: (payload: any) => void;
36
37
  }
37
38
  export declare const ProfileManagerContext: React.Context<any>;
38
39
  export declare const CrateManagerContext: React.Context<any>;
@@ -67061,6 +67061,7 @@ function validateId({ id: id2, type: type4 }) {
67061
67061
  if (id2.match(/arcp:\/\/name,.*/)) return { isValid: true };
67062
67062
  if (id2.match(/arcp:\/\/uuid,.*/)) return { isValid: true };
67063
67063
  if (id2.match(/arcp:\/\/ni,sha-256;,.*/)) return { isValid: true };
67064
+ if (id2.match(/^file:\/\/.*/)) return { isValid: true };
67064
67065
  try {
67065
67066
  let result = validateIri(id2, IriValidationStrategy.Strict);
67066
67067
  if (!result) {
@@ -109118,6 +109119,10 @@ function applyLayout({
109118
109119
  renderTabs = true;
109119
109120
  tabs = applyLayoutToEntity({ layouts, inputs, entity });
109120
109121
  tabs = applyTabDataIndicators({ configuration, tabs, entity });
109122
+ tabs = tabs.map((tab) => {
109123
+ var _a2;
109124
+ return { ...tab, profileUrl: (_a2 = layouts == null ? void 0 : layouts[tab.name]) == null ? void 0 : _a2.url };
109125
+ });
109121
109126
  }
109122
109127
  return { renderTabs, missingRequiredData, entity, tabs };
109123
109128
  }
@@ -109245,7 +109250,7 @@ function applyTabDataIndicators({
109245
109250
  }
109246
109251
  const RenderEntity = forwardRef((props, ref) => {
109247
109252
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
109248
- const { entity, onLoadEntity, onSaveCrate, onSaveEntityTemplate, onWarning, onError, onAddNewProfileRequest } = props;
109253
+ const { entity, onLoadEntity, onSaveCrate, onSaveEntityTemplate, onWarning, onError, onAddNewProfileRequest, onRemoveProfile } = props;
109249
109254
  const state = useStateStore();
109250
109255
  const profileManager = useContext(ProfileManagerContext);
109251
109256
  const crateManager = useContext(CrateManagerContext);
@@ -109332,6 +109337,25 @@ const RenderEntity = forwardRef((props, ref) => {
109332
109337
  onError();
109333
109338
  }
109334
109339
  };
109340
+ const handleRemoveProfile = (tab) => {
109341
+ try {
109342
+ onRemoveProfile == null ? void 0 : onRemoveProfile({
109343
+ entityId: entity["@id"],
109344
+ tab: {
109345
+ name: tab.name,
109346
+ label: tab.label || tab.name,
109347
+ hasData: tab.hasData,
109348
+ missingRequiredData: tab.missingRequiredData,
109349
+ description: tab.description,
109350
+ inputs: tab.inputs,
109351
+ profileUrl: tab.profileUrl
109352
+ }
109353
+ });
109354
+ } catch (error2) {
109355
+ console.error(error2);
109356
+ onError();
109357
+ }
109358
+ };
109335
109359
  const notifySave = (property) => {
109336
109360
  setSavedProperty(property);
109337
109361
  setTimeout(() => {
@@ -109606,12 +109630,24 @@ const RenderEntity = forwardRef((props, ref) => {
109606
109630
  items: [
109607
109631
  ...tabs.map((tab) => ({
109608
109632
  key: tab.name,
109609
- label: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col w-full", children: [
109610
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center justify-between w-full", children: [
109633
+ label: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col w-full group", children: [
109634
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center justify-between w-full relative", children: [
109611
109635
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left text-base font-medium text-gray-700 describo-tab-label", children: tab.label || tab.name }),
109612
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ml-2", children: [
109636
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ml-2 flex items-center space-x-2", children: [
109613
109637
  tab.missingRequiredData && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-red-600", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FontAwesomeIcon, { icon: faCircleXmark, size: "lg" }) }),
109614
- tab.hasData && !tab.missingRequiredData && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-green-600", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FontAwesomeIcon, { icon: faCircleCheck, size: "lg" }) })
109638
+ tab.hasData && !tab.missingRequiredData && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-green-600", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FontAwesomeIcon, { icon: faCircleCheck, size: "lg" }) }),
109639
+ !(["about", "overflow", "other"].includes((tab.name || "").toLowerCase()) || ["about", "other"].includes((tab.label || tab.name || "").toLowerCase())) && /* @__PURE__ */ jsxRuntimeExports.jsx(
109640
+ Button$1,
109641
+ {
109642
+ "aria-label": "Remove profile",
109643
+ type: "text",
109644
+ onClick: (e2) => {
109645
+ e2.stopPropagation();
109646
+ handleRemoveProfile(tab);
109647
+ },
109648
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefIcon$b, { style: { color: "oklch(57.7% 0.245 27.325)" } })
109649
+ }
109650
+ )
109615
109651
  ] })
109616
109652
  ] }),
109617
109653
  tab.description && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-left text-gray-500 font-light text-xs describo-tab-description", children: tab.description })
@@ -110047,7 +110083,7 @@ class CrateManager {
110047
110083
  entity: []
110048
110084
  },
110049
110085
  invalidIdentifier: {
110050
- description: `The entity identifier (@id) is not valid. See https://github.com/describo/crate-builder-component/blob/master/README.identifiers.md for more information`,
110086
+ description: `The entity identifier (@id) is not valid.`,
110051
110087
  entity: []
110052
110088
  },
110053
110089
  clash: {
@@ -110081,7 +110117,10 @@ class CrateManager {
110081
110117
  }
110082
110118
  this.graphLength = crate["@graph"].length;
110083
110119
  for (let i = 0; i < this.graphLength; i++) {
110084
- if (crate["@graph"][i]["@id"] === "ro-crate-metadata.json") {
110120
+ const eid = crate["@graph"][i]["@id"];
110121
+ const isRootDescriptor = eid === "ro-crate-metadata.json" || typeof eid === "string" && eid.match(/^file:\/\/\.\/ro-crate-metadata\.json$/) || typeof eid === "string" && eid.match(/^\.\/ro-crate-metadata\.json$/);
110122
+ if (isRootDescriptor) {
110123
+ crate["@graph"][i]["@id"] = "ro-crate-metadata.json";
110085
110124
  this.rootDescriptor = i;
110086
110125
  if ("about" in crate["@graph"][i]) {
110087
110126
  if (Array.isArray(crate["@graph"][i].about)) {
@@ -118064,7 +118103,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
118064
118103
  }) : null
118065
118104
  );
118066
118105
  var CacheProvider = EmotionCacheContext.Provider;
118067
- const version = "0.1.10";
118106
+ const version = "0.1.12";
118068
118107
  const pkg = {
118069
118108
  version
118070
118109
  };
@@ -118099,7 +118138,8 @@ function DescriboCrateBuilder(props) {
118099
118138
  onNavigation,
118100
118139
  onSaveCrate,
118101
118140
  onSaveEntityTemplate,
118102
- onAddNewProfileRequest
118141
+ onAddNewProfileRequest,
118142
+ onRemoveProfile
118103
118143
  } = props;
118104
118144
  console.log("DescriboCrateBuilder props:", { crate, profile, entityId });
118105
118145
  const [ready, setReady] = useState(false);
@@ -118293,7 +118333,8 @@ function DescriboCrateBuilder(props) {
118293
118333
  onSaveEntityTemplate: saveEntityAsTemplate,
118294
118334
  onWarning: handleWarning,
118295
118335
  onError: handleError,
118296
- onAddNewProfileRequest: handleAddProfileRequest
118336
+ onAddNewProfileRequest: handleAddProfileRequest,
118337
+ onRemoveProfile
118297
118338
  }
118298
118339
  ) }) }) }) }) }) }),
118299
118340
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pointer-events-none fixed bottom-2 right-2 z-50 text-xs text-gray-400", children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arpproject/recrate",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
 
6
6
  "main": "./dist/recrate.es.js",