@moda-chart/react 0.1.2
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.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/ChartView.d.ts +11 -0
- package/dist/ChartView.d.ts.map +1 -0
- package/dist/ChartView.js +13 -0
- package/dist/ChartView.js.map +1 -0
- package/dist/conformance.test.d.ts +2 -0
- package/dist/conformance.test.d.ts.map +1 -0
- package/dist/conformance.test.js +25 -0
- package/dist/conformance.test.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +1 -0
- package/dist/useChartCore.d.ts +18 -0
- package/dist/useChartCore.d.ts.map +1 -0
- package/dist/useChartCore.js +16 -0
- package/dist/useChartCore.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 park-taejoon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @moda-chart/react
|
|
2
|
+
|
|
3
|
+
`@moda-chart/core`의 React 어댑터 — 훅 + 컴포넌트.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { ChartView, useChartCore } from "@moda-chart/react";
|
|
7
|
+
import "@moda-chart/react/styles.css";
|
|
8
|
+
|
|
9
|
+
const { chart } = useChartCore({
|
|
10
|
+
type: "line",
|
|
11
|
+
series: [{ name: "매출", values: [12, 24, 16] }],
|
|
12
|
+
categories: ["1월", "2월", "3월"],
|
|
13
|
+
});
|
|
14
|
+
<ChartView chart={chart} />;
|
|
15
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChartCore } from "@moda-chart/core";
|
|
2
|
+
export interface ChartViewProps {
|
|
3
|
+
chart: ChartCore;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* React 렌더러 — 코어의 공용 DOM 렌더러(attachChartView)를 호스트 div에
|
|
8
|
+
* 연결한다. 스냅샷 → DOM 계약(mc-*) 변환과 이벤트 배선은 전부 코어가 한다.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ChartView({ chart, className }: ChartViewProps): import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=ChartView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartView.d.ts","sourceRoot":"","sources":["../src/ChartView.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,cAAc,+BAI7D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { attachChartView } from "@moda-chart/core";
|
|
4
|
+
/**
|
|
5
|
+
* React 렌더러 — 코어의 공용 DOM 렌더러(attachChartView)를 호스트 div에
|
|
6
|
+
* 연결한다. 스냅샷 → DOM 계약(mc-*) 변환과 이벤트 배선은 전부 코어가 한다.
|
|
7
|
+
*/
|
|
8
|
+
export function ChartView({ chart, className }) {
|
|
9
|
+
const ref = useRef(null);
|
|
10
|
+
useEffect(() => attachChartView(ref.current, chart), [chart]);
|
|
11
|
+
return _jsx("div", { ref: ref, className: className });
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ChartView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartView.js","sourceRoot":"","sources":["../src/ChartView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQnD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAkB;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IACzC,SAAS,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,OAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/D,OAAO,cAAK,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,GAAI,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.test.d.ts","sourceRoot":"","sources":["../src/conformance.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { act, createElement } from "react";
|
|
3
|
+
import { createRoot } from "react-dom/client";
|
|
4
|
+
import { runChartConformance } from "@moda-chart/core/conformance";
|
|
5
|
+
import { ChartCore } from "@moda-chart/core";
|
|
6
|
+
import { ChartView } from "./ChartView.js";
|
|
7
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
8
|
+
// React 렌더러 — createRoot + act로 마운트하고, DOM 반영은 act로 flush한다.
|
|
9
|
+
runChartConformance("react", async (opts) => {
|
|
10
|
+
const el = document.createElement("div");
|
|
11
|
+
document.body.appendChild(el);
|
|
12
|
+
const chart = new ChartCore(opts);
|
|
13
|
+
const root = createRoot(el);
|
|
14
|
+
await act(() => root.render(createElement(ChartView, { chart })));
|
|
15
|
+
return {
|
|
16
|
+
el,
|
|
17
|
+
chart,
|
|
18
|
+
flush: () => act(async () => { }),
|
|
19
|
+
destroy: () => {
|
|
20
|
+
act(() => root.unmount());
|
|
21
|
+
el.remove();
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=conformance.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.test.js","sourceRoot":"","sources":["../src/conformance.test.tsx"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE1C,UAAsC,CAAC,wBAAwB,GAAG,IAAI,CAAC;AAExE,6DAA6D;AAC7D,mBAAmB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;IAC1C,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACzC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;IAC5B,MAAM,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,OAAO;QACL,EAAE;QACF,KAAK;QACL,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC;QAChC,OAAO,EAAE,GAAG,EAAE;YACZ,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1B,EAAE,CAAC,MAAM,EAAE,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { useChartCore } from "./useChartCore.js";
|
|
2
|
+
export type { UseChartCoreResult } from "./useChartCore.js";
|
|
3
|
+
export { ChartView } from "./ChartView.js";
|
|
4
|
+
export type { ChartViewProps } from "./ChartView.js";
|
|
5
|
+
export type { AnnotationInput, CategoryValue, Chart, ChartCoreOptions, ChartEventHandlers, ChartEventMap, ChartEventType, ChartChordOptions, ChartFlowLink, ChartGaugeOptions, ChartHeatmapOptions, ChartLocale, ChartMapDatum, ChartMapLine, ChartMapOptions, ChartMapPoint, ChartBoxInput, ChartMenuItem, ChartContextMenuOptions, ItemStyle, ItemStyleContext, TooltipRenderContext, ChartDrawingOptions, ChartSearchOptions, ChartPictogramOptions, ChartPyramidPopOptions, ChartState, DrawingInput, DrawingView, DrawTool, SearchLoadArgs, PictoIconView, PictoRowView, SparklineOptions, ChartPointInput, ChartSankeyOptions, ChartSeriesInput, ChartSnapshot, ChartTheme, ChartTreeNode, ChartType, DrilldownLevel, MapProjection, MarkBandInput, MarkLineInput, } from "@moda-chart/core";
|
|
6
|
+
export { ChartCore, mountSparkline, parseDataXml, parseText, sparklineMarkup, WORLD_TOPOLOGY, } from "@moda-chart/core";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EACV,eAAe,EACf,aAAa,EACb,KAAK,EACL,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,cAAc,EACd,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,aAAa,EACb,SAAS,EACT,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,SAAS,EACT,cAAc,EACd,YAAY,EACZ,SAAS,EACT,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAiD3C,OAAO,EACL,SAAS,EACT,cAAc,EACd,YAAY,EACZ,SAAS,EACT,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC"}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "@moda-chart/core/styles.css";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChartCore } from "@moda-chart/core";
|
|
2
|
+
import type { ChartCoreOptions, ChartSnapshot } from "@moda-chart/core";
|
|
3
|
+
export interface UseChartCoreResult {
|
|
4
|
+
/** 헤드리스 코어 — 액션 호출용 */
|
|
5
|
+
chart: ChartCore;
|
|
6
|
+
/** 렌더용 스냅샷 — 변경 시 자동 재렌더 */
|
|
7
|
+
snapshot: ChartSnapshot;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* React 어댑터 훅 — 코어의 subscribe/getSnapshot을 useSyncExternalStore에
|
|
11
|
+
* 연결한다. getSnapshot이 같은 참조를 반환하는 코어 규약 덕분에 무한
|
|
12
|
+
* 리렌더 없이 동작한다.
|
|
13
|
+
*
|
|
14
|
+
* options는 최초 1회만 적용된다 — 이후 변경은 chart.setData 같은
|
|
15
|
+
* 코어 setter로 한다.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useChartCore(options: ChartCoreOptions): UseChartCoreResult;
|
|
18
|
+
//# sourceMappingURL=useChartCore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChartCore.d.ts","sourceRoot":"","sources":["../src/useChartCore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAExE,MAAM,WAAW,kBAAkB;IACjC,uBAAuB;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,4BAA4B;IAC5B,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,kBAAkB,CAQ1E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useMemo, useSyncExternalStore } from "react";
|
|
2
|
+
import { ChartCore } from "@moda-chart/core";
|
|
3
|
+
/**
|
|
4
|
+
* React 어댑터 훅 — 코어의 subscribe/getSnapshot을 useSyncExternalStore에
|
|
5
|
+
* 연결한다. getSnapshot이 같은 참조를 반환하는 코어 규약 덕분에 무한
|
|
6
|
+
* 리렌더 없이 동작한다.
|
|
7
|
+
*
|
|
8
|
+
* options는 최초 1회만 적용된다 — 이후 변경은 chart.setData 같은
|
|
9
|
+
* 코어 setter로 한다.
|
|
10
|
+
*/
|
|
11
|
+
export function useChartCore(options) {
|
|
12
|
+
const chart = useMemo(() => new ChartCore(options), []);
|
|
13
|
+
const snapshot = useSyncExternalStore((cb) => chart.subscribe(cb), () => chart.getSnapshot(), () => chart.getSnapshot());
|
|
14
|
+
return { chart, snapshot };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=useChartCore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChartCore.js","sourceRoot":"","sources":["../src/useChartCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAU7C;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,OAAyB;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,oBAAoB,CACnC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,EAC3B,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,EACzB,GAAG,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAC1B,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC7B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@moda-chart/react",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "React adapter for @moda-chart — useChartCore + ChartView",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./styles.css": "./dist/styles.css"
|
|
13
|
+
},
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"**/*.css"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"react",
|
|
26
|
+
"adapter",
|
|
27
|
+
"headless",
|
|
28
|
+
"library"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@moda-chart/core": "0.1.2"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": ">=18.0.0",
|
|
35
|
+
"react-dom": ">=18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/react": "^19.1.0",
|
|
39
|
+
"@types/react-dom": "^19.1.0",
|
|
40
|
+
"happy-dom": "^20.14.5",
|
|
41
|
+
"react": "^19.1.0",
|
|
42
|
+
"react-dom": "^19.1.0",
|
|
43
|
+
"typescript": "~5.9.2",
|
|
44
|
+
"vitest": "^3.2.7"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc -p tsconfig.json && cp src/styles.css dist/styles.css",
|
|
48
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
49
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
50
|
+
"test": "vitest run"
|
|
51
|
+
},
|
|
52
|
+
"main": "./dist/index.js"
|
|
53
|
+
}
|