analytica-frontend-lib 1.2.76 → 1.2.77

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 (56) hide show
  1. package/dist/ActivitiesHistory/index.css +3 -0
  2. package/dist/ActivitiesHistory/index.css.map +1 -1
  3. package/dist/ActivityCardQuestionBanks/index.css +3 -0
  4. package/dist/ActivityCardQuestionBanks/index.css.map +1 -1
  5. package/dist/ActivityCardQuestionPreview/index.css +3 -0
  6. package/dist/ActivityCardQuestionPreview/index.css.map +1 -1
  7. package/dist/ActivityDetails/index.css +3 -0
  8. package/dist/ActivityDetails/index.css.map +1 -1
  9. package/dist/ActivityDetails/index.d.ts +1 -3
  10. package/dist/ActivityDetails/index.d.ts.map +1 -1
  11. package/dist/ActivityDetails/index.js +2227 -691
  12. package/dist/ActivityDetails/index.js.map +1 -1
  13. package/dist/ActivityDetails/index.mjs +2212 -668
  14. package/dist/ActivityDetails/index.mjs.map +1 -1
  15. package/dist/ActivityFilters/index.css +3 -0
  16. package/dist/ActivityFilters/index.css.map +1 -1
  17. package/dist/ActivityFilters/index.d.ts +1 -1
  18. package/dist/ActivityFilters/index.d.ts.map +1 -1
  19. package/dist/ActivityFilters/index.js +343 -270
  20. package/dist/ActivityFilters/index.js.map +1 -1
  21. package/dist/ActivityFilters/index.mjs +335 -262
  22. package/dist/ActivityFilters/index.mjs.map +1 -1
  23. package/dist/ActivityPreview/index.css +3 -0
  24. package/dist/ActivityPreview/index.css.map +1 -1
  25. package/dist/AlertManager/index.css +3 -0
  26. package/dist/AlertManager/index.css.map +1 -1
  27. package/dist/RecommendedLessonsHistory/index.css +3 -0
  28. package/dist/RecommendedLessonsHistory/index.css.map +1 -1
  29. package/dist/SendActivityModal/SendActivityModal.css +3 -0
  30. package/dist/SendActivityModal/SendActivityModal.css.map +1 -1
  31. package/dist/SendActivityModal/index.css +3 -0
  32. package/dist/SendActivityModal/index.css.map +1 -1
  33. package/dist/TableProvider/index.css +3 -0
  34. package/dist/TableProvider/index.css.map +1 -1
  35. package/dist/index.css +3 -0
  36. package/dist/index.css.map +1 -1
  37. package/dist/index.js +4160 -3823
  38. package/dist/index.js.map +1 -1
  39. package/dist/index.mjs +2648 -2305
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/store/questionFiltersStore.d.ts +8 -1
  42. package/dist/store/questionFiltersStore.d.ts.map +1 -1
  43. package/dist/styles.css +3 -0
  44. package/dist/styles.css.map +1 -1
  45. package/dist/types/lessonFilters.d.ts +11 -0
  46. package/dist/types/lessonFilters.d.ts.map +1 -0
  47. package/dist/utils/activityFilters.d.ts.map +1 -1
  48. package/dist/utils/arraysEqual.d.ts +9 -0
  49. package/dist/utils/arraysEqual.d.ts.map +1 -0
  50. package/dist/utils/index.js +14 -11
  51. package/dist/utils/index.js.map +1 -1
  52. package/dist/utils/index.mjs +14 -11
  53. package/dist/utils/index.mjs.map +1 -1
  54. package/dist/utils/lessonFilters.d.ts +9 -0
  55. package/dist/utils/lessonFilters.d.ts.map +1 -0
  56. package/package.json +5 -1
@@ -1,10 +1,24 @@
1
1
  // src/components/ActivityFilters/ActivityFilters.tsx
2
- import { useState as useState10, useEffect as useEffect11, useMemo as useMemo3, useCallback as useCallback2, useRef as useRef7 } from "react";
2
+ import { useState as useState10, useEffect as useEffect13, useMemo as useMemo3, useCallback as useCallback2, useRef as useRef9 } from "react";
3
3
 
4
4
  // src/utils/utils.ts
5
5
  import { clsx } from "clsx";
6
6
  import { twMerge } from "tailwind-merge";
7
7
 
8
+ // src/utils/arraysEqual.ts
9
+ function arraysEqual(a, b, comparator) {
10
+ if (a.length !== b.length) return false;
11
+ if (a.length === 0 && b.length === 0) return true;
12
+ if (comparator) {
13
+ const sortedA2 = [...a].sort(comparator);
14
+ const sortedB2 = [...b].sort(comparator);
15
+ return sortedA2.every((val, index) => val === sortedB2[index]);
16
+ }
17
+ const sortedA = [...a].sort((x, y) => String(x).localeCompare(String(y)));
18
+ const sortedB = [...b].sort((x, y) => String(x).localeCompare(String(y)));
19
+ return sortedA.every((val, index) => val === sortedB[index]);
20
+ }
21
+
8
22
  // src/utils/activityFilters.ts
