d2coreui 23.0.57 → 23.0.59

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 (37) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +154 -154
  3. package/components/date/dateRangeInputAdvancedPanel.js +14 -14
  4. package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
  5. package/components/date/dateRangeInputConfirm.js +5 -5
  6. package/components/date/dateRangeInputConfirm.js.map +1 -1
  7. package/components/date/dateTimeInput.js +61 -61
  8. package/components/date/dateTimeInput.js.map +1 -1
  9. package/components/grid/config/columnTransfer.js +61 -43
  10. package/components/grid/config/columnTransfer.js.map +1 -1
  11. package/components/grid/dataGrid.d.ts +24 -1
  12. package/components/grid/dataGrid.js +106 -45
  13. package/components/grid/dataGrid.js.map +1 -1
  14. package/components/grid/export/worker/pdfExport.js.map +1 -1
  15. package/components/grid/extendedDataGrid.js +1 -0
  16. package/components/grid/extendedDataGrid.js.map +1 -1
  17. package/components/grid/header/simpleHeader.d.ts +1 -1
  18. package/components/grid/header/simpleHeader.js +3 -2
  19. package/components/grid/header/simpleHeader.js.map +1 -1
  20. package/components/grid/panel/dataGridPagination.d.ts +4 -1
  21. package/components/grid/panel/dataGridPagination.js +13 -8
  22. package/components/grid/panel/dataGridPagination.js.map +1 -1
  23. package/components/input/autoCompleteInput.d.ts +3 -0
  24. package/components/input/autoCompleteInput.js +18 -3
  25. package/components/input/autoCompleteInput.js.map +1 -1
  26. package/components/modal/impl/draggableModal.d.ts +1 -1
  27. package/components/modal/impl/draggableModal.js.map +1 -1
  28. package/components/modal/impl/draggableModalInner.js +1 -1
  29. package/components/modal/impl/draggableModalInner.js.map +1 -1
  30. package/components/modal/impl/draggableModalStyles.js +126 -126
  31. package/components/modal/impl/draggableModalStyles.js.map +1 -1
  32. package/components/modal/impl/resizeHandle.js.map +1 -1
  33. package/components/modal/modalDialog.d.ts +2 -2
  34. package/components/modal/modalDialog.js +2 -2
  35. package/components/modal/modalDialog.js.map +1 -1
  36. package/package.json +1 -1
  37. package/style/index.less +240 -240
