UNPKG

@wordpress/components

Version:
47 lines (36 loc) 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useFormGroupContextId = exports.useFormGroupContext = exports.FormGroupContext = void 0; var _element = require("@wordpress/element"); /** * WordPress dependencies */ /** * @typedef {{ id?: import('react').ReactText, horizontal: boolean }} FormGroupContext */ /** * @type {FormGroupContext} */ const initialContext = { id: undefined, horizontal: true }; /** * @type {import('react').Context<FormGroupContext>} */ const FormGroupContext = (0, _element.createContext)(initialContext); exports.FormGroupContext = FormGroupContext; const useFormGroupContext = () => (0, _element.useContext)(FormGroupContext); /** * @param {string | undefined} id The preferred id for the form group element. * @return {import('react').ReactText | undefined} The form group context id. */ exports.useFormGroupContext = useFormGroupContext; const useFormGroupContextId = id => { const contextId = useFormGroupContext().id; return id || contextId; }; exports.useFormGroupContextId = useFormGroupContextId; //# sourceMappingURL=form-group-context.js.map