@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) {
@@ -11262,14 +11262,165 @@ import {
11262
11262
  Flex as Flex3,
11263
11263
  UNSAFE_Menu as MenuImperative,
11264
11264
  spacing as spacing2,
11265
- useI18nContext as useI18nContext4
11265
+ useI18nContext as useI18nContext5
11266
11266
  } from "@procore/core-react";
11267
11267
  import { useToastAlertContext } from "@procore/toast-alert";
11268
11268
  import React15 from "react";
11269
11269
 
11270
+ // node_modules/@procore/core-http/dist/modern/index.js
11271
+ function getCSRFToken() {
11272
+ const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
11273
+ return token ? decodeURIComponent(token.pop() || "") : "";
11274
+ }
11275
+ function getCSRFHeader() {
11276
+ const csrfToken = getCSRFToken();
11277
+ return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
11278
+ }
11279
+ function removeLeadingSlash(url) {
11280
+ return url.startsWith("/") ? url.substring(1, url.length) : url;
11281
+ }
11282
+ function removeTrailingSlash(url) {
11283
+ return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
11284
+ }
11285
+ function applyBaseUrl(url, baseUrl) {
11286
+ return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
11287
+ }
11288
+ function getOptions({ headers, ...options }) {
11289
+ const opts = {
11290
+ credentials: "same-origin",
11291
+ headers: {
11292
+ ...getCSRFHeader(),
11293
+ ...headers
11294
+ },
11295
+ mode: "same-origin",
11296
+ ...options
11297
+ };
11298
+ return opts;
11299
+ }
11300
+ function getUrl(url, baseUrl) {
11301
+ return baseUrl ? applyBaseUrl(url, baseUrl) : url;
11302
+ }
11303
+ function request(url, { baseUrl, ...options } = {}) {
11304
+ return fetch(getUrl(url, baseUrl), getOptions(options));
11305
+ }
11306
+ function requestJSON(url, requestParams = {}) {
11307
+ return request(url, requestParams).then(
11308
+ (response) => response.json()
11309
+ );
11310
+ }
11311
+
11312
+ // src/utils/Api/queries.ts
11313
+ import { useQuery } from "@tanstack/react-query";
11314
+
11315
+ // src/utils/Api/queriesHandler.ts
11316
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
11317
+ import { useI18nContext as useI18nContext3 } from "@procore/core-react";
11318
+ var useApiRequest = (props, method, mutationKey) => {
11319
+ const { projectId, companyId, domain, tableName } = props;
11320
+ const queryClient2 = useQueryClient();
11321
+ const { locale: locale2 } = useI18nContext3();
11322
+ return useMutation({
11323
+ mutationKey,
11324
+ mutationFn: async (savedView) => {
11325
+ let url = "";
11326
+ if (method === "DELETE" || method === "PUT") {
11327
+ url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.id}?permissions_domain=${domain}`;
11328
+ } else {
11329
+ url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
11330
+ }
11331
+ const response = await requestJSON(url, {
11332
+ method,
11333
+ body: JSON.stringify(savedView),
11334
+ headers: {
11335
+ "Content-Type": "application/json",
11336
+ "Accept-Language": locale2
11337
+ }
11338
+ });
11339
+ if (response.error) {
11340
+ throw response.error;
11341
+ }
11342
+ return response.data;
11343
+ },
11344
+ onSuccess: (savedView) => {
11345
+ if (method === "DELETE" || method === "POST") {
11346
+ queryClient2.invalidateQueries({
11347
+ queryKey: ["savedViews", domain, tableName]
11348
+ });
11349
+ return;
11350
+ } else {
11351
+ const oldData = queryClient2.getQueryData([
11352
+ "savedViews",
11353
+ domain,
11354
+ tableName
11355
+ ]);
11356
+ const oldView = oldData?.find((item) => item.id === savedView.id);
11357
+ if (oldView?.name !== savedView.name) {
11358
+ queryClient2.invalidateQueries({
11359
+ queryKey: ["savedViews", domain, tableName]
11360
+ });
11361
+ return;
11362
+ }
11363
+ }
11364
+ queryClient2.setQueryData(
11365
+ ["savedViews", domain, tableName],
11366
+ (oldData) => {
11367
+ if (!oldData)
11368
+ return [savedView];
11369
+ return oldData.map(
11370
+ (item) => item.id === savedView.id ? savedView : item
11371
+ );
11372
+ }
11373
+ );
11374
+ }
11375
+ });
11376
+ };
11377
+
11270
11378
  // src/utils/Constants/viewLevels.ts
11271
11379
  var VIEW_LEVELS = ["company", "project", "personal"];
11272
11380
 
11381
+ // src/utils/Api/queries.ts
11382
+ var PAGE_SIZE = 50 * VIEW_LEVELS.length;
11383
+ var useSavedViewsQuery = (props) => {
11384
+ const { projectId, companyId, domain, tableName } = props;
11385
+ const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
11386
+ return useQuery({
11387
+ enabled: props.enableSavedViews,
11388
+ queryKey: ["savedViews", domain, tableName],
11389
+ queryFn: async () => {
11390
+ const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
11391
+ const response = await requestJSON(getUrl2);
11392
+ return response.data;
11393
+ }
11394
+ });
11395
+ };
11396
+ var useSavedViewsPermissions = (props) => {
11397
+ const { projectId, companyId, domain } = props;
11398
+ const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
11399
+ return useQuery({
11400
+ enabled: props.enableSavedViews,
11401
+ queryKey: ["savedViewsConfig", domain],
11402
+ queryFn: async () => {
11403
+ const response = await requestJSON(url);
11404
+ return response.data;
11405
+ }
11406
+ });
11407
+ };
11408
+ var useCreateSavedView = (props) => useApiRequest(props, "POST", [
11409
+ "createSavedView",
11410
+ props.domain,
11411
+ props.tableName
11412
+ ]);
11413
+ var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
11414
+ "updateSavedView",
11415
+ props.domain,
11416
+ props.tableName
11417
+ ]);
11418
+ var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
11419
+ "deleteSavedView",
11420
+ props.domain,
11421
+ props.tableName
11422
+ ]);
11423
+
11273
11424
  // src/SavedViews/components/Panels/PanelContentUtils.ts
11274
11425
  var import_lodash = __toESM(require_lodash());
11275
11426
 
@@ -11277,14 +11428,14 @@ var import_lodash = __toESM(require_lodash());
11277
11428
  function getSmartGridConfig(api) {
11278
11429
  const columnStateResult = api.getColumnState();
11279
11430
  const columnGroupStateResult = api.getColumnGroupState();
11280
- const rowGroupStateResult = api.getRowGroupColumns();
11431
+ const rowGroupStateResult = api.getRowGroupColumns().map((col) => col.getColId());
11281
11432
  const rowHeightResult = api.getGridOption("rowHeight") || api.getSizesForCurrentTheme().rowHeight;
11282
11433
  const serverFiltersResult = api.getFilterModel();
11283
11434
  const smartGridConfig = {
11284
11435
  columnState: columnStateResult,
11285
11436
  rowHeight: rowHeightResult,
11286
11437
  columnGroupState: columnGroupStateResult,
11287
- rowGroupState: rowGroupStateResult.filter((col) => typeof col?.getColId === "function").map((col) => col.getColId()),
11438
+ rowGroupState: rowGroupStateResult,
11288
11439
  filterState: serverFiltersResult
11289
11440
  };
11290
11441
  return smartGridConfig;
@@ -11477,7 +11628,7 @@ import {
11477
11628
  Flex as Flex2,
11478
11629
  spacing,
11479
11630
  Typography,
11480
- useI18nContext as useI18nContext3
11631
+ useI18nContext as useI18nContext4
11481
11632
  } from "@procore/core-react";
11482
11633
  import React14 from "react";
11483
11634
  var groupIcon = (group) => {
@@ -11497,7 +11648,7 @@ var Header = styled_components_esm_default(Flex2)`
11497
11648
  }
11498
11649
  `;
11499
11650
  var ViewLevelHeader = ({ expanded, toggleGroup, group }) => {
11500
- const I18n = useI18nContext3();
11651
+ const I18n = useI18nContext4();
11501
11652
  return /* @__PURE__ */ React14.createElement(
11502
11653
  Header,
11503
11654
  {
@@ -11545,10 +11696,9 @@ var Panel2 = styled_components_esm_default(DetailPage.Card)`
11545
11696
  `;
11546
11697
  var PanelContent = (props) => {
11547
11698
  const { showToast } = useToastAlertContext();
11548
- const I18n = useI18nContext4();
11549
- const { useSavedViewsQuery: useSavedViewsQuery2, useSavedViewsPermissions: useSavedViewsPermissions2, useUpdateSavedView: useUpdateSavedView2 } = props.backend;
11550
- const { mutate: updateSavedView, isPending: isUpdateLoading } = useUpdateSavedView2(props.queryInput);
11551
- const { data: savedViews, error: savedViewsError } = useSavedViewsQuery2(
11699
+ const I18n = useI18nContext5();
11700
+ const { mutate: updateSavedView, isPending: isUpdateLoading } = useUpdateSavedView(props.queryInput);
11701
+ const { data: savedViews, error: savedViewsError } = useSavedViewsQuery(
11552
11702
  props.queryInput
11553
11703
  );
11554
11704
  const errorToastRef = React15.useRef(null);
@@ -11558,7 +11708,7 @@ var PanelContent = (props) => {
11558
11708
  errorToastRef.current = savedViewsError;
11559
11709
  }
11560
11710
  }, [savedViewsError]);
11561
- const { data: permissions } = useSavedViewsPermissions2(props.queryInput);
11711
+ const { data: permissions } = useSavedViewsPermissions(props.queryInput);
11562
11712
  const selectedRowRef = useScrollToRef(savedViews);
11563
11713
  const onUpdate = (data) => {
11564
11714
  const newSavedView = {
@@ -11647,9 +11797,9 @@ var PanelContent = (props) => {
11647
11797
  import React20 from "react";
11648
11798
 
11649
11799
  // src/SavedViews/components/SavedViews/SmartGrid/SmartGridDefaultSavedView.tsx
11650
- import { useI18nContext as useI18nContext5 } from "@procore/core-react";
11800
+ import { useI18nContext as useI18nContext6 } from "@procore/core-react";
11651
11801
  var useDefaultViewName = (domain, defaultViewName) => {
11652
- const i18n = useI18nContext5();
11802
+ const i18n = useI18nContext6();
11653
11803
  return defaultViewName || i18n.t(domain, {
11654
11804
  scope: "savedViews.defaultViewTitle",
11655
11805
  defaultValue: "Default View"
@@ -11721,7 +11871,7 @@ import {
11721
11871
  ConfirmModal,
11722
11872
  Modal,
11723
11873
  P as P2,
11724
- useI18nContext as useI18nContext6
11874
+ useI18nContext as useI18nContext7
11725
11875
  } from "@procore/core-react";
11726
11876
  import React16 from "react";
11727
11877
  var SavedViewsDeleteConfirmationModalShared = ({
@@ -11729,7 +11879,7 @@ var SavedViewsDeleteConfirmationModalShared = ({
11729
11879
  onDelete,
11730
11880
  open
11731
11881
  }) => {
11732
- const i18n = useI18nContext6();
11882
+ const i18n = useI18nContext7();
11733
11883
  return /* @__PURE__ */ React16.createElement(
11734
11884
  ConfirmModal,
11735
11885
  {
@@ -11760,7 +11910,7 @@ import {
11760
11910
  Modal as Modal2,
11761
11911
  spacing as spacing3,
11762
11912
  Typography as Typography2,
11763
- useI18nContext as useI18nContext7
11913
+ useI18nContext as useI18nContext8
11764
11914
  } from "@procore/core-react";
11765
11915
  import * as React17 from "react";
11766
11916
 
@@ -14090,7 +14240,6 @@ function extractMessage(error, I18n) {
14090
14240
  }
14091
14241
 
14092
14242
  // src/SavedViews/components/SavedViewsModals/SavedViewsCreateUpdateModalBase.tsx
14093
- var { useEffect: useEffect3, useRef: useRef2 } = React17;
14094
14243
  var ScrollContainer = styled_components_esm_default("div")`
14095
14244
  overflow: auto;
14096
14245
  `;
@@ -14108,38 +14257,22 @@ var SavedViewsCreateUpdateModalBase = ({
14108
14257
  selectedSavedView,
14109
14258
  setSelectedSavedView,
14110
14259
  setOpenEditCreateModal,
14111
- onSelect,
14112
- backend
14260
+ onSelect
14113
14261
  }) => {
14114
- const I18n = useI18nContext7();
14262
+ const I18n = useI18nContext8();
14115
14263
  const NAME_MAX_LENGTH = 150;
14116
- const originalBodyWidth = useRef2("");
14117
- useEffect3(() => {
14118
- if (open) {
14119
- originalBodyWidth.current = document.body.style.width || "";
14120
- document.body.style.width = "100%";
14121
- } else {
14122
- document.body.style.width = originalBodyWidth.current;
14123
- }
14124
- return () => {
14125
- if (originalBodyWidth.current !== void 0) {
14126
- document.body.style.width = originalBodyWidth.current;
14127
- }
14128
- };
14129
- }, [open]);
14130
- const { useCreateSavedView: useCreateSavedView2, useUpdateSavedView: useUpdateSavedView2, useSavedViewsPermissions: useSavedViewsPermissions2 } = backend;
14131
14264
  const {
14132
14265
  mutate: createSavedView,
14133
14266
  isPending: isCreating,
14134
14267
  error: createError,
14135
14268
  reset: resetCreateMutation
14136
- } = useCreateSavedView2(queryInput);
14269
+ } = useCreateSavedView(queryInput);
14137
14270
  const {
14138
14271
  mutate: updateSavedView,
14139
14272
  isPending: isUpdating,
14140
14273
  error: updateError,
14141
14274
  reset: resetUpdateMutation
14142
- } = useUpdateSavedView2(queryInput);
14275
+ } = useUpdateSavedView(queryInput);
14143
14276
  const resetMutations = () => {
14144
14277
  resetCreateMutation();
14145
14278
  resetUpdateMutation();
@@ -14148,7 +14281,7 @@ var SavedViewsCreateUpdateModalBase = ({
14148
14281
  resetMutations();
14149
14282
  onCancel();
14150
14283
  };
14151
- const { data: permissions } = useSavedViewsPermissions2(queryInput);
14284
+ const { data: permissions } = useSavedViewsPermissions(queryInput);
14152
14285
  const isLoading = isCreating || isUpdating;
14153
14286
  const errors = extractMessage(createError || updateError, I18n);
14154
14287
  const handleOnSubmit = (data) => {
@@ -14259,7 +14392,6 @@ var SavedViewsCreateUpdateModalBase = ({
14259
14392
  Form.Select,
14260
14393
  {
14261
14394
  name: "view_level",
14262
- qa: { label: "view-level" },
14263
14395
  options: viewLevelOptions,
14264
14396
  label: I18n.t("savedViews.modal.fields.viewLevel"),
14265
14397
  colWidth: 12,
@@ -14283,7 +14415,7 @@ var SavedViewsCreateUpdateModalBase = ({
14283
14415
  };
14284
14416
 
14285
14417
  // src/SavedViews/components/SavedViewsModals/SavedViewsFormModal.tsx
14286
- import { useI18nContext as useI18nContext8 } from "@procore/core-react";
14418
+ import { useI18nContext as useI18nContext9 } from "@procore/core-react";
14287
14419
  var SavedViewsFormModal = ({
14288
14420
  open,
14289
14421
  mode,
@@ -14295,10 +14427,9 @@ var SavedViewsFormModal = ({
14295
14427
  setSelectedSavedView,
14296
14428
  setOpenEditCreateModal,
14297
14429
  onSelect,
14298
- defaultView,
14299
- backend
14430
+ defaultView
14300
14431
  }) => {
14301
- const i18n = useI18nContext8();
14432
+ const i18n = useI18nContext9();
14302
14433
  return /* @__PURE__ */ React18.createElement(
14303
14434
  SavedViewsCreateUpdateModalBase,
14304
14435
  {
@@ -14315,170 +14446,11 @@ var SavedViewsFormModal = ({
14315
14446
  setSelectedSavedView,
14316
14447
  setOpenEditCreateModal,
14317
14448
  onSelect,
14318
- defaultView,
14319
- backend
14449
+ defaultView
14320
14450
  }
14321
14451
  );
14322
14452
  };
14323
14453
 
14324
- // ../../node_modules/@procore/core-http/dist/modern/index.js
14325
- function getCSRFToken() {
14326
- const token = document.cookie.match("(^|;)\\s*csrf_token\\s*=\\s*([^;]+)");
14327
- return token ? decodeURIComponent(token.pop() || "") : "";
14328
- }
14329
- function getCSRFHeader() {
14330
- const csrfToken = getCSRFToken();
14331
- return csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {};
14332
- }
14333
- function removeLeadingSlash(url) {
14334
- return url.startsWith("/") ? url.substring(1, url.length) : url;
14335
- }
14336
- function removeTrailingSlash(url) {
14337
- return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
14338
- }
14339
- function applyBaseUrl(url, baseUrl) {
14340
- return `${removeTrailingSlash(baseUrl)}/${removeLeadingSlash(url)}`;
14341
- }
14342
- function getOptions({ headers, ...options }) {
14343
- const opts = {
14344
- credentials: "same-origin",
14345
- headers: {
14346
- ...getCSRFHeader(),
14347
- ...headers
14348
- },
14349
- mode: "same-origin",
14350
- ...options
14351
- };
14352
- return opts;
14353
- }
14354
- function getUrl(url, baseUrl) {
14355
- return baseUrl ? applyBaseUrl(url, baseUrl) : url;
14356
- }
14357
- function request(url, { baseUrl, ...options } = {}) {
14358
- return fetch(getUrl(url, baseUrl), getOptions(options));
14359
- }
14360
- function requestJSON(url, requestParams = {}) {
14361
- return request(url, requestParams).then(
14362
- (response) => response.json()
14363
- );
14364
- }
14365
-
14366
- // src/utils/Api/queries.ts
14367
- import { useQuery } from "@tanstack/react-query";
14368
-
14369
- // src/utils/Api/queriesHandler.ts
14370
- import { useMutation, useQueryClient } from "@tanstack/react-query";
14371
- import { useI18nContext as useI18nContext9 } from "@procore/core-react";
14372
- var useApiRequest = (props, method, mutationKey) => {
14373
- const { projectId, companyId, domain, tableName } = props;
14374
- const queryClient2 = useQueryClient();
14375
- const { locale: locale2 } = useI18nContext9();
14376
- return useMutation({
14377
- mutationKey,
14378
- mutationFn: async (savedView) => {
14379
- let url = "";
14380
- if (method === "DELETE" || method === "PUT") {
14381
- url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/${savedView.id}?permissions_domain=${domain}`;
14382
- } else {
14383
- url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
14384
- }
14385
- const response = await requestJSON(url, {
14386
- method,
14387
- body: JSON.stringify(savedView),
14388
- headers: {
14389
- "Content-Type": "application/json",
14390
- "Accept-Language": locale2
14391
- }
14392
- });
14393
- if (response.error) {
14394
- throw response.error;
14395
- }
14396
- return response.data;
14397
- },
14398
- onSuccess: (savedView) => {
14399
- if (method === "DELETE" || method === "POST") {
14400
- queryClient2.invalidateQueries({
14401
- queryKey: ["savedViews", domain, tableName]
14402
- });
14403
- return;
14404
- } else {
14405
- const oldData = queryClient2.getQueryData([
14406
- "savedViews",
14407
- domain,
14408
- tableName
14409
- ]);
14410
- const oldView = oldData?.find((item) => item.id === savedView.id);
14411
- if (oldView?.name !== savedView.name) {
14412
- queryClient2.invalidateQueries({
14413
- queryKey: ["savedViews", domain, tableName]
14414
- });
14415
- return;
14416
- }
14417
- }
14418
- queryClient2.setQueryData(
14419
- ["savedViews", domain, tableName],
14420
- (oldData) => {
14421
- if (!oldData)
14422
- return [savedView];
14423
- return oldData.map(
14424
- (item) => item.id === savedView.id ? savedView : item
14425
- );
14426
- }
14427
- );
14428
- }
14429
- });
14430
- };
14431
-
14432
- // src/utils/Api/queries.ts
14433
- var PAGE_SIZE = 50 * VIEW_LEVELS.length;
14434
- var useSavedViewsQuery = (props) => {
14435
- const { projectId, companyId, domain, tableName } = props;
14436
- const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views?table_name=${tableName}&permissions_domain=${domain}`;
14437
- return useQuery({
14438
- enabled: props.enableSavedViews,
14439
- queryKey: ["savedViews", domain, tableName],
14440
- queryFn: async () => {
14441
- const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
14442
- const response = await requestJSON(getUrl2);
14443
- return response.data;
14444
- }
14445
- });
14446
- };
14447
- var useSavedViewsPermissions = (props) => {
14448
- const { projectId, companyId, domain } = props;
14449
- const url = `/rest/v2.0/companies/${companyId}/projects/${projectId}/saved_views/permissions?permissions_domain=${domain}`;
14450
- return useQuery({
14451
- enabled: props.enableSavedViews,
14452
- queryKey: ["savedViewsConfig", domain],
14453
- queryFn: async () => {
14454
- const response = await requestJSON(url);
14455
- return response.data;
14456
- }
14457
- });
14458
- };
14459
- var useCreateSavedView = (props) => useApiRequest(props, "POST", [
14460
- "createSavedView",
14461
- props.domain,
14462
- props.tableName
14463
- ]);
14464
- var useUpdateSavedView = (props) => useApiRequest(props, "PUT", [
14465
- "updateSavedView",
14466
- props.domain,
14467
- props.tableName
14468
- ]);
14469
- var useDeleteSavedView = (props) => useApiRequest(props, "DELETE", [
14470
- "deleteSavedView",
14471
- props.domain,
14472
- props.tableName
14473
- ]);
14474
- var createQueries = (customBackend) => ({
14475
- useSavedViewsQuery: customBackend?.useSavedViewsQuery ?? useSavedViewsQuery,
14476
- useSavedViewsPermissions: customBackend?.useSavedViewsPermissions ?? useSavedViewsPermissions,
14477
- useCreateSavedView: customBackend?.useCreateSavedView ?? useCreateSavedView,
14478
- useUpdateSavedView: customBackend?.useUpdateSavedView ?? useUpdateSavedView,
14479
- useDeleteSavedView: customBackend?.useDeleteSavedView ?? useDeleteSavedView
14480
- });
14481
-
14482
14454
  // src/SavedViews/components/SavedViews/SavedViews.tsx
14483
14455
  var StyledPanel = styled_components_esm_default.div`
14484
14456
  border: ${({ provider }) => provider === "data-table" ? "1px solid #d6dadc" : "none"};
@@ -14493,8 +14465,7 @@ var SavedViewsContent = (props) => {
14493
14465
  projectId,
14494
14466
  companyId
14495
14467
  };
14496
- const backend = createQueries(props.backend);
14497
- const { mutate: deleteSavedView } = backend.useDeleteSavedView(queryInput);
14468
+ const { mutate: deleteSavedView } = useDeleteSavedView(queryInput);
14498
14469
  const [selectedSavedView, setSelectedSavedView] = useState4(() => {
14499
14470
  try {
14500
14471
  const savedView = JSON.parse(
@@ -14584,8 +14555,7 @@ var SavedViewsContent = (props) => {
14584
14555
  defaultView: props.defaultView,
14585
14556
  stickyViewsKey: props.stickyViewsKey,
14586
14557
  provider: props.provider,
14587
- userId: props.userId,
14588
- backend
14558
+ userId: props.userId
14589
14559
  }
14590
14560
  ))
14591
14561
  ), /* @__PURE__ */ React19.createElement(
@@ -14601,8 +14571,7 @@ var SavedViewsContent = (props) => {
14601
14571
  setSelectedSavedView,
14602
14572
  onSelect: (view) => handleViewItemSelect({ item: view }),
14603
14573
  setOpenEditCreateModal,
14604
- defaultView: props.defaultView,
14605
- backend
14574
+ defaultView: props.defaultView
14606
14575
  }
14607
14576
  ), selectedSavedView && /* @__PURE__ */ React19.createElement(
14608
14577
  SavedViewsDeleteConfirmationModalShared,
@@ -14640,13 +14609,11 @@ var SmartGridSavedViews = (props) => {
14640
14609
  gridApi.refreshCells();
14641
14610
  return item;
14642
14611
  }
14643
- const tableConfig2 = item.table_config;
14644
- const updatedItemConfig = props.transformSettings?.(tableConfig2) ?? tableConfig2;
14645
14612
  const updatedView = {
14646
14613
  ...item,
14647
14614
  table_config: customAndConfigSync(
14648
- updatedItemConfig,
14649
- tableConfig2
14615
+ item.table_config,
14616
+ tableConfig
14650
14617
  )
14651
14618
  };
14652
14619
  updateTableConfig(updatedView, gridApi, "smart-grid");
@@ -14666,8 +14633,7 @@ var SmartGridSavedViews = (props) => {
14666
14633
  tableName: props.tableName,
14667
14634
  tableConfig,
14668
14635
  stickyViewsKey: props.stickyViewsKey,
14669
- enableSavedViews: props.enableSavedViews,
14670
- backend: props.backend
14636
+ enableSavedViews: props.enableSavedViews
14671
14637
  }
14672
14638
  ));
14673
14639
  };