9
23
  function getSelectedIdsFromCategories(categories, keys) {
10
24
  const result = {};
@@ -20,17 +34,6 @@ function toggleArrayItem(array, item) {
20
34
  function toggleSingleValue(currentValue, newValue) {
21
35
  return currentValue === newValue ? null : newValue;
22
36
  }
23
- function arraysEqual(a, b, comparator) {
24
- if (a.length !== b.length) return false;
25
- if (comparator) {
26
- const sortedA2 = [...a].sort(comparator);
27
- const sortedB2 = [...b].sort(comparator);
28
- return sortedA2.every((val, index) => val === sortedB2[index]);
29
- }
30
- const sortedA = [...a].sort((x, y) => String(x).localeCompare(String(y)));
31
- const sortedB = [...b].sort((x, y) => String(x).localeCompare(String(y)));
32
- return sortedA.every((val, index) => val === sortedB[index]);
33
- }
34
37
  function areFiltersEqual(filters1, filters2) {
35
38
  if (filters1 === filters2) return true;
36
39
  if (!filters1 || !filters2) return false;
@@ -5233,8 +5236,269 @@ var createUseActivityFiltersData = (apiClient) => {
5233
5236
  return (options) => useActivityFiltersDataImpl(apiClient, options);
5234
5237
  };
5235
5238
 
5236
- // src/components/ActivityFilters/ActivityFilters.tsx
5239
+ // src/store/questionFiltersStore.ts
5240
+ import { create as create5 } from "zustand";
5241
+ var useQuestionFiltersStore = create5((set) => ({
5242
+ // Filter states
5243
+ draftFilters: null,
5244
+ appliedFilters: null,
5245
+ setDraftFilters: (filters) => {
5246
+ set({ draftFilters: filters });
5247
+ },
5248
+ applyFilters: () => {
5249
+ set((state) => ({
5250
+ appliedFilters: state.draftFilters
5251
+ }));
5252
+ },
5253
+ clearFilters: () => {
5254
+ set({
5255
+ draftFilters: null,
5256
+ appliedFilters: null,
5257
+ // Clear cached questions when filters are cleared
5258
+ cachedQuestions: [],
5259
+ cachedPagination: null,
5260
+ cachedFilters: null
5261
+ });
5262
+ },
5263
+ // Questions cache state
5264
+ cachedQuestions: [],
5265
+ cachedPagination: null,
5266
+ cachedFilters: null,
5267
+ setCachedQuestions: (questions, pagination, filters) => {
5268
+ set({
5269
+ cachedQuestions: questions,
5270
+ cachedPagination: pagination,
5271
+ cachedFilters: filters
5272
+ });
5273
+ },
5274
+ clearCachedQuestions: () => {
5275
+ set({
5276
+ cachedQuestions: [],
5277
+ cachedPagination: null,
5278
+ cachedFilters: null
5279
+ });
5280
+ }
5281
+ }));
5282
+
5283
+ // src/components/ActivityFilters/components/SubjectsFilter.tsx
5237
5284
  import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
5285
+ var SubjectsFilter = ({
5286
+ knowledgeAreas,
5287
+ selectedSubject,
5288
+ onSubjectChange,
5289
+ loading = false,
5290
+ error = null
5291
+ }) => {
5292
+ const { isDark } = useTheme();
5293
+ if (loading) {
5294
+ return /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "text-text-600", children: "Carregando mat\xE9rias..." });
5295
+ }
5296
+ if (error) {
5297
+ return /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "text-text-600", children: error });
5298
+ }
5299
+ return /* @__PURE__ */ jsx21("div", { className: "grid grid-cols-3 gap-3", children: knowledgeAreas.map((area) => /* @__PURE__ */ jsx21(
5300
+ Radio_default,
5301
+ {
5302
+ value: area.id,
5303
+ checked: selectedSubject === area.id,
5304
+ onChange: () => onSubjectChange(area.id),
5305
+ label: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-2 w-full min-w-0", children: [
5306
+ /* @__PURE__ */ jsx21(
5307
+ "span",
5308
+ {
5309
+ className: "size-4 rounded-sm flex items-center justify-center shrink-0 text-text-950",
5310
+ style: {
5311
+ backgroundColor: getSubjectColorWithOpacity(
5312
+ area.color,
5313
+ isDark
5314
+ )
5315
+ },
5316
+ children: /* @__PURE__ */ jsx21(
5317
+ IconRender_default,
5318
+ {
5319
+ iconName: area.icon || "BookOpen",
5320
+ size: 14,
5321
+ color: "currentColor"
5322
+ }
5323
+ )
5324
+ }
5325
+ ),
5326
+ /* @__PURE__ */ jsx21("span", { className: "truncate flex-1", children: area.name })
5327
+ ] })
5328
+ },
5329
+ area.id
5330
+ )) });
5331
+ };
5332
+
5333
+ // src/components/ActivityFilters/components/KnowledgeStructureFilter.tsx
5334
+ import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
5335
+ var KnowledgeStructureFilter = ({
5336
+ knowledgeStructure,
5337
+ knowledgeCategories,
5338
+ handleCategoriesChange
5339
+ }) => {
5340
+ return /* @__PURE__ */ jsxs17("div", { className: "mt-4", children: [
5341
+ /* @__PURE__ */ jsx22(Text_default, { size: "sm", weight: "bold", className: "mb-3 block", children: "Tema, Subtema e Assunto" }),
5342
+ knowledgeStructure.loading && /* @__PURE__ */ jsx22(Text_default, { size: "sm", className: "text-text-600 mb-3", children: "Carregando estrutura de conhecimento..." }),
5343
+ knowledgeStructure.error && /* @__PURE__ */ jsx22(Text_default, { size: "sm", className: "mb-3 text-error-500", children: knowledgeStructure.error }),
5344
+ knowledgeCategories.length > 0 && handleCategoriesChange && /* @__PURE__ */ jsx22(
5345
+ CheckboxGroup,
5346
+ {
5347
+ categories: knowledgeCategories,
5348
+ onCategoriesChange: handleCategoriesChange,
5349
+ compactSingleItem: false,
5350
+ showSingleItem: true
5351
+ }
5352
+ ),
5353
+ !knowledgeStructure.loading && knowledgeCategories.length === 0 && knowledgeStructure.topics.length === 0 && /* @__PURE__ */ jsx22(Text_default, { size: "sm", className: "text-text-600", children: "Nenhum tema dispon\xEDvel para as mat\xE9rias selecionadas" })
5354
+ ] });
5355
+ };
5356
+
5357
+ // src/components/ActivityFilters/components/FilterActions.tsx
5358
+ import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
5359
+ var FilterActions = ({
5360
+ onClearFilters,
5361
+ onApplyFilters
5362
+ }) => {
5363
+ if (!onClearFilters && !onApplyFilters) {
5364
+ return null;
5365
+ }
5366
+ return /* @__PURE__ */ jsxs18("div", { className: "grid grid-cols-2 gap-2 justify-end mt-4 px-4 pt-4 border-t border-border-200", children: [
5367
+ onClearFilters && /* @__PURE__ */ jsx23(Button_default, { variant: "link", onClick: onClearFilters, size: "small", children: "Limpar filtros" }),
5368
+ onApplyFilters && /* @__PURE__ */ jsx23(Button_default, { variant: "outline", onClick: onApplyFilters, size: "small", children: "Filtrar" })
5369
+ ] });
5370
+ };
5371
+
5372
+ // src/components/ActivityFilters/utils/useInitialFiltersLoader.ts
5373
+ import { useEffect as useEffect11, useRef as useRef7 } from "react";
5374
+ var useInitialFiltersLoader = ({
5375
+ initialFilters,
5376
+ loadTopics,
5377
+ loadSubtopics,
5378
+ loadContents
5379
+ }) => {
5380
+ const hasRequestedTopicsRef = useRef7(false);
5381
+ const hasRequestedSubtopicsRef = useRef7(false);
5382
+ const hasRequestedContentsRef = useRef7(false);
5383
+ useEffect11(() => {
5384
+ hasRequestedTopicsRef.current = false;
5385
+ hasRequestedSubtopicsRef.current = false;
5386
+ hasRequestedContentsRef.current = false;
5387
+ if (!initialFilters) {
5388
+ return;
5389
+ }
5390
+ const subjectIds = initialFilters.subjectIds || [];
5391
+ const topicIds = initialFilters.topicIds || [];
5392
+ const subtopicIds = initialFilters.subtopicIds || [];
5393
+ if (subjectIds.length > 0 && !hasRequestedTopicsRef.current) {
5394
+ if (loadTopics) {
5395
+ loadTopics(subjectIds);
5396
+ }
5397
+ hasRequestedTopicsRef.current = true;
5398
+ }
5399
+ if (topicIds.length > 0 && !hasRequestedSubtopicsRef.current) {
5400
+ if (loadSubtopics) {
5401
+ loadSubtopics(topicIds);
5402
+ }
5403
+ hasRequestedSubtopicsRef.current = true;
5404
+ }
5405
+ if (subtopicIds.length > 0 && !hasRequestedContentsRef.current) {
5406
+ if (loadContents) {
5407
+ loadContents(subtopicIds);
5408
+ }
5409
+ hasRequestedContentsRef.current = true;
5410
+ }
5411
+ }, [initialFilters, loadTopics, loadSubtopics, loadContents]);
5412
+ return {
5413
+ hasRequestedTopicsRef,
5414
+ hasRequestedSubtopicsRef,
5415
+ hasRequestedContentsRef
5416
+ };
5417
+ };
5418
+
5419
+ // src/components/ActivityFilters/utils/useKnowledgeStructureInitialFilters.ts
5420
+ import { useEffect as useEffect12, useRef as useRef8 } from "react";
5421
+ var useKnowledgeStructureInitialFilters = ({
5422
+ initialFilters,
5423
+ knowledgeCategories,
5424
+ handleCategoriesChange
5425
+ }) => {
5426
+ const hasAppliedKnowledgeInitialFiltersRef = useRef8(false);
5427
+ const hasAppliedTopicsRef = useRef8(false);
5428
+ const hasAppliedSubtopicsRef = useRef8(false);
5429
+ const hasAppliedContentsRef = useRef8(false);
5430
+ const knowledgeCategoriesRef = useRef8([]);
5431
+ useEffect12(() => {
5432
+ knowledgeCategoriesRef.current = knowledgeCategories;
5433
+ }, [knowledgeCategories]);
5434
+ useEffect12(() => {
5435
+ hasAppliedKnowledgeInitialFiltersRef.current = false;
5436
+ hasAppliedTopicsRef.current = false;
5437
+ hasAppliedSubtopicsRef.current = false;
5438
+ hasAppliedContentsRef.current = false;
5439
+ }, [initialFilters]);
5440
+ useEffect12(() => {
5441
+ if (!initialFilters || hasAppliedKnowledgeInitialFiltersRef.current || knowledgeCategoriesRef.current.length === 0 || !handleCategoriesChange) {
5442
+ return;
5443
+ }
5444
+ const topicIds = initialFilters.topicIds || [];
5445
+ const subtopicIds = initialFilters.subtopicIds || [];
5446
+ const contentIds = initialFilters.contentIds || [];
5447
+ const hasKnowledgeSelections = topicIds.length > 0 || subtopicIds.length > 0 || contentIds.length > 0;
5448
+ if (!hasKnowledgeSelections) {
5449
+ hasAppliedKnowledgeInitialFiltersRef.current = true;
5450
+ return;
5451
+ }
5452
+ const currentKnowledgeCategories = knowledgeCategoriesRef.current;
5453
+ let changed = false;
5454
+ const updatedCategories = currentKnowledgeCategories.map((category) => {
5455
+ if (category.key === "tema" && topicIds.length > 0 && !hasAppliedTopicsRef.current) {
5456
+ const selectedIds = (category.itens || []).filter((item) => topicIds.includes(item.id)).map((item) => item.id);
5457
+ if (selectedIds.length > 0) {
5458
+ hasAppliedTopicsRef.current = true;
5459
+ changed = true;
5460
+ return { ...category, selectedIds };
5461
+ }
5462
+ return category;
5463
+ }
5464
+ if (category.key === "subtema" && subtopicIds.length > 0 && !hasAppliedSubtopicsRef.current) {
5465
+ const selectedIds = (category.itens || []).filter((item) => subtopicIds.includes(item.id)).map((item) => item.id);
5466
+ if (selectedIds.length > 0) {
5467
+ hasAppliedSubtopicsRef.current = true;
5468
+ changed = true;
5469
+ return { ...category, selectedIds };
5470
+ }
5471
+ return category;
5472
+ }
5473
+ if (category.key === "assunto" && contentIds.length > 0 && !hasAppliedContentsRef.current) {
5474
+ const selectedIds = (category.itens || []).filter((item) => contentIds.includes(item.id)).map((item) => item.id);
5475
+ if (selectedIds.length > 0) {
5476
+ hasAppliedContentsRef.current = true;
5477
+ changed = true;
5478
+ return { ...category, selectedIds };
5479
+ }
5480
+ return category;
5481
+ }
5482
+ return category;
5483
+ });
5484
+ if (changed) {
5485
+ handleCategoriesChange(updatedCategories);
5486
+ }
5487
+ if ((topicIds.length === 0 || hasAppliedTopicsRef.current) && (subtopicIds.length === 0 || hasAppliedSubtopicsRef.current) && (contentIds.length === 0 || hasAppliedContentsRef.current)) {
5488
+ hasAppliedKnowledgeInitialFiltersRef.current = true;
5489
+ }
5490
+ }, [initialFilters, knowledgeCategories, handleCategoriesChange]);
5491
+ return {
5492
+ hasAppliedKnowledgeInitialFiltersRef,
5493
+ hasAppliedTopicsRef,
5494
+ hasAppliedSubtopicsRef,
5495
+ hasAppliedContentsRef,
5496
+ knowledgeCategoriesRef
5497
+ };
5498
+ };
5499
+
5500
+ // src/components/ActivityFilters/ActivityFilters.tsx
5501
+ import { jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
5238
5502
  var questionTypesFallback = [
5239
5503
  "ALTERNATIVA" /* ALTERNATIVA */,
5240
5504
  "VERDADEIRO_FALSO" /* VERDADEIRO_FALSO */,
@@ -5290,42 +5554,15 @@ var updateBankCategoriesWithInitialFilters = (prevCategories, bankIds, derivedYe
5290
5554
  return category;
5291
5555
  });
5292
5556
  };
