d2coreui 23.0.55 → 23.0.57
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/CHANGELOG.md +47 -0
- package/components/date/dateRangeInput.js +5 -5
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateRangeInputAdvancedPanel.js +26 -15
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
- package/components/date/dateRangeInputConfirm.js +16 -13
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +12 -3
- package/components/date/dateTimeInput.js +164 -93
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/grid/config/dataGridEditor.d.ts +4 -3
- package/components/grid/config/dataGridEditor.js +16 -4
- package/components/grid/config/dataGridEditor.js.map +1 -1
- package/components/grid/dataGrid.d.ts +19 -5
- package/components/grid/dataGrid.js +9 -5
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/export/contextMenu.d.ts +3 -2
- package/components/grid/export/contextMenu.js.map +1 -1
- package/components/grid/extendedDataGrid.d.ts +11 -4
- package/components/grid/extendedDataGrid.js +34 -24
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/modal/impl/draggableModalInner.js +22 -10
- package/components/modal/impl/draggableModalInner.js.map +1 -1
- package/components/modal/impl/draggableModalReducer.d.ts +2 -3
- package/components/modal/impl/draggableModalReducer.js +9 -7
- package/components/modal/impl/draggableModalReducer.js.map +1 -1
- package/components/modal/modalDialog.d.ts +2 -1
- package/components/modal/modalDialog.js +2 -1
- package/components/modal/modalDialog.js.map +1 -1
- package/components/style/withCss.d.ts +9 -4
- package/components/style/withCss.js +7 -3
- package/components/style/withCss.js.map +1 -1
- package/i18n/components.cs.json +2 -0
- package/i18n/components.sk.json +2 -0
- package/i18n/components.uk.json +2 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MenuProps } from "antd";
|
|
2
|
+
import { ResolvedUtcOffsetMode } from "d2core/i18n/localeHolder";
|
|
2
3
|
import ProgressPopup from "./progressPopup";
|
|
3
4
|
import { MenuElement } from "../dataGrid";
|
|
4
5
|
/** Properties of {@link getContextMenu}. The whole object is also passed to `getExportContent`. */
|
|
@@ -9,8 +10,8 @@ export interface ContextMenuProps {
|
|
|
9
10
|
showMilliseconds: boolean;
|
|
10
11
|
/** Hint for `getExportContent` to format dates with the year. */
|
|
11
12
|
showYear: boolean;
|
|
12
|
-
/** Hint for `getExportContent` to format date-time values
|
|
13
|
-
showUtcOffset:
|
|
13
|
+
/** Hint for `getExportContent` how to format date-time values of the hour repeated at the end of the daylight saving time. */
|
|
14
|
+
showUtcOffset: ResolvedUtcOffsetMode;
|
|
14
15
|
/** Copy to the clipboard without the progress (and error) notification. */
|
|
15
16
|
hideNotificationOnClipboardCopy?: boolean;
|
|
16
17
|
/** Page orientation of the PDF export, shown by the switch in the PDF menu item. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextMenu.js","sourceRoot":"","sources":["../../../../../components/grid/export/contextMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAY,MAAM,EAAE,UAAU,EAAC,MAAM,MAAM,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAC5E,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAgDpE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAuB;IAC1D,MAAM,EAAC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uB,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;oBACrE,CAAC,GACH,CACH;SACN;QACD;YACI,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,SAAS;SAClB;QACD;YACI,GAAG,EAAE,eAAe;YACpB,IAAI,EAAE,oBAAC,YAAY,OAAE;YACrB,QAAQ,EAAE,KAAK,CAAC,SAAS;YACzB,KAAK,EAAE;gBACF,IAAI,CAAC,mBAAmB,CAAC;gBAC1B,oBAAC,UAAU,CAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,aAA0B,CACxE;SACN;KACJ,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACX,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACH,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACd,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,OAAO,EAAE,CAAC;gBACV,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjC,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC","sourcesContent":["import {CopyOutlined, FileOutlined, FilePdfOutlined, FileTextOutlined} from \"@ant-design/icons\";\r\nimport {MenuProps, Switch, Typography} from \"antd\";\r\nimport React from \"react\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {spawn, Thread, Worker} from \"threads\"\r\nimport dayjs from \"dayjs\";\r\nimport ProgressPopup from \"./progressPopup\";\r\nimport {MenuElement} from \"../dataGrid\";\r\nimport {ClipboardUtils} from \"d2coreui/components/clipboard/clipboardUtils\";\r\nimport PlatformSpecific from \"d2coreui/components/platformSpecific\";\r\n\r\n\r\n/** Properties of {@link getContextMenu}. The whole object is also passed to `getExportContent`. */\r\nexport interface ContextMenuProps {\r\n /** Hint for `getExportContent` to export only the selected rows. */\r\n onlySelectedNodes?: boolean\r\n /** Hint for `getExportContent` to format date-time values with milliseconds. */\r\n showMilliseconds: boolean\r\n /** Hint for `getExportContent` to format dates with the year. */\r\n showYear: boolean\r\n /** Hint for `getExportContent` to format date-time values with the UTC offset. */\r\n showUtcOffset: boolean\r\n /** Copy to the clipboard without the progress (and error) notification. */\r\n hideNotificationOnClipboardCopy?: boolean\r\n /** Page orientation of the PDF export, shown by the switch in the PDF menu item. */\r\n pageOrientation: PageOrientation\r\n /** Disables the export items, e.g. while an export is running. */\r\n exporting: boolean\r\n\r\n /**\r\n * Produces the exported table: an array of rows of cell texts, the first row being the column headers.\r\n * It may report progress through `progressPopup`, which is `null` for a clipboard copy with\r\n * `hideNotificationOnClipboardCopy`.\r\n */\r\n getExportContent: (progressPopup: ProgressPopup | null, props: ContextMenuProps) => Promise<string[][]>\r\n /** Called when the user toggles the PDF orientation switch; the caller is expected to pass the new `pageOrientation` back. */\r\n onPageOrientationChange:(pageOrientation: PageOrientation)=>void\r\n /**\r\n * Called with `true` when any menu item is clicked and with `false` when the item has been processed. For the PDF\r\n * export, `false` comes before the PDF is produced (it is generated asynchronously), and it is not called at all when the\r\n * export fails.\r\n */\r\n onExport:(start: boolean)=>void\r\n\r\n /** Receives the built-in menu items and returns the items to show, e.g. with custom items added. */\r\n renderer?(menuElements: MenuElement[]): MenuElement[]\r\n\r\n /** Called with the key of every clicked item, built-in ones (`txtExport`, `csvExport`, `pdfExport`, `clipboardCopy`) included. */\r\n onClick?(key: string): void\r\n\r\n /** Called after a successful export with the number of exported data rows and the file name, or `\"[CLIPBOARD]\"` for a clipboard copy. */\r\n onExported?: (rowCount: number, destination: string) => void\r\n}\r\n\r\n/** Page orientation of the PDF export. */\r\nexport type PageOrientation = \"PORTRAIT\" | \"LANDSCAPE\";\r\n\r\n/**\r\n * Builds the export menu of a grid as antd `MenuProps` (for a `Dropdown`): export to TXT, CSV and PDF files and copy to\r\n * the clipboard. Content comes from `getExportContent` and is converted in a web worker; progress is shown by a\r\n * {@link ProgressPopup}, and files named `export_YYYYMMDD_HHmm.<ext>` are saved through {@link PlatformSpecific}.\r\n *\r\n * The workers are started with `new Worker(new URL(..., import.meta.url))`, so the consuming bundler must emit them as\r\n * separate chunks; a webpack application emitting its chunks into a subdirectory needs `output.publicPath: \"auto\"`.\r\n */\r\nexport default function getContextMenu(props: ContextMenuProps): MenuProps {\r\n const {hideNotificationOnClipboardCopy, getExportContent, renderer, onClick} = props;\r\n\r\n const onExportMenuClick = async (menuKey: string) => {\r\n props.onExport(true);\r\n switch (menuKey) {\r\n case \"txtExport\": {\r\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" TXT\");\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const txtExport = await spawn(new Worker(new URL('./worker/txtExport.js', import.meta.url) as any, {type: 'module'}));\r\n const textContent = await txtExport(tableContent);\r\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.txt`;\r\n await Thread.terminate(txtExport);\r\n await progressPopup.update(100);\r\n PlatformSpecific.INSTANCE.saveContent(fileName, textContent, true);\r\n props.onExported?.(tableContent.length - 1, fileName);\r\n break;\r\n }\r\n case \"csvExport\": {\r\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" CSV\");\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const csvExport = await spawn(new Worker(new URL('./worker/csvExport.js', import.meta.url) as any, {type: 'module'}));\r\n const csvContent = await csvExport(tableContent);\r\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.csv`;\r\n await Thread.terminate(csvExport);\r\n await progressPopup.update(100);\r\n PlatformSpecific.INSTANCE.saveContent(fileName, csvContent, true);\r\n props.onExported?.(tableContent.length - 1, fileName);\r\n break;\r\n }\r\n case \"clipboardCopy\": {\r\n const progressPopup = !hideNotificationOnClipboardCopy ? new ProgressPopup(i18n(\"Export List to\") + \" \" + i18n(\"Clipboard\")) : null;\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const clipboardExport = await spawn(new Worker(new URL('./worker/clipboardExport.js', import.meta.url) as any, {type: 'module'}));\r\n const clipboardContent = await clipboardExport(tableContent);\r\n const success = ClipboardUtils.copyToClipboard(clipboardContent);\r\n if (success) {\r\n await Thread.terminate(clipboardExport);\r\n await progressPopup?.update(100);\r\n props.onExported?.(tableContent.length - 1, \"[CLIPBOARD]\");\r\n } else {\r\n progressPopup?.error();\r\n }\r\n break;\r\n }\r\n case \"pdfExport\": {\r\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" PDF\");\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const pdfExport = await spawn(new Worker(new URL('./worker/pdfExport.js', import.meta.url) as any, {type: 'module'}));\r\n pdfExport.handler().subscribe(async (data: string) => {\r\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.pdf`;\r\n Thread.terminate(pdfExport);\r\n await progressPopup.update(100);\r\n PlatformSpecific.INSTANCE.saveContent(fileName, data, false);\r\n props.onExported?.(tableContent.length - 1, fileName);\r\n });\r\n pdfExport.export(tableContent, {pageOrientation: props.pageOrientation});\r\n break;\r\n }\r\n }\r\n props.onExport(false);\r\n }\r\n\r\n let menuItems: MenuElement[] = [\r\n {\r\n key: \"txtExport\",\r\n icon: <FileOutlined/>,\r\n disabled: props.exporting,\r\n label: i18n(\"Export List to\") + \" TXT\",\r\n },\r\n {\r\n key: \"csvExport\",\r\n icon: <FileTextOutlined/>,\r\n disabled: props.exporting,\r\n label: i18n(\"Export List to\") + \" CSV\",\r\n },\r\n {\r\n key: \"pdfExport\",\r\n icon: <FilePdfOutlined/>,\r\n disabled: props.exporting,\r\n label: <>\r\n {i18n(\"Export List to\") + \" PDF\"}\r\n <Switch\r\n style={{marginLeft: 8}}\r\n checkedChildren={i18n(\"Landscape\") + \" \"}\r\n unCheckedChildren={\"\" + i18n(\"Portrait\")}\r\n checked={props.pageOrientation !== \"PORTRAIT\"}\r\n onChange={(checked, e) => {\r\n e.stopPropagation();\r\n (e as any).nativeEvent.stopImmediatePropagation();\r\n props.onPageOrientationChange(checked ? \"LANDSCAPE\" : \"PORTRAIT\")\r\n }}\r\n />\r\n </>\r\n },\r\n {\r\n key: \"divider1\",\r\n type: \"divider\",\r\n },\r\n {\r\n key: \"clipboardCopy\",\r\n icon: <CopyOutlined/>,\r\n disabled: props.exporting,\r\n label: <>\r\n {i18n(\"Copy to Clipboard\")}\r\n <Typography.Text code style={{float: \"right\"}}>CTRL+C</Typography.Text>\r\n </>,\r\n }\r\n ];\r\n\r\n if (renderer) {\r\n menuItems = renderer(menuItems);\r\n }\r\n\r\n return {\r\n items: menuItems,\r\n onClick: (item) => {\r\n onExportMenuClick(item.key);\r\n if (onClick) {\r\n onClick(item.key.toString());\r\n }\r\n },\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"contextMenu.js","sourceRoot":"","sources":["../../../../../components/grid/export/contextMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAY,MAAM,EAAE,UAAU,EAAC,MAAM,MAAM,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAEpC,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAC,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,8CAA8C,CAAC;AAC5E,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAgDpE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAuB;IAC1D,MAAM,EAAC,+BAA+B,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,EAAC,GAAG,KAAK,CAAC;IAErF,MAAM,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AC,GACH,CACH;SACN;QACD;YACI,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,SAAS;SAClB;QACD;YACI,GAAG,EAAE,eAAe;YACpB,IAAI,EAAE,oBAAC,YAAY,OAAE;YACrB,QAAQ,EAAE,KAAK,CAAC,SAAS;YACzB,KAAK,EAAE;gBACF,IAAI,CAAC,mBAAmB,CAAC;gBAC1B,oBAAC,UAAU,CAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,aAA0B,CACxE;SACN;KACJ,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACX,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACH,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACd,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,OAAO,EAAE,CAAC;gBACV,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjC,CAAC;QACL,CAAC;KACJ,CAAA;AACL,CAAC","sourcesContent":["import {CopyOutlined, FileOutlined, FilePdfOutlined, FileTextOutlined} from \"@ant-design/icons\";\r\nimport {MenuProps, Switch, Typography} from \"antd\";\r\nimport React from \"react\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {ResolvedUtcOffsetMode} from \"d2core/i18n/localeHolder\";\r\nimport {spawn, Thread, Worker} from \"threads\"\r\nimport dayjs from \"dayjs\";\r\nimport ProgressPopup from \"./progressPopup\";\r\nimport {MenuElement} from \"../dataGrid\";\r\nimport {ClipboardUtils} from \"d2coreui/components/clipboard/clipboardUtils\";\r\nimport PlatformSpecific from \"d2coreui/components/platformSpecific\";\r\n\r\n\r\n/** Properties of {@link getContextMenu}. The whole object is also passed to `getExportContent`. */\r\nexport interface ContextMenuProps {\r\n /** Hint for `getExportContent` to export only the selected rows. */\r\n onlySelectedNodes?: boolean\r\n /** Hint for `getExportContent` to format date-time values with milliseconds. */\r\n showMilliseconds: boolean\r\n /** Hint for `getExportContent` to format dates with the year. */\r\n showYear: boolean\r\n /** Hint for `getExportContent` how to format date-time values of the hour repeated at the end of the daylight saving time. */\r\n showUtcOffset: ResolvedUtcOffsetMode\r\n /** Copy to the clipboard without the progress (and error) notification. */\r\n hideNotificationOnClipboardCopy?: boolean\r\n /** Page orientation of the PDF export, shown by the switch in the PDF menu item. */\r\n pageOrientation: PageOrientation\r\n /** Disables the export items, e.g. while an export is running. */\r\n exporting: boolean\r\n\r\n /**\r\n * Produces the exported table: an array of rows of cell texts, the first row being the column headers.\r\n * It may report progress through `progressPopup`, which is `null` for a clipboard copy with\r\n * `hideNotificationOnClipboardCopy`.\r\n */\r\n getExportContent: (progressPopup: ProgressPopup | null, props: ContextMenuProps) => Promise<string[][]>\r\n /** Called when the user toggles the PDF orientation switch; the caller is expected to pass the new `pageOrientation` back. */\r\n onPageOrientationChange:(pageOrientation: PageOrientation)=>void\r\n /**\r\n * Called with `true` when any menu item is clicked and with `false` when the item has been processed. For the PDF\r\n * export, `false` comes before the PDF is produced (it is generated asynchronously), and it is not called at all when the\r\n * export fails.\r\n */\r\n onExport:(start: boolean)=>void\r\n\r\n /** Receives the built-in menu items and returns the items to show, e.g. with custom items added. */\r\n renderer?(menuElements: MenuElement[]): MenuElement[]\r\n\r\n /** Called with the key of every clicked item, built-in ones (`txtExport`, `csvExport`, `pdfExport`, `clipboardCopy`) included. */\r\n onClick?(key: string): void\r\n\r\n /** Called after a successful export with the number of exported data rows and the file name, or `\"[CLIPBOARD]\"` for a clipboard copy. */\r\n onExported?: (rowCount: number, destination: string) => void\r\n}\r\n\r\n/** Page orientation of the PDF export. */\r\nexport type PageOrientation = \"PORTRAIT\" | \"LANDSCAPE\";\r\n\r\n/**\r\n * Builds the export menu of a grid as antd `MenuProps` (for a `Dropdown`): export to TXT, CSV and PDF files and copy to\r\n * the clipboard. Content comes from `getExportContent` and is converted in a web worker; progress is shown by a\r\n * {@link ProgressPopup}, and files named `export_YYYYMMDD_HHmm.<ext>` are saved through {@link PlatformSpecific}.\r\n *\r\n * The workers are started with `new Worker(new URL(..., import.meta.url))`, so the consuming bundler must emit them as\r\n * separate chunks; a webpack application emitting its chunks into a subdirectory needs `output.publicPath: \"auto\"`.\r\n */\r\nexport default function getContextMenu(props: ContextMenuProps): MenuProps {\r\n const {hideNotificationOnClipboardCopy, getExportContent, renderer, onClick} = props;\r\n\r\n const onExportMenuClick = async (menuKey: string) => {\r\n props.onExport(true);\r\n switch (menuKey) {\r\n case \"txtExport\": {\r\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" TXT\");\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const txtExport = await spawn(new Worker(new URL('./worker/txtExport.js', import.meta.url) as any, {type: 'module'}));\r\n const textContent = await txtExport(tableContent);\r\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.txt`;\r\n await Thread.terminate(txtExport);\r\n await progressPopup.update(100);\r\n PlatformSpecific.INSTANCE.saveContent(fileName, textContent, true);\r\n props.onExported?.(tableContent.length - 1, fileName);\r\n break;\r\n }\r\n case \"csvExport\": {\r\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" CSV\");\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const csvExport = await spawn(new Worker(new URL('./worker/csvExport.js', import.meta.url) as any, {type: 'module'}));\r\n const csvContent = await csvExport(tableContent);\r\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.csv`;\r\n await Thread.terminate(csvExport);\r\n await progressPopup.update(100);\r\n PlatformSpecific.INSTANCE.saveContent(fileName, csvContent, true);\r\n props.onExported?.(tableContent.length - 1, fileName);\r\n break;\r\n }\r\n case \"clipboardCopy\": {\r\n const progressPopup = !hideNotificationOnClipboardCopy ? new ProgressPopup(i18n(\"Export List to\") + \" \" + i18n(\"Clipboard\")) : null;\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const clipboardExport = await spawn(new Worker(new URL('./worker/clipboardExport.js', import.meta.url) as any, {type: 'module'}));\r\n const clipboardContent = await clipboardExport(tableContent);\r\n const success = ClipboardUtils.copyToClipboard(clipboardContent);\r\n if (success) {\r\n await Thread.terminate(clipboardExport);\r\n await progressPopup?.update(100);\r\n props.onExported?.(tableContent.length - 1, \"[CLIPBOARD]\");\r\n } else {\r\n progressPopup?.error();\r\n }\r\n break;\r\n }\r\n case \"pdfExport\": {\r\n const progressPopup = new ProgressPopup(i18n(\"Export List to\") + \" PDF\");\r\n const tableContent = await getExportContent(progressPopup, props);\r\n const pdfExport = await spawn(new Worker(new URL('./worker/pdfExport.js', import.meta.url) as any, {type: 'module'}));\r\n pdfExport.handler().subscribe(async (data: string) => {\r\n const fileName = `export_${dayjs().format(\"YYYYMMDD_HHmm\")}.pdf`;\r\n Thread.terminate(pdfExport);\r\n await progressPopup.update(100);\r\n PlatformSpecific.INSTANCE.saveContent(fileName, data, false);\r\n props.onExported?.(tableContent.length - 1, fileName);\r\n });\r\n pdfExport.export(tableContent, {pageOrientation: props.pageOrientation});\r\n break;\r\n }\r\n }\r\n props.onExport(false);\r\n }\r\n\r\n let menuItems: MenuElement[] = [\r\n {\r\n key: \"txtExport\",\r\n icon: <FileOutlined/>,\r\n disabled: props.exporting,\r\n label: i18n(\"Export List to\") + \" TXT\",\r\n },\r\n {\r\n key: \"csvExport\",\r\n icon: <FileTextOutlined/>,\r\n disabled: props.exporting,\r\n label: i18n(\"Export List to\") + \" CSV\",\r\n },\r\n {\r\n key: \"pdfExport\",\r\n icon: <FilePdfOutlined/>,\r\n disabled: props.exporting,\r\n label: <>\r\n {i18n(\"Export List to\") + \" PDF\"}\r\n <Switch\r\n style={{marginLeft: 8}}\r\n checkedChildren={i18n(\"Landscape\") + \" \"}\r\n unCheckedChildren={\"\" + i18n(\"Portrait\")}\r\n checked={props.pageOrientation !== \"PORTRAIT\"}\r\n onChange={(checked, e) => {\r\n e.stopPropagation();\r\n (e as any).nativeEvent.stopImmediatePropagation();\r\n props.onPageOrientationChange(checked ? \"LANDSCAPE\" : \"PORTRAIT\")\r\n }}\r\n />\r\n </>\r\n },\r\n {\r\n key: \"divider1\",\r\n type: \"divider\",\r\n },\r\n {\r\n key: \"clipboardCopy\",\r\n icon: <CopyOutlined/>,\r\n disabled: props.exporting,\r\n label: <>\r\n {i18n(\"Copy to Clipboard\")}\r\n <Typography.Text code style={{float: \"right\"}}>CTRL+C</Typography.Text>\r\n </>,\r\n }\r\n ];\r\n\r\n if (renderer) {\r\n menuItems = renderer(menuItems);\r\n }\r\n\r\n return {\r\n items: menuItems,\r\n onClick: (item) => {\r\n onExportMenuClick(item.key);\r\n if (onClick) {\r\n onClick(item.key.toString());\r\n }\r\n },\r\n }\r\n}\r\n"]}
|
|
@@ -3,6 +3,7 @@ import DataGrid, { DataGridFilterProps, DataGridProps, DataGridSearchProps, Sort
|
|
|
3
3
|
import { RowStyleRule } from "d2coreui/components/grid/cell/tableDefaultRowStyleRules";
|
|
4
4
|
import { ColumnState, RowDataUpdatedEvent } from "ag-grid-community";
|
|
5
5
|
import { DataChangeStateEnum } from "d2core/types/dataChangeStateEnum";
|
|
6
|
+
import { UtcOffsetMode } from "d2core/i18n/localeHolder";
|
|
6
7
|
/**
|
|
7
8
|
* Persistable user configuration of an {@link ExtendedDataGrid}: column state, paging, follow-last-record,
|
|
8
9
|
* row styling, date-time formatting and side panel widths.
|
|
@@ -66,16 +67,17 @@ export interface GridConfiguration {
|
|
|
66
67
|
*/
|
|
67
68
|
defaultHideYear?: boolean;
|
|
68
69
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
70
|
+
* How date-time columns tell apart the two readings of a DST fold - see `UtcOffsetMode` of
|
|
71
|
+
* `d2core/i18n/localeHolder`: `true` / `"offset"` the UTC offset at every time, `"offsetInFold"` the UTC offset only
|
|
72
|
+
* in the repeated hour, `"hourLetter"` the hour as `A2` / `B2`, `false` / `"none"` not at all.
|
|
71
73
|
* @default true
|
|
72
74
|
*/
|
|
73
|
-
showUtcOffset?:
|
|
75
|
+
showUtcOffset?: UtcOffsetMode;
|
|
74
76
|
/**
|
|
75
77
|
* Value of {@link GridConfiguration.showUtcOffset} restored when the user reverts the table settings.
|
|
76
78
|
* @default true
|
|
77
79
|
*/
|
|
78
|
-
defaultShowUtcOffset?:
|
|
80
|
+
defaultShowUtcOffset?: UtcOffsetMode;
|
|
79
81
|
/**
|
|
80
82
|
* Width of the left filter panel in pixels; `0` means collapsed. When not set, the panel is shown with
|
|
81
83
|
* `filterPanel.defaultWidth` (220 if that is not set either) if a `filterPanel` is configured.
|
|
@@ -379,6 +381,11 @@ export default class ExtendedDataGrid<T extends {
|
|
|
379
381
|
private equalValues;
|
|
380
382
|
private _onSelectionChanged;
|
|
381
383
|
private _onViewportChanged;
|
|
384
|
+
private _onSortChanged;
|
|
385
|
+
private _onColumnsChanged;
|
|
386
|
+
private _onShowMilliseconds;
|
|
387
|
+
private _onShowYear;
|
|
388
|
+
private _onShowUtcOffset;
|
|
382
389
|
private renderToolbarButtons;
|
|
383
390
|
private renderToolbar;
|
|
384
391
|
private renderSearchBadge;
|
|
@@ -132,6 +132,11 @@ class ExtendedDataGrid extends React.Component {
|
|
|
132
132
|
this.selectNextPreviousRecord = this.selectNextPreviousRecord.bind(this);
|
|
133
133
|
this._onSelectionChanged = this._onSelectionChanged.bind(this);
|
|
134
134
|
this._onViewportChanged = this._onViewportChanged.bind(this);
|
|
135
|
+
this._onSortChanged = this._onSortChanged.bind(this);
|
|
136
|
+
this._onColumnsChanged = this._onColumnsChanged.bind(this);
|
|
137
|
+
this._onShowMilliseconds = this._onShowMilliseconds.bind(this);
|
|
138
|
+
this._onShowYear = this._onShowYear.bind(this);
|
|
139
|
+
this._onShowUtcOffset = this._onShowUtcOffset.bind(this);
|
|
135
140
|
this._onResize = this._onResize.bind(this);
|
|
136
141
|
}
|
|
137
142
|
componentDidMount() {
|
|
@@ -671,6 +676,33 @@ class ExtendedDataGrid extends React.Component {
|
|
|
671
676
|
this.props.onViewportChanged(dataGridEvent);
|
|
672
677
|
}
|
|
673
678
|
}
|
|
679
|
+
_onSortChanged(event) {
|
|
680
|
+
var _a, _b;
|
|
681
|
+
const sortModel = (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.getSortModel();
|
|
682
|
+
if (this.state.gridConfiguration.followLastRecord && this.state.gridConfiguration.followLastRecordSortModel && !isEqual(this.state.gridConfiguration.followLastRecordSortModel, sortModel)) {
|
|
683
|
+
this.enableFollowLastRecord(false);
|
|
684
|
+
}
|
|
685
|
+
const columnState = (_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.getColumnState();
|
|
686
|
+
this._changeConfiguration({ columnModel: this._withPendingColumnStates(columnState) });
|
|
687
|
+
if (this.props.onSortChanged) {
|
|
688
|
+
this.props.onSortChanged(event);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
_onColumnsChanged(columnModel, event) {
|
|
692
|
+
this._changeConfiguration({ columnModel: this._withPendingColumnStates(columnModel) });
|
|
693
|
+
if (this.props.onColumnsChanged) {
|
|
694
|
+
this.props.onColumnsChanged(columnModel, event);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
_onShowMilliseconds(showMillis, callback) {
|
|
698
|
+
this._changeConfiguration({ showMilliseconds: showMillis }, callback);
|
|
699
|
+
}
|
|
700
|
+
_onShowYear(showYear, callback) {
|
|
701
|
+
this._changeConfiguration({ hideYear: !showYear }, callback);
|
|
702
|
+
}
|
|
703
|
+
_onShowUtcOffset(showUtcOffset, callback) {
|
|
704
|
+
this._changeConfiguration({ showUtcOffset: showUtcOffset }, callback);
|
|
705
|
+
}
|
|
674
706
|
renderToolbarButtons() {
|
|
675
707
|
var _a, _b, _c;
|
|
676
708
|
const renderFilter = this.props.filterPanel && this.props.filterPanel.renderer;
|
|
@@ -751,34 +783,12 @@ class ExtendedDataGrid extends React.Component {
|
|
|
751
783
|
toolbarButtons: this.renderToolbarButtons(),
|
|
752
784
|
hideRecordCount: toolbar === null || toolbar === void 0 ? void 0 : toolbar.hideRecordCount,
|
|
753
785
|
extraContent: toolbar === null || toolbar === void 0 ? void 0 : toolbar.extraContent,
|
|
754
|
-
}, onSortChanged: (
|
|
755
|
-
var _a, _b;
|
|
756
|
-
const sortModel = (_a = this.dataGrid) === null || _a === void 0 ? void 0 : _a.getSortModel();
|
|
757
|
-
if (this.state.gridConfiguration.followLastRecord && this.state.gridConfiguration.followLastRecordSortModel && !isEqual(this.state.gridConfiguration.followLastRecordSortModel, sortModel)) {
|
|
758
|
-
this.enableFollowLastRecord(false);
|
|
759
|
-
}
|
|
760
|
-
const columnState = (_b = this.gridApi) === null || _b === void 0 ? void 0 : _b.getColumnState();
|
|
761
|
-
this._changeConfiguration({ columnModel: this._withPendingColumnStates(columnState) });
|
|
762
|
-
if (onSortChanged) {
|
|
763
|
-
onSortChanged(event);
|
|
764
|
-
}
|
|
765
|
-
}, onNewColumnsLoaded: this._onNewColumnsLoaded, onColumnsChanged: (columnModel, event) => {
|
|
766
|
-
this._changeConfiguration({ columnModel: this._withPendingColumnStates(columnModel) });
|
|
767
|
-
if (onColumnsChanged) {
|
|
768
|
-
onColumnsChanged(columnModel, event);
|
|
769
|
-
}
|
|
770
|
-
}, onRowDataUpdated: this._onRowDataUpdated, tableConfigVisible: this.state.tableConfigVisible, onTableConfigVisible: (visible) => {
|
|
786
|
+
}, onSortChanged: this._onSortChanged, onNewColumnsLoaded: this._onNewColumnsLoaded, onColumnsChanged: this._onColumnsChanged, onRowDataUpdated: this._onRowDataUpdated, tableConfigVisible: this.state.tableConfigVisible, onTableConfigVisible: (visible) => {
|
|
771
787
|
this.setState({ tableConfigVisible: visible });
|
|
772
788
|
if (onTableConfigVisible) {
|
|
773
789
|
onTableConfigVisible(visible);
|
|
774
790
|
}
|
|
775
|
-
}, onSelectionChanged: this._onSelectionChanged, rowStyleRules: this.state.gridConfiguration.rowStyleRules, defaultRowStyleRules: this.state.gridConfiguration.defaultRowStyleRules, onChangeRowStyleRules: this._onChangeRowStyleRules, onViewportChanged: this._onViewportChanged, showMilliseconds: this.state.gridConfiguration.showMilliseconds, defaultShowMilliseconds: this.state.gridConfiguration.defaultShowMilliseconds, onShowMilliseconds:
|
|
776
|
-
this._changeConfiguration({ showMilliseconds: showMillis }, callback);
|
|
777
|
-
}, hideYear: this.state.gridConfiguration.hideYear, defaultHideYear: this.state.gridConfiguration.defaultHideYear, onShowYear: (showYear, callback) => {
|
|
778
|
-
this._changeConfiguration({ hideYear: !showYear }, callback);
|
|
779
|
-
}, showUtcOffset: this.state.gridConfiguration.showUtcOffset, defaultShowUtcOffset: this.state.gridConfiguration.defaultShowUtcOffset, onShowUtcOffset: (showUtcOffset, callback) => {
|
|
780
|
-
this._changeConfiguration({ showUtcOffset: showUtcOffset }, callback);
|
|
781
|
-
} })));
|
|
791
|
+
}, onSelectionChanged: this._onSelectionChanged, rowStyleRules: this.state.gridConfiguration.rowStyleRules, defaultRowStyleRules: this.state.gridConfiguration.defaultRowStyleRules, onChangeRowStyleRules: this._onChangeRowStyleRules, onViewportChanged: this._onViewportChanged, showMilliseconds: this.state.gridConfiguration.showMilliseconds, defaultShowMilliseconds: this.state.gridConfiguration.defaultShowMilliseconds, onShowMilliseconds: this._onShowMilliseconds, hideYear: this.state.gridConfiguration.hideYear, defaultHideYear: this.state.gridConfiguration.defaultHideYear, onShowYear: this._onShowYear, showUtcOffset: this.state.gridConfiguration.showUtcOffset, defaultShowUtcOffset: this.state.gridConfiguration.defaultShowUtcOffset, onShowUtcOffset: this._onShowUtcOffset })));
|
|
782
792
|
}
|
|
783
793
|
renderDataGridWithControlPanel() {
|
|
784
794
|
if (this.props.controlPanel && this.props.controlPanel.renderer) {
|