@uniai-fe/ui-legacy 0.1.6 → 0.1.8

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 (103) hide show
  1. package/README.md +3 -1
  2. package/package.json +35 -37
  3. package/src/button/index.tsx +12 -12
  4. package/src/components.tsx +2 -2
  5. package/src/icon/icon.scss +1 -1
  6. package/src/icon/index.tsx +4 -4
  7. package/src/icon/styled.tsx +2 -2
  8. package/src/index.scss +2 -2
  9. package/src/index.tsx +0 -2
  10. package/src/types/index.d.ts +2 -2
  11. package/src/chart/chart.scss +0 -11
  12. package/src/chart/components/Contents.tsx +0 -17
  13. package/src/chart/components/control/Button.tsx +0 -39
  14. package/src/chart/components/control/Container.tsx +0 -27
  15. package/src/chart/components/control/Provider.tsx +0 -117
  16. package/src/chart/components/control/index.tsx +0 -12
  17. package/src/chart/components/custom/ActivePieSector.tsx +0 -29
  18. package/src/chart/components/graphs/ArcGauge.tsx +0 -58
  19. package/src/chart/components/graphs/ArcMeter.tsx +0 -112
  20. package/src/chart/components/graphs/Area.tsx +0 -132
  21. package/src/chart/components/graphs/Bar.tsx +0 -179
  22. package/src/chart/components/graphs/Doughnut.tsx +0 -90
  23. package/src/chart/components/graphs/Line.tsx +0 -123
  24. package/src/chart/components/graphs/index.tsx +0 -17
  25. package/src/chart/components/ticks/XAxis.tsx +0 -39
  26. package/src/chart/components/ticks/index.tsx +0 -7
  27. package/src/chart/index.tsx +0 -17
  28. package/src/chart/styled.tsx +0 -3
  29. package/src/chart/styles/scss/arc-gauge.scss +0 -11
  30. package/src/chart/styles/scss/arc-meter.scss +0 -6
  31. package/src/chart/styles/scss/control.scss +0 -34
  32. package/src/chart/styles/scss/filter.scss +0 -0
  33. package/src/chart/styles/scss/graph.scss +0 -3
  34. package/src/chart/styles/scss/legend.scss +0 -35
  35. package/src/chart/styles/scss/level.color.scss +0 -7
  36. package/src/chart/styles/scss/tick.scss +0 -48
  37. package/src/chart/styles/scss/tooltip.scss +0 -70
  38. package/src/chart/styles/styled/arc-gauge.ts +0 -65
  39. package/src/chart/styles/styled/arc-meter.ts +0 -42
  40. package/src/chart/styles/styled/common.ts +0 -14
  41. package/src/chart/styles/styled/control.ts +0 -31
  42. package/src/chart/styles/styled/legend.ts +0 -11
  43. package/src/chart/svg/gauge-track.min.svg +0 -1
  44. package/src/chart/utils/getLevel.ts +0 -23
  45. package/src/icon/components/chart/Control.tsx +0 -40
  46. package/src/icon/components/chart/index.tsx +0 -7
  47. package/src/icon/components/health-score/HealthScore.tsx +0 -46
  48. package/src/icon/components/health-score/index.tsx +0 -3
  49. package/src/icon/styles/scss/chart.scss +0 -3
  50. package/src/icon/styles/styled/chart.ts +0 -17
  51. package/src/icon/svg/chart/control/pan-left.svg +0 -4
  52. package/src/icon/svg/chart/control/pan-right.svg +0 -4
  53. package/src/icon/svg/chart/control/zoom-in.svg +0 -4
  54. package/src/icon/svg/chart/control/zoom-out.svg +0 -4
  55. package/src/styled.template.tsx +0 -5
  56. package/src/template/compare/compare.scss +0 -1
  57. package/src/template/compare/components/box/Container.tsx +0 -33
  58. package/src/template/compare/components/box/TextStrong.tsx +0 -15
  59. package/src/template/compare/components/box/TextSub.tsx +0 -15
  60. package/src/template/compare/components/box/index.tsx +0 -11
  61. package/src/template/compare/components/button/Remove.tsx +0 -28
  62. package/src/template/compare/components/button/index.tsx +0 -5
  63. package/src/template/compare/components/chart/Container.tsx +0 -33
  64. package/src/template/compare/components/chart/graph/Container.tsx +0 -15
  65. package/src/template/compare/components/chart/graph/Item.tsx +0 -13
  66. package/src/template/compare/components/chart/index.tsx +0 -16
  67. package/src/template/compare/components/chart/legend/Container.tsx +0 -23
  68. package/src/template/compare/components/chart/legend/Section.tsx +0 -31
  69. package/src/template/compare/components/select-list/Container.tsx +0 -15
  70. package/src/template/compare/components/select-list/Header.tsx +0 -15
  71. package/src/template/compare/components/select-list/Item.tsx +0 -15
  72. package/src/template/compare/components/select-list/List.tsx +0 -18
  73. package/src/template/compare/components/select-list/index.tsx +0 -13
  74. package/src/template/compare/index.tsx +0 -13
  75. package/src/template/compare/styled.tsx +0 -17
  76. package/src/template/compare/styles/scss/variables.scss +0 -17
  77. package/src/template/compare/styles/styled-components/chart/graph.ts +0 -26
  78. package/src/template/compare/styles/styled-components/chart/layout.ts +0 -38
  79. package/src/template/compare/styles/styled-components/chart/legend.ts +0 -64
  80. package/src/template/compare/styles/styled-components/common.ts +0 -57
  81. package/src/template/compare/styles/styled-components/select-list.ts +0 -36
  82. package/src/template/filter/components/Container.tsx +0 -39
  83. package/src/template/filter/components/Group.tsx +0 -100
  84. package/src/template/filter/components/ToggleButton.tsx +0 -27
  85. package/src/template/filter/index.tsx +0 -5
  86. package/src/template/filter/styled.tsx +0 -3
  87. package/src/template/filter/styles/styled-components/filter.ts +0 -66
  88. package/src/template/health-score/components/Chart.tsx +0 -38
  89. package/src/template/health-score/index.tsx +0 -3
  90. package/src/template/health-score/styled.tsx +0 -3
  91. package/src/template/health-score/styles/styled/chart.ts +0 -26
  92. package/src/template.tsx +0 -5
  93. package/src/types/chart/axis.d.ts +0 -15
  94. package/src/types/chart/control.d.ts +0 -109
  95. package/src/types/chart/data.d.ts +0 -41
  96. package/src/types/chart/dot.d.ts +0 -3
  97. package/src/types/chart/index.d.ts +0 -7
  98. package/src/types/chart/legend.d.ts +0 -124
  99. package/src/types/chart/props.d.ts +0 -271
  100. package/src/types/chart/tick.d.ts +0 -30
  101. package/src/types/template/compare/chart.d.ts +0 -8
  102. package/src/types/template/filter.d.ts +0 -39
  103. package/src/types/template/index.d.ts +0 -2
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # client / ui
1
+ # client / ui-legacy
2
2
 