@@ -1 +1 @@
1
- {"version":3,"file":"simpleHeader.js","sourceRoot":"","sources":["../../../../../components/grid/header/simpleHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACH,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,QAAQ,EAAY,MAAM,MAAM,CAAC;AACzC,OAAO,IAAI,MAAM,kBAAkB,CAAA;AACnC,OAAO,EAAC,YAAY,EAAC,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAC,mBAAmB,EAAE,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AAGjG;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,KAAK,CAAC,SAAmB;IAM/D,YAAY,KAAoB;QAC5B,KAAK,CAAC,KAAK,CAAC,CAAC;QAJjB,oDAAoD;QACpD,cAAS,GAAY,KAAK,CAAC;QAIvB,IAAI,CAAC,KAAK,GAAG;YACT,QAAQ,EAAE,EAAE;YACZ,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,KAAK;YACpB,WAAW,EAAE,KAAK;SACrB,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CA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ACD,CACJ,CACC,CACd,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from 'react';\r\nimport {\r\n CheckOutlined,\r\n ColumnWidthOutlined,\r\n ControlOutlined,\r\n EyeInvisibleOutlined,\r\n PushpinOutlined\r\n} from \"@ant-design/icons\";\r\nimport {Dropdown, MenuProps} from \"antd\";\r\nimport i18n from \"d2core/i18n/i18n\"\r\nimport {UndoMenuIcon} from \"d2coreui/components/icons/undoIcon\";\r\nimport {MenuElement} from \"../dataGrid\";\r\nimport {calculateLineHeight, GRID_DEFAULT_ROW_HEIGHT_DELTA} from \"../config/rowHeightCalculator\";\r\nimport {Column} from \"ag-grid-community\";\r\n\r\n/**\r\n * ag-grid header component registered by `DataGrid` as `simpleHeader` and used for all adapted columns.\r\n * Shows the header name with filter, sort and multi-sort order indicators; clicking sorts the column (Shift, or Ctrl\r\n * with `multiSortKey: 'ctrl'`, for multi-sort). A menu button (visible on hover) and right click open the column menu:\r\n * pin left/right, autosize column, hide column, autosize all columns, reset columns and columns configuration.\r\n * Expects ag-grid header params plus `onColumnsConfigVisible(visible)` in `headerComponentParams` and `fontSize`\r\n * in the grid `context`.\r\n */\r\nexport default class SimpleHeader extends React.Component<any, any> {\r\n /** Time (ms) of the last column `movingChanged` event, used to ignore clicks caused by dragging. */\r\n lastMovingChanged: number;\r\n /** Set on unmount to ignore late ag-grid events. */\r\n unmounted: boolean = false;\r\n\r\n constructor(props: Readonly<any>) {\r\n super(props);\r\n this.state = {\r\n sortMode: \"\",\r\n sortOrderIndex: null,\r\n filterPresent: false,\r\n menuVisible: false\r\n };\r\n this.lastMovingChanged = 0;\r\n this.onHeaderClick = this.onHeaderClick.bind(this);\r\n this.onMovingChanged = this.onMovingChanged.bind(this);\r\n this.onFilterChanged = this.onFilterChanged.bind(this);\r\n this.onSortChanged = this.onSortChanged.bind(this);\r\n this.onMultiSortChanged = this.onMultiSortChanged.bind(this);\r\n this.onMenuSelect = this.onMenuSelect.bind(this);\r\n props.column.addEventListener('movingChanged', this.onMovingChanged);\r\n props.column.addEventListener('filterChanged', this.onFilterChanged);\r\n props.column.addEventListener('sortChanged', this.onSortChanged);\r\n props.api.addEventListener('sortChanged', this.onMultiSortChanged);\r\n }\r\n\r\n componentDidMount() {\r\n this.onFilterChanged();\r\n this.onSortChanged();\r\n }\r\n\r\n componentWillUnmount() {\r\n this.props.column.removeEventListener(this.onMovingChanged);\r\n this.props.column.removeEventListener(this.onFilterChanged);\r\n this.props.column.removeEventListener(this.onSortChanged);\r\n this.unmounted = true;\r\n }\r\n\r\n /** Header click handler: progresses the column sort (multi-sort with Shift, or Ctrl/Cmd when `multiSortKey` is `ctrl`); ignored right after a column drag or on the menu button. */\r\n onHeaderClick(event: React.MouseEvent<HTMLDivElement>) {\r\n const target = event.target as HTMLElement;\r\n if (target && target.className && target.className.indexOf(\"menu\") >= 0) {\r\n // now clicking on menu button, ignore sorting operation\r\n return;\r\n }\r\n // sometimes when moving a column via dragging, this was also firing a clicked event.\r\n // this check stops sort if a) column is moving or b) column moved less than 200ms ago (so caters for race condition)\r\n const moving = this.props.column.isMoving();\r\n const nowTime = new Date().getTime();\r\n // typically there is <2ms if moving flag was set recently, as it would be done in same VM turn\r\n const movedRecently = (nowTime - this.lastMovingChanged) < 50;\r\n const columnMoving = moving || movedRecently;\r\n\r\n if (!columnMoving && this.props.column.colDef.sortable) {\r\n const sortUsingCtrl = this.props.api.getGridOption('multiSortKey') === 'ctrl';\r\n const multiSort = sortUsingCtrl ? (event.ctrlKey || event.metaKey) : event.shiftKey;\r\n this.props.progressSort(multiSort);\r\n }\r\n }\r\n\r\n /** Records the time of the column `movingChanged` event. */\r\n onMovingChanged() {\r\n this.lastMovingChanged = new Date().getTime();\r\n }\r\n\r\n /** Updates the filter indicator from the column's active filter. */\r\n onFilterChanged() {\r\n const filterPresent = this.props.column.isFilterActive();\r\n if (!this.unmounted) {\r\n this.setState({filterPresent: filterPresent});\r\n }\r\n }\r\n\r\n /** Updates the ascending/descending indicator from the column's sort. */\r\n onSortChanged() {\r\n let sortMode = \"\";\r\n if (this.props.column.isSortAscending()) {\r\n sortMode = \"asc\";\r\n } else if (this.props.column.isSortDescending()) {\r\n sortMode = \"desc\";\r\n }\r\n if (!this.unmounted) {\r\n this.setState({\r\n sortMode: sortMode,\r\n });\r\n }\r\n }\r\n\r\n /** Updates the sort order number, shown only when more than one column is sorted. */\r\n onMultiSortChanged() {\r\n let showOrderIndex = null;\r\n const col = this.props.column;\r\n const allColumnsWithSorting = this.props.api.getColumns().filter((c:Column)=> !!c.getSort());\r\n\r\n const moreThanOneColSorting = allColumnsWithSorting.length > 1;\r\n const showIndex = col.isSorting() && moreThanOneColSorting;\r\n if (showIndex) {\r\n showOrderIndex = col.getSortIndex()!! + 1;\r\n }\r\n\r\n if (!this.unmounted) {\r\n this.setState({\r\n showOrderIndex: showOrderIndex\r\n });\r\n }\r\n }\r\n\r\n /** Executes a column menu command (`pinLeft`/`pinRight` toggle pinning, `autosizeColumn`, `hideColumn`, `autosizeAllColumns`, `resetColumns`, `columnsConfig`). */\r\n onMenuSelect(clickParam: any) {\r\n const {key} = clickParam;\r\n const pinned = this.props.column.pinned;\r\n if (key === \"pinLeft\") {\r\n if (pinned === \"left\") {\r\n this.props.api.setColumnsPinned([this.props.column], null);\r\n } else {\r\n this.props.api.setColumnsPinned([this.props.column], \"left\");\r\n }\r\n } else if (key === \"pinRight\") {\r\n if (pinned === \"right\") {\r\n this.props.api.setColumnsPinned([this.props.column], null);\r\n } else {\r\n this.props.api.setColumnsPinned([this.props.column], \"right\");\r\n }\r\n } else if (key === \"autosizeColumn\") {\r\n this.props.api.autoSizeColumns([this.props.column]);\r\n } else if (key === \"hideColumn\") {\r\n this.props.api.setColumnsVisible([this.props.column], false);\r\n } else if (key === \"autosizeAllColumns\") {\r\n this.props.api.autoSizeAllColumns();\r\n } else if (key === \"resetColumns\") {\r\n this.props.api.resetColumnState();\r\n } else if (key === \"columnsConfig\") {\r\n this.props.onColumnsConfigVisible(true);\r\n }\r\n this.setState({menuVisible: false});\r\n }\r\n\r\n /** Builds the column menu items; the pin items show a check mark for the current pinning. */\r\n getColumnMenu(): MenuProps {\r\n const pinned = this.props.column.pinned;\r\n const items: MenuElement[] = [\r\n {\r\n key: \"pin\",\r\n label: <span><PushpinOutlined/> {i18n(\"Pin Column\")}</span>,\r\n children: [\r\n {\r\n key: \"pinLeft\",\r\n icon: <CheckOutlined style={{visibility: pinned === \"left\" ? \"visible\" : \"hidden\"}}/>,\r\n label: i18n(\"Pin Left\"),\r\n },\r\n {\r\n key: \"pinRight\",\r\n icon: <CheckOutlined style={{visibility: pinned === \"right\" ? \"visible\" : \"hidden\"}}/>,\r\n label: i18n(\"Pin Right\"),\r\n },\r\n ]\r\n },\r\n {\r\n key: \"autosizeColumn\",\r\n icon: <ColumnWidthOutlined/>,\r\n label: i18n(\"Autosize Column\")\r\n },\r\n {\r\n key: \"hideColumn\",\r\n icon: <EyeInvisibleOutlined/>,\r\n label: i18n(\"Hide Column\"),\r\n },\r\n {\r\n key: \"divider-menu\",\r\n type: \"divider\",\r\n },\r\n {\r\n key: \"autosizeAllColumns\",\r\n icon: <ColumnWidthOutlined/>,\r\n label: i18n(\"Autosize All Columns\")\r\n },\r\n {\r\n key: \"resetColumns\",\r\n icon: <UndoMenuIcon/>,\r\n label: i18n(\"Reset Columns\")\r\n },\r\n {\r\n key: \"columnsConfig\",\r\n icon: <ControlOutlined/>,\r\n label: i18n(\"Columns Configuration\")\r\n },\r\n ];\r\n\r\n return {\r\n onClick: this.onMenuSelect,\r\n items: items,\r\n };\r\n }\r\n\r\n render() {\r\n const alwaysHideNoSort = !this.props.column.getColDef().unSortIcon && !this.props.api.getGridOption('unSortIcon');\r\n const sortAscClassName = !this.props.column.isSortAscending() ? \"ag-hidden\" : \"\",\r\n sortDescClassName = !this.props.column.isSortDescending() ? \"ag-hidden\" : \"\",\r\n sortNoneClassName = alwaysHideNoSort || !this.props.column.isSortNone() ? \"ag-hidden\" : \"\";\r\n let containerClassName = \"\";\r\n if (this.props.column.isSortAscending()) {\r\n containerClassName = 'ag-header-cell-sorted-asc';\r\n } else if (this.props.column.isSortDescending()) {\r\n containerClassName = 'ag-header-cell-sorted-desc';\r\n } else if (this.props.column.isSortNone()) {\r\n containerClassName = 'ag-header-cell-sorted-none';\r\n }\r\n const sortOrderIndexClassName = !this.state.showOrderIndex ? \"ag-hidden\" : \"\";\r\n const filterClassName = !this.state.filterPresent ? \"ag-hidden\" : \"\";\r\n const columnMenu = this.getColumnMenu();\r\n\r\n const textStyle = {\r\n fontSize: this.props.context.fontSize,\r\n lineHeight: calculateLineHeight(this.props.context.fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA + 2)\r\n };\r\n\r\n return (\r\n <Dropdown menu={columnMenu} trigger={[\"contextMenu\"]} placement=\"bottom\">\r\n <div className={\"ag-cell-label-container \" + containerClassName} role=\"presentation\"\r\n onClick={this.onHeaderClick}\r\n onMouseOver={() => {\r\n this.setState({menuVisible: true});\r\n }}\r\n onMouseOut={() => {\r\n this.setState({menuVisible: false});\r\n }}>\r\n <Dropdown menu={columnMenu} trigger={[\"click\"]} placement=\"bottom\">\r\n <span ref=\"eMenu\" className=\"ag-header-icon ag-header-cell-menu-button\"\r\n style={{\r\n opacity: this.state.menuVisible ? 1 : 0,\r\n transition: \"opacity 0.2s, border 0.2s\",\r\n cursor: this.state.menuVisible ? \"pointer\" : undefined\r\n }}>\r\n <span className=\"ag-icon ag-icon-menu\" unselectable=\"on\"/>\r\n </span>\r\n </Dropdown>\r\n <div className=\"ag-header-cell-label\" role=\"presentation\" unselectable=\"on\"\r\n style={textStyle}>\r\n <span className=\"ag-header-cell-text\" role=\"columnheader\" unselectable=\"on\">\r\n {this.props.displayName}\r\n </span>\r\n <span className={\"ag-header-icon ag-filter-icon \" + filterClassName}>\r\n <span className=\"ag-icon ag-icon-filter\" unselectable=\"on\"/>\r\n </span>\r\n <span className={\"ag-header-icon ag-sort-ascending-icon \" + sortAscClassName}>\r\n <span className=\"ag-icon ag-icon-asc\" unselectable=\"on\"/>\r\n </span>\r\n <span className={\"ag-header-icon ag-sort-descending-icon \" + sortDescClassName}>\r\n <span className=\"ag-icon ag-icon-desc\" unselectable=\"on\"/>\r\n </span>\r\n <span className={\"ag-header-icon ag-sort-none-icon \" + sortNoneClassName}>\r\n <span className=\"ag-icon ag-icon-none\" unselectable=\"on\"/>\r\n </span>\r\n <span className={\"ag-header-icon ag-sort-order \" + sortOrderIndexClassName}>\r\n {this.state.showOrderIndex}\r\n </span>\r\n </div>\r\n </div>\r\n </Dropdown>\r\n );\r\n }\r\n}"]}
1
+ {"version":3,"file":"simpleHeader.js","sourceRoot":"","sources":["../../../../../components/grid/header/simpleHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACH,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,QAAQ,EAAY,MAAM,MAAM,CAAC;AACzC,OAAO,IAAI,MAAM,kBAAkB,CAAA;AACnC,OAAO,EAAC,YAAY,EAAC,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAC,mBAAmB,EAAE,6BAA6B,EAAC,MAAM,+BAA+B,CAAC;AAGjG;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,KAAK,CAAC,SAAmB;IAM/D,YAAY,KAAoB;QAC5B,KAAK,CAAC,KAAK,CAAC,CAAC;QAJjB,oDAAoD;QACpD,cAAS,GAAY,KAAK,CAAC;QAIvB,IAAI,CAAC,KAAK,GAAG;YACT,QAAQ,EAAE,EAAE;YACZ,cAAc,EAAE,IAAI;YACpB,aAAa,EAAE,KAAK;YACpB,WAAW,EAAE,KAAK;SACrB,CAAC;QACF,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAA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D;oBACH,8BAAM,SAAS,EAAE,wCAAwC,GAAG,gBAAgB;wBAC5E,8BAAM,SAAS,EAAC,qBAAqB,EAAC,YAAY,EAAC,IAAI,GAAE,CACtD;oBACH,8BAAM,SAAS,EAAE,yCAAyC,GAAG,iBAAiB;wBAC9E,8BAAM,SAAS,EAAC,sBAAsB,EAAC,YAAY,EAAC,IAAI,GAAE,CACvD;oBACH,8BAAM,SAAS,EAAE,mCAAmC,GAAG,iBAAiB;wBACxE,8BAAM,SAAS,EAAC,sBAAsB,EAAC,YAAY,EAAC,IAAI,GAAE,CACvD;oBACH,8BAAM,SAAS,EAAE,+BAA+B,GAAG,uBAAuB,IACzE,IAAI,CAAC,KAAK,CAAC,cAAc,CACvB,CACD,CACJ,CACC,CACd,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from 'react';\r\nimport {\r\n CheckOutlined,\r\n ColumnWidthOutlined,\r\n ControlOutlined,\r\n EyeInvisibleOutlined,\r\n PushpinOutlined\r\n} from \"@ant-design/icons\";\r\nimport {Dropdown, MenuProps} from \"antd\";\r\nimport i18n from \"d2core/i18n/i18n\"\r\nimport {UndoMenuIcon} from \"d2coreui/components/icons/undoIcon\";\r\nimport {MenuElement} from \"../dataGrid\";\r\nimport {calculateLineHeight, GRID_DEFAULT_ROW_HEIGHT_DELTA} from \"../config/rowHeightCalculator\";\r\nimport {Column} from \"ag-grid-community\";\r\n\r\n/**\r\n * ag-grid header component registered by `DataGrid` as `simpleHeader` and used for all adapted columns.\r\n * Shows the header name with filter, sort and multi-sort order indicators; clicking sorts the column (Shift, or Ctrl\r\n * with `multiSortKey: 'ctrl'`, for multi-sort). A menu button (visible on hover) and right click open the column menu:\r\n * pin left/right, autosize column, hide column, autosize all columns, reset columns and columns configuration.\r\n * Expects ag-grid header params plus `onColumnsConfigVisible(visible)` in `headerComponentParams` and `fontSize`\r\n * in the grid `context`.\r\n */\r\nexport default class SimpleHeader extends React.Component<any, any> {\r\n /** Time (ms) of the last column `movingChanged` event, used to ignore clicks caused by dragging. */\r\n lastMovingChanged: number;\r\n /** Set on unmount to ignore late ag-grid events. */\r\n unmounted: boolean = false;\r\n\r\n constructor(props: Readonly<any>) {\r\n super(props);\r\n this.state = {\r\n sortMode: \"\",\r\n sortOrderIndex: null,\r\n filterPresent: false,\r\n menuVisible: false\r\n };\r\n this.lastMovingChanged = 0;\r\n this.onHeaderClick = this.onHeaderClick.bind(this);\r\n this.onMovingChanged = this.onMovingChanged.bind(this);\r\n this.onFilterChanged = this.onFilterChanged.bind(this);\r\n this.onSortChanged = this.onSortChanged.bind(this);\r\n this.onMultiSortChanged = this.onMultiSortChanged.bind(this);\r\n this.onMenuSelect = this.onMenuSelect.bind(this);\r\n props.column.addEventListener('movingChanged', this.onMovingChanged);\r\n props.column.addEventListener('filterChanged', this.onFilterChanged);\r\n props.column.addEventListener('sortChanged', this.onSortChanged);\r\n props.api.addEventListener('sortChanged', this.onMultiSortChanged);\r\n }\r\n\r\n componentDidMount() {\r\n this.onFilterChanged();\r\n this.onSortChanged();\r\n }\r\n\r\n componentWillUnmount() {\r\n this.props.column.removeEventListener(this.onMovingChanged);\r\n this.props.column.removeEventListener(this.onFilterChanged);\r\n this.props.column.removeEventListener(this.onSortChanged);\r\n this.unmounted = true;\r\n }\r\n\r\n /** Header click handler: progresses the column sort (multi-sort with Shift, or Ctrl/Cmd when `multiSortKey` is `ctrl`); ignored right after a column drag or on the menu button. */\r\n onHeaderClick(event: React.MouseEvent<HTMLDivElement>) {\r\n const target = event.target as HTMLElement;\r\n if (target && target.className && target.className.indexOf(\"menu\") >= 0) {\r\n // now clicking on menu button, ignore sorting operation\r\n return;\r\n }\r\n // sometimes when moving a column via dragging, this was also firing a clicked event.\r\n // this check stops sort if a) column is moving or b) column moved less than 200ms ago (so caters for race condition)\r\n const moving = this.props.column.isMoving();\r\n const nowTime = new Date().getTime();\r\n // typically there is <2ms if moving flag was set recently, as it would be done in same VM turn\r\n const movedRecently = (nowTime - this.lastMovingChanged) < 50;\r\n const columnMoving = moving || movedRecently;\r\n\r\n if (!columnMoving && this.props.column.colDef.sortable) {\r\n const sortUsingCtrl = this.props.api.getGridOption('multiSortKey') === 'ctrl';\r\n const multiSort = sortUsingCtrl ? (event.ctrlKey || event.metaKey) : event.shiftKey;\r\n this.props.progressSort(multiSort);\r\n }\r\n }\r\n\r\n /** Records the time of the column `movingChanged` event. */\r\n onMovingChanged() {\r\n this.lastMovingChanged = new Date().getTime();\r\n }\r\n\r\n /** Updates the filter indicator from the column's active filter. */\r\n onFilterChanged() {\r\n const filterPresent = this.props.column.isFilterActive();\r\n if (!this.unmounted) {\r\n this.setState({filterPresent: filterPresent});\r\n }\r\n }\r\n\r\n /** Updates the ascending/descending indicator from the column's sort. */\r\n onSortChanged() {\r\n let sortMode = \"\";\r\n if (this.props.column.isSortAscending()) {\r\n sortMode = \"asc\";\r\n } else if (this.props.column.isSortDescending()) {\r\n sortMode = \"desc\";\r\n }\r\n if (!this.unmounted) {\r\n this.setState({\r\n sortMode: sortMode,\r\n });\r\n }\r\n }\r\n\r\n /** Updates the sort order number, shown only when more than one column is sorted. */\r\n onMultiSortChanged() {\r\n let showOrderIndex = null;\r\n const col = this.props.column;\r\n const allColumnsWithSorting = this.props.api.getColumns().filter((c:Column)=> !!c.getSort());\r\n\r\n const moreThanOneColSorting = allColumnsWithSorting.length > 1;\r\n const showIndex = col.isSorting() && moreThanOneColSorting;\r\n if (showIndex) {\r\n showOrderIndex = col.getSortIndex()!! + 1;\r\n }\r\n\r\n if (!this.unmounted) {\r\n this.setState({\r\n showOrderIndex: showOrderIndex\r\n });\r\n }\r\n }\r\n\r\n /** Executes a column menu command (`pinLeft`/`pinRight` toggle pinning, `autosizeColumn`, `hideColumn` (ignored for a column with `lockVisible`), `autosizeAllColumns`, `resetColumns`, `columnsConfig`). */\r\n onMenuSelect(clickParam: any) {\r\n const {key} = clickParam;\r\n const pinned = this.props.column.pinned;\r\n if (key === \"pinLeft\") {\r\n if (pinned === \"left\") {\r\n this.props.api.setColumnsPinned([this.props.column], null);\r\n } else {\r\n this.props.api.setColumnsPinned([this.props.column], \"left\");\r\n }\r\n } else if (key === \"pinRight\") {\r\n if (pinned === \"right\") {\r\n this.props.api.setColumnsPinned([this.props.column], null);\r\n } else {\r\n this.props.api.setColumnsPinned([this.props.column], \"right\");\r\n }\r\n } else if (key === \"autosizeColumn\") {\r\n this.props.api.autoSizeColumns([this.props.column]);\r\n } else if (key === \"hideColumn\" && !this.props.column.getColDef().lockVisible) {\r\n this.props.api.setColumnsVisible([this.props.column], false);\r\n } else if (key === \"autosizeAllColumns\") {\r\n this.props.api.autoSizeAllColumns();\r\n } else if (key === \"resetColumns\") {\r\n this.props.api.resetColumnState();\r\n } else if (key === \"columnsConfig\") {\r\n this.props.onColumnsConfigVisible(true);\r\n }\r\n this.setState({menuVisible: false});\r\n }\r\n\r\n /** Builds the column menu items; the pin items show a check mark for the current pinning. */\r\n getColumnMenu(): MenuProps {\r\n const pinned = this.props.column.pinned;\r\n const items: MenuElement[] = [\r\n {\r\n key: \"pin\",\r\n label: <span><PushpinOutlined/> {i18n(\"Pin Column\")}</span>,\r\n children: [\r\n {\r\n key: \"pinLeft\",\r\n icon: <CheckOutlined style={{visibility: pinned === \"left\" ? \"visible\" : \"hidden\"}}/>,\r\n label: i18n(\"Pin Left\"),\r\n },\r\n {\r\n key: \"pinRight\",\r\n icon: <CheckOutlined style={{visibility: pinned === \"right\" ? \"visible\" : \"hidden\"}}/>,\r\n label: i18n(\"Pin Right\"),\r\n },\r\n ]\r\n },\r\n {\r\n key: \"autosizeColumn\",\r\n icon: <ColumnWidthOutlined/>,\r\n label: i18n(\"Autosize Column\")\r\n },\r\n {\r\n key: \"hideColumn\",\r\n icon: <EyeInvisibleOutlined/>,\r\n label: i18n(\"Hide Column\"),\r\n disabled: !!this.props.column.getColDef().lockVisible,\r\n },\r\n {\r\n key: \"divider-menu\",\r\n type: \"divider\",\r\n },\r\n {\r\n key: \"autosizeAllColumns\",\r\n icon: <ColumnWidthOutlined/>,\r\n label: i18n(\"Autosize All Columns\")\r\n },\r\n {\r\n key: \"resetColumns\",\r\n icon: <UndoMenuIcon/>,\r\n label: i18n(\"Reset Columns\")\r\n },\r\n {\r\n key: \"columnsConfig\",\r\n icon: <ControlOutlined/>,\r\n label: i18n(\"Columns Configuration\")\r\n },\r\n ];\r\n\r\n return {\r\n onClick: this.onMenuSelect,\r\n items: items,\r\n };\r\n }\r\n\r\n render() {\r\n const alwaysHideNoSort = !this.props.column.getColDef().unSortIcon && !this.props.api.getGridOption('unSortIcon');\r\n const sortAscClassName = !this.props.column.isSortAscending() ? \"ag-hidden\" : \"\",\r\n sortDescClassName = !this.props.column.isSortDescending() ? \"ag-hidden\" : \"\",\r\n sortNoneClassName = alwaysHideNoSort || !this.props.column.isSortNone() ? \"ag-hidden\" : \"\";\r\n let containerClassName = \"\";\r\n if (this.props.column.isSortAscending()) {\r\n containerClassName = 'ag-header-cell-sorted-asc';\r\n } else if (this.props.column.isSortDescending()) {\r\n containerClassName = 'ag-header-cell-sorted-desc';\r\n } else if (this.props.column.isSortNone()) {\r\n containerClassName = 'ag-header-cell-sorted-none';\r\n }\r\n const sortOrderIndexClassName = !this.state.showOrderIndex ? \"ag-hidden\" : \"\";\r\n const filterClassName = !this.state.filterPresent ? \"ag-hidden\" : \"\";\r\n const columnMenu = this.getColumnMenu();\r\n\r\n const textStyle = {\r\n fontSize: this.props.context.fontSize,\r\n lineHeight: calculateLineHeight(this.props.context.fontSize, GRID_DEFAULT_ROW_HEIGHT_DELTA + 2)\r\n };\r\n\r\n return (\r\n <Dropdown menu={columnMenu} trigger={[\"contextMenu\"]} placement=\"bottom\">\r\n <div className={\"ag-cell-label-container \" + containerClassName} role=\"presentation\"\r\n onClick={this.onHeaderClick}\r\n onMouseOver={() => {\r\n this.setState({menuVisible: true});\r\n }}\r\n onMouseOut={() => {\r\n this.setState({menuVisible: false});\r\n }}>\r\n <Dropdown menu={columnMenu} trigger={[\"click\"]} placement=\"bottom\">\r\n <span ref=\"eMenu\" className=\"ag-header-icon ag-header-cell-menu-button\"\r\n style={{\r\n opacity: this.state.menuVisible ? 1 : 0,\r\n transition: \"opacity 0.2s, border 0.2s\",\r\n cursor: this.state.menuVisible ? \"pointer\" : undefined\r\n }}>\r\n <span className=\"ag-icon ag-icon-menu\" unselectable=\"on\"/>\r\n </span>\r\n </Dropdown>\r\n <div className=\"ag-header-cell-label\" role=\"presentation\" unselectable=\"on\"\r\n style={textStyle}>\r\n <span className=\"ag-header-cell-text\" role=\"columnheader\" unselectable=\"on\">\r\n {this.props.displayName}\r\n </span>\r\n <span className={\"ag-header-icon ag-filter-icon \" + filterClassName}>\r\n <span className=\"ag-icon ag-icon-filter\" unselectable=\"on\"/>\r\n </span>\r\n <span className={\"ag-header-icon ag-sort-ascending-icon \" + sortAscClassName}>\r\n <span className=\"ag-icon ag-icon-asc\" unselectable=\"on\"/>\r\n </span>\r\n <span className={\"ag-header-icon ag-sort-descending-icon \" + sortDescClassName}>\r\n <span className=\"ag-icon ag-icon-desc\" unselectable=\"on\"/>\r\n </span>\r\n <span className={\"ag-header-icon ag-sort-none-icon \" + sortNoneClassName}>\r\n <span className=\"ag-icon ag-icon-none\" unselectable=\"on\"/>\r\n </span>\r\n <span className={\"ag-header-icon ag-sort-order \" + sortOrderIndexClassName}>\r\n {this.state.showOrderIndex}\r\n </span>\r\n </div>\r\n </div>\r\n </Dropdown>\r\n );\r\n }\r\n}"]}
@@ -8,6 +8,8 @@ interface DataGridPaginationProps {
8
8
  pageSize: number;
9
9
  /** Total number of rows. */
10
10
  total: number;
11
+ /** Leaves out the row range and the first / last page buttons, so that the pager fits a narrow (mobile) toolbar. */
12
+ compact?: boolean;
11
13
  /** Called with the 1-based number of the page to show. */
12
14
  onGoToPage(page: number): void;
13
15
  }
