37013.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. exports.id = 37013;
  2. exports.ids = [37013];
  3. exports.modules = {
  4. /***/ 88426:
  5. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6. "use strict";
  7. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  8. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  9. /* harmony export */ });
  10. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16689);
  11. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  12. var _path;
  13. function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
  14. var SvgStar = function SvgStar(props) {
  15. return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
  16. width: 15,
  17. height: 15,
  18. viewBox: "0 0 15 15",
  19. fill: "none",
  20. xmlns: "http://www.w3.org/2000/svg"
  21. }, props), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
  22. d: "m6.98 1.252-.022.05L5.588 4.6a.3.3 0 0 1-.253.184l-3.561.286-.055.004-.331.027-.3.024a.3.3 0 0 0-.172.527l.23.196.252.216.041.036 2.713 2.324a.3.3 0 0 1 .097.297l-.83 3.475-.012.053-.077.323-.07.294a.3.3 0 0 0 .448.326l.258-.158.284-.173.046-.028 3.049-1.863a.3.3 0 0 1 .312 0l3.049 1.863.046.028.284.173.258.158a.3.3 0 0 0 .448-.326l-.07-.293-.077-.324-.013-.053-.829-3.475a.3.3 0 0 1 .097-.297L13.562 6.1l.041-.036.253-.216.23-.196a.3.3 0 0 0-.172-.527l-.3-.024-.332-.027-.055-.004-3.56-.286a.3.3 0 0 1-.254-.184L8.042 1.302l-.021-.05-.128-.307-.116-.279a.3.3 0 0 0-.554 0l-.116.279-.128.307Zm.52 1.352-.99 2.38a1.3 1.3 0 0 1-1.096.797l-2.57.206 1.958 1.677a1.3 1.3 0 0 1 .418 1.29l-.598 2.507 2.2-1.344a1.3 1.3 0 0 1 1.356 0l2.2 1.344-.598-2.508a1.3 1.3 0 0 1 .418-1.289l1.958-1.677-2.57-.206a1.3 1.3 0 0 1-1.096-.797l-.99-2.38Z",
  23. fill: "currentColor",
  24. fillRule: "evenodd",
  25. clipRule: "evenodd"
  26. })));
  27. };
  28. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SvgStar);
  29. /***/ }),
  30. /***/ 99815:
  31. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  32. "use strict";
  33. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  34. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  35. /* harmony export */ });
  36. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16689);
  37. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  38. var _path;
  39. function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
  40. var SvgStarFilled = function SvgStarFilled(props) {
  41. return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
  42. width: 15,
  43. height: 15,
  44. viewBox: "0 0 15 15",
  45. fill: "none",
  46. xmlns: "http://www.w3.org/2000/svg"
  47. }, props), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
  48. d: "M7.223.666a.3.3 0 0 1 .554 0L9.413 4.6a.3.3 0 0 0 .253.184l4.248.34a.3.3 0 0 1 .171.528L10.85 8.424a.3.3 0 0 0-.097.297l.99 4.145a.3.3 0 0 1-.45.326L7.657 10.97a.3.3 0 0 0-.312 0l-3.637 2.222a.3.3 0 0 1-.448-.326l.989-4.145a.3.3 0 0 0-.097-.297L.915 5.652a.3.3 0 0 1 .171-.527l4.248-.34a.3.3 0 0 0 .253-.185L7.223.666Z",
  49. fill: "currentColor"
  50. })));
  51. };
  52. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SvgStarFilled);
  53. /***/ }),
  54. /***/ 37282:
  55. /***/ ((module) => {
  56. // Exports
  57. module.exports = {
  58. "container": "FormBuilder_container__7H_38",
  59. "inputContainer": "FormBuilder_inputContainer__v4ceB",
  60. "errorText": "FormBuilder_errorText__1uSsu",
  61. "submitButton": "FormBuilder_submitButton__4Wo4u"
  62. };
  63. /***/ }),
  64. /***/ 50794:
  65. /***/ ((module) => {
  66. // Exports
  67. module.exports = {
  68. "container": "Root_container__CQEHR"
  69. };
  70. /***/ }),
  71. /***/ 25162:
  72. /***/ ((module) => {
  73. // Exports
  74. module.exports = {
  75. "starButton": "Star_starButton__UeMsd",
  76. "selected": "Star_selected__M87yb"
  77. };
  78. /***/ }),
  79. /***/ 16926:
  80. /***/ ((module) => {
  81. // Exports
  82. module.exports = {
  83. "container": "TextArea_container__7anjD",
  84. "disabled": "TextArea_disabled__hBW2r",
  85. "error": "TextArea_error__JceFQ",
  86. "success": "TextArea_success__cfxk5",
  87. "warning": "TextArea_warning__fUWyl",
  88. "main": "TextArea_main__KBxzB",
  89. "input": "TextArea_input__SDMp4",
  90. "label": "TextArea_label__VLY9r"
  91. };
  92. /***/ }),
  93. /***/ 37013:
  94. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  95. "use strict";
  96. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  97. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  98. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  99. /* harmony export */ });
  100. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  101. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  102. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(59003);
  103. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__);
  104. /* harmony import */ var react_hook_form__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(45641);
  105. /* harmony import */ var _buildReactHookFormRules__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(32807);
  106. /* harmony import */ var _FormBuilder_module_scss__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(37282);
  107. /* harmony import */ var _FormBuilder_module_scss__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_FormBuilder_module_scss__WEBPACK_IMPORTED_MODULE_10__);
  108. /* harmony import */ var _dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(50497);
  109. /* harmony import */ var _dls_Forms_Checkbox_Checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(42752);
  110. /* harmony import */ var _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(91308);
  111. /* harmony import */ var _dls_Forms_StarRating__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(19662);
  112. /* harmony import */ var _dls_Forms_TextArea__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(482);
  113. /* harmony import */ var _types_FormField__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3840);
  114. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([react_hook_form__WEBPACK_IMPORTED_MODULE_2__, _dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__, _dls_Forms_Checkbox_Checkbox__WEBPACK_IMPORTED_MODULE_5__, _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_6__, _dls_Forms_StarRating__WEBPACK_IMPORTED_MODULE_7__]);
  115. ([react_hook_form__WEBPACK_IMPORTED_MODULE_2__, _dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__, _dls_Forms_Checkbox_Checkbox__WEBPACK_IMPORTED_MODULE_5__, _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_6__, _dls_Forms_StarRating__WEBPACK_IMPORTED_MODULE_7__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  116. /**
  117. * {@see https://legacy.reactjs.org/docs/jsx-in-depth.html#choosing-the-type-at-runtime}
  118. */ const FormFieldTypeToComponentMap = {
  119. [_types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.TextArea */ .E.TextArea]: _dls_Forms_TextArea__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .ZP,
  120. [_types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Text */ .E.Text]: _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .ZP,
  121. [_types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Password */ .E.Password]: _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .ZP,
  122. [_types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Phone */ .E.Phone]: _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .ZP,
  123. [_types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Number */ .E.Number]: _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .ZP,
  124. [_types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Checkbox */ .E.Checkbox]: _dls_Forms_Checkbox_Checkbox__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z,
  125. [_types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.StarRating */ .E.StarRating]: _dls_Forms_StarRating__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z
  126. };
  127. const isFieldTextInput = (type)=>{
  128. return [
  129. _types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Text */ .E.Text,
  130. _types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Password */ .E.Password,
  131. _types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Phone */ .E.Phone,
  132. _types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Number */ .E.Number,
  133. ].includes(type);
  134. };
  135. const FormBuilder = ({ formFields , onSubmit , actionText , actionProps ={} , isSubmitting , renderAction })=>{
  136. const { handleSubmit , control , setError } = (0,react_hook_form__WEBPACK_IMPORTED_MODULE_2__.useForm)({
  137. mode: "onBlur"
  138. });
  139. const internalOnSubmit = (data)=>{
  140. const onSubmitPromise = onSubmit(data);
  141. if (onSubmitPromise) {
  142. onSubmitPromise.then((errorData)=>{
  143. if (errorData && errorData?.errors) {
  144. Object.entries(errorData.errors).forEach(([field, errorMessage])=>{
  145. setError(field, {
  146. type: "manual",
  147. message: errorMessage
  148. });
  149. });
  150. }
  151. });
  152. }
  153. };
  154. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("form", {
  155. className: (_FormBuilder_module_scss__WEBPACK_IMPORTED_MODULE_10___default().container),
  156. onSubmit: handleSubmit(internalOnSubmit),
  157. children: [
  158. formFields?.map((formField)=>{
  159. return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(react_hook_form__WEBPACK_IMPORTED_MODULE_2__.Controller, {
  160. control: control,
  161. defaultValue: formField.defaultValue,
  162. rules: (0,_buildReactHookFormRules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)(formField),
  163. name: formField.field,
  164. render: ({ field , fieldState: { error } })=>{
  165. const inputFieldProps = {
  166. key: formField.field,
  167. value: field.value,
  168. id: formField.field,
  169. name: formField.field,
  170. containerClassName: formField.containerClassName,
  171. fieldSetLegend: formField.fieldSetLegend,
  172. label: formField.label,
  173. placeholder: formField.placeholder,
  174. onChange: (val)=>{
  175. field.onChange(val);
  176. if (formField?.onChange) {
  177. formField.onChange(val);
  178. }
  179. },
  180. ...isFieldTextInput(formField.type) && {
  181. htmlType: formField.type,
  182. fixedWidth: false
  183. },
  184. ...formField.type === _types_FormField__WEBPACK_IMPORTED_MODULE_9__/* .FormFieldType.Checkbox */ .E.Checkbox && typeof formField.checked !== "undefined" && {
  185. checked: formField.checked
  186. }
  187. };
  188. const InputField = FormFieldTypeToComponentMap[formField.type];
  189. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
  190. className: classnames__WEBPACK_IMPORTED_MODULE_1___default()((_FormBuilder_module_scss__WEBPACK_IMPORTED_MODULE_10___default().inputContainer), formField.containerClassName),
  191. children: [
  192. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(InputField, {
  193. ...inputFieldProps
  194. }),
  195. error && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("span", {
  196. className: (_FormBuilder_module_scss__WEBPACK_IMPORTED_MODULE_10___default().errorText),
  197. children: error.message
  198. }),
  199. formField.extraSection && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
  200. children: formField.extraSection
  201. })
  202. ]
  203. });
  204. }
  205. }, formField.field);
  206. }),
  207. renderAction ? renderAction({
  208. htmlType: "submit",
  209. isLoading: isSubmitting,
  210. onClick: (e)=>{
  211. e.stopPropagation();
  212. }
  213. }) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_dls_Button_Button__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .ZP, {
  214. ...actionProps,
  215. htmlType: "submit",
  216. isLoading: isSubmitting,
  217. onClick: (e)=>{
  218. e.stopPropagation();
  219. },
  220. className: classnames__WEBPACK_IMPORTED_MODULE_1___default()((_FormBuilder_module_scss__WEBPACK_IMPORTED_MODULE_10___default().submitButton), actionProps.className),
  221. children: actionText
  222. })
  223. ]
  224. });
  225. };
  226. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (FormBuilder);
  227. __webpack_async_result__();
  228. } catch(e) { __webpack_async_result__(e); } });
  229. /***/ }),
  230. /***/ 32807:
  231. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  232. "use strict";
  233. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  234. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  235. /* harmony export */ });
  236. /* harmony import */ var types_FieldRule__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(98213);
  237. /* eslint-disable react-func/max-lines-per-function */
  238. /**
  239. * 1) Check if the formField contains a `required` rule. If so, add a `required` rule to the React Hook Form rules
  240. * 2) Check if the formField contains `regex` rule. If so, try to test the regex against the `value` one by one
  241. * if one of test regex test fails, return the error message
  242. *
  243. * Note: The error message returned by this function is already translated using `t(validation.$errorId)`
  244. *
  245. * @param {FormField} formField
  246. * @returns {UseControllerProps['rules']} rules
  247. */ const buildReactHookFormRules = (formField)=>{
  248. const rules = {};
  249. const requiredRule = formField.rules?.find((rule)=>rule.type === types_FieldRule__WEBPACK_IMPORTED_MODULE_0__/* .RuleType.Required */ .S.Required && rule.value === true);
  250. // if contains a rule with type `required`
  251. if (requiredRule) {
  252. rules.required = {
  253. message: requiredRule.errorMessage,
  254. value: true
  255. };
  256. }
  257. const maximumLengthRule = formField.rules?.find((rule)=>rule.type === types_FieldRule__WEBPACK_IMPORTED_MODULE_0__/* .RuleType.MaximumLength */ .S.MaximumLength);
  258. if (maximumLengthRule) {
  259. rules.maxLength = {
  260. message: maximumLengthRule.errorMessage,
  261. value: maximumLengthRule.value
  262. };
  263. }
  264. const minimumLength = formField.rules?.find((rule)=>rule.type === types_FieldRule__WEBPACK_IMPORTED_MODULE_0__/* .RuleType.MinimumLength */ .S.MinimumLength);
  265. if (minimumLength) {
  266. rules.minLength = {
  267. message: minimumLength.errorMessage,
  268. value: minimumLength.value
  269. };
  270. }
  271. const regexValidations = formField.rules?.filter((rule)=>rule.type === types_FieldRule__WEBPACK_IMPORTED_MODULE_0__/* .RuleType.Regex */ .S.Regex);
  272. // if contains a rule with type `regex`
  273. if (regexValidations && regexValidations.length > 0) {
  274. rules.validate = {
  275. regex: (value)=>{
  276. const failedRule = regexValidations.find((rule)=>{
  277. const regex = new RegExp(rule.value);
  278. const isTestSucceed = regex.test(value);
  279. return !isTestSucceed;
  280. });
  281. if (failedRule) return failedRule.errorMessage;
  282. return null;
  283. }
  284. };
  285. }
  286. return rules;
  287. };
  288. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (buildReactHookFormRules);
  289. /***/ }),
  290. /***/ 90568:
  291. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  292. "use strict";
  293. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  294. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  295. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  296. /* harmony export */ });
  297. /* unused harmony export RadioRootOrientation */
  298. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  299. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  300. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  301. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  302. /* harmony import */ var _radix_ui_react_radio_group__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4086);
  303. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(59003);
  304. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_3__);
  305. /* harmony import */ var _Root_module_scss__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(50794);
  306. /* harmony import */ var _Root_module_scss__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_Root_module_scss__WEBPACK_IMPORTED_MODULE_5__);
  307. /* harmony import */ var _hooks_useDirection__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(64365);
  308. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_radix_ui_react_radio_group__WEBPACK_IMPORTED_MODULE_2__]);
  309. _radix_ui_react_radio_group__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  310. var RadioRootOrientation;
  311. (function(RadioRootOrientation) {
  312. RadioRootOrientation["Horizontal"] = "horizontal";
  313. RadioRootOrientation["Vertical"] = "vertical";
  314. })(RadioRootOrientation || (RadioRootOrientation = {}));
  315. const Root = ({ className , onChange , defaultValue , value , name , required , children , })=>{
  316. const direction = (0,_hooks_useDirection__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z)();
  317. return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_radix_ui_react_radio_group__WEBPACK_IMPORTED_MODULE_2__.Root, {
  318. className: classnames__WEBPACK_IMPORTED_MODULE_3___default()((_Root_module_scss__WEBPACK_IMPORTED_MODULE_5___default().container), className),
  319. dir: direction,
  320. ...onChange && {
  321. onValueChange: onChange
  322. },
  323. ...defaultValue && {
  324. defaultValue
  325. },
  326. ...value && {
  327. value
  328. },
  329. ...name && {
  330. name
  331. },
  332. ...required && {
  333. required
  334. },
  335. children: children
  336. });
  337. };
  338. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Root);
  339. __webpack_async_result__();
  340. } catch(e) { __webpack_async_result__(e); } });
  341. /***/ }),
  342. /***/ 16599:
  343. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  344. "use strict";
  345. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  346. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  347. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  348. /* harmony export */ });
  349. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  350. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  351. /* harmony import */ var _radix_ui_react_radio_group__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4086);
  352. /* harmony import */ var _radix_ui_react_visually_hidden__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(28560);
  353. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(59003);
  354. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_3__);
  355. /* harmony import */ var _Star_module_scss__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(25162);
  356. /* harmony import */ var _Star_module_scss__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_Star_module_scss__WEBPACK_IMPORTED_MODULE_6__);
  357. /* harmony import */ var _icons_star_svg__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(88426);
  358. /* harmony import */ var _icons_star_filled_svg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(99815);
  359. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_radix_ui_react_radio_group__WEBPACK_IMPORTED_MODULE_1__, _radix_ui_react_visually_hidden__WEBPACK_IMPORTED_MODULE_2__]);
  360. ([_radix_ui_react_radio_group__WEBPACK_IMPORTED_MODULE_1__, _radix_ui_react_visually_hidden__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  361. const Star = ({ className , ...props })=>{
  362. const { value , currentValue } = props;
  363. const starValue = Number(value);
  364. const isCurrentStarSelected = starValue <= Number(currentValue);
  365. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(_radix_ui_react_radio_group__WEBPACK_IMPORTED_MODULE_1__.Item, {
  366. className: classnames__WEBPACK_IMPORTED_MODULE_3___default()((_Star_module_scss__WEBPACK_IMPORTED_MODULE_6___default().starButton), className, {
  367. [(_Star_module_scss__WEBPACK_IMPORTED_MODULE_6___default().selected)]: isCurrentStarSelected
  368. }),
  369. ...props,
  370. children: [
  371. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_radix_ui_react_visually_hidden__WEBPACK_IMPORTED_MODULE_2__.VisuallyHidden, {
  372. children: `${starValue} ${starValue === 1 ? "star" : "stars"}`
  373. }),
  374. isCurrentStarSelected ? /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_icons_star_filled_svg__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, {
  375. width: "30",
  376. height: "30"
  377. }) : /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_icons_star_svg__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
  378. width: "30",
  379. height: "30"
  380. })
  381. ]
  382. });
  383. };
  384. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Star);
  385. __webpack_async_result__();
  386. } catch(e) { __webpack_async_result__(e); } });
  387. /***/ }),
  388. /***/ 19662:
  389. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  390. "use strict";
  391. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  392. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  393. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  394. /* harmony export */ });
  395. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  396. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  397. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  398. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  399. /* harmony import */ var _Root__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(90568);
  400. /* harmony import */ var _Star__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16599);
  401. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_Root__WEBPACK_IMPORTED_MODULE_2__, _Star__WEBPACK_IMPORTED_MODULE_3__]);
  402. ([_Root__WEBPACK_IMPORTED_MODULE_2__, _Star__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
  403. const StarRating = ({ maximumRating =5 , disabled =false , defaultValue ="1" , value , ...props })=>{
  404. return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_Root__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
  405. defaultValue: defaultValue,
  406. ...props,
  407. children: Array.from({
  408. length: maximumRating
  409. }, (_, index)=>{
  410. const starValue = index + 1;
  411. const starValueString = `${starValue}`;
  412. return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_Star__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {
  413. currentValue: value,
  414. // @ts-ignore
  415. value: starValue,
  416. id: starValueString,
  417. disabled: disabled === true
  418. }, starValueString);
  419. })
  420. });
  421. };
  422. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (StarRating);
  423. __webpack_async_result__();
  424. } catch(e) { __webpack_async_result__(e); } });
  425. /***/ }),
  426. /***/ 482:
  427. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  428. "use strict";
  429. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  430. /* harmony export */ "ZP": () => (__WEBPACK_DEFAULT_EXPORT__)
  431. /* harmony export */ });
  432. /* unused harmony exports TextAreaSize, TextAreaType, TextAreaVariant */
  433. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  434. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  435. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  436. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  437. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(59003);
  438. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__);
  439. /* harmony import */ var _TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16926);
  440. /* harmony import */ var _TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3__);
  441. var TextAreaSize;
  442. (function(TextAreaSize) {
  443. TextAreaSize["Small"] = "small";
  444. TextAreaSize["Medium"] = "medium";
  445. TextAreaSize["Large"] = "large";
  446. })(TextAreaSize || (TextAreaSize = {}));
  447. const SIZE_TO_COLS = {
  448. [TextAreaSize.Small]: 5,
  449. [TextAreaSize.Medium]: 10,
  450. [TextAreaSize.Large]: 25
  451. };
  452. var TextAreaType;
  453. (function(TextAreaType) {
  454. TextAreaType["Error"] = "error";
  455. TextAreaType["Warning"] = "warning";
  456. TextAreaType["Success"] = "success";
  457. })(TextAreaType || (TextAreaType = {}));
  458. var TextAreaVariant;
  459. (function(TextAreaVariant) {
  460. TextAreaVariant["Default"] = "default";
  461. TextAreaVariant["Main"] = "main";
  462. })(TextAreaVariant || (TextAreaVariant = {}));
  463. const TextArea = ({ id , name , label , placeholder , disabled =false , type , variant , onChange , value ="" , shouldFlipOnRTL =true , containerClassName , isRequired , inputRef , size =TextAreaSize.Medium , fieldSetLegend =null , })=>{
  464. const { 0: inputValue , 1: setTextAreaValue } = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(value);
  465. // listen to any change in value in-case the value gets populated after an API call.
  466. (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(()=>{
  467. setTextAreaValue(value);
  468. }, [
  469. value
  470. ]);
  471. const onValueChange = (event)=>{
  472. const newValue = event.target.value;
  473. setTextAreaValue(newValue);
  474. if (onChange) {
  475. onChange(newValue);
  476. }
  477. };
  478. const content = /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
  479. children: [
  480. label && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
  481. className: (_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().label),
  482. children: label
  483. }),
  484. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
  485. className: classnames__WEBPACK_IMPORTED_MODULE_2___default()((_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().container), containerClassName, {
  486. [(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().disabled)]: disabled,
  487. [(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().error)]: type === TextAreaType.Error,
  488. [(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().success)]: type === TextAreaType.Success,
  489. [(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().warning)]: type === TextAreaType.Warning,
  490. [(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().main)]: variant === TextAreaVariant.Main
  491. }),
  492. children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("textarea", {
  493. className: classnames__WEBPACK_IMPORTED_MODULE_2___default()((_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().input), {
  494. [(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().error)]: type === TextAreaType.Error,
  495. [(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().success)]: type === TextAreaType.Success,
  496. [(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().warning)]: type === TextAreaType.Warning,
  497. [(_TextArea_module_scss__WEBPACK_IMPORTED_MODULE_3___default().rtlTextArea)]: shouldFlipOnRTL
  498. }),
  499. required: isRequired,
  500. dir: "auto",
  501. id: id,
  502. rows: SIZE_TO_COLS[size],
  503. ref: inputRef,
  504. disabled: disabled,
  505. onChange: onValueChange,
  506. value: inputValue,
  507. ...placeholder && {
  508. placeholder
  509. },
  510. ...name && {
  511. name
  512. }
  513. })
  514. })
  515. ]
  516. });
  517. if (fieldSetLegend) {
  518. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("fieldset", {
  519. children: [
  520. /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("legend", {
  521. children: [
  522. " ",
  523. fieldSetLegend,
  524. " "
  525. ]
  526. }),
  527. content
  528. ]
  529. });
  530. }
  531. return content;
  532. };
  533. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TextArea);
  534. /***/ }),
  535. /***/ 98213:
  536. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  537. "use strict";
  538. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  539. /* harmony export */ "S": () => (/* binding */ RuleType)
  540. /* harmony export */ });
  541. var RuleType;
  542. (function(RuleType) {
  543. RuleType["Required"] = "required";
  544. RuleType["Regex"] = "regex";
  545. RuleType["MaximumLength"] = "maxLength";
  546. RuleType["MinimumLength"] = "minLength";
  547. })(RuleType || (RuleType = {}));
  548. /***/ }),
  549. /***/ 3840:
  550. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  551. "use strict";
  552. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  553. /* harmony export */ "E": () => (/* binding */ FormFieldType)
  554. /* harmony export */ });
  555. var FormFieldType;
  556. (function(FormFieldType) {
  557. FormFieldType["Text"] = "text";
  558. FormFieldType["Password"] = "password";
  559. FormFieldType["Phone"] = "phone";
  560. FormFieldType["Number"] = "number";
  561. FormFieldType["TextArea"] = "textarea";
  562. FormFieldType["Checkbox"] = "checkbox";
  563. FormFieldType["StarRating"] = "starRating";
  564. })(FormFieldType || (FormFieldType = {}));
  565. /***/ })
  566. };
  567. ;
  568. //# sourceMappingURL=37013.js.map