3
+ `deprecated`
3
4
  스타일링 도구와 토큰, 디자인 시스템, 컴포넌트 등 관리
5
+ -> `design/*`로 이동
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniai-fe/ui-legacy",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Legacy UI Toolkit for UNIAI FE Projects",
5
5
  "type": "module",
6
6
  "private": false,
@@ -10,9 +10,9 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "packageManager": "pnpm@10.22.0",
13
+ "packageManager": "pnpm@10.23.0",
14
14
  "engines": {
15
- "node": ">=22",
15
+ "node": ">=24",
16
16
  "pnpm": ">=10"
17
17
  },
18
18
  "author": {
@@ -42,15 +42,11 @@
42
42
  "./types": "./src/types/index.d.ts",
43
43
  "./components": "./src/components.tsx",
44
44
  "./components/styled": "./src/styled.components.tsx",
45
- "./template": "./src/template.tsx",
46
- "./template/styled": "./src/styled.template.tsx",
47
45
  "./frame": "./src/frame/index.tsx",
48
46
  "./frame/styled": "./src/frame/styled.tsx",
49
47
  "./modal": "./src/modal/index.tsx",
50
48
  "./icon": "./src/icon/index.tsx",
51
49
  "./icon/styled": "./src/icon/styled.tsx",
52
- "./chart": "./src/chart/index.tsx",
53
- "./chart/styled": "./src/chart/styled.tsx",
54
50
  "./table": "./src/table/index.tsx",
55
51
  "./table/styled": "./src/table/styled.tsx",
56
52
  "./scss": "./src/index.scss",
@@ -68,7 +64,10 @@
68
64
  "next": ">= 15",
69
65
  "react": ">= 19",
70
66
  "react-dom": ">= 19",
71
- "styled-components": ">= 6"
67
+ "styled-components": ">= 6",
68
+ "react-daum-postcode": ">= 3",
69
+ "@dnd-kit/core": ">= 6",
70
+ "@dnd-kit/utilities": ">= 3"
72
71
  },
