open-grid 1.3.1 → 1.4.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.
@@ -1,57 +1,203 @@
1
1
  /**
2
- * 조직도 노드 카드의 컬럼(필드) 정의. / Column (field) definition for an org-chart node card.
2
+ * 조직도 노드 카드의 컬럼(필드) 정의.
3
+ *
4
+ * Column (field) definition for an org-chart node card.
5
+ *
6
+ * 組織図のノードカードの列(フィールド)定義。
7
+ *
8
+ * 组织架构图节点卡片的列(字段)定义。
3
9
  */
4
10
  export interface OrgChartColumnDef {
5
- /** 표시할 데이터 필드명. / Data field name to display. */
11
+ /**
12
+ * 표시할 데이터 필드명.
13
+ *
14
+ * Data field name to display.
15
+ *
16
+ * 表示するデータのフィールド名。
17
+ *
18
+ * 要显示的数据字段名。
19
+ */
6
20
  field: string;
7
- /** 셀 래퍼에 추가할 CSS 클래스명. / Extra CSS class name for the cell wrapper. */
21
+ /**
22
+ * 셀 래퍼에 추가할 CSS 클래스명.
23
+ *
24
+ * Extra CSS class name for the cell wrapper.
25
+ *
26
+ * セルラッパーに追加する CSS クラス名。
27
+ *
28
+ * 为单元格包装元素追加的 CSS 类名。
29
+ */
8
30
  className?: string;
9
- /** 인라인 스타일 문자열 또는 (값, 행)→스타일 함수. / Inline style string or (value, row)→style function. */
31
+ /**
32
+ * 인라인 스타일 문자열 또는 (값, 행)→스타일 함수.
33
+ *
34
+ * Inline style string or (value, row)→style function.
35
+ *
36
+ * インラインスタイル文字列、または (値, 行)→スタイル の関数。
37
+ *
38
+ * 内联样式字符串,或 (值, 行)→样式 的函数。
39
+ */
10
40
  style?: string | ((value: any, row: Record<string, any>) => string);
11
- /** 커스텀 렌더러. 값을 텍스트 그대로 보여주는 대신 아바타·배지·아이콘 같은 커스텀 마크업을
41
+ /**
42
+ * 커스텀 렌더러. 값을 텍스트 그대로 보여주는 대신 아바타·배지·아이콘 같은 커스텀 마크업을
12
43
  * 넣고 싶을 때 지정한다. 문자열 반환 시 innerHTML, 엘리먼트 반환 시 append.
13
- * / Custom renderer. Set this when you need avatars, badges, or icons instead of plain text.
14
- * A string return is set as innerHTML; an element return is appended. */
44
+ *
45
+ * Custom renderer. Set this when you need avatars, badges, or icons instead of plain text.
46
+ * A string return is set as innerHTML; an element return is appended.
47
+ *
48
+ * カスタムレンダラー。値をテキストのまま見せる代わりに、アバター・バッジ・アイコンのような
49
+ * カスタムマークアップを入れたいときに指定します。文字列を返すと innerHTML、
50
+ * 要素を返すと append されます。
51
+ *
52
+ * 自定义渲染器。当你不想把值原样显示为文本,而要放入头像、徽标、图标这类自定义标记时指定它。
53
+ * 返回字符串则作为 innerHTML 写入,返回元素则以 append 方式插入。
54
+ */
15
55
  renderer?: (value: any, row: Record<string, any>) => HTMLElement | string;
16
56
  }
17
57
  /**
18
- * 조직도 생성 옵션. / Org-chart construction options.
58
+ * 조직도 생성 옵션.
59
+ *
60
+ * Org-chart construction options.
61
+ *
62
+ * 組織図の生成オプション。
63
+ *
64
+ * 组织架构图的生成选项。
19
65
  */
