@procore/saved-views 5.0.0-alpha.4 → 5.0.0-alpha.90

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.
@@ -2017,9 +2017,9 @@ var require_dist = __commonJS({
2017
2017
  }
2018
2018
  });
2019
2019
 
2020
- // node_modules/react-is/cjs/react-is.production.min.js
2020
+ // ../../node_modules/styled-components/node_modules/react-is/cjs/react-is.production.min.js
2021
2021
  var require_react_is_production_min = __commonJS({
2022
- "node_modules/react-is/cjs/react-is.production.min.js"(exports) {
2022
+ "../../node_modules/styled-components/node_modules/react-is/cjs/react-is.production.min.js"(exports) {
2023
2023
  "use strict";
2024
2024
  var b2 = 60103;
2025
2025
  var c2 = 60106;
@@ -2155,9 +2155,9 @@ var require_react_is_production_min = __commonJS({
2155
2155
  }
2156
2156
  });
2157
2157
 
2158
- // node_modules/react-is/cjs/react-is.development.js
2158
+ // ../../node_modules/styled-components/node_modules/react-is/cjs/react-is.development.js
2159
2159
  var require_react_is_development = __commonJS({
2160
- "node_modules/react-is/cjs/react-is.development.js"(exports) {
2160
+ "../../node_modules/styled-components/node_modules/react-is/cjs/react-is.development.js"(exports) {
2161
2161
  "use strict";
2162
2162
  if (process.env.NODE_ENV !== "production") {
2163
2163
  (function() {
@@ -2347,9 +2347,9 @@ var require_react_is_development = __commonJS({
2347
2347
  }
2348
2348
  });
2349
2349
 
2350
- // node_modules/react-is/index.js
2350
+ // ../../node_modules/styled-components/node_modules/react-is/index.js
2351
2351
  var require_react_is = __commonJS({
2352
- "node_modules/react-is/index.js"(exports, module) {
2352
+ "../../node_modules/styled-components/node_modules/react-is/index.js"(exports, module) {
2353
2353
  "use strict";
2354
2354
  if (process.env.NODE_ENV === "production") {
2355
2355
  module.exports = require_react_is_production_min();
@@ -9698,7 +9698,7 @@ function __rest(s2, e2) {
9698
9698
  return t2;
9699
9699
  }
9700
9700
 
9701
- // ../../node_modules/@procore/core-icons/dist/Icon.js
9701
+ // node_modules/@procore/core-icons/dist/Icon.js
9702
9702
  import * as React from "react";
9703
9703
  function getSize(size) {
9704
9704
  if (size === "sm") {
@@ -9717,7 +9717,7 @@ function Icon(_a) {
9717
9717
  return React.isValidElement(children) ? React.cloneElement(children, __assign(__assign({ "aria-hidden": true, "data-qa": "ci-".concat(props.name) }, props), { width: getSize(props.size), height: getSize(props.size), focusable: false, style: __assign(__assign({}, props.style), { flex: "0 0 auto" }) })) : null;
9718
9718
  }
9719
9719
 
9720
- // ../../node_modules/@procore/core-icons/dist/icons/Building.js
9720
+ // node_modules/@procore/core-icons/dist/icons/Building.js
9721
9721
  import * as React2 from "react";
9722
9722
  var Building = React2.forwardRef(function Building2(props, ref) {
9723
9723
  return React2.createElement(
@@ -9733,7 +9733,7 @@ var Building = React2.forwardRef(function Building2(props, ref) {
9733
9733
  Building.displayName = "Building";
9734
9734
  var Building_default = Building;
9735
9735
 
9736
- // ../../node_modules/@procore/core-icons/dist/icons/ChevronDown.js
9736
+ // node_modules/@procore/core-icons/dist/icons/ChevronDown.js
9737
9737
  import * as React3 from "react";
9738
9738
  var ChevronDown = React3.forwardRef(function ChevronDown2(props, ref) {
9739
9739
  return React3.createElement(
@@ -9749,7 +9749,7 @@ var ChevronDown = React3.forwardRef(function ChevronDown2(props, ref) {
9749
9749
  ChevronDown.displayName = "ChevronDown";
9750
9750
  var ChevronDown_default = ChevronDown;
9751
9751
 
9752
- // ../../node_modules/@procore/core-icons/dist/icons/ChevronRight.js
9752
+ // node_modules/@procore/core-icons/dist/icons/ChevronRight.js
9753
9753
  import * as React4 from "react";
9754
9754
  var ChevronRight = React4.forwardRef(function ChevronRight2(props, ref) {
9755
9755
  return React4.createElement(
@@ -9765,7 +9765,7 @@ var ChevronRight = React4.forwardRef(function ChevronRight2(props, ref) {
9765
9765
  ChevronRight.displayName = "ChevronRight";
9766
9766
  var ChevronRight_default = ChevronRight;
9767
9767
 
9768
- // ../../node_modules/@procore/core-icons/dist/icons/Excavator.js
9768
+ // node_modules/@procore/core-icons/dist/icons/Excavator.js
9769
9769
  import * as React5 from "react";
9770
9770
  var Excavator = React5.forwardRef(function Excavator2(props, ref) {
9771
9771
  return React5.createElement(
@@ -9782,7 +9782,7 @@ var Excavator = React5.forwardRef(function Excavator2(props, ref) {
9782
9782
  Excavator.displayName = "Excavator";
9783
9783
  var Excavator_default = Excavator;
9784
9784
 
9785
- // ../../node_modules/@procore/core-icons/dist/icons/ExpandSidebar.js
9785
+ // node_modules/@procore/core-icons/dist/icons/ExpandSidebar.js
9786
9786
  import * as React6 from "react";
9787
9787
  var ExpandSidebar = React6.forwardRef(function ExpandSidebar2(props, ref) {
9788
9788
  return React6.createElement(
@@ -9800,7 +9800,7 @@ var ExpandSidebar = React6.forwardRef(function ExpandSidebar2(props, ref) {
9800
9800
  ExpandSidebar.displayName = "ExpandSidebar";
9801
9801
  var ExpandSidebar_default = ExpandSidebar;
9802
9802
 
9803
- // ../../node_modules/@procore/core-icons/dist/icons/Help.js
9803
+ // node_modules/@procore/core-icons/dist/icons/Help.js
9804
9804
  import * as React7 from "react";
9805
9805
  var Help = React7.forwardRef(function Help2(props, ref) {
9806
9806
  return React7.createElement(
@@ -9816,7 +9816,7 @@ var Help = React7.forwardRef(function Help2(props, ref) {
9816
9816
  Help.displayName = "Help";
9817
9817
  var Help_default = Help;
9818
9818
 
9819
- // ../../node_modules/@procore/core-icons/dist/icons/Person.js
9819
+ // node_modules/@procore/core-icons/dist/icons/Person.js
9820
9820
  import * as React8 from "react";
9821
9821
  var Person = React8.forwardRef(function Person2(props, ref) {
9822
9822
  return React8.createElement(
@@ -9832,7 +9832,7 @@ var Person = React8.forwardRef(function Person2(props, ref) {
9832
9832
  Person.displayName = "Person";
9833
9833
  var Person_default = Person;
9834
9834
 
9835
- // ../../node_modules/@procore/core-icons/dist/icons/Plus.js
9835
+ // node_modules/@procore/core-icons/dist/icons/Plus.js
9836
9836
  import * as React9 from "react";
9837
9837
  var Plus = React9.forwardRef(function Plus2(props, ref) {
9838
9838
  return React9.createElement(
@@ -9852,7 +9852,7 @@ var Plus_default = Plus;
9852
9852
  import { Button } from "@procore/core-react";
9853
9853
  import React11 from "react";
9854
9854
 
9855
- // node_modules/styled-components/dist/styled-components.esm.js
9855
+ // ../../node_modules/styled-components/dist/styled-components.esm.js
9856
9856
  var import_react_is = __toESM(require_react_is());
9857
9857
  var import_shallowequal = __toESM(require_shallowequal());
9858
9858
  import r, { useState as o, useContext as s, useMemo as i, useEffect as a, useRef as c, createElement as u } from "react";
@@ -10407,7 +10407,7 @@ function memoize(fn) {
10407
10407
  };
10408
10408
  }
10409
10409
 
10410
- // ../../node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js
10410
+ // ../../node_modules/styled-components/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js
10411
10411
  var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
10412
10412
  var isPropValid = /* @__PURE__ */ memoize(
10413
10413
  function(prop) {
@@ -10416,7 +10416,7 @@ var isPropValid = /* @__PURE__ */ memoize(
10416
10416
  /* Z+1 */
10417
10417
  );
10418
10418
 
10419
- // node_modules/styled-components/dist/styled-components.esm.js
10419
+ // ../../node_modules/styled-components/dist/styled-components.esm.js
10420
10420
  var import_hoist_non_react_statics = __toESM(require_hoist_non_react_statics_cjs());
10421
10421
  function m() {
10422
10422
  return (m = Object.assign || function(e2) {
@@ -11264,14 +11264,165 @@ import {
11264
11264
  Flex as Flex3,
11265
11265
  UNSAFE_Menu as MenuImperative,
11266
11266
  spacing as spacing2,
11267
- useI18nContext as useI18nContext4
11267
+ useI18nContext as useI18nContext5
11268
11268
  } from "@procore/core-react";
11269
11269
  import { useToastAlertContext } from "@procore/toast-alert";
11270
11270
  import React15 from "react";
11271
11271
 
11272
+ // node_modules/@procore/core-http/dist/modern/index.js
11273
+ function getCSRFToken() {
11274
+ const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
11275
+ return token ? decodeURIComponent(token.pop() || "") : "";
11276
+ }
11277
+ function getCSRFHeader() {
11278
+ const csrfToken = getCSRFToken();
11279
+ return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
11280
+ }
11281
+ function removeLeadingSlash(url) {
11282
+ return url.startsWith("/") ? url.substring(1, url.length) : url;
11283
+ }
11284
+ function removeTrailingSlash(url) {
11285
+ return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
11286
+ }
11287
+ function applyBaseUrl(url, baseUrl) {
11288
+ return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
11289
+ }
11290
+ function getOptions({ headers, ...options }) {
11291
+ const opts = {
11292
+ credentials: "same-origin",
11293
+ headers: {
11294
+ ...getCSRFHeader(),
11295
+ ...headers
11296
+ },
11297
+ mode: "same-origin",
11298
+ ...options
11299
+ };
11300
+ return opts;
11301
+ }
11302
+ function getUrl(url, baseUrl) {
11303
+ return baseUrl ? applyBaseUrl(url, baseUrl) : url;
11304
+ }
11305
+ function request(url, { baseUrl, ...options } = {}) {
11306
+ return fetch(getUrl(url, baseUrl), getOptions(options));
11307
+ }
11308
+ function requestJSON(url, requestParams = {}) {
11309
+ return request(url, requestParams).then(
11310
+ (response) => response.json()
11311
+ );
11312
+ }
11313
+
11314
+ // src/utils/Api/queries.ts
11315
+ import { useQuery } from "@tanstack/react-query";
11316
+
11317
+ // src/utils/Api/queriesHandler.ts
11318
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
11319
+ import { useI18nContext as useI18nContext3 } from "@procore/core-react";
11320
+ var useApiRequest = (props, method, mutationKey) => {
11321
+ const { projectId, companyId, domain, tableName } = props;
11322
+ const queryClient2 = useQueryClient();
11323
+ const { locale: locale2 } = useI18nContext3();
11324
+ return useMutation({
11325
+ mutationKey,
11326
+ mutationFn: async (savedView) => {
11327
+ let url = "";
11328
+ if (method === "DELETE" || method === "PUT") {
11329
+ url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.id}?permissions_domain=${domain}`;
11330
+ } else {
11331
+ url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
11332
+ }
11333
+ const response = await requestJSON(url, {
11334
+ method,
11335
+ body: JSON.stringify(savedView),
11336
+ headers: {
11337
+ "Content-Type": "application/json",
11338
+ "Accept-Language": locale2
11339
+ }
11340
+ });
11341
+ if (response.error) {
11342
+ throw response.error;
11343
+ }
11344
+ return response.data;
11345
+ },
11346
+ onSuccess: (savedView) => {
11347
+ if (method === "DELETE" || method === "POST") {
11348
+ queryClient2.invalidateQueries({
11349
+ queryKey: ["savedViews", domain, tableName]
11350
+ });
11351
+ return;
11352
+ } else {
11353
+ const oldData = queryClient2.getQueryData([
11354
+ "savedViews",
11355
+ domain,
11356
+ tableName
11357
+ ]);
11358
+ const oldView = oldData == null ? void 0 : oldData.find((item) => item.id === savedView.id);
11359
+ if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
11360
+ queryClient2.invalidateQueries({
11361
+ queryKey: ["savedViews", domain, tableName]
11362
+ });
11363
+ return;
11364
+ }
11365
+ }
11366
+ queryClient2.setQueryData(
11367
+ ["savedViews", domain, tableName],
11368
+ (oldData) => {
11369
+ if (!oldData)
11370
+ return [savedView];
11371
+ return oldData.map(
11372
+ (item) => item.id === savedView.id ? savedView : item
11373
+ );
11374
+ }
11375
+ );
11376
+ }
11377
+ });
11378
+ };
11379
+
11272
11380
  // src/utils/Constants/viewLevels.ts
11273
11381
  var VIEW_LEVELS = ["company", "project", "personal"];
11274
11382
 
11383
+ // src/utils/Api/queries.ts
11384
+ var PAGE_SIZE = 50 * VIEW_LEVELS.length;
11385
+ var useSavedViewsQuery = (props) => {
11386
+ const { projectId, companyId, domain, tableName } = props;
11387
+ const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
11388
+ return useQuery({
11389
+ enabled: props.enableSavedViews,
11390
+ queryKey: ["savedViews", domain, tableName],
11391
+ queryFn: async () => {
11392
+ const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
11393
+ const response = await requestJSON(getUrl2);
11394
+ return response.data;
11395
+ }
11396
+ });
11397
+ };
11398
+ var useSavedViewsPermissions = (props) => {
11399
+ const { projectId, companyId, domain } = props;
11400
+ const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
11401
+ return useQuery({
11402
+ enabled: props.enableSavedViews,
11403
+ queryKey: ["savedViewsConfig", domain],
11404
+ queryFn: async () => {
11405
+ const response = await requestJSON(url);
11406
+ return response.data;
11407
+ }
11408
+ });
11409
+ };
11410
+ var useCreateSavedView = (props) => useApiRequest(props, "POST", [
11411
+ "createSavedView",
11412
+ props.domain,
11413
+ props.tableName
11414
+ ]);
11415
+ var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
11416
+ "updateSavedView",
11417
+ props.domain,
11418
+ props.tableName
11419
+ ]);
11420
+ var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
11421
+ "deleteSavedView",
11422
+ props.domain,
11423
+ props.tableName
11424
+ ]);
11425
+
11275
11426
  // src/SavedViews/components/Panels/PanelContentUtils.ts
11276
11427
  var import_lodash = __toESM(require_lodash());
11277
11428
 
@@ -11279,14 +11430,14 @@ var import_lodash = __toESM(require_lodash());
11279
11430
  function getSmartGridConfig(api) {
11280
11431
  const columnStateResult = api.getColumnState();
11281
11432
  const columnGroupStateResult = api.getColumnGroupState();
11282
- const rowGroupStateResult = api.getRowGroupColumns();
11433
+ const rowGroupStateResult = api.getRowGroupColumns().map((col) => col.getColId());
11283
11434
  const rowHeightResult = api.getGridOption("rowHeight") || api.getSizesForCurrentTheme().rowHeight;
11284
11435
  const serverFiltersResult = api.getFilterModel();
11285
11436
  const smartGridConfig = {
11286
11437
  columnState: columnStateResult,
11287
11438
  rowHeight: rowHeightResult,
11288
11439
  columnGroupState: columnGroupStateResult,
11289
- rowGroupState: rowGroupStateResult.filter((col) => typeof (col == null ? void 0 : col.getColId) === "function").map((col) => col.getColId()),
11440
+ rowGroupState: rowGroupStateResult,
11290
11441
  filterState: serverFiltersResult
11291
11442
  };
11292
11443
  return smartGridConfig;
@@ -11479,7 +11630,7 @@ import {
11479
11630
  Flex as Flex2,
11480
11631
  spacing,
11481
11632
  Typography,
11482
- useI18nContext as useI18nContext3
11633
+ useI18nContext as useI18nContext4
11483
11634
  } from "@procore/core-react";
11484
11635
  import React14 from "react";
11485
11636
  var groupIcon = (group) => {
@@ -11499,7 +11650,7 @@ var Header = styled_components_esm_default(Flex2)`
11499
11650
  }
11500
11651
  `;
11501
11652
  var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
11502
- const I18n = useI18nContext3();
11653
+ const I18n = useI18nContext4();
11503
11654
  return /* @__PURE__ */ React14.createElement(
11504
11655
  Header,
11505
11656
  {
@@ -11548,10 +11699,9 @@ var Panel2 = styled_components_esm_default(DetailPage.Card)`
11548
11699
  var PanelContent = (props) => {
11549
11700
  var _a;
11550
11701
  const { showToast } = useToastAlertContext();
11551
- const I18n = useI18nContext4();
11552
- const { useSavedViewsQuery: useSavedViewsQuery2, useSavedViewsPermissions: useSavedViewsPermissions2, useUpdateSavedView: useUpdateSavedView2 } = props.backend;
11553
- const { mutate: updateSavedView, isPending: isUpdateLoading } = useUpdateSavedView2(props.queryInput);
11554
- const { data: savedViews, error: savedViewsError } = useSavedViewsQuery2(
11702
+ const I18n = useI18nContext5();
11703
+ const { mutate: updateSavedView, isPending: isUpdateLoading } = useUpdateSavedView(props.queryInput);
11704
+ const { data: savedViews, error: savedViewsError } = useSavedViewsQuery(
11555
11705
  props.queryInput
11556
11706
  );
11557
11707
  const errorToastRef = React15.useRef(null);
@@ -11561,7 +11711,7 @@ var PanelContent = (props) => {
11561
11711
  errorToastRef.current = savedViewsError;
11562
11712
  }
11563
11713
  }, [savedViewsError]);
11564
- const { data: permissions } = useSavedViewsPermissions2(props.queryInput);
11714
+ const { data: permissions } = useSavedViewsPermissions(props.queryInput);
11565
11715
  const selectedRowRef = useScrollToRef(savedViews);
11566
11716
  const onUpdate = (data) => {
11567
11717
  const newSavedView = {
@@ -11651,9 +11801,9 @@ var PanelContent = (props) => {
11651
11801
  import React20 from "react";
11652
11802
 
11653
11803
  // src/SavedViews/components/SavedViews/SmartGrid/SmartGridDefaultSavedView.tsx
11654
- import { useI18nContext as useI18nContext5 } from "@procore/core-react";
11804
+ import { useI18nContext as useI18nContext6 } from "@procore/core-react";
11655
11805
  var useDefaultViewName = (domain, defaultViewName) => {
11656
- const i18n = useI18nContext5();
11806
+ const i18n = useI18nContext6();
11657
11807
  return defaultViewName || i18n.t(domain, {
11658
11808
  scope: "savedViews.defaultViewTitle",
11659
11809
  defaultValue: "Default View"
@@ -11725,7 +11875,7 @@ import {
11725
11875
  ConfirmModal,
11726
11876
  Modal,
11727
11877
  P as P2,
11728
- useI18nContext as useI18nContext6
11878
+ useI18nContext as useI18nContext7
11729
11879
  } from "@procore/core-react";
11730
11880
  import React16 from "react";
11731
11881
  var SavedViewsDeleteConfirmationModalShared = ({
@@ -11733,7 +11883,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
11733
11883
  onDelete,
11734
11884
  open
11735
11885
  }) => {
11736
- const i18n = useI18nContext6();
11886
+ const i18n = useI18nContext7();
11737
11887
  return /* @__PURE__ */ React16.createElement(
11738
11888
  ConfirmModal,
11739
11889
  {
@@ -11764,7 +11914,7 @@ import {
11764
11914
  Modal as Modal2,
11765
11915
  spacing as spacing3,
11766
11916
  Typography as Typography2,
11767
- useI18nContext as useI18nContext7
11917
+ useI18nContext as useI18nContext8
11768
11918
  } from "@procore/core-react";
11769
11919
  import * as React17 from "react";
11770
11920
 
@@ -14094,7 +14244,6 @@ function extractMessage(error, I18n) {
14094
14244
  }
14095
14245
 
14096
14246
  // src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
14097
- var { useEffect: useEffect3, useRef: useRef2 } = React17;
14098
14247
  var ScrollContainer = styled_components_esm_default("div")`
14099
14248
  overflow: auto;
14100
14249
  `;
@@ -14112,38 +14261,22 @@ var SavedViewsCreateUpdateModalBase = ({
14112
14261
  selectedSavedView,
14113
14262
  setSelectedSavedView,
14114
14263
  setOpenEditCreateModal,
14115
- onSelect,
14116
- backend
14264
+ onSelect
14117
14265
  }) => {
14118
- const I18n = useI18nContext7();
14266
+ const I18n = useI18nContext8();
14119
14267
  const NAME_MAX_LENGTH = 150;
14120
- const originalBodyWidth = useRef2("");
14121
- useEffect3(() => {
14122
- if (open) {
14123
- originalBodyWidth.current = document.body.style.width || "";
14124
- document.body.style.width = "100%";
14125
- } else {
14126
- document.body.style.width = originalBodyWidth.current;
14127
- }
14128
- return () => {
14129
- if (originalBodyWidth.current !== void 0) {
14130
- document.body.style.width = originalBodyWidth.current;
14131
- }
14132
- };
14133
- }, [open]);
14134
- const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
14135
14268
  const {
14136
14269
  mutate: createSavedView,
14137
14270
  isPending: isCreating,
14138
14271
  error: createError,
14139
14272
  reset: resetCreateMutation
14140
- } = useCreateSavedView2(queryInput);
14273
+ } = useCreateSavedView(queryInput);
14141
14274
  const {
14142
14275
  mutate: updateSavedView,
14143
14276
  isPending: isUpdating,
14144
14277
  error: updateError,
14145
14278
  reset: resetUpdateMutation
14146
- } = useUpdateSavedView2(queryInput);
14279
+ } = useUpdateSavedView(queryInput);
14147
14280
  const resetMutations = () => {
14148
14281
  resetCreateMutation();
14149
14282
  resetUpdateMutation();
@@ -14152,7 +14285,7 @@ var SavedViewsCreateUpdateModalBase = ({
14152
14285
  resetMutations();
14153
14286
  onCancel();
14154
14287
  };
14155
- const { data: permissions } = useSavedViewsPermissions2(queryInput);
14288
+ const { data: permissions } = useSavedViewsPermissions(queryInput);
14156
14289
  const isLoading = isCreating || isUpdating;
14157
14290
  const errors = extractMessage(createError || updateError, I18n);
14158
14291
  const handleOnSubmit = (data) => {
@@ -14263,7 +14396,6 @@ var SavedViewsCreateUpdateModalBase = ({
14263
14396
  Form.Select,
14264
14397
  {
14265
14398
  name: "view_level",
14266
- qa: { label: "view-level" },
14267
14399
  options: viewLevelOptions,
14268
14400
  label: I18n.t("savedViews.modal.fields.viewLevel"),
14269
14401
  colWidth: 12,
@@ -14287,7 +14419,7 @@ var SavedViewsCreateUpdateModalBase = ({
14287
14419
  };
14288
14420
 
14289
14421
  // src/SavedViews/components/SavedViewsModals/SavedViewsFormModal.tsx
14290
- import { useI18nContext as useI18nContext8 } from "@procore/core-react";
14422
+ import { useI18nContext as useI18nContext9 } from "@procore/core-react";
14291
14423
  var SavedViewsFormModal = ({
14292
14424
  open,
14293
14425
  mode,
@@ -14299,10 +14431,9 @@ var SavedViewsFormModal = ({
14299
14431
  setSelectedSavedView,
14300
14432
  setOpenEditCreateModal,
14301
14433
  onSelect,
14302
- defaultView,
14303
- backend
14434
+ defaultView
14304
14435
  }) => {
14305
- const i18n = useI18nContext8();
14436
+ const i18n = useI18nContext9();
14306
14437
  return /* @__PURE__ */ React18.createElement(
14307
14438
  SavedViewsCreateUpdateModalBase,
14308
14439
  {
@@ -14319,170 +14450,11 @@ var SavedViewsFormModal = ({
14319
14450
  setSelectedSavedView,
14320
14451
  setOpenEditCreateModal,
14321
14452
  onSelect,
14322
- defaultView,
14323
- backend
14453
+ defaultView
14324
14454
  }
14325
14455
  );
14326
14456
  };
14327
14457
 
14328
- // ../../node_modules/@procore/core-http/dist/modern/index.js
14329
- function getCSRFToken() {
14330
- const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
14331
- return token ? decodeURIComponent(token.pop() || "") : "";
14332
- }
14333
- function getCSRFHeader() {
14334
- const csrfToken = getCSRFToken();
14335
- return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
14336
- }
14337
- function removeLeadingSlash(url) {
14338
- return url.startsWith("/") ? url.substring(1, url.length) : url;
14339
- }
14340
- function removeTrailingSlash(url) {
14341
- return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
14342
- }
14343
- function applyBaseUrl(url, baseUrl) {
14344
- return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
14345
- }
14346
- function getOptions({ headers, ...options }) {
14347
- const opts = {
14348
- credentials: "same-origin",
14349
- headers: {
14350
- ...getCSRFHeader(),
14351
- ...headers
14352
- },
14353
- mode: "same-origin",
14354
- ...options
14355
- };
14356
- return opts;
14357
- }
14358
- function getUrl(url, baseUrl) {
14359
- return baseUrl ? applyBaseUrl(url, baseUrl) : url;
14360
- }
14361
- function request(url, { baseUrl, ...options } = {}) {
14362
- return fetch(getUrl(url, baseUrl), getOptions(options));
14363
- }
14364
- function requestJSON(url, requestParams = {}) {
14365
- return request(url, requestParams).then(
14366
- (response) => response.json()
14367
- );
14368
- }
14369
-
14370
- // src/utils/Api/queries.ts
14371
- import { useQuery } from "@tanstack/react-query";
14372
-
14373
- // src/utils/Api/queriesHandler.ts
14374
- import { useMutation, useQueryClient } from "@tanstack/react-query";
14375
- import { useI18nContext as useI18nContext9 } from "@procore/core-react";
14376
- var useApiRequest = (props, method, mutationKey) => {
14377
- const { projectId, companyId, domain, tableName } = props;
14378
- const queryClient2 = useQueryClient();
14379
- const { locale: locale2 } = useI18nContext9();
14380
- return useMutation({
14381
- mutationKey,
14382
- mutationFn: async (savedView) => {
14383
- let url = "";
14384
- if (method === "DELETE" || method === "PUT") {
14385
- url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.id}?permissions_domain=${domain}`;
14386
- } else {
14387
- url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
14388
- }
14389
- const response = await requestJSON(url, {
14390
- method,
14391
- body: JSON.stringify(savedView),
14392
- headers: {
14393
- "Content-Type": "application/json",
14394
- "Accept-Language": locale2
14395
- }
14396
- });
14397
- if (response.error) {
14398
- throw response.error;
14399
- }
14400
- return response.data;
14401
- },
14402
- onSuccess: (savedView) => {
14403
- if (method === "DELETE" || method === "POST") {
14404
- queryClient2.invalidateQueries({
14405
- queryKey: ["savedViews", domain, tableName]
14406
- });
14407
- return;
14408
- } else {
14409
- const oldData = queryClient2.getQueryData([
14410
- "savedViews",
14411
- domain,
14412
- tableName
14413
- ]);
14414
- const oldView = oldData == null ? void 0 : oldData.find((item) => item.id === savedView.id);
14415
- if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
14416
- queryClient2.invalidateQueries({
14417
- queryKey: ["savedViews", domain, tableName]
14418
- });
14419
- return;
14420
- }
14421
- }
14422
- queryClient2.setQueryData(
14423
- ["savedViews", domain, tableName],
14424
- (oldData) => {
14425
- if (!oldData)
14426
- return [savedView];
14427
- return oldData.map(
14428
- (item) => item.id === savedView.id ? savedView : item
14429
- );
14430
- }
14431
- );
14432
- }
14433
- });
14434
- };
14435
-
14436
- // src/utils/Api/queries.ts
14437
- var PAGE_SIZE = 50 * VIEW_LEVELS.length;
14438
- var useSavedViewsQuery = (props) => {
14439
- const { projectId, companyId, domain, tableName } = props;
14440
- const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
14441
- return useQuery({
14442
- enabled: props.enableSavedViews,
14443
- queryKey: ["savedViews", domain, tableName],
14444
- queryFn: async () => {
14445
- const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
14446
- const response = await requestJSON(getUrl2);
14447
- return response.data;
14448
- }
14449
- });
14450
- };
14451
- var useSavedViewsPermissions = (props) => {
14452
- const { projectId, companyId, domain } = props;
14453
- const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
14454
- return useQuery({
14455
- enabled: props.enableSavedViews,
14456
- queryKey: ["savedViewsConfig", domain],
14457
- queryFn: async () => {
14458
- const response = await requestJSON(url);
14459
- return response.data;
14460
- }
14461
- });
14462
- };
14463
- var useCreateSavedView = (props) => useApiRequest(props, "POST", [
14464
- "createSavedView",
14465
- props.domain,
14466
- props.tableName
14467
- ]);
14468
- var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
14469
- "updateSavedView",
14470
- props.domain,
14471
- props.tableName
14472
- ]);
14473
- var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
14474
- "deleteSavedView",
14475
- props.domain,
14476
- props.tableName
14477
- ]);
14478
- var createQueries = (customBackend) => ({
14479
- useSavedViewsQuery: (customBackend == null ? void 0 : customBackend.useSavedViewsQuery) ?? useSavedViewsQuery,
14480
- useSavedViewsPermissions: (customBackend == null ? void 0 : customBackend.useSavedViewsPermissions) ?? useSavedViewsPermissions,
14481
- useCreateSavedView: (customBackend == null ? void 0 : customBackend.useCreateSavedView) ?? useCreateSavedView,
14482
- useUpdateSavedView: (customBackend == null ? void 0 : customBackend.useUpdateSavedView) ?? useUpdateSavedView,
14483
- useDeleteSavedView: (customBackend == null ? void 0 : customBackend.useDeleteSavedView) ?? useDeleteSavedView
14484
- });
14485
-
14486
14458
  // src/SavedViews/components/SavedViews/SavedViews.tsx
14487
14459
  var StyledPanel = styled_components_esm_default.div`
14488
14460
  border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
@@ -14497,8 +14469,7 @@ var SavedViewsContent = (props) => {
14497
14469
  projectId,
14498
14470
  companyId
14499
14471
  };
14500
- const backend = createQueries(props.backend);
14501
- const { mutate: deleteSavedView } = backend.useDeleteSavedView(queryInput);
14472
+ const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
14502
14473
  const [selectedSavedView, setSelectedSavedView] = useState4(() => {
14503
14474
  try {
14504
14475
  const savedView = JSON.parse(
@@ -14588,8 +14559,7 @@ var SavedViewsContent = (props) => {
14588
14559
  defaultView: props.defaultView,
14589
14560
  stickyViewsKey: props.stickyViewsKey,
14590
14561
  provider: props.provider,
14591
- userId: props.userId,
14592
- backend
14562
+ userId: props.userId
14593
14563
  }
14594
14564
  ))
14595
14565
  ), /* @__PURE__ */ React19.createElement(
@@ -14605,8 +14575,7 @@ var SavedViewsContent = (props) => {
14605
14575
  setSelectedSavedView,
14606
14576
  onSelect: (view) => handleViewItemSelect({ item: view }),
14607
14577
  setOpenEditCreateModal,
14608
- defaultView: props.defaultView,
14609
- backend
14578
+ defaultView: props.defaultView
14610
14579
  }
14611
14580
  ), selectedSavedView && /* @__PURE__ */ React19.createElement(
14612
14581
  SavedViewsDeleteConfirmationModalShared,
@@ -14634,7 +14603,6 @@ var SmartGridSavedViews = (props) => {
14634
14603
  domain: props.domain
14635
14604
  });
14636
14605
  const onSelect = ({ item }) => {
14637
- var _a;
14638
14606
  if (!gridApi)
14639
14607
  return item;
14640
14608
  if (item.id === "default") {
@@ -14645,13 +14613,11 @@ var SmartGridSavedViews = (props) => {
14645
14613
  gridApi.refreshCells();
14646
14614
  return item;
14647
14615
  }
14648
- const tableConfig2 = item.table_config;
14649
- const updatedItemConfig = ((_a = props.transformSettings) == null ? void 0 : _a.call(props, tableConfig2)) ?? tableConfig2;
14650
14616
  const updatedView = {
14651
14617
  ...item,
14652
14618
  table_config: customAndConfigSync(
14653
- updatedItemConfig,
14654
- tableConfig2
14619
+ item.table_config,
14620
+ tableConfig
14655
14621
  )
14656
14622
  };
14657
14623
  updateTableConfig(updatedView, gridApi, "smart-grid");
@@ -14671,8 +14637,7 @@ var SmartGridSavedViews = (props) => {
14671
14637
  tableName: props.tableName,
14672
14638
  tableConfig,
14673
14639
  stickyViewsKey: props.stickyViewsKey,
14674
- enableSavedViews: props.enableSavedViews,
14675
- backend: props.backend
14640
+ enableSavedViews: props.enableSavedViews
14676
14641
  }
14677
14642
  ));
14678
14643
  };