Debian Codegraph @

node/@patternfly/react-core/dist/js/helpers/SSRSafeIds/SSRSafeIds.js

raw
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.SSRSafeIds = void 0;
4 const useSSRSafeId_1 = require("../useSSRSafeId");
5 const ouiaPrefix = 'OUIA-Generated-';
6 /**
7 * Provides SSR/Strict-Mode-safe IDs for class components via render props.
8 * Uses useSSRSafeId() (React.useId) for both component ID and OUIA ID,
9 * ensuring consistent values between server and client rendering.
10 */
11 const SSRSafeIds = ({ prefix, ouiaComponentType, children }) => {
12 var _a;
13 const id = (0, useSSRSafeId_1.useSSRSafeId)(prefix);
14 const ouiaId = (0, useSSRSafeId_1.useSSRSafeId)(ouiaComponentType ? `${ouiaPrefix}${ouiaComponentType}-` : 'pf-unused-');
15 return (_a = children(id, ouiaComponentType ? ouiaId : undefined)) !== null && _a !== void 0 ? _a : null;
16 };
17 exports.SSRSafeIds = SSRSafeIds;
18 exports.SSRSafeIds.displayName = 'SSRSafeIds';
19 //# sourceMappingURL=SSRSafeIds.js.map