73
72
  "peerDependenciesMeta": {
74
73
  "next": {
@@ -79,33 +78,33 @@
79
78
  "@dnd-kit/core": "^6.3.1",
80
79
  "@dnd-kit/sortable": "^10.0.0",
81
80
  "@dnd-kit/utilities": "^3.2.2",
82
- "@mantine/core": "^8.3.7",
83
- "@mantine/dates": "^8.3.7",
84
- "@mantine/hooks": "^8.3.7",
85
- "@mantine/tiptap": "^8.3.7",
86
- "@tanstack/react-query": "^5.90.8",
87
- "@tiptap/extension-blockquote": "^3.10.7",
88
- "@tiptap/extension-bold": "^3.10.7",
89
- "@tiptap/extension-code": "^3.10.7",
90
- "@tiptap/extension-code-block": "^3.10.7",
91
- "@tiptap/extension-document": "^3.10.7",
92
- "@tiptap/extension-hard-break": "^3.10.7",
93
- "@tiptap/extension-heading": "^3.10.7",
94
- "@tiptap/extension-horizontal-rule": "^3.10.7",
95
- "@tiptap/extension-italic": "^3.10.7",
96
- "@tiptap/extension-link": "^3.10.7",
97
- "@tiptap/extension-list": "^3.10.7",
98
- "@tiptap/extension-paragraph": "^3.10.7",
99
- "@tiptap/extension-placeholder": "^3.10.7",
100
- "@tiptap/extension-strike": "^3.10.7",
101
- "@tiptap/extension-text": "^3.10.7",
102
- "@tiptap/extension-text-align": "^3.10.7",
103
- "@tiptap/extension-underline": "^3.10.7",
104
- "@tiptap/pm": "^3.10.7",
105
- "@tiptap/react": "^3.10.7",
106
- "@tiptap/starter-kit": "^3.10.7",
81
+ "@mantine/core": "^8.3.9",
82
+ "@mantine/dates": "^8.3.9",
83
+ "@mantine/hooks": "^8.3.9",
84
+ "@mantine/tiptap": "^8.3.9",
85
+ "@tanstack/react-query": "^5.90.10",
86
+ "@tiptap/extension-blockquote": "^3.11.0",
87
+ "@tiptap/extension-bold": "^3.11.0",
88
+ "@tiptap/extension-code": "^3.11.0",
89
+ "@tiptap/extension-code-block": "^3.11.0",
90
+ "@tiptap/extension-document": "^3.11.0",
91
+ "@tiptap/extension-hard-break": "^3.11.0",
92
+ "@tiptap/extension-heading": "^3.11.0",
93
+ "@tiptap/extension-horizontal-rule": "^3.11.0",
94
+ "@tiptap/extension-italic": "^3.11.0",
95
+ "@tiptap/extension-link": "^3.11.0",
96
+ "@tiptap/extension-list": "^3.11.0",
97
+ "@tiptap/extension-paragraph": "^3.11.0",
98
+ "@tiptap/extension-placeholder": "^3.11.0",
99
+ "@tiptap/extension-strike": "^3.11.0",
100
+ "@tiptap/extension-text": "^3.11.0",
101
+ "@tiptap/extension-text-align": "^3.11.0",
102
+ "@tiptap/extension-underline": "^3.11.0",
103
+ "@tiptap/pm": "^3.11.0",
104
+ "@tiptap/react": "^3.11.0",
105
+ "@tiptap/starter-kit": "^3.11.0",
107
106
  "@types/node": "^24.10.1",
108
- "@types/react": "^19.2.4",
107
+ "@types/react": "^19.2.7",
109
108
  "@types/react-dom": "^19.2.3",
110
109
  "@types/react-flatpickr": "^3.8.11",
111
110
  "@uniai-fe/eslint-config": "workspace:*",
@@ -134,9 +133,8 @@
134
133
  "react-daum-postcode": "^3.2.0",
135
134
  "react-dom": "^19.2.0",
136
135
  "react-flatpickr": "3.10.13",
137
- "react-hook-form": "^7.66.0",
138
- "recharts": "^3.4.1",
139
- "sass": "^1.94.0",
136
+ "react-hook-form": "^7.66.1",
137
+ "sass": "^1.94.2",
140
138
  "simplebar-core": "^1.3.2",
141
139
  "simplebar-react": "3.3.2",
142
140
  "styled-components": "^6.1.19",
@@ -12,18 +12,18 @@ import ButtonMultipleContainer from "./components/multiple/Container";
12
12
  import ButtonResetSelected from "./components/base/ResetSelected";
13
13
 
14
14
  const Button = {
15
- Default: ButtonDefault,
16
- Expand: ButtonExpand,
17
- Link: ButtonLink,
18
- Text: ButtonText,
19
- Tooltip: ButtonTooltip,
20
- ArrayAdd: ButtonAddArray,
21
- ArrayRemove: ButtonRemoveArray,
22
- SelectBox: ButtonSelectBox,
23
- Refresh: ButtonRefresh,
24
- Reset: ButtonReset,
25
- ResetSelected: ButtonResetSelected,
26
- Multiple: ButtonMultipleContainer,
15
+ Default: ButtonDefault as typeof ButtonDefault,
16
+ Expand: ButtonExpand as typeof ButtonExpand,
17
+ Link: ButtonLink as typeof ButtonLink,
18
+ Text: ButtonText as typeof ButtonText,
19
+ Tooltip: ButtonTooltip as typeof ButtonTooltip,
20
+ ArrayAdd: ButtonAddArray as typeof ButtonAddArray,
21
+ ArrayRemove: ButtonRemoveArray as typeof ButtonRemoveArray,
22
+ SelectBox: ButtonSelectBox as typeof ButtonSelectBox,
23
+ Refresh: ButtonRefresh as typeof ButtonRefresh,
24
+ Reset: ButtonReset as typeof ButtonReset,
25
+ ResetSelected: ButtonResetSelected as typeof ButtonResetSelected,
26
+ Multiple: ButtonMultipleContainer as typeof ButtonMultipleContainer,
27
27
  };
28
28
 
29
29
  export default Button;
@@ -11,7 +11,7 @@ import Icon from "./icon";
11
11
  import Alternate from "./alternate";
12
12
  import Delta from "./delta";
13
13
  import Dot from "./dot";
14
- import Chart from "./chart";
14
+ // import Chart from "./chart"; // recharts 버전 충돌로 분리, 그리고 recharts는 deprecated. Apache ECharts로 대체 예정
15
15
  import Table from "./table";
16
16
  import Form from "./form";
17
17
  import Modal from "./modal";
@@ -32,7 +32,7 @@ export {
32
32
  Alternate,
33
33
  Delta,
34
34
  Dot,
35
- Chart,
35
+ // Chart,
36
36
  Table,
37
37
  Modal,
38
38
  Form,
@@ -1,5 +1,5 @@
1
1
  @use "./styles/scss/arrow.scss";
2
2
  @use "./styles/scss/input.scss";
3
3
  @use "./styles/scss/table.scss";
4
- @use "./styles/scss/chart.scss";
4
+ // @use "./styles/scss/chart.scss";
5
5
  @use "./styles/scss/page-header.scss";
@@ -1,7 +1,7 @@
1
1
  import IconArrow from "./components/arrow";
2
2
  import IconDelta from "./components/delta";
3
3
  import IconNav from "./components/nav";
4
- import IconHealthScore from "./components/health-score";
4
+ // import IconHealthScore from "./components/health-score";
5
5
  import IconCage from "./components/cage";
6
6
  import IconPageHeader from "./components/page-header";
7
7
  import IconTooltip from "./components/tooltip";
@@ -10,13 +10,13 @@ import IconButton from "./components/button";
10
10
  import IconTable from "./components/table";
11
11
  import IconInput from "./components/input";
12
12
  import IconTabMenu from "./components/tab-menu";
13
- import IconChart from "./components/chart";
13
+ // import IconChart from "./components/chart";
14
14
 
15
15
  const Icon = {
16
16
  Arrow: IconArrow,
17
17
  Delta: IconDelta,
18
18
  Nav: IconNav,
19
- HealthScore: IconHealthScore,
19
+ // HealthScore: IconHealthScore,
20
20
  Cage: IconCage,
21
21
  PageHeader: IconPageHeader,
22
22
  Tooltip: IconTooltip,
@@ -25,7 +25,7 @@ const Icon = {
25
25
  Table: IconTable,
26
26
  Input: IconInput,
27
27
  TabMenu: IconTabMenu,
28
- Chart: IconChart,
28
+ // Chart: IconChart,
29
29
  };
30
30
 
31
31
  export default Icon;
@@ -1,4 +1,4 @@
1
- import StyledIconChart from "./styles/styled/chart";
1
+ // import StyledIconChart from "./styles/styled/chart";
2
2
  import StyledIconCommon from "./styles/styled/common";
3
3
  import StyledIconDelta from "./styles/styled/delta";
4
4
  import StyledIconInput from "./styles/styled/input";
@@ -11,7 +11,7 @@ const StyledIcon = {
11
11
  pageHeader: StyledIconPageHeader,
12
12
  table: StyledIconTable,
13
13
  input: StyledIconInput,
14
- chart: StyledIconChart,
14
+ // chart: StyledIconChart,
15
15
  };
16
16
 
17
17
  export default StyledIcon;
package/src/index.scss CHANGED
@@ -11,10 +11,10 @@
11
11
  @use "./form-field/input/input.scss";
12
12
  @use "./form-field/select/select.scss";
13
13
  @use "./frame/frame.scss";
14
- @use "./chart/chart.scss";
14
+ // @use "./chart/chart.scss";
15
15
  @use "./table/table.scss";
16
16
  @use "./modal/modal.scss";
17
17
  @use "./text-editor/text-editor.scss";
18
18
 
19
19
  // templates
20
- @use "./template/compare/compare.scss";
20
+ // @use "./template/compare/compare.scss";
package/src/index.tsx CHANGED
@@ -1,9 +1,7 @@
1
1
  import "./index.scss";
2
2
 
3
3
  export * from "./components";
4
- export * from "./template";
5
4
  export * from "./styled.components";
6
- export * from "./styled.template";
7
5
 
8
6
  export * from "./modal/util";
9
7
  export * from "./table/util";
@@ -6,9 +6,9 @@ export type * from "./chip";
6
6
  export type * from "./icon";
7
7
  export type * from "./delta";
8
8
  export type * from "./modal";
9
- export type * from "./chart";
9
+ // export type * from "./chart"; // recharts 버전 충돌로 분리, 그리고 recharts는 deprecated. Apache ECharts로 대체 예정
10
10
  export type * from "./table";
11
11
  export type * from "./tab-menu";
12
- export type * from "./template";
12
+ // export type * from "./template"; // ui-legacy-template 과 관련된 타입
13
13
  export type * from "./weather";
14
14
  export type * from "./style-option";
@@ -1,11 +0,0 @@
1
- @use "./styles/scss/level.color.scss";
2
-
3
- @use "./styles/scss/tick.scss";
4
- @use "./styles/scss/graph.scss";
5
- @use "./styles/scss/legend.scss";
6
- @use "./styles/scss/tooltip.scss";
7
- @use "./styles/scss/control.scss";
8
- @use "./styles/scss/filter.scss";
9
-
10
- @use "./styles/scss/arc-gauge.scss";
11
- @use "./styles/scss/arc-meter.scss";
@@ -1,17 +0,0 @@
1
- "use client";
2
-
3
- import StyledChartCommon from "../styles/styled/common";
4
-
5
- export default function ChartContents({
6
- className,
7
- children,
8
- }: {
9
- className?: string;
10
- children: React.ReactNode;
11
- }) {
12
- return (
13
- <StyledChartCommon.container className={className}>
14
- {children}
15
- </StyledChartCommon.container>
16
- );
17
- }
@@ -1,39 +0,0 @@
1
- "use client";
2
-
3
- import { clsx } from "clsx";
4
- import StyledChartControl from "../../styles/styled/control";
5
- import Icon from "../../../icon";
6
-
7
- /**
8
- * 차트 인터렉션 컨트롤 버튼
9
- * @component
10
- * @property {"zoom-in" | "zoom-out" | "pan-left" | "pan-right"} role - 버튼 역할
11
- * @property {Function} clickEvent - 클릭 이벤트 핸들러
12
- * @property {string} [className] - 추가 클래스 이름
13
- * @property {React.ReactNode} [children] - 버튼 내부에 렌더링
14
- */
15
- export default function ChartControlButton({
16
- className,
17
- role,
18
- clickEvent,
19
- children,
20
- disabled,
21
- }: {
22
- role: "zoom-in" | "zoom-out" | "pan-left" | "pan-right";
23
- clickEvent: () => void;
24
- } & Partial<{
25
- className: string;
26
- children: React.ReactNode;
27
- disabled: boolean;
28
- }>) {
29
- return (
30
- <StyledChartControl.button
31
- type="button"
32
- className={clsx("chart-control-button", className)}
33
- disabled={disabled}
34
- onClick={!disabled ? clickEvent : undefined}
35
- >
36
- {children || <Icon.Chart.Control {...{ role, width: 20, height: 20 }} />}
37
- </StyledChartControl.button>
38
- );
39
- }
@@ -1,27 +0,0 @@
1
- "use client";
2
-
3
- import { clsx } from "clsx";
4
- import StyledChartControl from "../../styles/styled/control";
5
-
6
- /**
7
- * 차트 인터렉션 컨트롤 컨테이너
8
- * @component
9
- * @property {string} [className] - 추가 클래스 이름
10
- * @property {React.ReactNode} children - 자식 컴포넌트
11
- */
12
- export default function ChartControlContainer({
13
- className,
14
- children,
15
- }: {
16
- children: React.ReactNode;
17
- } & Partial<{
18
- className: string;
19
- }>) {
20
- return (
21
- <StyledChartControl.container
22
- className={clsx("chart-control-container", className)}
23
- >
24
- {children}
25
- </StyledChartControl.container>
26
- );
27
- }
@@ -1,117 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- createContext,
5
- useContext,
6
- useLayoutEffect,
7
- useRef,
8
- useState,
9
- } from "react";
10
- import type { ChartControlContext, ChartControlRange } from "../../../types";
11
-
12
- /**
13
- * 차트 컨트롤을 위한 데이터 컨텍스트
14
- * @context
15
- * @desc
16
- * - {object[]} originData 원본 차트 데이터
17
- * - {{ start: number; end: number; }} indexRange 현재 X축 인덱스 범위
18
- * - {function} setRange X축 범위 업데이트 함수
19
- */
20
- const ChartControlContext = createContext<ChartControlContext>({
21
- originData: [],
22
- indexRange: { start: 0, end: 0 },
23
- setIndexRange: () => {},
24
- });
25
-
26
- /**
27
- * 차트 컨트롤을 위한 데이터 컨텍스트 공급자
28
- * @component
29
- * @param {object} props
30
- * @param {object[]} props.originData 원본 차트 데이터
31
- * @param {React.ReactNode} props.children
32
- */
33
- export default function ChartControlProvider<
34
- ChartData extends object = object,
35
- >({
36
- originData,
37
- children,
38
- }: {
39
- /**
40
- * 원본 차트 데이터
41
- * @type {object[]}
42
- */
43
- originData: ChartData[];
44
- children: React.ReactNode;
45
- }) {
46
- const [indexRange, setIndexRange] = useState<ChartControlRange>({
47
- start: 0,
48
- end: originData.length > 1 ? originData.length - 1 : 0,
49
- });
50
-
51
- // 초기 데이터 로딩 시(0 -> N) 전체 범위로 동기 업데이트하여 깜빡임 방지
52
- const prevLenRef = useRef<number>(originData.length);
53
- useLayoutEffect(() => {
54
- const prev = prevLenRef.current;
55
- const next = originData.length;
56
- if (prev === 0 && next > 0) {
57
- setIndexRange({ start: 0, end: Math.max(0, next - 1) });
58
- }
59
- prevLenRef.current = next;
60
- }, [originData.length]);
61
-
62
- // 데이터 길이가 변할 때 현재 indexRange를 데이터 범위에 맞춰 정돈
63
- useLayoutEffect(() => {
64
- const total = originData.length;
65
- if (total < 0) return;
66
- const maxEnd = Math.max(0, total - 1);
67
-
68
- // 비어있는 경우 0,0 고정
69
- if (total === 0) {
70
- if (indexRange.start !== 0 || indexRange.end !== 0)
71
- setIndexRange({ start: 0, end: 0 });
72
- return;
73
- }
74
-
75
- // 현재 윈도우 길이 보존 시도
76
- const length = Math.max(1, indexRange.end - indexRange.start + 1);
77
-
78
- // 범위를 넘어가면 오른쪽 끝에 맞춰 재정렬
79
- if (indexRange.end > maxEnd || indexRange.start > maxEnd) {
80
- const newEnd = maxEnd;
81
- const newStart = Math.max(0, newEnd - Math.min(length, total) + 1);
82
- if (newStart !== indexRange.start || newEnd !== indexRange.end)
83
- setIndexRange({ start: newStart, end: newEnd });
84
- }
85
- }, [originData.length, indexRange.start, indexRange.end]);
86
-
87
- return (
88
- <ChartControlContext.Provider
89
- value={{
90
- originData,
91
- indexRange,
92
- setIndexRange,
93
- }}
94
- >
95
- {children}
96
- </ChartControlContext.Provider>
97
- );
98
- }
99
-
100
- /**
101
- * 차트 컨트롤 데이터 컨텍스트를 사용하기 위한 커스텀 훅
102
- * @hook
103
- * @desc
104
- * - {object[]} originData 원본 차트 데이터
105
- * - {{ start: number; end: number; }} indexRange 현재 X축 인덱스 범위
106
- * - {function} setIndexRange X축 범위 업데이트 함수
107
- * @return {ChartControlContext} { originData, indexRange, setIndexRange }
108
- */
109
- export function useChartContext<
110
- ChartData extends object,
111
- >(): ChartControlContext<ChartData> {
112
- const context = useContext(ChartControlContext);
113
- if (!context) {
114
- throw new Error("차트 데이터에 대한 컨텍스트를 찾을 수 없습니다.");
115
- }
116
- return context as ChartControlContext<ChartData>;
117
- }
@@ -1,12 +0,0 @@
1
- import ChartControlButton from "./Button";
2
- import ChartControlContainer from "./Container";
3
- import ChartControlProvider, { useChartContext } from "./Provider";
4
-
5
- const ChartControl = {
6
- Provider: ChartControlProvider,
7
- useContext: useChartContext,
8
- Container: ChartControlContainer,
9
- Button: ChartControlButton,
10
- };
11
-
12
- export default ChartControl;
@@ -1,29 +0,0 @@
1
- "use client";
2
-
3
- import { Sector } from "recharts";
4
- import type { Props } from "recharts/types/shape/Sector";
5
-
6
- export default function ChartActivePieSector({
7
- cx,
8
- cy,
9
- innerRadius,
10
- outerRadius,
11
- startAngle,
12
- endAngle,
13
- fill,
14
- }: Props) {
15
- return (
16
- <Sector
17
- cx={cx}
18
- cy={cy}
19
- innerRadius={innerRadius}
20
- outerRadius={
21
- typeof outerRadius === "number" ? outerRadius + 2 : outerRadius
22
- }
23
- startAngle={startAngle}
24
- endAngle={endAngle}
25
- fill={fill}
26
- cornerRadius={0}
27
- />
28
- );
29
- }
@@ -1,58 +0,0 @@
1
- "use client";
2
-
3
- import { useMemo } from "react";
4
- import { lengthFormat } from "@uniai-fe/util-functions";
5
- import StyledArcGauge from "../../styles/styled/arc-gauge";
6
- import ArcGaugeTrack from "../../svg/gauge-track.min.svg";
7
-
8
- /**
9
- * 차트 템플릿; 반원 게이지
10
- * - 체중균일도 차트 등에 사용
11
- */
12
- export default function ChartArcGauge({
13
- className,
14
- value,
15
- unit,
16
- }: {
17
- className?: string;
18
- value: number | "";
19
- unit: string;
20
- }) {
21
- const v = useMemo((): string => {
22
- if (typeof value !== "number") return "-";
23
- return lengthFormat(value, 0);
24
- }, [value]);
25
-
26
- const level = useMemo((): number => {
27
- if (typeof value !== "number") return 0;
28
-
29
- if (value <= 25) return 1;
30
- else if (25 < value && value <= 50) return 2;
31
- else if (50 < value && value <= 75) return 3;
32
- else if (75 < value) return 4;
33
- return 0;
34
- }, [value]);
35
-
36
- const degree = useMemo((): number => {
37
- if (typeof value !== "number") return 0;
38
-
39
- if (value <= 0) return 0;
40
- else if (value > 100) return 180;
41
- return ((value * Math.PI) / 180) * 100;
42
- }, [value]);
43
-
44
- return (
45
- <StyledArcGauge.container className={className}>
46
- <StyledArcGauge.track>
47
- <ArcGaugeTrack />
48
- {value !== "" && (
49
- <StyledArcGauge.point $level={level} $degree={degree} />
50
- )}
51
- </StyledArcGauge.track>
52
- <StyledArcGauge.value>
53
- <strong>{v}</strong>
54
- <span>{unit}</span>
55
- </StyledArcGauge.value>
56
- </StyledArcGauge.container>
57
- );
58
- }