@lokalise/harmony 1.36.0 → 1.37.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 (195) hide show
  1. package/dist/harmony.cjs +1 -3
  2. package/dist/harmony.cjs.map +1 -1
  3. package/dist/harmony.mjs +2 -4
  4. package/dist/harmony100.cjs +3 -9
  5. package/dist/harmony100.cjs.map +1 -1
  6. package/dist/harmony100.mjs +3 -9
  7. package/dist/harmony100.mjs.map +1 -1
  8. package/dist/harmony101.cjs +19 -9
  9. package/dist/harmony101.cjs.map +1 -1
  10. package/dist/harmony101.mjs +21 -11
  11. package/dist/harmony101.mjs.map +1 -1
  12. package/dist/harmony102.cjs +11 -20
  13. package/dist/harmony102.cjs.map +1 -1
  14. package/dist/harmony102.mjs +11 -20
  15. package/dist/harmony102.mjs.map +1 -1
  16. package/dist/harmony104.cjs +14 -21
  17. package/dist/harmony104.cjs.map +1 -1
  18. package/dist/harmony104.mjs +13 -20
  19. package/dist/harmony104.mjs.map +1 -1
  20. package/dist/harmony105.cjs +18 -6
  21. package/dist/harmony105.cjs.map +1 -1
  22. package/dist/harmony105.mjs +18 -6
  23. package/dist/harmony105.mjs.map +1 -1
  24. package/dist/harmony106.cjs +21 -132
  25. package/dist/harmony106.cjs.map +1 -1
  26. package/dist/harmony106.mjs +20 -131
  27. package/dist/harmony106.mjs.map +1 -1
  28. package/dist/harmony107.cjs +6 -12
  29. package/dist/harmony107.cjs.map +1 -1
  30. package/dist/harmony107.mjs +5 -11
  31. package/dist/harmony107.mjs.map +1 -1
  32. package/dist/harmony108.cjs +132 -5
  33. package/dist/harmony108.cjs.map +1 -1
  34. package/dist/harmony108.mjs +132 -5
  35. package/dist/harmony108.mjs.map +1 -1
  36. package/dist/harmony109.cjs +12 -40
  37. package/dist/harmony109.cjs.map +1 -1
  38. package/dist/harmony109.mjs +11 -39
  39. package/dist/harmony109.mjs.map +1 -1
  40. package/dist/harmony110.cjs +4 -59
  41. package/dist/harmony110.cjs.map +1 -1
  42. package/dist/harmony110.mjs +5 -60
  43. package/dist/harmony110.mjs.map +1 -1
  44. package/dist/harmony111.cjs +39 -6
  45. package/dist/harmony111.cjs.map +1 -1
  46. package/dist/harmony111.mjs +39 -6
  47. package/dist/harmony111.mjs.map +1 -1
  48. package/dist/harmony112.cjs +59 -13
  49. package/dist/harmony112.cjs.map +1 -1
  50. package/dist/harmony112.mjs +59 -13
  51. package/dist/harmony112.mjs.map +1 -1
  52. package/dist/harmony113.cjs +7 -18
  53. package/dist/harmony113.cjs.map +1 -1
  54. package/dist/harmony113.mjs +7 -18
  55. package/dist/harmony113.mjs.map +1 -1
  56. package/dist/harmony115.cjs +1 -1
  57. package/dist/harmony115.mjs +1 -1
  58. package/dist/harmony116.cjs +1 -1
  59. package/dist/harmony116.mjs +1 -1
  60. package/dist/harmony117.cjs +95 -61
  61. package/dist/harmony117.cjs.map +1 -1
  62. package/dist/harmony117.mjs +95 -61
  63. package/dist/harmony117.mjs.map +1 -1
  64. package/dist/harmony118.cjs +13 -88
  65. package/dist/harmony118.cjs.map +1 -1
  66. package/dist/harmony118.mjs +13 -88
  67. package/dist/harmony118.mjs.map +1 -1
  68. package/dist/harmony119.cjs +15 -19
  69. package/dist/harmony119.cjs.map +1 -1
  70. package/dist/harmony119.mjs +14 -18
  71. package/dist/harmony119.mjs.map +1 -1
  72. package/dist/harmony120.cjs +34 -94
  73. package/dist/harmony120.cjs.map +1 -1
  74. package/dist/harmony120.mjs +34 -94
  75. package/dist/harmony120.mjs.map +1 -1
  76. package/dist/harmony121.cjs +26 -11
  77. package/dist/harmony121.cjs.map +1 -1
  78. package/dist/harmony121.mjs +26 -11
  79. package/dist/harmony121.mjs.map +1 -1
  80. package/dist/harmony122.cjs +60 -12
  81. package/dist/harmony122.cjs.map +1 -1
  82. package/dist/harmony122.mjs +60 -12
  83. package/dist/harmony122.mjs.map +1 -1
  84. package/dist/harmony123.cjs +88 -36
  85. package/dist/harmony123.cjs.map +1 -1
  86. package/dist/harmony123.mjs +88 -36
  87. package/dist/harmony123.mjs.map +1 -1
  88. package/dist/harmony124.cjs +19 -29
  89. package/dist/harmony124.cjs.map +1 -1
  90. package/dist/harmony124.mjs +18 -28
  91. package/dist/harmony124.mjs.map +1 -1
  92. package/dist/harmony129.cjs +1 -1
  93. package/dist/harmony129.mjs +1 -1
  94. package/dist/harmony13.cjs +1 -1
  95. package/dist/harmony13.mjs +1 -1
  96. package/dist/harmony140.cjs +1 -1
  97. package/dist/harmony140.mjs +1 -1
  98. package/dist/harmony16.cjs +1 -1
  99. package/dist/harmony16.mjs +1 -1
  100. package/dist/harmony23.cjs +1 -1
  101. package/dist/harmony23.mjs +1 -1
  102. package/dist/harmony24.cjs +1 -1
  103. package/dist/harmony24.mjs +1 -1
  104. package/dist/harmony27.cjs +1 -1
  105. package/dist/harmony27.cjs.map +1 -1
  106. package/dist/harmony27.mjs +1 -1
  107. package/dist/harmony27.mjs.map +1 -1
  108. package/dist/harmony31.cjs +4 -4
  109. package/dist/harmony31.cjs.map +1 -1
  110. package/dist/harmony31.mjs +5 -5
  111. package/dist/harmony31.mjs.map +1 -1
  112. package/dist/harmony38.cjs.map +1 -1
  113. package/dist/harmony38.mjs.map +1 -1
  114. package/dist/harmony40.cjs.map +1 -1
  115. package/dist/harmony40.mjs.map +1 -1
  116. package/dist/harmony44.cjs.map +1 -1
  117. package/dist/harmony44.mjs.map +1 -1
  118. package/dist/harmony64.cjs +4 -15
  119. package/dist/harmony64.cjs.map +1 -1
  120. package/dist/harmony64.mjs +4 -15
  121. package/dist/harmony64.mjs.map +1 -1
  122. package/dist/harmony74.cjs +1 -1
  123. package/dist/harmony74.mjs +1 -1
  124. package/dist/harmony75.cjs +1 -1
  125. package/dist/harmony75.mjs +1 -1
  126. package/dist/harmony76.cjs +1 -1
  127. package/dist/harmony76.mjs +1 -1
  128. package/dist/harmony77.cjs +2 -2
  129. package/dist/harmony77.mjs +2 -2
  130. package/dist/harmony78.cjs +2 -2
  131. package/dist/harmony78.mjs +2 -2
  132. package/dist/harmony79.cjs +2 -2
  133. package/dist/harmony79.mjs +2 -2
  134. package/dist/harmony80.cjs +2 -2
  135. package/dist/harmony80.mjs +2 -2
  136. package/dist/harmony81.cjs +3 -3
  137. package/dist/harmony81.mjs +3 -3
  138. package/dist/harmony82.cjs +6 -6
  139. package/dist/harmony82.mjs +6 -6
  140. package/dist/harmony85.cjs +2 -2
  141. package/dist/harmony85.mjs +2 -2
  142. package/dist/harmony87.cjs +2 -2
  143. package/dist/harmony87.mjs +2 -2
  144. package/dist/harmony88.cjs +12 -6
  145. package/dist/harmony88.cjs.map +1 -1
  146. package/dist/harmony88.mjs +11 -5
  147. package/dist/harmony88.mjs.map +1 -1
  148. package/dist/harmony89.cjs +9 -6
  149. package/dist/harmony89.cjs.map +1 -1
  150. package/dist/harmony89.mjs +9 -6
  151. package/dist/harmony89.mjs.map +1 -1
  152. package/dist/harmony90.cjs +12 -10
  153. package/dist/harmony90.cjs.map +1 -1
  154. package/dist/harmony90.mjs +11 -9
  155. package/dist/harmony90.mjs.map +1 -1
  156. package/dist/harmony91.cjs +21 -57
  157. package/dist/harmony91.cjs.map +1 -1
  158. package/dist/harmony91.mjs +20 -56
  159. package/dist/harmony91.mjs.map +1 -1
  160. package/dist/harmony92.cjs +6 -42
  161. package/dist/harmony92.cjs.map +1 -1
  162. package/dist/harmony92.mjs +5 -41
  163. package/dist/harmony92.mjs.map +1 -1
  164. package/dist/harmony93.cjs +10 -6
  165. package/dist/harmony93.cjs.map +1 -1
  166. package/dist/harmony93.mjs +9 -5
  167. package/dist/harmony93.mjs.map +1 -1
  168. package/dist/harmony94.cjs +6 -6
  169. package/dist/harmony94.mjs +6 -6
  170. package/dist/harmony95.cjs +57 -24
  171. package/dist/harmony95.cjs.map +1 -1
  172. package/dist/harmony95.mjs +56 -23
  173. package/dist/harmony95.mjs.map +1 -1
  174. package/dist/harmony96.cjs +42 -6
  175. package/dist/harmony96.cjs.map +1 -1
  176. package/dist/harmony96.mjs +41 -5
  177. package/dist/harmony96.mjs.map +1 -1
  178. package/dist/harmony97.cjs +5 -21
  179. package/dist/harmony97.cjs.map +1 -1
  180. package/dist/harmony97.mjs +5 -21
  181. package/dist/harmony97.mjs.map +1 -1
  182. package/dist/harmony98.cjs +4 -7
  183. package/dist/harmony98.cjs.map +1 -1
  184. package/dist/harmony98.mjs +4 -7
  185. package/dist/harmony98.mjs.map +1 -1
  186. package/dist/harmony99.cjs +24 -12
  187. package/dist/harmony99.cjs.map +1 -1
  188. package/dist/harmony99.mjs +23 -11
  189. package/dist/harmony99.mjs.map +1 -1
  190. package/dist/types/src/features/publicApi/hooks/useCreateScoreMutation.d.ts +2 -2
  191. package/dist/types/src/features/publicApi/hooks/useDeleteScoreMutation.d.ts +2 -2
  192. package/dist/types/src/features/publicApi/hooks/useGetScoreQuery.d.ts +4 -3
  193. package/dist/types/src/features/publicApi/score.d.ts +8 -4
  194. package/dist/types/src/features/publicApi/types/scoreTypes.d.ts +8 -33
  195. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"harmony110.mjs","sources":["../src/components/Sidebar/Widgets/Tasks/TasksProvider.tsx"],"sourcesContent":["import { useEffectOnce } from '@utils'\nimport { type FC, type PropsWithChildren, useState } from 'react'\nimport { TasksContext } from './TasksContext'\nimport type { SidebarTask, SidebarTasksConfig, SidebarTasksContextProps } from './types'\nimport { TaskEvents } from './utils/taskEvents'\n\ntype TasksProviderProps = PropsWithChildren<{\n\tconfig: SidebarTasksConfig\n}>\n\nexport const TasksProvider = ({ children, config }: TasksProviderProps) => {\n\tconst [tasks, setTasks] = useState<SidebarTask[]>([])\n\tconst [loadingTasks, setLoadingTasks] = useState(true)\n\n\tconst [tasksCount, setTaskCount] = useState(0)\n\n\tconst {\n\t\tgetProjectUrl,\n\t\tonLanguageCompleteConfirm,\n\t\tonTasksWidgetOpen,\n\t\tlangNameOnClick,\n\t\tlangProgressOnClick,\n\t\ttaskTitleOnClick,\n\t} = config\n\n\tconst { getTasks, getTasksCount } = config\n\n\tconst fetchTasks = async () => {\n\t\tsetLoadingTasks(true)\n\t\tconst result = await getTasks()\n\t\tsetTasks(result)\n\t\tsetLoadingTasks(false)\n\t\treturn result\n\t}\n\n\tconst fetchTaskCount = async () => {\n\t\tconst result = await getTasksCount()\n\t\tsetTaskCount(result)\n\t}\n\n\tuseEffectOnce(() => {\n\t\tfetchTaskCount()\n\n\t\tdocument.addEventListener(TaskEvents.TaskCompleted, fetchTaskCount)\n\t\tdocument.addEventListener(TaskEvents.TaskClosed, fetchTaskCount)\n\t\tdocument.addEventListener(TaskEvents.Refresh, fetchTaskCount)\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(TaskEvents.TaskCompleted, fetchTaskCount)\n\t\t\tdocument.removeEventListener(TaskEvents.TaskClosed, fetchTaskCount)\n\t\t\tdocument.removeEventListener(TaskEvents.Refresh, fetchTaskCount)\n\t\t}\n\t})\n\n\tconst providerValue: SidebarTasksContextProps = {\n\t\tfetchTasks,\n\t\ttasks,\n\t\ttasksCount,\n\t\tloadingTasks,\n\t\tgetProjectUrl,\n\t\tonLanguageCompleteConfirm,\n\t\tonTasksWidgetOpen,\n\t\tlangNameOnClick,\n\t\tlangProgressOnClick,\n\t\ttaskTitleOnClick,\n\t}\n\n\treturn <TasksContext.Provider value={providerValue}>{children}</TasksContext.Provider>\n}\n\nexport const withTasksContext = <P extends { config: SidebarTasksConfig }>(\n\tWrappedComponent: FC<Omit<P, 'config'>>,\n) =>\n\tfunction withTasksContextFn(props: P) {\n\t\tconst { config, ...rest } = props\n\n\t\treturn (\n\t\t\t<TasksProvider config={config}>\n\t\t\t\t<WrappedComponent {...rest} />\n\t\t\t</TasksProvider>\n\t\t)\n\t}\n"],"names":[],"mappings":";;;;;AAUO,MAAM,gBAAgB,CAAC,EAAE,UAAU,aAAiC;AAC1E,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,CAAA,CAAE;AACpD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,IAAI;AAErD,QAAM,CAAC,YAAY,YAAY,IAAI,SAAS,CAAC;AAEvC,QAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACG;AAEE,QAAA,EAAE,UAAU,cAAA,IAAkB;AAEpC,QAAM,aAAa,YAAY;AAC9B,oBAAgB,IAAI;AACd,UAAA,SAAS,MAAM,SAAS;AAC9B,aAAS,MAAM;AACf,oBAAgB,KAAK;AACd,WAAA;AAAA,EACR;AAEA,QAAM,iBAAiB,YAAY;AAC5B,UAAA,SAAS,MAAM,cAAc;AACnC,iBAAa,MAAM;AAAA,EACpB;AAEA,gBAAc,MAAM;AACJ,mBAAA;AAEN,aAAA,iBAAiB,WAAW,eAAe,cAAc;AACzD,aAAA,iBAAiB,WAAW,YAAY,cAAc;AACtD,aAAA,iBAAiB,WAAW,SAAS,cAAc;AAE5D,WAAO,MAAM;AACH,eAAA,oBAAoB,WAAW,eAAe,cAAc;AAC5D,eAAA,oBAAoB,WAAW,YAAY,cAAc;AACzD,eAAA,oBAAoB,WAAW,SAAS,cAAc;AAAA,IAChE;AAAA,EAAA,CACA;AAED,QAAM,gBAA0C;AAAA,IAC/C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,6BAAQ,aAAa,UAAb,EAAsB,OAAO,eAAgB,UAAS;AAC/D;AAEO,MAAM,mBAAmB,CAC/B,qBAEA,SAAS,mBAAmB,OAAU;AACrC,QAAM,EAAE,QAAQ,GAAG,KAAA,IAAS;AAE5B,6BACE,eAAc,EAAA,QACd,8BAAC,kBAAkB,EAAA,GAAG,KAAM,CAAA,GAC7B;AAEF;"}
