@xras/ui 0.10.0 → 0.10.1

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/xras-ui.js CHANGED
@@ -26674,33 +26674,37 @@ function lO({ onClose: t }) {
26674
26674
  lO.propTypes = {
26675
26675
  onClose: Pe.func.isRequired
26676
26676
  };
26677
- function UH({ availableResources: t, relativeUrlRoot: r }) {
26678
- const i = k.useMemo(
26677
+ function UH({
26678
+ availableResources: t,
26679
+ canAdd: r = !1,
26680
+ relativeUrlRoot: i
26681
+ }) {
26682
+ const l = k.useMemo(
26679
26683
  () => xH(t),
26680
26684
  [t]
26681
- ), [l, u] = k.useState(i), [d, v] = k.useState(!1), h = k.useRef(null), y = k.useRef(null);
26685
+ ), [u, d] = k.useState(l), [v, h] = k.useState(!1), y = k.useRef(null), x = k.useRef(null);
26682
26686
  k.useEffect(() => {
26683
- u(i);
26684
- }, [i]);
26685
- const x = (R, j) => {
26686
- h.current = j;
26687
- }, C = (R, j) => {
26688
- if (R.preventDefault(), h.current === j)
26687
+ d(l);
26688
+ }, [l]);
26689
+ const C = (j, N) => {
26690
+ y.current = N;
26691
+ }, w = (j, N) => {
26692
+ if (j.preventDefault(), y.current === N)
26689
26693
  return;
26690
- const N = [...l], T = N[h.current];
26691
- N.splice(h.current, 1), N.splice(j, 0, T), h.current = j, u(N);
26692
- const { clientY: I } = R, M = 130;
26693
- I < M ? DI(-1, y) : window.innerHeight - I < M ? DI(1, y) : $E(y);
26694
- }, w = () => {
26695
- h.current = null, $E(y), bH(r, l);
26694
+ const T = [...u], I = T[y.current];
26695
+ T.splice(y.current, 1), T.splice(N, 0, I), y.current = N, d(T);
26696
+ const { clientY: M } = j, P = 130;
26697
+ M < P ? DI(-1, x) : window.innerHeight - M < P ? DI(1, x) : $E(x);
26698
+ }, R = () => {
26699
+ y.current = null, $E(x), bH(i, u);
26696
26700
  };
26697
- return k.useEffect(() => () => $E(y), []), /* @__PURE__ */ m.jsxs(m.Fragment, { children: [
26701
+ return k.useEffect(() => () => $E(x), []), /* @__PURE__ */ m.jsxs(m.Fragment, { children: [
26698
26702
  /* @__PURE__ */ m.jsxs("div", { className: ls["resources-container"], children: [
26699
- /* @__PURE__ */ m.jsx(
26703
+ r && /* @__PURE__ */ m.jsx(
26700
26704
  "button",
26701
26705
  {
26702
26706
  className: "btn btn-primary pull-right",
26703
- onClick: () => v(!0),
26707
+ onClick: () => h(!0),
26704
26708
  children: "Add a Resource from CIDeR"
26705
26709
  }
26706
26710
  ),
@@ -26711,32 +26715,32 @@ function UH({ availableResources: t, relativeUrlRoot: r }) {
26711
26715
  /* @__PURE__ */ m.jsx("span", { className: ls["header-name"], children: "Resource Name" }),
26712
26716
  /* @__PURE__ */ m.jsx("span", { className: ls["header-repo"], children: "Repository Key" })
26713
26717
  ] }),
26714
- l.map((R, j) => /* @__PURE__ */ m.jsxs(
26718
+ u.map((j, N) => /* @__PURE__ */ m.jsxs(
26715
26719
  "div",
26716
26720
  {
26717
26721
  className: `${ls["resources-item"]}`,
26718
26722
  draggable: !0,
26719
- onDragStart: (N) => x(N, j),
26720
- onDragOver: (N) => C(N, j),
26721
- onDrop: w,
26723
+ onDragStart: (T) => C(T, N),
26724
+ onDragOver: (T) => w(T, N),
26725
+ onDrop: R,
26722
26726
  children: [
26723
26727
  /* @__PURE__ */ m.jsx("span", { className: ls["drag-handle"] }),
26724
26728
  /* @__PURE__ */ m.jsx("span", { className: ls["resource-name"], children: /* @__PURE__ */ m.jsx(
26725
26729
  "a",
26726
26730
  {
26727
- href: `${r}/resources/${R.resource_id}`,
26731
+ href: `${i}/resources/${j.resource_id}`,
26728
26732
  className: ls["resource-link"],
26729
- children: R.display_resource_name
26733
+ children: j.display_resource_name
26730
26734
  }
26731
26735
  ) }),
26732
- /* @__PURE__ */ m.jsx("span", { className: ls["resource-repo"], children: R.resource_repository_key || "N/A" })
26736
+ /* @__PURE__ */ m.jsx("span", { className: ls["resource-repo"], children: j.resource_repository_key || "N/A" })
26733
26737
  ]
26734
26738
  },
26735
- R.resource_id
26739
+ j.resource_id
26736
26740
  ))
26737
26741
  ] })
26738
26742
  ] }),
26739
- d && /* @__PURE__ */ m.jsx(lO, { onClose: () => v(!1) })
26743
+ v && /* @__PURE__ */ m.jsx(lO, { onClose: () => h(!1) })
26740
26744
  ] });
26741
26745
  }
26742
26746
  function nh() {
@@ -41056,19 +41060,30 @@ const z8 = (t) => {
41056
41060
  /* @__PURE__ */ m.jsx("div", { className: "col-sm-8", children: /* @__PURE__ */ m.jsx(Tq, {}) })
41057
41061
  ] }) }) : /* @__PURE__ */ m.jsx(nh, {});
