@canvas-components/react-gantt-table 0.1.1 → 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/dist/index.cjs CHANGED
@@ -34,7 +34,11 @@ var ReactGanttTable = react.forwardRef(function ReactGanttTable2(props, ref) {
34
34
  const ganttRef = react.useRef(null);
35
35
  react.useEffect(() => {
36
36
  if (!containerRef.current) return;
37
- const gantt = new ganttTable.Gantt(containerRef.current, { ...options, onTaskClick, onTaskChange });
37
+ const gantt = new ganttTable.Gantt(containerRef.current, {
38
+ ...options,
39
+ onTaskClick,
40
+ onTaskChange
41
+ });
38
42
  gantt.mount();
39
43
  ganttRef.current = gantt;
40
44
  return () => {
@@ -45,8 +49,23 @@ var ReactGanttTable = react.forwardRef(function ReactGanttTable2(props, ref) {
45
49
  react.useEffect(() => {
46
50
  ganttRef.current?.updateOptions({ ...options, onTaskClick, onTaskChange });
47
51
  }, [options, onTaskClick, onTaskChange]);
48
- react.useImperativeHandle(ref, () => ({ getSelectedTask: () => ganttRef.current?.getSelectedTask() ?? null, scrollTo: () => void 0 }), []);
49
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className, style: { position: "relative", width: "100%", height: "100%", ...style } });
52
+ react.useImperativeHandle(
53
+ ref,
54
+ () => ({
55
+ getSelectedTask: () => ganttRef.current?.getSelectedTask() ?? null,
56
+ getSelectedDependency: () => ganttRef.current?.getSelectedDependency() ?? null,
57
+ scrollTo: (left, top) => ganttRef.current?.scrollTo(left, top)
58
+ }),
59
+ []
60
+ );
61
+ return /* @__PURE__ */ jsxRuntime.jsx(
62
+ "div",
63
+ {
64
+ ref: containerRef,
65
+ className,
66
+ style: { position: "relative", width: "100%", height: "100%", ...style }
67
+ }
68
+ );
50
69
  });
51
70
 
52
71
  exports.ReactGanttTable = ReactGanttTable;
@@ -1 +1 @@
1
- {"version":3,"sources":["#style-inject:#style-inject","../src/styles/gantt-table.css","../src/components/react-gantt-table.t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CAAU,MAAM;AAAE,IAAA,IAAI,CAAC,aAAa,OAAA,EAAS;AAAQ,IAAA,MAAM,KAAA,GAAQ,IAAIC,gBAAA,CAAM,YAAA,CAAa,OAAA,EAAS,EAAE,GAAG,OAAA,EAAS,WAAA,EAAa,YAAA,EAAc,CAAA;AAAG,IAAA,KAAA,CAAM,KAAA,EAAM;AAAG,IAAA,QAAA,CAAS,OAAA,GAAU,KAAA;AAAO,IAAA,OAAO,MAAM;AAAE,MAAA,KAAA,CAAM,OAAA,EAAQ;AAAG,MAAA,QAAA,CAAS,OAAA,GAAU,IAAA;AAAA,IAAM,CAAA;AAAA,EAAG,CAAA,EAAG,EAAE,CAAA;AACzP,EAAAD,eAAA,CAAU,MAAM;AAAE,IAAA,QAAA,CAAS,SAAS,aAAA,CAAc,EAAE,GAAG,OAAA,EAAS,WAAA,EAAa,cAAc,CAAA;AAAA,EAAG,CAAA,EAAG,CAAC,OAAA,EAAS,WAAA,EAAa,YAAY,CAAC,CAAA;AACrI,EAAAE,yBAAA,CAAoB,GAAA,EAAK,OAAO,EAAE,eAAA,EAAiB,MAAM,QAAA,CAAS,OAAA,EAAS,eAAA,EAAgB,IAAK,MAAM,QAAA,EAAU,MAAM,MAAA,EAAU,CAAA,EAAI,EAAE,CAAA;AACtI,EAAA,uBAAOC,cAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,YAAA,EAAc,WAAsB,KAAA,EAAO,EAAE,QAAA,EAAU,UAAA,EAAY,OAAO,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,GAAG,OAAM,EAAG,CAAA;AACjI,CAAC","file":"index.cjs","sourcesContent":["\n export default function styleInject(css, { insertAt } = {}) {\n if (!css || typeof document === 'undefined') return\n \n const head = document.head || document.getElementsByTagName('head')[0]\n const style = document.createElement('style')\n style.type = 'text/css'\n \n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild)\n } else {\n head.appendChild(style)\n }\n } else {\n head.appendChild(style)\n }\n \n if (style.styleSheet) {\n style.styleSheet.cssText = css\n } else {\n style.appendChild(document.createTextNode(css))\n }\n }\n ","import styleInject from '#style-inject';styleInject(\".react-gantt-table {\\n position: relative;\\n width: 100%;\\n height: 100%;\\n}\\n\")","import { forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\nimport { Gantt } from \"@canvas-components/gantt-table\";\nimport type { ReactGanttTableProps, ReactGanttTableRef } from \"../types\";\n\n/** 甘特图 React 宿主组件。 */\nexport const ReactGanttTable = forwardRef<ReactGanttTableRef, ReactGanttTableProps>(function ReactGanttTable(props, ref) {\n const { className, style, onTaskClick, onTaskChange, ...options } = props;\n const containerRef = useRef<HTMLDivElement>(null);\n const ganttRef = useRef<Gantt | null>(null);\n useEffect(() => { if (!containerRef.current) return; const gantt = new Gantt(containerRef.current, { ...options, onTaskClick, onTaskChange }); gantt.mount(); ganttRef.current = gantt; return () => { gantt.destroy(); ganttRef.current = null; }; }, []);\n useEffect(() => { ganttRef.current?.updateOptions({ ...options, onTaskClick, onTaskChange }); }, [options, onTaskClick, onTaskChange]);\n useImperativeHandle(ref, () => ({ getSelectedTask: () => ganttRef.current?.getSelectedTask() ?? null, scrollTo: () => undefined }), []);\n return <div ref={containerRef} className={className} style={{ position: \"relative\", width: \"100%\", height: \"100%\", ...style }} />;\n});\n"]}
1
+ {"version":3,"sources":["#style-inject:#style-inject","../src/styles/gantt-table.css","../src/components/react-gantt-table.tsx"],"names":["forwardRef","ReactGanttTable","useRef","useEffect","Gantt","useImperativeHandle","jsx"],"mappings":";;;;;;;AACyB,SAAR,YAA6B,GAAA,EAAK,EAAE,QAAA,EAAS,GAAI,EAAC,EAAG;AAC1D,EAAA,IAAY,OAAO,QAAA,KAAa,WAAA,EAAa;AAE7C,EAAA,MAAM,OAAO,QAAA,CAAS,IAAA,IAAQ,SAAS,oBAAA,CAAqB,MAAM,EAAE,CAAC,CAAA;AACrE,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,aAAA,CAAc,OAAO,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AAA,CAAS,OAAA,GAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AACL,EAAAD,eAAA,CAAU,MAAM;AACd,IAAA,QAAA,CAAS,SAAS,aAAA,CAAc,EAAE,GAAG,OAAA,EAAS,WAAA,EAAa,cAAc,CAAA;AAAA,EAC3E,CAAA,EAAG,CAAC,OAAA,EAAS,WAAA,EAAa,YAAY,CAAC,CAAA;AACvC,EAAAE,yBAAA;AAAA,IACE,GAAA;AAAA,IACA,OAAO;AAAA,MACL,eAAA,EAAiB,MAAM,QAAA,CAAS,OAAA,EAAS,iBAAgB,IAAK,IAAA;AAAA,MAC9D,qBAAA,EAAuB,MACrB,QAAA,CAAS,OAAA,EAAS,uBAAsB,IAAK,IAAA;AAAA,MAC/C,QAAA,EAAU,CAAC,IAAA,EAAM,GAAA,KAAQ,SAAS,OAAA,EAAS,QAAA,CAAS,MAAM,GAAG;AAAA,KAC/D,CAAA;AAAA,IACA;AAAC,GACH;AACA,EAAA,uBACEC,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,YAAA;AAAA,MACL,SAAA;AAAA,MACA,KAAA,EAAO,EAAE,QAAA,EAAU,UAAA,EAAY,OAAO,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,GAAG,KAAA;AAAM;AAAA,GACzE;AAEJ,CAAC","file":"index.cjs","sourcesContent":["\n export default function styleInject(css, { insertAt } = {}) {\n if (!css || typeof document === 'undefined') return\n \n const head = document.head || document.getElementsByTagName('head')[0]\n const style = document.createElement('style')\n style.type = 'text/css'\n \n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild)\n } else {\n head.appendChild(style)\n }\n } else {\n head.appendChild(style)\n }\n \n if (style.styleSheet) {\n style.styleSheet.cssText = css\n } else {\n style.appendChild(document.createTextNode(css))\n }\n }\n ","import styleInject from '#style-inject';styleInject(\".react-gantt-table {\\n position: relative;\\n width: 100%;\\n height: 100%;\\n}\\n\")","import { forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\nimport { Gantt } from \"@canvas-components/gantt-table\";\nimport type { ReactGanttTableProps, ReactGanttTableRef } from \"../types\";\n\n/** 甘特图 React 宿主组件。 */\nexport const ReactGanttTable = forwardRef<\n ReactGanttTableRef,\n ReactGanttTableProps\n>(function ReactGanttTable(props, ref) {\n const { className, style, onTaskClick, onTaskChange, ...options } = props;\n const containerRef = useRef<HTMLDivElement>(null);\n const ganttRef = useRef<Gantt | null>(null);\n useEffect(() => {\n if (!containerRef.current) return;\n const gantt = new Gantt(containerRef.current, {\n ...options,\n onTaskClick,\n onTaskChange,\n });\n gantt.mount();\n ganttRef.current = gantt;\n return () => {\n gantt.destroy();\n ganttRef.current = null;\n };\n }, []);\n useEffect(() => {\n ganttRef.current?.updateOptions({ ...options, onTaskClick, onTaskChange });\n }, [options, onTaskClick, onTaskChange]);\n useImperativeHandle(\n ref,\n () => ({\n getSelectedTask: () => ganttRef.current?.getSelectedTask() ?? null,\n getSelectedDependency: () =>\n ganttRef.current?.getSelectedDependency() ?? null,\n scrollTo: (left, top) => ganttRef.current?.scrollTo(left, top),\n }),\n [],\n );\n return (\n <div\n ref={containerRef}\n className={className}\n style={{ position: \"relative\", width: \"100%\", height: \"100%\", ...style }}\n />\n );\n});\n"]}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { CSSProperties } from 'react';
3
- import { GanttOptions, GanttTask } from '@canvas-components/gantt-table';
3
+ import { GanttOptions, GanttTask, GanttDependency } from '@canvas-components/gantt-table';
4
4
 
5
5
  /** React 甘特图属性。 */
6
6
  interface ReactGanttTableProps extends Omit<GanttOptions, "onTaskClick" | "onTaskChange"> {
@@ -12,6 +12,7 @@ interface ReactGanttTableProps extends Omit<GanttOptions, "onTaskClick" | "onTas
12
12
  /** React 甘特图实例引用。 */
13
13
  interface ReactGanttTableRef {
14
14
  getSelectedTask: () => GanttTask | null;
15
+ getSelectedDependency: () => GanttDependency | null;
15
16
  scrollTo: (left: number, top?: number) => void;
16
17
  }
17
18
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { CSSProperties } from 'react';
3
- import { GanttOptions, GanttTask } from '@canvas-components/gantt-table';
3
+ import { GanttOptions, GanttTask, GanttDependency } from '@canvas-components/gantt-table';
4
4
 
5
5
  /** React 甘特图属性。 */
6
6
  interface ReactGanttTableProps extends Omit<GanttOptions, "onTaskClick" | "onTaskChange"> {
@@ -12,6 +12,7 @@ interface ReactGanttTableProps extends Omit<GanttOptions, "onTaskClick" | "onTas
12
12
  /** React 甘特图实例引用。 */
13
13
  interface ReactGanttTableRef {
14
14
  getSelectedTask: () => GanttTask | null;
15
+ getSelectedDependency: () => GanttDependency | null;
15
16
  scrollTo: (left: number, top?: number) => void;
16
17
  }
17
18
 
package/dist/index.js CHANGED
@@ -32,7 +32,11 @@ var ReactGanttTable = forwardRef(function ReactGanttTable2(props, ref) {
32
32
  const ganttRef = useRef(null);
33
33
  useEffect(() => {
34
34
  if (!containerRef.current) return;
35
- const gantt = new Gantt(containerRef.current, { ...options, onTaskClick, onTaskChange });
35
+ const gantt = new Gantt(containerRef.current, {
36
+ ...options,
37
+ onTaskClick,
38
+ onTaskChange
39
+ });
36
40
  gantt.mount();
37
41
  ganttRef.current = gantt;
38
42
  return () => {
@@ -43,8 +47,23 @@ var ReactGanttTable = forwardRef(function ReactGanttTable2(props, ref) {
43
47
  useEffect(() => {
44
48
  ganttRef.current?.updateOptions({ ...options, onTaskClick, onTaskChange });
45
49
  }, [options, onTaskClick, onTaskChange]);
46
- useImperativeHandle(ref, () => ({ getSelectedTask: () => ganttRef.current?.getSelectedTask() ?? null, scrollTo: () => void 0 }), []);
47
- return /* @__PURE__ */ jsx("div", { ref: containerRef, className, style: { position: "relative", width: "100%", height: "100%", ...style } });
50
+ useImperativeHandle(
51
+ ref,
52
+ () => ({
53
+ getSelectedTask: () => ganttRef.current?.getSelectedTask() ?? null,
54
+ getSelectedDependency: () => ganttRef.current?.getSelectedDependency() ?? null,
55
+ scrollTo: (left, top) => ganttRef.current?.scrollTo(left, top)
56
+ }),
57
+ []
58
+ );
59
+ return /* @__PURE__ */ jsx(
60
+ "div",
61
+ {
62
+ ref: containerRef,
63
+ className,
64
+ style: { position: "relative", width: "100%", height: "100%", ...style }
65
+ }
66
+ );
48
67
  });
49
68
 
50
69
  export { ReactGanttTable };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["#style-inject:#style-inject","../src/styles/gantt-table.css","../src/components/react-gantt-table.tsx"],"names":["ReactGanttTable"],"mappings":";;;;;AACyB,SAAR,YAA6B,GAAA,EAAK,EAAE,QAAA,EAAS,GAAI,EAAC,EAAG;AAC1D,EAAA,IAAY,OAAO,QAAA,KAAa,WAAA,EAAa;AAE7C,EAAA,MAAM,OAAO,QAAA,CAAS,IAAA,IAAQ,SAAS,oBAAA,CAAqB,MAAM,EAAE,CAAC,CAAA;AACrE,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,aAAA,CAAc,OAAO,CAAA;AAC5C,EAAA,KAAA,CAAM,IAAA,GAAO,UAAA;AAEb,EAAA,IAAI,aAAa,KAAA,EAAO;AACtB,IAAA,IAAI,KAAK,UAAA,EAAY;AACnB,MAAA,IAAA,CAAK,YAAA,CAAa,KAAA,EAAO,IAAA,CAAK,UAAU,CAAA;AAAA,IAC1C,CAAA,MAAO;AACL,MAAA,IAAA,CAAK,YAAY,KAAK,CAAA;AAAA,IACxB;AAAA,EACF,CAAA,MAAO;AACL,IAAA,IAAA,CAAK,YAAY,KAAK,CAAA;AAAA,EACxB;AAEA,EAAA,IAAI,MAAM,UAAA,EAAY;AACpB,IAAA,KAAA,CAAM,WAAW,OAAA,GAAU,GAAA;AAAA,EAC7B,CAAA,MAAO;AACL,IAAA,KAAA,CAAM,WAAA,CAAY,QAAA,CAAS,cAAA,CAAe,GAAG,CAAC,C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AAA,EAAU,UAAA,EAAY,OAAO,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,GAAG,OAAM,EAAG,CAAA;AACjI,CAAC","file":"index.js","sourcesContent":["\n export default function styleInject(css, { insertAt } = {}) {\n if (!css || typeof document === 'undefined') return\n \n const head = document.head || document.getElementsByTagName('head')[0]\n const style = document.createElement('style')\n style.type = 'text/css'\n \n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild)\n } else {\n head.appendChild(style)\n }\n } else {\n head.appendChild(style)\n }\n \n if (style.styleSheet) {\n style.styleSheet.cssText = css\n } else {\n style.appendChild(document.createTextNode(css))\n }\n }\n ","import styleInject from '#style-inject';styleInject(\".react-gantt-table {\\n position: relative;\\n width: 100%;\\n height: 100%;\\n}\\n\")","import { forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\nimport { Gantt } from \"@canvas-components/gantt-table\";\nimport type { ReactGanttTableProps, ReactGanttTableRef } from \"../types\";\n\n/** 甘特图 React 宿主组件。 */\nexport const ReactGanttTable = forwardRef<ReactGanttTableRef, ReactGanttTableProps>(function ReactGanttTable(props, ref) {\n const { className, style, onTaskClick, onTaskChange, ...options } = props;\n const containerRef = useRef<HTMLDivElement>(null);\n const ganttRef = useRef<Gantt | null>(null);\n useEffect(() => { if (!containerRef.current) return; const gantt = new Gantt(containerRef.current, { ...options, onTaskClick, onTaskChange }); gantt.mount(); ganttRef.current = gantt; return () => { gantt.destroy(); ganttRef.current = null; }; }, []);\n useEffect(() => { ganttRef.current?.updateOptions({ ...options, onTaskClick, onTaskChange }); }, [options, onTaskClick, onTaskChange]);\n useImperativeHandle(ref, () => ({ getSelectedTask: () => ganttRef.current?.getSelectedTask() ?? null, scrollTo: () => undefined }), []);\n return <div ref={containerRef} className={className} style={{ position: \"relative\", width: \"100%\", height: \"100%\", ...style }} />;\n});\n"]}
1
+ {"version":3,"sources":["#style-inject:#style-inject","../src/styles/gantt-table.css","../src/components/react-gantt-table.tsx"],"names":["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B,IAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,CAAM,YAAA,CAAa,OAAA,EAAS;AAAA,MAC5C,GAAG,OAAA;AAAA,MACH,WAAA;AAAA,MACA;AAAA,KACD,CAAA;AACD,IAAA,KAAA,CAAM,KAAA,EAAM;AACZ,IAAA,QAAA,CAAS,OAAA,GAAU,KAAA;AACnB,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,CAAM,OAAA,EAAQ;AACd,MAAA,QAAA,CAAS,OAAA,GAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA,EAAG,EAAE,CAAA;AACL,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,QAAA,CAAS,SAAS,aAAA,CAAc,EAAE,GAAG,OAAA,EAAS,WAAA,EAAa,cAAc,CAAA;AAAA,EAC3E,CAAA,EAAG,CAAC,OAAA,EAAS,WAAA,EAAa,YAAY,CAAC,CAAA;AACvC,EAAA,mBAAA;AAAA,IACE,GAAA;AAAA,IACA,OAAO;AAAA,MACL,eAAA,EAAiB,MAAM,QAAA,CAAS,OAAA,EAAS,iBAAgB,IAAK,IAAA;AAAA,MAC9D,qBAAA,EAAuB,MACrB,QAAA,CAAS,OAAA,EAAS,uBAAsB,IAAK,IAAA;AAAA,MAC/C,QAAA,EAAU,CAAC,IAAA,EAAM,GAAA,KAAQ,SAAS,OAAA,EAAS,QAAA,CAAS,MAAM,GAAG;AAAA,KAC/D,CAAA;AAAA,IACA;AAAC,GACH;AACA,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA,EAAK,YAAA;AAAA,MACL,SAAA;AAAA,MACA,KAAA,EAAO,EAAE,QAAA,EAAU,UAAA,EAAY,OAAO,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,GAAG,KAAA;AAAM;AAAA,GACzE;AAEJ,CAAC","file":"index.js","sourcesContent":["\n export default function styleInject(css, { insertAt } = {}) {\n if (!css || typeof document === 'undefined') return\n \n const head = document.head || document.getElementsByTagName('head')[0]\n const style = document.createElement('style')\n style.type = 'text/css'\n \n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild)\n } else {\n head.appendChild(style)\n }\n } else {\n head.appendChild(style)\n }\n \n if (style.styleSheet) {\n style.styleSheet.cssText = css\n } else {\n style.appendChild(document.createTextNode(css))\n }\n }\n ","import styleInject from '#style-inject';styleInject(\".react-gantt-table {\\n position: relative;\\n width: 100%;\\n height: 100%;\\n}\\n\")","import { forwardRef, useEffect, useImperativeHandle, useRef } from \"react\";\nimport { Gantt } from \"@canvas-components/gantt-table\";\nimport type { ReactGanttTableProps, ReactGanttTableRef } from \"../types\";\n\n/** 甘特图 React 宿主组件。 */\nexport const ReactGanttTable = forwardRef<\n ReactGanttTableRef,\n ReactGanttTableProps\n>(function ReactGanttTable(props, ref) {\n const { className, style, onTaskClick, onTaskChange, ...options } = props;\n const containerRef = useRef<HTMLDivElement>(null);\n const ganttRef = useRef<Gantt | null>(null);\n useEffect(() => {\n if (!containerRef.current) return;\n const gantt = new Gantt(containerRef.current, {\n ...options,\n onTaskClick,\n onTaskChange,\n });\n gantt.mount();\n ganttRef.current = gantt;\n return () => {\n gantt.destroy();\n ganttRef.current = null;\n };\n }, []);\n useEffect(() => {\n ganttRef.current?.updateOptions({ ...options, onTaskClick, onTaskChange });\n }, [options, onTaskClick, onTaskChange]);\n useImperativeHandle(\n ref,\n () => ({\n getSelectedTask: () => ganttRef.current?.getSelectedTask() ?? null,\n getSelectedDependency: () =>\n ganttRef.current?.getSelectedDependency() ?? null,\n scrollTo: (left, top) => ganttRef.current?.scrollTo(left, top),\n }),\n [],\n );\n return (\n <div\n ref={containerRef}\n className={className}\n style={{ position: \"relative\", width: \"100%\", height: \"100%\", ...style }}\n />\n );\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvas-components/react-gantt-table",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "React adapter for the Gantt table core engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -28,7 +28,7 @@
28
28
  "pnpm": ">=9.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "@canvas-components/gantt-table": "0.1.1"
31
+ "@canvas-components/gantt-table": "0.1.2"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": ">=16.8.0",