1
+ {"version":3,"file":"harmony110.mjs","sources":["../src/components/Sidebar/Widgets/Tasks/TasksContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react'\nimport type { SidebarTasksContextProps } from './types'\n\nexport const TasksContext = createContext({} as SidebarTasksContextProps)\n\nexport const useTasks = () => useContext(TasksContext)\n"],"names":[],"mappings":";AAGa,MAAA,eAAe,cAAc,CAA8B,CAAA;AAE3D,MAAA,WAAW,MAAM,WAAW,YAAY;"}
@@ -1,10 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const TaskEvents = {
4
- TaskCompleted: "task_completed",
5
- TaskClosed: "task_closed",
6
- Refresh: "refresh",
7
- ShowDialog: "show_dialog"
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const louis = require("@lokalise/louis");
5
+ const useEffectOnce = require("./harmony12.cjs");
6
+ const TaskOverview = require("./harmony123.cjs");
7
+ const TasksContext = require("./harmony110.cjs");
8
+ const taskEvents = require("./harmony113.cjs");
9
+ const TasksPopover_module = require("./harmony124.cjs");
10
+ const TasksPopover = () => {
11
+ const { tasks, onTasksWidgetOpen, loadingTasks, fetchTasks } = TasksContext.useTasks();
12
+ useEffectOnce.useEffectOnce(() => {
13
+ const handleTaskPopoverOpen = async () => {
14
+ const contextTasks = await fetchTasks();
15
+ onTasksWidgetOpen == null ? void 0 : onTasksWidgetOpen({ tasks: contextTasks });
16
+ };
17
+ handleTaskPopoverOpen();
18
+ document.addEventListener(taskEvents.TaskEvents.TaskCompleted, fetchTasks);
19
+ document.addEventListener(taskEvents.TaskEvents.TaskClosed, fetchTasks);
20
+ document.addEventListener(taskEvents.TaskEvents.Refresh, fetchTasks);
21
+ return () => {
22
+ document.removeEventListener(taskEvents.TaskEvents.TaskCompleted, fetchTasks);
23
+ document.removeEventListener(taskEvents.TaskEvents.TaskClosed, fetchTasks);
24
+ document.removeEventListener(taskEvents.TaskEvents.Refresh, fetchTasks);
25
+ };
26
+ });
27
+ if (loadingTasks) {
28
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "sidebar-tasks-loading-popover", className: TasksPopover_module.default.loadingContainer, children: /* @__PURE__ */ jsxRuntime.jsx(louis.Loading, {}) });
29
+ }
30
+ if (tasks.length === 0) {
31
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-testid": "sidebar-no-tasks-popover", className: TasksPopover_module.default.noTasksContainer, children: [
32
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: TasksPopover_module.default.noTasksHeading, children: "No tasks" }),
33
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: TasksPopover_module.default.noTasksText, children: [
34
+ "Your incoming tasks will appear here.",
35
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
36
+ /* @__PURE__ */ jsxRuntime.jsx(louis.Link, { href: "https://docs.lokalise.com/translation-workflow/tasks", target: "_new", children: "Learn more" })
37
+ ] })
38
+ ] });
39
+ }
40
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "sidebar-tasks-popover", className: TasksPopover_module.default.tasksContainer, children: tasks.map((task) => /* @__PURE__ */ jsxRuntime.jsx(TaskOverview.TaskOverview, { task }, task.id)) });
8
41
  };