20
66
  export interface OrgChartOptions {
21
- /** 각 행의 고유 id 필드명. / Field name holding each row's unique id. */
67
+ /**
68
+ * 각 행의 고유 id 필드명.
69
+ *
70
+ * Field name holding each row's unique id.
71
+ *
72
+ * 各行の一意な id を持つフィールド名。
73
+ *
74
+ * 存放每行唯一 id 的字段名。
75
+ */
22
76
  idField: string;
23
- /** 부모 id 를 담은 필드명(트리 구성 기준). / Field name holding the parent id (tree structure key). */
77
+ /**
78
+ * 부모 id 를 담은 필드명(트리 구성 기준).
79
+ *
80
+ * Field name holding the parent id (tree structure key).
81
+ *
82
+ * 親の id を持つフィールド名(ツリー構成の基準)。
83
+ *
84
+ * 存放父级 id 的字段名(构建树的依据)。
85
+ */
24
86
  parentIdField: string;
25
- /** 노드 카드에 렌더할 컬럼 정의 배열. / Column definitions rendered inside each node card. */
87
+ /**
88
+ * 노드 카드에 렌더할 컬럼 정의 배열.
89
+ *
90
+ * Column definitions rendered inside each node card.
91
+ *
92
+ * ノードカードにレンダリングする列定義の配列。
93
+ *
94
+ * 在节点卡片中渲染的列定义数组。
95
+ */
26
96
  columns: OrgChartColumnDef[];
27
- /** 노드 카드 너비(px). 기본 160. / Node card width in px. Default 160. @defaultValue 160 */
97
+ /**
98
+ * 노드 카드 너비(px). 기본 160.
99
+ *
100
+ * Node card width in px. Default 160.
101
+ *
102
+ * ノードカードの幅(px)。既定は 160。
103
+ *
104
+ * 节点卡片宽度(px)。默认 160。
105
+ *
106
+ * @defaultValue 160
107
+ */
28
108
  nodeWidth?: number;
29
- /** 노드 카드 높이(px). 기본 72. / Node card height in px. Default 72. @defaultValue 72 */
109
+ /**
110
+ * 노드 카드 높이(px). 기본 72.
111
+ *
112
+ * Node card height in px. Default 72.
113
+ *
114
+ * ノードカードの高さ(px)。既定は 72。
115
+ *
116
+ * 节点卡片高度(px)。默认 72。
117
+ *
118
+ * @defaultValue 72
119
+ */
30
120
  nodeHeight?: number;
31
- /** 레벨(세대) 간 세로 간격(px). 기본 52. / Vertical gap between levels in px. Default 52. @defaultValue 52 */
121
+ /**
122
+ * 레벨(세대) 간 세로 간격(px). 기본 52.
123
+ *
124
+ * Vertical gap between levels in px. Default 52.
125
+ *
126
+ * レベル(世代)間の縦の間隔(px)。既定は 52。
127
+ *
128
+ * 层级(代)之间的纵向间距(px)。默认 52。
129
+ *
130
+ * @defaultValue 52
131
+ */
32
132
  levelGap?: number;
33
- /** 형제 노드 간 가로 간격(px). 기본 20. / Horizontal gap between siblings in px. Default 20. @defaultValue 20 */
133
+ /**
134
+ * 형제 노드 간 가로 간격(px). 기본 20.
135
+ *
136
+ * Horizontal gap between siblings in px. Default 20.
137
+ *
138
+ * 兄弟ノード間の横の間隔(px)。既定は 20。
139
+ *
140
+ * 同级节点之间的横向间距(px)。默认 20。
141
+ *
142
+ * @defaultValue 20
143
+ */
34
144
  siblingGap?: number;
35
- /** 최초 로드 시 전체 펼침 여부. 기본 true. / Whether to expand all on first load. Default true. @defaultValue true */
145
+ /**
146
+ * 최초 로드 시 전체 펼침 여부. 기본 true.
147
+ *
148
+ * Whether to expand all on first load. Default true.
149
+ *
150
+ * 初回ロード時に全体を展開するかどうか。既定は true。
151
+ *
152
+ * 首次加载时是否展开全部。默认 true。
153
+ *
154
+ * @defaultValue true
155
+ */
36
156
  expandOnLoad?: boolean;
37
- /** 노드 클릭 콜백 (id, 행데이터). / Node click callback (id, row data). */
157
+ /**
158
+ * 노드 클릭 콜백 (id, 행데이터).
159
+ *
160
+ * Node click callback (id, row data).
161
+ *
162
+ * ノードクリックのコールバック (id, 行データ)。
163
+ *
164
+ * 节点点击回调 (id, 行数据)。
165
+ */
38
166
  onNodeClick?: (id: any, data: Record<string, any>) => void;
39
167
  }