41058
41062
  };
41059
- function Bq(t, { bootstrapFonts: r = !0, bootstrapVariables: i = !0, access: l = !1, baseUrl: u = null } = {}) {
41063
+ function Bq(t, {
41064
+ bootstrapFonts: r = !0,
41065
+ bootstrapVariables: i = !0,
41066
+ access: l = !1,
41067
+ baseUrl: u = null
41068
+ } = {}) {
41060
41069
  const d = t.attachShadow({ mode: "open" }), v = document.createElement("div"), h = document.createElement("div"), y = document.createElement("div"), x = document.createElement("div"), C = document.createElement("link"), w = document.createElement("link"), R = document.createElement("link");
41061
41070
  return u = u ?? import.meta.url.replace(/\/[^/]+$/, ""), C.rel = "stylesheet", C.href = `${u}/bootstrap.css`, w.rel = "stylesheet", w.href = `${u}/xras-ui.css`, R.rel = "stylesheet", R.href = `${u}/access.css`, y.appendChild(x), h.appendChild(y), v.appendChild(h), d.appendChild(C), d.appendChild(w), d.appendChild(R), d.appendChild(v), v.classList.add("bootstrap"), i && h.classList.add("bootstrap-variables"), r && (y.classList.add("bootstrap-fonts"), y.setAttribute("data-bs-theme", "light")), x;
41062
41071
  }
41063
41072
  function zq({ target: t }) {
41064
41073
  Xi.createRoot(t).render(/* @__PURE__ */ m.jsx(yH, {}));
41065
41074
  }
41066
- function $q({ target: t, availableResources: r, relativeUrlRoot: i }) {
41067
- Xi.createRoot(t).render(
41075
+ function $q({
41076
+ availableResources: t,
41077
+ canAdd: r,
41078
+ relativeUrlRoot: i,
41079
+ target: l
41080
+ }) {
41081
+ Xi.createRoot(l).render(
41068
41082
  /* @__PURE__ */ m.jsx(
41069
41083
  UH,
41070
41084
  {
41071
- availableResources: r,
41085
+ availableResources: t,
41086
+ canAdd: r,
41072
41087
  relativeUrlRoot: i
41073
41088
  }
41074
41089
  )
@@ -41140,14 +41155,26 @@ function Xq({ target: t, routes: r }) {
41140
41155
  ) })
41141
41156
  );
41142
41157
  }
41143
- function Yq({ target: t, catalogSources: r, onRamps: i, baseUrl: l }) {
41158
+ function Yq({
41159
+ target: t,
41160
+ catalogSources: r,
41161
+ onRamps: i,
41162
+ baseUrl: l
41163
+ }) {
41144
41164
  const u = Pm({
41145
41165
  reducer: {
41146
41166
  resourceCatalog: J8
41147
41167
  }
41148
41168
  });
41149
41169
  Xi.createRoot(t).render(
41150
- /* @__PURE__ */ m.jsx(th, { store: u, children: /* @__PURE__ */ m.jsx(vq, { catalogSources: r, onRamps: i, baseUrl: l }) })
41170
+ /* @__PURE__ */ m.jsx(th, { store: u, children: /* @__PURE__ */ m.jsx(
41171
+ vq,
41172
+ {
41173
+ catalogSources: r,
41174
+ onRamps: i,
41175
+ baseUrl: l
41176
+ }
41177
+ ) })
41151
41178
  );
41152
41179
  }
41153
41180
  function Zq({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xras/ui",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "User interface components for XRAS",
5
5
  "repository": "github:access-ci-org/xras-ui",
6
6
  "license": "Apache-2.0",