9
- exports.TaskEvents = TaskEvents;
42
+ exports.TasksPopover = TasksPopover;
10
43
  //# sourceMappingURL=harmony111.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harmony111.cjs","sources":["../src/components/Sidebar/Widgets/Tasks/utils/taskEvents.ts"],"sourcesContent":["import type { TypesFromMap } from '@utils'\n\nexport const TaskEvents = {\n\tTaskCompleted: 'task_completed',\n\tTaskClosed: 'task_closed',\n\tRefresh: 'refresh',\n\tShowDialog: 'show_dialog',\n} as const\n\nexport type TaskEvent = TypesFromMap<typeof TaskEvents>\n\ntype SingleTaskPayload = {\n\ttaskId: string | number\n}\n\ntype DispatchTaskEventPayload =\n\t| {\n\t\t\tname: typeof TaskEvents.TaskCompleted\n\t\t\tdetail: SingleTaskPayload\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.TaskClosed\n\t\t\tdetail: SingleTaskPayload\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.Refresh\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.ShowDialog\n\t }\n\nexport const dispatchTaskEvent = (props: DispatchTaskEventPayload) => {\n\tconst { name } = props\n\tdocument.dispatchEvent(new CustomEvent(name, { detail: 'detail' in props ? props.detail : {} }))\n}\n"],"names":[],"mappings":";;AAEO,MAAM,aAAa;AAAA,EACzB,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,YAAY;AACb;;"}
1
+ {"version":3,"file":"harmony111.cjs","sources":["../src/components/Sidebar/Widgets/Tasks/TasksPopover/TasksPopover.tsx"],"sourcesContent":["import { Link, Loading } from '@lokalise/louis'\nimport { useEffectOnce } from '@utils'\nimport { TaskOverview } from '../TaskOverview/TaskOverview'\nimport { useTasks } from '../TasksContext'\nimport type { SidebarTask } from '../types'\nimport { TaskEvents } from '../utils/taskEvents'\nimport styles from './TasksPopover.module.css'\n\nexport const TasksPopover = () => {\n\tconst { tasks, onTasksWidgetOpen, loadingTasks, fetchTasks } = useTasks()\n\n\tuseEffectOnce(() => {\n\t\tconst handleTaskPopoverOpen = async () => {\n\t\t\tconst contextTasks = await fetchTasks()\n\t\t\tonTasksWidgetOpen?.({ tasks: contextTasks })\n\t\t}\n\n\t\thandleTaskPopoverOpen()\n\n\t\tdocument.addEventListener(TaskEvents.TaskCompleted, fetchTasks)\n\t\tdocument.addEventListener(TaskEvents.TaskClosed, fetchTasks)\n\t\tdocument.addEventListener(TaskEvents.Refresh, fetchTasks)\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(TaskEvents.TaskCompleted, fetchTasks)\n\t\t\tdocument.removeEventListener(TaskEvents.TaskClosed, fetchTasks)\n\t\t\tdocument.removeEventListener(TaskEvents.Refresh, fetchTasks)\n\t\t}\n\t})\n\n\tif (loadingTasks) {\n\t\treturn (\n\t\t\t<div data-testid=\"sidebar-tasks-loading-popover\" className={styles.loadingContainer}>\n\t\t\t\t<Loading />\n\t\t\t</div>\n\t\t)\n\t}\n\n\tif (tasks.length === 0) {\n\t\treturn (\n\t\t\t<div data-testid=\"sidebar-no-tasks-popover\" className={styles.noTasksContainer}>\n\t\t\t\t<h3 className={styles.noTasksHeading}>No tasks</h3>\n\t\t\t\t<div className={styles.noTasksText}>\n\t\t\t\t\tYour incoming tasks will appear here.\n\t\t\t\t\t<br />\n\t\t\t\t\t<Link href=\"https://docs.lokalise.com/translation-workflow/tasks\" target=\"_new\">\n\t\t\t\t\t\tLearn more\n\t\t\t\t\t</Link>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t)\n\t}\n\n\treturn (\n\t\t<div data-testid=\"sidebar-tasks-popover\" className={styles.tasksContainer}>\n\t\t\t{tasks.map((task: SidebarTask) => (\n\t\t\t\t<TaskOverview key={task.id} task={task} />\n\t\t\t))}\n\t\t</div>\n\t)\n}\n"],"names":["useTasks","useEffectOnce","TaskEvents","jsx","styles","Loading","jsxs","Link","TaskOverview"],"mappings":";;;;;;;;;AAQO,MAAM,eAAe,MAAM;AACjC,QAAM,EAAE,OAAO,mBAAmB,cAAc,WAAA,IAAeA,aAAAA,SAAS;AAExEC,gBAAAA,cAAc,MAAM;AACnB,UAAM,wBAAwB,YAAY;AACnC,YAAA,eAAe,MAAM,WAAW;AAClB,6DAAA,EAAE,OAAO;IAC9B;AAEsB,0BAAA;AAEb,aAAA,iBAAiBC,sBAAW,eAAe,UAAU;AACrD,aAAA,iBAAiBA,sBAAW,YAAY,UAAU;AAClD,aAAA,iBAAiBA,sBAAW,SAAS,UAAU;AAExD,WAAO,MAAM;AACH,eAAA,oBAAoBA,sBAAW,eAAe,UAAU;AACxD,eAAA,oBAAoBA,sBAAW,YAAY,UAAU;AACrD,eAAA,oBAAoBA,sBAAW,SAAS,UAAU;AAAA,IAC5D;AAAA,EAAA,CACA;AAED,MAAI,cAAc;AAEhB,WAAAC,2BAAA,IAAC,SAAI,eAAY,iCAAgC,WAAWC,4BAAO,kBAClE,UAACD,2BAAAA,IAAAE,MAAAA,SAAA,CAAA,CAAQ,EACV,CAAA;AAAA,EAAA;AAIE,MAAA,MAAM,WAAW,GAAG;AACvB,2CACE,OAAI,EAAA,eAAY,4BAA2B,WAAWD,oBAAAA,QAAO,kBAC7D,UAAA;AAAA,MAAAD,2BAAA,IAAC,MAAG,EAAA,WAAWC,oBAAO,QAAA,gBAAgB,UAAQ,YAAA;AAAA,MAC7CE,2BAAA,KAAA,OAAA,EAAI,WAAWF,oBAAAA,QAAO,aAAa,UAAA;AAAA,QAAA;AAAA,uCAElC,MAAG,EAAA;AAAA,uCACHG,MAAAA,MAAK,EAAA,MAAK,wDAAuD,QAAO,QAAO,UAEhF,aAAA,CAAA;AAAA,MAAA,EACD,CAAA;AAAA,IAAA,GACD;AAAA,EAAA;AAIF,wCACE,OAAI,EAAA,eAAY,yBAAwB,WAAWH,oBAAAA,QAAO,gBACzD,UAAA,MAAM,IAAI,CAAC,SACVD,2BAAA,IAAAK,2BAAA,EAA2B,QAAT,KAAK,EAAgB,CACxC,GACF;AAEF;;"}
@@ -1,10 +1,43 @@
1
- const TaskEvents = {
2
- TaskCompleted: "task_completed",
3
- TaskClosed: "task_closed",
4
- Refresh: "refresh",
5
- ShowDialog: "show_dialog"
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Loading, Link } from "@lokalise/louis";
3
+ import { useEffectOnce } from "./harmony12.mjs";
4
+ import { TaskOverview } from "./harmony123.mjs";
5
+ import { useTasks } from "./harmony110.mjs";
6
+ import { TaskEvents } from "./harmony113.mjs";
7
+ import styles from "./harmony124.mjs";
8
+ const TasksPopover = () => {
9
+ const { tasks, onTasksWidgetOpen, loadingTasks, fetchTasks } = useTasks();
10
+ useEffectOnce(() => {
11
+ const handleTaskPopoverOpen = async () => {
12
+ const contextTasks = await fetchTasks();
13
+ onTasksWidgetOpen == null ? void 0 : onTasksWidgetOpen({ tasks: contextTasks });
14
+ };
15
+ handleTaskPopoverOpen();
16
+ document.addEventListener(TaskEvents.TaskCompleted, fetchTasks);
17
+ document.addEventListener(TaskEvents.TaskClosed, fetchTasks);
18
+ document.addEventListener(TaskEvents.Refresh, fetchTasks);
19
+ return () => {
20
+ document.removeEventListener(TaskEvents.TaskCompleted, fetchTasks);
21
+ document.removeEventListener(TaskEvents.TaskClosed, fetchTasks);
22
+ document.removeEventListener(TaskEvents.Refresh, fetchTasks);
23
+ };
24
+ });
25
+ if (loadingTasks) {
26
+ return /* @__PURE__ */ jsx("div", { "data-testid": "sidebar-tasks-loading-popover", className: styles.loadingContainer, children: /* @__PURE__ */ jsx(Loading, {}) });
27
+ }
28
+ if (tasks.length === 0) {
29
+ return /* @__PURE__ */ jsxs("div", { "data-testid": "sidebar-no-tasks-popover", className: styles.noTasksContainer, children: [
30
+ /* @__PURE__ */ jsx("h3", { className: styles.noTasksHeading, children: "No tasks" }),
31
+ /* @__PURE__ */ jsxs("div", { className: styles.noTasksText, children: [
32
+ "Your incoming tasks will appear here.",
33
+ /* @__PURE__ */ jsx("br", {}),
34
+ /* @__PURE__ */ jsx(Link, { href: "https://docs.lokalise.com/translation-workflow/tasks", target: "_new", children: "Learn more" })
35
+ ] })
36
+ ] });
37
+ }
38
+ return /* @__PURE__ */ jsx("div", { "data-testid": "sidebar-tasks-popover", className: styles.tasksContainer, children: tasks.map((task) => /* @__PURE__ */ jsx(TaskOverview, { task }, task.id)) });
6
39
  };