5293
- var getSelectedIdsForKnowledgeCategory = (category, filterIds) => {
5294
- return (category.itens || []).filter((item) => filterIds.includes(item.id)).map((item) => item.id);
5295
- };
5296
- var updateTopicCategory = (category, topicIds, hasAppliedTopicsRef) => {
5297
- const selectedIds = getSelectedIdsForKnowledgeCategory(category, topicIds);
5298
- if (selectedIds.length > 0) {
5299
- hasAppliedTopicsRef.current = true;
5300
- return { category: { ...category, selectedIds }, changed: true };
5301
- }
5302
- return { category, changed: false };
5303
- };
5304
- var updateSubtopicCategory = (category, subtopicIds, hasAppliedSubtopicsRef) => {
5305
- const selectedIds = getSelectedIdsForKnowledgeCategory(category, subtopicIds);
5306
- if (selectedIds.length > 0) {
5307
- hasAppliedSubtopicsRef.current = true;
5308
- return { category: { ...category, selectedIds }, changed: true };
5309
- }
5310
- return { category, changed: false };
5311
- };
5312
- var updateContentCategory = (category, contentIds, hasAppliedContentsRef) => {
5313
- const selectedIds = getSelectedIdsForKnowledgeCategory(category, contentIds);
5314
- if (selectedIds.length > 0) {
5315
- hasAppliedContentsRef.current = true;
5316
- return { category: { ...category, selectedIds }, changed: true };
5317
- }
5318
- return { category, changed: false };
5319
- };
5320
5557
  var QuestionTypeFilter = ({
5321
5558
  selectedTypes,
5322
5559
  onToggleType,
5323
5560
  allowedQuestionTypes
5324
5561
  }) => {
5325
5562
  const availableQuestionTypes = allowedQuestionTypes || questionTypesFallback;
5326
- return /* @__PURE__ */ jsxs16("div", { children: [
5327
- /* @__PURE__ */ jsx21(Text_default, { size: "sm", weight: "bold", className: "mb-3 block", children: "Tipo de quest\xE3o" }),
5328
- /* @__PURE__ */ jsx21("div", { className: "grid grid-cols-2 gap-2", children: availableQuestionTypes.map((questionType) => /* @__PURE__ */ jsx21(
5563
+ return /* @__PURE__ */ jsxs19("div", { children: [
5564
+ /* @__PURE__ */ jsx24(Text_default, { size: "sm", weight: "bold", className: "mb-3 block", children: "Tipo de quest\xE3o" }),
5565
+ /* @__PURE__ */ jsx24("div", { className: "grid grid-cols-2 gap-2", children: availableQuestionTypes.map((questionType) => /* @__PURE__ */ jsx24(
5329
5566
  Chips_default,
5330
5567
  {
5331
5568
  selected: selectedTypes.includes(questionType),
@@ -5345,16 +5582,16 @@ var BanksAndYearsFilter = ({
5345
5582
  error = null
5346
5583
  }) => {
5347
5584
  if (loading) {
5348
- return /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "text-text-600", children: "Carregando bancas..." });
5585
+ return /* @__PURE__ */ jsx24(Text_default, { size: "sm", className: "text-text-600", children: "Carregando bancas..." });
5349
5586
  }
5350
5587
  if (error) {
5351
- return /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "text-text-600", children: error });
5588
+ return /* @__PURE__ */ jsx24(Text_default, { size: "sm", className: "text-text-600", children: error });
5352
5589
  }
5353
5590
  if (banks.length === 0 && bankYears.length === 0) {
5354
- return /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "text-text-600", children: "Nenhuma banca encontrada" });
5591
+ return /* @__PURE__ */ jsx24(Text_default, { size: "sm", className: "text-text-600", children: "Nenhuma banca encontrada" });
5355
5592
  }
5356
5593
  if (bankCategories.length > 0) {
5357
- return /* @__PURE__ */ jsx21(
5594
+ return /* @__PURE__ */ jsx24(
5358
5595
  CheckboxGroup,
5359
5596
  {
5360
5597
  categories: bankCategories,
@@ -5366,86 +5603,6 @@ var BanksAndYearsFilter = ({
5366
5603
  }
5367
5604
  return null;
5368
5605
  };
5369
- var SubjectsFilter = ({
5370
- knowledgeAreas,
5371
- selectedSubject,
5372
- onSubjectChange,
5373
- loading = false,
5374
- error = null
5375
- }) => {
5376
- const { isDark } = useTheme();
5377
- if (loading) {
5378
- return /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "text-text-600", children: "Carregando mat\xE9rias..." });
5379
- }
5380
- if (error) {
5381
- return /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "text-text-600", children: error });
5382
- }
5383
- return /* @__PURE__ */ jsx21("div", { className: "grid grid-cols-3 gap-3", children: knowledgeAreas.map((area) => /* @__PURE__ */ jsx21(
5384
- Radio_default,
5385
- {
5386
- value: area.id,
5387
- checked: selectedSubject === area.id,
5388
- onChange: () => onSubjectChange(area.id),
5389
- label: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-2 w-full min-w-0", children: [
5390
- /* @__PURE__ */ jsx21(
5391
- "span",
5392
- {
5393
- className: "size-4 rounded-sm flex items-center justify-center shrink-0 text-text-950",
5394
- style: {
5395
- backgroundColor: getSubjectColorWithOpacity(
5396
- area.color,
5397
- isDark
5398
- )
5399
- },
5400
- children: /* @__PURE__ */ jsx21(
5401
- IconRender_default,
5402
- {
5403
- iconName: area.icon || "BookOpen",
5404
- size: 14,
5405
- color: "currentColor"
5406
- }
5407
- )
5408
- }
5409
- ),
5410
- /* @__PURE__ */ jsx21("span", { className: "truncate flex-1", children: area.name })
5411
- ] })
5412
- },
5413
- area.id
5414
- )) });
5415
- };
5416
- var KnowledgeStructureFilter = ({
5417
- knowledgeStructure,
5418
- knowledgeCategories,
5419
- handleCategoriesChange
5420
- }) => {
5421
- return /* @__PURE__ */ jsxs16("div", { className: "mt-4", children: [
5422
- /* @__PURE__ */ jsx21(Text_default, { size: "sm", weight: "bold", className: "mb-3 block", children: "Tema, Subtema e Assunto" }),
5423
- knowledgeStructure.loading && /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "text-text-600 mb-3", children: "Carregando estrutura de conhecimento..." }),
5424
- knowledgeStructure.error && /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "mb-3 text-error-500", children: knowledgeStructure.error }),
5425
- knowledgeCategories.length > 0 && handleCategoriesChange && /* @__PURE__ */ jsx21(
5426
- CheckboxGroup,
5427
- {
5428
- categories: knowledgeCategories,
5429
- onCategoriesChange: handleCategoriesChange,
5430
- compactSingleItem: false,
5431
- showSingleItem: true
5432
- }
5433
- ),
5434
- !knowledgeStructure.loading && knowledgeCategories.length === 0 && knowledgeStructure.topics.length === 0 && /* @__PURE__ */ jsx21(Text_default, { size: "sm", className: "text-text-600", children: "Nenhum tema dispon\xEDvel para as mat\xE9rias selecionadas" })
5435
- ] });
5436
- };
5437
- var FilterActions = ({
5438
- onClearFilters,
5439
- onApplyFilters
5440
- }) => {
5441
- if (!onClearFilters && !onApplyFilters) {
5442
- return null;
5443
- }
5444
- return /* @__PURE__ */ jsxs16("div", { className: "grid grid-cols-2 gap-2 justify-end mt-4 px-4 pt-4 border-t border-border-200", children: [
5445
- onClearFilters && /* @__PURE__ */ jsx21(Button_default, { variant: "link", onClick: onClearFilters, size: "small", children: "Limpar filtros" }),
5446
- onApplyFilters && /* @__PURE__ */ jsx21(Button_default, { variant: "outline", onClick: onApplyFilters, size: "small", children: "Filtrar" })
5447
- ] });
5448
- };
5449
5606
  var ActivityFilters = ({
5450
5607
  apiClient,
5451
5608
  onFiltersChange,
@@ -5483,19 +5640,22 @@ var ActivityFilters = ({
5483
5640
  selectedSubjects: selectedSubject ? [selectedSubject] : [],
5484
5641
  institutionId
5485
5642
  });
5486
- const prevAllowedQuestionTypesRef = useRef7(null);
5487
- const hasAppliedBasicInitialFiltersRef = useRef7(false);
5488
- const hasAppliedBankInitialFiltersRef = useRef7(false);
5489
- const hasAppliedKnowledgeInitialFiltersRef = useRef7(false);
5490
- const hasRequestedTopicsRef = useRef7(false);
5491
- const hasRequestedSubtopicsRef = useRef7(false);
5492
- const hasRequestedContentsRef = useRef7(false);
5493
- const hasAppliedTopicsRef = useRef7(false);
5494
- const hasAppliedSubtopicsRef = useRef7(false);
5495
- const hasAppliedContentsRef = useRef7(false);
5496
- const bankCategoriesRef = useRef7([]);
5497
- const knowledgeCategoriesRef = useRef7([]);
5498
- useEffect11(() => {
5643
+ const prevAllowedQuestionTypesRef = useRef9(null);
5644
+ const hasAppliedBasicInitialFiltersRef = useRef9(false);
5645
+ const hasAppliedBankInitialFiltersRef = useRef9(false);
5646
+ const bankCategoriesRef = useRef9([]);
5647
+ useInitialFiltersLoader({
5648
+ initialFilters,
5649
+ loadTopics,
5650
+ loadSubtopics,
5651
+ loadContents
5652
+ });
5653
+ useKnowledgeStructureInitialFilters({
5654
+ initialFilters,
5655
+ knowledgeCategories,
5656
+ handleCategoriesChange
5657
+ });
5658
+ useEffect13(() => {
5499
5659
  if (!allowedQuestionTypes || allowedQuestionTypes.length === 0) {
5500
5660
  prevAllowedQuestionTypesRef.current = null;
5501
5661
  return;
@@ -5529,7 +5689,7 @@ var ActivityFilters = ({
5529
5689
  });
5530
5690
  }, [allowedQuestionTypes]);
5531
5691
  const [bankCategories, setBankCategories] = useState10([]);
5532
- useEffect11(() => {
5692
+ useEffect13(() => {
5533
5693
  bankCategoriesRef.current = bankCategories;
5534
5694
  }, [bankCategories]);
5535
5695
  const selectedSubjects = useMemo3(
@@ -5545,7 +5705,7 @@ var ActivityFilters = ({
5545
5705
  const handleBankCategoriesChange = (updatedCategories) => {
5546
5706
  setBankCategories(updatedCategories);
5547
5707
  };
5548
- useEffect11(() => {
5708
+ useEffect13(() => {
5549
5709
  setBankCategories((prevCategories) => {
5550
5710
  const bankCategory = {
5551
5711
  key: "banca",
@@ -5571,21 +5731,11 @@ var ActivityFilters = ({
5571
5731
  return [bankCategory, yearCategory];
5572
5732
  });
5573
5733
  }, [banks, bankYears]);
5574
- useEffect11(() => {
5575
- knowledgeCategoriesRef.current = knowledgeCategories;
5576
- }, [knowledgeCategories]);
5577
- useEffect11(() => {
5734
+ useEffect13(() => {
5578
5735
  hasAppliedBasicInitialFiltersRef.current = false;
5579
5736
  hasAppliedBankInitialFiltersRef.current = false;
5580
- hasAppliedKnowledgeInitialFiltersRef.current = false;
5581
- hasRequestedTopicsRef.current = false;
5582
- hasRequestedSubtopicsRef.current = false;
5583
- hasRequestedContentsRef.current = false;
5584
- hasAppliedTopicsRef.current = false;
5585
- hasAppliedSubtopicsRef.current = false;
5586
- hasAppliedContentsRef.current = false;
5587
5737
  }, [initialFilters]);
5588
- useEffect11(() => {
5738
+ useEffect13(() => {
5589
5739
  if (!initialFilters || hasAppliedBasicInitialFiltersRef.current) {
5590
5740
  return;
5591
5741
  }
@@ -5597,7 +5747,7 @@ var ActivityFilters = ({
5597
5747
  }
5598
5748
  hasAppliedBasicInitialFiltersRef.current = true;
5599
5749
  }, [initialFilters]);
5600
- useEffect11(() => {
5750
+ useEffect13(() => {
5601
5751
  if (!initialFilters || hasAppliedBankInitialFiltersRef.current || bankCategoriesRef.current.length === 0) {
5602
5752
  return;
5603
5753
  }
@@ -5629,90 +5779,7 @@ var ActivityFilters = ({
5629
5779
  );
5630
5780
  hasAppliedBankInitialFiltersRef.current = true;
5631
5781
  }, [initialFilters, bankCategories]);
5632
- useEffect11(() => {
5633
- if (!initialFilters) {
5634
- return;
5635
- }
5636
- const subjectIds = initialFilters.subjectIds || [];
5637
- const topicIds = initialFilters.topicIds || [];
5638
- const subtopicIds = initialFilters.subtopicIds || [];
5639
- if (subjectIds.length > 0 && !hasRequestedTopicsRef.current) {
5640
- if (loadTopics) {
5641
- loadTopics(subjectIds);
5642
- }
5643
- hasRequestedTopicsRef.current = true;
5644
- }
5645
- if (topicIds.length > 0 && !hasRequestedSubtopicsRef.current) {
5646
- if (loadSubtopics) {
5647
- loadSubtopics(topicIds);
5648
- }
5649
- hasRequestedSubtopicsRef.current = true;
5650
- }
5651
- if (subtopicIds.length > 0 && !hasRequestedContentsRef.current) {
5652
- if (loadContents) {
5653
- loadContents(subtopicIds);
5654
- }
5655
- hasRequestedContentsRef.current = true;
5656
- }
5657
- }, [initialFilters, loadTopics, loadSubtopics, loadContents]);
5658
- useEffect11(() => {
5659
- if (!initialFilters || hasAppliedKnowledgeInitialFiltersRef.current || knowledgeCategoriesRef.current.length === 0 || !handleCategoriesChange) {
5660
- return;
5661
- }
5662
- const topicIds = initialFilters.topicIds || [];
5663
- const subtopicIds = initialFilters.subtopicIds || [];
5664
- const contentIds = initialFilters.contentIds || [];
5665
- const hasKnowledgeSelections = topicIds.length > 0 || subtopicIds.length > 0 || contentIds.length > 0;
5666
- if (!hasKnowledgeSelections) {
5667
- hasAppliedKnowledgeInitialFiltersRef.current = true;
5668
- return;
5669
- }
5670
- const currentKnowledgeCategories = knowledgeCategoriesRef.current;
5671
- let changed = false;
5672
- const updatedCategories = currentKnowledgeCategories.map((category) => {
5673
- if (category.key === "tema" && topicIds.length > 0 && !hasAppliedTopicsRef.current) {
5674
- const result = updateTopicCategory(
5675
- category,
5676
- topicIds,
5677
- hasAppliedTopicsRef
5678
- );
5679
- if (result.changed) {
5680
- changed = true;
5681
- }
5682
- return result.category;
5683
- }
5684
- if (category.key === "subtema" && subtopicIds.length > 0 && !hasAppliedSubtopicsRef.current) {
5685
- const result = updateSubtopicCategory(
5686
- category,
5687
- subtopicIds,
5688
- hasAppliedSubtopicsRef
5689
- );
5690
- if (result.changed) {
5691
- changed = true;
5692
- }
5693
- return result.category;
5694
- }
5695
- if (category.key === "assunto" && contentIds.length > 0 && !hasAppliedContentsRef.current) {
5696
- const result = updateContentCategory(
5697
- category,
5698
- contentIds,
5699
- hasAppliedContentsRef
5700
- );
5701
- if (result.changed) {
5702
- changed = true;
5703
- }
5704
- return result.category;
5705
- }
5706
- return category;
5707
- });
5708
- if (changed) {
5709
- handleCategoriesChange(updatedCategories);
5710
- }
5711
- if ((topicIds.length === 0 || hasAppliedTopicsRef.current) && (subtopicIds.length === 0 || hasAppliedSubtopicsRef.current) && (contentIds.length === 0 || hasAppliedContentsRef.current)) {
5712
- hasAppliedKnowledgeInitialFiltersRef.current = true;
5713
- }
5714
- }, [initialFilters, knowledgeCategories, handleCategoriesChange]);
5715
- useEffect11(() => {
5782
+ useEffect13(() => {
5716
5783
  if (loadBanks) {
5717
5784
  loadBanks();
5718
5785
  }
@@ -5743,12 +5810,12 @@ var ActivityFilters = ({
5743
5810
  yearIds: "ano"
5744
5811
  });
5745
5812
  }, [bankCategories]);
5746
- const onFiltersChangeRef = useRef7(onFiltersChange);
5747
- useEffect11(() => {
5813
+ const onFiltersChangeRef = useRef9(onFiltersChange);
5814
+ useEffect13(() => {
5748
5815
  onFiltersChangeRef.current = onFiltersChange;
5749
5816
  }, [onFiltersChange]);
5750
- const prevFiltersRef = useRef7(null);
5751
- useEffect11(() => {
5817
+ const prevFiltersRef = useRef9(null);
5818
+ useEffect13(() => {
5752
5819
  const knowledgeIds = getSelectedKnowledgeIds();
5753
5820
  const bankIds = getSelectedBankIds();
5754
5821
  const filters = {
@@ -5774,10 +5841,10 @@ var ActivityFilters = ({
5774
5841
  ]);
5775
5842
  const containerClassName = variant === "popover" ? "w-full bg-background" : "w-[400px] flex-shrink-0 p-4 bg-background";
5776
5843
  const contentClassName = variant === "popover" ? "p-4" : "";
5777
- return /* @__PURE__ */ jsxs16("div", { className: containerClassName, children: [
5778
- variant === "default" && /* @__PURE__ */ jsx21("section", { className: "flex flex-row items-center gap-2 text-text-950 mb-4", children: /* @__PURE__ */ jsx21(Text_default, { size: "lg", weight: "bold", children: "Filtro de quest\xF5es" }) }),
5779
- /* @__PURE__ */ jsx21("div", { className: contentClassName, children: /* @__PURE__ */ jsxs16("section", { className: "flex flex-col gap-4", children: [
5780
- /* @__PURE__ */ jsx21(
5844
+ return /* @__PURE__ */ jsxs19("div", { className: containerClassName, children: [
5845
+ variant === "default" && /* @__PURE__ */ jsx24("section", { className: "flex flex-row items-center gap-2 text-text-950 mb-4", children: /* @__PURE__ */ jsx24(Text_default, { size: "lg", weight: "bold", children: "Filtro de quest\xF5es" }) }),
5846
+ /* @__PURE__ */ jsx24("div", { className: contentClassName, children: /* @__PURE__ */ jsxs19("section", { className: "flex flex-col gap-4", children: [
5847
+ /* @__PURE__ */ jsx24(
5781
5848
  QuestionTypeFilter,
5782
5849
  {
5783
5850
  selectedTypes: selectedQuestionTypes,
@@ -5785,7 +5852,7 @@ var ActivityFilters = ({
5785
5852
  allowedQuestionTypes: availableQuestionTypes
5786
5853
  }
5787
5854
  ),
5788
- loadingQuestionTypes && /* @__PURE__ */ jsx21(
5855
+ loadingQuestionTypes && /* @__PURE__ */ jsx24(
5789
5856
  Text_default,
5790
5857
  {
5791
5858
  size: "sm",
@@ -5794,7 +5861,7 @@ var ActivityFilters = ({
5794
5861
  children: "Carregando tipos de quest\xE3o..."
5795
5862
  }
5796
5863
  ),
5797
- questionTypesError && /* @__PURE__ */ jsx21(
5864
+ questionTypesError && /* @__PURE__ */ jsx24(
5798
5865
  Text_default,
5799
5866
  {
5800
5867
  size: "sm",
@@ -5803,9 +5870,9 @@ var ActivityFilters = ({
5803
5870
  children: questionTypesError
5804
5871
  }
5805
5872
  ),
5806
- /* @__PURE__ */ jsxs16("div", { children: [
5807
- /* @__PURE__ */ jsx21(Text_default, { size: "sm", weight: "bold", className: "mb-3 block", children: "Banca de vestibular" }),
5808
- /* @__PURE__ */ jsx21(
5873
+ /* @__PURE__ */ jsxs19("div", { children: [
5874
+ /* @__PURE__ */ jsx24(Text_default, { size: "sm", weight: "bold", className: "mb-3 block", children: "Banca de vestibular" }),
5875
+ /* @__PURE__ */ jsx24(
5809
5876
  BanksAndYearsFilter,
5810
5877
  {
5811
5878
  banks,
@@ -5817,9 +5884,9 @@ var ActivityFilters = ({
5817
5884
  }
5818
5885
  )
5819
5886
  ] }),
5820
- /* @__PURE__ */ jsxs16("div", { children: [
5821
- /* @__PURE__ */ jsx21("div", { className: "flex flex-row justify-between items-center mb-3", children: /* @__PURE__ */ jsx21(Text_default, { size: "sm", weight: "bold", children: "Mat\xE9ria" }) }),
5822
- /* @__PURE__ */ jsx21(
5887
+ /* @__PURE__ */ jsxs19("div", { children: [
5888
+ /* @__PURE__ */ jsx24("div", { className: "flex flex-row justify-between items-center mb-3", children: /* @__PURE__ */ jsx24(Text_default, { size: "sm", weight: "bold", children: "Mat\xE9ria" }) }),
5889
+ /* @__PURE__ */ jsx24(
5823
5890
  SubjectsFilter,
5824
5891
  {
5825
5892
  knowledgeAreas,
@@ -5830,7 +5897,7 @@ var ActivityFilters = ({
5830
5897
  }
5831
5898
  )
5832
5899
  ] }),
5833
- selectedSubject && /* @__PURE__ */ jsx21(
5900
+ selectedSubject && /* @__PURE__ */ jsx24(
5834
5901
  KnowledgeStructureFilter,
5835
5902
  {
5836
5903
  knowledgeStructure,
@@ -5838,7 +5905,7 @@ var ActivityFilters = ({
5838
5905
  handleCategoriesChange
5839
5906
  }
5840
5907
  ),
5841
- /* @__PURE__ */ jsx21(
5908
+ /* @__PURE__ */ jsx24(
5842
5909
  FilterActions,
5843
5910
  {
5844
5911
  onClearFilters,
@@ -5851,22 +5918,28 @@ var ActivityFilters = ({
5851
5918
  var ActivityFiltersPopover = ({
5852
5919
  onFiltersChange,
5853
5920
  triggerLabel = "Filtro de quest\xF5es",
5921
+ initialFilters,
5854
5922
  ...activityFiltersProps
5855
5923
  }) => {
5856
5924
  const [open, setOpen] = useState10(false);
5857
- return /* @__PURE__ */ jsxs16(DropdownMenu_default, { open, onOpenChange: setOpen, children: [
5858
- /* @__PURE__ */ jsx21(DropdownMenuTrigger, { children: /* @__PURE__ */ jsx21(Button_default, { variant: "outline", children: triggerLabel }) }),
5859
- /* @__PURE__ */ jsx21(
5925
+ const appliedFilters = useQuestionFiltersStore(
5926
+ (state) => state.appliedFilters
5927
+ );
5928
+ const effectiveInitialFilters = appliedFilters ?? initialFilters;
5929
+ return /* @__PURE__ */ jsxs19(DropdownMenu_default, { open, onOpenChange: setOpen, children: [
5930
+ /* @__PURE__ */ jsx24(DropdownMenuTrigger, { children: /* @__PURE__ */ jsx24(Button_default, { variant: "outline", children: triggerLabel }) }),
5931
+ /* @__PURE__ */ jsx24(
5860
5932
  DropdownMenuContent,
5861
5933
  {
5862
5934
  className: "w-[90vw] max-w-[400px] max-h-[calc(100vh-8rem)] overflow-y-auto p-0",
5863
5935
  align: "start",
5864
- children: /* @__PURE__ */ jsx21(
5936
+ children: /* @__PURE__ */ jsx24(
5865
5937
  ActivityFilters,
5866
5938
  {
5867
5939
  onFiltersChange,
5868
5940
  variant: "popover",
5869
- ...activityFiltersProps
5941
+ ...activityFiltersProps,
5942
+ initialFilters: effectiveInitialFilters
5870
5943
  }
5871
5944
  )
5872
5945
  }