40
168
  /**
41
- * 조직도 컴포넌트. / Org-chart component.
169
+ * 조직도 컴포넌트.
170
+ *
171
+ * Org-chart component.
172
+ *
173
+ * 組織図コンポーネント。
174
+ *
175
+ * 组织架构图组件。
42
176
  *
43
177
  * 보고 라인·조직 구조·계층형 카테고리처럼 "누가 누구 밑에 있는가"를 시각적으로 보여주고 싶을 때
44
178
  * 쓴다. 그리드와 별개의 독립 컴포넌트라서, 그리드 없이 조직도 하나만 페이지에 넣어도 동작한다.
45
179
  * 동작 순서: `setData()`로 평면 행 배열(각 행에 id/parentId만 있으면 됨)을 넘기면 → 내부에서
46
180
  * 부모/자식 관계(idField/parentIdField)를 따라 트리로 구성하고 → 그 결과를 SVG 연결선 + 노드
47
181
  * 카드로 화면에 그린다.
48
- * / Use this when you need to show "who reports to whom" — org structure, reporting lines, or
182
+ *
183
+ * Use this when you need to show "who reports to whom" — org structure, reporting lines, or
49
184
  * hierarchical categories. It's a standalone component independent of the grid, so it works on
50
185
  * its own with no grid on the page. Operation order: pass a flat row array to `setData()` (each
51
186
  * row just needs an id/parentId) → internally it's built into a tree following the parent/child
52
187
  * relation (idField/parentIdField) → the result is drawn on screen as SVG connectors plus node
53
188
  * cards.
54
189
  *
190
+ * レポートライン・組織構造・階層型カテゴリのように「誰が誰の下にいるか」を視覚的に見せたいときに
191
+ * 使います。グリッドとは別の独立したコンポーネントなので、グリッドなしで組織図だけをページに
192
+ * 置いても動作します。動作の順序: `setData()` にフラットな行の配列(各行に id/parentId さえあれば
193
+ * 十分)を渡すと → 内部で親子関係(idField/parentIdField)をたどってツリーを構成し → その結果を
194
+ * SVG の連結線 + ノードカードとして画面に描画します。
195
+ *
196
+ * 当你需要直观展示「谁在谁的下面」时使用它 —— 汇报关系、组织结构或层级分类。它是独立于表格的
197
+ * 组件,页面上没有表格也能单独工作。执行顺序: 向 `setData()` 传入扁平的行数组(每行只需带有
198
+ * id/parentId) → 内部按父子关系(idField/parentIdField)构建成树 → 再把结果绘制为 SVG 连接线和
199
+ * 节点卡片。
200
+ *
55
201
  * @example
56
202
  * const chart = new OrgChart('#org', {
57
203
  * idField: 'id', parentIdField: 'managerId',
@@ -67,43 +213,114 @@ export declare class OrgChart {
67
213
  private _expandedKeys;
68
214
  private _selectedId;
69
215
  /**
70
- * @param selector - 마운트할 컨테이너 셀렉터 문자열 또는 엘리먼트 / Container selector string or element to mount into
71
- * @param opts - 조직도 옵션 / Org-chart options
216
+ * @param selector - 마운트할 컨테이너 셀렉터 문자열 또는 엘리먼트
217
+ *
218
+ * Container selector string or element to mount into
219
+ *
220
+ * マウントするコンテナのセレクタ文字列、または要素
221
+ *
222
+ * 挂载目标容器的选择器字符串或元素
223
+ *
224
+ * @param opts - 조직도 옵션
225
+ *
226
+ * Org-chart options
227
+ *
228
+ * 組織図のオプション
229
+ *
230
+ * 组织架构图选项
72
231
  */
73
232
  constructor(selector: string | HTMLElement, opts: OrgChartOptions);
74
233
  /**
75
234
  * 조직도 데이터를 설정하고 렌더한다. 최초 로드는 물론, 데이터를 새로 받아올 때마다
76
- * 다시 호출하면 트리를 재구성해 다시 그린다. / Set org-chart data and render. Call this on
235
+ * 다시 호출하면 트리를 재구성해 다시 그린다.
236
+ *
237
+ * Set org-chart data and render. Call this on
77
238
  * initial load and again whenever fresh data arrives — it rebuilds the tree and redraws.
78
239
  *
79
- * @param data - 부모/자식 관계를 가진 평면 행 배열 / Flat array of rows with parent/child relations
240
+ * 組織図のデータを設定してレンダリングします。初回ロードはもちろん、データを新しく受け取るたびに
241
+ * 再び呼び出せば、ツリーを再構成して描き直します。
242
+ *
243
+ * 设置组织架构图数据并渲染。首次加载时调用它,之后每次拿到新数据也再调用一次 —— 它会重建树并
244
+ * 重新绘制。
245
+ *
246
+ * @param data - 부모/자식 관계를 가진 평면 행 배열
247
+ *
248
+ * Flat array of rows with parent/child relations
249
+ *
250
+ * 親子関係を持つフラットな行の配列
251
+ *
252
+ * 带有父子关系的扁平行数组
80
253
  */
81
254
  setData(data: Record<string, any>[]): void;