7
40
  export {
8
- TaskEvents
41
+ TasksPopover
9
42
  };
10
43
  //# sourceMappingURL=harmony111.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harmony111.mjs","sources":["../src/components/Sidebar/Widgets/Tasks/utils/taskEvents.ts"],"sourcesContent":["import type { TypesFromMap } from '@utils'\n\nexport const TaskEvents = {\n\tTaskCompleted: 'task_completed',\n\tTaskClosed: 'task_closed',\n\tRefresh: 'refresh',\n\tShowDialog: 'show_dialog',\n} as const\n\nexport type TaskEvent = TypesFromMap<typeof TaskEvents>\n\ntype SingleTaskPayload = {\n\ttaskId: string | number\n}\n\ntype DispatchTaskEventPayload =\n\t| {\n\t\t\tname: typeof TaskEvents.TaskCompleted\n\t\t\tdetail: SingleTaskPayload\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.TaskClosed\n\t\t\tdetail: SingleTaskPayload\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.Refresh\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.ShowDialog\n\t }\n\nexport const dispatchTaskEvent = (props: DispatchTaskEventPayload) => {\n\tconst { name } = props\n\tdocument.dispatchEvent(new CustomEvent(name, { detail: 'detail' in props ? props.detail : {} }))\n}\n"],"names":[],"mappings":"AAEO,MAAM,aAAa;AAAA,EACzB,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,YAAY;AACb;"}
