@uniformdev/mesh-sdk-react 18.9.0 → 18.10.1-alpha.7

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.esm.js CHANGED
@@ -957,7 +957,8 @@ import { useAsync, useAsyncFn as useAsyncFn2 } from "react-use";
957
957
 
958
958
  // src/components/EntrySearch/DefaultSearchRow.tsx
959
959
  import { css as css7 } from "@emotion/react";
960
- import { useEffect, useRef, useState } from "react";
960
+ import { useOutsideClick } from "@uniformdev/design-system";
961
+ import { useRef, useState } from "react";
961
962
 
962
963
  // src/components/EntrySearch/styles/DefaultSearchRow.styles.ts
963
964
  import { css as css6 } from "@emotion/react";
@@ -1001,22 +1002,11 @@ var searchRowBtn = css6`
1001
1002
  `;
1002
1003
 
1003
1004
  // src/components/EntrySearch/DefaultSearchRow.tsx
1004
- import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs8 } from "@emotion/react/jsx-runtime";
1005
+ import { jsx as jsx19, jsxs as jsxs8 } from "@emotion/react/jsx-runtime";
1005
1006
  var DefaultSearchRow = ({ result, isSelected, triggerSelection }) => {
1006
- const buttonRef = useRef(null);
1007
1007
  const popoverRef = useRef(null);
1008
1008
  const [showInfo, setShowInfo] = useState(false);
1009
- useEffect(() => {
1010
- function handleClickOutside(event) {
1011
- if (buttonRef.current && !buttonRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
1012
- setShowInfo(false);
1013
- }
1014
- }
1015
- document.addEventListener("mousedown", handleClickOutside);
1016
- return () => {
1017
- document.removeEventListener("mousedown", handleClickOutside);
1018
- };
1019
- }, [popoverRef]);
1009
+ useOutsideClick(popoverRef, () => setShowInfo(false));
1020
1010
  const click = (event) => {
1021
1011
  event.stopPropagation();
1022
1012
  setShowInfo(!showInfo);
@@ -1035,12 +1025,11 @@ var DefaultSearchRow = ({ result, isSelected, triggerSelection }) => {
1035
1025
  onClick: () => triggerSelection(),
1036
1026
  children: [
1037
1027
  result.title,
1038
- result.popoverData && isSelected ? /* @__PURE__ */ jsxs8(Fragment3, { children: [
1028
+ result.popoverData && isSelected ? /* @__PURE__ */ jsxs8("div", { ref: popoverRef, children: [
1039
1029
  /* @__PURE__ */ jsx19(
1040
1030
  "button",
1041
1031
  {
1042
1032
  type: "button",
1043
- ref: buttonRef,
1044
1033
  css: searchRowBtn,
1045
1034
  "aria-controls": "path-details",
1046
1035
  onClick: (e) => click(e),
@@ -1053,7 +1042,6 @@ var DefaultSearchRow = ({ result, isSelected, triggerSelection }) => {
1053
1042
  {
1054
1043
  id: "path-details",
1055
1044
  "aria-hidden": !showInfo,
1056
- ref: popoverRef,
1057
1045
  css: [
1058
1046
  searchRowPopover,
1059
1047
  showInfo ? css7`
@@ -1089,8 +1077,8 @@ var DefaultSearchRow = ({ result, isSelected, triggerSelection }) => {
1089
1077
 
1090
1078
  // src/components/EntrySearch/DefaultSelectedItem.tsx
1091
1079
  import { css as css9 } from "@emotion/react";
1092
- import { Icon as Icon2 } from "@uniformdev/design-system";
1093
- import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
1080
+ import { Icon as Icon2, useOutsideClick as useOutsideClick2 } from "@uniformdev/design-system";
1081
+ import { useEffect, useRef as useRef2, useState as useState2 } from "react";
1094
1082
  import { CgClose as CgClose2, CgInfo } from "react-icons/cg";
1095
1083
  import { format as timeAgo } from "timeago.js";
1096
1084
 
@@ -1148,8 +1136,9 @@ var selectItemPopover = css8`
1148
1136
  border-radius: var(--rounded-base);
1149
1137
  border-left: 4px solid var(--brand-secondary-3);
1150
1138
  box-shadow: var(--shadow-base);
1151
- position: fixed;
1152
- padding: var(--spacing-base);
1139
+ position: absolute;
1140
+ top: var(--spacing-base);
1141
+ right: var(--spacing-xl);
1153
1142
  z-index: var(--z-10);
1154
1143
  width: max-content;
1155
1144
  `;
@@ -1189,7 +1178,7 @@ var selectItemLinkBtn = css8`
1189
1178
  `;
1190
1179
 
1191
1180
  // src/components/EntrySearch/DefaultSelectedItem.tsx
1192
- import { Fragment as Fragment4, jsx as jsx20, jsxs as jsxs9 } from "@emotion/react/jsx-runtime";
1181
+ import { jsx as jsx20, jsxs as jsxs9 } from "@emotion/react/jsx-runtime";
1193
1182
  var DefaultSelectedItem = ({
1194
1183
  selectedItem,
1195
1184
  logoIcon,
@@ -1197,37 +1186,18 @@ var DefaultSelectedItem = ({
1197
1186
  onEditClosed
1198
1187
  }) => {
1199
1188
  var _a;
1200
- const buttonRef = useRef2(null);
1201
1189
  const popoverRef = useRef2(null);
1202
1190
  const [showInfo, setShowInfo] = useState2(false);
1203
- useEffect2(() => {
1204
- const eventHandler = (event) => {
1205
- if (buttonRef.current && !buttonRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
1206
- setShowInfo(false);
1207
- }
1208
- };
1191
+ useOutsideClick2(popoverRef, () => setShowInfo(false));
1192
+ useEffect(() => {
1209
1193
  const resizeHandler = () => {
1210
1194
  setShowInfo(false);
1211
1195
  };
1212
1196
  window.addEventListener("resize", resizeHandler, true);
1213
- document.addEventListener("scroll", eventHandler, true);
1214
- document.addEventListener("mousedown", eventHandler);
1215
1197
  return () => {
1216
1198
  window.removeEventListener("resize", resizeHandler, true);
1217
- document.removeEventListener("scroll", eventHandler, true);
1218
- document.removeEventListener("mousedown", eventHandler);
1219
1199
  };
1220
1200
  }, [popoverRef]);
1221
- const popoverClick = () => {
1222
- var _a2;
1223
- setShowInfo(!showInfo);
1224
- if (popoverRef.current && buttonRef.current) {
1225
- const buttonPos = (_a2 = buttonRef == null ? void 0 : buttonRef.current) == null ? void 0 : _a2.getBoundingClientRect();
1226
- const popoverWidth = popoverRef.current.offsetWidth;
1227
- popoverRef.current.style["top"] = `${buttonPos.top + 30}px`;
1228
- popoverRef.current.style["left"] = `${buttonPos.left - popoverWidth + 30}px`;
1229
- }
1230
- };
1231
1201
  return /* @__PURE__ */ jsx20("div", { css: selectedItemContainer, children: /* @__PURE__ */ jsxs9("div", { css: selectedItemInner, children: [
1232
1202
  /* @__PURE__ */ jsxs9("div", { css: selectedItemDetails, children: [
1233
1203
  /* @__PURE__ */ jsxs9("div", { css: selectedItemCopy, children: [
@@ -1245,18 +1215,17 @@ var DefaultSelectedItem = ({
1245
1215
  children: selectedItem.title || selectedItem.id || ""
1246
1216
  }
1247
1217
  ),
1248
- selectedItem.popoverData ? /* @__PURE__ */ jsxs9(Fragment4, { children: [
1218
+ selectedItem.popoverData ? /* @__PURE__ */ jsxs9("div", { ref: popoverRef, children: [
1249
1219
  /* @__PURE__ */ jsx20(
1250
1220
  "button",
1251
1221
  {
1252
1222
  type: "button",
1253
- ref: buttonRef,
1254
1223
  css: css9`
1255
1224
  margin: calc(var(--spacing-xs) * -1) 0 calc(var(--spacing-xs) * -1) var(--spacing-sm);
1256
1225
  `,
1257
1226
  "aria-controls": "path-details",
1258
1227
  "aria-expanded": showInfo,
1259
- onClick: popoverClick,
1228
+ onClick: () => setShowInfo(!showInfo),
1260
1229
  children: /* @__PURE__ */ jsx20(
1261
1230
  Icon2,
1262
1231
  {
@@ -1275,7 +1244,6 @@ var DefaultSelectedItem = ({
1275
1244
  {
1276
1245
  id: "path-details",
1277
1246
  "aria-hidden": !showInfo,
1278
- ref: popoverRef,
1279
1247
  css: [
1280
1248
  selectItemPopover,
1281
1249
  showInfo ? css9`
@@ -1411,14 +1379,14 @@ import { useDebounce as useDebounce2 } from "react-use";
1411
1379
  import { v4 } from "uuid";
1412
1380
 
1413
1381
  // src/hooks/useLoadingDelay.ts
1414
- import { useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
1382
+ import { useEffect as useEffect2, useRef as useRef3, useState as useState3 } from "react";
1415
1383
  function useLoadingDelay(loading, { delay = 500, minDuration = 200 } = {
1416
1384
  delay: 500,
1417
1385
  minDuration: 200
1418
1386
  }) {
1419
1387
  const [state, setState] = useState3("IDLE");
1420
1388
  const timeout = useRef3(void 0);
1421
- useEffect3(() => {
1389
+ useEffect2(() => {
1422
1390
  if (loading && state === "IDLE") {
1423
1391
  clearTimeout(timeout.current);
1424
1392
  timeout.current = setTimeout(() => {
@@ -1437,7 +1405,7 @@ function useLoadingDelay(loading, { delay = 500, minDuration = 200 } = {
1437
1405
  setState("IDLE");
1438
1406
  }
1439
1407
  }, [loading, state, delay, minDuration]);
1440
- useEffect3(() => {
1408
+ useEffect2(() => {
1441
1409
  return () => clearTimeout(timeout.current);
1442
1410
  }, []);
1443
1411
  return state === "DISPLAY" || state === "EXPIRE";
@@ -1555,7 +1523,7 @@ var badgeIcon = css10`
1555
1523
  `;
1556
1524
 
1557
1525
  // src/components/EntrySearch/EntrySearch.tsx
1558
- import { Fragment as Fragment5, jsx as jsx21, jsxs as jsxs10 } from "@emotion/react/jsx-runtime";
1526
+ import { Fragment as Fragment3, jsx as jsx21, jsxs as jsxs10 } from "@emotion/react/jsx-runtime";
1559
1527
  var DefaultNoResults = ({ searchText, selectedContentType }) => {
1560
1528
  let message = "No content found";
1561
1529
  if (selectedContentType && selectedContentType !== "any") {
@@ -1714,7 +1682,7 @@ var EntrySearch = ({
1714
1682
  margin-block: var(--spacing-base);
1715
1683
  `,
1716
1684
  children: [
1717
- showSearchBox ? /* @__PURE__ */ jsxs10(Fragment5, { children: [
1685
+ showSearchBox ? /* @__PURE__ */ jsxs10(Fragment3, { children: [
1718
1686
  /* @__PURE__ */ jsx21("div", { css: entrySearchWrapper, "data-test-id": "component-search", children: /* @__PURE__ */ jsxs10(
1719
1687
  "button",
1720
1688
  {
@@ -2375,7 +2343,7 @@ var useProductSearchContext = () => {
2375
2343
  // src/components/dam/DamSelectedItem.tsx
2376
2344
  import { css as css17 } from "@emotion/react";
2377
2345
  import { Icon as Icon4 } from "@uniformdev/design-system";
2378
- import { useEffect as useEffect5, useRef as useRef6, useState as useState5 } from "react";
2346
+ import { useEffect as useEffect4, useRef as useRef6, useState as useState5 } from "react";
2379
2347
  import { CgClose as CgClose4, CgInfo as CgInfo2 } from "react-icons/cg";
2380
2348
  import { format as timeAgo2 } from "timeago.js";
2381
2349
 
@@ -2423,8 +2391,9 @@ var damSelectedItemPopover = css16`
2423
2391
  border-radius: var(--rounded-base);
2424
2392
  border-left: 4px solid var(--brand-secondary-3);
2425
2393
  box-shadow: var(--shadow-base);
2426
- position: fixed;
2427
- padding: var(--spacing-base);
2394
+ position: absolute;
2395
+ top: var(--spacing-base);
2396
+ right: var(--spacing-xl);
2428
2397
  z-index: var(--z-10);
2429
2398
  width: max-content;
2430
2399
  `;
@@ -2481,7 +2450,7 @@ var damSelectItemImage = css16`
2481
2450
  `;
2482
2451
 
2483
2452
  // src/components/dam/DamSelectedItem.tsx
2484
- import { Fragment as Fragment6, jsx as jsx25, jsxs as jsxs14 } from "@emotion/react/jsx-runtime";
2453
+ import { jsx as jsx25, jsxs as jsxs14 } from "@emotion/react/jsx-runtime";
2485
2454
  function DamSelectedItem({
2486
2455
  selectedItem,
2487
2456
  onDeselect,
@@ -2489,35 +2458,17 @@ function DamSelectedItem({
2489
2458
  logoIcon,
2490
2459
  itemDetailsRendererComponent
2491
2460
  }) {
2492
- const buttonRef = useRef6(null);
2493
2461
  const popoverRef = useRef6(null);
2494
2462
  const [showInfo, setShowInfo] = useState5(false);
2495
- useEffect5(() => {
2496
- const eventHandler = (event) => {
2497
- if (buttonRef.current && !buttonRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
2498
- setShowInfo(false);
2499
- }
2500
- };
2463
+ useEffect4(() => {
2501
2464
  const resizeHandler = () => {
2502
2465
  setShowInfo(false);
2503
2466
  };
2504
2467
  window.addEventListener("resize", resizeHandler, true);
2505
- document.addEventListener("scroll", eventHandler, true);
2506
- document.addEventListener("mousedown", eventHandler);
2507
2468
  return () => {
2508
2469
  window.removeEventListener("resize", resizeHandler, true);
2509
- document.removeEventListener("scroll", eventHandler, true);
2510
- document.removeEventListener("mousedown", eventHandler);
2511
2470
  };
2512
2471
  }, [popoverRef]);
2513
- const popoverClick = () => {
2514
- var _a;
2515
- setShowInfo(!showInfo);
2516
- if (popoverRef.current && buttonRef.current) {
2517
- const buttonPos = (_a = buttonRef == null ? void 0 : buttonRef.current) == null ? void 0 : _a.getBoundingClientRect();
2518
- popoverRef.current.style["top"] = `${buttonPos.top + 30}px`;
2519
- }
2520
- };
2521
2472
  const ResolvedItemDetailsRendererComponent = itemDetailsRendererComponent != null ? itemDetailsRendererComponent : DefaultDamItemRenderer;
2522
2473
  return /* @__PURE__ */ jsx25(
2523
2474
  "div",
@@ -2540,16 +2491,15 @@ function DamSelectedItem({
2540
2491
  children: selectedItem.title || selectedItem.id || ""
2541
2492
  }
2542
2493
  ),
2543
- selectedItem.popoverData ? /* @__PURE__ */ jsxs14(Fragment6, { children: [
2494
+ selectedItem.popoverData ? /* @__PURE__ */ jsxs14("div", { ref: popoverRef, children: [
2544
2495
  /* @__PURE__ */ jsx25(
2545
2496
  "button",
2546
2497
  {
2547
2498
  type: "button",
2548
- ref: buttonRef,
2549
2499
  css: damSelectedItemInfoBtn,
2550
2500
  "aria-controls": "path-details",
2551
2501
  "aria-expanded": showInfo,
2552
- onClick: popoverClick,
2502
+ onClick: () => setShowInfo(!showInfo),
2553
2503
  children: /* @__PURE__ */ jsx25(
2554
2504
  Icon4,
2555
2505
  {
@@ -2568,7 +2518,6 @@ function DamSelectedItem({
2568
2518
  {
2569
2519
  id: "path-details",
2570
2520
  "aria-hidden": !showInfo,
2571
- ref: popoverRef,
2572
2521
  css: [
2573
2522
  damSelectedItemPopover,
2574
2523
  showInfo ? css17`
@@ -3421,7 +3370,7 @@ function useVariables() {
3421
3370
  }
3422
3371
 
3423
3372
  // src/components/Variables/InputVariables.tsx
3424
- import { Fragment as Fragment7, jsx as jsx30, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
3373
+ import { Fragment as Fragment4, jsx as jsx30, jsxs as jsxs18 } from "@emotion/react/jsx-runtime";
3425
3374
  function cleanTagifyValue(rawValue) {
3426
3375
  return rawValue.replace(/\${{.*?"value":"([^"]+)".*?}}/g, "${$1}").replace(/[\r\n]+/g, "");
3427
3376
  }
@@ -3474,7 +3423,7 @@ function InputVariables({
3474
3423
  });
3475
3424
  }
3476
3425
  }, []);
3477
- return /* @__PURE__ */ jsxs18(Fragment7, { children: [
3426
+ return /* @__PURE__ */ jsxs18(Fragment4, { children: [
3478
3427
  /* @__PURE__ */ jsx30(Global, { styles: tagifyStyles }),
3479
3428
  /* @__PURE__ */ jsx30(
3480
3429
  Tags,
@@ -3604,7 +3553,7 @@ function variablesToList(variables) {
3604
3553
  }
3605
3554
 
3606
3555
  // src/components/Variables/VariablesList.tsx
3607
- import { Fragment as Fragment8, jsx as jsx31, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
3556
+ import { Fragment as Fragment5, jsx as jsx31, jsxs as jsxs19 } from "@emotion/react/jsx-runtime";
3608
3557
  function VariablesList() {
3609
3558
  const { variables, dispatch } = useVariables();
3610
3559
  const sorted = variablesToList(variables);
@@ -3625,7 +3574,7 @@ function VariablesList() {
3625
3574
  return result;
3626
3575
  }
3627
3576
  };
3628
- return /* @__PURE__ */ jsxs19(Fragment8, { children: [
3577
+ return /* @__PURE__ */ jsxs19(Fragment5, { children: [
3629
3578
  /* @__PURE__ */ jsx31(DragDropContext2, { onDragEnd: (res) => onDragEnd(res), children: /* @__PURE__ */ jsx31(Droppable2, { droppableId: "variables-table", children: (provided) => /* @__PURE__ */ jsxs19(Table, { ...provided.droppableProps, ref: provided.innerRef, children: [
3630
3579
  /* @__PURE__ */ jsx31(TableHead, { children: /* @__PURE__ */ jsxs19(TableRow, { children: [
3631
3580
  /* @__PURE__ */ jsx31(TableCellHead, { children: "Name" }),
@@ -4151,7 +4100,7 @@ function decodeVariablesInUrlEncodedString(string, varValues) {
4151
4100
  }
4152
4101
 
4153
4102
  // src/components/Request/RequestUrl.tsx
4154
- import { Fragment as Fragment9, jsx as jsx39, jsxs as jsxs24 } from "@emotion/react/jsx-runtime";
4103
+ import { Fragment as Fragment6, jsx as jsx39, jsxs as jsxs24 } from "@emotion/react/jsx-runtime";
4155
4104
  function RequestUrl() {
4156
4105
  var _a, _b;
4157
4106
  const { variables } = useVariables();
@@ -4175,7 +4124,7 @@ function RequestUrl() {
4175
4124
  request.baseRequest ? /* @__PURE__ */ jsx39("span", { children: (_b = request.baseRequest) == null ? void 0 : _b.baseUrl }) : null,
4176
4125
  /* @__PURE__ */ jsxs24("span", { css: { fontWeight: request.baseRequest ? "bold" : "inherit" }, children: [
4177
4126
  urlEncodeRequestUrl(request.relativeUrl, variables),
4178
- mergedParameters.length > 0 ? /* @__PURE__ */ jsxs24(Fragment9, { children: [
4127
+ mergedParameters.length > 0 ? /* @__PURE__ */ jsxs24(Fragment6, { children: [
4179
4128
  "?",
4180
4129
  mergedParameters.map((param, index) => {
4181
4130
  const encoded = urlEncodeRequestParameter(param, variables);
@@ -4377,12 +4326,12 @@ import { LoadingIndicator as LoadingIndicator2, Theme as Theme2 } from "@uniform
4377
4326
 
4378
4327
  // src/hooks/useInitializeUniformMeshSdk.ts
4379
4328
  import { initializeUniformMeshSDK } from "@uniformdev/mesh-sdk";
4380
- import { useEffect as useEffect7, useRef as useRef9, useState as useState9 } from "react";
4329
+ import { useEffect as useEffect6, useRef as useRef9, useState as useState9 } from "react";
4381
4330
  var useInitializeUniformMeshSdk = ({ autoResizingDisabled } = {}) => {
4382
4331
  const [error, setError] = useState9();
4383
4332
  const [sdk, setSdk] = useState9();
4384
4333
  const initializationInProgress = useRef9(false);
4385
- useEffect7(
4334
+ useEffect6(
4386
4335
  () => {
4387
4336
  if (typeof window === "undefined" || sdk) {
4388
4337
  return;