82
255
  /**
83
256
  * 색 테마(라이트/다크 등)를 컨테이너에 설정한다. 호스트 페이지의 다크모드 토글에 맞춰 전환할
84
- * 때 호출한다. / Set the color theme (light/dark, etc.) on the container. Call this when
257
+ * 때 호출한다.
258
+ *
259
+ * Set the color theme (light/dark, etc.) on the container. Call this when
85
260
  * switching to match the host page's dark-mode toggle.
86
261
  *
87
- * @param theme - data-og-theme 값 / data-og-theme value
262
+ * 色テーマ(ライト/ダークなど)をコンテナに設定します。ホストページのダークモードトグルに
263
+ * 合わせて切り替えるときに呼び出します。
264
+ *
265
+ * 在容器上设置颜色主题(浅色/深色等)。需要跟随宿主页面的深色模式开关切换时调用它。
266
+ *
267
+ * @param theme - data-og-theme 값
268
+ *
269
+ * data-og-theme value
270
+ *
271
+ * data-og-theme の値
272
+ *
273
+ * data-og-theme 的值
88
274
  */
89
275
  setTheme(theme: string): void;
90
276
  /**
91
277
  * 형태(스킨) 테마를 컨테이너에 설정한다. 색은 그대로 두고 모서리·밀도 같은 겉모양만 바꾸고
92
278
  * 싶을 때 쓴다. `setTheme`(색)과 서로 독립된 축이라, 색 테마는 그대로 두고 스킨만 바꾸거나
93
279
  * 그 반대로 자유롭게 조합할 수 있다.
94
- * / Set the form (skin) theme on the container. Use this to change the look (corner radius,
280
+ *
281
+ * Set the form (skin) theme on the container. Use this to change the look (corner radius,
95
282
  * density, etc.) while leaving color untouched. This is an axis independent from `setTheme`
96
283
  * (color), so you can swap the skin alone, the color theme alone, or both freely.
97
284
  *
98
- * @param skin - data-og-skin 값 / data-og-skin value
285
+ * 形(スキン)テーマをコンテナに設定します。色はそのままにして、角丸・密度のような見た目だけを
286
+ * 変えたいときに使います。`setTheme`(色)とは互いに独立した軸なので、色テーマはそのままで
287
+ * スキンだけを変えたり、その逆も自由に組み合わせできます。
288
+ *
289
+ * 在容器上设置形态(皮肤)主题。想保持颜色不变,只改圆角、密度这类外观时使用它。它与
290
+ * `setTheme`(颜色)是彼此独立的两个维度,因此可以只换皮肤、只换颜色主题,也可以两者自由组合。
291
+ *
292
+ * @param skin - data-og-skin 값
293
+ *
294
+ * data-og-skin value
295
+ *
296
+ * data-og-skin の値
297
+ *
298
+ * data-og-skin 的值
99
299
  */
100
300
  setSkin(skin: string): void;
101
- /** 모든 노드를 펼친다. 조직 전체를 한눈에 훑어보고 싶을 때 호출. / Expand all nodes. Call when
102
- * the viewer wants to see the whole organization at a glance. */
301
+ /**
302
+ * 모든 노드를 펼친다. 조직 전체를 한눈에 훑어보고 싶을 때 호출.
303
+ *
304
+ * Expand all nodes. Call when
305
+ * the viewer wants to see the whole organization at a glance.
306
+ *
307
+ * すべてのノードを展開します。組織全体をひと目で見渡したいときに呼び出します。
308
+ *
309
+ * 展开所有节点。想一眼纵览整个组织时调用。
310
+ */
103
311
  expandAll(): void;
104
- /** 모든 노드를 접는다(루트만 표시). 큰 조직도를 처음 접했을 때 최상위 구조부터 보여주고 싶을
105
- * 때 호출. / Collapse all nodes (roots only). Call to show top-level structure first when a
106
- * large org chart is first opened. */
312
+ /**
313
+ * 모든 노드를 접는다(루트만 표시). 큰 조직도를 처음 접했을 때 최상위 구조부터 보여주고 싶을
314
+ * 때 호출.
315
+ *
316
+ * Collapse all nodes (roots only). Call to show top-level structure first when a
317
+ * large org chart is first opened.
318
+ *
319
+ * すべてのノードを折りたたみます(ルートのみ表示)。大きな組織図を初めて開いたときに、
320
+ * 最上位の構造から見せたい場合に呼び出します。
321
+ *
322
+ * 折叠所有节点(仅显示根节点)。初次打开较大的组织架构图,想先展示最上层结构时调用。
323
+ */
107
324
  collapseAll(): void;
108
325
  private _toggle;
109
326
  private _rebuild;