analytica-frontend-lib 1.3.3 → 1.3.5

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.
@@ -1,4 +1,4 @@
1
1
  export { StudentLessonProgressModal, default, } from './StudentLessonProgressModal';
2
- export type { StudentLessonProgressModalProps, StudentLessonProgressData, StudentLessonProgressLabels, LessonProgressItem, LessonProgressStatus, } from './types';
2
+ export type { StudentLessonProgressModalProps, StudentLessonProgressData, StudentLessonProgressLabels, TopicProgressItem, SubtopicProgressItem, ContentProgressItem, LessonProgressStatus, } from './types';
3
3
  export { DEFAULT_LESSON_PROGRESS_LABELS } from './types';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/StudentLessonProgressModal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,OAAO,GACR,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,+BAA+B,EAC/B,yBAAyB,EACzB,2BAA2B,EAC3B,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/StudentLessonProgressModal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,OAAO,GACR,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,+BAA+B,EAC/B,yBAAyB,EACzB,2BAA2B,EAC3B,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC"}
@@ -2770,16 +2770,106 @@ var DEFAULT_LESSON_PROGRESS_LABELS = {
2770
2770
 
2771
2771
  // src/components/StudentLessonProgressModal/StudentLessonProgressModal.tsx
2772
2772
  var import_jsx_runtime13 = require("react/jsx-runtime");
2773
- var LessonAccordionItem = ({
2773
+ var ContentAccordionItem = ({
2774
2774
  item,
2775
- noDataMessage,
2776
- level = 0
2775
+ noDataMessage
2776
+ }) => {
2777
+ const hasNoData = item.progress === 0 && !item.isCompleted;
2778
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between p-4 border-t border-border-50", children: [
2779
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "sm", className: "text-text-950", children: item.content.name }),
2780
+ hasNoData ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "xs", className: "text-text-500", children: noDataMessage }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2781
+ Text_default,
2782
+ {
2783
+ size: "xs",
2784
+ weight: "medium",
2785
+ className: "text-text-500 whitespace-nowrap",
2786
+ children: [
2787
+ Math.round(item.progress),
2788
+ "%"
2789
+ ]
2790
+ }
2791
+ )
2792
+ ] });
2793
+ };
2794
+ var SubtopicAccordionItem = ({
2795
+ item,
2796
+ noDataMessage
2797
+ }) => {
2798
+ const [isExpanded, setIsExpanded] = (0, import_react5.useState)(false);
2799
+ const hasChildren = item.contents && item.contents.length > 0;
2800
+ const hasNoData = item.status === "no_data";
2801
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col", children: [
2802
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2803
+ "button",
2804
+ {
2805
+ type: "button",
2806
+ onClick: () => hasChildren && setIsExpanded(!isExpanded),
2807
+ disabled: !hasChildren,
2808
+ className: cn(
2809
+ "w-full flex items-center justify-between gap-3 p-4 text-left transition-colors duration-200",
2810
+ "focus:outline-none focus:ring-2 focus:ring-primary-950 focus:ring-inset rounded-xl",
2811
+ "border-t border-border-50",
2812
+ hasChildren && "cursor-pointer hover:bg-background-50",
2813
+ !hasChildren && "cursor-default"
2814
+ ),
2815
+ "aria-expanded": hasChildren ? isExpanded : void 0,
2816
+ children: [
2817
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between flex-1 min-w-0", children: [
2818
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "md", weight: "medium", className: "text-text-950", children: item.subtopic.name }),
2819
+ !hasNoData && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2820
+ Text_default,
2821
+ {
2822
+ size: "xs",
2823
+ weight: "medium",
2824
+ className: "text-text-500 whitespace-nowrap",
2825
+ children: [
2826
+ Math.round(item.progress),
2827
+ "%"
2828
+ ]
2829
+ }
2830
+ )
2831
+ ] }),
2832
+ hasChildren && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2833
+ import_phosphor_react4.CaretRight,
2834
+ {
2835
+ size: 20,
2836
+ className: cn(
2837
+ "transition-transform duration-200 flex-shrink-0 text-text-700",
2838
+ isExpanded ? "rotate-90" : "rotate-0"
2839
+ )
2840
+ }
2841
+ )
2842
+ ]
2843
+ }
2844
+ ),
2845
+ hasChildren && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2846
+ "div",
2847
+ {
2848
+ "data-testid": `accordion-content-subtopic-${item.subtopic.id}`,
2849
+ "data-expanded": isExpanded,
2850
+ className: cn(
2851
+ "transition-all duration-300 ease-in-out overflow-hidden",
2852
+ isExpanded ? "max-h-[2000px] opacity-100" : "max-h-0 opacity-0"
2853
+ ),
2854
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pl-4", children: item.contents.map((content) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2855
+ ContentAccordionItem,
2856
+ {
2857
+ item: content,
2858
+ noDataMessage
2859
+ },
2860
+ content.content.id
2861
+ )) })
2862
+ }
2863
+ )
2864
+ ] });
2865
+ };
2866
+ var TopicAccordionItem = ({
2867
+ item,
2868
+ noDataMessage
2777
2869
  }) => {
2778
2870
  const [isExpanded, setIsExpanded] = (0, import_react5.useState)(false);
2779
- const hasChildren = item.children && item.children.length > 0;
2780
- const hasNoData = item.status === "no_data" || item.progress === null;
2781
- const progressValue = item.progress ?? 0;
2782
- const paddingLeft = level > 0 ? `${level * 16}px` : void 0;
2871
+ const hasChildren = item.subtopics && item.subtopics.length > 0;
2872
+ const hasNoData = item.status === "no_data";
2783
2873
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col", children: [
2784
2874
  /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2785
2875
  "button",
@@ -2791,19 +2881,17 @@ var LessonAccordionItem = ({
2791
2881
  "w-full flex items-center justify-between gap-3 p-4 text-left transition-colors duration-200",
2792
2882
  "focus:outline-none focus:ring-2 focus:ring-primary-950 focus:ring-inset rounded-xl",
2793
2883
  hasChildren && "cursor-pointer hover:bg-background-50",
2794
- !hasChildren && "cursor-default",
2795
- level > 0 && "border-t border-border-50"
2884
+ !hasChildren && "cursor-default"
2796
2885
  ),
2797
- style: { paddingLeft },
2798
2886
  "aria-expanded": hasChildren ? isExpanded : void 0,
2799
2887
  children: [
2800
- level === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-2 flex-1 min-w-0", children: [
2801
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "lg", weight: "bold", className: "text-text-950", children: item.topic }),
2888
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-2 flex-1 min-w-0", children: [
2889
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "lg", weight: "bold", className: "text-text-950", children: item.topic.name }),
2802
2890
  hasNoData ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "xs", className: "text-text-500", children: noDataMessage }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-row items-center gap-2", children: [