@@ -17,7 +19,8 @@ interface DataGridPaginationState {
17
19
  /**
18
20
  * Compact pager used in the `DataGrid` toolbar: the "first-last of total" row range followed by first/previous
19
21
  * buttons, a "page / pages" button (hover or click opens a go-to-page input) and next/last buttons. Stateless apart
20
- * from the go-to-page input; the parent changes `current` in response to `onGoToPage`.
22
+ * from the go-to-page input; the parent changes `current` in response to `onGoToPage`. With `compact` only the
23
+ * previous, "page / pages" (as wide as its text) and next buttons are shown.
21
24
  */
22
25
  export default class DataGridPagination extends React.Component<DataGridPaginationProps, DataGridPaginationState> {
23
26
  constructor(props: Readonly<DataGridPaginationProps>);
@@ -4,18 +4,23 @@ import i18n from "d2core/i18n/i18n";
4
4
  import { CaretLeftOutlined, CaretRightOutlined, CheckOutlined, StepBackwardOutlined, StepForwardOutlined } from "@ant-design/icons";
5
5
  import { createStyles } from "antd-style";
6
6
  import WithCss from "d2coreui/components/style/withCss";
7
- const useStyles = createStyles(({ css }) => {
7
+ const useStyles = createStyles(({ css, token }, props) => {
8
+ var _a;
9
+ const controlHeight = { small: token.controlHeightSM, middle: token.controlHeight, large: token.controlHeightLG }[(_a = props === null || props === void 0 ? void 0 : props.size) !== null && _a !== void 0 ? _a : "middle"];
8
10
  return {
11
+ // as high as the pager buttons, so that the text is in their middle also in a toolbar aligned to the top
9
12
  paginationStyle: css `
10
13
  margin: 0 12px;
11
14
  white-space: nowrap;
15
+ line-height: ${controlHeight}px;
12
16
  `
13
17
  };
14
18
  });
15
19
  /**
16
20
  * Compact pager used in the `DataGrid` toolbar: the "first-last of total" row range followed by first/previous
17
21
  * buttons, a "page / pages" button (hover or click opens a go-to-page input) and next/last buttons. Stateless apart
18
- * from the go-to-page input; the parent changes `current` in response to `onGoToPage`.
22
+ * from the go-to-page input; the parent changes `current` in response to `onGoToPage`. With `compact` only the
23
+ * previous, "page / pages" (as wide as its text) and next buttons are shown.
19
24
  */
20
25
  export default class DataGridPagination extends React.Component {
21
26
  constructor(props) {
@@ -23,14 +28,14 @@ export default class DataGridPagination extends React.Component {
23
28
  this.state = {};
24
29
  }
25
30
  render() {
26
- const { disabled, total, pageSize, current } = this.props;
31
+ const { disabled, total, pageSize, current, compact } = this.props;
27
32
  const rangeStart = total === 0 ? 0 : (current - 1) * pageSize + 1;
28
33
  const rangeEnd = current * pageSize > total ? total : current * pageSize;
29
34
  const totalPages = Math.ceil(total / pageSize);
30
35
  return (React.createElement(WithCss, { useStyles: useStyles }, (css) => (React.createElement(React.Fragment, null,
31
- React.createElement("li", { className: css.styles.paginationStyle, style: { color: disabled ? css.theme.colorTextDisabled : undefined } }, `${rangeStart}-${rangeEnd} ${i18n('of')} ${total}`),
32
- React.createElement(Button.Group, null,
33
- React.createElement(Button, { title: i18n("First Page"), disabled: disabled || current === 1, icon: React.createElement(StepBackwardOutlined, null), onClick: () => {
36
+ !compact && React.createElement("li", { className: css.styles.paginationStyle, style: { color: disabled ? css.theme.colorTextDisabled : undefined } }, `${rangeStart}-${rangeEnd} ${i18n('of')} ${total}`),
37
+ React.createElement(Button.Group, { style: compact ? { marginLeft: "auto" } : undefined },
38
+ !compact && React.createElement(Button, { title: i18n("First Page"), disabled: disabled || current === 1, icon: React.createElement(StepBackwardOutlined, null), onClick: () => {
34
39
  this.props.onGoToPage(1);
35
40
  } }),
36
41
  React.createElement(Button, { title: i18n("Previous Page"), disabled: disabled || current === 1, icon: React.createElement(CaretLeftOutlined, null), onClick: () => {
@@ -54,7 +59,7 @@ export default class DataGridPagination extends React.Component {
54
59
  }
55
60
  } },
56
61
  React.createElement(CheckOutlined, null))) },
57
- React.createElement(Button, { disabled: disabled, style: { width: 80, paddingLeft: 0, paddingRight: 0 } },
62
+ React.createElement(Button, { disabled: disabled, style: compact ? { paddingLeft: 8, paddingRight: 8 } : { width: 80, paddingLeft: 0, paddingRight: 0 } },
58
63
  React.createElement("span", { style: {
59
64
  display: "inline-block",
60
65
  width: "100%",
@@ -66,7 +71,7 @@ export default class DataGridPagination extends React.Component {
66
71
  React.createElement(Button, { title: i18n("Next Page"), disabled: disabled || current === totalPages || total === 0, icon: React.createElement(CaretRightOutlined, null), onClick: () => {
67
72
  this.props.onGoToPage(current + 1);
68
73
  } }),
69
- React.createElement(Button, { title: i18n("Last Page"), disabled: disabled || current === totalPages || total === 0, icon: React.createElement(StepForwardOutlined, null), onClick: () => {
74
+ !compact && React.createElement(Button, { title: i18n("Last Page"), disabled: disabled || current === totalPages || total === 0, icon: React.createElement(StepForwardOutlined, null), onClick: () => {
70
75
  this.props.onGoToPage(totalPages);
71
76
  } }))))));
72
77
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dataGridPagination.js","sourceRoot":"","sources":["../../../../../components/grid/panel/dataGridPagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AACzD,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EACH,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,OAAO,MAAM,mCAAmC,CAAC;AAExD,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,EAAC,GAAG,EAAC,EAAE,EAAE;IACrC,OAAO;QACH,eAAe,EAAE,GAAG,CAAA;;;SAGnB;KACJ,CAAA;AACL,CAAC,CAAC,CAAC;AAoBH;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,KAAK,CAAC,SAA2D;IAC7G,YAAY,KAAwC;QAChD,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;IACnB,CAAC;IAED,MAAM;QACF,MAAM,EAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACxD,MAAM,UAAU,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,GAAG,C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AQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAC,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAC;wBAC3E,8BAAM,KAAK,EAAE;gCACT,OAAO,EAAE,cAAc;gCACvB,KAAK,EAAE,MAAM;gCACb,SAAS,EAAE,QAAQ;6BACtB;4BAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;;4BAAK,UAAU,CAAQ,CAC/C,CACH;gBACV,oBAAC,MAAM,IACH,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,EACxB,QAAQ,EAAE,QAAQ,IAAI,OAAO,KAAK,UAAU,IAAI,KAAK,KAAK,CAAC,EAC3D,IAAI,EAAE,oBAAC,kBAAkB,OAAE,EAC3B,OAAO,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;oBACvC,CAAC,GACH;gBACF,oBAAC,MAAM,IACH,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,EACxB,QAAQ,EAAE,QAAQ,IAAI,OAAO,KAAK,UAAU,IAAI,KAAK,KAAK,CAAC,EAC3D,IAAI,EAAE,oBAAC,mBAAmB,OAAE,EAC5B,OAAO,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;oBACtC,CAAC,GACH,CACS,CAChB,CACN,CACS,CACb,CAAC;IACN,CAAC;CAEJ","sourcesContent":["import React from \"react\";\r\nimport {Button, InputNumber, Popover, Space} from \"antd\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {\r\n CaretLeftOutlined,\r\n CaretRightOutlined,\r\n CheckOutlined,\r\n StepBackwardOutlined,\r\n StepForwardOutlined\r\n} from \"@ant-design/icons\";\r\nimport {createStyles} from \"antd-style\";\r\nimport WithCss from \"d2coreui/components/style/withCss\";\r\n\r\nconst useStyles = createStyles(({css}) => {\r\n return {\r\n paginationStyle: css`\r\n margin: 0 12px;\r\n white-space: nowrap;\r\n `\r\n }\r\n});\r\n\r\ninterface DataGridPaginationProps {\r\n /** Disables all pager controls. */\r\n disabled?: boolean\r\n /** Current page number, 1-based. */\r\n current: number\r\n /** Number of rows per page. */\r\n pageSize: number\r\n /** Total number of rows. */\r\n total: number\r\n\r\n /** Called with the 1-based number of the page to show. */\r\n onGoToPage(page: number): void\r\n}\r\n\r\ninterface DataGridPaginationState {\r\n gotoPageNumber?: number\r\n}\r\n\r\n/**\r\n * Compact pager used in the `DataGrid` toolbar: the \"first-last of total\" row range followed by first/previous\r\n * buttons, a \"page / pages\" button (hover or click opens a go-to-page input) and next/last buttons. Stateless apart\r\n * from the go-to-page input; the parent changes `current` in response to `onGoToPage`.\r\n */\r\nexport default class DataGridPagination extends React.Component<DataGridPaginationProps, DataGridPaginationState> {\r\n constructor(props: Readonly<DataGridPaginationProps>) {\r\n super(props);\r\n\r\n this.state = {}\r\n }\r\n\r\n render() {\r\n const {disabled, total, pageSize, current} = this.props;\r\n const rangeStart = total === 0 ? 0 : (current - 1) * pageSize + 1;\r\n const rangeEnd = current * pageSize > total ? total : current * pageSize;\r\n const totalPages = Math.ceil(total / pageSize);\r\n return (\r\n <WithCss useStyles={useStyles}>{(css) => (\r\n <>\r\n <li className={css.styles.paginationStyle} style={{color: disabled ? css.theme.colorTextDisabled : undefined}}>\r\n {`${rangeStart}-${rangeEnd} ${i18n('of')} ${total}`}\r\n </li>\r\n <Button.Group>\r\n <Button\r\n title={i18n(\"First Page\")}\r\n disabled={disabled || current === 1}\r\n icon={<StepBackwardOutlined/>}\r\n onClick={() => {\r\n this.props.onGoToPage(1);\r\n }}\r\n />\r\n <Button\r\n title={i18n(\"Previous Page\")}\r\n disabled={disabled || current === 1}\r\n icon={<CaretLeftOutlined/>}\r\n onClick={() => {\r\n this.props.onGoToPage(current - 1);\r\n }}\r\n />\r\n <Popover\r\n placement=\"bottom\"\r\n trigger={disabled || totalPages <= 1 ? [] : [\"hover\", \"click\"]}\r\n content={\r\n <Space.Compact>\r\n <InputNumber\r\n disabled={disabled || total === 0}\r\n min={1} max={totalPages}\r\n value={this.state.gotoPageNumber ? this.state.gotoPageNumber : this.props.current}\r\n onChange={(newValue) => {\r\n if (typeof newValue === \"number\") {\r\n this.setState({gotoPageNumber: newValue});\r\n }\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.code === \"Enter\") {\r\n if (this.state.gotoPageNumber) {\r\n this.props.onGoToPage(this.state.gotoPageNumber);\r\n }\r\n }\r\n }}\r\n />\r\n <Button\r\n title={i18n(\"Goto Page\")}\r\n type=\"primary\"\r\n onClick={() => {\r\n if (this.state.gotoPageNumber) {\r\n this.props.onGoToPage(this.state.gotoPageNumber);\r\n }\r\n }}\r\n >\r\n <CheckOutlined/>\r\n </Button>\r\n </Space.Compact>\r\n }>\r\n <Button disabled={disabled} style={{width: 80, paddingLeft: 0, paddingRight: 0}}>\r\n <span style={{\r\n display: \"inline-block\",\r\n width: \"100%\",\r\n textAlign: \"center\",\r\n }}>{total === 0 ? 0 : current} / {totalPages}</span>\r\n </Button>\r\n </Popover>\r\n <Button\r\n title={i18n(\"Next Page\")}\r\n disabled={disabled || current === totalPages || total === 0}\r\n icon={<CaretRightOutlined/>}\r\n onClick={() => {\r\n this.props.onGoToPage(current + 1);\r\n }}\r\n />\r\n <Button\r\n title={i18n(\"Last Page\")}\r\n disabled={disabled || current === totalPages || total === 0}\r\n icon={<StepForwardOutlined/>}\r\n onClick={() => {\r\n this.props.onGoToPage(totalPages);\r\n }}\r\n />\r\n </Button.Group>\r\n </>\r\n )}\r\n </WithCss>\r\n );\r\n }\r\n\r\n}"]}
1
+ {"version":3,"file":"dataGridPagination.js","sourceRoot":"","sources":["../../../../../components/grid/panel/dataGridPagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,WAAW,EAAE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ACG;oBAGpB,oBAAC,MAAM,IAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAC,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAC,CAAC,CAAC,CAAC,EAAC,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAC;wBACzH,8BAAM,KAAK,EAAE;gCACT,OAAO,EAAE,cAAc;gCACvB,KAAK,EAAE,MAAM;gCACb,SAAS,EAAE,QAAQ;6BACtB;4BAAG,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;;4BAAK,UAAU,CAAQ,CAC/C,CACH;gBACV,oBAAC,MAAM,IACH,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,EACxB,QAAQ,EAAE,QAAQ,IAAI,OAAO,KAAK,UAAU,IAAI,KAAK,KAAK,CAAC,EAC3D,IAAI,EAAE,oBAAC,kBAAkB,OAAE,EAC3B,OAAO,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;oBACvC,CAAC,GACH;gBACD,CAAC,OAAO,IAAI,oBAAC,MAAM,IAChB,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,EACxB,QAAQ,EAAE,QAAQ,IAAI,OAAO,KAAK,UAAU,IAAI,KAAK,KAAK,CAAC,EAC3D,IAAI,EAAE,oBAAC,mBAAmB,OAAE,EAC5B,OAAO,EAAE,GAAG,EAAE;wBACV,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;oBACtC,CAAC,GACH,CACS,CAChB,CACN,CACS,CACb,CAAC;IACN,CAAC;CAEJ","sourcesContent":["import React from \"react\";\r\nimport {Button, InputNumber, Popover, Space} from \"antd\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {\r\n CaretLeftOutlined,\r\n CaretRightOutlined,\r\n CheckOutlined,\r\n StepBackwardOutlined,\r\n StepForwardOutlined\r\n} from \"@ant-design/icons\";\r\nimport {createStyles} from \"antd-style\";\r\nimport WithCss, {WithCssInjectedProps} from \"d2coreui/components/style/withCss\";\r\n\r\nconst useStyles = createStyles(({css, token}, props?: WithCssInjectedProps) => {\r\n const controlHeight = {small: token.controlHeightSM, middle: token.controlHeight, large: token.controlHeightLG}[props?.size ?? \"middle\"];\r\n\r\n return {\r\n // as high as the pager buttons, so that the text is in their middle also in a toolbar aligned to the top\r\n paginationStyle: css`\r\n margin: 0 12px;\r\n white-space: nowrap;\r\n line-height: ${controlHeight}px;\r\n `\r\n }\r\n});\r\n\r\ninterface DataGridPaginationProps {\r\n /** Disables all pager controls. */\r\n disabled?: boolean\r\n /** Current page number, 1-based. */\r\n current: number\r\n /** Number of rows per page. */\r\n pageSize: number\r\n /** Total number of rows. */\r\n total: number\r\n /** Leaves out the row range and the first / last page buttons, so that the pager fits a narrow (mobile) toolbar. */\r\n compact?: boolean\r\n\r\n /** Called with the 1-based number of the page to show. */\r\n onGoToPage(page: number): void\r\n}\r\n\r\ninterface DataGridPaginationState {\r\n gotoPageNumber?: number\r\n}\r\n\r\n/**\r\n * Compact pager used in the `DataGrid` toolbar: the \"first-last of total\" row range followed by first/previous\r\n * buttons, a \"page / pages\" button (hover or click opens a go-to-page input) and next/last buttons. Stateless apart\r\n * from the go-to-page input; the parent changes `current` in response to `onGoToPage`. With `compact` only the\r\n * previous, \"page / pages\" (as wide as its text) and next buttons are shown.\r\n */\r\nexport default class DataGridPagination extends React.Component<DataGridPaginationProps, DataGridPaginationState> {\r\n constructor(props: Readonly<DataGridPaginationProps>) {\r\n super(props);\r\n\r\n this.state = {}\r\n }\r\n\r\n render() {\r\n const {disabled, total, pageSize, current, compact} = this.props;\r\n const rangeStart = total === 0 ? 0 : (current - 1) * pageSize + 1;\r\n const rangeEnd = current * pageSize > total ? total : current * pageSize;\r\n const totalPages = Math.ceil(total / pageSize);\r\n return (\r\n <WithCss useStyles={useStyles}>{(css) => (\r\n <>\r\n {!compact && <li className={css.styles.paginationStyle} style={{color: disabled ? css.theme.colorTextDisabled : undefined}}>\r\n {`${rangeStart}-${rangeEnd} ${i18n('of')} ${total}`}\r\n </li>}\r\n {/* compact: the grid toolbar spaces it, and it stays on the right when it wraps under the toolbar */}\r\n <Button.Group style={compact ? {marginLeft: \"auto\"} : undefined}>\r\n {!compact && <Button\r\n title={i18n(\"First Page\")}\r\n disabled={disabled || current === 1}\r\n icon={<StepBackwardOutlined/>}\r\n onClick={() => {\r\n this.props.onGoToPage(1);\r\n }}\r\n />}\r\n <Button\r\n title={i18n(\"Previous Page\")}\r\n disabled={disabled || current === 1}\r\n icon={<CaretLeftOutlined/>}\r\n onClick={() => {\r\n this.props.onGoToPage(current - 1);\r\n }}\r\n />\r\n <Popover\r\n placement=\"bottom\"\r\n trigger={disabled || totalPages <= 1 ? [] : [\"hover\", \"click\"]}\r\n content={\r\n <Space.Compact>\r\n <InputNumber\r\n disabled={disabled || total === 0}\r\n min={1} max={totalPages}\r\n value={this.state.gotoPageNumber ? this.state.gotoPageNumber : this.props.current}\r\n onChange={(newValue) => {\r\n if (typeof newValue === \"number\") {\r\n this.setState({gotoPageNumber: newValue});\r\n }\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.code === \"Enter\") {\r\n if (this.state.gotoPageNumber) {\r\n this.props.onGoToPage(this.state.gotoPageNumber);\r\n }\r\n }\r\n }}\r\n />\r\n <Button\r\n title={i18n(\"Goto Page\")}\r\n type=\"primary\"\r\n onClick={() => {\r\n if (this.state.gotoPageNumber) {\r\n this.props.onGoToPage(this.state.gotoPageNumber);\r\n }\r\n }}\r\n >\r\n <CheckOutlined/>\r\n </Button>\r\n </Space.Compact>\r\n }>\r\n {/* compact: as wide as the text, so that the pager fits a phone toolbar */}\r\n <Button disabled={disabled} style={compact ? {paddingLeft: 8, paddingRight: 8} : {width: 80, paddingLeft: 0, paddingRight: 0}}>\r\n <span style={{\r\n display: \"inline-block\",\r\n width: \"100%\",\r\n textAlign: \"center\",\r\n }}>{total === 0 ? 0 : current} / {totalPages}</span>\r\n </Button>\r\n </Popover>\r\n <Button\r\n title={i18n(\"Next Page\")}\r\n disabled={disabled || current === totalPages || total === 0}\r\n icon={<CaretRightOutlined/>}\r\n onClick={() => {\r\n this.props.onGoToPage(current + 1);\r\n }}\r\n />\r\n {!compact && <Button\r\n title={i18n(\"Last Page\")}\r\n disabled={disabled || current === totalPages || total === 0}\r\n icon={<StepForwardOutlined/>}\r\n onClick={() => {\r\n this.props.onGoToPage(totalPages);\r\n }}\r\n />}\r\n </Button.Group>\r\n </>\r\n )}\r\n </WithCss>\r\n );\r\n }\r\n\r\n}"]}
@@ -37,6 +37,7 @@ interface InputSearchWithHistoryProps extends Omit<InputProps, "onChange" | "onS
37
37
  interface InputSearchWithHistoryState {
38
38
  opened: boolean;
39
39
  searchString: string;
40
+ menuMaxHeight?: number;
40
41
  }
41
42
  /**
42
43
  * Text input with a history dropdown. When `options` is non-empty, a down-arrow suffix (or the ArrowDown key)
@@ -51,12 +52,14 @@ export default class AutoCompleteInput extends React.Component<InputSearchWithHi
51
52
  };
52
53
  private inputRef;
53
54
  private menuRef;
55
+ private wrapperRef;
54
56
  constructor(props: Readonly<InputSearchWithHistoryProps>);
55
57
  componentDidUpdate(prevProps: Readonly<InputSearchWithHistoryProps>): void;
56
58
  /** Moves the keyboard focus to the text input. */
57
59
  focus(): void;
58
60
  private triggerChange;
59
61
  private toggleDropdown;
62
+ private getMenuMaxHeight;
60
63
  render(): React.JSX.Element;
61
64
  }
62
65
  export {};
@@ -13,6 +13,9 @@ import React from "react";
13
13
  import { Dropdown, Input, Menu } from "antd";
14
14
  import { DownOutlined } from "@ant-design/icons";
15
15
  import { Key } from "ts-key-enum";
16
+ // antd places the dropdown popup 4 px away from the input
17
+ const DROPDOWN_POPUP_OFFSET = 4;
18
+ const MENU_VIEWPORT_MARGIN = 8;
16
19
  /**
17
20
  * Text input with a history dropdown. When `options` is non-empty, a down-arrow suffix (or the ArrowDown key)
18
21
  * opens a menu of the entries; picking one sets the text and fires `onChange`, `onSearch` and `onSelect`.
@@ -32,6 +35,7 @@ export default class AutoCompleteInput extends React.Component {
32
35
  super(props);
33
36
  this.inputRef = React.createRef();
34
37
  this.menuRef = React.createRef();
38
+ this.wrapperRef = React.createRef();
35
39
  this.triggerChange = (value) => {
36
40
  this.setState({ searchString: value }, () => {
37
41
  this.props.onChange(value);
@@ -43,7 +47,7 @@ export default class AutoCompleteInput extends React.Component {
43
47
  if (this.props.disabled && !this.props.inputReadonly)
44
48
  return;
45
49
  const willOpen = !this.state.opened;
46
- this.setState({ opened: willOpen }, () => {
50
+ this.setState(Object.assign({ opened: willOpen }, (willOpen ? { menuMaxHeight: this.getMenuMaxHeight() } : {})), () => {
47
51
  if (willOpen) {
48
52
  setTimeout(() => {
49
53
  var _a;
@@ -67,10 +71,21 @@ export default class AutoCompleteInput extends React.Component {
67
71
  var _a;
68
72
  (_a = this.inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
69
73
  }
74
+ // The popup is rendered into document.body, so a menu taller than the free space makes the whole page scrollable.
75
+ // Taking the larger side lets antd's autoAdjustOverflow flip the popup above the input when that side is bigger.
76
+ getMenuMaxHeight() {
77
+ var _a;
78
+ const rect = (_a = this.wrapperRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
79
+ if (!rect)
80
+ return undefined;
81
+ const spaceBelow = window.innerHeight - rect.bottom;
82
+ const spaceAbove = rect.top;
83
+ return Math.max(spaceBelow, spaceAbove) - DROPDOWN_POPUP_OFFSET - MENU_VIEWPORT_MARGIN;
84
+ }
70
85
  render() {
71
86
  const _a = this.props, { disabled, inputReadonly, placeholder, prefix, onPressEnter, onSearch, onSelect, options, stringFormatter, style, value, onBlur, onKeyDown, onFocus } = _a, rest = __rest(_a, ["disabled", "inputReadonly", "placeholder", "prefix", "onPressEnter", "onSearch", "onSelect", "options", "stringFormatter", "style", "value", "onBlur", "onKeyDown", "onFocus"]);
72
87
  const hasHistory = options && options.length > 0;
73
- const historyMenu = (React.createElement(Menu, { ref: this.menuRef, onClick: ({ key }) => {
88
+ const historyMenu = (React.createElement(Menu, { ref: this.menuRef, style: { maxHeight: this.state.menuMaxHeight, overflowY: "auto", overscrollBehavior: "contain" }, onClick: ({ key }) => {
74
89
  this.triggerChange(key);
75
90
  this.setState({ opened: false });
76
91
  onSearch === null || onSearch === void 0 ? void 0 : onSearch();
@@ -84,7 +99,7 @@ export default class AutoCompleteInput extends React.Component {
84
99
  key: opt,
85
100
  label: stringFormatter ? stringFormatter(opt) : opt,
86
101
  })) }));
87
- return (React.createElement("div", { style: Object.assign({ width: 200, display: "inline-block" }, style) },
102
+ return (React.createElement("div", { ref: this.wrapperRef, style: Object.assign({ width: 200, display: "inline-block" }, style) },
88
103
  React.createElement(Dropdown, { popupRender: () => historyMenu, open: this.state.opened && hasHistory, onOpenChange: (open) => {
89
104
  this.setState({ opened: open });
90
105
  }, trigger: [] },
@@ -1 +1 @@
1
- {"version":3,"file":"autoCompleteInput.js","sourceRoot":"","sources":["../../../../components/input/autoCompleteInput.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAY,IAAI,EAAC,MAAM,MAAM,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAmDhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAmE;IACpH,MAAM,KAAK,YAAY;QACnB,OAAO;YACH,QAAQ,EAAE,GAAG,EAAE;YACf,CAAC;YACD,QAAQ,EAAE,GAAG,EAAE;YACf,CAAC;SACJ,CAAC;IACN,CAAC;IAKD,YAAY,KAA4C;QACpD,KAAK,CAAC,KAAK,CAAC,CAAC;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CACK,CACT,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Dropdown, Input, InputRef, Menu} from \"antd\";\r\nimport {DownOutlined} from \"@ant-design/icons\";\r\nimport {InputProps} from \"antd/es\";\r\nimport {Key} from \"ts-key-enum\";\r\n\r\ninterface InputSearchWithHistoryProps extends Omit<InputProps, \"onChange\" | \"onSearch\" | \"onSelect\" | \"placeholder\" | \"options\"> {\r\n /** Current text. The component keeps its own copy, which is replaced whenever this prop changes. */\r\n value?: string\r\n\r\n /** History entries offered in the dropdown (falsy entries are skipped). The dropdown arrow is shown only when non-empty. */\r\n options?: string[]\r\n\r\n /** Placeholder of the text input. */\r\n placeholder?: string\r\n\r\n /** Content rendered at the start of the text input. */\r\n prefix?: React.ReactNode\r\n\r\n /**\r\n * Called with the new text on every edit, on clear and when a history entry is picked.\r\n * @default no-op\r\n */\r\n onChange(searchString: string): void\r\n\r\n /**\r\n * Called on Enter (whether or not the dropdown is open) and after a history entry is picked.\r\n * @default no-op\r\n */\r\n onSearch(): void\r\n\r\n /** Called after a history entry is picked, right after `onSearch`. */\r\n onSelect?: () => void\r\n\r\n /** Called on Enter while the dropdown is closed, before `onSearch`. */\r\n onPressEnter?(): void\r\n\r\n /**\r\n * Makes the input read-only. Combined with `disabled`, the input is rendered read-only instead of disabled,\r\n * so the clear button and the history dropdown stay usable.\r\n */\r\n inputReadonly?: boolean\r\n\r\n /**\r\n * Maps a string to its displayed form; applied to the input value and to the option labels.\r\n * Picking an option passes the unformatted option to `onChange`, typing passes the edited displayed text.\r\n */\r\n stringFormatter?(rawString: string): string\r\n}\r\n\r\ninterface InputSearchWithHistoryState {\r\n opened: boolean\r\n searchString: string\r\n}\r\n\r\n/**\r\n * Text input with a history dropdown. When `options` is non-empty, a down-arrow suffix (or the ArrowDown key)\r\n * opens a menu of the entries; picking one sets the text and fires `onChange`, `onSearch` and `onSelect`.\r\n * Escape closes the menu. The `style` prop is applied to the wrapping element (default width 200 px);\r\n * `onBlur`, `onFocus` and `onKeyDown` are not forwarded to the input.\r\n */\r\nexport default class AutoCompleteInput extends React.Component<InputSearchWithHistoryProps, InputSearchWithHistoryState> {\r\n static get defaultProps() {\r\n return {\r\n onSearch: () => {\r\n },\r\n onChange: () => {\r\n }\r\n };\r\n }\r\n\r\n private inputRef = React.createRef<InputRef>();\r\n private menuRef = React.createRef<any>();\r\n\r\n constructor(props: Readonly<InputSearchWithHistoryProps>) {\r\n super(props);\r\n this.state = {\r\n opened: false,\r\n searchString: props.value || \"\",\r\n };\r\n }\r\n\r\n componentDidUpdate(prevProps: Readonly<InputSearchWithHistoryProps>) {\r\n if (this.props.value !== prevProps.value && this.props.value !== this.state.searchString) {\r\n this.setState({searchString: this.props.value || \"\"});\r\n }\r\n }\r\n\r\n /** Moves the keyboard focus to the text input. */\r\n public focus() {\r\n this.inputRef.current?.focus();\r\n }\r\n\r\n private triggerChange = (value: string) => {\r\n this.setState({searchString: value}, () => {\r\n this.props.onChange(value);\r\n });\r\n };\r\n\r\n private toggleDropdown = (e?: React.MouseEvent) => {\r\n e?.preventDefault();\r\n e?.stopPropagation();\r\n\r\n if (this.props.disabled && !this.props.inputReadonly) return;\r\n\r\n const willOpen = !this.state.opened;\r\n\r\n this.setState({opened: willOpen}, () => {\r\n if (willOpen) {\r\n setTimeout(() => {\r\n this.menuRef.current?.focus();\r\n }, 50);\r\n }\r\n });\r\n };\r\n\r\n render() {\r\n const {\r\n disabled,\r\n inputReadonly,\r\n placeholder,\r\n prefix,\r\n onPressEnter,\r\n onSearch,\r\n onSelect,\r\n options,\r\n stringFormatter,\r\n style,\r\n value,\r\n onBlur,\r\n onKeyDown,\r\n onFocus,\r\n\r\n ...rest\r\n } = this.props;\r\n\r\n const hasHistory = options && options.length > 0;\r\n\r\n const historyMenu = (\r\n <Menu\r\n ref={this.menuRef}\r\n onClick={({key}) => {\r\n this.triggerChange(key);\r\n this.setState({opened: false});\r\n onSearch?.();\r\n onSelect?.();\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.key === Key.Escape) {\r\n this.setState({opened: false});\r\n this.focus();\r\n }\r\n }}\r\n items={options?.filter(Boolean).map((opt) => ({\r\n key: opt,\r\n label: stringFormatter ? stringFormatter(opt) : opt,\r\n }))}\r\n />\r\n );\r\n\r\n return (\r\n <div style={{width: 200, display: \"inline-block\", ...style}}>\r\n <Dropdown\r\n popupRender={() => historyMenu}\r\n open={this.state.opened && hasHistory}\r\n onOpenChange={(open) => {\r\n this.setState({opened: open});\r\n }}\r\n trigger={[]}\r\n >\r\n <Input\r\n {...rest}\r\n ref={this.inputRef}\r\n placeholder={placeholder}\r\n prefix={prefix}\r\n value={stringFormatter ? stringFormatter(this.state.searchString) : this.state.searchString}\r\n disabled={disabled && !inputReadonly}\r\n readOnly={inputReadonly}\r\n allowClear={!disabled || inputReadonly}\r\n onChange={(e) => {\r\n this.triggerChange(e.target.value);\r\n }}\r\n onKeyDown={(e) => {\r\n if (!this.state.opened && e.key === Key.ArrowDown) {\r\n e.preventDefault();\r\n this.toggleDropdown();\r\n } else if (e.key === Key.Escape) {\r\n e.preventDefault();\r\n this.setState({opened: false});\r\n } else if (this.state.opened && e.key === Key.Enter) {\r\n e.preventDefault();\r\n this.setState({opened: false});\r\n if (onSearch) onSearch();\r\n } else if (!this.state.opened && e.key === Key.Enter) {\r\n if (onPressEnter) onPressEnter();\r\n if (onSearch) onSearch();\r\n }\r\n }}\r\n suffix={\r\n hasHistory ? (\r\n <DownOutlined\r\n style={{\r\n cursor: (disabled && !inputReadonly) ? \"not-allowed\" : \"pointer\",\r\n color: \"rgba(0, 0, 0, 0.25)\",\r\n padding: \"4px\"\r\n }}\r\n onMouseDown={(e) => e.preventDefault()}\r\n onClick={this.toggleDropdown}\r\n />\r\n ) : null\r\n }\r\n />\r\n </Dropdown>\r\n </div>\r\n );\r\n }\r\n}"]}
1
+ {"version":3,"file":"autoCompleteInput.js","sourceRoot":"","sources":["../../../../components/input/autoCompleteInput.tsx"],"names":[],"mappings":";;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cAAc,EAAE,EACtC,OAAO,EAAE,IAAI,CAAC,cAAc,GAC9B,CACL,CAAC,CAAC,CAAC,IAAI,IAEd,CACK,CACT,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Dropdown, Input, InputRef, Menu} from \"antd\";\r\nimport {DownOutlined} from \"@ant-design/icons\";\r\nimport {InputProps} from \"antd/es\";\r\nimport {Key} from \"ts-key-enum\";\r\n\r\ninterface InputSearchWithHistoryProps extends Omit<InputProps, \"onChange\" | \"onSearch\" | \"onSelect\" | \"placeholder\" | \"options\"> {\r\n /** Current text. The component keeps its own copy, which is replaced whenever this prop changes. */\r\n value?: string\r\n\r\n /** History entries offered in the dropdown (falsy entries are skipped). The dropdown arrow is shown only when non-empty. */\r\n options?: string[]\r\n\r\n /** Placeholder of the text input. */\r\n placeholder?: string\r\n\r\n /** Content rendered at the start of the text input. */\r\n prefix?: React.ReactNode\r\n\r\n /**\r\n * Called with the new text on every edit, on clear and when a history entry is picked.\r\n * @default no-op\r\n */\r\n onChange(searchString: string): void\r\n\r\n /**\r\n * Called on Enter (whether or not the dropdown is open) and after a history entry is picked.\r\n * @default no-op\r\n */\r\n onSearch(): void\r\n\r\n /** Called after a history entry is picked, right after `onSearch`. */\r\n onSelect?: () => void\r\n\r\n /** Called on Enter while the dropdown is closed, before `onSearch`. */\r\n onPressEnter?(): void\r\n\r\n /**\r\n * Makes the input read-only. Combined with `disabled`, the input is rendered read-only instead of disabled,\r\n * so the clear button and the history dropdown stay usable.\r\n */\r\n inputReadonly?: boolean\r\n\r\n /**\r\n * Maps a string to its displayed form; applied to the input value and to the option labels.\r\n * Picking an option passes the unformatted option to `onChange`, typing passes the edited displayed text.\r\n */\r\n stringFormatter?(rawString: string): string\r\n}\r\n\r\ninterface InputSearchWithHistoryState {\r\n opened: boolean\r\n searchString: string\r\n menuMaxHeight?: number\r\n}\r\n\r\n// antd places the dropdown popup 4 px away from the input\r\nconst DROPDOWN_POPUP_OFFSET = 4;\r\nconst MENU_VIEWPORT_MARGIN = 8;\r\n\r\n/**\r\n * Text input with a history dropdown. When `options` is non-empty, a down-arrow suffix (or the ArrowDown key)\r\n * opens a menu of the entries; picking one sets the text and fires `onChange`, `onSearch` and `onSelect`.\r\n * Escape closes the menu. The `style` prop is applied to the wrapping element (default width 200 px);\r\n * `onBlur`, `onFocus` and `onKeyDown` are not forwarded to the input.\r\n */\r\nexport default class AutoCompleteInput extends React.Component<InputSearchWithHistoryProps, InputSearchWithHistoryState> {\r\n static get defaultProps() {\r\n return {\r\n onSearch: () => {\r\n },\r\n onChange: () => {\r\n }\r\n };\r\n }\r\n\r\n private inputRef = React.createRef<InputRef>();\r\n private menuRef = React.createRef<any>();\r\n private wrapperRef = React.createRef<HTMLDivElement>();\r\n\r\n constructor(props: Readonly<InputSearchWithHistoryProps>) {\r\n super(props);\r\n this.state = {\r\n opened: false,\r\n searchString: props.value || \"\",\r\n };\r\n }\r\n\r\n componentDidUpdate(prevProps: Readonly<InputSearchWithHistoryProps>) {\r\n if (this.props.value !== prevProps.value && this.props.value !== this.state.searchString) {\r\n this.setState({searchString: this.props.value || \"\"});\r\n }\r\n }\r\n\r\n /** Moves the keyboard focus to the text input. */\r\n public focus() {\r\n this.inputRef.current?.focus();\r\n }\r\n\r\n private triggerChange = (value: string) => {\r\n this.setState({searchString: value}, () => {\r\n this.props.onChange(value);\r\n });\r\n };\r\n\r\n private toggleDropdown = (e?: React.MouseEvent) => {\r\n e?.preventDefault();\r\n e?.stopPropagation();\r\n\r\n if (this.props.disabled && !this.props.inputReadonly) return;\r\n\r\n const willOpen = !this.state.opened;\r\n\r\n this.setState({opened: willOpen, ...(willOpen ? {menuMaxHeight: this.getMenuMaxHeight()} : {})}, () => {\r\n if (willOpen) {\r\n setTimeout(() => {\r\n this.menuRef.current?.focus();\r\n }, 50);\r\n }\r\n });\r\n };\r\n\r\n // The popup is rendered into document.body, so a menu taller than the free space makes the whole page scrollable.\r\n // Taking the larger side lets antd's autoAdjustOverflow flip the popup above the input when that side is bigger.\r\n private getMenuMaxHeight(): number | undefined {\r\n const rect = this.wrapperRef.current?.getBoundingClientRect();\r\n if (!rect) return undefined;\r\n const spaceBelow = window.innerHeight - rect.bottom;\r\n const spaceAbove = rect.top;\r\n return Math.max(spaceBelow, spaceAbove) - DROPDOWN_POPUP_OFFSET - MENU_VIEWPORT_MARGIN;\r\n }\r\n\r\n render() {\r\n const {\r\n disabled,\r\n inputReadonly,\r\n placeholder,\r\n prefix,\r\n onPressEnter,\r\n onSearch,\r\n onSelect,\r\n options,\r\n stringFormatter,\r\n style,\r\n value,\r\n onBlur,\r\n onKeyDown,\r\n onFocus,\r\n\r\n ...rest\r\n } = this.props;\r\n\r\n const hasHistory = options && options.length > 0;\r\n\r\n const historyMenu = (\r\n <Menu\r\n ref={this.menuRef}\r\n style={{maxHeight: this.state.menuMaxHeight, overflowY: \"auto\", overscrollBehavior: \"contain\"}}\r\n onClick={({key}) => {\r\n this.triggerChange(key);\r\n this.setState({opened: false});\r\n onSearch?.();\r\n onSelect?.();\r\n }}\r\n onKeyDown={(e) => {\r\n if (e.key === Key.Escape) {\r\n this.setState({opened: false});\r\n this.focus();\r\n }\r\n }}\r\n items={options?.filter(Boolean).map((opt) => ({\r\n key: opt,\r\n label: stringFormatter ? stringFormatter(opt) : opt,\r\n }))}\r\n />\r\n );\r\n\r\n return (\r\n <div ref={this.wrapperRef} style={{width: 200, display: \"inline-block\", ...style}}>\r\n <Dropdown\r\n popupRender={() => historyMenu}\r\n open={this.state.opened && hasHistory}\r\n onOpenChange={(open) => {\r\n this.setState({opened: open});\r\n }}\r\n trigger={[]}\r\n >\r\n <Input\r\n {...rest}\r\n ref={this.inputRef}\r\n placeholder={placeholder}\r\n prefix={prefix}\r\n value={stringFormatter ? stringFormatter(this.state.searchString) : this.state.searchString}\r\n disabled={disabled && !inputReadonly}\r\n readOnly={inputReadonly}\r\n allowClear={!disabled || inputReadonly}\r\n onChange={(e) => {\r\n this.triggerChange(e.target.value);\r\n }}\r\n onKeyDown={(e) => {\r\n if (!this.state.opened && e.key === Key.ArrowDown) {\r\n e.preventDefault();\r\n this.toggleDropdown();\r\n } else if (e.key === Key.Escape) {\r\n e.preventDefault();\r\n this.setState({opened: false});\r\n } else if (this.state.opened && e.key === Key.Enter) {\r\n e.preventDefault();\r\n this.setState({opened: false});\r\n if (onSearch) onSearch();\r\n } else if (!this.state.opened && e.key === Key.Enter) {\r\n if (onPressEnter) onPressEnter();\r\n if (onSearch) onSearch();\r\n }\r\n }}\r\n suffix={\r\n hasHistory ? (\r\n <DownOutlined\r\n style={{\r\n cursor: (disabled && !inputReadonly) ? \"not-allowed\" : \"pointer\",\r\n color: \"rgba(0, 0, 0, 0.25)\",\r\n padding: \"4px\"\r\n }}\r\n onMouseDown={(e) => e.preventDefault()}\r\n onClick={this.toggleDropdown}\r\n />\r\n ) : null\r\n }\r\n />\r\n </Dropdown>\r\n </div>\r\n );\r\n }\r\n}"]}
@@ -3,7 +3,7 @@ import { ModalProps } from 'antd/lib/modal';
3
3
  export interface DraggableModalProps extends Omit<ModalProps, "width"> {
4
4
  initialWidth?: number;
5
5
  initialHeight?: number;
6
- /** show the maximize/restore button next to the close button (default true) */
6
+ /** show the maximize/restore button next to the close button (default false) */
7
7
  maximizable?: boolean;
8
8
  onResize?(size: {
9
9
  width: number;
@@ -1 +1 @@
1
- {"version":3,"file":"draggableModal.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModal.tsx"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAoB,UAAU,EAAC,MAAM,OAAO,CAAA;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AAYrD,MAAM,CAAC,MAAM,cAAc,GAA2C,CAAC,KAA0B,EAAsB,EAAE;IACrH,mCAAmC;IACnC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAEpB,sBAAsB;IACtB,MAAM,aAAa,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;IACxD,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;IAClC,CAAC;IAED,MAAM,EAAC,QAAQ,EAAE,KAAK,EAAC,GAAG,aAAa,CAAC;IACxC,MAAM,UAAU,GAAG,aAAa,CAAC,EAAC,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAC,CAAC,CAAC;IAEpH,2EAA2E;IAC3E,gEAAgE;IAChE,qCAAqC;IACrC,OAAO,oBAAC,mBAAmB,kBAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,IAAM,KAAK,EAAI,CAAA;AACjG,CAAC,CAAC","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {FunctionComponent, useContext} from 'react'\r\nimport {useUID} from 'react-uid'\r\nimport {DraggableModalContext} from './draggableModalContext'\r\nimport {DraggableModalInner} from './draggableModalInner'\r\nimport {getModalState} from './draggableModalReducer'\r\nimport {ModalProps} from 'antd/lib/modal'\r\n\r\nexport interface DraggableModalProps extends Omit<ModalProps, \"width\"> {\r\n initialWidth?: number,\r\n initialHeight?: number\r\n /** show the maximize/restore button next to the close button (default true) */\r\n maximizable?: boolean\r\n // resize dialog handler\r\n onResize?(size: { width: number, height: number }): void\r\n}\r\n\r\nexport const DraggableModal: FunctionComponent<DraggableModalProps> = (props: DraggableModalProps): React.ReactElement => {\r\n // Get the unique ID of this modal.\r\n const id = useUID();\r\n\r\n // Get modal provider.\r\n const modalProvider = useContext(DraggableModalContext);\r\n if (!modalProvider) {\r\n throw new Error('No Provider')\r\n }\r\n\r\n const {dispatch, state} = modalProvider;\r\n const modalState = getModalState({state, id, initialWidth: props.initialWidth, initialHeight: props.initialHeight});\r\n\r\n // We do this so that we don't re-render all modals for every state change.\r\n // DraggableModalInner uses React.memo, so it only re-renders if\r\n // if props change (e.g. modalState).\r\n return <DraggableModalInner id={id} dispatch={dispatch} modalState={modalState} {...props} />\r\n};\r\n"]}
1
+ {"version":3,"file":"draggableModal.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModal.tsx"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAoB,UAAU,EAAC,MAAM,OAAO,CAAA;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AAYrD,MAAM,CAAC,MAAM,cAAc,GAA2C,CAAC,KAA0B,EAAsB,EAAE;IACrH,mCAAmC;IACnC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAEpB,sBAAsB;IACtB,MAAM,aAAa,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;IACxD,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;IAClC,CAAC;IAED,MAAM,EAAC,QAAQ,EAAE,KAAK,EAAC,GAAG,aAAa,CAAC;IACxC,MAAM,UAAU,GAAG,aAAa,CAAC,EAAC,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAC,CAAC,CAAC;IAEpH,2EAA2E;IAC3E,gEAAgE;IAChE,qCAAqC;IACrC,OAAO,oBAAC,mBAAmB,kBAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,IAAM,KAAK,EAAI,CAAA;AACjG,CAAC,CAAC","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {FunctionComponent, useContext} from 'react'\r\nimport {useUID} from 'react-uid'\r\nimport {DraggableModalContext} from './draggableModalContext'\r\nimport {DraggableModalInner} from './draggableModalInner'\r\nimport {getModalState} from './draggableModalReducer'\r\nimport {ModalProps} from 'antd/lib/modal'\r\n\r\nexport interface DraggableModalProps extends Omit<ModalProps, \"width\"> {\r\n initialWidth?: number,\r\n initialHeight?: number\r\n /** show the maximize/restore button next to the close button (default false) */\r\n maximizable?: boolean\r\n // resize dialog handler\r\n onResize?(size: { width: number, height: number }): void\r\n}\r\n\r\nexport const DraggableModal: FunctionComponent<DraggableModalProps> = (props: DraggableModalProps): React.ReactElement => {\r\n // Get the unique ID of this modal.\r\n const id = useUID();\r\n\r\n // Get modal provider.\r\n const modalProvider = useContext(DraggableModalContext);\r\n if (!modalProvider) {\r\n throw new Error('No Provider')\r\n }\r\n\r\n const {dispatch, state} = modalProvider;\r\n const modalState = getModalState({state, id, initialWidth: props.initialWidth, initialHeight: props.initialHeight});\r\n\r\n // We do this so that we don't re-render all modals for every state change.\r\n // DraggableModalInner uses React.memo, so it only re-renders if\r\n // if props change (e.g. modalState).\r\n return <DraggableModalInner id={id} dispatch={dispatch} modalState={modalState} {...props} />\r\n};\r\n"]}
@@ -25,7 +25,7 @@ import { getWindowSize } from './getWindowSize';
25
25
  import { headerButtonGeometry, useDraggableModalStyles } from "./draggableModalStyles";
26
26
  const modalStyle = { margin: 0, paddingBottom: 0, pointerEvents: 'auto' };
27
27
  export const DraggableModalInner = memo((_a) => {
28
- var { id, modalState, dispatch, open, children, title, initialWidth, initialHeight, onResize, maximizable = true } = _a, otherProps = __rest(_a, ["id", "modalState", "dispatch", "open", "children", "title", "initialWidth", "initialHeight", "onResize", "maximizable"]);
28
+ var { id, modalState, dispatch, open, children, title, initialWidth, initialHeight, onResize, maximizable = false } = _a, otherProps = __rest(_a, ["id", "modalState", "dispatch", "open", "children", "title", "initialWidth", "initialHeight", "onResize", "maximizable"]);
29
29
  const { styles, cx, theme } = useDraggableModalStyles();
30
30
  const { getPrefixCls, getPopupContainer } = useContext(ConfigContext);
31
31
  const modalPrefixCls = getPrefixCls('modal');
@@ -1 +1 @@
1
- {"version":3,"file":"draggableModalInner.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalInner.tsx"],"names":[],"mappings":"AAAA,yCAAyC;;;;;;;;;;;;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAA;AAChG,OAAO,EAAC,KAAK,EAAC,MAAM,MAAM,CAAA;AAC1B,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAC5E,OAAO,IAAI,MAAM,kBAAkB,CAAA;AACnC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AACzC,OAAO,EAAsB,aAAa,EAAC,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAE7C,OAAO,EAAC,oBAAoB,EAAE,uBAAuB,EAAC,MAAM,wBAAwB,CAAC;AAErF,MAAM,UAAU,GAAwB,EAAC,MAAM,EAAE,CAAC,EAAE,aAA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CAAC,UAAU,CAAC,EACrD,SAAS,EAAE,GAAG,cAAc,4CAA4C,EACxE,OAAO,EAAE,gBAAgB;YAC7B,8BAAM,SAAS,EAAE,GAAG,cAAc,UAAU,IACvC,SAAS,CAAC,CAAC,CAAC,oBAAC,sBAAsB,OAAE,CAAC,CAAC,CAAC,oBAAC,kBAAkB,OAAE,CAC3D,CACF;QACT,oBAAC,YAAY,IAAC,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,cAAc,EAAE,MAAM,CAAC,iBAAiB,EACxE,WAAW,EAAE,aAAa,GAAG,CACvC,CACX,CAAA;AACL,CAAC,CACJ,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;IACxC,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAC3D,CAAC","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef} from 'react'\r\nimport {Modal} from 'antd'\r\nimport {ConfigContext} from 'antd/es/config-provider'\r\nimport {FullscreenExitOutlined, FullscreenOutlined} from '@ant-design/icons'\r\nimport i18n from 'd2core/i18n/i18n'\r\nimport {ResizeHandle} from './resizeHandle'\r\nimport {useDrag} from './useDrag'\r\nimport {DraggableModalContextMethods} from './draggableModalContext'\r\nimport {usePrevious} from './usePrevious'\r\nimport {ModalID, ModalState, WINDOW_MARGIN} from './draggableModalReducer'\r\nimport {useResize} from './useResize'\r\nimport {getWindowSize} from './getWindowSize'\r\nimport {DraggableModalProps} from \"./draggableModal\";\r\nimport {headerButtonGeometry, useDraggableModalStyles} from \"./draggableModalStyles\";\r\n\r\nconst modalStyle: React.CSSProperties = {margin: 0, paddingBottom: 0, pointerEvents: 'auto'}\r\n\r\ninterface ContextProps extends DraggableModalContextMethods {\r\n id: ModalID\r\n modalState: ModalState\r\n initialWidth?: number\r\n initialHeight?: number\r\n}\r\n\r\n//export type DraggableModalInnerProps = ModalProps & { children?: React.ReactNode } & ContextProps\r\nexport interface DraggableModalInnerProps extends DraggableModalProps, ContextProps {\r\n children?: React.ReactNode\r\n}\r\n\r\nexport const DraggableModalInner = memo(\r\n ({\r\n id,\r\n modalState,\r\n dispatch,\r\n open,\r\n children,\r\n title,\r\n initialWidth,\r\n initialHeight,\r\n onResize,\r\n maximizable = true,\r\n ...otherProps\r\n }: DraggableModalInnerProps) => {\r\n const {styles, cx, theme} = useDraggableModalStyles();\r\n const {getPrefixCls, getPopupContainer} = useContext(ConfigContext);\r\n const modalPrefixCls = getPrefixCls('modal');\r\n\r\n // antd stacks sibling modals of equal z-index by DOM order, but appends the container of a modal kept\r\n // in the DOM (destroyOnHidden={false}) only on its first opening - reopened, it would stay under every\r\n // modal opened since. Only antd's own container (no getContainer / getPopupContainer) holds this modal\r\n // alone and may move.\r\n const titleRef = useRef<HTMLDivElement>(null);\r\n const movableContainer = otherProps.getContainer === undefined && getPopupContainer === undefined;\r\n useLayoutEffect(() => {\r\n const container = open && movableContainer\r\n ? titleRef.current?.closest(`.${modalPrefixCls}-root`)?.parentElement\r\n : undefined;\r\n if (container?.parentElement && container !== container.parentElement.lastElementChild) {\r\n container.parentElement.appendChild(container);\r\n }\r\n }, [open, movableContainer, modalPrefixCls]);\r\n\r\n // NO_BUTTONS dialogs (and anyone passing footer={null}) render no footer, which is where the\r\n // bottom inset normally lives - the content has to take it back\r\n const hasFooter = otherProps.footer !== null;\r\n // room the title has to leave in the top-right corner so the buttons do not cover it\r\n const titleReserve = headerButtonGeometry(theme)\r\n .reserve((otherProps.closable === false ? 0 : 1) + (maximizable ? 1 : 0));\r\n\r\n // Call on mount and unmount.\r\n useEffect(() => {\r\n dispatch({type: 'mount', id, intialState: {initialWidth, initialHeight}});\r\n return () => dispatch({type: 'unmount', id})\r\n }, [dispatch, id, initialWidth, initialHeight]);\r\n\r\n const visiblePrevious = usePrevious(open);\r\n useEffect(() => {\r\n if (open !== visiblePrevious) {\r\n if (open) {\r\n dispatch({type: 'show', id})\r\n } else {\r\n dispatch({type: 'hide', id})\r\n }\r\n }\r\n }, [open, visiblePrevious, id, dispatch]);\r\n\r\n const {x, y, width, height} = modalState;\r\n\r\n const style: React.CSSProperties = useMemo(\r\n () => ({...modalStyle, top: y, left: x, height}),\r\n [y, x, height],\r\n );\r\n\r\n const onDragWithID = useCallback((args: any) => dispatch({type: 'drag', id, ...args}), [\r\n dispatch,\r\n id,\r\n ]);\r\n\r\n const onResizeWithID = useCallback((args: any) => {\r\n onResize?.({width: args.width, height: args.height});\r\n return dispatch({type: 'resize', id, ...args})\r\n }, [dispatch, id,]);\r\n\r\n const {restore} = modalState;\r\n const maximized = restore !== undefined;\r\n\r\n const onToggleMaximize = useCallback(() => {\r\n const windowSize = getWindowSize();\r\n onResize?.(restore\r\n ? {width: restore.width, height: restore.height}\r\n : {width: windowSize.width - WINDOW_MARGIN, height: windowSize.height - WINDOW_MARGIN});\r\n dispatch({type: 'maximize', id, margin: WINDOW_MARGIN})\r\n }, [dispatch, id, onResize, restore]);\r\n\r\n const onMouseDrag = useDrag(x, y, onDragWithID);\r\n const onMouseResize = useResize(x, y, width, height, onResizeWithID);\r\n\r\n const titleElement = useMemo(\r\n () => (\r\n <div\r\n ref={titleRef}\r\n // the legacy class name is kept as a styling hook for the app (e.g. .compact-modal)\r\n className={cx(\"ant-design-draggable-modal-title\", styles.title)}\r\n // inline so it wins over the class padding without a specificity contest\r\n style={titleReserve > 0 ? {paddingInlineEnd: titleReserve} : undefined}\r\n onMouseDown={onMouseDrag}\r\n >\r\n {title}\r\n </div>\r\n ),\r\n [onMouseDrag, title, cx, styles.title, titleReserve],\r\n );\r\n\r\n return (\r\n <Modal\r\n wrapClassName={cx(\"ant-design-draggable-modal\", styles.wrap, !hasFooter && styles.wrapWithoutFooter)}\r\n style={style}\r\n destroyOnHidden\r\n width={width}\r\n title={titleElement}\r\n open={open}\r\n {...otherProps}\r\n >\r\n {children}\r\n {/* reuses antd's close-button markup so it matches the button it sits next to */}\r\n {maximizable && <button type=\"button\"\r\n aria-label={maximized ? i18n(\"Restore\") : i18n(\"Maximize\")}\r\n title={maximized ? i18n(\"Restore\") : i18n(\"Maximize\")}\r\n className={`${modalPrefixCls}-close ant-design-draggable-modal-maximize`}\r\n onClick={onToggleMaximize}>\r\n <span className={`${modalPrefixCls}-close-x`}>\r\n {maximized ? <FullscreenExitOutlined/> : <FullscreenOutlined/>}\r\n </span>\r\n </button>}\r\n <ResizeHandle className={styles.resizeHandle} innerClassName={styles.resizeHandleInner}\r\n onMouseDown={onMouseResize}/>\r\n </Modal>\r\n )\r\n }\r\n);\r\n\r\nif (process.env.NODE_ENV !== 'production') {\r\n DraggableModalInner.displayName = 'DraggableModalInner'\r\n}\r\n"]}
1
+ {"version":3,"file":"draggableModalInner.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalInner.tsx"],"names":[],"mappings":"AAAA,yCAAyC;;;;;;;;;;;;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAA;AAChG,OAAO,EAAC,KAAK,EAAC,MAAM,MAAM,CAAA;AAC1B,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAC5E,OAAO,IAAI,MAAM,kBAAkB,CAAA;AACnC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AACzC,OAAO,EAAsB,aAAa,EAAC,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAA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AAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAC1D,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EACrD,SAAS,EAAE,GAAG,cAAc,4CAA4C,EACxE,OAAO,EAAE,gBAAgB;YAC7B,8BAAM,SAAS,EAAE,GAAG,cAAc,UAAU,IACvC,SAAS,CAAC,CAAC,CAAC,oBAAC,sBAAsB,OAAE,CAAC,CAAC,CAAC,oBAAC,kBAAkB,OAAE,CAC3D,CACF;QACT,oBAAC,YAAY,IAAC,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,cAAc,EAAE,MAAM,CAAC,iBAAiB,EACxE,WAAW,EAAE,aAAa,GAAG,CACvC,CACX,CAAA;AACL,CAAC,CACJ,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;IACxC,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAC3D,CAAC","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef} from 'react'\r\nimport {Modal} from 'antd'\r\nimport {ConfigContext} from 'antd/es/config-provider'\r\nimport {FullscreenExitOutlined, FullscreenOutlined} from '@ant-design/icons'\r\nimport i18n from 'd2core/i18n/i18n'\r\nimport {ResizeHandle} from './resizeHandle'\r\nimport {useDrag} from './useDrag'\r\nimport {DraggableModalContextMethods} from './draggableModalContext'\r\nimport {usePrevious} from './usePrevious'\r\nimport {ModalID, ModalState, WINDOW_MARGIN} from './draggableModalReducer'\r\nimport {useResize} from './useResize'\r\nimport {getWindowSize} from './getWindowSize'\r\nimport {DraggableModalProps} from \"./draggableModal\";\r\nimport {headerButtonGeometry, useDraggableModalStyles} from \"./draggableModalStyles\";\r\n\r\nconst modalStyle: React.CSSProperties = {margin: 0, paddingBottom: 0, pointerEvents: 'auto'}\r\n\r\ninterface ContextProps extends DraggableModalContextMethods {\r\n id: ModalID\r\n modalState: ModalState\r\n initialWidth?: number\r\n initialHeight?: number\r\n}\r\n\r\n//export type DraggableModalInnerProps = ModalProps & { children?: React.ReactNode } & ContextProps\r\nexport interface DraggableModalInnerProps extends DraggableModalProps, ContextProps {\r\n children?: React.ReactNode\r\n}\r\n\r\nexport const DraggableModalInner = memo(\r\n ({\r\n id,\r\n modalState,\r\n dispatch,\r\n open,\r\n children,\r\n title,\r\n initialWidth,\r\n initialHeight,\r\n onResize,\r\n maximizable = false,\r\n ...otherProps\r\n }: DraggableModalInnerProps) => {\r\n const {styles, cx, theme} = useDraggableModalStyles();\r\n const {getPrefixCls, getPopupContainer} = useContext(ConfigContext);\r\n const modalPrefixCls = getPrefixCls('modal');\r\n\r\n // antd stacks sibling modals of equal z-index by DOM order, but appends the container of a modal kept\r\n // in the DOM (destroyOnHidden={false}) only on its first opening - reopened, it would stay under every\r\n // modal opened since. Only antd's own container (no getContainer / getPopupContainer) holds this modal\r\n // alone and may move.\r\n const titleRef = useRef<HTMLDivElement>(null);\r\n const movableContainer = otherProps.getContainer === undefined && getPopupContainer === undefined;\r\n useLayoutEffect(() => {\r\n const container = open && movableContainer\r\n ? titleRef.current?.closest(`.${modalPrefixCls}-root`)?.parentElement\r\n : undefined;\r\n if (container?.parentElement && container !== container.parentElement.lastElementChild) {\r\n container.parentElement.appendChild(container);\r\n }\r\n }, [open, movableContainer, modalPrefixCls]);\r\n\r\n // NO_BUTTONS dialogs (and anyone passing footer={null}) render no footer, which is where the\r\n // bottom inset normally lives - the content has to take it back\r\n const hasFooter = otherProps.footer !== null;\r\n // room the title has to leave in the top-right corner so the buttons do not cover it\r\n const titleReserve = headerButtonGeometry(theme)\r\n .reserve((otherProps.closable === false ? 0 : 1) + (maximizable ? 1 : 0));\r\n\r\n // Call on mount and unmount.\r\n useEffect(() => {\r\n dispatch({type: 'mount', id, intialState: {initialWidth, initialHeight}});\r\n return () => dispatch({type: 'unmount', id})\r\n }, [dispatch, id, initialWidth, initialHeight]);\r\n\r\n const visiblePrevious = usePrevious(open);\r\n useEffect(() => {\r\n if (open !== visiblePrevious) {\r\n if (open) {\r\n dispatch({type: 'show', id})\r\n } else {\r\n dispatch({type: 'hide', id})\r\n }\r\n }\r\n }, [open, visiblePrevious, id, dispatch]);\r\n\r\n const {x, y, width, height} = modalState;\r\n\r\n const style: React.CSSProperties = useMemo(\r\n () => ({...modalStyle, top: y, left: x, height}),\r\n [y, x, height],\r\n );\r\n\r\n const onDragWithID = useCallback((args: any) => dispatch({type: 'drag', id, ...args}), [\r\n dispatch,\r\n id,\r\n ]);\r\n\r\n const onResizeWithID = useCallback((args: any) => {\r\n onResize?.({width: args.width, height: args.height});\r\n return dispatch({type: 'resize', id, ...args})\r\n }, [dispatch, id,]);\r\n\r\n const {restore} = modalState;\r\n const maximized = restore !== undefined;\r\n\r\n const onToggleMaximize = useCallback(() => {\r\n const windowSize = getWindowSize();\r\n onResize?.(restore\r\n ? {width: restore.width, height: restore.height}\r\n : {width: windowSize.width - WINDOW_MARGIN, height: windowSize.height - WINDOW_MARGIN});\r\n dispatch({type: 'maximize', id, margin: WINDOW_MARGIN})\r\n }, [dispatch, id, onResize, restore]);\r\n\r\n const onMouseDrag = useDrag(x, y, onDragWithID);\r\n const onMouseResize = useResize(x, y, width, height, onResizeWithID);\r\n\r\n const titleElement = useMemo(\r\n () => (\r\n <div\r\n ref={titleRef}\r\n // the legacy class name is kept as a styling hook for the app (e.g. .compact-modal)\r\n className={cx(\"ant-design-draggable-modal-title\", styles.title)}\r\n // inline so it wins over the class padding without a specificity contest\r\n style={titleReserve > 0 ? {paddingInlineEnd: titleReserve} : undefined}\r\n onMouseDown={onMouseDrag}\r\n >\r\n {title}\r\n </div>\r\n ),\r\n [onMouseDrag, title, cx, styles.title, titleReserve],\r\n );\r\n\r\n return (\r\n <Modal\r\n wrapClassName={cx(\"ant-design-draggable-modal\", styles.wrap, !hasFooter && styles.wrapWithoutFooter)}\r\n style={style}\r\n destroyOnHidden\r\n width={width}\r\n title={titleElement}\r\n open={open}\r\n {...otherProps}\r\n >\r\n {children}\r\n {/* reuses antd's close-button markup so it matches the button it sits next to */}\r\n {maximizable && <button type=\"button\"\r\n aria-label={maximized ? i18n(\"Restore\") : i18n(\"Maximize\")}\r\n title={maximized ? i18n(\"Restore\") : i18n(\"Maximize\")}\r\n className={`${modalPrefixCls}-close ant-design-draggable-modal-maximize`}\r\n onClick={onToggleMaximize}>\r\n <span className={`${modalPrefixCls}-close-x`}>\r\n {maximized ? <FullscreenExitOutlined/> : <FullscreenOutlined/>}\r\n </span>\r\n </button>}\r\n <ResizeHandle className={styles.resizeHandle} innerClassName={styles.resizeHandleInner}\r\n onMouseDown={onMouseResize}/>\r\n </Modal>\r\n )\r\n }\r\n);\r\n\r\nif (process.env.NODE_ENV !== 'production') {\r\n DraggableModalInner.displayName = 'DraggableModalInner'\r\n}\r\n"]}