@instructure/ui-react-utils 11.7.10 → 11.7.11-snapshot-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/CHANGELOG.md +7 -0
- package/es/HydrationContext/HydrationContext.js +33 -0
- package/es/HydrationContext/HydrationGate.js +49 -0
- package/es/HydrationContext/HydrationProvider.js +49 -0
- package/es/HydrationContext/index.js +28 -0
- package/es/HydrationContext/useIsHydratedContext.js +46 -0
- package/es/index.js +3 -1
- package/es/useIsHydrated.js +45 -0
- package/lib/HydrationContext/HydrationContext.js +37 -0
- package/lib/HydrationContext/HydrationGate.js +55 -0
- package/lib/HydrationContext/HydrationProvider.js +55 -0
- package/lib/HydrationContext/index.js +33 -0
- package/lib/HydrationContext/useIsHydratedContext.js +51 -0
- package/lib/index.js +33 -1
- package/lib/useIsHydrated.js +50 -0
- package/package.json +7 -7
- package/src/HydrationContext/HydrationContext.ts +34 -0
- package/src/HydrationContext/HydrationGate.tsx +54 -0
- package/src/HydrationContext/HydrationProvider.tsx +57 -0
- package/src/HydrationContext/index.ts +30 -0
- package/src/HydrationContext/useIsHydratedContext.ts +48 -0
- package/src/index.ts +12 -0
- package/src/useIsHydrated.ts +47 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/HydrationContext/HydrationContext.d.ts +8 -0
- package/types/HydrationContext/HydrationContext.d.ts.map +1 -0
- package/types/HydrationContext/HydrationGate.d.ts +25 -0
- package/types/HydrationContext/HydrationGate.d.ts.map +1 -0
- package/types/HydrationContext/HydrationProvider.d.ts +20 -0
- package/types/HydrationContext/HydrationProvider.d.ts.map +1 -0
- package/types/HydrationContext/index.d.ts +7 -0
- package/types/HydrationContext/index.d.ts.map +1 -0
- package/types/HydrationContext/useIsHydratedContext.d.ts +14 -0
- package/types/HydrationContext/useIsHydratedContext.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -1
- package/types/useIsHydrated.d.ts +15 -0
- package/types/useIsHydrated.d.ts.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [11.7.11-snapshot-0](https://github.com/instructure/instructure-ui/compare/v11.7.10...v11.7.11-snapshot-0) (2026-10-14)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **INSTUI-5156:** new skeleton loader ([#2720](https://github.com/instructure/instructure-ui/issues/2720)) ([f83433e](https://github.com/instructure/instructure-ui/commit/f83433ee71854ecc409ee042fabbcf9b92336a3a))
|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
## [11.7.10](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.10) (2026-10-14)
|
|
7
14
|
|
|
8
15
|
**Note:** Version bump only for package @instructure/ui-react-utils
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { createContext } from 'react';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Whether the page has hydrated. `undefined` means there's no
|
|
29
|
+
* `HydrationProvider` above, and `false` means hydration hasn't finished yet.
|
|
30
|
+
*/
|
|
31
|
+
const HydrationContext = /*#__PURE__*/createContext(undefined);
|
|
32
|
+
export { HydrationContext };
|
|
33
|
+
export default HydrationContext;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useIsHydratedContext } from './useIsHydratedContext.js';
|
|
26
|
+
import { Fragment as _Fragment, jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
27
|
+
/**
|
|
28
|
+
* ---
|
|
29
|
+
* category: utilities/SSR
|
|
30
|
+
* ---
|
|
31
|
+
* Lets class components know whether the page has hydrated. It works with or
|
|
32
|
+
* without a `HydrationProvider` above it.
|
|
33
|
+
*
|
|
34
|
+
* ```jsx
|
|
35
|
+
* <HydrationGate>
|
|
36
|
+
* {(isHydrated) => (isHydrated ? <Content /> : <Placeholder />)}
|
|
37
|
+
* </HydrationGate>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
function HydrationGate({
|
|
41
|
+
children
|
|
42
|
+
}) {
|
|
43
|
+
return _jsx(_Fragment, {
|
|
44
|
+
children: children(useIsHydratedContext())
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
HydrationGate.displayName = 'HydrationGate';
|
|
48
|
+
export { HydrationGate };
|
|
49
|
+
export default HydrationGate;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { HydrationContext } from './HydrationContext.js';
|
|
26
|
+
import { useIsHydrated } from '../useIsHydrated.js';
|
|
27
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
28
|
+
/**
|
|
29
|
+
* ---
|
|
30
|
+
* category: utilities/SSR
|
|
31
|
+
* ---
|
|
32
|
+
* Shares whether the page has hydrated with every component below it, so they
|
|
33
|
+
* all switch from their server output at the same time. Class components read
|
|
34
|
+
* it with `HydrationGate`.
|
|
35
|
+
*
|
|
36
|
+
* `InstUISettingsProvider` already includes it, so you usually don't need to
|
|
37
|
+
* add it yourself.
|
|
38
|
+
*/
|
|
39
|
+
function HydrationProvider({
|
|
40
|
+
children
|
|
41
|
+
}) {
|
|
42
|
+
const isHydrated = useIsHydrated();
|
|
43
|
+
return _jsx(HydrationContext.Provider, {
|
|
44
|
+
value: isHydrated,
|
|
45
|
+
children: children
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export { HydrationProvider };
|
|
49
|
+
export default HydrationProvider;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export { HydrationContext } from './HydrationContext.js';
|
|
26
|
+
export { HydrationProvider } from './HydrationProvider.js';
|
|
27
|
+
export { useIsHydratedContext } from './useIsHydratedContext.js';
|
|
28
|
+
export { HydrationGate } from './HydrationGate.js';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useContext } from 'react';
|
|
26
|
+
import { HydrationContext } from './HydrationContext.js';
|
|
27
|
+
import { useIsHydrated } from '../useIsHydrated.js';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* ---
|
|
31
|
+
* category: utilities/SSR
|
|
32
|
+
* ---
|
|
33
|
+
* Like `useIsHydrated`, but reads the value from the nearest
|
|
34
|
+
* `HydrationProvider` when there is one.
|
|
35
|
+
*
|
|
36
|
+
* @module useIsHydratedContext
|
|
37
|
+
* @returns {boolean} `true` once the page has hydrated
|
|
38
|
+
*/
|
|
39
|
+
const useIsHydratedContext = () => {
|
|
40
|
+
const fromProvider = useContext(HydrationContext);
|
|
41
|
+
// Hooks can't be called conditionally, so this always runs.
|
|
42
|
+
const standalone = useIsHydrated();
|
|
43
|
+
return fromProvider ?? standalone;
|
|
44
|
+
};
|
|
45
|
+
export { useIsHydratedContext };
|
|
46
|
+
export default useIsHydratedContext;
|
package/es/index.js
CHANGED
|
@@ -33,5 +33,7 @@ export { omitProps } from './omitProps.js';
|
|
|
33
33
|
export { passthroughProps } from './passthroughProps.js';
|
|
34
34
|
export { pickProps } from './pickProps.js';
|
|
35
35
|
export { safeCloneElement } from './safeCloneElement.js';
|
|
36
|
+
export { useIsHydrated } from './useIsHydrated.js';
|
|
36
37
|
export { windowMessageListener } from './windowMessageListener.js';
|
|
37
|
-
export { DeterministicIdContext, DeterministicIdContextProvider, withDeterministicId, useDeterministicId } from './DeterministicIdContext/index.js';
|
|
38
|
+
export { DeterministicIdContext, DeterministicIdContextProvider, withDeterministicId, useDeterministicId } from './DeterministicIdContext/index.js';
|
|
39
|
+
export { HydrationContext, HydrationProvider, useIsHydratedContext, HydrationGate } from './HydrationContext/index.js';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useSyncExternalStore } from 'react';
|
|
26
|
+
|
|
27
|
+
// The value never changes, so there's nothing to subscribe to.
|
|
28
|
+
const noopSubscribe = () => () => {};
|
|
29
|
+
const getClientSnapshot = () => true;
|
|
30
|
+
const getServerSnapshot = () => false;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ---
|
|
34
|
+
* category: utilities/SSR
|
|
35
|
+
* ---
|
|
36
|
+
* Returns `false` on the server and while React is hydrating, then `true`.
|
|
37
|
+
* Use it to render something different on the client without causing a
|
|
38
|
+
* hydration mismatch. In class components, use `HydrationGate` instead.
|
|
39
|
+
*
|
|
40
|
+
* @module useIsHydrated
|
|
41
|
+
* @returns {boolean} `true` once the page has hydrated
|
|
42
|
+
*/
|
|
43
|
+
const useIsHydrated = () => useSyncExternalStore(noopSubscribe, getClientSnapshot, getServerSnapshot);
|
|
44
|
+
export default useIsHydrated;
|
|
45
|
+
export { useIsHydrated };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.HydrationContext = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/*
|
|
9
|
+
* The MIT License (MIT)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Whether the page has hydrated. `undefined` means there's no
|
|
34
|
+
* `HydrationProvider` above, and `false` means hydration hasn't finished yet.
|
|
35
|
+
*/
|
|
36
|
+
const HydrationContext = exports.HydrationContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
37
|
+
var _default = exports.default = HydrationContext;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HydrationGate = HydrationGate;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _useIsHydratedContext = require("./useIsHydratedContext.js");
|
|
9
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
|
+
/*
|
|
11
|
+
* The MIT License (MIT)
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* ---
|
|
36
|
+
* category: utilities/SSR
|
|
37
|
+
* ---
|
|
38
|
+
* Lets class components know whether the page has hydrated. It works with or
|
|
39
|
+
* without a `HydrationProvider` above it.
|
|
40
|
+
*
|
|
41
|
+
* ```jsx
|
|
42
|
+
* <HydrationGate>
|
|
43
|
+
* {(isHydrated) => (isHydrated ? <Content /> : <Placeholder />)}
|
|
44
|
+
* </HydrationGate>
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function HydrationGate({
|
|
48
|
+
children
|
|
49
|
+
}) {
|
|
50
|
+
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
51
|
+
children: children((0, _useIsHydratedContext.useIsHydratedContext)())
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
HydrationGate.displayName = 'HydrationGate';
|
|
55
|
+
var _default = exports.default = HydrationGate;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HydrationProvider = HydrationProvider;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _HydrationContext = require("./HydrationContext.js");
|
|
9
|
+
var _useIsHydrated = require("../useIsHydrated.js");
|
|
10
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
11
|
+
/*
|
|
12
|
+
* The MIT License (MIT)
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
15
|
+
*
|
|
16
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
17
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
18
|
+
* in the Software without restriction, including without limitation the rights
|
|
19
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
20
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
21
|
+
* furnished to do so, subject to the following conditions:
|
|
22
|
+
*
|
|
23
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
* copies or substantial portions of the Software.
|
|
25
|
+
*
|
|
26
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
* SOFTWARE.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* ---
|
|
37
|
+
* category: utilities/SSR
|
|
38
|
+
* ---
|
|
39
|
+
* Shares whether the page has hydrated with every component below it, so they
|
|
40
|
+
* all switch from their server output at the same time. Class components read
|
|
41
|
+
* it with `HydrationGate`.
|
|
42
|
+
*
|
|
43
|
+
* `InstUISettingsProvider` already includes it, so you usually don't need to
|
|
44
|
+
* add it yourself.
|
|
45
|
+
*/
|
|
46
|
+
function HydrationProvider({
|
|
47
|
+
children
|
|
48
|
+
}) {
|
|
49
|
+
const isHydrated = (0, _useIsHydrated.useIsHydrated)();
|
|
50
|
+
return (0, _jsxRuntime.jsx)(_HydrationContext.HydrationContext.Provider, {
|
|
51
|
+
value: isHydrated,
|
|
52
|
+
children: children
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
var _default = exports.default = HydrationProvider;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "HydrationContext", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _HydrationContext.HydrationContext;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "HydrationGate", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _HydrationGate.HydrationGate;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "HydrationProvider", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _HydrationProvider.HydrationProvider;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "useIsHydratedContext", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _useIsHydratedContext.useIsHydratedContext;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _HydrationContext = require("./HydrationContext.js");
|
|
31
|
+
var _HydrationProvider = require("./HydrationProvider.js");
|
|
32
|
+
var _useIsHydratedContext = require("./useIsHydratedContext.js");
|
|
33
|
+
var _HydrationGate = require("./HydrationGate.js");
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useIsHydratedContext = exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _HydrationContext = require("./HydrationContext.js");
|
|
9
|
+
var _useIsHydrated = require("../useIsHydrated.js");
|
|
10
|
+
/*
|
|
11
|
+
* The MIT License (MIT)
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* ---
|
|
36
|
+
* category: utilities/SSR
|
|
37
|
+
* ---
|
|
38
|
+
* Like `useIsHydrated`, but reads the value from the nearest
|
|
39
|
+
* `HydrationProvider` when there is one.
|
|
40
|
+
*
|
|
41
|
+
* @module useIsHydratedContext
|
|
42
|
+
* @returns {boolean} `true` once the page has hydrated
|
|
43
|
+
*/
|
|
44
|
+
const useIsHydratedContext = () => {
|
|
45
|
+
const fromProvider = (0, _react.useContext)(_HydrationContext.HydrationContext);
|
|
46
|
+
// Hooks can't be called conditionally, so this always runs.
|
|
47
|
+
const standalone = (0, _useIsHydrated.useIsHydrated)();
|
|
48
|
+
return fromProvider ?? standalone;
|
|
49
|
+
};
|
|
50
|
+
exports.useIsHydratedContext = useIsHydratedContext;
|
|
51
|
+
var _default = exports.default = useIsHydratedContext;
|
package/lib/index.js
CHANGED
|
@@ -15,6 +15,24 @@ Object.defineProperty(exports, "DeterministicIdContextProvider", {
|
|
|
15
15
|
return _index.DeterministicIdContextProvider;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "HydrationContext", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _index2.HydrationContext;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "HydrationGate", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _index2.HydrationGate;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "HydrationProvider", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _index2.HydrationProvider;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
18
36
|
Object.defineProperty(exports, "callRenderProp", {
|
|
19
37
|
enumerable: true,
|
|
20
38
|
get: function () {
|
|
@@ -81,6 +99,18 @@ Object.defineProperty(exports, "useDeterministicId", {
|
|
|
81
99
|
return _index.useDeterministicId;
|
|
82
100
|
}
|
|
83
101
|
});
|
|
102
|
+
Object.defineProperty(exports, "useIsHydrated", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _useIsHydrated.useIsHydrated;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "useIsHydratedContext", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () {
|
|
111
|
+
return _index2.useIsHydratedContext;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
84
114
|
Object.defineProperty(exports, "windowMessageListener", {
|
|
85
115
|
enumerable: true,
|
|
86
116
|
get: function () {
|
|
@@ -103,5 +133,7 @@ var _omitProps = require("./omitProps.js");
|
|
|
103
133
|
var _passthroughProps = require("./passthroughProps.js");
|
|
104
134
|
var _pickProps = require("./pickProps.js");
|
|
105
135
|
var _safeCloneElement = require("./safeCloneElement.js");
|
|
136
|
+
var _useIsHydrated = require("./useIsHydrated.js");
|
|
106
137
|
var _windowMessageListener = require("./windowMessageListener.js");
|
|
107
|
-
var _index = require("./DeterministicIdContext/index.js");
|
|
138
|
+
var _index = require("./DeterministicIdContext/index.js");
|
|
139
|
+
var _index2 = require("./HydrationContext/index.js");
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useIsHydrated = exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/*
|
|
9
|
+
* The MIT License (MIT)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
// The value never changes, so there's nothing to subscribe to.
|
|
33
|
+
const noopSubscribe = () => () => {};
|
|
34
|
+
const getClientSnapshot = () => true;
|
|
35
|
+
const getServerSnapshot = () => false;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* ---
|
|
39
|
+
* category: utilities/SSR
|
|
40
|
+
* ---
|
|
41
|
+
* Returns `false` on the server and while React is hydrating, then `true`.
|
|
42
|
+
* Use it to render something different on the client without causing a
|
|
43
|
+
* hydration mismatch. In class components, use `HydrationGate` instead.
|
|
44
|
+
*
|
|
45
|
+
* @module useIsHydrated
|
|
46
|
+
* @returns {boolean} `true` once the page has hydrated
|
|
47
|
+
*/
|
|
48
|
+
const useIsHydrated = () => (0, _react.useSyncExternalStore)(noopSubscribe, getClientSnapshot, getServerSnapshot);
|
|
49
|
+
exports.useIsHydrated = useIsHydrated;
|
|
50
|
+
var _default = exports.default = useIsHydrated;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-react-utils",
|
|
3
|
-
"version": "11.7.
|
|
3
|
+
"version": "11.7.11-snapshot-0",
|
|
4
4
|
"description": "A React utility library made by Instructure Inc.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.29.7",
|
|
18
18
|
"@emotion/is-prop-valid": "^1.4.0",
|
|
19
|
-
"@instructure/console": "11.7.
|
|
20
|
-
"@instructure/shared-types": "11.7.
|
|
21
|
-
"@instructure/ui-decorator": "11.7.
|
|
22
|
-
"@instructure/ui-dom-utils": "11.7.
|
|
23
|
-
"@instructure/ui-utils": "11.7.
|
|
19
|
+
"@instructure/console": "11.7.11-snapshot-0",
|
|
20
|
+
"@instructure/shared-types": "11.7.11-snapshot-0",
|
|
21
|
+
"@instructure/ui-decorator": "11.7.11-snapshot-0",
|
|
22
|
+
"@instructure/ui-dom-utils": "11.7.11-snapshot-0",
|
|
23
|
+
"@instructure/ui-utils": "11.7.11-snapshot-0",
|
|
24
24
|
"hoist-non-react-statics": "^3.3.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@instructure/ui-babel-preset": "11.7.
|
|
27
|
+
"@instructure/ui-babel-preset": "11.7.11-snapshot-0",
|
|
28
28
|
"@types/hoist-non-react-statics": "^3.3.7",
|
|
29
29
|
"vitest": "^5.0.0"
|
|
30
30
|
},
|