2803
2891
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2804
2892
  ProgressBar_default,
2805
2893
  {
2806
- value: progressValue,
2894
+ value: item.progress,
2807
2895
  variant: "green",
2808
2896
  size: "medium"
2809
2897
  }
@@ -2815,30 +2903,13 @@ var LessonAccordionItem = ({
2815
2903
  weight: "medium",
2816
2904
  className: "text-text-950 whitespace-nowrap",
2817
2905
  children: [
2818
- Math.round(progressValue),
2819
- "%"
2820
- ]
2821
- }
2822
- )
2823
- ] })
2824
- ] }) : (
2825
- /* Level 1+: Subtopic/lesson with only percentage */
2826
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center justify-between flex-1 min-w-0", children: [
2827
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "md", weight: "medium", className: "text-text-950", children: item.topic }),
2828
- !hasNoData && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2829
- Text_default,
2830
- {
2831
- size: "xs",
2832
- weight: "medium",
2833
- className: "text-text-500 whitespace-nowrap",
2834
- children: [
2835
- Math.round(progressValue),
2906
+ Math.round(item.progress),
2836
2907
  "%"
2837
2908
  ]
2838
2909
  }
2839
2910
  )
2840
2911
  ] })
2841
- ),
2912
+ ] }),
2842
2913
  hasChildren && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2843
2914
  import_phosphor_react4.CaretRight,
2844
2915
  {
@@ -2855,20 +2926,19 @@ var LessonAccordionItem = ({
2855
2926
  hasChildren && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2856
2927
  "div",
2857
2928
  {
2858
- "data-testid": `accordion-content-${item.id}`,
2929
+ "data-testid": `accordion-content-${item.topic.id}`,
2859
2930
  "data-expanded": isExpanded,
2860
2931
  className: cn(
2861
2932
  "transition-all duration-300 ease-in-out overflow-hidden",
2862
2933
  isExpanded ? "max-h-[2000px] opacity-100" : "max-h-0 opacity-0"
2863
2934
  ),
2864
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pl-4", children: item.children.map((child) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2865
- LessonAccordionItem,
2935
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pl-4", children: item.subtopics.map((subtopic) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2936
+ SubtopicAccordionItem,
2866
2937
  {
2867
- item: child,
2868
- noDataMessage,
2869
- level: level + 1
2938
+ item: subtopic,
2939
+ noDataMessage
2870
2940
  },
2871
- child.id
2941
+ subtopic.subtopic.id
2872
2942
  )) })
2873
2943
  }
2874
2944
  )
@@ -2958,20 +3028,20 @@ var ProgressContent = ({
2958
3028
  ] }),
2959
3029
  data.lessonProgress.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex flex-col gap-4 pt-4", children: [
2960
3030
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Text_default, { size: "lg", weight: "bold", className: "text-text-950", children: labels.lessonProgressTitle }),
2961
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex flex-col gap-2", children: data.lessonProgress.map((item) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
3031
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex flex-col gap-2", children: data.lessonProgress.map((topic) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2962
3032
  "div",
2963
3033
  {
2964
- "data-testid": `lesson-item-${item.id}`,
3034
+ "data-testid": `lesson-item-${topic.topic.id}`,
2965
3035
  className: "bg-background rounded-xl border border-border-50",
2966
3036
  children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2967
- LessonAccordionItem,
3037
+ TopicAccordionItem,
2968
3038
  {
2969
- item,
3039
+ item: topic,
2970
3040
  noDataMessage: labels.noDataMessage
2971
3041
  }
2972
3042
  )
2973
3043
  },
2974
- item.id
3044
+ topic.topic.id
2975
3045
  )) })
2976
3046
  ] })
2977
3047
  ] });