@ansible/ansible-ui-framework 0.0.268 → 0.0.269

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ export declare function useIsMounted(): boolean;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.useIsMounted = void 0;
20
+ var react_1 = require("react");
21
+ function useIsMounted() {
22
+ var _a = __read((0, react_1.useState)(true), 2), isMounted = _a[0], setIsMounted = _a[1];
23
+ (0, react_1.useEffect)(function () { return function () {
24
+ setIsMounted(false);
25
+ }; }, []);
26
+ return isMounted;
27
+ }
28
+ exports.useIsMounted = useIsMounted;
@@ -0,0 +1 @@
1
+ export declare function useSearchParams(): [URLSearchParams, (setSearchParams: URLSearchParams) => void];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useSearchParams = void 0;
4
+ var react_1 = require("react");
5
+ var useWindowLocation_1 = require("./useWindowLocation");
6
+ function useSearchParams() {
7
+ var _a, _b;
8
+ var location = (0, useWindowLocation_1.useWindowLocation)();
9
+ var pathname = ((_a = location.location) === null || _a === void 0 ? void 0 : _a.pathname) || '/';
10
+ var searchParams = (0, react_1.useMemo)(function () { var _a, _b; return new URLSearchParams((_b = (_a = location.location) === null || _a === void 0 ? void 0 : _a.search) !== null && _b !== void 0 ? _b : '/'); }, [(_b = location.location) === null || _b === void 0 ? void 0 : _b.search]);
11
+ var setSearchParams = (0, react_1.useCallback)(function (searchParams) {
12
+ var newSearch = searchParams.toString();
13
+ if (newSearch)
14
+ location.update('?' + newSearch);
15
+ else
16
+ location.update(pathname); // retain the existing pathname
17
+ }, [location, pathname]);
18
+ return [searchParams, setSearchParams];
19
+ }
20
+ exports.useSearchParams = useSearchParams;
@@ -1,6 +1,5 @@
1
- export declare function useWindowHistory(): {
1
+ export declare function useWindowLocation(): {
2
2
  location: void | Location;
3
3
  push: (url?: string | URL | null) => void;
4
4
  update: (url?: string | URL | null) => void;
5
5
  };
6
- export declare function useSearchParams(): [URLSearchParams, (setSearchParams: URLSearchParams) => void];
@@ -16,17 +16,11 @@ var __read = (this && this.__read) || function (o, n) {
16
16
  return ar;
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.useSearchParams = exports.useWindowHistory = void 0;
19
+ exports.useWindowLocation = void 0;
20
20
  var react_1 = require("react");
21
- function useIsMounted() {
22
- var _a = __read((0, react_1.useState)(true), 2), isMounted = _a[0], setIsMounted = _a[1];
23
- (0, react_1.useEffect)(function () { return function () {
24
- setIsMounted(false);
25
- }; }, []);
26
- return isMounted;
27
- }
28
- function useWindowHistory() {
29
- var isMounted = useIsMounted();
21
+ var useIsMounted_1 = require("./useIsMounted");
22
+ function useWindowLocation() {
23
+ var isMounted = (0, useIsMounted_1.useIsMounted)();
30
24
  var _a = __read((0, react_1.useState)(isMounted ? window.location : undefined), 2), location = _a[0], setLocation = _a[1];
31
25
  var setWindowLocation = (0, react_1.useCallback)(function () {
32
26
  setLocation(window.location);
@@ -52,19 +46,4 @@ function useWindowHistory() {
52
46
  }, [setWindowLocation]);
53
47
  return { location: location, push: push, update: update };
54
48
  }
55
- exports.useWindowHistory = useWindowHistory;
56
- function useSearchParams() {
57
- var _a, _b;
58
- var history = useWindowHistory();
59
- var pathname = ((_a = history.location) === null || _a === void 0 ? void 0 : _a.pathname) || '/';
60
- var searchParams = (0, react_1.useMemo)(function () { var _a, _b; return new URLSearchParams((_b = (_a = history.location) === null || _a === void 0 ? void 0 : _a.search) !== null && _b !== void 0 ? _b : '/'); }, [(_b = history.location) === null || _b === void 0 ? void 0 : _b.search]);
61
- var setSearchParams = (0, react_1.useCallback)(function (searchParams) {
62
- var newSearch = searchParams.toString();
63
- if (newSearch)
64
- history.update('?' + newSearch);
65
- else
66
- history.update(pathname); // retain the existing pathname
67
- }, [history, pathname]);
68
- return [searchParams, setSearchParams];
69
- }
70
- exports.useSearchParams = useSearchParams;
49
+ exports.useWindowLocation = useWindowLocation;
package/cjs/useView.js CHANGED
@@ -29,9 +29,9 @@ var __values = (this && this.__values) || function(o) {
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.useView = void 0;
31
31
  var react_1 = require("react");
32
- var react_router_dom_1 = require("react-router-dom");
32
+ var useSearchParams_1 = require("./components/useSearchParams");
33
33
  function useView(view, disableQueryString) {
34
- var _a = __read((0, react_router_dom_1.useSearchParams)(), 2), searchParams = _a[0], setSearchParams = _a[1];
34
+ var _a = __read((0, useSearchParams_1.useSearchParams)(), 2), searchParams = _a[0], setSearchParams = _a[1];
35
35
  var _b = __read((0, react_1.useState)(function () {
36
36
  var _a;
37
37
  if (!disableQueryString) {
@@ -136,7 +136,7 @@ function useView(view, disableQueryString) {
136
136
  newSearchParams.set(filter, filters[filter].join(','));
137
137
  }
138
138
  localStorage.setItem('perPage', perPage.toString());
139
- setSearchParams(newSearchParams, { replace: true });
139
+ setSearchParams(newSearchParams);
140
140
  }, [sort, sortDirection, setSearchParams, disableQueryString, page, perPage, filters]);
141
141
  return (0, react_1.useMemo)(function () { return ({
142
142
  page: page,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ansible/ansible-ui-framework",
3
3
  "description": "Framework for building consistent responsive web applications using PatternFly.",
4
- "version": "0.0.268",
4
+ "version": "0.0.269",
5
5
  "author": "Red Hat",
6
6
  "license": "MIT",
7
7
  "repository": {