118 lines
6.5 KiB
JavaScript
118 lines
6.5 KiB
JavaScript
"use strict";
|
|
exports.id = 2348;
|
|
exports.ids = [2348];
|
|
exports.modules = {
|
|
|
|
/***/ 2348:
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "Z": () => (/* binding */ FormRadios)
|
|
/* harmony export */ });
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(997);
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - Server props
|
|
* @param {{
|
|
* title: string,
|
|
* payload: string | boolean,
|
|
* default?: boolean,
|
|
* jsx?: React.ReactNode,
|
|
* onChangeHandler?: (e: any) => void,
|
|
* }[]} props.radioValues - array of objects
|
|
* @param {string} props.name - form radios collective name
|
|
* @param {(e: any) => void} [props.onChangeHandler] - when radios change
|
|
* @param {React.Dispatch<React.SetStateAction<any>>} [props.setAlert] - set an external alert dispatch
|
|
* @param {boolean} [props.flexRow] - if the radio and label are stacked on each other or side-by-side
|
|
* @param {string} [props.labelColor] - Label color using tailwind syntax
|
|
* @param {boolean} [props.baseText] - Font size regular
|
|
* @param {boolean} [props.smallText] - Font size smaller
|
|
* @param {string} [props.className] - Additional class names for the wrapper
|
|
*/ function FormRadios({ radioValues , name , onChangeHandler , setAlert , flexRow , labelColor , baseText , smallText , className , }) {
|
|
try {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
|
|
className: "flex items-start gap-4 flex-wrap " + (flexRow ? "" : " flex-col ") + (className ? className : ""),
|
|
children: radioValues.map((value, index)=>{
|
|
const { payload , title , jsx } = value;
|
|
const radioPayload = payload === false ? payload : payload ? payload : title ? title : null;
|
|
return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
|
|
className: "flex items-center gap-2",
|
|
children: [
|
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("input", {
|
|
className: "m-0" + (baseText ? " w-5 h-5" : smallText ? " w-4 h-4" : " w-6 h-6"),
|
|
type: "radio",
|
|
defaultChecked: value.default ? true : false,
|
|
name: name,
|
|
id: name + "_" + radioPayload,
|
|
onChange: (e)=>{
|
|
if (setAlert) setAlert(null);
|
|
if (value.onChangeHandler) {
|
|
value.onChangeHandler(e);
|
|
} else if (onChangeHandler) {
|
|
onChangeHandler(e);
|
|
}
|
|
},
|
|
value: typeof radioPayload == "string" ? radioPayload : undefined
|
|
}),
|
|
jsx ? jsx : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
|
|
htmlFor: name + "_" + radioPayload,
|
|
className: "text-lg m-0 " + (labelColor ? labelColor : "text-slate-800") + (baseText ? " text-base" : smallText ? " text-sm" : " text-lg"),
|
|
children: title
|
|
})
|
|
]
|
|
}, index + 1);
|
|
})
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
} catch (error) {
|
|
console.log("ERROR in FormRadio =>", error);
|
|
return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
|
|
children: "Form Radio Error"
|
|
});
|
|
}
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
|
|
/***/ })
|
|
|
|
};
|
|
; |