@cgi-learning-hub/ui
Version:
@cgi-learning-hub/ui is an open-source React component library that implements UI for HUB's features
192 lines (191 loc) • 5.51 kB
JavaScript
import * as l from "react";
import { P as o } from "./index-B9vkf41S.js";
import { F as C, G as v, H as g } from "./generateUtilityClasses-B_xKAflz.js";
import { b as M } from "./Radio-DiyDpiVL.js";
import { jsx as w } from "react/jsx-runtime";
import { u as S } from "./useControlled-nm4pBabJ.js";
import { u as P } from "./useForkRef-u29GSuCu.js";
import { u as U } from "./useId-CK6Kn3Tn.js";
import { u as V } from "./useFormControl-CatNKXAi.js";
import { f as D } from "./formControlState-vgaj2ksH.js";
import { u as O, s as T, c as F } from "./DefaultPropsProvider-BrmlvPWg.js";
function j(r) {
return v("MuiFormGroup", r);
}
const X = C("MuiFormGroup", ["root", "row", "error"]), E = (r) => {
const {
classes: e,
row: s,
error: t
} = r;
return F({
root: ["root", s && "row", t && "error"]
}, j, e);
}, k = T("div", {
name: "MuiFormGroup",
slot: "Root",
overridesResolver: (r, e) => {
const {
ownerState: s
} = r;
return [e.root, s.row && e.row];
}
})({
display: "flex",
flexDirection: "column",
flexWrap: "wrap",
variants: [{
props: {
row: !0
},
style: {
flexDirection: "row"
}
}]
}), h = /* @__PURE__ */ l.forwardRef(function(e, s) {
const t = O({
props: e,
name: "MuiFormGroup"
}), {
className: n,
row: i = !1,
...p
} = t, m = V(), u = D({
props: t,
muiFormControl: m,
states: ["error"]
}), c = {
...t,
row: i,
error: u.error
}, f = E(c);
return /* @__PURE__ */ w(k, {
className: g(f.root, n),
ownerState: c,
ref: s,
...p
});
});
process.env.NODE_ENV !== "production" && (h.propTypes = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* The content of the component.
*/
children: o.node,
/**
* Override or extend the styles applied to the component.
*/
classes: o.object,
/**
* @ignore
*/
className: o.string,
/**
* Display group of elements in a compact row.
* @default false
*/
row: o.bool,
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx: o.oneOfType([o.arrayOf(o.oneOfType([o.func, o.object, o.bool])), o.func, o.object])
});
function q(r) {
return v("MuiRadioGroup", r);
}
const Y = C("MuiRadioGroup", ["root", "row", "error"]), H = (r) => {
const {
classes: e,
row: s,
error: t
} = r;
return F({
root: ["root", s && "row", t && "error"]
}, q, e);
}, I = /* @__PURE__ */ l.forwardRef(function(e, s) {
const {
// private
// eslint-disable-next-line react/prop-types
actions: t,
children: n,
className: i,
defaultValue: p,
name: m,
onChange: u,
value: c,
...f
} = e, d = l.useRef(null), x = H(e), [y, G] = S({
controlled: c,
default: p,
name: "RadioGroup"
});
l.useImperativeHandle(t, () => ({
focus: () => {
let a = d.current.querySelector("input:not(:disabled):checked");
a || (a = d.current.querySelector("input:not(:disabled)")), a && a.focus();
}
}), []);
const N = P(s, d), R = U(m), b = l.useMemo(() => ({
name: R,
onChange(a) {
G(a.target.value), u && u(a, a.target.value);
},
value: y
}), [R, u, G, y]);
return /* @__PURE__ */ w(M.Provider, {
value: b,
children: /* @__PURE__ */ w(h, {
role: "radiogroup",
ref: N,
className: g(x.root, i),
...f,
children: n
})
});
});
process.env.NODE_ENV !== "production" && (I.propTypes = {
// ┌────────────────────────────── Warning ──────────────────────────────┐
// │ These PropTypes are generated from the TypeScript type definitions. │
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
// └─────────────────────────────────────────────────────────────────────┘
/**
* The content of the component.
*/
children: o.node,
/**
* @ignore
*/
className: o.string,
/**
* The default value. Use when the component is not controlled.
*/
defaultValue: o.any,
/**
* The name used to reference the value of the control.
* If you don't provide this prop, it falls back to a randomly generated name.
*/
name: o.string,
/**
* Callback fired when a radio button is selected.
*
* @param {React.ChangeEvent<HTMLInputElement>} event The event source of the callback.
* @param {string} value The value of the selected radio button.
* You can pull out the new value by accessing `event.target.value` (string).
*/
onChange: o.func,
/**
* Value of the selected radio button. The DOM API casts this to a string.
*/
value: o.any
});
export {
h as F,
I as R,
q as a,
X as f,
j as g,
Y as r
};