73273.js 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680
  1. exports.id = 73273;
  2. exports.ids = [73273];
  3. exports.modules = {
  4. /***/ 69457:
  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, _path2;
  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 SvgBook = function SvgBook(props) {
  15. return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
  16. xmlns: "http://www.w3.org/2000/svg",
  17. width: 24,
  18. height: 24,
  19. viewBox: "0 0 24 24",
  20. fill: "none",
  21. stroke: "currentColor",
  22. strokeWidth: 2,
  23. strokeLinecap: "round",
  24. strokeLinejoin: "round",
  25. className: "feather feather-book"
  26. }, props), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
  27. d: "M4 19.5A2.5 2.5 0 0 1 6.5 17H20"
  28. })), _path2 || (_path2 = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
  29. d: "M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"
  30. })));
  31. };
  32. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SvgBook);
  33. /***/ }),
  34. /***/ 49880:
  35. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  36. "use strict";
  37. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  38. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  39. /* harmony export */ });
  40. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16689);
  41. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  42. var _path;
  43. 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); }
  44. var SvgChevronLeft = function SvgChevronLeft(props) {
  45. return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
  46. width: 15,
  47. height: 15,
  48. viewBox: "0 0 15 15",
  49. fill: "none",
  50. xmlns: "http://www.w3.org/2000/svg"
  51. }, props), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
  52. d: "M8.842 3.135a.5.5 0 0 1 .023.707L5.435 7.5l3.43 3.658a.5.5 0 0 1-.73.684l-3.75-4a.5.5 0 0 1 0-.684l3.75-4a.5.5 0 0 1 .707-.023Z",
  53. fill: "currentColor",
  54. fillRule: "evenodd",
  55. clipRule: "evenodd"
  56. })));
  57. };
  58. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SvgChevronLeft);
  59. /***/ }),
  60. /***/ 3932:
  61. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  62. "use strict";
  63. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  64. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  65. /* harmony export */ });
  66. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16689);
  67. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  68. var _path;
  69. 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); }
  70. var SvgChevronRight = function SvgChevronRight(props) {
  71. return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
  72. width: 15,
  73. height: 15,
  74. viewBox: "0 0 15 15",
  75. fill: "none",
  76. xmlns: "http://www.w3.org/2000/svg"
  77. }, props), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
  78. d: "M6.158 3.135a.5.5 0 0 1 .707.023l3.75 4a.5.5 0 0 1 0 .684l-3.75 4a.5.5 0 1 1-.73-.684L9.566 7.5l-3.43-3.658a.5.5 0 0 1 .023-.707Z",
  79. fill: "currentColor",
  80. fillRule: "evenodd",
  81. clipRule: "evenodd"
  82. })));
  83. };
  84. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SvgChevronRight);
  85. /***/ }),
  86. /***/ 8674:
  87. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  88. "use strict";
  89. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  90. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  91. /* harmony export */ });
  92. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16689);
  93. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  94. var _path;
  95. 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); }
  96. var SvgClock = function SvgClock(props) {
  97. return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", _extends({
  98. xmlns: "http://www.w3.org/2000/svg",
  99. fill: "none",
  100. viewBox: "0 0 24 24",
  101. strokeWidth: 1.5,
  102. stroke: "currentColor",
  103. className: "w-6 h-6"
  104. }, props), _path || (_path = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {
  105. strokeLinecap: "round",
  106. strokeLinejoin: "round",
  107. d: "M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"
  108. })));
  109. };
  110. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SvgClock);
  111. /***/ }),
  112. /***/ 13646:
  113. /***/ ((module) => {
  114. // Exports
  115. module.exports = {
  116. "rangeInputContainer": "ReadingGoalInput_rangeInputContainer__ZEAD_",
  117. "inputContainer": "ReadingGoalInput_inputContainer__I_R3M",
  118. "fullWidth": "ReadingGoalInput_fullWidth__MyI06",
  119. "input": "ReadingGoalInput_input__PtUNh",
  120. "label": "ReadingGoalInput_label__lxzo1"
  121. };
  122. /***/ }),
  123. /***/ 72549:
  124. /***/ ((module) => {
  125. // Exports
  126. module.exports = {
  127. "label": "Combobox_label__0IpZG",
  128. "disabledSearch": "Combobox_disabledSearch__8rVdt",
  129. "comboboxContainer": "Combobox_comboboxContainer__kgP9M",
  130. "fixedWidth": "Combobox_fixedWidth__CVwtY",
  131. "enabled": "Combobox_enabled__N0Xzz",
  132. "select": "Combobox_select__RdEEM",
  133. "selector": "Combobox_selector__w5Qy_",
  134. "activeSelector": "Combobox_activeSelector__87gl9",
  135. "disabledSelector": "Combobox_disabledSelector__f7dH_",
  136. "hasError": "Combobox_hasError__btZox",
  137. "placeholder": "Combobox_placeholder__KxuIs",
  138. "overflow": "Combobox_overflow__wDx9g",
  139. "multiSelectSearchInput": "Combobox_multiSelectSearchInput__50i6f",
  140. "smallSearchInput": "Combobox_smallSearchInput__Fp22X",
  141. "mediumSearchInput": "Combobox_mediumSearchInput__rHPbe",
  142. "largeSearchInput": "Combobox_largeSearchInput__B6SoL",
  143. "overflowItem": "Combobox_overflowItem__3lo49",
  144. "tagContainer": "Combobox_tagContainer__2pMfb",
  145. "search": "Combobox_search__7gUOl",
  146. "fullWidth": "Combobox_fullWidth__pBxh_"
  147. };
  148. /***/ }),
  149. /***/ 92460:
  150. /***/ ((module) => {
  151. // Exports
  152. module.exports = {
  153. "input": "ComboboxItem_input__tPkeb",
  154. "itemLabel": "ComboboxItem_itemLabel__i2tdo",
  155. "itemContainer": "ComboboxItem_itemContainer__B_pz1",
  156. "enabledItem": "ComboboxItem_enabledItem__nMWDe",
  157. "disabledItem": "ComboboxItem_disabledItem__Wk3vx",
  158. "checkedItem": "ComboboxItem_checkedItem__fltvV",
  159. "prefix": "ComboboxItem_prefix__iu_PS",
  160. "labelContainer": "ComboboxItem_labelContainer__sYcB_",
  161. "prefixContainer": "ComboboxItem_prefixContainer__bFcOl",
  162. "suffixContainer": "ComboboxItem_suffixContainer__Fof34"
  163. };
  164. /***/ }),
  165. /***/ 47973:
  166. /***/ ((module) => {
  167. // Exports
  168. module.exports = {
  169. "comboboxBodyContainer": "ComboboxItems_comboboxBodyContainer__U8FV9",
  170. "fixedWidth": "ComboboxItems_fixedWidth__Ja9N8",
  171. "largeComboboxBodyContainer": "ComboboxItems_largeComboboxBodyContainer__yEoGv",
  172. "openedComboboxBodyContainer": "ComboboxItems_openedComboboxBodyContainer__FTC8W",
  173. "itemsContainer": "ComboboxItems_itemsContainer__gSdDs"
  174. };
  175. /***/ }),
  176. /***/ 82601:
  177. /***/ ((module) => {
  178. // Exports
  179. module.exports = {
  180. "caretIconButton": "CaretInputIcon_caretIconButton__CFt6U",
  181. "openedCaretIconButton": "CaretInputIcon_openedCaretIconButton__xrU_c"
  182. };
  183. /***/ }),
  184. /***/ 80899:
  185. /***/ ((module) => {
  186. // Exports
  187. module.exports = {
  188. "clearIconContainer": "ClearInputIcon_clearIconContainer__SJWTP",
  189. "icon": "ClearInputIcon_icon__m6i8c"
  190. };
  191. /***/ }),
  192. /***/ 24899:
  193. /***/ ((module) => {
  194. // Exports
  195. module.exports = {
  196. "iconContainer": "SearchInputIcon_iconContainer__z7b2G",
  197. "icon": "SearchInputIcon_icon__t1nGp",
  198. "selectSearch": "SearchInputIcon_selectSearch__Gdqtn"
  199. };
  200. /***/ }),
  201. /***/ 17874:
  202. /***/ ((module) => {
  203. // Exports
  204. module.exports = {
  205. "item": "Tag_item__0hGuv",
  206. "largeItem": "Tag_largeItem__hrrwN",
  207. "itemContent": "Tag_itemContent__Pxwpg",
  208. "itemRemove": "Tag_itemRemove__9cr6J"
  209. };
  210. /***/ }),
  211. /***/ 40458:
  212. /***/ ((module) => {
  213. // Exports
  214. module.exports = {
  215. "container": "Select_container___DCC_",
  216. "withBackground": "Select_withBackground__rpdEL",
  217. "defaultStyledContainer": "Select_defaultStyledContainer__b32Mm",
  218. "smallContainer": "Select_smallContainer__L2Lff",
  219. "mediumContainer": "Select_mediumContainer__MF_Vq",
  220. "largeContainer": "Select_largeContainer___qGs0",
  221. "disabledContainer": "Select_disabledContainer__gi7YD",
  222. "arrow": "Select_arrow__WAbAk",
  223. "disabledArrow": "Select_disabledArrow__V4nEO",
  224. "select": "Select_select__BnH2G",
  225. "defaultStyledSelect": "Select_defaultStyledSelect__LmeKj",
  226. "disabledSelect": "Select_disabledSelect___R3Jd"
  227. };
  228. /***/ }),
  229. /***/ 37326:
  230. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  231. "use strict";
  232. // EXPORTS
  233. __webpack_require__.d(__webpack_exports__, {
  234. "Z": () => (/* binding */ ReadingGoalInput_VerseRangeInput)
  235. });
  236. // EXTERNAL MODULE: external "react/jsx-runtime"
  237. var jsx_runtime_ = __webpack_require__(20997);
  238. // EXTERNAL MODULE: external "react"
  239. var external_react_ = __webpack_require__(16689);
  240. // EXTERNAL MODULE: external "next-translate/useTranslation"
  241. var useTranslation_ = __webpack_require__(60866);
  242. var useTranslation_default = /*#__PURE__*/__webpack_require__.n(useTranslation_);
  243. // EXTERNAL MODULE: ./src/components/ReadingGoal/ReadingGoalInput/ReadingGoalInput.module.scss
  244. var ReadingGoalInput_module = __webpack_require__(13646);
  245. var ReadingGoalInput_module_default = /*#__PURE__*/__webpack_require__.n(ReadingGoalInput_module);
  246. // EXTERNAL MODULE: ./src/contexts/DataContext.ts
  247. var DataContext = __webpack_require__(70813);
  248. // EXTERNAL MODULE: external "classnames"
  249. var external_classnames_ = __webpack_require__(59003);
  250. var external_classnames_default = /*#__PURE__*/__webpack_require__.n(external_classnames_);
  251. // EXTERNAL MODULE: external "react-hotkeys-hook"
  252. var external_react_hotkeys_hook_ = __webpack_require__(2784);
  253. // EXTERNAL MODULE: ./src/components/dls/Forms/Combobox/Combobox.module.scss
  254. var Combobox_module = __webpack_require__(72549);
  255. var Combobox_module_default = /*#__PURE__*/__webpack_require__.n(Combobox_module);
  256. // EXTERNAL MODULE: ./src/components/dls/Forms/Combobox/ComboboxItems/ComboboxItems.module.scss
  257. var ComboboxItems_module = __webpack_require__(47973);
  258. var ComboboxItems_module_default = /*#__PURE__*/__webpack_require__.n(ComboboxItems_module);
  259. // EXTERNAL MODULE: ./src/components/dls/Forms/Combobox/ComboboxItem/ComboboxItem.module.scss
  260. var ComboboxItem_module = __webpack_require__(92460);
  261. var ComboboxItem_module_default = /*#__PURE__*/__webpack_require__.n(ComboboxItem_module);
  262. ;// CONCATENATED MODULE: ./src/components/dls/Forms/Combobox/ComboboxItem/index.tsx
  263. const ComboboxItem = ({ checked , disabled , itemId , selectedItemRef , item , onItemSelectedChange , isNotFound =false , emptyMessage , })=>{
  264. if (isNotFound) {
  265. return /*#__PURE__*/ jsx_runtime_.jsx("div", {
  266. className: external_classnames_default()((ComboboxItem_module_default()).itemContainer, (ComboboxItem_module_default()).disabledItem),
  267. children: emptyMessage
  268. });
  269. }
  270. return /*#__PURE__*/ jsx_runtime_.jsx("label", {
  271. htmlFor: itemId,
  272. children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
  273. ref: checked ? selectedItemRef : null,
  274. className: external_classnames_default()((ComboboxItem_module_default()).itemContainer, {
  275. [(ComboboxItem_module_default()).disabledItem]: disabled
  276. }, {
  277. [(ComboboxItem_module_default()).enabledItem]: !disabled
  278. }, {
  279. [(ComboboxItem_module_default()).checkedItem]: checked
  280. }),
  281. children: [
  282. /*#__PURE__*/ jsx_runtime_.jsx("input", {
  283. type: "checkbox",
  284. className: (ComboboxItem_module_default()).input,
  285. id: itemId,
  286. name: item.name,
  287. disabled: disabled,
  288. checked: checked,
  289. onChange: onItemSelectedChange,
  290. "data-item-label": item.label
  291. }),
  292. /*#__PURE__*/ (0,jsx_runtime_.jsxs)("label", {
  293. htmlFor: itemId,
  294. className: external_classnames_default()((ComboboxItem_module_default()).labelContainer, {
  295. [(ComboboxItem_module_default()).itemLabel]: !disabled
  296. }),
  297. children: [
  298. /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
  299. className: (ComboboxItem_module_default()).prefixContainer,
  300. children: [
  301. item.prefix && /*#__PURE__*/ jsx_runtime_.jsx("div", {
  302. className: (ComboboxItem_module_default()).prefix,
  303. children: item.prefix
  304. }),
  305. " ",
  306. item.label
  307. ]
  308. }),
  309. item.suffix && /*#__PURE__*/ jsx_runtime_.jsx("div", {
  310. className: (ComboboxItem_module_default()).suffixContainer,
  311. children: item.suffix
  312. })
  313. ]
  314. })
  315. ]
  316. })
  317. }, itemId);
  318. };
  319. /* harmony default export */ const Combobox_ComboboxItem = (/*#__PURE__*/(0,external_react_.memo)(ComboboxItem));
  320. ;// CONCATENATED MODULE: ./src/components/dls/Forms/Combobox/types/ComboboxSize.ts
  321. var ComboboxSize;
  322. (function(ComboboxSize) {
  323. ComboboxSize["Small"] = "small";
  324. ComboboxSize["Medium"] = "medium";
  325. ComboboxSize["Large"] = "large";
  326. })(ComboboxSize || (ComboboxSize = {}));
  327. /* harmony default export */ const types_ComboboxSize = (ComboboxSize);
  328. // EXTERNAL MODULE: ./src/hooks/useScrollToElement.ts
  329. var useScrollToElement = __webpack_require__(56748);
  330. ;// CONCATENATED MODULE: ./src/components/dls/Forms/Combobox/ComboboxItems/index.tsx
  331. const SCROLL_TO_SELECTED_ELEMENT_OPTIONS = {
  332. block: "nearest"
  333. };
  334. const ComboboxItems = ({ isOpened , disabled , size , filteredItems , isMultiSelect , preventSelecting , emptyMessage , id , onItemSelectedChange , selectedValue , fixedWidth , })=>{
  335. const [scrollToSelectedItem, selectedItemRef] = (0,useScrollToElement/* default */.ZP)(SCROLL_TO_SELECTED_ELEMENT_OPTIONS);
  336. // once the dropdown is opened, scroll to the selected item.
  337. (0,external_react_.useEffect)(()=>{
  338. if (isOpened) {
  339. scrollToSelectedItem();
  340. }
  341. }, [
  342. isOpened,
  343. scrollToSelectedItem
  344. ]);
  345. return /*#__PURE__*/ jsx_runtime_.jsx("div", {
  346. className: external_classnames_default()((ComboboxItems_module_default()).comboboxBodyContainer, {
  347. [(ComboboxItems_module_default()).openedComboboxBodyContainer]: isOpened,
  348. [(ComboboxItems_module_default()).largeComboboxBodyContainer]: size === types_ComboboxSize.Large,
  349. [(ComboboxItems_module_default()).fixedWidth]: fixedWidth
  350. }),
  351. "aria-modal": "true",
  352. role: "dialog",
  353. children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
  354. className: (ComboboxItems_module_default()).itemsContainer,
  355. role: "listbox",
  356. children: [
  357. filteredItems.map((item)=>{
  358. let checked = false;
  359. if (selectedValue) {
  360. if (!isMultiSelect && selectedValue === item.name) {
  361. checked = true;
  362. } else if (isMultiSelect && selectedValue[item.name] !== undefined) {
  363. checked = true;
  364. }
  365. }
  366. const isItemDisabled = disabled === true || item.disabled === true || preventSelecting;
  367. const itemId = `${id}-${item.id}`;
  368. return /*#__PURE__*/ jsx_runtime_.jsx(Combobox_ComboboxItem, {
  369. onItemSelectedChange: onItemSelectedChange,
  370. checked: checked,
  371. disabled: isItemDisabled,
  372. itemId: itemId,
  373. selectedItemRef: selectedItemRef,
  374. item: item
  375. }, itemId);
  376. }),
  377. !filteredItems.length && /*#__PURE__*/ jsx_runtime_.jsx(Combobox_ComboboxItem, {
  378. emptyMessage: emptyMessage,
  379. checked: false,
  380. disabled: true,
  381. isNotFound: true
  382. })
  383. ]
  384. })
  385. });
  386. };
  387. /* harmony default export */ const Combobox_ComboboxItems = (ComboboxItems);
  388. // EXTERNAL MODULE: ./src/components/dls/Forms/Combobox/Icons/CaretInputIcon.module.scss
  389. var CaretInputIcon_module = __webpack_require__(82601);
  390. var CaretInputIcon_module_default = /*#__PURE__*/__webpack_require__.n(CaretInputIcon_module);
  391. // EXTERNAL MODULE: ./public/icons/caret-down.svg
  392. var caret_down = __webpack_require__(85970);
  393. ;// CONCATENATED MODULE: ./src/components/dls/Forms/Combobox/Icons/CaretInputIcon.tsx
  394. const CaretInputIcon = ({ shouldShowIcon , isOpened })=>{
  395. if (!shouldShowIcon) {
  396. return null;
  397. }
  398. return /*#__PURE__*/ jsx_runtime_.jsx("div", {
  399. className: external_classnames_default()((CaretInputIcon_module_default()).caretIconButton, {
  400. [(CaretInputIcon_module_default()).openedCaretIconButton]: isOpened
  401. }),
  402. "aria-label": "Show more",
  403. children: /*#__PURE__*/ jsx_runtime_.jsx(caret_down/* default */.Z, {})
  404. });
  405. };
  406. /* harmony default export */ const Icons_CaretInputIcon = (CaretInputIcon);
  407. // EXTERNAL MODULE: ./src/components/dls/Forms/Combobox/Icons/ClearInputIcon.module.scss
  408. var ClearInputIcon_module = __webpack_require__(80899);
  409. var ClearInputIcon_module_default = /*#__PURE__*/__webpack_require__.n(ClearInputIcon_module);
  410. // EXTERNAL MODULE: ./public/icons/close.svg
  411. var icons_close = __webpack_require__(51053);
  412. ;// CONCATENATED MODULE: ./src/components/dls/Forms/Combobox/Icons/ClearInputIcon.tsx
  413. const ClearInputIcon = ({ shouldShowIcon , onClearButtonClicked })=>{
  414. if (!shouldShowIcon) {
  415. return null;
  416. }
  417. return /*#__PURE__*/ jsx_runtime_.jsx("span", {
  418. className: (ClearInputIcon_module_default()).clearIconContainer,
  419. // eslint-disable-next-line react/no-unknown-property
  420. unselectable: "on",
  421. "aria-hidden": "true",
  422. onClick: onClearButtonClicked,
  423. children: /*#__PURE__*/ jsx_runtime_.jsx("span", {
  424. role: "img",
  425. "aria-label": "close-circle",
  426. className: (ClearInputIcon_module_default()).icon,
  427. children: /*#__PURE__*/ jsx_runtime_.jsx(icons_close/* default */.Z, {})
  428. })
  429. });
  430. };
  431. /* harmony default export */ const Icons_ClearInputIcon = (ClearInputIcon);
  432. // EXTERNAL MODULE: ./src/components/dls/Forms/Combobox/Icons/SearchInputIcon.module.scss
  433. var SearchInputIcon_module = __webpack_require__(24899);
  434. var SearchInputIcon_module_default = /*#__PURE__*/__webpack_require__.n(SearchInputIcon_module);
  435. // EXTERNAL MODULE: ./public/icons/search.svg
  436. var search = __webpack_require__(29033);
  437. ;// CONCATENATED MODULE: ./src/components/dls/Forms/Combobox/Icons/SearchInputIcon.tsx
  438. /* eslint-disable react/no-unknown-property */
  439. const SearchInputIcon = ()=>/*#__PURE__*/ jsx_runtime_.jsx("span", {
  440. className: external_classnames_default()((SearchInputIcon_module_default()).iconContainer, (SearchInputIcon_module_default()).selectSearch),
  441. unselectable: "on",
  442. "aria-hidden": "true",
  443. children: /*#__PURE__*/ jsx_runtime_.jsx("span", {
  444. role: "img",
  445. className: (SearchInputIcon_module_default()).icon,
  446. children: /*#__PURE__*/ jsx_runtime_.jsx(search/* default */.Z, {})
  447. })
  448. });
  449. /* harmony default export */ const Icons_SearchInputIcon = (SearchInputIcon);
  450. // EXTERNAL MODULE: ./src/components/dls/Forms/Combobox/Tag/Tag.module.scss
  451. var Tag_module = __webpack_require__(17874);
  452. var Tag_module_default = /*#__PURE__*/__webpack_require__.n(Tag_module);
  453. ;// CONCATENATED MODULE: ./src/components/dls/Forms/Combobox/Tag/index.tsx
  454. /* eslint-disable react/no-unknown-property */
  455. const Tag = ({ onRemoveTagClicked , size , tag })=>/*#__PURE__*/ (0,jsx_runtime_.jsxs)("span", {
  456. className: external_classnames_default()((Tag_module_default()).item, {
  457. [(Tag_module_default()).largeItem]: size === types_ComboboxSize.Large
  458. }),
  459. children: [
  460. /*#__PURE__*/ jsx_runtime_.jsx("span", {
  461. className: (Tag_module_default()).itemContent,
  462. children: tag
  463. }),
  464. /*#__PURE__*/ jsx_runtime_.jsx("span", {
  465. className: (Tag_module_default()).itemRemove,
  466. unselectable: "on",
  467. "aria-hidden": "true",
  468. onClick: (event)=>{
  469. onRemoveTagClicked(event, tag);
  470. },
  471. children: /*#__PURE__*/ jsx_runtime_.jsx("span", {
  472. role: "img",
  473. "aria-label": "close",
  474. className: (Tag_module_default()).icon,
  475. children: /*#__PURE__*/ jsx_runtime_.jsx(icons_close/* default */.Z, {})
  476. })
  477. })
  478. ]
  479. });
  480. /* harmony default export */ const Combobox_Tag = (/*#__PURE__*/(0,external_react_.memo)(Tag));
  481. // EXTERNAL MODULE: ./src/hooks/useFocusElement.ts
  482. var useFocusElement = __webpack_require__(79862);
  483. // EXTERNAL MODULE: ./src/hooks/useOutsideClickDetector.ts
  484. var useOutsideClickDetector = __webpack_require__(38646);
  485. ;// CONCATENATED MODULE: ./src/components/dls/Forms/Combobox/index.tsx
  486. /* eslint-disable react/no-unknown-property */ /* eslint-disable max-lines */ /* eslint-disable jsx-a11y/role-has-required-aria-props */ /* eslint-disable jsx-a11y/click-events-have-key-events */ /* eslint-disable jsx-a11y/no-static-element-interactions */
  487. const Combobox = ({ items , placeholder ="Search..." , hasError =false , value , initialInputValue , disabled =false , clearable =true , isMultiSelect =false , emptyMessage ="No results" , tagsLimit , label , id , size =types_ComboboxSize.Medium , minimumRequiredItems =0 , onChange , fixedWidth =true , })=>{
  488. const { 0: isOpened , 1: setIsOpened } = (0,external_react_.useState)(false);
  489. const { 0: inputValue , 1: setInputValue } = (0,external_react_.useState)(initialInputValue || "");
  490. const { 0: selectedValue , 1: setSelectedValue } = (0,external_react_.useState)(()=>{
  491. if (!value) {
  492. return getDefaultValue(isMultiSelect);
  493. }
  494. if (!isMultiSelect) {
  495. return value;
  496. }
  497. return convertArrayToObject(value);
  498. });
  499. const { 0: filteredItems , 1: setFilteredItems } = (0,external_react_.useState)(items);
  500. const [focusInput, inputRef] = (0,useFocusElement/* default */.Z)();
  501. const comboBoxRef = (0,external_react_.useRef)(null);
  502. // instead of running items.find in the closeCombobox function, we can create a map to memoize the result
  503. const valueToLabelMap = (0,external_react_.useMemo)(()=>{
  504. const map = {};
  505. items.forEach((item)=>{
  506. map[item.value] = item.label;
  507. });
  508. return map;
  509. }, [
  510. items
  511. ]);
  512. const closeCombobox = (0,external_react_.useCallback)(()=>{
  513. if (!isMultiSelect) {
  514. const currentValue = selectedValue;
  515. setInputValue(valueToLabelMap[currentValue] ?? currentValue);
  516. } else {
  517. setInputValue("");
  518. }
  519. setIsOpened(false);
  520. }, [
  521. isMultiSelect,
  522. selectedValue,
  523. valueToLabelMap
  524. ]);
  525. (0,useOutsideClickDetector/* default */.Z)(comboBoxRef, closeCombobox, isOpened);
  526. (0,external_react_hotkeys_hook_.useHotkeys)("Escape", closeCombobox, {
  527. enabled: isOpened,
  528. enableOnTags: [
  529. "INPUT"
  530. ]
  531. });
  532. // if there are any changes in the items, we should update the filteredItems.
  533. // this is necessary when the parent items are have initial empty value and
  534. // the actual values are fetched remotely and by the time they have a value,
  535. // filteredItems would have already been initialized with the initial items value
  536. // and the actual values wouldn't reflect.
  537. (0,external_react_.useEffect)(()=>{
  538. setFilteredItems(items);
  539. }, [
  540. items
  541. ]);
  542. // filter items when the search query changes
  543. (0,external_react_.useEffect)(()=>{
  544. // if the search query is empty it means it has been cleared so we set the original items back.
  545. setFilteredItems(!inputValue ? items : items.filter((item)=>// we convert the search query and the item's label to lowercase first then check if the label contains a part/all of the search query.
  546. item.label.toLowerCase().includes(inputValue.toLowerCase())));
  547. }, [
  548. inputValue,
  549. items
  550. ]);
  551. // if there are any changes in the value, we should update the selectedValue.
  552. (0,external_react_.useEffect)(()=>{
  553. if (!value) {
  554. setSelectedValue(getDefaultValue(isMultiSelect));
  555. } else {
  556. setSelectedValue(isMultiSelect ? convertArrayToObject(value) : value);
  557. }
  558. }, [
  559. value,
  560. isMultiSelect
  561. ]);
  562. // if there are any changes in the initialInputValue, we should update the inputValue.
  563. (0,external_react_.useEffect)(()=>{
  564. setInputValue(initialInputValue);
  565. }, [
  566. initialInputValue
  567. ]);
  568. const tags = (0,external_react_.useMemo)(()=>{
  569. if (!isMultiSelect) {
  570. return null;
  571. }
  572. // get the labels of the selected items by looking inside items array
  573. return items.filter((item)=>Object.keys(selectedValue).includes(item.name)).map((item)=>item.label);
  574. }, [
  575. isMultiSelect,
  576. items,
  577. selectedValue
  578. ]);
  579. /**
  580. * By default we can un-select any items. We disallow unselecting items when
  581. * we meet the the following conditions:
  582. *
  583. * 1. minimumRequiredItems has a value above 0.
  584. * 2. if it's isMultiSelect:
  585. * 2.1 there should be some selected items already.
  586. * 2.2 the number of selected items are either equal to
  587. * or below the minimum required selected items.
  588. * 3. if it's not isMultiSelect: there should already be a selected value.
  589. */ const hasMinimumRequiredItems = minimumRequiredItems > 0;
  590. const preventUnselectingItems = hasMinimumRequiredItems && (tags && tags.length <= minimumRequiredItems || !isMultiSelect && selectedValue);
  591. const invokeOnChangeCallback = (0,external_react_.useCallback)((newValue)=>{
  592. if (onChange) {
  593. onChange(isMultiSelect ? Object.keys(newValue) : newValue, id);
  594. }
  595. }, [
  596. id,
  597. isMultiSelect,
  598. onChange
  599. ]);
  600. /**
  601. * We detect whether we should allow to delete the last selected tag when clicking
  602. * the backspace key based on the following conditions:
  603. *
  604. * 1. it it's multiSelect.
  605. * 2. The input value doesn't have a value otherwise, backspace key should be used to remove the input value and not the present tags.
  606. * 3. We at least have 1 tag present.
  607. * 4. We allow un-selecting items.
  608. */ (0,external_react_hotkeys_hook_.useHotkeys)("Backspace", ()=>{
  609. setSelectedValue((prevSelectedValue)=>{
  610. const newSelectedValues = {
  611. ...prevSelectedValue
  612. };
  613. const lastTag = Object.keys(newSelectedValues).pop();
  614. delete newSelectedValues[lastTag];
  615. invokeOnChangeCallback(newSelectedValues);
  616. return newSelectedValues;
  617. });
  618. }, {
  619. enabled: isOpened && isMultiSelect && !inputValue && !!tags.length && !preventUnselectingItems,
  620. enableOnTags: [
  621. "INPUT"
  622. ]
  623. }, [
  624. invokeOnChangeCallback
  625. ]);
  626. const onSelectorClicked = ()=>{
  627. setIsOpened((prevIsOpened)=>!prevIsOpened);
  628. // we need to focus on the input field whenever the user clicks anywhere inside the component.
  629. if (isMultiSelect) {
  630. focusInput();
  631. }
  632. };
  633. /**
  634. * Handle when an item is selected.
  635. *
  636. * @param {ChangeEvent<HTMLInputElement>} event
  637. */ const onItemSelectedChange = (0,external_react_.useCallback)((event)=>{
  638. const { itemLabel } = event.target.dataset;
  639. const selectedItemName = event.target.name;
  640. const isUnSelect = !event.currentTarget.checked;
  641. /*
  642. only change the selected value if:
  643. 1. we are selecting.
  644. 2. we are un-selecting and we are not prevented from un-selecting.
  645. */ const shouldProcessChange = !isUnSelect || isUnSelect && !preventUnselectingItems;
  646. if (isMultiSelect) {
  647. if (shouldProcessChange) {
  648. setSelectedValue((prevSelectedValues)=>{
  649. const newSelectedValues = {
  650. ...prevSelectedValues
  651. };
  652. if (isUnSelect) {
  653. delete newSelectedValues[selectedItemName];
  654. } else {
  655. newSelectedValues[selectedItemName] = true;
  656. }
  657. invokeOnChangeCallback(newSelectedValues);
  658. return newSelectedValues;
  659. });
  660. }
  661. setInputValue(""); // reset the input value even if it's selecting.
  662. } else if (shouldProcessChange) {
  663. setInputValue(isUnSelect ? "" : itemLabel);
  664. setSelectedValue(()=>{
  665. const newSelectedValue = isUnSelect ? "" : selectedItemName;
  666. invokeOnChangeCallback(newSelectedValue);
  667. return newSelectedValue;
  668. });
  669. }
  670. setIsOpened(false); // close the items container
  671. }, [
  672. preventUnselectingItems,
  673. invokeOnChangeCallback,
  674. isMultiSelect
  675. ]);
  676. /**
  677. * Handle when the user searches for an item.
  678. *
  679. * @param {React.FormEvent<HTMLInputElement>} event
  680. * @returns {void}
  681. */ const onInputValueChange = (event)=>{
  682. const newInputValue = event.currentTarget.value;
  683. setInputValue(newInputValue);
  684. setIsOpened(true);
  685. };
  686. /**
  687. * Handle when the clear button is clicked.
  688. * We will reset the input value, the selected value
  689. * and the filtered items.
  690. *
  691. * @param {React.MouseEvent<HTMLSpanElement>} event
  692. */ const onClearButtonClicked = (event)=>{
  693. event.stopPropagation();
  694. /*
  695. Don't allow the clearing of the selected items when:
  696. 1. it's multiSelect.
  697. 2. has minimum required items set.
  698. This is done to avoid clearing all items while the minimum amount of items
  699. that should be selected is set.
  700. */ if (!(hasMinimumRequiredItems && isMultiSelect)) {
  701. setInputValue("");
  702. // if it's allowed to un-select items.
  703. if (!preventUnselectingItems) {
  704. setSelectedValue(()=>{
  705. const defaultSelectedValue = getDefaultValue(isMultiSelect);
  706. invokeOnChangeCallback(defaultSelectedValue);
  707. return defaultSelectedValue;
  708. });
  709. }
  710. }
  711. };
  712. /**
  713. * Handle when removing a tag.
  714. *
  715. * @param {React.MouseEvent<HTMLSpanElement>} event
  716. * @param {string} tag
  717. */ const onRemoveTagClicked = (0,external_react_.useCallback)((event, tag)=>{
  718. event.stopPropagation();
  719. // if it's allowed to un-select items.
  720. if (!preventUnselectingItems) {
  721. const toBeRemovedTag = items.find((item)=>item.label === tag);
  722. setSelectedValue((prevSelectedValues)=>{
  723. const newSelectedValues = {
  724. ...prevSelectedValues
  725. };
  726. delete newSelectedValues[toBeRemovedTag.name];
  727. invokeOnChangeCallback(newSelectedValues);
  728. return newSelectedValues;
  729. });
  730. }
  731. }, [
  732. invokeOnChangeCallback,
  733. items,
  734. preventUnselectingItems
  735. ]);
  736. const shouldShowCaret = !isMultiSelect && !inputValue || isMultiSelect && !inputValue && !tags.length;
  737. const shouldShowClear = clearable && !shouldShowCaret;
  738. // if we should prevent selecting when the tags limit has been reached.
  739. const preventSelecting = tagsLimit && tags && tags.length >= tagsLimit;
  740. return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
  741. children: [
  742. label && /*#__PURE__*/ jsx_runtime_.jsx("p", {
  743. className: (Combobox_module_default()).label,
  744. children: label
  745. }),
  746. /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
  747. ref: comboBoxRef,
  748. className: external_classnames_default()((Combobox_module_default()).comboboxContainer, {
  749. [(Combobox_module_default()).enabled]: !disabled,
  750. [(Combobox_module_default()).fixedWidth]: fixedWidth
  751. }),
  752. children: [
  753. /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
  754. onClick: onSelectorClicked,
  755. className: external_classnames_default()((Combobox_module_default()).select, {
  756. [(Combobox_module_default()).disabledSearch]: disabled
  757. }),
  758. children: [
  759. /*#__PURE__*/ jsx_runtime_.jsx(Icons_SearchInputIcon, {}),
  760. /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
  761. className: external_classnames_default()((Combobox_module_default()).selector, {
  762. [(Combobox_module_default()).disabledSelector]: disabled,
  763. [(Combobox_module_default()).activeSelector]: !disabled && !hasError && isOpened,
  764. [(Combobox_module_default()).hasError]: hasError
  765. }),
  766. children: [
  767. /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
  768. className: external_classnames_default()({
  769. [(Combobox_module_default()).overflow]: isMultiSelect,
  770. [(Combobox_module_default()).fullWidth]: !isMultiSelect
  771. }),
  772. children: [
  773. isMultiSelect && tags.map((tag)=>/*#__PURE__*/ jsx_runtime_.jsx("div", {
  774. className: external_classnames_default()((Combobox_module_default()).overflowItem, (Combobox_module_default()).tagContainer),
  775. children: /*#__PURE__*/ jsx_runtime_.jsx(Combobox_Tag, {
  776. tag: tag,
  777. onRemoveTagClicked: onRemoveTagClicked,
  778. size: size
  779. })
  780. }, tag)),
  781. /*#__PURE__*/ jsx_runtime_.jsx("div", {
  782. className: (Combobox_module_default()).overflowItem,
  783. children: /*#__PURE__*/ jsx_runtime_.jsx("div", {
  784. className: external_classnames_default()((Combobox_module_default()).search, {
  785. [(Combobox_module_default()).fullWidth]: !isMultiSelect
  786. }),
  787. style: {
  788. ...isMultiSelect && inputValue && {
  789. width: `${inputValue.length}rem`
  790. }
  791. },
  792. children: /*#__PURE__*/ jsx_runtime_.jsx("input", {
  793. ref: inputRef,
  794. autoComplete: "off",
  795. type: "search",
  796. className: external_classnames_default()((Combobox_module_default()).multiSelectSearchInput, {
  797. [(Combobox_module_default()).smallSearchInput]: size === types_ComboboxSize.Small,
  798. [(Combobox_module_default()).mediumSearchInput]: size === types_ComboboxSize.Medium,
  799. [(Combobox_module_default()).largeSearchInput]: size === types_ComboboxSize.Large
  800. }),
  801. role: "combobox",
  802. "aria-haspopup": "listbox",
  803. "aria-expanded": isOpened,
  804. "aria-owns": id,
  805. "aria-autocomplete": "list",
  806. onChange: onInputValueChange,
  807. value: inputValue,
  808. disabled: disabled,
  809. readOnly: false,
  810. unselectable: "on",
  811. ...!isMultiSelect && {
  812. placeholder
  813. }
  814. })
  815. })
  816. })
  817. ]
  818. }),
  819. isMultiSelect && !tags.length && !inputValue && /*#__PURE__*/ jsx_runtime_.jsx("span", {
  820. className: (Combobox_module_default()).placeholder,
  821. children: placeholder
  822. })
  823. ]
  824. }),
  825. /*#__PURE__*/ jsx_runtime_.jsx(Icons_CaretInputIcon, {
  826. isOpened: isOpened,
  827. shouldShowIcon: shouldShowCaret
  828. }),
  829. /*#__PURE__*/ jsx_runtime_.jsx(Icons_ClearInputIcon, {
  830. shouldShowIcon: shouldShowClear,
  831. onClearButtonClicked: onClearButtonClicked
  832. })
  833. ]
  834. }),
  835. /*#__PURE__*/ jsx_runtime_.jsx(Combobox_ComboboxItems, {
  836. onItemSelectedChange: onItemSelectedChange,
  837. isOpened: isOpened,
  838. disabled: disabled,
  839. size: size,
  840. filteredItems: filteredItems,
  841. isMultiSelect: isMultiSelect,
  842. preventSelecting: preventSelecting,
  843. selectedValue: selectedValue,
  844. id: id,
  845. emptyMessage: emptyMessage,
  846. fixedWidth: fixedWidth
  847. })
  848. ]
  849. })
  850. ]
  851. });
  852. };
  853. /**
  854. * Get the default value based on the type:
  855. *
  856. * - if it's multi-select, it's an empty object.
  857. * - if it's single-select, it's an empty string.
  858. *
  859. * @param {boolean} isMultiSelect
  860. * @returns {Value}
  861. */ const getDefaultValue = (isMultiSelect)=>isMultiSelect ? {} : "";
  862. /**
  863. * Convert the initial values array of strings to an object.
  864. *
  865. * @param {InitialSelectedItems} array
  866. * @returns {MultiSelectValue}
  867. */ const convertArrayToObject = (array)=>{
  868. const multiSelectValue = {};
  869. array.forEach((selectedItem)=>{
  870. multiSelectValue[selectedItem] = true;
  871. });
  872. return multiSelectValue;
  873. };
  874. /* harmony default export */ const Forms_Combobox = (Combobox);
  875. // EXTERNAL MODULE: ./types/Range.ts
  876. var Range = __webpack_require__(70725);
  877. // EXTERNAL MODULE: ./src/utils/generators.ts
  878. var generators = __webpack_require__(49184);
  879. // EXTERNAL MODULE: ./src/utils/verse.ts
  880. var verse = __webpack_require__(44519);
  881. ;// CONCATENATED MODULE: ./src/components/ReadingGoal/ReadingGoalInput/VerseRangeInput.tsx
  882. /* eslint-disable max-lines */
  883. const VerseRangeInput = ({ rangeStartVerse , rangeEndVerse , onRangeChange , logChange })=>{
  884. const { t , lang } = useTranslation_default()("reading-goal");
  885. const chaptersData = (0,external_react_.useContext)(DataContext/* default */.Z);
  886. const { 0: startChapter , 1: setStartChapter } = (0,external_react_.useState)(rangeStartVerse ? (0,verse/* getChapterNumberFromKey */.Tc)(rangeStartVerse).toString() : undefined);
  887. const { 0: endChapter , 1: setEndChapter } = (0,external_react_.useState)(rangeEndVerse ? (0,verse/* getChapterNumberFromKey */.Tc)(rangeEndVerse).toString() : undefined);
  888. const chapterOptions = (0,external_react_.useMemo)(()=>(0,generators/* generateChapterOptions */.IU)(chaptersData, lang), [
  889. chaptersData,
  890. lang
  891. ]);
  892. const startingVerseOptions = (0,external_react_.useMemo)(()=>(0,generators/* generateVerseOptions */.ZK)(chaptersData, t, lang, startChapter), [
  893. t,
  894. lang,
  895. chaptersData,
  896. startChapter
  897. ]);
  898. const endingVerseOptions = (0,external_react_.useMemo)(()=>(0,generators/* generateVerseOptions */.ZK)(chaptersData, t, lang, endChapter), [
  899. t,
  900. lang,
  901. chaptersData,
  902. endChapter
  903. ]);
  904. // useEffect(() => {
  905. // if (!rangeStartVerse) {
  906. // setStartChapter(undefined);
  907. // }
  908. // }, [rangeStartVerse]);
  909. // useEffect(() => {
  910. // if (!rangeEndVerse) {
  911. // setEndChapter(undefined);
  912. // }
  913. // }, [rangeEndVerse]);
  914. const endingVerse = (0,external_react_.useMemo)(()=>{
  915. if (!rangeEndVerse) return undefined;
  916. return (0,verse/* getVerseNumberFromKey */.tR)(rangeEndVerse).toString();
  917. }, [
  918. rangeEndVerse
  919. ]);
  920. const startingVerse = (0,external_react_.useMemo)(()=>{
  921. if (!rangeStartVerse) return undefined;
  922. return (0,verse/* getVerseNumberFromKey */.tR)(rangeStartVerse).toString();
  923. }, [
  924. rangeStartVerse
  925. ]);
  926. // eslint-disable-next-line react-func/max-lines-per-function
  927. const onChapterChange = (chapterPosition)=>(chapterId)=>{
  928. const isStartChapter = chapterPosition === Range/* RangeItemPosition.Start */.EQ.Start;
  929. const oldChapterId = isStartChapter ? startChapter : endChapter;
  930. const setChapter = isStartChapter ? setStartChapter : setEndChapter;
  931. if (!chapterId || chapterId !== oldChapterId) {
  932. onRangeChange(isStartChapter ? {
  933. startVerse: null,
  934. endVerse: rangeEndVerse
  935. } : {
  936. startVerse: rangeStartVerse,
  937. endVerse: null
  938. });
  939. }
  940. // if the current value is null, we don't need to log it
  941. const currentVerse = isStartChapter ? rangeStartVerse : rangeEndVerse;
  942. if (currentVerse && logChange) {
  943. logChange(isStartChapter ? "start_verse" : "end_verse", {
  944. currentValue: currentVerse,
  945. newValue: null
  946. }, {
  947. chapter: chapterId || null,
  948. verse: (isStartChapter ? startingVerse : endingVerse) || null
  949. });
  950. }
  951. if (!chapterId) {
  952. setChapter(undefined);
  953. } else {
  954. setChapter(chapterId);
  955. }
  956. };
  957. const startChapterOptions = (0,external_react_.useMemo)(()=>{
  958. if (!endChapter) return chapterOptions;
  959. const endChapterIdx = Number(endChapter) - 1;
  960. return chapterOptions.slice(0, endChapterIdx + 1);
  961. }, [
  962. chapterOptions,
  963. endChapter
  964. ]);
  965. const endChapterOptions = (0,external_react_.useMemo)(()=>{
  966. if (!startChapter) return chapterOptions;
  967. const startChapterIdx = Number(startChapter) - 1;
  968. return chapterOptions.slice(startChapterIdx);
  969. }, [
  970. chapterOptions,
  971. startChapter
  972. ]);
  973. const onVerseChange = (versePosition)=>(verseId)=>{
  974. const isStartVerse = versePosition === Range/* RangeItemPosition.Start */.EQ.Start;
  975. const newVerseKey = verseId ? (0,verse/* makeVerseKey */.u)(isStartVerse ? startChapter : endChapter, verseId) : null;
  976. onRangeChange(isStartVerse ? {
  977. startVerse: newVerseKey,
  978. endVerse: rangeEndVerse
  979. } : {
  980. startVerse: rangeStartVerse,
  981. endVerse: newVerseKey
  982. });
  983. if (logChange) {
  984. logChange(isStartVerse ? "start_verse" : "end_verse", {
  985. currentValue: isStartVerse ? rangeStartVerse : rangeEndVerse,
  986. newValue: newVerseKey
  987. }, {
  988. chapter: (isStartVerse ? startChapter : endChapter) || null,
  989. verse: verseId || null
  990. });
  991. }
  992. };
  993. const getInitialInputValue = (inputType)=>{
  994. if (inputType === Range/* RangeItem.StartingChapter */.JF.StartingChapter || inputType === Range/* RangeItem.EndingChapter */.JF.EndingChapter) {
  995. const chapterId = inputType === Range/* RangeItem.StartingChapter */.JF.StartingChapter ? startChapter : endChapter;
  996. if (!chapterId) return undefined;
  997. return chapterOptions[Number(chapterId) - 1]?.label;
  998. }
  999. const verseId = inputType === Range/* RangeItem.StartingVerse */.JF.StartingVerse ? startingVerse : endingVerse;
  1000. if (!verseId) return "";
  1001. const verseOptions = inputType === Range/* RangeItem.StartingVerse */.JF.StartingVerse ? startingVerseOptions : endingVerseOptions;
  1002. return verseOptions[Number(verseId) - 1]?.label;
  1003. };
  1004. return /*#__PURE__*/ (0,jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
  1005. children: [
  1006. /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
  1007. className: (ReadingGoalInput_module_default()).rangeInputContainer,
  1008. children: [
  1009. /*#__PURE__*/ jsx_runtime_.jsx("div", {
  1010. children: /*#__PURE__*/ jsx_runtime_.jsx(Forms_Combobox, {
  1011. id: "start-chapter",
  1012. size: types_ComboboxSize.Large,
  1013. fixedWidth: false,
  1014. label: /*#__PURE__*/ jsx_runtime_.jsx("p", {
  1015. className: (ReadingGoalInput_module_default()).label,
  1016. children: t("starting-chapter")
  1017. }),
  1018. items: startChapterOptions,
  1019. value: startChapter,
  1020. initialInputValue: getInitialInputValue(Range/* RangeItem.StartingChapter */.JF.StartingChapter),
  1021. onChange: onChapterChange(Range/* RangeItemPosition.Start */.EQ.Start)
  1022. })
  1023. }),
  1024. /*#__PURE__*/ jsx_runtime_.jsx("div", {
  1025. children: /*#__PURE__*/ jsx_runtime_.jsx(Forms_Combobox, {
  1026. id: "starting-verse",
  1027. size: types_ComboboxSize.Large,
  1028. fixedWidth: false,
  1029. disabled: !startChapter,
  1030. label: /*#__PURE__*/ jsx_runtime_.jsx("p", {
  1031. className: (ReadingGoalInput_module_default()).label,
  1032. children: t("starting-verse")
  1033. }),
  1034. items: startingVerseOptions,
  1035. value: startingVerse,
  1036. initialInputValue: getInitialInputValue(Range/* RangeItem.StartingVerse */.JF.StartingVerse),
  1037. onChange: onVerseChange(Range/* RangeItemPosition.Start */.EQ.Start)
  1038. })
  1039. })
  1040. ]
  1041. }),
  1042. /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
  1043. className: (ReadingGoalInput_module_default()).rangeInputContainer,
  1044. children: [
  1045. /*#__PURE__*/ jsx_runtime_.jsx("div", {
  1046. children: /*#__PURE__*/ jsx_runtime_.jsx(Forms_Combobox, {
  1047. id: "end-chapter",
  1048. size: types_ComboboxSize.Large,
  1049. fixedWidth: false,
  1050. label: /*#__PURE__*/ jsx_runtime_.jsx("p", {
  1051. className: (ReadingGoalInput_module_default()).label,
  1052. children: t("ending-chapter")
  1053. }),
  1054. items: endChapterOptions,
  1055. value: endChapter,
  1056. initialInputValue: getInitialInputValue(Range/* RangeItem.EndingChapter */.JF.EndingChapter),
  1057. onChange: onChapterChange(Range/* RangeItemPosition.End */.EQ.End)
  1058. })
  1059. }),
  1060. /*#__PURE__*/ jsx_runtime_.jsx("div", {
  1061. children: /*#__PURE__*/ jsx_runtime_.jsx(Forms_Combobox, {
  1062. id: "end-verse",
  1063. size: types_ComboboxSize.Large,
  1064. fixedWidth: false,
  1065. label: /*#__PURE__*/ jsx_runtime_.jsx("p", {
  1066. className: (ReadingGoalInput_module_default()).label,
  1067. children: t("ending-verse")
  1068. }),
  1069. items: endingVerseOptions,
  1070. value: endingVerse,
  1071. disabled: !endChapter,
  1072. initialInputValue: getInitialInputValue(Range/* RangeItem.EndingVerse */.JF.EndingVerse),
  1073. onChange: onVerseChange(Range/* RangeItemPosition.End */.EQ.End)
  1074. })
  1075. })
  1076. ]
  1077. })
  1078. ]
  1079. });
  1080. };
  1081. /* harmony default export */ const ReadingGoalInput_VerseRangeInput = (VerseRangeInput);
  1082. /***/ }),
  1083. /***/ 93272:
  1084. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  1085. "use strict";
  1086. __webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
  1087. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1088. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  1089. /* harmony export */ });
  1090. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  1091. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  1092. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  1093. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  1094. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(59003);
  1095. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__);
  1096. /* harmony import */ var next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(60866);
  1097. /* harmony import */ var next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3__);
  1098. /* harmony import */ var _ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(13646);
  1099. /* harmony import */ var _ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9__);
  1100. /* harmony import */ var _VerseRangeInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(37326);
  1101. /* harmony import */ var _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(91308);
  1102. /* harmony import */ var _dls_Forms_Select__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(58087);
  1103. /* harmony import */ var _types_auth_Goal__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(63196);
  1104. /* harmony import */ var _utils_generators__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(49184);
  1105. var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_dls_Forms_Input__WEBPACK_IMPORTED_MODULE_5__]);
  1106. _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_5__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
  1107. /* eslint-disable react-func/max-lines-per-function */ /* eslint-disable max-lines */
  1108. const ReadingGoalInput = ({ type , rangeStartVerse , rangeEndVerse , pages , seconds , onRangeChange , onPagesChange , onSecondsChange , widthFull =true , logChange , })=>{
  1109. const { t , lang } = next_translate_useTranslation__WEBPACK_IMPORTED_MODULE_3___default()("reading-goal");
  1110. const timeOptions = (0,react__WEBPACK_IMPORTED_MODULE_1__.useMemo)(()=>(0,_utils_generators__WEBPACK_IMPORTED_MODULE_8__/* .generateTimeOptions */ .Ph)(t, lang), [
  1111. t,
  1112. lang
  1113. ]);
  1114. if (type === _types_auth_Goal__WEBPACK_IMPORTED_MODULE_7__/* .GoalType.RANGE */ .lC.RANGE) {
  1115. return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_VerseRangeInput__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {
  1116. rangeStartVerse: rangeStartVerse,
  1117. rangeEndVerse: rangeEndVerse,
  1118. onRangeChange: onRangeChange,
  1119. logChange: logChange
  1120. });
  1121. }
  1122. if (type === _types_auth_Goal__WEBPACK_IMPORTED_MODULE_7__/* .GoalType.PAGES */ .lC.PAGES) {
  1123. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
  1124. className: (_ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9___default().inputContainer),
  1125. children: [
  1126. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
  1127. htmlFor: "pages",
  1128. className: (_ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9___default().label),
  1129. children: t("goal-types.pages.title")
  1130. }),
  1131. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_dls_Forms_Input__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .ZP, {
  1132. id: "pages",
  1133. containerClassName: classnames__WEBPACK_IMPORTED_MODULE_2___default()((_ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9___default().input), widthFull && (_ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9___default().fullWidth)),
  1134. size: _dls_Forms_Input__WEBPACK_IMPORTED_MODULE_5__/* .InputSize.Large */ .fz.Large,
  1135. value: pages.toString(),
  1136. fixedWidth: false,
  1137. htmlType: "number",
  1138. // prevent users from entering decimal value
  1139. onKeyDown: (e)=>e.key === "." && e.preventDefault(),
  1140. inputMode: "numeric",
  1141. onChange: (p)=>{
  1142. const parsedPages = Number(p);
  1143. onPagesChange(parsedPages);
  1144. logChange("pages", {
  1145. currentValue: pages,
  1146. newValue: parsedPages
  1147. });
  1148. }
  1149. })
  1150. ]
  1151. });
  1152. }
  1153. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
  1154. className: (_ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9___default().inputContainer),
  1155. children: [
  1156. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("label", {
  1157. htmlFor: "seconds",
  1158. className: (_ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9___default().label),
  1159. children: t("goal-types.time.title")
  1160. }),
  1161. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_dls_Forms_Select__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, {
  1162. id: "seconds",
  1163. name: "seconds",
  1164. size: _dls_Forms_Select__WEBPACK_IMPORTED_MODULE_6__/* .SelectSize.Large */ .h.Large,
  1165. className: (_ReadingGoalInput_module_scss__WEBPACK_IMPORTED_MODULE_9___default().input),
  1166. options: timeOptions,
  1167. value: seconds.toString(),
  1168. onChange: (s)=>{
  1169. const parsedSeconds = Number(s);
  1170. onSecondsChange(parsedSeconds);
  1171. logChange("seconds", {
  1172. currentValue: seconds,
  1173. newValue: parsedSeconds
  1174. });
  1175. }
  1176. })
  1177. ]
  1178. });
  1179. };
  1180. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ReadingGoalInput);
  1181. __webpack_async_result__();
  1182. } catch(e) { __webpack_async_result__(e); } });
  1183. /***/ }),
  1184. /***/ 27097:
  1185. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1186. "use strict";
  1187. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1188. /* harmony export */ "I": () => (/* binding */ isValidVerseRange),
  1189. /* harmony export */ "w": () => (/* binding */ validateReadingGoalData)
  1190. /* harmony export */ });
  1191. /* harmony import */ var _utils_validator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(41051);
  1192. /* harmony import */ var _utils_verse__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(44519);
  1193. /* harmony import */ var types_auth_Goal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(63196);
  1194. /* eslint-disable import/prefer-default-export */
  1195. const SECONDS_LIMIT = 4 * 60 * 60; // 4 hours
  1196. const MIN_SECONDS = 60; // 1 minute
  1197. /**
  1198. * A utility function to validate the reading goal data
  1199. *
  1200. * @param {ChaptersData} chaptersData
  1201. * @param {ReadingGoalPayload} payload
  1202. * @returns {boolean} is the payload valid
  1203. */ const validateReadingGoalData = (chaptersData, { type , pages , seconds , range }, mushafId)=>{
  1204. // if the user selected a pages goal and didn't enter a valid amount of pages, disable the next button
  1205. if (type === types_auth_Goal__WEBPACK_IMPORTED_MODULE_2__/* .GoalType.PAGES */ .lC.PAGES && !(0,_utils_validator__WEBPACK_IMPORTED_MODULE_0__/* .isValidPageNumber */ .vU)(pages, mushafId)) return false;
  1206. // if the user selected a time goal and didn't enter a valid amount of seconds, disable the next button
  1207. // in theory, this should never happen because the input is a select, but just in case
  1208. if (type === types_auth_Goal__WEBPACK_IMPORTED_MODULE_2__/* .GoalType.TIME */ .lC.TIME && (Number.isNaN(seconds) || seconds > SECONDS_LIMIT || seconds < MIN_SECONDS)) {
  1209. return false;
  1210. }
  1211. // if the user selected a range goal and didn't enter a valid range, disable the next button
  1212. if (type === types_auth_Goal__WEBPACK_IMPORTED_MODULE_2__/* .GoalType.RANGE */ .lC.RANGE) {
  1213. return isValidVerseRange(chaptersData, range);
  1214. }
  1215. return true;
  1216. };
  1217. /**
  1218. * Check wether the ranges are valid or not.
  1219. *
  1220. * @param {ChaptersData} chaptersData
  1221. * @param {Range} range
  1222. * @returns {boolean}
  1223. */ const isValidVerseRange = (chaptersData, range)=>{
  1224. if (!range?.startVerse || !range?.endVerse) return false;
  1225. if (!(0,_utils_validator__WEBPACK_IMPORTED_MODULE_0__/* .isValidVerseKey */ .CG)(chaptersData, range.startVerse) || !(0,_utils_validator__WEBPACK_IMPORTED_MODULE_0__/* .isValidVerseKey */ .CG)(chaptersData, range.endVerse)) {
  1226. return false;
  1227. }
  1228. // check if the starting verse key is greater than the ending verse key
  1229. const [startingChapter, startingVerse] = (0,_utils_verse__WEBPACK_IMPORTED_MODULE_1__/* .getVerseAndChapterNumbersFromKey */ .bV)(range.startVerse);
  1230. const [endingChapter, endingVerse] = (0,_utils_verse__WEBPACK_IMPORTED_MODULE_1__/* .getVerseAndChapterNumbersFromKey */ .bV)(range.endVerse);
  1231. // if it's the same Surah but in reverse order
  1232. if (startingChapter === endingChapter && Number(startingVerse) > Number(endingVerse)) {
  1233. return false;
  1234. }
  1235. // if it's the range Surahs are in reverse order
  1236. if (Number(startingChapter) > Number(endingChapter)) {
  1237. return false;
  1238. }
  1239. return true;
  1240. };
  1241. /***/ }),
  1242. /***/ 58087:
  1243. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1244. "use strict";
  1245. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1246. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__),
  1247. /* harmony export */ "h": () => (/* binding */ SelectSize)
  1248. /* harmony export */ });
  1249. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20997);
  1250. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  1251. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16689);
  1252. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  1253. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(59003);
  1254. /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__);
  1255. /* harmony import */ var _Select_module_scss__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(40458);
  1256. /* harmony import */ var _Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4__);
  1257. /* harmony import */ var _icons_caret_down_svg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(85970);
  1258. var SelectSize;
  1259. (function(SelectSize) {
  1260. SelectSize["Small"] = "small";
  1261. SelectSize["Medium"] = "medium";
  1262. SelectSize["Large"] = "large";
  1263. })(SelectSize || (SelectSize = {}));
  1264. const Select = ({ name , id , onChange , options , value , disabled =false , required =false , size =SelectSize.Medium , placeholder ="Select an option" , defaultStyle =true , className , withBackground =true , })=>{
  1265. const onSelectChange = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)((e)=>{
  1266. if (onChange) {
  1267. onChange(e.target.value);
  1268. }
  1269. }, [
  1270. onChange
  1271. ]);
  1272. return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
  1273. className: classnames__WEBPACK_IMPORTED_MODULE_2___default()((_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().container), {
  1274. [(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().defaultStyledContainer)]: defaultStyle,
  1275. [className]: className,
  1276. [(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().disabledContainer)]: disabled,
  1277. [(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().smallContainer)]: size === SelectSize.Small,
  1278. [(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().mediumContainer)]: size === SelectSize.Medium,
  1279. [(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().largeContainer)]: size === SelectSize.Large,
  1280. [(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().withBackground)]: withBackground
  1281. }),
  1282. children: [
  1283. /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("select", {
  1284. className: classnames__WEBPACK_IMPORTED_MODULE_2___default()((_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().select), {
  1285. [(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().defaultStyledSelect)]: defaultStyle,
  1286. [(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().disabledSelect)]: disabled
  1287. }),
  1288. name: name,
  1289. id: id,
  1290. onChange: onSelectChange,
  1291. disabled: disabled,
  1292. required: required,
  1293. ...value ? {
  1294. value
  1295. } : {
  1296. defaultValue: ""
  1297. },
  1298. children: [
  1299. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("option", {
  1300. value: "",
  1301. disabled: true,
  1302. hidden: true,
  1303. children: placeholder
  1304. }),
  1305. options.map((option)=>/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("option", {
  1306. value: option.value,
  1307. disabled: option.disabled || false,
  1308. children: option.label
  1309. }, option.value))
  1310. ]
  1311. }),
  1312. /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
  1313. className: classnames__WEBPACK_IMPORTED_MODULE_2___default()((_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().arrow), {
  1314. [(_Select_module_scss__WEBPACK_IMPORTED_MODULE_4___default().disabledArrow)]: disabled
  1315. }),
  1316. children: /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_icons_caret_down_svg__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z, {})
  1317. })
  1318. ]
  1319. });
  1320. };
  1321. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Select);
  1322. /***/ }),
  1323. /***/ 23830:
  1324. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1325. "use strict";
  1326. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1327. /* harmony export */ "Z": () => (__WEBPACK_DEFAULT_EXPORT__)
  1328. /* harmony export */ });
  1329. /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6022);
  1330. /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_redux__WEBPACK_IMPORTED_MODULE_0__);
  1331. /* harmony import */ var _redux_slices_QuranReader_styles__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(62093);
  1332. /* harmony import */ var _utils_api__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4917);
  1333. /**
  1334. * Instead of repeating using multiple selectors to get the MushafId
  1335. * in multiple components, we are introducing this hook to keep it DRY.
  1336. *
  1337. * TODO: apply it to everywhere using the mushafId
  1338. *
  1339. * @returns {Mushaf}
  1340. */ const useGetMushaf = ()=>{
  1341. const quranFont = (0,react_redux__WEBPACK_IMPORTED_MODULE_0__.useSelector)(_redux_slices_QuranReader_styles__WEBPACK_IMPORTED_MODULE_1__/* .selectQuranFont */ .Ho, react_redux__WEBPACK_IMPORTED_MODULE_0__.shallowEqual);
  1342. const mushafLines = (0,react_redux__WEBPACK_IMPORTED_MODULE_0__.useSelector)(_redux_slices_QuranReader_styles__WEBPACK_IMPORTED_MODULE_1__/* .selectQuranMushafLines */ .z$, react_redux__WEBPACK_IMPORTED_MODULE_0__.shallowEqual);
  1343. const { mushaf } = (0,_utils_api__WEBPACK_IMPORTED_MODULE_2__/* .getMushafId */ .$P)(quranFont, mushafLines);
  1344. return mushaf;
  1345. };
  1346. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useGetMushaf);
  1347. /***/ }),
  1348. /***/ 56748:
  1349. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1350. "use strict";
  1351. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1352. /* harmony export */ "Oz": () => (/* binding */ useScrollToElement),
  1353. /* harmony export */ "ZP": () => (__WEBPACK_DEFAULT_EXPORT__),
  1354. /* harmony export */ "gZ": () => (/* binding */ SMOOTH_SCROLL_TO_TOP),
  1355. /* harmony export */ "lT": () => (/* binding */ SCROLL_TO_NEAREST_ELEMENT),
  1356. /* harmony export */ "nv": () => (/* binding */ SMOOTH_SCROLL_TO_CENTER)
  1357. /* harmony export */ });
  1358. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16689);
  1359. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  1360. /**
  1361. * A hook that scrolls to a specific element in the DOM.
  1362. * The scrolling will only happen when executeScroll function
  1363. * is invoked.
  1364. *
  1365. * @param {ScrollIntoViewOptions} options
  1366. * @returns {[() => void, RefObject<T>]}
  1367. */ const useScrollToElement = (options)=>{
  1368. const elementRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
  1369. // a function that will be invoked by the component using this hook to scroll to the element being referenced (if found).
  1370. const executeScroll = ()=>{
  1371. // only scroll when the ref has a value
  1372. if (elementRef.current) {
  1373. elementRef.current.scrollIntoView(options);
  1374. }
  1375. };
  1376. return [
  1377. executeScroll,
  1378. elementRef
  1379. ];
  1380. };
  1381. const SMOOTH_SCROLL_TO_CENTER = {
  1382. block: "center",
  1383. behavior: "smooth"
  1384. };
  1385. const SMOOTH_SCROLL_TO_TOP = {
  1386. block: "start",
  1387. behavior: "smooth"
  1388. };
  1389. const SCROLL_TO_NEAREST_ELEMENT = {
  1390. block: "nearest"
  1391. };
  1392. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (useScrollToElement);
  1393. /***/ }),
  1394. /***/ 49184:
  1395. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1396. "use strict";
  1397. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1398. /* harmony export */ "IU": () => (/* binding */ generateChapterOptions),
  1399. /* harmony export */ "Ph": () => (/* binding */ generateTimeOptions),
  1400. /* harmony export */ "ZK": () => (/* binding */ generateVerseOptions),
  1401. /* harmony export */ "zQ": () => (/* binding */ generateDurationDaysOptions)
  1402. /* harmony export */ });
  1403. /* harmony import */ var _utils_chapter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(95892);
  1404. /* harmony import */ var _utils_datetime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(76410);
  1405. /* harmony import */ var _utils_locale__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(24709);
  1406. /* eslint-disable import/prefer-default-export */
  1407. const TIME_OPTIONS_LIMIT = 4 * 60; // 4 hours
  1408. const DURATION_DAYS_LIMIT = 365; // 1 year, 365 days
  1409. /**
  1410. * Generates options for the reading goal time input.
  1411. *
  1412. * The options are within a range of 1 minute to 4 hours.
  1413. * - From 1 to 10 minutes (first 10 options), increment by 1 minute
  1414. * - From > 10 minutes to 4 hours, increment by 5 minutes
  1415. *
  1416. * @param {Translate} t
  1417. * @param {string} locale
  1418. * @returns {SelectOption[]}
  1419. */ const generateTimeOptions = (t, locale)=>{
  1420. // for the first 10 minutes, we want to show 1 until 10
  1421. // but after that, we want to increment by 5 minutes
  1422. // and our limit is TIME_OPTIONS_LIMIT
  1423. const options = new Array(10 + (TIME_OPTIONS_LIMIT - 10) / 5).fill(null)// eslint-disable-next-line @typescript-eslint/naming-convention
  1424. .map((_, i)=>{
  1425. let minutes;
  1426. if (i < 10) {
  1427. minutes = i + 1;
  1428. } else {
  1429. minutes = (i - 9) * 5 + 10;
  1430. }
  1431. const seconds = minutes * 60;
  1432. return {
  1433. value: seconds,
  1434. label: (0,_utils_datetime__WEBPACK_IMPORTED_MODULE_1__/* .secondsToReadableFormat */ .by)(seconds, t, locale)
  1435. };
  1436. });
  1437. return options;
  1438. };
  1439. /**
  1440. * Generates options for the reading goal chapter input.
  1441. *
  1442. * @param {ChaptersData} chaptersData
  1443. * @param {string} locale
  1444. * @returns {DropdownItem[]}
  1445. */ const generateChapterOptions = (chaptersData, locale)=>{
  1446. const data = Object.keys(chaptersData).map((chapterId)=>{
  1447. const chapter = (0,_utils_chapter__WEBPACK_IMPORTED_MODULE_0__/* .getChapterData */ .dy)(chaptersData, chapterId);
  1448. const localizedChapterId = (0,_utils_locale__WEBPACK_IMPORTED_MODULE_2__/* .toLocalizedNumber */ .rQ)(Number(chapterId), locale);
  1449. return {
  1450. id: chapterId,
  1451. name: chapterId,
  1452. value: chapterId,
  1453. label: `${localizedChapterId} - ${chapter.transliteratedName}`
  1454. };
  1455. });
  1456. return data;
  1457. };
  1458. /**
  1459. * Generates verse options for a certain chapter in the reading goal verse input.
  1460. *
  1461. * @param {ChaptersData} chaptersData
  1462. * @param {Translate} t
  1463. * @param {string} locale
  1464. * @param {string?} chapterId
  1465. * @returns {DropdownItem[]}
  1466. */ const generateVerseOptions = (chaptersData, t, locale, chapterId)=>{
  1467. if (!chapterId) return [];
  1468. const chapter = (0,_utils_chapter__WEBPACK_IMPORTED_MODULE_0__/* .getChapterData */ .dy)(chaptersData, chapterId);
  1469. // eslint-disable-next-line @typescript-eslint/naming-convention
  1470. const options = new Array(chapter.versesCount).fill(null).map((_, index)=>{
  1471. const localizedVerseId = (0,_utils_locale__WEBPACK_IMPORTED_MODULE_2__/* .toLocalizedNumber */ .rQ)(index + 1, locale);
  1472. const verseId = String(index + 1);
  1473. return {
  1474. id: verseId,
  1475. name: verseId,
  1476. value: verseId,
  1477. label: `${t("common:ayah")} ${localizedVerseId}`
  1478. };
  1479. });
  1480. return options;
  1481. };
  1482. /**
  1483. * Generates options for the reading goal duration input.
  1484. *
  1485. * The options are within a range of 1 day to 365 days in this format:
  1486. * "1 day", "2 days", "3 days", etc...
  1487. *
  1488. * @param {Translate} t
  1489. * @param {string} locale
  1490. * @returns {SelectOption[]}
  1491. */ const generateDurationDaysOptions = (t, locale)=>{
  1492. // for the first 10 days, we want to show 1 until 10
  1493. // but after that, we want to increment by 5 days
  1494. // and our limit is DURATION_DAYS_LIMIT
  1495. const options = new Array(10 + (DURATION_DAYS_LIMIT - 10) / 5).fill(null)// eslint-disable-next-line @typescript-eslint/naming-convention
  1496. .map((_, i)=>{
  1497. let day;
  1498. if (i < 10) {
  1499. day = i + 1;
  1500. } else {
  1501. day = (i - 9) * 5 + 10;
  1502. }
  1503. return {
  1504. value: day.toString(),
  1505. label: t("reading-goal:x-days", {
  1506. count: day,
  1507. days: (0,_utils_locale__WEBPACK_IMPORTED_MODULE_2__/* .toLocalizedNumber */ .rQ)(day, locale)
  1508. })
  1509. };
  1510. });
  1511. return options;
  1512. };
  1513. /***/ })
  1514. };
  1515. ;
  1516. //# sourceMappingURL=73273.js.map