@bigbinary/neeto-commons-frontend 3.0.16 → 3.1.0
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/cjs/cypress-configs/plugins.js +9 -0
- package/cjs/react-utils/index.js +8 -0
- package/cjs/react-utils/index.js.map +1 -1
- package/cjs/react-utils/useBreakpoints/index.js +22 -0
- package/cjs/react-utils/useBreakpoints/index.js.map +1 -0
- package/cjs/react-utils/useBreakpoints/utils.js +32 -0
- package/cjs/react-utils/useBreakpoints/utils.js.map +1 -0
- package/cypress-configs/plugins.js +9 -0
- package/package.json +1 -1
- package/react-utils/index.js +1 -0
- package/react-utils/index.js.map +1 -1
- package/react-utils/useBreakpoints/index.js +15 -0
- package/react-utils/useBreakpoints/index.js.map +1 -0
- package/react-utils/useBreakpoints/utils.js +23 -0
- package/react-utils/useBreakpoints/utils.js.map +1 -0
- package/react-utils.d.ts +70 -1
|
@@ -45,6 +45,15 @@ module.exports = (on, config) => {
|
|
|
45
45
|
};
|
|
46
46
|
on("file:preprocessor", webpack(options));
|
|
47
47
|
|
|
48
|
+
on("task", {
|
|
49
|
+
log(message) {
|
|
50
|
+
//eslint-disable-next-line
|
|
51
|
+
console.log(message);
|
|
52
|
+
|
|
53
|
+
return null;
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
48
57
|
config = cypressBrowserPermissionsPlugin(on, config);
|
|
49
58
|
|
|
50
59
|
const newEnvironment = merge(config, configForEnvironment);
|
package/cjs/react-utils/index.js
CHANGED
|
@@ -26,6 +26,7 @@ var _exportNames = {
|
|
|
26
26
|
useStateWithDependency: true,
|
|
27
27
|
useTimer: true,
|
|
28
28
|
useUpdateEffect: true,
|
|
29
|
+
useBreakpoints: true,
|
|
29
30
|
withImmutableActions: true,
|
|
30
31
|
withT: true,
|
|
31
32
|
withTitle: true
|
|
@@ -42,6 +43,12 @@ Object.defineProperty(exports, "PrivateRoute", {
|
|
|
42
43
|
return _PrivateRoute["default"];
|
|
43
44
|
}
|
|
44
45
|
});
|
|
46
|
+
Object.defineProperty(exports, "useBreakpoints", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function get() {
|
|
49
|
+
return _useBreakpoints["default"];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
45
52
|
Object.defineProperty(exports, "useDebounce", {
|
|
46
53
|
enumerable: true,
|
|
47
54
|
get: function get() {
|
|
@@ -210,6 +217,7 @@ Object.keys(_useRegisterNavigationCheckpoint).forEach(function (key) {
|
|
|
210
217
|
var _useStateWithDependency = _interopRequireDefault(require("./useStateWithDependency"));
|
|
211
218
|
var _useTimer = _interopRequireDefault(require("./useTimer"));
|
|
212
219
|
var _useUpdateEffect = _interopRequireDefault(require("./useUpdateEffect"));
|
|
220
|
+
var _useBreakpoints = _interopRequireDefault(require("./useBreakpoints"));
|
|
213
221
|
var _BrowserPushNotifications = require("./BrowserPushNotifications");
|
|
214
222
|
Object.keys(_BrowserPushNotifications).forEach(function (key) {
|
|
215
223
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_HoneybadgerErrorBoundary","_interopRequireDefault","require","_PrivateRoute","_useDebounce","_useDisplayErrorPage","_interopRequireWildcard","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useFetchNeetoApps","_useFieldSubmit","_useFuncDebounce","_useHotKeys","_useIsElementVisibleInDom","_useKeyboardShortcutsPaneState","_useLocalStorage","_useMutationWithInvalidation","_useOnClickOutside","_usePersistedQuery","_usePrevious","_useQueryParams","_useRegisterNavigationCheckpoint","_useStateWithDependency","_useTimer","_useUpdateEffect","_BrowserPushNotifications","_metaClick","_withImmutableActions","_withT","_withTitle","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set"],"sources":["../../../src/react-utils/index.js"],"sourcesContent":["// components\nexport { default as HoneybadgerErrorBoundary } from \"./HoneybadgerErrorBoundary\";\nexport { default as PrivateRoute } from \"./PrivateRoute\";\n\n// hooks\nexport { default as useDebounce } from \"./useDebounce\";\nexport * from \"./useDisplayErrorPage\";\nexport { default as useDisplayErrorPage } from \"./useDisplayErrorPage\";\nexport { default as useFetchNeetoApps } from \"./useFetchNeetoApps\";\nexport { default as useFieldSubmit } from \"./useFieldSubmit\";\nexport { default as useFuncDebounce } from \"./useFuncDebounce\";\nexport { default as useHotKeys } from \"./useHotKeys\";\nexport { default as useIsElementVisibleInDom } from \"./useIsElementVisibleInDom\";\nexport { default as useKeyboardShortcutsPaneState } from \"./useKeyboardShortcutsPaneState\";\nexport { default as useLocalStorage } from \"./useLocalStorage\";\nexport { default as useMutationWithInvalidation } from \"./useMutationWithInvalidation\";\nexport { default as useOnClickOutside } from \"./useOnClickOutside\";\nexport { default as usePersistedQuery } from \"./usePersistedQuery\";\nexport { default as usePrevious } from \"./usePrevious\";\nexport { default as useQueryParams } from \"./useQueryParams\";\nexport * from \"./useRegisterNavigationCheckpoint\";\nexport { default as useRegisterNavigationCheckpoint } from \"./useRegisterNavigationCheckpoint\";\nexport { default as useStateWithDependency } from \"./useStateWithDependency\";\nexport { default as useTimer } from \"./useTimer\";\nexport { default as useUpdateEffect } from \"./useUpdateEffect\";\n\n// utils\nexport * from \"./BrowserPushNotifications\";\nexport * from \"./metaClick\";\nexport { default as withImmutableActions } from \"./withImmutableActions\";\nexport { default as withT } from \"./withT\";\nexport { default as withTitle } from \"./withTitle\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["_HoneybadgerErrorBoundary","_interopRequireDefault","require","_PrivateRoute","_useDebounce","_useDisplayErrorPage","_interopRequireWildcard","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_useFetchNeetoApps","_useFieldSubmit","_useFuncDebounce","_useHotKeys","_useIsElementVisibleInDom","_useKeyboardShortcutsPaneState","_useLocalStorage","_useMutationWithInvalidation","_useOnClickOutside","_usePersistedQuery","_usePrevious","_useQueryParams","_useRegisterNavigationCheckpoint","_useStateWithDependency","_useTimer","_useUpdateEffect","_useBreakpoints","_BrowserPushNotifications","_metaClick","_withImmutableActions","_withT","_withTitle","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set"],"sources":["../../../src/react-utils/index.js"],"sourcesContent":["// components\nexport { default as HoneybadgerErrorBoundary } from \"./HoneybadgerErrorBoundary\";\nexport { default as PrivateRoute } from \"./PrivateRoute\";\n\n// hooks\nexport { default as useDebounce } from \"./useDebounce\";\nexport * from \"./useDisplayErrorPage\";\nexport { default as useDisplayErrorPage } from \"./useDisplayErrorPage\";\nexport { default as useFetchNeetoApps } from \"./useFetchNeetoApps\";\nexport { default as useFieldSubmit } from \"./useFieldSubmit\";\nexport { default as useFuncDebounce } from \"./useFuncDebounce\";\nexport { default as useHotKeys } from \"./useHotKeys\";\nexport { default as useIsElementVisibleInDom } from \"./useIsElementVisibleInDom\";\nexport { default as useKeyboardShortcutsPaneState } from \"./useKeyboardShortcutsPaneState\";\nexport { default as useLocalStorage } from \"./useLocalStorage\";\nexport { default as useMutationWithInvalidation } from \"./useMutationWithInvalidation\";\nexport { default as useOnClickOutside } from \"./useOnClickOutside\";\nexport { default as usePersistedQuery } from \"./usePersistedQuery\";\nexport { default as usePrevious } from \"./usePrevious\";\nexport { default as useQueryParams } from \"./useQueryParams\";\nexport * from \"./useRegisterNavigationCheckpoint\";\nexport { default as useRegisterNavigationCheckpoint } from \"./useRegisterNavigationCheckpoint\";\nexport { default as useStateWithDependency } from \"./useStateWithDependency\";\nexport { default as useTimer } from \"./useTimer\";\nexport { default as useUpdateEffect } from \"./useUpdateEffect\";\nexport { default as useBreakpoints } from \"./useBreakpoints\";\n\n// utils\nexport * from \"./BrowserPushNotifications\";\nexport * from \"./metaClick\";\nexport { default as withImmutableActions } from \"./withImmutableActions\";\nexport { default as withT } from \"./withT\";\nexport { default as withTitle } from \"./withTitle\";\n"],"mappings":"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"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _ramda = require("ramda");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
var useBreakpoints = function useBreakpoints(breakpointOverrides) {
|
|
11
|
+
var getSnapshot = function getSnapshot() {
|
|
12
|
+
return (0, _utils.getCurrentSize)(window, breakpointOverrides);
|
|
13
|
+
};
|
|
14
|
+
var currentSize = (0, _react.useSyncExternalStore)(_utils.subscribe, getSnapshot);
|
|
15
|
+
return {
|
|
16
|
+
currentSize: currentSize,
|
|
17
|
+
isSize: (0, _ramda.equals)(currentSize)
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
var _default = useBreakpoints;
|
|
21
|
+
exports["default"] = _default;
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","require","_ramda","_utils","useBreakpoints","breakpointOverrides","getSnapshot","getCurrentSize","window","currentSize","useSyncExternalStore","subscribe","isSize","equals","_default","exports"],"sources":["../../../../src/react-utils/useBreakpoints/index.js"],"sourcesContent":["import { useSyncExternalStore } from \"react\";\n\nimport { equals } from \"ramda\";\n\nimport { getCurrentSize, subscribe } from \"./utils\";\n\nconst useBreakpoints = breakpointOverrides => {\n const getSnapshot = () => getCurrentSize(window, breakpointOverrides);\n const currentSize = useSyncExternalStore(subscribe, getSnapshot);\n\n return { currentSize, isSize: equals(currentSize) };\n};\n\nexport default useBreakpoints;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAMG,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,mBAAmB,EAAI;EAC5C,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAA;IAAA,OAAS,IAAAC,qBAAc,EAACC,MAAM,EAAEH,mBAAmB,CAAC;EAAA;EACrE,IAAMI,WAAW,GAAG,IAAAC,2BAAoB,EAACC,gBAAS,EAAEL,WAAW,CAAC;EAEhE,OAAO;IAAEG,WAAW,EAAXA,WAAW;IAAEG,MAAM,EAAE,IAAAC,aAAM,EAACJ,WAAW;EAAE,CAAC;AACrD,CAAC;AAAC,IAAAK,QAAA,GAEaV,cAAc;AAAAW,OAAA,cAAAD,QAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.subscribe = exports.getCurrentSize = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
var subscribe = function subscribe(listener) {
|
|
12
|
+
window.addEventListener("resize", listener);
|
|
13
|
+
return function () {
|
|
14
|
+
return window.removeEventListener("resize", listener);
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
exports.subscribe = subscribe;
|
|
18
|
+
var getCurrentSize = function getCurrentSize(window, breakpointOverrides) {
|
|
19
|
+
var innerWidth = window.innerWidth;
|
|
20
|
+
var sizes = _objectSpread({
|
|
21
|
+
mobile: innerWidth < 768,
|
|
22
|
+
tablet: innerWidth >= 768 && innerWidth < 1024,
|
|
23
|
+
desktop: innerWidth >= 1024 && innerWidth < 1280,
|
|
24
|
+
largeDesktop: innerWidth >= 1280
|
|
25
|
+
}, breakpointOverrides === null || breakpointOverrides === void 0 ? void 0 : breakpointOverrides(window));
|
|
26
|
+
var size = Object.keys(sizes).find(function (breakpoint) {
|
|
27
|
+
return sizes[breakpoint];
|
|
28
|
+
}) || "";
|
|
29
|
+
return size;
|
|
30
|
+
};
|
|
31
|
+
exports.getCurrentSize = getCurrentSize;
|
|
32
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["subscribe","listener","window","addEventListener","removeEventListener","exports","getCurrentSize","breakpointOverrides","innerWidth","sizes","_objectSpread","mobile","tablet","desktop","largeDesktop","size","Object","keys","find","breakpoint"],"sources":["../../../../src/react-utils/useBreakpoints/utils.js"],"sourcesContent":["export const subscribe = listener => {\n window.addEventListener(\"resize\", listener);\n\n return () => window.removeEventListener(\"resize\", listener);\n};\n\nexport const getCurrentSize = (window, breakpointOverrides) => {\n const { innerWidth } = window;\n const sizes = {\n mobile: innerWidth < 768,\n tablet: innerWidth >= 768 && innerWidth < 1024,\n desktop: innerWidth >= 1024 && innerWidth < 1280,\n largeDesktop: innerWidth >= 1280,\n ...breakpointOverrides?.(window),\n };\n\n const size = Object.keys(sizes).find(breakpoint => sizes[breakpoint]) || \"\";\n\n return size;\n};\n"],"mappings":";;;;;;;;;;AAAO,IAAMA,SAAS,GAAG,SAAZA,SAASA,CAAGC,QAAQ,EAAI;EACnCC,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAEF,QAAQ,CAAC;EAE3C,OAAO;IAAA,OAAMC,MAAM,CAACE,mBAAmB,CAAC,QAAQ,EAAEH,QAAQ,CAAC;EAAA;AAC7D,CAAC;AAACI,OAAA,CAAAL,SAAA,GAAAA,SAAA;AAEK,IAAMM,cAAc,GAAG,SAAjBA,cAAcA,CAAIJ,MAAM,EAAEK,mBAAmB,EAAK;EAC7D,IAAQC,UAAU,GAAKN,MAAM,CAArBM,UAAU;EAClB,IAAMC,KAAK,GAAAC,aAAA;IACTC,MAAM,EAAEH,UAAU,GAAG,GAAG;IACxBI,MAAM,EAAEJ,UAAU,IAAI,GAAG,IAAIA,UAAU,GAAG,IAAI;IAC9CK,OAAO,EAAEL,UAAU,IAAI,IAAI,IAAIA,UAAU,GAAG,IAAI;IAChDM,YAAY,EAAEN,UAAU,IAAI;EAAI,GAC7BD,mBAAmB,aAAnBA,mBAAmB,uBAAnBA,mBAAmB,CAAGL,MAAM,CAAC,CACjC;EAED,IAAMa,IAAI,GAAGC,MAAM,CAACC,IAAI,CAACR,KAAK,CAAC,CAACS,IAAI,CAAC,UAAAC,UAAU;IAAA,OAAIV,KAAK,CAACU,UAAU,CAAC;EAAA,EAAC,IAAI,EAAE;EAE3E,OAAOJ,IAAI;AACb,CAAC;AAACV,OAAA,CAAAC,cAAA,GAAAA,cAAA"}
|
|
@@ -45,6 +45,15 @@ module.exports = (on, config) => {
|
|
|
45
45
|
};
|
|
46
46
|
on("file:preprocessor", webpack(options));
|
|
47
47
|
|
|
48
|
+
on("task", {
|
|
49
|
+
log(message) {
|
|
50
|
+
//eslint-disable-next-line
|
|
51
|
+
console.log(message);
|
|
52
|
+
|
|
53
|
+
return null;
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
48
57
|
config = cypressBrowserPermissionsPlugin(on, config);
|
|
49
58
|
|
|
50
59
|
const newEnvironment = merge(config, configForEnvironment);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
package/react-utils/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export { default as useRegisterNavigationCheckpoint } from "./useRegisterNavigat
|
|
|
23
23
|
export { default as useStateWithDependency } from "./useStateWithDependency";
|
|
24
24
|
export { default as useTimer } from "./useTimer";
|
|
25
25
|
export { default as useUpdateEffect } from "./useUpdateEffect";
|
|
26
|
+
export { default as useBreakpoints } from "./useBreakpoints";
|
|
26
27
|
|
|
27
28
|
// utils
|
|
28
29
|
export * from "./BrowserPushNotifications";
|
package/react-utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","HoneybadgerErrorBoundary","PrivateRoute","useDebounce","useDisplayErrorPage","useFetchNeetoApps","useFieldSubmit","useFuncDebounce","useHotKeys","useIsElementVisibleInDom","useKeyboardShortcutsPaneState","useLocalStorage","useMutationWithInvalidation","useOnClickOutside","usePersistedQuery","usePrevious","useQueryParams","useRegisterNavigationCheckpoint","useStateWithDependency","useTimer","useUpdateEffect","withImmutableActions","withT","withTitle"],"sources":["../../src/react-utils/index.js"],"sourcesContent":["// components\nexport { default as HoneybadgerErrorBoundary } from \"./HoneybadgerErrorBoundary\";\nexport { default as PrivateRoute } from \"./PrivateRoute\";\n\n// hooks\nexport { default as useDebounce } from \"./useDebounce\";\nexport * from \"./useDisplayErrorPage\";\nexport { default as useDisplayErrorPage } from \"./useDisplayErrorPage\";\nexport { default as useFetchNeetoApps } from \"./useFetchNeetoApps\";\nexport { default as useFieldSubmit } from \"./useFieldSubmit\";\nexport { default as useFuncDebounce } from \"./useFuncDebounce\";\nexport { default as useHotKeys } from \"./useHotKeys\";\nexport { default as useIsElementVisibleInDom } from \"./useIsElementVisibleInDom\";\nexport { default as useKeyboardShortcutsPaneState } from \"./useKeyboardShortcutsPaneState\";\nexport { default as useLocalStorage } from \"./useLocalStorage\";\nexport { default as useMutationWithInvalidation } from \"./useMutationWithInvalidation\";\nexport { default as useOnClickOutside } from \"./useOnClickOutside\";\nexport { default as usePersistedQuery } from \"./usePersistedQuery\";\nexport { default as usePrevious } from \"./usePrevious\";\nexport { default as useQueryParams } from \"./useQueryParams\";\nexport * from \"./useRegisterNavigationCheckpoint\";\nexport { default as useRegisterNavigationCheckpoint } from \"./useRegisterNavigationCheckpoint\";\nexport { default as useStateWithDependency } from \"./useStateWithDependency\";\nexport { default as useTimer } from \"./useTimer\";\nexport { default as useUpdateEffect } from \"./useUpdateEffect\";\n\n// utils\nexport * from \"./BrowserPushNotifications\";\nexport * from \"./metaClick\";\nexport { default as withImmutableActions } from \"./withImmutableActions\";\nexport { default as withT } from \"./withT\";\nexport { default as withTitle } from \"./withTitle\";\n"],"mappings":"AAAA;AACA,SAASA,OAAO,IAAIC,wBAAwB;AAC5C,SAASD,OAAO,IAAIE,YAAY;;AAEhC;AACA,SAASF,OAAO,IAAIG,WAAW;AAC/B;AACA,SAASH,OAAO,IAAII,mBAAmB;AACvC,SAASJ,OAAO,IAAIK,iBAAiB;AACrC,SAASL,OAAO,IAAIM,cAAc;AAClC,SAASN,OAAO,IAAIO,eAAe;AACnC,SAASP,OAAO,IAAIQ,UAAU;AAC9B,SAASR,OAAO,IAAIS,wBAAwB;AAC5C,SAAST,OAAO,IAAIU,6BAA6B;AACjD,SAASV,OAAO,IAAIW,eAAe;AACnC,SAASX,OAAO,IAAIY,2BAA2B;AAC/C,SAASZ,OAAO,IAAIa,iBAAiB;AACrC,SAASb,OAAO,IAAIc,iBAAiB;AACrC,SAASd,OAAO,IAAIe,WAAW;AAC/B,SAASf,OAAO,IAAIgB,cAAc;AAClC;AACA,SAAShB,OAAO,IAAIiB,+BAA+B;AACnD,SAASjB,OAAO,IAAIkB,sBAAsB;AAC1C,SAASlB,OAAO,IAAImB,QAAQ;AAC5B,SAASnB,OAAO,IAAIoB,eAAe;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","HoneybadgerErrorBoundary","PrivateRoute","useDebounce","useDisplayErrorPage","useFetchNeetoApps","useFieldSubmit","useFuncDebounce","useHotKeys","useIsElementVisibleInDom","useKeyboardShortcutsPaneState","useLocalStorage","useMutationWithInvalidation","useOnClickOutside","usePersistedQuery","usePrevious","useQueryParams","useRegisterNavigationCheckpoint","useStateWithDependency","useTimer","useUpdateEffect","useBreakpoints","withImmutableActions","withT","withTitle"],"sources":["../../src/react-utils/index.js"],"sourcesContent":["// components\nexport { default as HoneybadgerErrorBoundary } from \"./HoneybadgerErrorBoundary\";\nexport { default as PrivateRoute } from \"./PrivateRoute\";\n\n// hooks\nexport { default as useDebounce } from \"./useDebounce\";\nexport * from \"./useDisplayErrorPage\";\nexport { default as useDisplayErrorPage } from \"./useDisplayErrorPage\";\nexport { default as useFetchNeetoApps } from \"./useFetchNeetoApps\";\nexport { default as useFieldSubmit } from \"./useFieldSubmit\";\nexport { default as useFuncDebounce } from \"./useFuncDebounce\";\nexport { default as useHotKeys } from \"./useHotKeys\";\nexport { default as useIsElementVisibleInDom } from \"./useIsElementVisibleInDom\";\nexport { default as useKeyboardShortcutsPaneState } from \"./useKeyboardShortcutsPaneState\";\nexport { default as useLocalStorage } from \"./useLocalStorage\";\nexport { default as useMutationWithInvalidation } from \"./useMutationWithInvalidation\";\nexport { default as useOnClickOutside } from \"./useOnClickOutside\";\nexport { default as usePersistedQuery } from \"./usePersistedQuery\";\nexport { default as usePrevious } from \"./usePrevious\";\nexport { default as useQueryParams } from \"./useQueryParams\";\nexport * from \"./useRegisterNavigationCheckpoint\";\nexport { default as useRegisterNavigationCheckpoint } from \"./useRegisterNavigationCheckpoint\";\nexport { default as useStateWithDependency } from \"./useStateWithDependency\";\nexport { default as useTimer } from \"./useTimer\";\nexport { default as useUpdateEffect } from \"./useUpdateEffect\";\nexport { default as useBreakpoints } from \"./useBreakpoints\";\n\n// utils\nexport * from \"./BrowserPushNotifications\";\nexport * from \"./metaClick\";\nexport { default as withImmutableActions } from \"./withImmutableActions\";\nexport { default as withT } from \"./withT\";\nexport { default as withTitle } from \"./withTitle\";\n"],"mappings":"AAAA;AACA,SAASA,OAAO,IAAIC,wBAAwB;AAC5C,SAASD,OAAO,IAAIE,YAAY;;AAEhC;AACA,SAASF,OAAO,IAAIG,WAAW;AAC/B;AACA,SAASH,OAAO,IAAII,mBAAmB;AACvC,SAASJ,OAAO,IAAIK,iBAAiB;AACrC,SAASL,OAAO,IAAIM,cAAc;AAClC,SAASN,OAAO,IAAIO,eAAe;AACnC,SAASP,OAAO,IAAIQ,UAAU;AAC9B,SAASR,OAAO,IAAIS,wBAAwB;AAC5C,SAAST,OAAO,IAAIU,6BAA6B;AACjD,SAASV,OAAO,IAAIW,eAAe;AACnC,SAASX,OAAO,IAAIY,2BAA2B;AAC/C,SAASZ,OAAO,IAAIa,iBAAiB;AACrC,SAASb,OAAO,IAAIc,iBAAiB;AACrC,SAASd,OAAO,IAAIe,WAAW;AAC/B,SAASf,OAAO,IAAIgB,cAAc;AAClC;AACA,SAAShB,OAAO,IAAIiB,+BAA+B;AACnD,SAASjB,OAAO,IAAIkB,sBAAsB;AAC1C,SAASlB,OAAO,IAAImB,QAAQ;AAC5B,SAASnB,OAAO,IAAIoB,eAAe;AACnC,SAASpB,OAAO,IAAIqB,cAAc;;AAElC;AACA;AACA;AACA,SAASrB,OAAO,IAAIsB,oBAAoB;AACxC,SAAStB,OAAO,IAAIuB,KAAK;AACzB,SAASvB,OAAO,IAAIwB,SAAS"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
import { equals } from "ramda";
|
|
3
|
+
import { getCurrentSize, subscribe } from "./utils";
|
|
4
|
+
var useBreakpoints = function useBreakpoints(breakpointOverrides) {
|
|
5
|
+
var getSnapshot = function getSnapshot() {
|
|
6
|
+
return getCurrentSize(window, breakpointOverrides);
|
|
7
|
+
};
|
|
8
|
+
var currentSize = useSyncExternalStore(subscribe, getSnapshot);
|
|
9
|
+
return {
|
|
10
|
+
currentSize: currentSize,
|
|
11
|
+
isSize: equals(currentSize)
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export default useBreakpoints;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["useSyncExternalStore","equals","getCurrentSize","subscribe","useBreakpoints","breakpointOverrides","getSnapshot","window","currentSize","isSize"],"sources":["../../../src/react-utils/useBreakpoints/index.js"],"sourcesContent":["import { useSyncExternalStore } from \"react\";\n\nimport { equals } from \"ramda\";\n\nimport { getCurrentSize, subscribe } from \"./utils\";\n\nconst useBreakpoints = breakpointOverrides => {\n const getSnapshot = () => getCurrentSize(window, breakpointOverrides);\n const currentSize = useSyncExternalStore(subscribe, getSnapshot);\n\n return { currentSize, isSize: equals(currentSize) };\n};\n\nexport default useBreakpoints;\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,OAAO;AAE5C,SAASC,MAAM,QAAQ,OAAO;AAE9B,SAASC,cAAc,EAAEC,SAAS;AAElC,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,mBAAmB,EAAI;EAC5C,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CAAA;IAAA,OAASJ,cAAc,CAACK,MAAM,EAAEF,mBAAmB,CAAC;EAAA;EACrE,IAAMG,WAAW,GAAGR,oBAAoB,CAACG,SAAS,EAAEG,WAAW,CAAC;EAEhE,OAAO;IAAEE,WAAW,EAAXA,WAAW;IAAEC,MAAM,EAAER,MAAM,CAACO,WAAW;EAAE,CAAC;AACrD,CAAC;AAED,eAAeJ,cAAc"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
export var subscribe = function subscribe(listener) {
|
|
5
|
+
window.addEventListener("resize", listener);
|
|
6
|
+
return function () {
|
|
7
|
+
return window.removeEventListener("resize", listener);
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export var getCurrentSize = function getCurrentSize(window, breakpointOverrides) {
|
|
11
|
+
var innerWidth = window.innerWidth;
|
|
12
|
+
var sizes = _objectSpread({
|
|
13
|
+
mobile: innerWidth < 768,
|
|
14
|
+
tablet: innerWidth >= 768 && innerWidth < 1024,
|
|
15
|
+
desktop: innerWidth >= 1024 && innerWidth < 1280,
|
|
16
|
+
largeDesktop: innerWidth >= 1280
|
|
17
|
+
}, breakpointOverrides === null || breakpointOverrides === void 0 ? void 0 : breakpointOverrides(window));
|
|
18
|
+
var size = Object.keys(sizes).find(function (breakpoint) {
|
|
19
|
+
return sizes[breakpoint];
|
|
20
|
+
}) || "";
|
|
21
|
+
return size;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["subscribe","listener","window","addEventListener","removeEventListener","getCurrentSize","breakpointOverrides","innerWidth","sizes","_objectSpread","mobile","tablet","desktop","largeDesktop","size","Object","keys","find","breakpoint"],"sources":["../../../src/react-utils/useBreakpoints/utils.js"],"sourcesContent":["export const subscribe = listener => {\n window.addEventListener(\"resize\", listener);\n\n return () => window.removeEventListener(\"resize\", listener);\n};\n\nexport const getCurrentSize = (window, breakpointOverrides) => {\n const { innerWidth } = window;\n const sizes = {\n mobile: innerWidth < 768,\n tablet: innerWidth >= 768 && innerWidth < 1024,\n desktop: innerWidth >= 1024 && innerWidth < 1280,\n largeDesktop: innerWidth >= 1280,\n ...breakpointOverrides?.(window),\n };\n\n const size = Object.keys(sizes).find(breakpoint => sizes[breakpoint]) || \"\";\n\n return size;\n};\n"],"mappings":";;;AAAA,OAAO,IAAMA,SAAS,GAAG,SAAZA,SAASA,CAAGC,QAAQ,EAAI;EACnCC,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAEF,QAAQ,CAAC;EAE3C,OAAO;IAAA,OAAMC,MAAM,CAACE,mBAAmB,CAAC,QAAQ,EAAEH,QAAQ,CAAC;EAAA;AAC7D,CAAC;AAED,OAAO,IAAMI,cAAc,GAAG,SAAjBA,cAAcA,CAAIH,MAAM,EAAEI,mBAAmB,EAAK;EAC7D,IAAQC,UAAU,GAAKL,MAAM,CAArBK,UAAU;EAClB,IAAMC,KAAK,GAAAC,aAAA;IACTC,MAAM,EAAEH,UAAU,GAAG,GAAG;IACxBI,MAAM,EAAEJ,UAAU,IAAI,GAAG,IAAIA,UAAU,GAAG,IAAI;IAC9CK,OAAO,EAAEL,UAAU,IAAI,IAAI,IAAIA,UAAU,GAAG,IAAI;IAChDM,YAAY,EAAEN,UAAU,IAAI;EAAI,GAC7BD,mBAAmB,aAAnBA,mBAAmB,uBAAnBA,mBAAmB,CAAGJ,MAAM,CAAC,CACjC;EAED,IAAMY,IAAI,GAAGC,MAAM,CAACC,IAAI,CAACR,KAAK,CAAC,CAACS,IAAI,CAAC,UAAAC,UAAU;IAAA,OAAIV,KAAK,CAACU,UAAU,CAAC;EAAA,EAAC,IAAI,EAAE;EAE3E,OAAOJ,IAAI;AACb,CAAC"}
|
package/react-utils.d.ts
CHANGED
|
@@ -1505,4 +1505,73 @@ export function useMutationWithInvalidation<TData = unknown, TError = unknown, T
|
|
|
1505
1505
|
* const { sort_by, order_by } = useQueryParams({ toCamelCase: false });
|
|
1506
1506
|
* @endexample
|
|
1507
1507
|
*/
|
|
1508
|
-
export function useQueryParams(options?: qsOptionsType): QueryParamsType;
|
|
1508
|
+
export function useQueryParams(options?: qsOptionsType): QueryParamsType;
|
|
1509
|
+
type BreakpointKeys = 'mobile' | 'tablet' | 'desktop' | 'largeDesktop';
|
|
1510
|
+
type Breakpoints = { [key in BreakpointKeys]: boolean };
|
|
1511
|
+
/**
|
|
1512
|
+
*
|
|
1513
|
+
* The useBreakpoints hook is a utility for responsive styling on components
|
|
1514
|
+
*
|
|
1515
|
+
* based on the viewport size. It returns the current breakpoint name and a
|
|
1516
|
+
*
|
|
1517
|
+
* function to check if the current breakpoint matches a given breakpoint name. It
|
|
1518
|
+
*
|
|
1519
|
+
* also re-renders the component when the current breakpoint changes.
|
|
1520
|
+
*
|
|
1521
|
+
* Note: Use this hook only if you need the component to re-render when the
|
|
1522
|
+
*
|
|
1523
|
+
* current breakpoint change happens. If all you need is plain read and write
|
|
1524
|
+
*
|
|
1525
|
+
* operations on the current breakpoint, prefer the vanilla window.matchMedia or
|
|
1526
|
+
*
|
|
1527
|
+
* window.innerWidth API.
|
|
1528
|
+
*
|
|
1529
|
+
* @example
|
|
1530
|
+
*
|
|
1531
|
+
* (window) => {
|
|
1532
|
+
* mobile: window.innerWidth < 768,
|
|
1533
|
+
* tablet: window.innerWidth >= 768 && window.innerWidth < 1024,
|
|
1534
|
+
* desktop: window.innerWidth >= 1024 && window.innerWidth < 1280,
|
|
1535
|
+
* largeDesktop: window.innerWidth >= 1280,
|
|
1536
|
+
* }
|
|
1537
|
+
* @endexample
|
|
1538
|
+
* This hook will return an object with two values currentSize and isSize.
|
|
1539
|
+
*
|
|
1540
|
+
* The following code snippet illustrates the usage of useLocalStorage in
|
|
1541
|
+
*
|
|
1542
|
+
* implementing a theme-switching feature.
|
|
1543
|
+
*
|
|
1544
|
+
* @example
|
|
1545
|
+
*
|
|
1546
|
+
* import { useBreakpoints } from "@bigbinary/neeto-commons-frontend/react-utils";
|
|
1547
|
+
*
|
|
1548
|
+
* const { currentSize, isSize } = useBreakpoints();
|
|
1549
|
+
*
|
|
1550
|
+
* // When window.innerWidth is 1028
|
|
1551
|
+
* console.log(currentSize); // logs `tablet`
|
|
1552
|
+
* console.log(isSize("mobile")); // logs `false`
|
|
1553
|
+
* console.log(isSize("tablet")); // logs `true`
|
|
1554
|
+
* @endexample
|
|
1555
|
+
* We can also override the default breakpoints by passing a function to the
|
|
1556
|
+
*
|
|
1557
|
+
* useBreakpoints hook.
|
|
1558
|
+
*
|
|
1559
|
+
* @example
|
|
1560
|
+
*
|
|
1561
|
+
* import { useBreakpoints } from "@bigbinary/neeto-commons-frontend/react-utils";
|
|
1562
|
+
*
|
|
1563
|
+
* // Overriding the default breakpoints
|
|
1564
|
+
* const { currentSize, isSize } = useBreakpoints(window => ({
|
|
1565
|
+
* largeDesktop: window.innerWidth >= 1280 && window.innerWidth < 1440,
|
|
1566
|
+
* extraLargeDesktop: window.innerWidth >= 1440,
|
|
1567
|
+
* }));
|
|
1568
|
+
*
|
|
1569
|
+
* // When window.innerWidth is 1440
|
|
1570
|
+
* console.log(currentSize); // logs `extraLargeDesktop`
|
|
1571
|
+
* console.log(isSize("extraLargeDesktop")); // logs `true`
|
|
1572
|
+
* @endexample
|
|
1573
|
+
*/
|
|
1574
|
+
export function useBreakpoints<T extends {}>(breakpointOverrides?: (window: Window) => Partial<T & Breakpoints>): {
|
|
1575
|
+
currentSize: BreakpointKeys | keyof T;
|
|
1576
|
+
isSize: (size: BreakpointKeys | keyof T) => boolean;
|
|
1577
|
+
};
|