@qoretechnologies/reqore 0.78.5-pr.708.g98ba321 → 0.78.5-pr.708.g9ef15cc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DataView/index.d.ts.map +1 -1
- package/dist/components/DataView/index.js +5 -6
- package/dist/components/DataView/index.js.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +34 -7
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Dropdown/list.js +36 -3
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/RowActionsMenu/index.d.ts.map +1 -1
- package/dist/components/RowActionsMenu/index.js +3 -1
- package/dist/components/RowActionsMenu/index.js.map +1 -1
- package/dist/components/Statistic/index.d.ts.map +1 -1
- package/dist/components/Statistic/index.js +4 -1
- package/dist/components/Statistic/index.js.map +1 -1
- package/dist/components/Timeline/index.d.ts.map +1 -1
- package/dist/components/Timeline/index.js +5 -4
- package/dist/components/Timeline/index.js.map +1 -1
- package/dist/components/Tree/modal.d.ts.map +1 -1
- package/dist/components/Tree/modal.js +3 -1
- package/dist/components/Tree/modal.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +27 -13
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/hooks/useCloneThroughFragments.d.ts.map +1 -1
- package/dist/hooks/useCloneThroughFragments.js +27 -0
- package/dist/hooks/useCloneThroughFragments.js.map +1 -1
- package/dist/hooks/useReqoreMedia.d.ts +14 -7
- package/dist/hooks/useReqoreMedia.d.ts.map +1 -1
- package/dist/hooks/useReqoreMedia.js +30 -9
- package/dist/hooks/useReqoreMedia.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useReqoreMedia = exports.CAN_QUERY_MEDIA = void 0;
|
|
4
|
-
var
|
|
4
|
+
var react_1 = require("react");
|
|
5
5
|
/**
|
|
6
6
|
* Whether this environment can answer a media query at all. Decided ONCE at
|
|
7
|
-
* module load, on purpose:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* (several do, to drive their own hooks) must not be able to flip it.
|
|
7
|
+
* module load, on purpose: a test that defines `window.matchMedia` after the
|
|
8
|
+
* module loaded (several do, to drive their own hooks) must not be able to
|
|
9
|
+
* flip it, and hand its own stub to every Reqore component.
|
|
11
10
|
*
|
|
12
11
|
* jsdom has no `matchMedia`, so unit tests get fixed defaults. A real browser —
|
|
13
12
|
* the app, the Storybook dev server AND the browser-mode story runner — gets
|
|
@@ -18,15 +17,37 @@ var react_use_1 = require("react-use");
|
|
|
18
17
|
*/
|
|
19
18
|
exports.CAN_QUERY_MEDIA = typeof window !== 'undefined' && typeof window.matchMedia === 'function';
|
|
20
19
|
/**
|
|
21
|
-
*
|
|
22
|
-
* evaluated (jsdom, SSR) instead of throwing. Reqore owns the
|
|
23
|
-
* this is for Reqore's own components — the provider's `isMobile` /
|
|
20
|
+
* Whether a media query matches, live: `defaultState` where media queries
|
|
21
|
+
* cannot be evaluated (jsdom, SSR), instead of throwing. Reqore owns the
|
|
22
|
+
* breakpoints: this is for Reqore's own components — the provider's `isMobile` /
|
|
24
23
|
* `isTablet` / `isHoverCapable` and the drawer's sheet breakpoint — not a
|
|
25
24
|
* licence for a consumer to hand-roll a query of its own.
|
|
25
|
+
*
|
|
26
|
+
* The FIRST render already has the answer. It used to be react-use's
|
|
27
|
+
* `useMedia(query, defaultState)`, which renders `defaultState` first and only
|
|
28
|
+
* asks the browser in an effect: on a phone, a `responsiveLayout` drawer
|
|
29
|
+
* mounted as the caller's side panel for one render before it became a sheet,
|
|
30
|
+
* and a floating one kept the side panel's `right: 10px` from that render (a
|
|
31
|
+
* 380px sheet on a 390px phone). Where the query can be evaluated it is asked
|
|
32
|
+
* as the state is made, and the effect keeps it current from then on.
|
|
26
33
|
*/
|
|
27
34
|
var useReqoreMedia = function (query, defaultState) {
|
|
28
35
|
if (defaultState === void 0) { defaultState = false; }
|
|
29
|
-
|
|
36
|
+
var _a = (0, react_1.useState)(function () {
|
|
37
|
+
return exports.CAN_QUERY_MEDIA ? window.matchMedia(query).matches : defaultState;
|
|
38
|
+
}), matches = _a[0], setMatches = _a[1];
|
|
39
|
+
(0, react_1.useEffect)(function () {
|
|
40
|
+
if (!exports.CAN_QUERY_MEDIA) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
var list = window.matchMedia(query);
|
|
44
|
+
var update = function () { return setMatches(list.matches); };
|
|
45
|
+
// A new query, or a change between the render and this effect.
|
|
46
|
+
update();
|
|
47
|
+
list.addEventListener('change', update);
|
|
48
|
+
return function () { return list.removeEventListener('change', update); };
|
|
49
|
+
}, [query]);
|
|
50
|
+
return matches;
|
|
30
51
|
};
|
|
31
52
|
exports.useReqoreMedia = useReqoreMedia;
|
|
32
53
|
//# sourceMappingURL=useReqoreMedia.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReqoreMedia.js","sourceRoot":"","sources":["../../src/hooks/useReqoreMedia.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"useReqoreMedia.js","sourceRoot":"","sources":["../../src/hooks/useReqoreMedia.ts"],"names":[],"mappings":";;;AAAA,+BAA4C;AAE5C;;;;;;;;;;;;GAYG;AACU,QAAA,eAAe,GAC1B,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACI,IAAM,cAAc,GAAG,UAAC,KAAa,EAAE,YAAoB;IAApB,6BAAA,EAAA,oBAAoB;IAC1D,IAAA,KAAwB,IAAA,gBAAQ,EAAC;QACrC,OAAA,uBAAe,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY;IAAjE,CAAiE,CAClE,EAFM,OAAO,QAAA,EAAE,UAAU,QAEzB,CAAC;IAEF,IAAA,iBAAS,EAAC;QACR,IAAI,CAAC,uBAAe,EAAE,CAAC;YACrB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACtC,IAAM,MAAM,GAAG,cAAM,OAAA,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAxB,CAAwB,CAAC;QAE9C,+DAA+D;QAC/D,MAAM,EAAE,CAAC;QACT,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAExC,OAAO,cAAM,OAAA,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAA1C,CAA0C,CAAC;IAC1D,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AArBW,QAAA,cAAc,kBAqBzB"}
|
package/package.json
CHANGED