@roomstay/frontend 2.2.4 → 2.3.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/115.bundle.js +1 -0
  2. package/dist/213.bundle.js +1 -1
  3. package/dist/370.bundle.js +1 -1
  4. package/dist/387.bundle.js +1 -0
  5. package/dist/446.bundle.js +1 -0
  6. package/dist/449.bundle.js +1 -1
  7. package/dist/572.bundle.js +1 -0
  8. package/dist/619.bundle.js +1 -0
  9. package/dist/903.bundle.js +1 -0
  10. package/dist/975.bundle.js +1 -0
  11. package/dist/main.bundle.js +1 -1
  12. package/dist/src/components/generic/Tabs/TabContext.js.map +1 -1
  13. package/dist/src/components/generic/Tabs/TabLink.js +10 -7
  14. package/dist/src/components/generic/Tabs/TabLink.js.map +1 -1
  15. package/dist/src/components/generic/Tabs/TabRouteContainer.js +3 -1
  16. package/dist/src/components/generic/Tabs/TabRouteContainer.js.map +1 -1
  17. package/dist/src/components/generic/Tabs/Tabs.d.ts +1 -0
  18. package/dist/src/components/generic/Tabs/Tabs.js +2 -11
  19. package/dist/src/components/generic/Tabs/Tabs.js.map +1 -1
  20. package/dist/src/components/generic/Tooltip/Tooltip.d.ts +2 -0
  21. package/dist/src/components/generic/Tooltip/Tooltip.js +2 -2
  22. package/dist/src/components/generic/Tooltip/Tooltip.js.map +1 -1
  23. package/dist/src/components/steps/room/RoomList.js +2 -119
  24. package/dist/src/components/steps/room/RoomList.js.map +1 -1
  25. package/dist/src/components/steps/room/TabGroupedRooms/TabGroupedRoomList.d.ts +8 -0
  26. package/dist/src/components/steps/room/TabGroupedRooms/TabGroupedRoomList.js +97 -0
  27. package/dist/src/components/steps/room/TabGroupedRooms/TabGroupedRoomList.js.map +1 -0
  28. package/dist/src/components/steps/room/TabGroupedRooms/TabGroupedRooms.d.ts +1 -0
  29. package/dist/src/components/steps/room/TabGroupedRooms/TabGroupedRooms.js +107 -0
  30. package/dist/src/components/steps/room/TabGroupedRooms/TabGroupedRooms.js.map +1 -0
  31. package/dist/src/components/steps/room/TripteaseLodgingSearchSchema.d.ts +1 -0
  32. package/dist/src/components/steps/room/TripteaseLodgingSearchSchema.js +43 -0
  33. package/dist/src/components/steps/room/TripteaseLodgingSearchSchema.js.map +1 -0
  34. package/dist/src/components/steps/room/UserSearchSummary/UserSearchSummary.d.ts +1 -0
  35. package/dist/src/components/steps/room/UserSearchSummary/UserSearchSummary.js +56 -0
  36. package/dist/src/components/steps/room/UserSearchSummary/UserSearchSummary.js.map +1 -0
  37. package/dist/src/components/steps/room/UserSearchSummary/UserSearchSummaryPromocodeInput.d.ts +8 -0
  38. package/dist/src/components/steps/room/UserSearchSummary/UserSearchSummaryPromocodeInput.js +90 -0
  39. package/dist/src/components/steps/room/UserSearchSummary/UserSearchSummaryPromocodeInput.js.map +1 -0
  40. package/dist/src/components/steps/room/UserSearchSummary/UserSearchSummaryRow.d.ts +7 -0
  41. package/dist/src/components/steps/room/UserSearchSummary/UserSearchSummaryRow.js +172 -0
  42. package/dist/src/components/steps/room/UserSearchSummary/UserSearchSummaryRow.js.map +1 -0
  43. package/dist/src/components/steps/room/roomBuilderProgress/RoomBuilderProgress.js +2 -10
  44. package/dist/src/components/steps/room/roomBuilderProgress/RoomBuilderProgress.js.map +1 -1
  45. package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js +1 -0
  46. package/dist/src/contexts/CompanyContext/CompanyContextWrapper.js.map +1 -1
  47. package/dist/src/contexts/FullPageEngineContext/FullPageEngineContextWrapper.js +2 -1
  48. package/dist/src/contexts/FullPageEngineContext/FullPageEngineContextWrapper.js.map +1 -1
  49. package/dist/src/hooks/RoomRateAvailabilityListFromApi.d.ts +8 -0
  50. package/dist/src/hooks/RoomRateAvailabilityListFromApi.js +133 -0
  51. package/dist/src/hooks/RoomRateAvailabilityListFromApi.js.map +1 -0
  52. package/dist/src/models/Api/HotelDTO.d.ts +14 -0
  53. package/dist/src/models/Api/HotelDTO.js.map +1 -1
  54. package/dist/src/models/Client/Hotel/Hotel.d.ts +2 -1
  55. package/dist/src/models/Client/Hotel/Hotel.js.map +1 -1
  56. package/dist/src/models/Room/Room.d.ts +8 -0
  57. package/dist/src/models/Room/Room.js +6 -0
  58. package/dist/src/models/Room/Room.js.map +1 -1
  59. package/dist/src/pages/hotel/HotelInfo.js +4 -4
  60. package/dist/src/pages/hotel/HotelInfo.js.map +1 -1
  61. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoom.d.ts +15 -0
  62. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoom.js +30 -0
  63. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoom.js.map +1 -0
  64. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoomComponent.d.ts +2 -0
  65. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoomComponent.js +69 -0
  66. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoomComponent.js.map +1 -0
  67. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoomLoader.d.ts +1 -0
  68. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoomLoader.js +109 -0
  69. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoomLoader.js.map +1 -0
  70. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoomValidator.d.ts +3 -0
  71. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoomValidator.js +10 -0
  72. package/dist/src/pages/steps/StepGroupedRoom/StepGroupedRoomValidator.js.map +1 -0
  73. package/dist/src/translations/Translation.d.ts +0 -4
  74. package/dist/src/translations/Translation.js +0 -4
  75. package/dist/src/translations/Translation.js.map +1 -1
  76. package/dist/src/translations/languages/en-gb.js +0 -4
  77. package/dist/src/translations/languages/en-gb.js.map +1 -1
  78. package/dist/src/util/DataLayer.js +1 -1
  79. package/dist/src/util/DataLayer.js.map +1 -1
  80. package/dist/test.bundle.js +1 -1
  81. package/dist/tests/offline/entry/RSCompany.js +5 -0
  82. package/dist/tests/offline/entry/RSCompany.js.map +1 -1
  83. package/package.json +2 -2
  84. package/dist/548.bundle.js +0 -1
  85. package/dist/882.bundle.js +0 -1
  86. package/dist/93.bundle.js +0 -1
  87. package/dist/src/components/generic/Select.d.ts +0 -0
  88. package/dist/src/components/generic/Select.js +0 -2
  89. package/dist/src/components/generic/Select.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TabContext.js","sourceRoot":"/","sources":["src/components/generic/Tabs/TabContext.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iCAA4C;AAU5C,MAAM,UAAU,GAAG,eAAK,CAAC,aAAa,CAAkB;IACpD,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,CAAC;IACZ,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,GAAG,EAAE;QACX,EAAE;IACN,CAAC;CACJ,CAAC,CAAC;AAmCoB,6BAAO;AA3B9B,MAAM,kBAAkB,GAAsC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,EAAE;IACvG,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAS,CAAC,CAAC,CAAC;IACtD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAS,CAAC,CAAC,CAAC;IAE5D,MAAM,SAAS,GAAG;QACd,SAAS;QACT,SAAS;QACT,YAAY;QACZ,QAAQ,EAAE,CAAC,MAAc,EAAE,KAAa,EAAE,EAAE;YACxC,+CAA+C;YAC/C,uGAAuG;YACvG,kCAAkC;YAClC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,MAAM,CAAC,CAAC;YACnB,YAAY,CAAC,YAAY,CAAC,CAAC;YAC3B,eAAe,CAAC,KAAK,CAAC,CAAC;YACvB,YAAY,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;KACJ,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACnC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,8BAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS,IAAG,QAAQ,CAAuB,CAAC;AACnF,CAAC,CAAC;AAE8B,gDAAkB","sourcesContent":["import React from 'react';\nimport { useEffect, useState } from 'react';\nimport { EventKey } from '@/components/generic/Tabs/Tabs';\n\ninterface TabContextProps {\n activeKey: string;\n lastIndex: number;\n currentIndex: number;\n onChange: (newKey: string, index: number) => void;\n}\n\nconst TabContext = React.createContext<TabContextProps>({\n activeKey: '',\n lastIndex: 0,\n currentIndex: 0,\n onChange: () => {\n //\n },\n});\n\ninterface TabContextProviderProps {\n children: any;\n defaultActiveKey: string;\n onChange?: (key: string) => void;\n}\n\nconst TabContextProvider: React.FC<TabContextProviderProps> = ({ children, defaultActiveKey, onChange }) => {\n const [activeKey, setActiveKey] = useState<string>('');\n const [lastIndex, setLastIndex] = useState<number>(0);\n const [currentIndex, setCurrentIndex] = useState<number>(0);\n\n const tabValues = {\n activeKey,\n lastIndex,\n currentIndex,\n onChange: (newKey: string, index: number) => {\n // TODO: Add checks for Tab state being \"Dirty\"\n // This means if you're in the middle of editing a form, and you press back / forward, we don't want to\n // yank the user out of their flow\n onChange?.(newKey);\n setLastIndex(currentIndex);\n setCurrentIndex(index);\n setActiveKey(newKey);\n },\n };\n\n useEffect(() => {\n setActiveKey(defaultActiveKey);\n }, []);\n\n return <TabContext.Provider value={tabValues}>{children}</TabContext.Provider>;\n};\n\nexport { TabContext as default, TabContextProvider };\n"]}
1
+ {"version":3,"file":"TabContext.js","sourceRoot":"/","sources":["src/components/generic/Tabs/TabContext.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iCAA4C;AAS5C,MAAM,UAAU,GAAG,eAAK,CAAC,aAAa,CAAkB;IACpD,SAAS,EAAE,EAAE;IACb,SAAS,EAAE,CAAC;IACZ,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,GAAG,EAAE;QACX,EAAE;IACN,CAAC;CACJ,CAAC,CAAC;AAmCoB,6BAAO;AA3B9B,MAAM,kBAAkB,GAAsC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE,EAAE;IACvG,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAS,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAS,CAAC,CAAC,CAAC;IACtD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAS,CAAC,CAAC,CAAC;IAE5D,MAAM,SAAS,GAAG;QACd,SAAS;QACT,SAAS;QACT,YAAY;QACZ,QAAQ,EAAE,CAAC,MAAc,EAAE,KAAa,EAAE,EAAE;YACxC,+CAA+C;YAC/C,uGAAuG;YACvG,kCAAkC;YAClC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,MAAM,CAAC,CAAC;YACnB,YAAY,CAAC,YAAY,CAAC,CAAC;YAC3B,eAAe,CAAC,KAAK,CAAC,CAAC;YACvB,YAAY,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;KACJ,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,YAAY,CAAC,gBAAgB,CAAC,CAAC;IACnC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,8BAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS,IAAG,QAAQ,CAAuB,CAAC;AACnF,CAAC,CAAC;AAE8B,gDAAkB","sourcesContent":["import React from 'react';\nimport { useEffect, useState } from 'react';\n\ninterface TabContextProps {\n activeKey: string;\n lastIndex: number;\n currentIndex: number;\n onChange: (newKey: string, index: number) => void;\n}\n\nconst TabContext = React.createContext<TabContextProps>({\n activeKey: '',\n lastIndex: 0,\n currentIndex: 0,\n onChange: () => {\n //\n },\n});\n\ninterface TabContextProviderProps {\n children: any;\n defaultActiveKey: string;\n onChange?: (key: string) => void;\n}\n\nconst TabContextProvider: React.FC<TabContextProviderProps> = ({ children, defaultActiveKey, onChange }) => {\n const [activeKey, setActiveKey] = useState<string>('');\n const [lastIndex, setLastIndex] = useState<number>(0);\n const [currentIndex, setCurrentIndex] = useState<number>(0);\n\n const tabValues = {\n activeKey,\n lastIndex,\n currentIndex,\n onChange: (newKey: string, index: number) => {\n // TODO: Add checks for Tab state being \"Dirty\"\n // This means if you're in the middle of editing a form, and you press back / forward, we don't want to\n // yank the user out of their flow\n onChange?.(newKey);\n setLastIndex(currentIndex);\n setCurrentIndex(index);\n setActiveKey(newKey);\n },\n };\n\n useEffect(() => {\n setActiveKey(defaultActiveKey);\n }, []);\n\n return <TabContext.Provider value={tabValues}>{children}</TabContext.Provider>;\n};\n\nexport { TabContext as default, TabContextProvider };\n"]}
@@ -33,21 +33,24 @@ const TabContext_1 = __importDefault(require("./TabContext"));
33
33
  const react_router_dom_1 = require("react-router-dom");
34
34
  const Text_1 = __importDefault(require("../Text"));
35
35
  const Color_1 = require("../../../util/Color");
36
+ const HistoryConsistentPush_1 = require("../../../hooks/HistoryConsistentPush");
36
37
  const TabLink = (props) => {
37
38
  const tabContext = (0, react_1.useContext)(TabContext_1.default);
38
- const history = (0, react_router_dom_1.useHistory)();
39
+ const { location } = (0, react_router_dom_1.useHistory)();
40
+ const historyConsistentPush = (0, HistoryConsistentPush_1.useHistoryConsistentPush)();
39
41
  const { title, navPath, disabled, index } = props;
40
42
  if (!title) {
41
43
  return null;
42
44
  }
45
+ const stateConsistentPath = Object.assign(Object.assign({}, location), { pathname: navPath });
43
46
  return (react_1.default.createElement("li", null,
44
- react_1.default.createElement(react_router_dom_1.NavLink, { to: navPath, activeClassName: "active", className: (0, classnames_1.default)('c-nav-item ', { disabled }), onClick: (e) => {
45
- if (disabled) {
46
- e.preventDefault();
47
- }
48
- else {
47
+ react_1.default.createElement(react_router_dom_1.NavLink, { to: stateConsistentPath, isActive: (match, location) => {
48
+ return !disabled && location.pathname.endsWith(navPath);
49
+ }, activeClassName: "active", className: (0, classnames_1.default)('c-nav-item ', { disabled }), onClick: (e) => {
50
+ e.preventDefault();
51
+ if (!disabled) {
49
52
  // Sometimes "to" property does not trigger, we need to call push action
50
- history.push(navPath);
53
+ historyConsistentPush(navPath);
51
54
  tabContext.onChange(navPath, index);
52
55
  }
53
56
  } },
@@ -1 +1 @@
1
- {"version":3,"file":"TabLink.js","sourceRoot":"/","sources":["src/components/generic/Tabs/TabLink.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAC1C,4DAA4B;AAC5B,sFAA8D;AAC9D,uDAAuD;AACvD,qEAA6C;AAC7C,wCAAqC;AAE9B,MAAM,OAAO,GAAG,CAAC,KAAU,EAAE,EAAE;IAClC,MAAM,UAAU,GAAG,IAAA,kBAAU,EAAC,oBAAU,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,IAAA,6BAAU,GAAE,CAAC;IAE7B,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAElD,IAAI,CAAC,KAAK,EAAE;QACR,OAAO,IAAI,CAAC;KACf;IAED,OAAO,CACH;QACI,8BAAC,0BAAO,IACJ,EAAE,EAAE,OAAO,EACX,eAAe,EAAC,QAAQ,EACxB,SAAS,EAAE,IAAA,oBAAE,EAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,CAAC,EAC1C,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;gBACX,IAAI,QAAQ,EAAE;oBACV,CAAC,CAAC,cAAc,EAAE,CAAC;iBACtB;qBAAM;oBACH,wEAAwE;oBACxE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;oBACtB,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;iBACvC;YACL,CAAC;YAED,wCAAM,SAAS,EAAE,IAAA,oBAAE,EAAC,YAAY,CAAC;gBAC7B,8BAAC,cAAI,IAAC,KAAK,EAAE,aAAK,CAAC,QAAQ,EAAE,IAAI,UAC5B,KAAK,CACH,CACJ,CACD,CACT,CACR,CAAC;AACN,CAAC,CAAC;AAlCW,QAAA,OAAO,WAkClB","sourcesContent":["import React, { useContext } from 'react';\nimport cx from 'classnames';\nimport TabContext from '@/components/generic/Tabs/TabContext';\nimport { NavLink, useHistory } from 'react-router-dom';\nimport Text from '@/components/generic/Text';\nimport { Color } from '@/util/Color';\n\nexport const TabLink = (props: any) => {\n const tabContext = useContext(TabContext);\n const history = useHistory();\n\n const { title, navPath, disabled, index } = props;\n\n if (!title) {\n return null;\n }\n\n return (\n <li>\n <NavLink\n to={navPath}\n activeClassName=\"active\"\n className={cx('c-nav-item ', { disabled })}\n onClick={(e) => {\n if (disabled) {\n e.preventDefault();\n } else {\n // Sometimes \"to\" property does not trigger, we need to call push action\n history.push(navPath);\n tabContext.onChange(navPath, index);\n }\n }}\n >\n <span className={cx('c-nav-link')}>\n <Text color={Color.DarkGrey} bold>\n {title}\n </Text>\n </span>\n </NavLink>\n </li>\n );\n};\n"]}
1
+ {"version":3,"file":"TabLink.js","sourceRoot":"/","sources":["src/components/generic/Tabs/TabLink.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAC1C,4DAA4B;AAC5B,sFAA8D;AAC9D,uDAAuD;AACvD,qEAA6C;AAC7C,wCAAqC;AACrC,yEAAyE;AAElE,MAAM,OAAO,GAAG,CAAC,KAAU,EAAE,EAAE;IAClC,MAAM,UAAU,GAAG,IAAA,kBAAU,EAAC,oBAAU,CAAC,CAAC;IAC1C,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,6BAAU,GAAE,CAAC;IAElC,MAAM,qBAAqB,GAAG,IAAA,gDAAwB,GAAE,CAAC;IAEzD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAElD,IAAI,CAAC,KAAK,EAAE;QACR,OAAO,IAAI,CAAC;KACf;IAED,MAAM,mBAAmB,mCAClB,QAAQ,KACX,QAAQ,EAAE,OAAO,GACpB,CAAC;IAEF,OAAO,CACH;QACI,8BAAC,0BAAO,IACJ,EAAE,EAAE,mBAAmB,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1B,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC5D,CAAC,EACD,eAAe,EAAC,QAAQ,EACxB,SAAS,EAAE,IAAA,oBAAE,EAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,CAAC,EAC1C,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;gBACX,CAAC,CAAC,cAAc,EAAE,CAAC;gBAEnB,IAAI,CAAC,QAAQ,EAAE;oBACX,wEAAwE;oBACxE,qBAAqB,CAAC,OAAO,CAAC,CAAC;oBAC/B,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;iBACvC;YACL,CAAC;YAED,wCAAM,SAAS,EAAE,IAAA,oBAAE,EAAC,YAAY,CAAC;gBAC7B,8BAAC,cAAI,IAAC,KAAK,EAAE,aAAK,CAAC,QAAQ,EAAE,IAAI,UAC5B,KAAK,CACH,CACJ,CACD,CACT,CACR,CAAC;AACN,CAAC,CAAC;AA5CW,QAAA,OAAO,WA4ClB","sourcesContent":["import React, { useContext } from 'react';\nimport cx from 'classnames';\nimport TabContext from '@/components/generic/Tabs/TabContext';\nimport { NavLink, useHistory } from 'react-router-dom';\nimport Text from '@/components/generic/Text';\nimport { Color } from '@/util/Color';\nimport { useHistoryConsistentPush } from '@/hooks/HistoryConsistentPush';\n\nexport const TabLink = (props: any) => {\n const tabContext = useContext(TabContext);\n const { location } = useHistory();\n\n const historyConsistentPush = useHistoryConsistentPush();\n\n const { title, navPath, disabled, index } = props;\n\n if (!title) {\n return null;\n }\n\n const stateConsistentPath = {\n ...location,\n pathname: navPath,\n };\n\n return (\n <li>\n <NavLink\n to={stateConsistentPath}\n isActive={(match, location) => {\n return !disabled && location.pathname.endsWith(navPath);\n }}\n activeClassName=\"active\"\n className={cx('c-nav-item ', { disabled })}\n onClick={(e) => {\n e.preventDefault();\n\n if (!disabled) {\n // Sometimes \"to\" property does not trigger, we need to call push action\n historyConsistentPush(navPath);\n tabContext.onChange(navPath, index);\n }\n }}\n >\n <span className={cx('c-nav-link')}>\n <Text color={Color.DarkGrey} bold>\n {title}\n </Text>\n </span>\n </NavLink>\n </li>\n );\n};\n"]}
@@ -12,6 +12,7 @@ const ElementChildren_1 = require("./ElementChildren");
12
12
  const TabContext_1 = __importDefault(require("./TabContext"));
13
13
  function TabRouteContainer({ children }) {
14
14
  const tabContext = (0, react_2.useContext)(TabContext_1.default);
15
+ const { location } = (0, react_router_1.useHistory)();
15
16
  const transitions = (0, web_1.useTransition)(tabContext.activeKey, {
16
17
  from: { opacity: 0, position: 'absolute' },
17
18
  to: { opacity: 1, position: 'relative' },
@@ -21,12 +22,13 @@ function TabRouteContainer({ children }) {
21
22
  friction: 25,
22
23
  },
23
24
  });
25
+ const firstTabRoute = Object.assign(Object.assign({}, location), { pathname: children[0].props.navPath });
24
26
  return (react_1.default.createElement("div", { className: "u-pos-rel" }, transitions((props) => {
25
27
  return (react_1.default.createElement(web_1.animated.div, { style: Object.assign({ left: 0, right: 0 }, props) },
26
28
  react_1.default.createElement(react_router_1.Switch, null,
27
29
  (0, ElementChildren_1.reactMap)(children, (child) => (react_1.default.createElement(react_router_1.Route, { path: child.props.navPath }, child.props.children))),
28
30
  react_1.default.createElement(react_router_1.Route, { path: "*" },
29
- react_1.default.createElement(react_router_1.Redirect, { to: children[0].props.navPath, push: false })))));
31
+ react_1.default.createElement(react_router_1.Redirect, { to: firstTabRoute, push: false })))));
30
32
  })));
31
33
  }
32
34
  exports.TabRouteContainer = TabRouteContainer;
@@ -1 +1 @@
1
- {"version":3,"file":"TabRouteContainer.js","sourceRoot":"/","sources":["src/components/generic/Tabs/TabRouteContainer.tsx"],"names":[],"mappings":";;;;;;AAAA,2CAA4D;AAC5D,kDAA0B;AAC1B,iCAA8C;AAC9C,+CAAuD;AACvD,+EAAqE;AACrE,sFAA8D;AAM9D,SAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAA0B;IAClE,MAAM,UAAU,GAAG,IAAA,kBAAU,EAAC,oBAAU,CAAC,CAAC;IAE1C,MAAM,WAAW,GAAG,IAAA,mBAAa,EAAC,UAAU,CAAC,SAAS,EAAE;QACpD,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE;QAC1C,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE;QACxC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE;QAC3C,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE;QAC3C,MAAM,EAAE;YACJ,QAAQ,EAAE,EAAE;SACf;KACJ,CAAC,CAAC;IAEH,OAAO,CACH,uCAAK,SAAS,EAAC,WAAW,IACrB,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;QACnB,OAAO,CACH,8BAAC,cAAQ,CAAC,GAAG,IAAC,KAAK,kBAAI,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,IAAM,KAAa;YACvD,8BAAC,qBAAM;gBACF,IAAA,0BAAQ,EAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAC3B,8BAAC,oBAAK,IAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,IAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAS,CACnE,CAAC;gBAEF,8BAAC,oBAAK,IAAC,IAAI,EAAC,GAAG;oBACX,8BAAC,uBAAQ,IAAC,EAAE,EAAG,QAAgB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,GAAI,CAC7D,CACH,CACE,CAClB,CAAC;IACN,CAAC,CAAC,CACA,CACT,CAAC;AACN,CAAC;AAhCD,8CAgCC","sourcesContent":["import { animated, useTransition } from '@react-spring/web';\nimport React from 'react';\nimport { ReactNode, useContext } from 'react';\nimport { Switch, Route, Redirect } from 'react-router';\nimport { reactMap } from '@/components/generic/Tabs/ElementChildren';\nimport TabContext from '@/components/generic/Tabs/TabContext';\n\ninterface TabRouteContainerProps {\n children: ReactNode[];\n}\n\nexport function TabRouteContainer({ children }: TabRouteContainerProps) {\n const tabContext = useContext(TabContext);\n\n const transitions = useTransition(tabContext.activeKey, {\n from: { opacity: 0, position: 'absolute' },\n to: { opacity: 1, position: 'relative' },\n enter: { opacity: 1, position: 'relative' },\n leave: { opacity: 0, position: 'absolute' },\n config: {\n friction: 25,\n },\n });\n\n return (\n <div className=\"u-pos-rel\">\n {transitions((props) => {\n return (\n <animated.div style={{ left: 0, right: 0, ...(props as any) }}>\n <Switch>\n {reactMap(children, (child) => (\n <Route path={child.props.navPath}>{child.props.children}</Route>\n ))}\n {/* Adding a redirect if no route is matched */}\n <Route path=\"*\">\n <Redirect to={(children as any)[0].props.navPath} push={false} />\n </Route>\n </Switch>\n </animated.div>\n );\n })}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"TabRouteContainer.js","sourceRoot":"/","sources":["src/components/generic/Tabs/TabRouteContainer.tsx"],"names":[],"mappings":";;;;;;AAAA,2CAA4D;AAC5D,kDAA0B;AAC1B,iCAA8C;AAC9C,+CAAmE;AACnE,+EAAqE;AACrE,sFAA8D;AAM9D,SAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAA0B;IAClE,MAA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AAC,CAAC,CACA,CACT,CAAC;AACN,CAAC;AAtCD,8CAsCC","sourcesContent":["import { animated, useTransition } from '@react-spring/web';\nimport React from 'react';\nimport { ReactNode, useContext } from 'react';\nimport { Switch, Route, Redirect, useHistory } from 'react-router';\nimport { reactMap } from '@/components/generic/Tabs/ElementChildren';\nimport TabContext from '@/components/generic/Tabs/TabContext';\n\ninterface TabRouteContainerProps {\n children: ReactNode[];\n}\n\nexport function TabRouteContainer({ children }: TabRouteContainerProps) {\n const tabContext = useContext(TabContext);\n const { location } = useHistory();\n\n const transitions = useTransition(tabContext.activeKey, {\n from: { opacity: 0, position: 'absolute' },\n to: { opacity: 1, position: 'relative' },\n enter: { opacity: 1, position: 'relative' },\n leave: { opacity: 0, position: 'absolute' },\n config: {\n friction: 25,\n },\n });\n\n const firstTabRoute = {\n ...location,\n pathname: (children as any)[0].props.navPath,\n };\n\n return (\n <div className=\"u-pos-rel\">\n {transitions((props) => {\n return (\n <animated.div style={{ left: 0, right: 0, ...(props as any) }}>\n <Switch>\n {reactMap(children, (child) => (\n <Route path={child.props.navPath}>{child.props.children}</Route>\n ))}\n {/* Adding a redirect if no route is matched */}\n <Route path=\"*\">\n <Redirect to={firstTabRoute} push={false} />\n </Route>\n </Switch>\n </animated.div>\n );\n })}\n </div>\n );\n}\n"]}
@@ -7,6 +7,7 @@ export interface TabsProps {
7
7
  defaultActiveKey?: EventKey;
8
8
  onSelect?: (key: string) => void;
9
9
  children: ReactNode[];
10
+ fullBleedOnLineBreak?: boolean;
10
11
  }
11
12
  declare const Tabs: React.FC<TabsProps>;
12
13
  export default Tabs;
@@ -12,15 +12,6 @@ const TabContext_1 = require("./TabContext");
12
12
  const TabLink_1 = require("./TabLink");
13
13
  const TabRouteContainer_1 = require("./TabRouteContainer");
14
14
  const tabs_module_scss_1 = __importDefault(require("./tabs.module.scss"));
15
- const getDefaultActiveKey = (children) => {
16
- let defaultActiveKey = undefined;
17
- (0, ElementChildren_1.reactForEach)(children, (child) => {
18
- if (!defaultActiveKey) {
19
- defaultActiveKey = child.props.eventKey;
20
- }
21
- });
22
- return defaultActiveKey;
23
- };
24
15
  const options = {
25
16
  slidesPerView: 'auto',
26
17
  allowTouchMove: true,
@@ -28,14 +19,14 @@ const options = {
28
19
  noSwiping: false,
29
20
  };
30
21
  const Tabs = (props) => {
31
- const { onSelect, children, variant = 'tabs', activeKey = getDefaultActiveKey(children), } = (0, uncontrollable_1.useUncontrolled)(props, {
22
+ const { onSelect, children, variant = 'tabs', activeKey = null, fullBleedOnLineBreak = true, } = (0, uncontrollable_1.useUncontrolled)(props, {
32
23
  activeKey: 'onSelect',
33
24
  });
34
25
  return (react_1.default.createElement(TabContext_1.TabContextProvider, { defaultActiveKey: activeKey || '', onChange: onSelect },
35
26
  react_1.default.createElement("ul", { className: `c-nav c-nav-${variant} ${tabs_module_scss_1.default.tabCarousel}` },
36
27
  react_1.default.createElement(react_2.Swiper, Object.assign({}, options), (0, ElementChildren_1.reactMap)(children, (child, index) => (react_1.default.createElement(react_2.SwiperSlide, { key: index },
37
28
  react_1.default.createElement(TabLink_1.TabLink, Object.assign({ index: index }, child.props), child)))))),
38
- react_1.default.createElement(LineBreak_1.default, { noMargins: true, fullBleed: true }),
29
+ react_1.default.createElement(LineBreak_1.default, { noMargins: true, fullBleed: fullBleedOnLineBreak }),
39
30
  react_1.default.createElement(TabRouteContainer_1.TabRouteContainer, null, props.children)));
40
31
  };
41
32
  exports.default = Tabs;
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","sourceRoot":"/","sources":["src/components/generic/Tabs/Tabs.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,mDAAiD;AAEjD,wCAAmD;AACnD,+EAAuD;AACvD,+EAAmF;AAEnF,qEAA0E;AAC1E,+DAA4D;AAC5D,mFAAgF;AAEhF,0EAAwC;AAYxC,MAAM,mBAAmB,GAAG,CAAC,QAAa,EAAsB,EAAE;IAC9D,IAAI,gBAAgB,GAAuB,SAAS,CAAC;IAC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Node } from 'react';\nimport { useUncontrolled } from 'uncontrollable';\nimport { SwiperOptions } from 'swiper';\nimport { Swiper, SwiperSlide } from 'swiper/react';\nimport LineBreak from '@/components/generic/LineBreak';\nimport { reactForEach, reactMap } from '@/components/generic/Tabs/ElementChildren';\n\nimport { TabContextProvider } from '@/components/generic/Tabs/TabContext';\nimport { TabLink } from '@/components/generic/Tabs/TabLink';\nimport { TabRouteContainer } from '@/components/generic/Tabs/TabRouteContainer';\n\nimport styles from './tabs.module.scss';\n\nexport type EventKey = string | number;\n\nexport interface TabsProps {\n variant?: 'tabs' | 'pills';\n activeKey?: string;\n defaultActiveKey?: EventKey;\n onSelect?: (key: string) => void;\n children: ReactNode[];\n}\n\nconst getDefaultActiveKey = (children: any): string | undefined => {\n let defaultActiveKey: string | undefined = undefined;\n reactForEach(children, (child) => {\n if (!defaultActiveKey) {\n defaultActiveKey = child.props.eventKey;\n }\n });\n\n return defaultActiveKey;\n};\n\nconst options: SwiperOptions = {\n slidesPerView: 'auto',\n allowTouchMove: true,\n spaceBetween: 32,\n noSwiping: false,\n};\n\nconst Tabs: React.FC<TabsProps> = (props) => {\n const {\n onSelect,\n children,\n variant = 'tabs',\n activeKey = getDefaultActiveKey(children),\n } = useUncontrolled(props, {\n activeKey: 'onSelect',\n });\n\n return (\n <TabContextProvider defaultActiveKey={activeKey || ''} onChange={onSelect}>\n <ul className={`c-nav c-nav-${variant} ${styles.tabCarousel}`}>\n <Swiper {...options}>\n {reactMap(children, (child, index) => (\n <SwiperSlide key={index}>\n <TabLink index={index} {...child.props}>\n {child}\n </TabLink>\n </SwiperSlide>\n ))}\n </Swiper>\n </ul>\n <LineBreak noMargins fullBleed />\n <TabRouteContainer>{props.children}</TabRouteContainer>\n </TabContextProvider>\n );\n};\n\nexport default Tabs;\n"]}
1
+ {"version":3,"file":"Tabs.js","sourceRoot":"/","sources":["src/components/generic/Tabs/Tabs.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,mDAAiD;AAEjD,wCAAmD;AACnD,+EAAuD;AACvD,+EAAqE;AAErE,qEAA0E;AAC1E,+DAA4D;AAC5D,mFAAgF;AAEhF,0EAAwC;AAaxC,MAAM,OAAO,GAAkB;IAC3B,aAAa,EAAE,MAAM;IACrB,cAAc,EAAE,IAAI;IACpB,YAAY,EAAE,EAAE;IAChB,SAAS,EAAE,KAAK;CACnB,CAAC;AAEF,MAAM,IAAI,GAAwB,CAAC,KAAK,EAAE,EAAE;IACxC,MAAM,EACF,QAAQ,EACR,QAAQ,EACR,OAAO,GAAG,MAAM,EAChB,SAAS,GAAG,IAAI,EAChB,oBAAoB,GAAG,IAAI,GAC9B,GAAG,IAAA,gCAAe,EAAC,KAAK,EAAE;QACvB,SAAS,EAAE,UAAU;KACxB,CAAC,CAAC;IAEH,OAAO,CACH,8BAAC,+BAAkB,IAAC,gBAAgB,EAAE,SAAS,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ;QACrE,sCAAI,SAAS,EAAE,eAAe,OAAO,IAAI,0BAAM,CAAC,WAAW,EAAE;YACzD,8BAAC,cAAM,oBAAK,OAAO,GACd,IAAA,0BAAQ,EAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAClC,8BAAC,mBAAW,IAAC,GAAG,EAAE,KAAK;gBACnB,8BAAC,iBAAO,kBAAC,KAAK,EAAE,KAAK,IAAM,KAAK,CAAC,KAAK,GACjC,KAAK,CACA,CACA,CACjB,CAAC,CACG,CACR;QACL,8BAAC,mBAAS,IAAC,SAAS,QAAC,SAAS,EAAE,oBAAoB,GAAI;QACxD,8BAAC,qCAAiB,QAAE,KAAK,CAAC,QAAQ,CAAqB,CACtC,CACxB,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,IAAI,CAAC","sourcesContent":["import React from 'react';\nimport { ReactNode } from 'react';\nimport { useUncontrolled } from 'uncontrollable';\nimport { SwiperOptions } from 'swiper';\nimport { Swiper, SwiperSlide } from 'swiper/react';\nimport LineBreak from '@/components/generic/LineBreak';\nimport { reactMap } from '@/components/generic/Tabs/ElementChildren';\n\nimport { TabContextProvider } from '@/components/generic/Tabs/TabContext';\nimport { TabLink } from '@/components/generic/Tabs/TabLink';\nimport { TabRouteContainer } from '@/components/generic/Tabs/TabRouteContainer';\n\nimport styles from './tabs.module.scss';\n\nexport type EventKey = string | number;\n\nexport interface TabsProps {\n variant?: 'tabs' | 'pills';\n activeKey?: string;\n defaultActiveKey?: EventKey;\n onSelect?: (key: string) => void;\n children: ReactNode[];\n fullBleedOnLineBreak?: boolean;\n}\n\nconst options: SwiperOptions = {\n slidesPerView: 'auto',\n allowTouchMove: true,\n spaceBetween: 32,\n noSwiping: false,\n};\n\nconst Tabs: React.FC<TabsProps> = (props) => {\n const {\n onSelect,\n children,\n variant = 'tabs',\n activeKey = null,\n fullBleedOnLineBreak = true,\n } = useUncontrolled(props, {\n activeKey: 'onSelect',\n });\n\n return (\n <TabContextProvider defaultActiveKey={activeKey || ''} onChange={onSelect}>\n <ul className={`c-nav c-nav-${variant} ${styles.tabCarousel}`}>\n <Swiper {...options}>\n {reactMap(children, (child, index) => (\n <SwiperSlide key={index}>\n <TabLink index={index} {...child.props}>\n {child}\n </TabLink>\n </SwiperSlide>\n ))}\n </Swiper>\n </ul>\n <LineBreak noMargins fullBleed={fullBleedOnLineBreak} />\n <TabRouteContainer>{props.children}</TabRouteContainer>\n </TabContextProvider>\n );\n};\n\nexport default Tabs;\n"]}
@@ -1,8 +1,10 @@
1
1
  import { ReactChild } from 'react';
2
2
  export interface BETooltipProps {
3
3
  wrapperClasses?: string;
4
+ followElement?: HTMLElement | null;
4
5
  overrideContainer?: HTMLElement | null;
5
6
  children: ReactChild | ReactChild[];
6
7
  title: string;
8
+ disabled?: boolean;
7
9
  }
8
10
  export default function Tooltip(props: BETooltipProps): JSX.Element;
@@ -8,7 +8,7 @@ const react_2 = require("react");
8
8
  const Overlay_1 = require("../Overlay/Overlay");
9
9
  const Tooltip_module_scss_1 = __importDefault(require("./Tooltip.module.scss"));
10
10
  function Tooltip(props) {
11
- var _a;
11
+ var _a, _b;
12
12
  const wrapperClass = (_a = props.wrapperClasses) !== null && _a !== void 0 ? _a : '';
13
13
  const containerRef = (0, react_2.useRef)(null);
14
14
  const [isDisplayed, setDisplayed] = (0, react_2.useState)(false);
@@ -19,7 +19,7 @@ function Tooltip(props) {
19
19
  setDisplayed(true);
20
20
  };
21
21
  return (react_1.default.createElement("div", { ref: containerRef, onMouseLeave: displayFalse, onMouseEnter: displayTrue, onMouseDown: displayFalse, className: wrapperClass },
22
- react_1.default.createElement(Overlay_1.Overlay, { open: isDisplayed, container: props.overrideContainer, hideStyles: true, followElement: containerRef === null || containerRef === void 0 ? void 0 : containerRef.current },
22
+ react_1.default.createElement(Overlay_1.Overlay, { open: isDisplayed && !props.disabled, container: props.overrideContainer, hideStyles: true, followElement: (_b = props.followElement) !== null && _b !== void 0 ? _b : containerRef === null || containerRef === void 0 ? void 0 : containerRef.current },
23
23
  react_1.default.createElement("div", { className: Tooltip_module_scss_1.default['rs-tooltip'] },
24
24
  react_1.default.createElement("div", { className: Tooltip_module_scss_1.default['rs-tooltip-arrow'] }),
25
25
  props.title)),
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sourceRoot":"/","sources":["src/components/generic/Tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,iCAAqD;AACrD,kEAA+D;AAE/D,gFAA2C;AAS3C,SAAwB,OAAO,CAAC,KAAqB;;IACjD,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,cAAc,mCAAI,EAAE,CAAC;IAChD,MAAM,YAAY,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC;IAElC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEpD,MAAM,YAAY,GAAG,GAAG,EAAE;QACtB,YAAY,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,GAAG,EAAE;QACrB,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,CACH,uCAAK,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY;QAC7H,8BAAC,iBAAO,IAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,CAAC,iBAAiB,EAAE,UAAU,QAAC,aAAa,EAAE,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO;YAC3G,uCAAK,SAAS,EAAE,6BAAM,CAAC,YAAY,CAAC;gBAChC,uCAAK,SAAS,EAAE,6BAAM,CAAC,kBAAkB,CAAC,GAAQ;gBACjD,KAAK,CAAC,KAAK,CACV,CACA;QACT,KAAK,CAAC,QAAQ,CACb,CACT,CAAC;AACN,CAAC;AAzBD,0BAyBC","sourcesContent":["import React from 'react';\n\nimport { useState, useRef, ReactChild } from 'react';\nimport { Overlay } from '@/components/generic/Overlay/Overlay';\n\nimport styles from './Tooltip.module.scss';\n\nexport interface BETooltipProps {\n wrapperClasses?: string;\n overrideContainer?: HTMLElement | null;\n children: ReactChild | ReactChild[];\n title: string;\n}\n\nexport default function Tooltip(props: BETooltipProps) {\n const wrapperClass = props.wrapperClasses ?? '';\n const containerRef = useRef(null);\n\n const [isDisplayed, setDisplayed] = useState(false);\n\n const displayFalse = () => {\n setDisplayed(false);\n };\n\n const displayTrue = () => {\n setDisplayed(true);\n };\n\n return (\n <div ref={containerRef} onMouseLeave={displayFalse} onMouseEnter={displayTrue} onMouseDown={displayFalse} className={wrapperClass}>\n <Overlay open={isDisplayed} container={props.overrideContainer} hideStyles followElement={containerRef?.current}>\n <div className={styles['rs-tooltip']}>\n <div className={styles['rs-tooltip-arrow']}></div>\n {props.title}\n </div>\n </Overlay>\n {props.children}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"/","sources":["src/components/generic/Tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,iCAAqD;AACrD,kEAA+D;AAE/D,gFAA2C;AAY3C,SAAwB,OAAO,CAAC,KAAqB;;IACjD,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,cAAc,mCAAI,EAAE,CAAC;IAChD,MAAM,YAAY,GAAG,IAAA,cAAM,EAAC,IAAI,CAAC,CAAC;IAElC,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAEpD,MAAM,YAAY,GAAG,GAAG,EAAE;QACtB,YAAY,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,GAAG,EAAE;QACrB,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,CACH,uCAAK,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY;QAC7H,8BAAC,iBAAO,IAAC,IAAI,EAAE,WAAW,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,iBAAiB,EAAE,UAAU,QAAC,aAAa,EAAE,MAAA,KAAK,CAAC,aAAa,mCAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO;YACrJ,uCAAK,SAAS,EAAE,6BAAM,CAAC,YAAY,CAAC;gBAChC,uCAAK,SAAS,EAAE,6BAAM,CAAC,kBAAkB,CAAC,GAAQ;gBACjD,KAAK,CAAC,KAAK,CACV,CACA;QACT,KAAK,CAAC,QAAQ,CACb,CACT,CAAC;AACN,CAAC;AAzBD,0BAyBC","sourcesContent":["import React from 'react';\n\nimport { useState, useRef, ReactChild } from 'react';\nimport { Overlay } from '@/components/generic/Overlay/Overlay';\n\nimport styles from './Tooltip.module.scss';\n\nexport interface BETooltipProps {\n wrapperClasses?: string;\n followElement?: HTMLElement | null;\n overrideContainer?: HTMLElement | null;\n children: ReactChild | ReactChild[];\n title: string;\n\n disabled?: boolean;\n}\n\nexport default function Tooltip(props: BETooltipProps) {\n const wrapperClass = props.wrapperClasses ?? '';\n const containerRef = useRef(null);\n\n const [isDisplayed, setDisplayed] = useState(false);\n\n const displayFalse = () => {\n setDisplayed(false);\n };\n\n const displayTrue = () => {\n setDisplayed(true);\n };\n\n return (\n <div ref={containerRef} onMouseLeave={displayFalse} onMouseEnter={displayTrue} onMouseDown={displayFalse} className={wrapperClass}>\n <Overlay open={isDisplayed && !props.disabled} container={props.overrideContainer} hideStyles followElement={props.followElement ?? containerRef?.current}>\n <div className={styles['rs-tooltip']}>\n <div className={styles['rs-tooltip-arrow']}></div>\n {props.title}\n </div>\n </Overlay>\n {props.children}\n </div>\n );\n}\n"]}
@@ -31,39 +31,23 @@ const contexts_1 = require("../../../contexts/index.js");
31
31
  const RoomDetails_1 = __importDefault(require("./roomDetails/RoomDetails"));
32
32
  const LargeLoader_1 = __importDefault(require("../../generic/loader/LargeLoader"));
33
33
  const RoomSortProvider_1 = __importDefault(require("../../../providers/RoomSortProvider"));
34
- const FilterProvider_1 = __importDefault(require("../../../providers/FilterProvider"));
35
34
  const RoomListCrossSellBlock_1 = __importDefault(require("./RoomListCrossSellBlock"));
36
35
  const DataLayer_1 = __importDefault(require("../../../util/DataLayer"));
37
36
  const ScreenSize_1 = __importDefault(require("../../../util/ScreenSize"));
38
37
  const hooks_1 = require("../../../hooks/index.js");
39
- const GuestSearchEvent_1 = require("../../../events/actions/GuestSearchEvent");
40
- const RoomListSearchEvent_1 = require("../../../events/actions/RoomListSearchEvent");
41
38
  const RoomDetailsRetargeting_1 = require("./roomDetails/RoomDetailsRetargeting");
42
- const dayjs_1 = __importDefault(require("dayjs"));
43
39
  const NoRoomsFoundBlock_1 = __importDefault(require("./NoRoomsFoundBlock"));
44
40
  const RoomListAlert_1 = require("./RoomListAlert");
45
41
  const StepRoomErrorForm_1 = require("./StepRoomErrorForm");
42
+ const RoomRateAvailabilityListFromApi_1 = require("../../../hooks/RoomRateAvailabilityListFromApi");
46
43
  function RoomList() {
47
- var _a;
48
44
  const basketContext = (0, react_1.useContext)(contexts_1.BasketContext);
49
45
  const beContext = (0, react_1.useContext)(contexts_1.BookingEngineContext);
50
- const ccx = (0, react_1.useContext)(contexts_1.CompanyContext);
51
- const { roomstayMember } = (0, react_1.useContext)(contexts_1.RoomstayMemberContext);
52
46
  const { hotel } = (0, hooks_1.useCurrentHotel)();
53
- const [rooms, setRooms] = react_1.default.useState([]);
54
- const [isLoading, setIsLoading] = (0, react_1.useState)(false);
55
- const [openRoom, setOpenRoom] = (0, react_1.useState)(null);
56
- const [apiHasError, setApiHasError] = (0, react_1.useState)(null);
47
+ const { rooms, isLoading, openRoom, apiHasError, retargetingRoom } = (0, RoomRateAvailabilityListFromApi_1.useRoomRateAvailabilityListFromApi)();
57
48
  const roomListRef = (0, react_1.useRef)(null);
58
- const selectedRow = basketContext.selectedBasketRow;
59
- const startDate = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.getStartDate();
60
- const endDate = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.getEndDate();
61
- const promoCode = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.getPromoCode();
62
- const adults = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.getAdults();
63
- const children = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.getChildren();
64
49
  const sortBy = beContext.currentRoomSort;
65
50
  let listWhenLastScrolled = null;
66
- const { raise } = (0, hooks_1.useEvent)();
67
51
  const scrollIntoView = () => {
68
52
  if (roomListRef.current && listWhenLastScrolled !== rooms) {
69
53
  listWhenLastScrolled = rooms;
@@ -74,107 +58,6 @@ function RoomList() {
74
58
  });
75
59
  }
76
60
  };
77
- (0, react_1.useEffect)(() => {
78
- let isCancelled = false;
79
- try {
80
- const search = {
81
- checkInTime: startDate === null || startDate === void 0 ? void 0 : startDate.format('YYYY-M-D'),
82
- checkOutTime: endDate === null || endDate === void 0 ? void 0 : endDate.format('YYYY-M-D'),
83
- numAdults: adults,
84
- numChildren: children,
85
- numRooms: 1,
86
- promoCode: promoCode,
87
- };
88
- const event = new GuestSearchEvent_1.GuestSearchEvent(search);
89
- raise(event);
90
- const filters = Object.values(beContext.currentFilters).filter((filter) => !!filter);
91
- let row = basketContext.selectedBasketRow;
92
- if (!row && !rooms.length) {
93
- row = basketContext.attemptSelectUnfilledRow();
94
- }
95
- if (!row) {
96
- const validRows = basketContext.getAllValidRows();
97
- row = validRows[validRows.length - 1];
98
- }
99
- if (row) {
100
- setIsLoading(true);
101
- FilterProvider_1.default.getRoomList(row, filters, hotel === null || hotel === void 0 ? void 0 : hotel.hotelID)
102
- .then((availableRooms) => {
103
- var _a;
104
- if (!isCancelled) {
105
- setRooms(availableRooms);
106
- setOpenRoom(!!basketContext.selectedBasketRow);
107
- setApiHasError(false);
108
- const foundRooms = (_a = availableRooms === null || availableRooms === void 0 ? void 0 : availableRooms.map((room) => {
109
- var _a, _b;
110
- const { name, code } = room;
111
- const foundRoom = {
112
- name: name,
113
- code: code,
114
- lowestPrice: room.getLowestPrice(),
115
- highestPrice: room.getHighestPrice(),
116
- currency: ccx.currentCurrency,
117
- rates: (_b = (_a = room.getRates()) === null || _a === void 0 ? void 0 : _a.map((rate) => {
118
- const { name, code } = rate;
119
- return {
120
- name,
121
- code,
122
- price: {
123
- averagePrice: rate.getAveragePrice(),
124
- totalPrice: rate.getTotalPrice(),
125
- currency: ccx.currentCurrency,
126
- },
127
- };
128
- })) !== null && _b !== void 0 ? _b : [],
129
- };
130
- return foundRoom;
131
- })) !== null && _a !== void 0 ? _a : [];
132
- const event = new RoomListSearchEvent_1.RoomListSearchEvent(search, foundRooms);
133
- raise(event);
134
- }
135
- })
136
- .catch(() => {
137
- if (!isCancelled) {
138
- setRooms([]);
139
- setOpenRoom(null);
140
- setApiHasError(true);
141
- }
142
- })
143
- .finally(() => {
144
- setIsLoading(false);
145
- });
146
- }
147
- }
148
- catch (ex) {
149
- //
150
- }
151
- return () => {
152
- setIsLoading(false);
153
- isCancelled = true;
154
- };
155
- }, [adults, children, startDate, endDate, promoCode, ccx.currentLanguage, beContext.currentFilters, (_a = basketContext.selectedBasketRow) === null || _a === void 0 ? void 0 : _a.getStale()]);
156
- const retargetingRoom = (0, react_1.useMemo)(() => {
157
- var _a;
158
- if (!roomstayMember || ((_a = roomstayMember.bookings) === null || _a === void 0 ? void 0 : _a.length) === 0)
159
- return null;
160
- let lastBookingDate;
161
- let lastBookingRoomcode = '';
162
- roomstayMember.bookings.forEach((booking) => {
163
- if (booking.hotelId !== (hotel === null || hotel === void 0 ? void 0 : hotel.hotelID)) {
164
- return;
165
- }
166
- Object.values(booking.itinerary).map((itinerary) => {
167
- const { roomCode, nights } = itinerary;
168
- const dates = Object.keys(nights).map(dayjs_1.default);
169
- const maxDate = (0, dayjs_1.default)(Math.max.apply(null, dates.map((d) => +d)));
170
- if (!lastBookingDate || maxDate.isAfter(maxDate)) {
171
- lastBookingDate = maxDate;
172
- lastBookingRoomcode = roomCode;
173
- }
174
- });
175
- });
176
- return rooms.find((room) => room.code === lastBookingRoomcode);
177
- }, [rooms, roomstayMember]);
178
61
  return (0, react_1.useMemo)(() => {
179
62
  var _a;
180
63
  const sortedRooms = [...rooms];
@@ -1 +1 @@
1
- {"version":3,"file":"RoomList.js","sourceRoot":"/","sources":["src/components/steps/room/RoomList.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgF;AAChF,iDAAgH;AAChH,kGAA0E;AAE1E,0FAAkE;AAClE,oFAA4D;AAE5D,gFAAwD;AACxD,4GAAoF;AACpF,iEAAyC;AACzC,mEAA2C;AAC3C,2CAA4D;AAG5D,wEAAqE;AAErE,8EAA2E;AAE3E,iFAA8E;AAC9E,kDAA0B;AAC1B,4E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ACnJ,QAAQ,CACV,CACN,CAAC;IACN,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;AACtG,CAAC;AAxMD,2BAwMC","sourcesContent":["import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { BasketContext, BookingEngineContext, CompanyContext, RoomstayMemberContext } from '@frontend/contexts';\nimport RoomDetails from '@/components/steps/room/roomDetails/RoomDetails';\nimport { Room } from '@/models/Room/Room';\nimport LargeLoader from '@/components/generic/loader/LargeLoader';\nimport RoomSortProvider from '@/providers/RoomSortProvider';\nimport Filter from '@/models/Room/Filters/Filter';\nimport FilterProvider from '@/providers/FilterProvider';\nimport RoomListCrossSellBlock from '@/components/steps/room/RoomListCrossSellBlock';\nimport DataLayer from '@/util/DataLayer';\nimport ScreenSize from '@/util/ScreenSize';\nimport { useCurrentHotel, useEvent } from '@frontend/hooks';\n\nimport { SearchParameters } from '@/models/SearchParameters';\nimport { GuestSearchEvent } from '@/events/actions/GuestSearchEvent';\nimport { RoomListSearch } from '@/models/RoomListSearch';\nimport { RoomListSearchEvent } from '@/events/actions/RoomListSearchEvent';\n\nimport { RoomDetailsRetargeting } from './roomDetails/RoomDetailsRetargeting';\nimport dayjs from 'dayjs';\nimport NoRoomsFoundBlock from './NoRoomsFoundBlock';\nimport { RoomListAlert } from './RoomListAlert';\nimport { StepRoomErrorForm } from './StepRoomErrorForm';\nimport BasketRow from 'models/BasketRow';\nimport { IRoomstayMemberBookingItem } from '@roomstay/core';\n\nexport default function RoomList() {\n const basketContext = useContext(BasketContext);\n const beContext = useContext(BookingEngineContext);\n const ccx = useContext(CompanyContext);\n const { roomstayMember } = useContext(RoomstayMemberContext);\n\n const { hotel } = useCurrentHotel();\n\n const [rooms, setRooms] = React.useState<Room[]>([]);\n const [isLoading, setIsLoading] = useState(false);\n\n const [openRoom, setOpenRoom] = useState<boolean | null>(null);\n const [apiHasError, setApiHasError] = useState<boolean | null>(null);\n\n const roomListRef = useRef<HTMLDivElement | null>(null);\n\n const selectedRow = basketContext.selectedBasketRow;\n\n const startDate = selectedRow?.getStartDate();\n const endDate = selectedRow?.getEndDate();\n const promoCode = selectedRow?.getPromoCode();\n\n const adults = selectedRow?.getAdults();\n const children = selectedRow?.getChildren();\n const sortBy = beContext.currentRoomSort;\n\n let listWhenLastScrolled: Room[] | null = null;\n\n const { raise } = useEvent();\n\n const scrollIntoView = () => {\n if (roomListRef.current && listWhenLastScrolled !== rooms) {\n listWhenLastScrolled = rooms;\n const offset = beContext.screenSize <= ScreenSize.Medium ? 185 : 350;\n\n window.scrollTo({\n top: window.scrollY + (roomListRef.current.getBoundingClientRect().top - offset),\n behavior: 'smooth',\n });\n }\n };\n\n useEffect(() => {\n let isCancelled = false;\n\n try {\n const search: SearchParameters = {\n checkInTime: startDate?.format('YYYY-M-D'),\n checkOutTime: endDate?.format('YYYY-M-D'),\n numAdults: adults,\n numChildren: children,\n numRooms: 1,\n promoCode: promoCode,\n };\n\n const event = new GuestSearchEvent(search);\n raise(event);\n\n const filters: Filter[] = Object.values(beContext.currentFilters).filter((filter) => !!filter) as Filter[];\n\n let row = basketContext.selectedBasketRow;\n\n if (!row && !rooms.length) {\n row = basketContext.attemptSelectUnfilledRow() as BasketRow;\n }\n\n if (!row) {\n const validRows = basketContext.getAllValidRows();\n row = validRows[validRows.length - 1];\n }\n\n if (row) {\n setIsLoading(true);\n FilterProvider.getRoomList(row, filters, hotel?.hotelID as string)\n .then((availableRooms) => {\n if (!isCancelled) {\n setRooms(availableRooms);\n setOpenRoom(!!basketContext.selectedBasketRow);\n setApiHasError(false);\n\n const foundRooms: RoomListSearch[] =\n availableRooms?.map((room) => {\n const { name, code } = room;\n\n const foundRoom: RoomListSearch = {\n name: name as string,\n code: code as string,\n lowestPrice: room.getLowestPrice(),\n highestPrice: room.getHighestPrice(),\n currency: ccx.currentCurrency,\n\n rates:\n room.getRates()?.map((rate) => {\n const { name, code } = rate;\n return {\n name,\n code,\n\n price: {\n averagePrice: rate.getAveragePrice(),\n totalPrice: rate.getTotalPrice(),\n currency: ccx.currentCurrency,\n },\n };\n }) ?? [],\n };\n\n return foundRoom;\n }) ?? [];\n\n const event = new RoomListSearchEvent(search, foundRooms);\n raise(event);\n }\n })\n .catch(() => {\n if (!isCancelled) {\n setRooms([]);\n setOpenRoom(null);\n setApiHasError(true);\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }\n } catch (ex) {\n //\n }\n\n return () => {\n setIsLoading(false);\n isCancelled = true;\n };\n }, [adults, children, startDate, endDate, promoCode, ccx.currentLanguage, beContext.currentFilters, basketContext.selectedBasketRow?.getStale()]);\n\n const retargetingRoom = useMemo(() => {\n if (!roomstayMember || roomstayMember.bookings?.length === 0) return null;\n\n let lastBookingDate: dayjs.Dayjs;\n let lastBookingRoomcode = '';\n roomstayMember.bookings.forEach((booking) => {\n if (booking.hotelId !== hotel?.hotelID) {\n return;\n }\n\n Object.values<IRoomstayMemberBookingItem>(booking.itinerary).map((itinerary) => {\n const { roomCode, nights } = itinerary;\n const dates = Object.keys(nights).map(dayjs);\n const maxDate = dayjs(\n Math.max.apply(\n null,\n dates.map((d) => +d)\n )\n );\n if (!lastBookingDate || maxDate.isAfter(maxDate)) {\n lastBookingDate = maxDate;\n lastBookingRoomcode = roomCode;\n }\n });\n });\n\n return rooms.find((room) => room.code === lastBookingRoomcode);\n }, [rooms, roomstayMember]);\n\n return useMemo(() => {\n const sortedRooms = [...rooms];\n if (sortedRooms.length !== 0) {\n sortedRooms.sort(RoomSortProvider.getSortByFunction(sortBy));\n }\n\n setTimeout(() => {\n scrollIntoView();\n }, 100);\n\n const elements = (\n <div ref={roomListRef}>\n {isLoading ? (\n <LargeLoader />\n ) : sortedRooms.length ? (\n sortedRooms.map((room, index) => <RoomDetails key={room.code} room={room} disableMarginBottom={index === sortedRooms.length - 1} />)\n ) : (\n <>\n {apiHasError ? <StepRoomErrorForm /> : <NoRoomsFoundBlock />}\n {hotel?.crossSellHotelIds?.map((hotelId) => (\n <RoomListCrossSellBlock key={hotelId} hotelId={hotelId} />\n ))}\n </>\n )}\n </div>\n );\n\n DataLayer.instance.sendRoomImpressions();\n\n return (\n <>\n <RoomListAlert>{!isLoading && retargetingRoom ? <RoomDetailsRetargeting key={retargetingRoom.code} room={retargetingRoom} /> : null}</RoomListAlert>\n {elements}\n </>\n );\n }, [rooms, isLoading, openRoom, sortBy, beContext.currentFilters, basketContext.loadedPromotion]);\n}\n"]}
1
+ {"version":3,"file":"RoomList.js","sourceRoot":"/","sources":["src/components/steps/room/RoomList.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA2D;AAC3D,iDAAyE;AACzE,kGAA0E;AAE1E,0FAAkE;AAClE,oFAA4D;AAC5D,4GAAoF;AACpF,iEAAyC;AACzC,mEAA2C;AAC3C,2CAAkD;AAElD,iFAA8E;AAC9E,4EAAoD;AACpD,mDAAgD;AAChD,2DAAwD;AACxD,6FAA6F;AAE7F,SAAwB,QAAQ;IAC5B,MAAM,aAAa,GAAG,IAAA,kBAAU,EAAC,wBAAa,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,IAAA,kBAAU,EAAC,+BAAoB,CAAC,CAAC;IAEnD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,uBAAe,GAAE,CAAC;IACpC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,IAAA,oEAAkC,GAAE,CAAC;IAE1G,MAAM,WAAW,GAAG,IAAA,cAAM,EAAwB,IAAI,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,SAAS,CAAC,eAAe,CAAC;IACzC,IAAI,oBAAoB,GAAkB,IAAI,CAAC;IAE/C,MAAM,cAAc,GAAG,GAAG,EAAE;QACxB,IAAI,WAAW,CAAC,OAAO,IAAI,oBAAoB,KAAK,KAAK,E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aAAL,KAAK,uBAAL,KAAK,CAAE,iBAAiB;eAAE,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACxC,8BAAC,gCAAsB,IAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAI,CAC7D,CAAC,CACH,CACN,CACC,CACT,CAAC;QAEF,mBAAS,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAC;QAEzC,OAAO,CACH;YACI,8BAAC,6BAAa,QAAE,CAAC,SAAS,IAAI,eAAe,CAAC,CAAC,CAAC,8BAAC,+CAAsB,IAAC,GAAG,EAAE,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,GAAI,CAAC,CAAC,CAAC,IAAI,CAAiB;YACnJ,QAAQ,CACV,CACN,CAAC;IACN,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;AACtG,CAAC;AA3DD,2BA2DC","sourcesContent":["import React, { useContext, useMemo, useRef } from 'react';\nimport { BasketContext, BookingEngineContext } from '@frontend/contexts';\nimport RoomDetails from '@/components/steps/room/roomDetails/RoomDetails';\nimport { Room } from '@/models/Room/Room';\nimport LargeLoader from '@/components/generic/loader/LargeLoader';\nimport RoomSortProvider from '@/providers/RoomSortProvider';\nimport RoomListCrossSellBlock from '@/components/steps/room/RoomListCrossSellBlock';\nimport DataLayer from '@/util/DataLayer';\nimport ScreenSize from '@/util/ScreenSize';\nimport { useCurrentHotel } from '@frontend/hooks';\n\nimport { RoomDetailsRetargeting } from './roomDetails/RoomDetailsRetargeting';\nimport NoRoomsFoundBlock from './NoRoomsFoundBlock';\nimport { RoomListAlert } from './RoomListAlert';\nimport { StepRoomErrorForm } from './StepRoomErrorForm';\nimport { useRoomRateAvailabilityListFromApi } from '@/hooks/RoomRateAvailabilityListFromApi';\n\nexport default function RoomList() {\n const basketContext = useContext(BasketContext);\n const beContext = useContext(BookingEngineContext);\n\n const { hotel } = useCurrentHotel();\n const { rooms, isLoading, openRoom, apiHasError, retargetingRoom } = useRoomRateAvailabilityListFromApi();\n\n const roomListRef = useRef<HTMLDivElement | null>(null);\n const sortBy = beContext.currentRoomSort;\n let listWhenLastScrolled: Room[] | null = null;\n\n const scrollIntoView = () => {\n if (roomListRef.current && listWhenLastScrolled !== rooms) {\n listWhenLastScrolled = rooms;\n const offset = beContext.screenSize <= ScreenSize.Medium ? 185 : 350;\n\n window.scrollTo({\n top: window.scrollY + (roomListRef.current.getBoundingClientRect().top - offset),\n behavior: 'smooth',\n });\n }\n };\n\n return useMemo(() => {\n const sortedRooms = [...rooms];\n if (sortedRooms.length !== 0) {\n sortedRooms.sort(RoomSortProvider.getSortByFunction(sortBy));\n }\n\n setTimeout(() => {\n scrollIntoView();\n }, 100);\n\n const elements = (\n <div ref={roomListRef}>\n {isLoading ? (\n <LargeLoader />\n ) : sortedRooms.length ? (\n sortedRooms.map((room, index) => <RoomDetails key={room.code} room={room} disableMarginBottom={index === sortedRooms.length - 1} />)\n ) : (\n <>\n {apiHasError ? <StepRoomErrorForm /> : <NoRoomsFoundBlock />}\n {hotel?.crossSellHotelIds?.map((hotelId) => (\n <RoomListCrossSellBlock key={hotelId} hotelId={hotelId} />\n ))}\n </>\n )}\n </div>\n );\n\n DataLayer.instance.sendRoomImpressions();\n\n return (\n <>\n <RoomListAlert>{!isLoading && retargetingRoom ? <RoomDetailsRetargeting key={retargetingRoom.code} room={retargetingRoom} /> : null}</RoomListAlert>\n {elements}\n </>\n );\n }, [rooms, isLoading, openRoom, sortBy, beContext.currentFilters, basketContext.loadedPromotion]);\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { Room } from '../../../../models/Room/Room';
2
+ import { HotelRoomGroupsDTO } from '../../../../models/Api/HotelDTO';
3
+ type TabGroupedRoomListProps = {
4
+ rooms: Room[];
5
+ group: HotelRoomGroupsDTO[number];
6
+ };
7
+ export declare const TabGroupedRoomList: (props: TabGroupedRoomListProps) => JSX.Element;
8
+ export {};
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.TabGroupedRoomList = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const RoomDetails_1 = __importDefault(require("../roomDetails/RoomDetails"));
32
+ const TabGroupedRoomList_module_scss_1 = __importDefault(require("./TabGroupedRoomList.module.scss"));
33
+ const Headline_1 = __importDefault(require("../../../generic/Headline"));
34
+ const Select_1 = require("../../../generic/Select/Select");
35
+ const TabGroupedRoomList = (props) => {
36
+ const { rooms, group } = props;
37
+ const [appliedFilters, setAppliedFilters] = (0, react_1.useState)({});
38
+ const filterKeys = (0, react_1.useMemo)(() => {
39
+ return Object.keys(group.filters || {});
40
+ }, [group.filters]);
41
+ const roomList = (0, react_1.useMemo)(() => {
42
+ return rooms
43
+ .filter((room) => {
44
+ var _a, _b, _c;
45
+ for (const filter of Object.keys(appliedFilters)) {
46
+ let possibleValues = [];
47
+ const auxFilter = (_a = group.filters) === null || _a === void 0 ? void 0 : _a[filter];
48
+ if (auxFilter.includeAllAbove) {
49
+ let foundKey = false;
50
+ for (let i = auxFilter.options.length - 1; i >= 0; i--) {
51
+ const currentValue = auxFilter.options[i];
52
+ possibleValues.push(currentValue.value);
53
+ if (appliedFilters[filter] === currentValue.value) {
54
+ foundKey = true;
55
+ break;
56
+ }
57
+ }
58
+ if (!foundKey) {
59
+ possibleValues = [];
60
+ }
61
+ }
62
+ else {
63
+ possibleValues = (_b = appliedFilters[filter]) !== null && _b !== void 0 ? _b : [];
64
+ }
65
+ if (((_c = room.auxiliaryValues) === null || _c === void 0 ? void 0 : _c[filter]) && appliedFilters[filter] && !possibleValues.includes(room.auxiliaryValues[filter])) {
66
+ return false;
67
+ }
68
+ }
69
+ return room;
70
+ })
71
+ .map((room, index) => {
72
+ return react_1.default.createElement(RoomDetails_1.default, { key: room.code, room: room, disableMarginBottom: index === rooms.length - 1 });
73
+ });
74
+ }, [rooms, appliedFilters]);
75
+ return (react_1.default.createElement("div", { className: TabGroupedRoomList_module_scss_1.default.groupedRoomList },
76
+ react_1.default.createElement("div", { className: TabGroupedRoomList_module_scss_1.default.groupedRoomListHeader },
77
+ react_1.default.createElement(Headline_1.default, { bold: true }, group.groupName)),
78
+ !!(filterKeys === null || filterKeys === void 0 ? void 0 : filterKeys.length) && (react_1.default.createElement("div", { className: TabGroupedRoomList_module_scss_1.default.filterContainer }, filterKeys.map((filterKey) => {
79
+ var _a, _b, _c;
80
+ const filter = (_a = group.filters) === null || _a === void 0 ? void 0 : _a[filterKey];
81
+ if (filter.type === 'select') {
82
+ const options = [{ label: 'All', value: null }, ...filter.options];
83
+ const currentValue = (_b = appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters[filterKey]) !== null && _b !== void 0 ? _b : (_c = options[0]) === null || _c === void 0 ? void 0 : _c.value;
84
+ const localOnFilterChange = (value) => {
85
+ setAppliedFilters((prev) => (Object.assign(Object.assign({}, prev), { [filterKey]: value })));
86
+ };
87
+ return (react_1.default.createElement("div", { key: filterKey, className: TabGroupedRoomList_module_scss_1.default.filterItem },
88
+ react_1.default.createElement("div", { className: TabGroupedRoomList_module_scss_1.default['filterItem-label'] },
89
+ filter.name,
90
+ ":"),
91
+ react_1.default.createElement(Select_1.Select, { keyName: "value", labelName: "label", options: options, value: currentValue, onChange: localOnFilterChange })));
92
+ }
93
+ }))),
94
+ roomList));
95
+ };
96
+ exports.TabGroupedRoomList = TabGroupedRoomList;
97
+ //# sourceMappingURL=TabGroupedRoomList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabGroupedRoomList.js","sourceRoot":"/","sources":["src/components/steps/room/TabGroupedRooms/TabGroupedRoomList.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiD;AAEjD,6EAAqD;AAGrD,sGAAsD;AACtD,6EAAqD;AACrD,+DAA4D;AAQrD,MAAM,kBAAkB,GAAG,CAAC,KAA8B,EAAE,EAAE;IACjE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAC/B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAwB,EAAE,CAAC,CAAC;IAEhF,MAAM,UAAU,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpB,MAAM,QAAQ,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC1B,OAAO,KAAK;aACP,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;;YACb,KAAK,MAAM,MAAM,IAA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EAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,mBAAmB,GAAW,CACvH,CACT,CAAC;aACL;QACL,CAAC,CAAC,CACA,CACT;QACA,QAAQ,CACP,CACT,CAAC;AACN,CAAC,CAAC;AA9EW,QAAA,kBAAkB,sBA8E7B","sourcesContent":["import React, { useMemo, useState } from 'react';\nimport { Room } from '@/models/Room/Room';\nimport RoomDetails from '../roomDetails/RoomDetails';\nimport { HotelRoomGroupsDTO } from '@/models/Api/HotelDTO';\n\nimport styles from './TabGroupedRoomList.module.scss';\nimport Headline from '@/components/generic/Headline';\nimport { Select } from '@/components/generic/Select/Select';\nimport DataLayer from '@/util/DataLayer';\n\ntype TabGroupedRoomListProps = {\n rooms: Room[];\n group: HotelRoomGroupsDTO[number];\n};\n\nexport const TabGroupedRoomList = (props: TabGroupedRoomListProps) => {\n const { rooms, group } = props;\n const [appliedFilters, setAppliedFilters] = useState<{ [id: string]: any }>({});\n\n const filterKeys = useMemo(() => {\n return Object.keys(group.filters || {});\n }, [group.filters]);\n\n const roomList = useMemo(() => {\n return rooms\n .filter((room) => {\n for (const filter of Object.keys(appliedFilters)) {\n let possibleValues: any[] = [];\n\n const auxFilter = group.filters?.[filter];\n\n if (auxFilter.includeAllAbove) {\n let foundKey = false;\n for (let i = auxFilter.options.length - 1; i >= 0; i--) {\n const currentValue = auxFilter.options[i];\n possibleValues.push(currentValue.value);\n\n if (appliedFilters[filter] === currentValue.value) {\n foundKey = true;\n break;\n }\n }\n\n if (!foundKey) {\n possibleValues = [];\n }\n } else {\n possibleValues = appliedFilters[filter] ?? [];\n }\n\n if (room.auxiliaryValues?.[filter] && appliedFilters[filter] && !possibleValues.includes(room.auxiliaryValues[filter])) {\n return false;\n }\n }\n\n return room;\n })\n .map((room, index) => {\n return <RoomDetails key={room.code} room={room} disableMarginBottom={index === rooms.length - 1} />;\n });\n }, [rooms, appliedFilters]);\n\n return (\n <div className={styles.groupedRoomList}>\n <div className={styles.groupedRoomListHeader}>\n <Headline bold>{group.groupName}</Headline>\n </div>\n {!!filterKeys?.length && (\n <div className={styles.filterContainer}>\n {filterKeys.map((filterKey) => {\n const filter = group.filters?.[filterKey];\n\n if (filter.type === 'select') {\n const options = [{ label: 'All', value: null }, ...filter.options];\n const currentValue = appliedFilters?.[filterKey] ?? options[0]?.value;\n\n const localOnFilterChange = (value: string) => {\n setAppliedFilters((prev) => ({ ...prev, [filterKey]: value }));\n };\n\n return (\n <div key={filterKey} className={styles.filterItem}>\n <div className={styles['filterItem-label']}>{filter.name}:</div>\n <Select keyName=\"value\" labelName=\"label\" options={options} value={currentValue} onChange={localOnFilterChange}></Select>\n </div>\n );\n }\n })}\n </div>\n )}\n {roomList}\n </div>\n );\n};\n"]}
@@ -0,0 +1 @@
1
+ export declare const TabGroupedRooms: () => JSX.Element;