1
+ {"version":3,"file":"harmony111.mjs","sources":["../src/components/Sidebar/Widgets/Tasks/TasksPopover/TasksPopover.tsx"],"sourcesContent":["import { Link, Loading } from '@lokalise/louis'\nimport { useEffectOnce } from '@utils'\nimport { TaskOverview } from '../TaskOverview/TaskOverview'\nimport { useTasks } from '../TasksContext'\nimport type { SidebarTask } from '../types'\nimport { TaskEvents } from '../utils/taskEvents'\nimport styles from './TasksPopover.module.css'\n\nexport const TasksPopover = () => {\n\tconst { tasks, onTasksWidgetOpen, loadingTasks, fetchTasks } = useTasks()\n\n\tuseEffectOnce(() => {\n\t\tconst handleTaskPopoverOpen = async () => {\n\t\t\tconst contextTasks = await fetchTasks()\n\t\t\tonTasksWidgetOpen?.({ tasks: contextTasks })\n\t\t}\n\n\t\thandleTaskPopoverOpen()\n\n\t\tdocument.addEventListener(TaskEvents.TaskCompleted, fetchTasks)\n\t\tdocument.addEventListener(TaskEvents.TaskClosed, fetchTasks)\n\t\tdocument.addEventListener(TaskEvents.Refresh, fetchTasks)\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(TaskEvents.TaskCompleted, fetchTasks)\n\t\t\tdocument.removeEventListener(TaskEvents.TaskClosed, fetchTasks)\n\t\t\tdocument.removeEventListener(TaskEvents.Refresh, fetchTasks)\n\t\t}\n\t})\n\n\tif (loadingTasks) {\n\t\treturn (\n\t\t\t<div data-testid=\"sidebar-tasks-loading-popover\" className={styles.loadingContainer}>\n\t\t\t\t<Loading />\n\t\t\t</div>\n\t\t)\n\t}\n\n\tif (tasks.length === 0) {\n\t\treturn (\n\t\t\t<div data-testid=\"sidebar-no-tasks-popover\" className={styles.noTasksContainer}>\n\t\t\t\t<h3 className={styles.noTasksHeading}>No tasks</h3>\n\t\t\t\t<div className={styles.noTasksText}>\n\t\t\t\t\tYour incoming tasks will appear here.\n\t\t\t\t\t<br />\n\t\t\t\t\t<Link href=\"https://docs.lokalise.com/translation-workflow/tasks\" target=\"_new\">\n\t\t\t\t\t\tLearn more\n\t\t\t\t\t</Link>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t)\n\t}\n\n\treturn (\n\t\t<div data-testid=\"sidebar-tasks-popover\" className={styles.tasksContainer}>\n\t\t\t{tasks.map((task: SidebarTask) => (\n\t\t\t\t<TaskOverview key={task.id} task={task} />\n\t\t\t))}\n\t\t</div>\n\t)\n}\n"],"names":[],"mappings":";;;;;;;AAQO,MAAM,eAAe,MAAM;AACjC,QAAM,EAAE,OAAO,mBAAmB,cAAc,WAAA,IAAe,SAAS;AAExE,gBAAc,MAAM;AACnB,UAAM,wBAAwB,YAAY;AACnC,YAAA,eAAe,MAAM,WAAW;AAClB,6DAAA,EAAE,OAAO;IAC9B;AAEsB,0BAAA;AAEb,aAAA,iBAAiB,WAAW,eAAe,UAAU;AACrD,aAAA,iBAAiB,WAAW,YAAY,UAAU;AAClD,aAAA,iBAAiB,WAAW,SAAS,UAAU;AAExD,WAAO,MAAM;AACH,eAAA,oBAAoB,WAAW,eAAe,UAAU;AACxD,eAAA,oBAAoB,WAAW,YAAY,UAAU;AACrD,eAAA,oBAAoB,WAAW,SAAS,UAAU;AAAA,IAC5D;AAAA,EAAA,CACA;AAED,MAAI,cAAc;AAEhB,WAAA,oBAAC,SAAI,eAAY,iCAAgC,WAAW,OAAO,kBAClE,UAAC,oBAAA,SAAA,CAAA,CAAQ,EACV,CAAA;AAAA,EAAA;AAIE,MAAA,MAAM,WAAW,GAAG;AACvB,gCACE,OAAI,EAAA,eAAY,4BAA2B,WAAW,OAAO,kBAC7D,UAAA;AAAA,MAAA,oBAAC,MAAG,EAAA,WAAW,OAAO,gBAAgB,UAAQ,YAAA;AAAA,MAC7C,qBAAA,OAAA,EAAI,WAAW,OAAO,aAAa,UAAA;AAAA,QAAA;AAAA,4BAElC,MAAG,EAAA;AAAA,4BACH,MAAK,EAAA,MAAK,wDAAuD,QAAO,QAAO,UAEhF,aAAA,CAAA;AAAA,MAAA,EACD,CAAA;AAAA,IAAA,GACD;AAAA,EAAA;AAIF,6BACE,OAAI,EAAA,eAAY,yBAAwB,WAAW,OAAO,gBACzD,UAAA,MAAM,IAAI,CAAC,SACV,oBAAA,cAAA,EAA2B,QAAT,KAAK,EAAgB,CACxC,GACF;AAEF;"}
@@ -1,17 +1,63 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const jwtTokenPayload = require("./harmony16.cjs");
7
- const _NewJwtIssuedEvent = class _NewJwtIssuedEvent extends CustomEvent {
8
- constructor(token) {
9
- super(_NewJwtIssuedEvent.eventName, {
10
- detail: { token, payload: jwtTokenPayload.parseJwtTokenPayload(token.accessToken) }
11
- });
12
- }
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const useEffectOnce = require("./harmony12.cjs");
5
+ const React = require("react");
6
+ const TasksContext = require("./harmony110.cjs");
7
+ const taskEvents = require("./harmony113.cjs");
8
+ const TasksProvider = ({ children, config }) => {
9
+ const [tasks, setTasks] = React.useState([]);
10
+ const [loadingTasks, setLoadingTasks] = React.useState(true);
11
+ const [tasksCount, setTaskCount] = React.useState(0);
12
+ const {
13
+ getProjectUrl,
14
+ onLanguageCompleteConfirm,
15
+ onTasksWidgetOpen,
16
+ langNameOnClick,
17
+ langProgressOnClick,
18
+ taskTitleOnClick
19
+ } = config;
20
+ const { getTasks, getTasksCount } = config;
21
+ const fetchTasks = async () => {
22
+ setLoadingTasks(true);
23
+ const result = await getTasks();
24
+ setTasks(result);
25
+ setLoadingTasks(false);
26
+ return result;
27
+ };
28
+ const fetchTaskCount = async () => {
29
+ const result = await getTasksCount();
30
+ setTaskCount(result);
31
+ };
32
+ useEffectOnce.useEffectOnce(() => {
33
+ fetchTaskCount();
34
+ document.addEventListener(taskEvents.TaskEvents.TaskCompleted, fetchTaskCount);
35
+ document.addEventListener(taskEvents.TaskEvents.TaskClosed, fetchTaskCount);
36
+ document.addEventListener(taskEvents.TaskEvents.Refresh, fetchTaskCount);
37
+ return () => {
38
+ document.removeEventListener(taskEvents.TaskEvents.TaskCompleted, fetchTaskCount);
39
+ document.removeEventListener(taskEvents.TaskEvents.TaskClosed, fetchTaskCount);
40
+ document.removeEventListener(taskEvents.TaskEvents.Refresh, fetchTaskCount);
41
+ };
42
+ });
43
+ const providerValue = {
44
+ fetchTasks,
45
+ tasks,
46
+ tasksCount,
47
+ loadingTasks,
48
+ getProjectUrl,
49
+ onLanguageCompleteConfirm,
50
+ onTasksWidgetOpen,
51
+ langNameOnClick,
52
+ langProgressOnClick,
53
+ taskTitleOnClick
54
+ };
55
+ return /* @__PURE__ */ jsxRuntime.jsx(TasksContext.TasksContext.Provider, { value: providerValue, children });
13
56
  };
14
- __publicField(_NewJwtIssuedEvent, "eventName", "new-jwt-issued");
15
- let NewJwtIssuedEvent = _NewJwtIssuedEvent;
16
- exports.NewJwtIssuedEvent = NewJwtIssuedEvent;
57
+ const withTasksContext = (WrappedComponent) => function withTasksContextFn(props) {
58
+ const { config, ...rest } = props;
59
+ return /* @__PURE__ */ jsxRuntime.jsx(TasksProvider, { config, children: /* @__PURE__ */ jsxRuntime.jsx(WrappedComponent, { ...rest }) });
60
+ };
61
+ exports.TasksProvider = TasksProvider;
62
+ exports.withTasksContext = withTasksContext;
17
63
  //# sourceMappingURL=harmony112.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harmony112.cjs","sources":["../src/features/auth/frontend/events/NewJwtIssuedEvent.ts"],"sourcesContent":["import type { JwtTokenPayload } from '@features/auth/core/types/jwtTokenPayload'\nimport { parseJwtTokenPayload } from '@features/auth/core/utils/jwtTokenPayload'\nimport type { JwtToken } from '@features/publicApi/types/userTokenTypes'\n\ntype NewJwtIssuedEventDetail = {\n\ttoken: JwtToken\n\tpayload: JwtTokenPayload | undefined\n}\n\n/**\n * This event is emitted when a new JWT token is issued or refreshed.\n */\nexport class NewJwtIssuedEvent extends CustomEvent<NewJwtIssuedEventDetail> {\n\tstatic readonly eventName = 'new-jwt-issued' as const\n\n\tconstructor(token: JwtToken) {\n\t\tsuper(NewJwtIssuedEvent.eventName, {\n\t\t\tdetail: { token, payload: parseJwtTokenPayload(token.accessToken) },\n\t\t})\n\t}\n}\n\nexport const isNewJwtIssuedEvent = (event: Event): event is NewJwtIssuedEvent =>\n\tevent.type === NewJwtIssuedEvent.eventName\n\ndeclare global {\n\tinterface WindowEventMap {\n\t\t[NewJwtIssuedEvent.eventName]: NewJwtIssuedEvent\n\t}\n}\n"],"names":["parseJwtTokenPayload"],"mappings":";;;;;;AAYO,MAAM,qBAAN,MAAM,2BAA0B,YAAqC;AAAA,EAG3E,YAAY,OAAiB;AAC5B,UAAM,mBAAkB,WAAW;AAAA,MAClC,QAAQ,EAAE,OAAO,SAASA,gBAAAA,qBAAqB,MAAM,WAAW,EAAE;AAAA,IAAA,CAClE;AAAA,EAAA;AAEH;AAPC,cADY,oBACI,aAAY;AADtB,IAAM,oBAAN;;"}
1
+ {"version":3,"file":"harmony112.cjs","sources":["../src/components/Sidebar/Widgets/Tasks/TasksProvider.tsx"],"sourcesContent":["import { useEffectOnce } from '@utils'\nimport { type FC, type PropsWithChildren, useState } from 'react'\nimport { TasksContext } from './TasksContext'\nimport type { SidebarTask, SidebarTasksConfig, SidebarTasksContextProps } from './types'\nimport { TaskEvents } from './utils/taskEvents'\n\ntype TasksProviderProps = PropsWithChildren<{\n\tconfig: SidebarTasksConfig\n}>\n\nexport const TasksProvider = ({ children, config }: TasksProviderProps) => {\n\tconst [tasks, setTasks] = useState<SidebarTask[]>([])\n\tconst [loadingTasks, setLoadingTasks] = useState(true)\n\n\tconst [tasksCount, setTaskCount] = useState(0)\n\n\tconst {\n\t\tgetProjectUrl,\n\t\tonLanguageCompleteConfirm,\n\t\tonTasksWidgetOpen,\n\t\tlangNameOnClick,\n\t\tlangProgressOnClick,\n\t\ttaskTitleOnClick,\n\t} = config\n\n\tconst { getTasks, getTasksCount } = config\n\n\tconst fetchTasks = async () => {\n\t\tsetLoadingTasks(true)\n\t\tconst result = await getTasks()\n\t\tsetTasks(result)\n\t\tsetLoadingTasks(false)\n\t\treturn result\n\t}\n\n\tconst fetchTaskCount = async () => {\n\t\tconst result = await getTasksCount()\n\t\tsetTaskCount(result)\n\t}\n\n\tuseEffectOnce(() => {\n\t\tfetchTaskCount()\n\n\t\tdocument.addEventListener(TaskEvents.TaskCompleted, fetchTaskCount)\n\t\tdocument.addEventListener(TaskEvents.TaskClosed, fetchTaskCount)\n\t\tdocument.addEventListener(TaskEvents.Refresh, fetchTaskCount)\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(TaskEvents.TaskCompleted, fetchTaskCount)\n\t\t\tdocument.removeEventListener(TaskEvents.TaskClosed, fetchTaskCount)\n\t\t\tdocument.removeEventListener(TaskEvents.Refresh, fetchTaskCount)\n\t\t}\n\t})\n\n\tconst providerValue: SidebarTasksContextProps = {\n\t\tfetchTasks,\n\t\ttasks,\n\t\ttasksCount,\n\t\tloadingTasks,\n\t\tgetProjectUrl,\n\t\tonLanguageCompleteConfirm,\n\t\tonTasksWidgetOpen,\n\t\tlangNameOnClick,\n\t\tlangProgressOnClick,\n\t\ttaskTitleOnClick,\n\t}\n\n\treturn <TasksContext.Provider value={providerValue}>{children}</TasksContext.Provider>\n}\n\nexport const withTasksContext = <P extends { config: SidebarTasksConfig }>(\n\tWrappedComponent: FC<Omit<P, 'config'>>,\n) =>\n\tfunction withTasksContextFn(props: P) {\n\t\tconst { config, ...rest } = props\n\n\t\treturn (\n\t\t\t<TasksProvider config={config}>\n\t\t\t\t<WrappedComponent {...rest} />\n\t\t\t</TasksProvider>\n\t\t)\n\t}\n"],"names":["useState","useEffectOnce","TaskEvents","TasksContext"],"mappings":";;;;;;;AAUO,MAAM,gBAAgB,CAAC,EAAE,UAAU,aAAiC;AAC1E,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAwB,CAAA,CAAE;AACpD,QAAM,CAAC,cAAc,eAAe,IAAIA,MAAAA,SAAS,IAAI;AAErD,QAAM,CAAC,YAAY,YAAY,IAAIA,MAAAA,SAAS,CAAC;AAEvC,QAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACG;AAEE,QAAA,EAAE,UAAU,cAAA,IAAkB;AAEpC,QAAM,aAAa,YAAY;AAC9B,oBAAgB,IAAI;AACd,UAAA,SAAS,MAAM,SAAS;AAC9B,aAAS,MAAM;AACf,oBAAgB,KAAK;AACd,WAAA;AAAA,EACR;AAEA,QAAM,iBAAiB,YAAY;AAC5B,UAAA,SAAS,MAAM,cAAc;AACnC,iBAAa,MAAM;AAAA,EACpB;AAEAC,gBAAAA,cAAc,MAAM;AACJ,mBAAA;AAEN,aAAA,iBAAiBC,sBAAW,eAAe,cAAc;AACzD,aAAA,iBAAiBA,sBAAW,YAAY,cAAc;AACtD,aAAA,iBAAiBA,sBAAW,SAAS,cAAc;AAE5D,WAAO,MAAM;AACH,eAAA,oBAAoBA,sBAAW,eAAe,cAAc;AAC5D,eAAA,oBAAoBA,sBAAW,YAAY,cAAc;AACzD,eAAA,oBAAoBA,sBAAW,SAAS,cAAc;AAAA,IAChE;AAAA,EAAA,CACA;AAED,QAAM,gBAA0C;AAAA,IAC/C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,wCAAQC,aAAAA,aAAa,UAAb,EAAsB,OAAO,eAAgB,UAAS;AAC/D;AAEO,MAAM,mBAAmB,CAC/B,qBAEA,SAAS,mBAAmB,OAAU;AACrC,QAAM,EAAE,QAAQ,GAAG,KAAA,IAAS;AAE5B,wCACE,eAAc,EAAA,QACd,yCAAC,kBAAkB,EAAA,GAAG,KAAM,CAAA,GAC7B;AAEF;;;"}
@@ -1,17 +1,63 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { parseJwtTokenPayload } from "./harmony16.mjs";
5
- const _NewJwtIssuedEvent = class _NewJwtIssuedEvent extends CustomEvent {
6
- constructor(token) {
7
- super(_NewJwtIssuedEvent.eventName, {
8
- detail: { token, payload: parseJwtTokenPayload(token.accessToken) }
9
- });
10
- }
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useEffectOnce } from "./harmony12.mjs";
3
+ import { useState } from "react";
4
+ import { TasksContext } from "./harmony110.mjs";
5
+ import { TaskEvents } from "./harmony113.mjs";
6
+ const TasksProvider = ({ children, config }) => {
7
+ const [tasks, setTasks] = useState([]);
8
+ const [loadingTasks, setLoadingTasks] = useState(true);
9
+ const [tasksCount, setTaskCount] = useState(0);
10
+ const {
11
+ getProjectUrl,
12
+ onLanguageCompleteConfirm,
13
+ onTasksWidgetOpen,
14
+ langNameOnClick,
15
+ langProgressOnClick,
16
+ taskTitleOnClick
17
+ } = config;
18
+ const { getTasks, getTasksCount } = config;
19
+ const fetchTasks = async () => {
20
+ setLoadingTasks(true);
21
+ const result = await getTasks();
22
+ setTasks(result);
23
+ setLoadingTasks(false);
24
+ return result;
25
+ };
26
+ const fetchTaskCount = async () => {
27
+ const result = await getTasksCount();
28
+ setTaskCount(result);
29
+ };
30
+ useEffectOnce(() => {
31
+ fetchTaskCount();
32
+ document.addEventListener(TaskEvents.TaskCompleted, fetchTaskCount);
33
+ document.addEventListener(TaskEvents.TaskClosed, fetchTaskCount);
34
+ document.addEventListener(TaskEvents.Refresh, fetchTaskCount);
35
+ return () => {
36
+ document.removeEventListener(TaskEvents.TaskCompleted, fetchTaskCount);
37
+ document.removeEventListener(TaskEvents.TaskClosed, fetchTaskCount);
38
+ document.removeEventListener(TaskEvents.Refresh, fetchTaskCount);
39
+ };
40
+ });
41
+ const providerValue = {
42
+ fetchTasks,
43
+ tasks,
44
+ tasksCount,
45
+ loadingTasks,
46
+ getProjectUrl,
47
+ onLanguageCompleteConfirm,
48
+ onTasksWidgetOpen,
49
+ langNameOnClick,
50
+ langProgressOnClick,
51
+ taskTitleOnClick
52
+ };
53
+ return /* @__PURE__ */ jsx(TasksContext.Provider, { value: providerValue, children });
54
+ };
55
+ const withTasksContext = (WrappedComponent) => function withTasksContextFn(props) {
56
+ const { config, ...rest } = props;
57
+ return /* @__PURE__ */ jsx(TasksProvider, { config, children: /* @__PURE__ */ jsx(WrappedComponent, { ...rest }) });
11
58
  };
12
- __publicField(_NewJwtIssuedEvent, "eventName", "new-jwt-issued");
13
- let NewJwtIssuedEvent = _NewJwtIssuedEvent;
14
59
  export {
15
- NewJwtIssuedEvent
60
+ TasksProvider,
61
+ withTasksContext
16
62
  };
17
63
  //# sourceMappingURL=harmony112.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harmony112.mjs","sources":["../src/features/auth/frontend/events/NewJwtIssuedEvent.ts"],"sourcesContent":["import type { JwtTokenPayload } from '@features/auth/core/types/jwtTokenPayload'\nimport { parseJwtTokenPayload } from '@features/auth/core/utils/jwtTokenPayload'\nimport type { JwtToken } from '@features/publicApi/types/userTokenTypes'\n\ntype NewJwtIssuedEventDetail = {\n\ttoken: JwtToken\n\tpayload: JwtTokenPayload | undefined\n}\n\n/**\n * This event is emitted when a new JWT token is issued or refreshed.\n */\nexport class NewJwtIssuedEvent extends CustomEvent<NewJwtIssuedEventDetail> {\n\tstatic readonly eventName = 'new-jwt-issued' as const\n\n\tconstructor(token: JwtToken) {\n\t\tsuper(NewJwtIssuedEvent.eventName, {\n\t\t\tdetail: { token, payload: parseJwtTokenPayload(token.accessToken) },\n\t\t})\n\t}\n}\n\nexport const isNewJwtIssuedEvent = (event: Event): event is NewJwtIssuedEvent =>\n\tevent.type === NewJwtIssuedEvent.eventName\n\ndeclare global {\n\tinterface WindowEventMap {\n\t\t[NewJwtIssuedEvent.eventName]: NewJwtIssuedEvent\n\t}\n}\n"],"names":[],"mappings":";;;;AAYO,MAAM,qBAAN,MAAM,2BAA0B,YAAqC;AAAA,EAG3E,YAAY,OAAiB;AAC5B,UAAM,mBAAkB,WAAW;AAAA,MAClC,QAAQ,EAAE,OAAO,SAAS,qBAAqB,MAAM,WAAW,EAAE;AAAA,IAAA,CAClE;AAAA,EAAA;AAEH;AAPC,cADY,oBACI,aAAY;AADtB,IAAM,oBAAN;"}
1
+ {"version":3,"file":"harmony112.mjs","sources":["../src/components/Sidebar/Widgets/Tasks/TasksProvider.tsx"],"sourcesContent":["import { useEffectOnce } from '@utils'\nimport { type FC, type PropsWithChildren, useState } from 'react'\nimport { TasksContext } from './TasksContext'\nimport type { SidebarTask, SidebarTasksConfig, SidebarTasksContextProps } from './types'\nimport { TaskEvents } from './utils/taskEvents'\n\ntype TasksProviderProps = PropsWithChildren<{\n\tconfig: SidebarTasksConfig\n}>\n\nexport const TasksProvider = ({ children, config }: TasksProviderProps) => {\n\tconst [tasks, setTasks] = useState<SidebarTask[]>([])\n\tconst [loadingTasks, setLoadingTasks] = useState(true)\n\n\tconst [tasksCount, setTaskCount] = useState(0)\n\n\tconst {\n\t\tgetProjectUrl,\n\t\tonLanguageCompleteConfirm,\n\t\tonTasksWidgetOpen,\n\t\tlangNameOnClick,\n\t\tlangProgressOnClick,\n\t\ttaskTitleOnClick,\n\t} = config\n\n\tconst { getTasks, getTasksCount } = config\n\n\tconst fetchTasks = async () => {\n\t\tsetLoadingTasks(true)\n\t\tconst result = await getTasks()\n\t\tsetTasks(result)\n\t\tsetLoadingTasks(false)\n\t\treturn result\n\t}\n\n\tconst fetchTaskCount = async () => {\n\t\tconst result = await getTasksCount()\n\t\tsetTaskCount(result)\n\t}\n\n\tuseEffectOnce(() => {\n\t\tfetchTaskCount()\n\n\t\tdocument.addEventListener(TaskEvents.TaskCompleted, fetchTaskCount)\n\t\tdocument.addEventListener(TaskEvents.TaskClosed, fetchTaskCount)\n\t\tdocument.addEventListener(TaskEvents.Refresh, fetchTaskCount)\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener(TaskEvents.TaskCompleted, fetchTaskCount)\n\t\t\tdocument.removeEventListener(TaskEvents.TaskClosed, fetchTaskCount)\n\t\t\tdocument.removeEventListener(TaskEvents.Refresh, fetchTaskCount)\n\t\t}\n\t})\n\n\tconst providerValue: SidebarTasksContextProps = {\n\t\tfetchTasks,\n\t\ttasks,\n\t\ttasksCount,\n\t\tloadingTasks,\n\t\tgetProjectUrl,\n\t\tonLanguageCompleteConfirm,\n\t\tonTasksWidgetOpen,\n\t\tlangNameOnClick,\n\t\tlangProgressOnClick,\n\t\ttaskTitleOnClick,\n\t}\n\n\treturn <TasksContext.Provider value={providerValue}>{children}</TasksContext.Provider>\n}\n\nexport const withTasksContext = <P extends { config: SidebarTasksConfig }>(\n\tWrappedComponent: FC<Omit<P, 'config'>>,\n) =>\n\tfunction withTasksContextFn(props: P) {\n\t\tconst { config, ...rest } = props\n\n\t\treturn (\n\t\t\t<TasksProvider config={config}>\n\t\t\t\t<WrappedComponent {...rest} />\n\t\t\t</TasksProvider>\n\t\t)\n\t}\n"],"names":[],"mappings":";;;;;AAUO,MAAM,gBAAgB,CAAC,EAAE,UAAU,aAAiC;AAC1E,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,CAAA,CAAE;AACpD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,IAAI;AAErD,QAAM,CAAC,YAAY,YAAY,IAAI,SAAS,CAAC;AAEvC,QAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACG;AAEE,QAAA,EAAE,UAAU,cAAA,IAAkB;AAEpC,QAAM,aAAa,YAAY;AAC9B,oBAAgB,IAAI;AACd,UAAA,SAAS,MAAM,SAAS;AAC9B,aAAS,MAAM;AACf,oBAAgB,KAAK;AACd,WAAA;AAAA,EACR;AAEA,QAAM,iBAAiB,YAAY;AAC5B,UAAA,SAAS,MAAM,cAAc;AACnC,iBAAa,MAAM;AAAA,EACpB;AAEA,gBAAc,MAAM;AACJ,mBAAA;AAEN,aAAA,iBAAiB,WAAW,eAAe,cAAc;AACzD,aAAA,iBAAiB,WAAW,YAAY,cAAc;AACtD,aAAA,iBAAiB,WAAW,SAAS,cAAc;AAE5D,WAAO,MAAM;AACH,eAAA,oBAAoB,WAAW,eAAe,cAAc;AAC5D,eAAA,oBAAoB,WAAW,YAAY,cAAc;AACzD,eAAA,oBAAoB,WAAW,SAAS,cAAc;AAAA,IAChE;AAAA,EAAA,CACA;AAED,QAAM,gBAA0C;AAAA,IAC/C;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,6BAAQ,aAAa,UAAb,EAAsB,OAAO,eAAgB,UAAS;AAC/D;AAEO,MAAM,mBAAmB,CAC/B,qBAEA,SAAS,mBAAmB,OAAU;AACrC,QAAM,EAAE,QAAQ,GAAG,KAAA,IAAS;AAE5B,6BACE,eAAc,EAAA,QACd,8BAAC,kBAAkB,EAAA,GAAG,KAAM,CAAA,GAC7B;AAEF;"}
@@ -1,21 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const zod = require("zod");
4
- const teamRoleTypes = require("./harmony66.cjs");
5
- const JWT_TOKEN_PAYLOAD_SCHEMA = zod.z.object({
6
- userId: zod.z.number(),
7
- userUuid: zod.z.string().uuid(),
8
- teamId: zod.z.number(),
9
- teamUuid: zod.z.string().uuid(),
10
- userTeamRole: teamRoleTypes.TEAM_ROLE_SCHEMA,
11
- userEmail: zod.z.string().email(),
12
- userName: zod.z.string(),
13
- userCurrentTeamId: zod.z.number(),
14
- planId: zod.z.number(),
15
- planName: zod.z.string(),
16
- isProviderAlpha: zod.z.boolean(),
17
- isFullyAuthenticated: zod.z.boolean(),
18
- exp: zod.z.number()
19
- });
20
- exports.JWT_TOKEN_PAYLOAD_SCHEMA = JWT_TOKEN_PAYLOAD_SCHEMA;
3
+ const TaskEvents = {
4
+ TaskCompleted: "task_completed",
5
+ TaskClosed: "task_closed",
6
+ Refresh: "refresh",
7
+ ShowDialog: "show_dialog"
8
+ };
9
+ exports.TaskEvents = TaskEvents;
21
10
  //# sourceMappingURL=harmony113.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harmony113.cjs","sources":["../src/features/auth/core/types/jwtTokenPayload.ts"],"sourcesContent":["import { z } from 'zod'\nimport { TEAM_ROLE_SCHEMA } from '../../../publicApi/types/teamRoleTypes'\n\nexport const JWT_TOKEN_PAYLOAD_SCHEMA = z.object({\n\tuserId: z.number(),\n\tuserUuid: z.string().uuid(),\n\tteamId: z.number(),\n\tteamUuid: z.string().uuid(),\n\tuserTeamRole: TEAM_ROLE_SCHEMA,\n\tuserEmail: z.string().email(),\n\tuserName: z.string(),\n\tuserCurrentTeamId: z.number(),\n\tplanId: z.number(),\n\tplanName: z.string(),\n\tisProviderAlpha: z.boolean(),\n\tisFullyAuthenticated: z.boolean(),\n\texp: z.number(),\n})\nexport type JwtTokenPayload = z.infer<typeof JWT_TOKEN_PAYLOAD_SCHEMA>\n"],"names":["z","TEAM_ROLE_SCHEMA"],"mappings":";;;;AAGa,MAAA,2BAA2BA,MAAE,OAAO;AAAA,EAChD,QAAQA,MAAE,OAAO;AAAA,EACjB,UAAUA,IAAA,EAAE,OAAO,EAAE,KAAK;AAAA,EAC1B,QAAQA,MAAE,OAAO;AAAA,EACjB,UAAUA,IAAA,EAAE,OAAO,EAAE,KAAK;AAAA,EAC1B,cAAcC,cAAA;AAAA,EACd,WAAWD,IAAA,EAAE,OAAO,EAAE,MAAM;AAAA,EAC5B,UAAUA,MAAE,OAAO;AAAA,EACnB,mBAAmBA,MAAE,OAAO;AAAA,EAC5B,QAAQA,MAAE,OAAO;AAAA,EACjB,UAAUA,MAAE,OAAO;AAAA,EACnB,iBAAiBA,MAAE,QAAQ;AAAA,EAC3B,sBAAsBA,MAAE,QAAQ;AAAA,EAChC,KAAKA,MAAE,OAAO;AACf,CAAC;;"}
1
+ {"version":3,"file":"harmony113.cjs","sources":["../src/components/Sidebar/Widgets/Tasks/utils/taskEvents.ts"],"sourcesContent":["import type { TypesFromMap } from '@utils'\n\nexport const TaskEvents = {\n\tTaskCompleted: 'task_completed',\n\tTaskClosed: 'task_closed',\n\tRefresh: 'refresh',\n\tShowDialog: 'show_dialog',\n} as const\n\nexport type TaskEvent = TypesFromMap<typeof TaskEvents>\n\ntype SingleTaskPayload = {\n\ttaskId: string | number\n}\n\ntype DispatchTaskEventPayload =\n\t| {\n\t\t\tname: typeof TaskEvents.TaskCompleted\n\t\t\tdetail: SingleTaskPayload\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.TaskClosed\n\t\t\tdetail: SingleTaskPayload\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.Refresh\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.ShowDialog\n\t }\n\nexport const dispatchTaskEvent = (props: DispatchTaskEventPayload) => {\n\tconst { name } = props\n\tdocument.dispatchEvent(new CustomEvent(name, { detail: 'detail' in props ? props.detail : {} }))\n}\n"],"names":[],"mappings":";;AAEO,MAAM,aAAa;AAAA,EACzB,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,YAAY;AACb;;"}
@@ -1,21 +1,10 @@
1
- import { z } from "zod";
2
- import { TEAM_ROLE_SCHEMA } from "./harmony66.mjs";
3
- const JWT_TOKEN_PAYLOAD_SCHEMA = z.object({
4
- userId: z.number(),
5
- userUuid: z.string().uuid(),
6
- teamId: z.number(),
7
- teamUuid: z.string().uuid(),
8
- userTeamRole: TEAM_ROLE_SCHEMA,
9
- userEmail: z.string().email(),
10
- userName: z.string(),
11
- userCurrentTeamId: z.number(),
12
- planId: z.number(),
13
- planName: z.string(),
14
- isProviderAlpha: z.boolean(),
15
- isFullyAuthenticated: z.boolean(),
16
- exp: z.number()
17
- });
1
+ const TaskEvents = {
2
+ TaskCompleted: "task_completed",
3
+ TaskClosed: "task_closed",
4
+ Refresh: "refresh",
5
+ ShowDialog: "show_dialog"
6
+ };
18
7
  export {
19
- JWT_TOKEN_PAYLOAD_SCHEMA
8
+ TaskEvents
20
9
  };
21
10
  //# sourceMappingURL=harmony113.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"harmony113.mjs","sources":["../src/features/auth/core/types/jwtTokenPayload.ts"],"sourcesContent":["import { z } from 'zod'\nimport { TEAM_ROLE_SCHEMA } from '../../../publicApi/types/teamRoleTypes'\n\nexport const JWT_TOKEN_PAYLOAD_SCHEMA = z.object({\n\tuserId: z.number(),\n\tuserUuid: z.string().uuid(),\n\tteamId: z.number(),\n\tteamUuid: z.string().uuid(),\n\tuserTeamRole: TEAM_ROLE_SCHEMA,\n\tuserEmail: z.string().email(),\n\tuserName: z.string(),\n\tuserCurrentTeamId: z.number(),\n\tplanId: z.number(),\n\tplanName: z.string(),\n\tisProviderAlpha: z.boolean(),\n\tisFullyAuthenticated: z.boolean(),\n\texp: z.number(),\n})\nexport type JwtTokenPayload = z.infer<typeof JWT_TOKEN_PAYLOAD_SCHEMA>\n"],"names":[],"mappings":";;AAGa,MAAA,2BAA2B,EAAE,OAAO;AAAA,EAChD,QAAQ,EAAE,OAAO;AAAA,EACjB,UAAU,EAAE,OAAO,EAAE,KAAK;AAAA,EAC1B,QAAQ,EAAE,OAAO;AAAA,EACjB,UAAU,EAAE,OAAO,EAAE,KAAK;AAAA,EAC1B,cAAc;AAAA,EACd,WAAW,EAAE,OAAO,EAAE,MAAM;AAAA,EAC5B,UAAU,EAAE,OAAO;AAAA,EACnB,mBAAmB,EAAE,OAAO;AAAA,EAC5B,QAAQ,EAAE,OAAO;AAAA,EACjB,UAAU,EAAE,OAAO;AAAA,EACnB,iBAAiB,EAAE,QAAQ;AAAA,EAC3B,sBAAsB,EAAE,QAAQ;AAAA,EAChC,KAAK,EAAE,OAAO;AACf,CAAC;"}
1
+ {"version":3,"file":"harmony113.mjs","sources":["../src/components/Sidebar/Widgets/Tasks/utils/taskEvents.ts"],"sourcesContent":["import type { TypesFromMap } from '@utils'\n\nexport const TaskEvents = {\n\tTaskCompleted: 'task_completed',\n\tTaskClosed: 'task_closed',\n\tRefresh: 'refresh',\n\tShowDialog: 'show_dialog',\n} as const\n\nexport type TaskEvent = TypesFromMap<typeof TaskEvents>\n\ntype SingleTaskPayload = {\n\ttaskId: string | number\n}\n\ntype DispatchTaskEventPayload =\n\t| {\n\t\t\tname: typeof TaskEvents.TaskCompleted\n\t\t\tdetail: SingleTaskPayload\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.TaskClosed\n\t\t\tdetail: SingleTaskPayload\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.Refresh\n\t }\n\t| {\n\t\t\tname: typeof TaskEvents.ShowDialog\n\t }\n\nexport const dispatchTaskEvent = (props: DispatchTaskEventPayload) => {\n\tconst { name } = props\n\tdocument.dispatchEvent(new CustomEvent(name, { detail: 'detail' in props ? props.detail : {} }))\n}\n"],"names":[],"mappings":"AAEO,MAAM,aAAa;AAAA,EACzB,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,YAAY;AACb;"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const _commonjsHelpers = require("./harmony136.cjs");
4
- const debounce$1 = require("./harmony120.cjs");
4
+ const debounce$1 = require("./harmony117.cjs");
5
5
  var debounceExports = debounce$1.__require();
6
6
  const debounce = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(debounceExports);
7
7
  exports.default = debounce;
@@ -1,5 +1,5 @@
1
1
  import { getDefaultExportFromCjs } from "./harmony136.mjs";
2
- import { __require as requireDebounce } from "./harmony120.mjs";
2
+ import { __require as requireDebounce } from "./harmony117.mjs";
3
3
  var debounceExports = requireDebounce();
4
4
  const debounce = /* @__PURE__ */ getDefaultExportFromCjs(debounceExports);
5
5
  export {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const _commonjsHelpers = require("./harmony136.cjs");
4
- const throttle$1 = require("./harmony124.cjs");
4
+ const throttle$1 = require("./harmony121.cjs");
5
5
  var throttleExports = throttle$1.__require();
6
6
  const throttle = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(throttleExports);
7
7
  exports.default = throttle;
@@ -1,5 +1,5 @@
1
1
  import { getDefaultExportFromCjs } from "./harmony136.mjs";
2
- import { __require as requireThrottle } from "./harmony124.mjs";
2
+ import { __require as requireThrottle } from "./harmony121.mjs";
3
3
  var throttleExports = requireThrottle();
4
4
  const throttle = /* @__PURE__ */ getDefaultExportFromCjs(throttleExports);
5
5
  export {
@@ -1,65 +1,99 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const min = Math.min;
4
- const max = Math.max;
5
- function clamp(start, value, end) {
6
- return max(start, min(value, end));
3
+ const isObject = require("./harmony118.cjs");
4
+ const now = require("./harmony119.cjs");
5
+ const toNumber = require("./harmony120.cjs");
6
+ var debounce_1;
7
+ var hasRequiredDebounce;
8
+ function requireDebounce() {
9
+ if (hasRequiredDebounce) return debounce_1;
10
+ hasRequiredDebounce = 1;
11
+ var isObject$1 = isObject.__require(), now$1 = now.__require(), toNumber$1 = toNumber.__require();
12
+ var FUNC_ERROR_TEXT = "Expected a function";
13
+ var nativeMax = Math.max, nativeMin = Math.min;
14
+ function debounce(func, wait, options) {
15
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
16
+ if (typeof func != "function") {
17
+ throw new TypeError(FUNC_ERROR_TEXT);
18
+ }
19
+ wait = toNumber$1(wait) || 0;
20
+ if (isObject$1(options)) {
21
+ leading = !!options.leading;
22
+ maxing = "maxWait" in options;
23
+ maxWait = maxing ? nativeMax(toNumber$1(options.maxWait) || 0, wait) : maxWait;
24
+ trailing = "trailing" in options ? !!options.trailing : trailing;
25
+ }
26
+ function invokeFunc(time) {
27
+ var args = lastArgs, thisArg = lastThis;
28
+ lastArgs = lastThis = void 0;
29
+ lastInvokeTime = time;
30
+ result = func.apply(thisArg, args);
31
+ return result;
32
+ }
33
+ function leadingEdge(time) {
34
+ lastInvokeTime = time;
35
+ timerId = setTimeout(timerExpired, wait);
36
+ return leading ? invokeFunc(time) : result;
37
+ }
38
+ function remainingWait(time) {
39
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
40
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
41
+ }
42
+ function shouldInvoke(time) {
43
+ var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
44
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
45
+ }
46
+ function timerExpired() {
47
+ var time = now$1();
48
+ if (shouldInvoke(time)) {
49
+ return trailingEdge(time);
50
+ }
51
+ timerId = setTimeout(timerExpired, remainingWait(time));
52
+ }
53
+ function trailingEdge(time) {
54
+ timerId = void 0;
55
+ if (trailing && lastArgs) {
56
+ return invokeFunc(time);
57
+ }
58
+ lastArgs = lastThis = void 0;
59
+ return result;
60
+ }
61
+ function cancel() {
62
+ if (timerId !== void 0) {
63
+ clearTimeout(timerId);
64
+ }
65
+ lastInvokeTime = 0;
66
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
67
+ }
68
+ function flush() {
69
+ return timerId === void 0 ? result : trailingEdge(now$1());
70
+ }
71
+ function debounced() {
72
+ var time = now$1(), isInvoking = shouldInvoke(time);
73
+ lastArgs = arguments;
74
+ lastThis = this;
75
+ lastCallTime = time;
76
+ if (isInvoking) {
77
+ if (timerId === void 0) {
78
+ return leadingEdge(lastCallTime);
79
+ }
80
+ if (maxing) {
81
+ clearTimeout(timerId);
82
+ timerId = setTimeout(timerExpired, wait);
83
+ return invokeFunc(lastCallTime);
84
+ }
85
+ }
86
+ if (timerId === void 0) {
87
+ timerId = setTimeout(timerExpired, wait);
88
+ }
89
+ return result;
90
+ }
91
+ debounced.cancel = cancel;
92
+ debounced.flush = flush;
93
+ return debounced;
94
+ }
95
+ debounce_1 = debounce;
96
+ return debounce_1;
7
97
  }
8
- function evaluate(value, param) {
9
- return typeof value === "function" ? value(param) : value;
10
- }
11
- function getSide(placement) {
12
- return placement.split("-")[0];
13
- }
14
- function getOppositeAxis(axis) {
15
- return axis === "x" ? "y" : "x";
16
- }
17
- function getSideAxis(placement) {
18
- return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
19
- }
20
- function expandPaddingObject(padding) {
21
- return {
22
- top: 0,
23
- right: 0,
24
- bottom: 0,
25
- left: 0,
26
- ...padding
27
- };
28
- }
29
- function getPaddingObject(padding) {
30
- return typeof padding !== "number" ? expandPaddingObject(padding) : {
31
- top: padding,
32
- right: padding,
33
- bottom: padding,
34
- left: padding
35
- };
36
- }
37
- function rectToClientRect(rect) {
38
- const {
39
- x,
40
- y,
41
- width,
42
- height
43
- } = rect;
44
- return {
45
- width,
46
- height,
47
- top: y,
48
- left: x,
49
- right: x + width,
50
- bottom: y + height,
51
- x,
52
- y
53
- };
54
- }
55
- exports.clamp = clamp;
56
- exports.evaluate = evaluate;
57
- exports.expandPaddingObject = expandPaddingObject;
58
- exports.getOppositeAxis = getOppositeAxis;
59
- exports.getPaddingObject = getPaddingObject;
60
- exports.getSide = getSide;
61
- exports.getSideAxis = getSideAxis;
62
- exports.max = max;
63
- exports.min = min;
64
- exports.rectToClientRect = rectToClientRect;
98
+ exports.__require = requireDebounce;
65
99
  //# sourceMappingURL=harmony117.cjs.map