d2coreui 23.0.51 → 23.0.53
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 +27 -0
- package/README.md +154 -0
- package/components/clipboard/clipboardUtils.d.ts +11 -0
- package/components/clipboard/clipboardUtils.js +16 -4
- package/components/clipboard/clipboardUtils.js.map +1 -1
- package/components/codemirror/SyntaxHighlighter.d.ts +13 -0
- package/components/codemirror/SyntaxHighlighter.js +6 -1
- package/components/codemirror/SyntaxHighlighter.js.map +1 -1
- package/components/collapse/expandable.d.ts +10 -0
- package/components/collapse/expandable.js +4 -0
- package/components/collapse/expandable.js.map +1 -1
- package/components/color/colorPicker.d.ts +16 -0
- package/components/color/colorPicker.js +4 -0
- package/components/color/colorPicker.js.map +1 -1
- package/components/color/colorSwatch.d.ts +16 -0
- package/components/color/colorSwatch.js +23 -2
- package/components/color/colorSwatch.js.map +1 -1
- package/components/color/colorUtils.d.ts +9 -0
- package/components/color/colorUtils.js +15 -0
- package/components/color/colorUtils.js.map +1 -1
- package/components/date/dateRangeInput.d.ts +76 -0
- package/components/date/dateRangeInput.js +63 -12
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -0
- package/components/date/dateRangeInputAdvancedPanel.js +7 -0
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
- package/components/date/dateRangeInputConfirm.d.ts +18 -0
- package/components/date/dateRangeInputConfirm.js +12 -0
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +99 -0
- package/components/date/dateTimeInput.js +78 -6
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/date/durationInput.d.ts +37 -0
- package/components/date/durationInput.js +26 -3
- package/components/date/durationInput.js.map +1 -1
- package/components/date/savedIntervals.d.ts +63 -0
- package/components/date/savedIntervals.js +37 -0
- package/components/date/savedIntervals.js.map +1 -1
- package/components/date/savedIntervalsDialog.d.ts +13 -0
- package/components/date/savedIntervalsDialog.js +7 -2
- package/components/date/savedIntervalsDialog.js.map +1 -1
- package/components/form/NiceFormItem.d.ts +9 -0
- package/components/form/NiceFormItem.js +4 -0
- package/components/form/NiceFormItem.js.map +1 -1
- package/components/grid/cell/beanAccessor.d.ts +12 -0
- package/components/grid/cell/beanAccessor.js +8 -0
- package/components/grid/cell/beanAccessor.js.map +1 -1
- package/components/grid/cell/bigNumberCellEditor.d.ts +9 -0
- package/components/grid/cell/bigNumberCellEditor.js +19 -0
- package/components/grid/cell/bigNumberCellEditor.js.map +1 -1
- package/components/grid/cell/cellControl.d.ts +4 -0
- package/components/grid/cell/cellControl.js +14 -0
- package/components/grid/cell/cellControl.js.map +1 -1
- package/components/grid/cell/cellEditorUtils.d.ts +6 -0
- package/components/grid/cell/cellEditorUtils.js +6 -0
- package/components/grid/cell/cellEditorUtils.js.map +1 -1
- package/components/grid/cell/customEnumCellEditor.d.ts +6 -0
- package/components/grid/cell/customEnumCellEditor.js +10 -0
- package/components/grid/cell/customEnumCellEditor.js.map +1 -1
- package/components/grid/cell/dataGridCellEditorComponent.d.ts +26 -0
- package/components/grid/cell/dataGridCellEditorComponent.js +21 -0
- package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -1
- package/components/grid/cell/dateCellEditor.d.ts +6 -0
- package/components/grid/cell/dateCellEditor.js +10 -0
- package/components/grid/cell/dateCellEditor.js.map +1 -1
- package/components/grid/cell/dragListenerFeature.d.ts +6 -0
- package/components/grid/cell/dragListenerFeature.js +6 -0
- package/components/grid/cell/dragListenerFeature.js.map +1 -1
- package/components/grid/cell/durationCellEditor.d.ts +6 -0
- package/components/grid/cell/durationCellEditor.js +14 -0
- package/components/grid/cell/durationCellEditor.js.map +1 -1
- package/components/grid/cell/hexaOctetStringCellEditor.d.ts +6 -0
- package/components/grid/cell/hexaOctetStringCellEditor.js +14 -0
- package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
- package/components/grid/cell/hexaValueCellEditor.d.ts +6 -0
- package/components/grid/cell/hexaValueCellEditor.js +14 -0
- package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
- package/components/grid/cell/numberCellEditor.d.ts +6 -0
- package/components/grid/cell/numberCellEditor.js +15 -0
- package/components/grid/cell/numberCellEditor.js.map +1 -1
- package/components/grid/cell/rangeSelector.d.ts +7 -0
- package/components/grid/cell/rangeSelector.js +59 -5
- package/components/grid/cell/rangeSelector.js.map +1 -1
- package/components/grid/cell/simpleStatusTextCellEditor.d.ts +7 -0
- package/components/grid/cell/simpleStatusTextCellEditor.js +11 -0
- package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
- package/components/grid/cell/statusTextCellEditor.d.ts +7 -0
- package/components/grid/cell/statusTextCellEditor.js +17 -0
- package/components/grid/cell/statusTextCellEditor.js.map +1 -1
- package/components/grid/cell/tableDefaultRowStyleRules.d.ts +31 -0
- package/components/grid/cell/tableDefaultRowStyleRules.js +5 -0
- package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
- package/components/grid/cell/textCellEditor.d.ts +6 -0
- package/components/grid/cell/textCellEditor.js +15 -0
- package/components/grid/cell/textCellEditor.js.map +1 -1
- package/components/grid/cell/withAgGridHooks.d.ts +8 -0
- package/components/grid/cell/withAgGridHooks.js +8 -0
- package/components/grid/cell/withAgGridHooks.js.map +1 -1
- package/components/grid/columnUtils.d.ts +7 -0
- package/components/grid/columnUtils.js +7 -0
- package/components/grid/columnUtils.js.map +1 -1
- package/components/grid/config/columnTransfer.d.ts +18 -0
- package/components/grid/config/columnTransfer.js +14 -3
- package/components/grid/config/columnTransfer.js.map +1 -1
- package/components/grid/config/dataGridEditor.d.ts +31 -0
- package/components/grid/config/dataGridEditor.js +14 -2
- package/components/grid/config/dataGridEditor.js.map +1 -1
- package/components/grid/config/rowHeightCalculator.d.ts +11 -0
- package/components/grid/config/rowHeightCalculator.js +11 -0
- package/components/grid/config/rowHeightCalculator.js.map +1 -1
- package/components/grid/config/rowStylePicker.d.ts +19 -0
- package/components/grid/config/rowStylePicker.js +12 -0
- package/components/grid/config/rowStylePicker.js.map +1 -1
- package/components/grid/dataGrid.d.ts +331 -0
- package/components/grid/dataGrid.js +168 -11
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/detail/detailHeaderPanel.d.ts +11 -0
- package/components/grid/detail/detailHeaderPanel.js +5 -0
- package/components/grid/detail/detailHeaderPanel.js.map +1 -1
- package/components/grid/export/contextMenu.d.ts +31 -0
- package/components/grid/export/contextMenu.js +8 -0
- package/components/grid/export/contextMenu.js.map +1 -1
- package/components/grid/export/progressPopup.d.ts +21 -0
- package/components/grid/export/progressPopup.js +17 -0
- package/components/grid/export/progressPopup.js.map +1 -1
- package/components/grid/export/worker/pdfExport.js +5 -0
- package/components/grid/export/worker/pdfExport.js.map +1 -1
- package/components/grid/extendedDataGrid.d.ts +241 -0
- package/components/grid/extendedDataGrid.js +121 -2
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/grid/filter/customColumnFilter.d.ts +5 -0
- package/components/grid/filter/customColumnFilter.js +5 -0
- package/components/grid/filter/customColumnFilter.js.map +1 -1
- package/components/grid/filter/dataGridColumnFilter.d.ts +19 -0
- package/components/grid/filter/dataGridColumnFilter.js +19 -0
- package/components/grid/filter/dataGridColumnFilter.js.map +1 -1
- package/components/grid/filter/dateColumnFilter.d.ts +6 -0
- package/components/grid/filter/dateColumnFilter.js +6 -0
- package/components/grid/filter/dateColumnFilter.js.map +1 -1
- package/components/grid/filter/textColumnFilter.d.ts +6 -0
- package/components/grid/filter/textColumnFilter.js +6 -0
- package/components/grid/filter/textColumnFilter.js.map +1 -1
- package/components/grid/filter/wildcardQuickFilterEngine.d.ts +21 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js +21 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -1
- package/components/grid/header/simpleHeader.d.ts +17 -0
- package/components/grid/header/simpleHeader.js +20 -0
- package/components/grid/header/simpleHeader.js.map +1 -1
- package/components/grid/panel/dataGridPagination.d.ts +10 -0
- package/components/grid/panel/dataGridPagination.js +5 -0
- package/components/grid/panel/dataGridPagination.js.map +1 -1
- package/components/grid/panel/loadingOverlay.d.ts +5 -0
- package/components/grid/panel/loadingOverlay.js +4 -0
- package/components/grid/panel/loadingOverlay.js.map +1 -1
- package/components/grid/panel/noRecordsOverlay.d.ts +6 -0
- package/components/grid/panel/noRecordsOverlay.js +5 -0
- package/components/grid/panel/noRecordsOverlay.js.map +1 -1
- package/components/grid/panel/tablePagination.d.ts +4 -0
- package/components/grid/panel/tablePagination.js +4 -0
- package/components/grid/panel/tablePagination.js.map +1 -1
- package/components/icons/dropdownArrow.d.ts +3 -0
- package/components/icons/dropdownArrow.js +2 -0
- package/components/icons/dropdownArrow.js.map +1 -1
- package/components/icons/undoIcon.d.ts +2 -0
- package/components/icons/undoIcon.js +2 -0
- package/components/icons/undoIcon.js.map +1 -1
- package/components/input/autoCompleteInput.d.ts +29 -0
- package/components/input/autoCompleteInput.js +7 -0
- package/components/input/autoCompleteInput.js.map +1 -1
- package/components/input/draftUtils.d.ts +7 -0
- package/components/input/draftUtils.js +9 -0
- package/components/input/draftUtils.js.map +1 -1
- package/components/input/hexaFormattedInput.d.ts +9 -0
- package/components/input/hexaFormattedInput.js +3 -0
- package/components/input/hexaFormattedInput.js.map +1 -1
- package/components/input/mask/helpers.d.ts +27 -0
- package/components/input/mask/helpers.js +27 -0
- package/components/input/mask/helpers.js.map +1 -1
- package/components/input/mask/inputMaskCore.d.ts +80 -0
- package/components/input/mask/inputMaskCore.js +90 -0
- package/components/input/mask/inputMaskCore.js.map +1 -1
- package/components/input/mask/pattern.d.ts +24 -0
- package/components/input/mask/pattern.js +26 -0
- package/components/input/mask/pattern.js.map +1 -1
- package/components/input/maskedInput.d.ts +53 -0
- package/components/input/maskedInput.js +44 -4
- package/components/input/maskedInput.js.map +1 -1
- package/components/input/passwordInput.d.ts +7 -0
- package/components/input/passwordInput.js +8 -0
- package/components/input/passwordInput.js.map +1 -1
- package/components/input/simpleAutoComplete.d.ts +6 -0
- package/components/input/simpleAutoComplete.js +6 -0
- package/components/input/simpleAutoComplete.js.map +1 -1
- package/components/input/textarea/extractSpansOfClasses.d.ts +17 -0
- package/components/input/textarea/extractSpansOfClasses.js +26 -1
- package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
- package/components/input/textarea/getRanges.d.ts +7 -0
- package/components/input/textarea/getRanges.js +11 -0
- package/components/input/textarea/getRanges.js.map +1 -1
- package/components/input/textarea/getType.d.ts +5 -0
- package/components/input/textarea/getType.js +5 -0
- package/components/input/textarea/getType.js.map +1 -1
- package/components/input/textarea/highlighedContents.d.ts +4 -0
- package/components/input/textarea/highlighedContents.js +5 -0
- package/components/input/textarea/highlighedContents.js.map +1 -1
- package/components/input/textarea/mentionsWithHighlighting.d.ts +25 -0
- package/components/input/textarea/mentionsWithHighlighting.js +14 -0
- package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
- package/components/keyboard/keyboardUtils.d.ts +6 -0
- package/components/keyboard/keyboardUtils.js +6 -0
- package/components/keyboard/keyboardUtils.js.map +1 -1
- package/components/modal/draggableModalProvider.d.ts +6 -0
- package/components/modal/draggableModalProvider.js +7 -0
- package/components/modal/draggableModalProvider.js.map +1 -1
- package/components/modal/impl/clamp.js +1 -0
- package/components/modal/impl/clamp.js.map +1 -1
- package/components/modal/impl/draggableModal.d.ts +1 -0
- package/components/modal/impl/draggableModal.js +6 -0
- package/components/modal/impl/draggableModal.js.map +1 -1
- package/components/modal/impl/draggableModalContext.js +1 -0
- package/components/modal/impl/draggableModalContext.js.map +1 -1
- package/components/modal/impl/draggableModalInner.js +12 -1
- package/components/modal/impl/draggableModalInner.js.map +1 -1
- package/components/modal/impl/draggableModalReducer.d.ts +7 -1
- package/components/modal/impl/draggableModalReducer.js +6 -1
- package/components/modal/impl/draggableModalReducer.js.map +1 -1
- package/components/modal/impl/draggableModalStyles.d.ts +17 -0
- package/components/modal/impl/draggableModalStyles.js +157 -126
- package/components/modal/impl/draggableModalStyles.js.map +1 -1
- package/components/modal/impl/getWindowSize.js +1 -0
- package/components/modal/impl/getWindowSize.js.map +1 -1
- package/components/modal/impl/index.js +1 -0
- package/components/modal/impl/index.js.map +1 -1
- package/components/modal/impl/resizeHandle.d.ts +1 -0
- package/components/modal/impl/resizeHandle.js +4 -1
- package/components/modal/impl/resizeHandle.js.map +1 -1
- package/components/modal/impl/useDrag.js +1 -0
- package/components/modal/impl/useDrag.js.map +1 -1
- package/components/modal/impl/usePrevious.js +1 -0
- package/components/modal/impl/usePrevious.js.map +1 -1
- package/components/modal/impl/useResize.js +1 -0
- package/components/modal/impl/useResize.js.map +1 -1
- package/components/modal/modalDialog.d.ts +85 -0
- package/components/modal/modalDialog.js +80 -10
- package/components/modal/modalDialog.js.map +1 -1
- package/components/picker/enumValuePicker.d.ts +17 -0
- package/components/picker/enumValuePicker.js +4 -0
- package/components/picker/enumValuePicker.js.map +1 -1
- package/components/platformSpecific.d.ts +17 -0
- package/components/platformSpecific.js +16 -0
- package/components/platformSpecific.js.map +1 -1
- package/components/scrollTo/onlyText.d.ts +5 -0
- package/components/scrollTo/onlyText.js +5 -0
- package/components/scrollTo/onlyText.js.map +1 -1
- package/components/scrollTo/scrollTo.d.ts +56 -0
- package/components/scrollTo/scrollTo.js +40 -3
- package/components/scrollTo/scrollTo.js.map +1 -1
- package/components/style/withCss.d.ts +15 -0
- package/components/style/withCss.js +6 -0
- package/components/style/withCss.js.map +1 -1
- package/components/table/dragSortingTable.d.ts +15 -0
- package/components/table/dragSortingTable.js +12 -0
- package/components/table/dragSortingTable.js.map +1 -1
- package/components/text/impl/innerSize.js +2 -0
- package/components/text/impl/innerSize.js.map +1 -1
- package/components/text/impl/series.d.ts +10 -0
- package/components/text/impl/series.js +10 -0
- package/components/text/impl/series.js.map +1 -1
- package/components/text/impl/shallowEqual.js +1 -0
- package/components/text/impl/shallowEqual.js.map +1 -1
- package/components/text/impl/whilst.d.ts +7 -0
- package/components/text/impl/whilst.js +7 -0
- package/components/text/impl/whilst.js.map +1 -1
- package/components/text/textFit.d.ts +24 -0
- package/components/text/textFit.js +29 -1
- package/components/text/textFit.js.map +1 -1
- package/i18n/componentsLocaleHolder.d.ts +9 -0
- package/i18n/componentsLocaleHolder.js +9 -0
- package/i18n/componentsLocaleHolder.js.map +1 -1
- package/package.json +4 -3
- package/style/index.less +240 -240
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { useGridCellEditor } from "ag-grid-react";
|
|
2
2
|
import React, { useRef } from "react";
|
|
3
3
|
import { Key } from "ts-key-enum";
|
|
4
|
+
/**
|
|
5
|
+
* Base class for class-based ag-grid React cell editors. About 200 ms after mount it calls {@link focus} and
|
|
6
|
+
* then either {@link select} (editing started by Enter, double-click or API) or {@link placeCursorToEnd}
|
|
7
|
+
* (editing started by typing a printable character or pressing F2). Subclasses override these hooks and may
|
|
8
|
+
* implement {@link isCancelBeforeStart}; wrap the subclass with {@link withAgGridHooks} before registering it
|
|
9
|
+
* as an ag-grid `cellEditor`.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam P - editor props: ag-grid's `CustomCellEditorProps` plus the column's `cellEditorParams`.
|
|
12
|
+
* @typeParam S - editor state.
|
|
13
|
+
*/
|
|
4
14
|
export class DataGridCellEditorComponent extends React.Component {
|
|
15
|
+
/** Decides from `props.eventKey` whether the initial focus selects the content or places the caret at its end. */
|
|
5
16
|
constructor(props) {
|
|
6
17
|
super(props);
|
|
7
18
|
this.focusOpId = null;
|
|
@@ -27,13 +38,23 @@ export class DataGridCellEditorComponent extends React.Component {
|
|
|
27
38
|
clearTimeout(this.focusOpId);
|
|
28
39
|
}
|
|
29
40
|
}
|
|
41
|
+
/** Moves focus into the editor's input. Called once after mount; the default does nothing. */
|
|
30
42
|
focus() {
|
|
31
43
|
}
|
|
44
|
+
/** Selects the whole content of the editor's input. Called after {@link focus} when editing was not started by typing or F2; the default does nothing. */
|
|
32
45
|
select() {
|
|
33
46
|
}
|
|
47
|
+
/** Places the caret after the last character. Called after {@link focus} when editing was started by typing or F2; the default does nothing. */
|
|
34
48
|
placeCursorToEnd() {
|
|
35
49
|
}
|
|
36
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Wraps a class-based {@link DataGridCellEditorComponent} subclass into a function component usable as an
|
|
53
|
+
* ag-grid React `cellEditor`. It registers the ag-grid editor hooks via `useGridCellEditor`, forwarding
|
|
54
|
+
* `isCancelBeforeStart` to the class instance, and passes all ag-grid props (including `cellEditorParams`) through.
|
|
55
|
+
*
|
|
56
|
+
* @param Component - the editor class to wrap.
|
|
57
|
+
*/
|
|
37
58
|
export function withAgGridHooks(Component) {
|
|
38
59
|
return (props) => {
|
|
39
60
|
const componentRef = useRef(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataGridCellEditorComponent.js","sourceRoot":"","sources":["../../../../../components/grid/cell/dataGridCellEditorComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,EAAC,MAAM,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAEhC,MAAM,OAAO,2BAAgE,SAAQ,KAAK,CAAC,SAAe;IAItG,YAAY,KAAQ;QAChB,KAAK,CAAC,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"dataGridCellEditorComponent.js","sourceRoot":"","sources":["../../../../../components/grid/cell/dataGridCellEditorComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,EAAE,EAAC,MAAM,EAAC,MAAM,OAAO,CAAC;AACpC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAEhC;;;;;;;;;GASG;AACH,MAAM,OAAO,2BAAgE,SAAQ,KAAK,CAAC,SAAe;IAItG,kHAAkH;IAClH,YAAY,KAAQ;QAChB,KAAK,CAAC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AC;SACJ,CAAC,CAAC;QACH,OAAO,oBAAC,SAAS,kBAAC,GAAG,EAAE,YAAY,IAAM,KAAK,EAAI,CAAC;IACvD,CAAC,CAAC;AACN,CAAC","sourcesContent":["import {CustomCellEditorProps, useGridCellEditor} from \"ag-grid-react\";\r\nimport React, {useRef} from \"react\";\r\nimport {Key} from \"ts-key-enum\";\r\n\r\n/**\r\n * Base class for class-based ag-grid React cell editors. About 200 ms after mount it calls {@link focus} and\r\n * then either {@link select} (editing started by Enter, double-click or API) or {@link placeCursorToEnd}\r\n * (editing started by typing a printable character or pressing F2). Subclasses override these hooks and may\r\n * implement {@link isCancelBeforeStart}; wrap the subclass with {@link withAgGridHooks} before registering it\r\n * as an ag-grid `cellEditor`.\r\n *\r\n * @typeParam P - editor props: ag-grid's `CustomCellEditorProps` plus the column's `cellEditorParams`.\r\n * @typeParam S - editor state.\r\n */\r\nexport class DataGridCellEditorComponent<P extends CustomCellEditorProps, S> extends React.Component<P, S> {\r\n private focusOpId: number | null = null;\r\n private highlightAllOnFocus: boolean = true;\r\n\r\n /** Decides from `props.eventKey` whether the initial focus selects the content or places the caret at its end. */\r\n constructor(props: P) {\r\n super(props);\r\n if (!!props.eventKey && (props.eventKey.length === 1 || props.eventKey === Key.F2)) {\r\n this.highlightAllOnFocus = false;\r\n }\r\n }\r\n\r\n componentDidMount() {\r\n this.focusOpId = window.setTimeout(() => {\r\n this.focus();\r\n if (this.highlightAllOnFocus) {\r\n this.select();\r\n this.highlightAllOnFocus = false;\r\n } else {\r\n this.placeCursorToEnd();\r\n }\r\n }, 200);\r\n }\r\n\r\n componentWillUnmount() {\r\n if (this.focusOpId) {\r\n clearTimeout(this.focusOpId);\r\n }\r\n }\r\n\r\n /** Moves focus into the editor's input. Called once after mount; the default does nothing. */\r\n focus() {\r\n }\r\n\r\n /** Selects the whole content of the editor's input. Called after {@link focus} when editing was not started by typing or F2; the default does nothing. */\r\n select() {\r\n }\r\n\r\n /** Places the caret after the last character. Called after {@link focus} when editing was started by typing or F2; the default does nothing. */\r\n placeCursorToEnd() {\r\n }\r\n\r\n /**\r\n * Optional. Called by ag-grid (through {@link withAgGridHooks}) once before editing starts; returning `true`\r\n * cancels editing before the editor is shown. Use it to e.g. start editing a numeric cell only when the\r\n * user typed a digit, not a letter.\r\n */\r\n isCancelBeforeStart?(): boolean;\r\n}\r\n\r\n/**\r\n * Wraps a class-based {@link DataGridCellEditorComponent} subclass into a function component usable as an\r\n * ag-grid React `cellEditor`. It registers the ag-grid editor hooks via `useGridCellEditor`, forwarding\r\n * `isCancelBeforeStart` to the class instance, and passes all ag-grid props (including `cellEditorParams`) through.\r\n *\r\n * @param Component - the editor class to wrap.\r\n */\r\nexport function withAgGridHooks<P extends CustomCellEditorProps, S>(Component: any) {\r\n return (props: CustomCellEditorProps) => {\r\n const componentRef: React.MutableRefObject<DataGridCellEditorComponent<P, S> | null> = useRef(null);\r\n useGridCellEditor({\r\n isCancelBeforeStart: () => {\r\n return componentRef.current?.isCancelBeforeStart?.() ?? false;\r\n }\r\n });\r\n return <Component ref={componentRef} {...props} />;\r\n };\r\n}"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CustomCellEditorProps } from "ag-grid-react";
|
|
3
|
+
/**
|
|
4
|
+
* ag-grid cell editor for date-time values (registered in `DataGrid` as `dateCellEditor`), based on `DateTimeInput`.
|
|
5
|
+
* The cell value is a `UnixTime` (seconds or milliseconds, per `setUnixTimeConversion`); a falsy value (including `0`)
|
|
6
|
+
* starts as empty. Backspace/Delete start from `null`; a printable non-digit key cancels editing, a digit starts with
|
|
7
|
+
* the current value. Reports `UnixTime | null` through `onValueChange`.
|
|
8
|
+
*/
|
|
3
9
|
declare const _default: (props: CustomCellEditorProps) => React.JSX.Element;
|
|
4
10
|
export default _default;
|
|
@@ -14,10 +14,12 @@ class DateCellEditor extends DataGridCellEditorComponent {
|
|
|
14
14
|
getInitialState(props) {
|
|
15
15
|
let value;
|
|
16
16
|
if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {
|
|
17
|
+
// if backspace or delete pressed, we clear the cell
|
|
17
18
|
value = null;
|
|
18
19
|
props.onValueChange(null);
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
22
|
+
// otherwise we start with the current value
|
|
21
23
|
value = props.value ? unixTimeToMoment(props.value) : null;
|
|
22
24
|
}
|
|
23
25
|
return {
|
|
@@ -39,9 +41,11 @@ class DateCellEditor extends DataGridCellEditorComponent {
|
|
|
39
41
|
this.inputComponent = component;
|
|
40
42
|
}, size: "small", mask: this.props.mask, value: this.state.value, getPopupContainer: () => {
|
|
41
43
|
var _a, _b, _c;
|
|
44
|
+
// very nasty trick how to keep select's popup within focusable area of ag-grid cell editor popup (prevent closing cell editor when we click in select's dropdown area)
|
|
42
45
|
return ((_c = (_b = (_a = this.inputComponent) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.parentNode) !== null && _c !== void 0 ? _c : document.body);
|
|
43
46
|
}, onChange: (value) => {
|
|
44
47
|
if (KeyboardUtils.isKeyPressed(Key.Alt)) {
|
|
48
|
+
// ignore navigational keystrokes ALT+cursor arrow
|
|
45
49
|
return;
|
|
46
50
|
}
|
|
47
51
|
this.setState({ value: value });
|
|
@@ -49,5 +53,11 @@ class DateCellEditor extends DataGridCellEditorComponent {
|
|
|
49
53
|
}, style: { width: '100%', minWidth: 220 } }));
|
|
50
54
|
}
|
|
51
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* ag-grid cell editor for date-time values (registered in `DataGrid` as `dateCellEditor`), based on `DateTimeInput`.
|
|
58
|
+
* The cell value is a `UnixTime` (seconds or milliseconds, per `setUnixTimeConversion`); a falsy value (including `0`)
|
|
59
|
+
* starts as empty. Backspace/Delete start from `null`; a printable non-digit key cancels editing, a digit starts with
|
|
60
|
+
* the current value. Reports `UnixTime | null` through `onValueChange`.
|
|
61
|
+
*/
|
|
52
62
|
export default withAgGridHooks(DateCellEditor);
|
|
53
63
|
//# sourceMappingURL=dateCellEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/dateCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,aAAa,MAAM,wCAAwC,CAAC;AAEnE,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAE7E,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"dateCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/dateCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,aAAa,MAAM,wCAAwC,CAAC;AAEnE,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAE7E,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAY3F,MAAM,cAAe,SAAQ,2BAA0E;IAGnG,YAAY,KAAyC;QACjD,KAAK,CAAC,KAAK,CAAC,CAAC;QAHT,mBAAc,GAAyB,IAAI,CAAC;QAIhD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;IAED,eAAe,CAAC,KAAyC;QACrD,IAAI,KAAmB,CAAC;QAExB,IAAI,KAAK,CAAC,QAAQ,KAA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I,CAAC,cAAc,0CAAE,KAAK,0CAAE,UAAU,mCAAI,QAAQ,CAAC,IAAI,CAAgB,CAAC;YACpF,CAAC,EACD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,IAAI,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBACtC,kDAAkD;oBAClD,OAAO;gBACX,CAAC;gBACD,IAAI,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;gBAC9B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;YACnE,CAAC,EACD,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAC,GACvC,CACL,CAAC;IACN,CAAC;CACJ;AAED;;;;;GAKG;AACH,eAAe,eAAe,CAAC,cAAc,CAAC,CAAA","sourcesContent":["import React from 'react';\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport DateTimeInput from \"d2coreui/components/date/dateTimeInput\";\r\nimport {Dayjs} from \"dayjs\";\r\nimport {DateTimeUtils} from \"d2core/utils/dateTimeUtils\";\r\nimport {dayJsToUnixTime, unixTimeToMoment} from \"d2core/types/unixTimeUtils\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\n/** Props of {@link DateCellEditor}: ag-grid cell editor props plus these `cellEditorParams`. */\r\ninterface DateCellEditorProperties extends CustomCellEditorProps {\r\n /** Date-time format mask of the `DateTimeInput`. */\r\n mask: string\r\n}\r\n\r\ninterface DateCellEditorState {\r\n value: Dayjs | null\r\n}\r\n\r\nclass DateCellEditor extends DataGridCellEditorComponent<DateCellEditorProperties, DateCellEditorState> {\r\n private inputComponent: DateTimeInput | null = null;\r\n\r\n constructor(props: Readonly<DateCellEditorProperties>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<DateCellEditorProperties>): DateCellEditorState {\r\n let value: Dayjs | null;\r\n\r\n if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {\r\n // if backspace or delete pressed, we clear the cell\r\n value = null;\r\n props.onValueChange(null);\r\n } else {\r\n // otherwise we start with the current value\r\n value = props.value ? unixTimeToMoment(props.value) : null;\r\n }\r\n return {\r\n value: value,\r\n } as DateCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.inputComponent?.focus();\r\n }\r\n\r\n getValue() {\r\n return this.state.value ? DateTimeUtils.toUnixTime(this.state.value) : null;\r\n }\r\n\r\n isCancelBeforeStart(): boolean {\r\n return !!this.props.eventKey && this.props.eventKey.length === 1 && '1234567890'.indexOf(this.props.eventKey) < 0;\r\n }\r\n\r\n render() {\r\n return (\r\n <DateTimeInput\r\n ref={(component) => {\r\n this.inputComponent = component;\r\n }}\r\n size=\"small\"\r\n mask={this.props.mask}\r\n value={this.state.value}\r\n getPopupContainer={() => {\r\n // very nasty trick how to keep select's popup within focusable area of ag-grid cell editor popup (prevent closing cell editor when we click in select's dropdown area)\r\n return (this.inputComponent?.input?.parentNode ?? document.body) as HTMLElement;\r\n }}\r\n onChange={(value) => {\r\n if (KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n // ignore navigational keystrokes ALT+cursor arrow\r\n return;\r\n }\r\n this.setState({value: value});\r\n this.props.onValueChange(value ? dayJsToUnixTime(value) : null)\r\n }}\r\n style={{width: '100%', minWidth: 220}}\r\n />\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * ag-grid cell editor for date-time values (registered in `DataGrid` as `dateCellEditor`), based on `DateTimeInput`.\r\n * The cell value is a `UnixTime` (seconds or milliseconds, per `setUnixTimeConversion`); a falsy value (including `0`)\r\n * starts as empty. Backspace/Delete start from `null`; a printable non-digit key cancels editing, a digit starts with\r\n * the current value. Reports `UnixTime | null` through `onValueChange`.\r\n */\r\nexport default withAgGridHooks(DateCellEditor)"]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ag-grid feature created by `RangeSelector` (via `createDragListenerFeature(eContainer)`) for a grid body
|
|
3
|
+
* container. It registers the container as a drag source whose drag start / dragging / drag stop events drive the
|
|
4
|
+
* grid's `rangeSvc` cell range selection; the drag source is re-registered when `enableRangeSelection` or
|
|
5
|
+
* `cellSelection` change and removed when the feature is destroyed.
|
|
6
|
+
*/
|
|
1
7
|
export class DragListenerFeature extends BeanStub<"destroyed"> {
|
|
2
8
|
constructor(eContainer: any);
|
|
3
9
|
eContainer: any;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { BeanStub, _isCellSelectionEnabled } from 'ag-grid-community';
|
|
2
|
+
/**
|
|
3
|
+
* ag-grid feature created by `RangeSelector` (via `createDragListenerFeature(eContainer)`) for a grid body
|
|
4
|
+
* container. It registers the container as a drag source whose drag start / dragging / drag stop events drive the
|
|
5
|
+
* grid's `rangeSvc` cell range selection; the drag source is re-registered when `enableRangeSelection` or
|
|
6
|
+
* `cellSelection` change and removed when the feature is destroyed.
|
|
7
|
+
*/
|
|
2
8
|
export class DragListenerFeature extends BeanStub {
|
|
3
9
|
constructor(eContainer) {
|
|
4
10
|
super();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dragListenerFeature.js","sourceRoot":"","sources":["../../../../../components/grid/cell/dragListenerFeature.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,OAAO,mBAAoB,SAAQ,QAAQ;IAC7C,YAAY,UAAU;QAClB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,aAAa;QACT,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,MAAM,MAAM,GAAG;YACX,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;YAChD,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC9C,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;SACjD,CAAC;QAEF,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAClE,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAEtE,IAAI,CAAC,2BAA2B,CAAC,CAAC,sBAAsB,EAAE,eAAe,CAAC,EAAE,GAAG,EAAE;YAC7E,aAAa,EAAE,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QAEpC,aAAa,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import { BeanStub, _isCellSelectionEnabled } from 'ag-grid-community';\r\n\r\nexport class DragListenerFeature extends BeanStub {\r\n constructor(eContainer) {\r\n super();\r\n this.eContainer = eContainer;\r\n }\r\n\r\n postConstruct() {\r\n const { beans, gos, eContainer } = this;\r\n const rangeSvc = beans.rangeSvc;\r\n const params = {\r\n eElement: eContainer,\r\n onDragStart: rangeSvc.onDragStart.bind(rangeSvc),\r\n onDragStop: rangeSvc.onDragStop.bind(rangeSvc),\r\n onDragging: rangeSvc.onDragging.bind(rangeSvc),\r\n };\r\n\r\n const dragSvc = beans.dragSvc;\r\n const enableFeature = dragSvc.addDragSource.bind(dragSvc, params);\r\n const disableFeature = dragSvc.removeDragSource.bind(dragSvc, params);\r\n\r\n this.addManagedPropertyListeners(['enableRangeSelection', 'cellSelection'], () => {\r\n enableFeature();\r\n });\r\n\r\n this.addDestroyFunc(disableFeature);\r\n\r\n enableFeature();\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"file":"dragListenerFeature.js","sourceRoot":"","sources":["../../../../../components/grid/cell/dragListenerFeature.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,QAAQ;IAC7C,YAAY,UAAU;QAClB,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,aAAa;QACT,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,MAAM,MAAM,GAAG;YACX,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;YAChD,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC9C,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;SACjD,CAAC;QAEF,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAClE,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAEtE,IAAI,CAAC,2BAA2B,CAAC,CAAC,sBAAsB,EAAE,eAAe,CAAC,EAAE,GAAG,EAAE;YAC7E,aAAa,EAAE,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QAEpC,aAAa,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import { BeanStub, _isCellSelectionEnabled } from 'ag-grid-community';\r\n\r\n/**\r\n * ag-grid feature created by `RangeSelector` (via `createDragListenerFeature(eContainer)`) for a grid body\r\n * container. It registers the container as a drag source whose drag start / dragging / drag stop events drive the\r\n * grid's `rangeSvc` cell range selection; the drag source is re-registered when `enableRangeSelection` or\r\n * `cellSelection` change and removed when the feature is destroyed.\r\n */\r\nexport class DragListenerFeature extends BeanStub {\r\n constructor(eContainer) {\r\n super();\r\n this.eContainer = eContainer;\r\n }\r\n\r\n postConstruct() {\r\n const { beans, gos, eContainer } = this;\r\n const rangeSvc = beans.rangeSvc;\r\n const params = {\r\n eElement: eContainer,\r\n onDragStart: rangeSvc.onDragStart.bind(rangeSvc),\r\n onDragStop: rangeSvc.onDragStop.bind(rangeSvc),\r\n onDragging: rangeSvc.onDragging.bind(rangeSvc),\r\n };\r\n\r\n const dragSvc = beans.dragSvc;\r\n const enableFeature = dragSvc.addDragSource.bind(dragSvc, params);\r\n const disableFeature = dragSvc.removeDragSource.bind(dragSvc, params);\r\n\r\n this.addManagedPropertyListeners(['enableRangeSelection', 'cellSelection'], () => {\r\n enableFeature();\r\n });\r\n\r\n this.addDestroyFunc(disableFeature);\r\n\r\n enableFeature();\r\n }\r\n}"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CustomCellEditorProps } from "ag-grid-react";
|
|
3
|
+
/**
|
|
4
|
+
* ag-grid cell editor for durations (registered in `DataGrid` as `durationCellEditor`), based on `DurationInput`.
|
|
5
|
+
* The cell value is a number of seconds (may be fractional). Starts from `initialValue`, from the typed digit, or from
|
|
6
|
+
* `null` on Backspace/Delete; other printable keys cancel editing. Reports the duration in seconds, or `null` when
|
|
7
|
+
* cleared, through `onValueChange`. Alt+Arrow Up/Down and Ctrl+A are swallowed by the input.
|
|
8
|
+
*/
|
|
3
9
|
declare const _default: (props: CustomCellEditorProps) => React.JSX.Element;
|
|
4
10
|
export default _default;
|
|
@@ -14,15 +14,18 @@ class DurationCellEditor extends DataGridCellEditorComponent {
|
|
|
14
14
|
getInitialState(props) {
|
|
15
15
|
let value;
|
|
16
16
|
if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {
|
|
17
|
+
// if backspace or delete pressed, we clear the cell
|
|
17
18
|
value = null;
|
|
18
19
|
props.onValueChange(null);
|
|
19
20
|
}
|
|
20
21
|
else if (props.eventKey && props.eventKey.length === 1) {
|
|
22
|
+
// if a letter was pressed, we start with the letter
|
|
21
23
|
const parsedValue = Number.parseInt(props.eventKey);
|
|
22
24
|
value = isNaN(parsedValue) ? props.value : parsedValue;
|
|
23
25
|
props.onValueChange(value);
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
28
|
+
// otherwise we start with the current value
|
|
26
29
|
value = props.initialValue;
|
|
27
30
|
}
|
|
28
31
|
return { value: value };
|
|
@@ -37,6 +40,10 @@ class DurationCellEditor extends DataGridCellEditorComponent {
|
|
|
37
40
|
}
|
|
38
41
|
placeCursorToEnd() {
|
|
39
42
|
var _a, _b, _c, _d, _e;
|
|
43
|
+
// when we started editing, we want the carot at the end, not the start.
|
|
44
|
+
// this comes into play in two scenarios: a) when user hits F2 and b)
|
|
45
|
+
// when user hits a printable character, then on IE (and only IE) the carot
|
|
46
|
+
// was placed after the first character, thus 'apply' would end up as 'pplea'
|
|
40
47
|
const length = ((_b = (_a = this.inputComponent) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.value) ? (_c = this.inputComponent) === null || _c === void 0 ? void 0 : _c.input.value.length : 0;
|
|
41
48
|
if (length > 0) {
|
|
42
49
|
(_e = (_d = this.inputComponent) === null || _d === void 0 ? void 0 : _d.input) === null || _e === void 0 ? void 0 : _e.setSelectionRange(length, length);
|
|
@@ -51,6 +58,7 @@ class DurationCellEditor extends DataGridCellEditorComponent {
|
|
|
51
58
|
this.inputComponent = component;
|
|
52
59
|
}, size: "small", mask: (_a = this.props.mask) !== null && _a !== void 0 ? _a : "", value: this.state.value !== undefined && this.state.value !== null ? dayjs.duration(this.state.value * 1000) : null, onChange: (time) => {
|
|
53
60
|
if (KeyboardUtils.isKeyPressed(Key.Alt)) {
|
|
61
|
+
// ignore navigational keystrokes ALT+cursor arrow
|
|
54
62
|
return;
|
|
55
63
|
}
|
|
56
64
|
if (time) {
|
|
@@ -71,5 +79,11 @@ class DurationCellEditor extends DataGridCellEditorComponent {
|
|
|
71
79
|
}, style: { width: '100%' } }));
|
|
72
80
|
}
|
|
73
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* ag-grid cell editor for durations (registered in `DataGrid` as `durationCellEditor`), based on `DurationInput`.
|
|
84
|
+
* The cell value is a number of seconds (may be fractional). Starts from `initialValue`, from the typed digit, or from
|
|
85
|
+
* `null` on Backspace/Delete; other printable keys cancel editing. Reports the duration in seconds, or `null` when
|
|
86
|
+
* cleared, through `onValueChange`. Alt+Arrow Up/Down and Ctrl+A are swallowed by the input.
|
|
87
|
+
*/
|
|
74
88
|
export default withAgGridHooks(DurationCellEditor);
|
|
75
89
|
//# sourceMappingURL=durationCellEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durationCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/durationCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,aAAa,MAAM,wCAAwC,CAAC;AACnE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;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,CAAC,CAAA","sourcesContent":["import React from 'react';\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport {CellEditorUtils} from \"./cellEditorUtils\";\r\nimport DurationInput from \"d2coreui/components/date/durationInput\";\r\nimport dayjs from \"dayjs\";\r\nimport {Duration} from \"d2core/dayjs/duration\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\n/** Props of {@link DurationCellEditor}: ag-grid cell editor props plus these `cellEditorParams`. */\r\ninterface DurationCellEditorProperties extends CustomCellEditorProps {\r\n /**\r\n * Duration format mask of the `DurationInput`.\r\n * @default \"\"\r\n */\r\n mask?: string\r\n}\r\n\r\ninterface DurationCellEditorState {\r\n value: number | null\r\n}\r\n\r\nclass DurationCellEditor extends DataGridCellEditorComponent<DurationCellEditorProperties, DurationCellEditorState> {\r\n private inputComponent: DurationInput | null = null;\r\n\r\n constructor(props: Readonly<DurationCellEditorProperties>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<DurationCellEditorProperties>): DurationCellEditorState {\r\n let value: number | null;\r\n\r\n if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {\r\n // if backspace or delete pressed, we clear the cell\r\n value = null;\r\n props.onValueChange(null);\r\n } else if (props.eventKey && props.eventKey.length === 1) {\r\n // if a letter was pressed, we start with the letter\r\n const parsedValue = Number.parseInt(props.eventKey);\r\n value = isNaN(parsedValue) ? props.value : parsedValue;\r\n props.onValueChange(value);\r\n } else {\r\n // otherwise we start with the current value\r\n value = props.initialValue;\r\n }\r\n return {value: value} as DurationCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.inputComponent?.focus();\r\n }\r\n\r\n select() {\r\n this.inputComponent?.input?.select();\r\n }\r\n\r\n placeCursorToEnd() {\r\n // when we started editing, we want the carot at the end, not the start.\r\n // this comes into play in two scenarios: a) when user hits F2 and b)\r\n // when user hits a printable character, then on IE (and only IE) the carot\r\n // was placed after the first character, thus 'apply' would end up as 'pplea'\r\n const length = this.inputComponent?.input?.value ? this.inputComponent?.input.value.length : 0;\r\n if (length > 0) {\r\n this.inputComponent?.input?.setSelectionRange(length, length);\r\n }\r\n }\r\n\r\n isCancelBeforeStart(): boolean {\r\n return !!this.props.eventKey && this.props.eventKey.length === 1 && '1234567890'.indexOf(this.props.eventKey) < 0;\r\n }\r\n\r\n render() {\r\n return (\r\n <DurationInput\r\n ref={(component) => {\r\n this.inputComponent = component as DurationInput | null;\r\n }}\r\n size=\"small\"\r\n mask={this.props.mask ?? \"\"}\r\n value={this.state.value !== undefined && this.state.value !== null ? dayjs.duration(this.state.value * 1000) : null}\r\n onChange={(time: Duration | null) => {\r\n if (KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n // ignore navigational keystrokes ALT+cursor arrow\r\n return;\r\n }\r\n if (time) {\r\n const value = time.asMilliseconds() / 1000;\r\n this.setState({value: value});\r\n this.props.onValueChange(value);\r\n } else if (time === undefined) {\r\n this.setState({value: null});\r\n this.props.onValueChange(null);\r\n }\r\n }}\r\n onKeyDown={(e) => {\r\n if (CellEditorUtils.shouldIgnoreKeyEvent(e)) {\r\n e.preventDefault();\r\n e.nativeEvent.stopImmediatePropagation();\r\n e.nativeEvent.preventDefault();\r\n }\r\n }}\r\n style={{width: '100%'}}\r\n />\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * ag-grid cell editor for durations (registered in `DataGrid` as `durationCellEditor`), based on `DurationInput`.\r\n * The cell value is a number of seconds (may be fractional). Starts from `initialValue`, from the typed digit, or from\r\n * `null` on Backspace/Delete; other printable keys cancel editing. Reports the duration in seconds, or `null` when\r\n * cleared, through `onValueChange`. Alt+Arrow Up/Down and Ctrl+A are swallowed by the input.\r\n */\r\nexport default withAgGridHooks(DurationCellEditor)"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CustomCellEditorProps } from 'ag-grid-react';
|
|
3
|
+
/**
|
|
4
|
+
* ag-grid cell editor for an octet string written as hexadecimal bytes separated by spaces (e.g. `0A FF 12`), registered
|
|
5
|
+
* in `DataGrid` as `hexaOctetStringCellEditor`. Uses a masked input limited to `hexaStringMaxLength` octets. Starts from
|
|
6
|
+
* `initialValue` or from `null` on Backspace/Delete; a printable non-digit key cancels editing. Reports the upper-cased
|
|
7
|
+
* string (or `""` when emptied) through `onValueChange`; input containing non-hex characters is not reported.
|
|
8
|
+
*/
|
|
3
9
|
declare const _default: (props: CustomCellEditorProps) => React.JSX.Element;
|
|
4
10
|
export default _default;
|
|
@@ -12,15 +12,18 @@ class HexaOctetStringCellEditor extends DataGridCellEditorComponent {
|
|
|
12
12
|
getInitialState(props) {
|
|
13
13
|
let value;
|
|
14
14
|
if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {
|
|
15
|
+
// if backspace or delete pressed, we clear the cell
|
|
15
16
|
value = null;
|
|
16
17
|
props.onValueChange(null);
|
|
17
18
|
}
|
|
18
19
|
else if (props.eventKey && props.eventKey.length === 1) {
|
|
20
|
+
// if a letter was pressed, we start with the letter
|
|
19
21
|
const parsedValue = Number.parseInt(props.eventKey);
|
|
20
22
|
value = isNaN(parsedValue) ? props.value : parsedValue;
|
|
21
23
|
props.onValueChange(value);
|
|
22
24
|
}
|
|
23
25
|
else {
|
|
26
|
+
// otherwise we start with the current value
|
|
24
27
|
value = props.initialValue;
|
|
25
28
|
}
|
|
26
29
|
return { value: value };
|
|
@@ -35,6 +38,10 @@ class HexaOctetStringCellEditor extends DataGridCellEditorComponent {
|
|
|
35
38
|
}
|
|
36
39
|
placeCursorToEnd() {
|
|
37
40
|
var _a, _b, _c;
|
|
41
|
+
// when we started editing, we want the carot at the end, not the start.
|
|
42
|
+
// this comes into play in two scenarios: a) when user hits F2 and b)
|
|
43
|
+
// when user hits a printable character, then on IE (and only IE) the carot
|
|
44
|
+
// was placed after the first character, thus 'apply' would end up as 'pplea'
|
|
38
45
|
const length = ((_a = this.inputComponent) === null || _a === void 0 ? void 0 : _a.value) ? (_b = this.inputComponent) === null || _b === void 0 ? void 0 : _b.value.length : 0;
|
|
39
46
|
if (length > 0) {
|
|
40
47
|
(_c = this.inputComponent) === null || _c === void 0 ? void 0 : _c.setSelectionRange(length, length);
|
|
@@ -54,6 +61,7 @@ class HexaOctetStringCellEditor extends DataGridCellEditorComponent {
|
|
|
54
61
|
}, value: this.state.value !== undefined && this.state.value !== null ? this.state.value.toUpperCase() : "", onValueChange: event => {
|
|
55
62
|
const value = event.value;
|
|
56
63
|
if (KeyboardUtils.isKeyPressed(Key.Alt)) {
|
|
64
|
+
// ignore navigational keystrokes ALT+cursor arrow
|
|
57
65
|
return;
|
|
58
66
|
}
|
|
59
67
|
if (/^[0-9A-Fa-f ]+$/.test(value)) {
|
|
@@ -67,5 +75,11 @@ class HexaOctetStringCellEditor extends DataGridCellEditorComponent {
|
|
|
67
75
|
}, mask: mask.trim(), maskChar: " ", showMask: false }));
|
|
68
76
|
}
|
|
69
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* ag-grid cell editor for an octet string written as hexadecimal bytes separated by spaces (e.g. `0A FF 12`), registered
|
|
80
|
+
* in `DataGrid` as `hexaOctetStringCellEditor`. Uses a masked input limited to `hexaStringMaxLength` octets. Starts from
|
|
81
|
+
* `initialValue` or from `null` on Backspace/Delete; a printable non-digit key cancels editing. Reports the upper-cased
|
|
82
|
+
* string (or `""` when emptied) through `onValueChange`; input containing non-hex characters is not reported.
|
|
83
|
+
*/
|
|
70
84
|
export default withAgGridHooks(HexaOctetStringCellEditor);
|
|
71
85
|
//# sourceMappingURL=hexaOctetStringCellEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hexaOctetStringCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/hexaOctetStringCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO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sourcesContent":["import React from 'react';\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport MaskInput from 'react-maskinput';\r\nimport {CustomCellEditorProps} from 'ag-grid-react';\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\n/** Props of {@link HexaOctetStringCellEditor}: ag-grid cell editor props plus these `cellEditorParams`. */\r\ninterface HexaOctetStringCellEditorProps extends CustomCellEditorProps {\r\n /** Maximum number of octets (two-digit hex bytes) the input mask accepts. */\r\n hexaStringMaxLength: number\r\n}\r\n\r\ninterface HexaOctetStringCellEditorState {\r\n value: string | null\r\n}\r\n\r\nclass HexaOctetStringCellEditor extends DataGridCellEditorComponent<HexaOctetStringCellEditorProps, HexaOctetStringCellEditorState> {\r\n private inputComponent: HTMLInputElement | null = null;\r\n\r\n constructor(props: Readonly<HexaOctetStringCellEditorProps>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<HexaOctetStringCellEditorProps>): HexaOctetStringCellEditorState {\r\n let value: number | null;\r\n if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {\r\n // if backspace or delete pressed, we clear the cell\r\n value = null;\r\n props.onValueChange(null);\r\n } else if (props.eventKey && props.eventKey.length === 1) {\r\n // if a letter was pressed, we start with the letter\r\n const parsedValue = Number.parseInt(props.eventKey);\r\n value = isNaN(parsedValue) ? props.value : parsedValue;\r\n props.onValueChange(value);\r\n } else {\r\n // otherwise we start with the current value\r\n value = props.initialValue;\r\n }\r\n return {value: value} as HexaOctetStringCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.inputComponent?.focus();\r\n }\r\n\r\n select() {\r\n this.inputComponent?.select();\r\n }\r\n\r\n placeCursorToEnd() {\r\n // when we started editing, we want the carot at the end, not the start.\r\n // this comes into play in two scenarios: a) when user hits F2 and b)\r\n // when user hits a printable character, then on IE (and only IE) the carot\r\n // was placed after the first character, thus 'apply' would end up as 'pplea'\r\n const length = this.inputComponent?.value ? this.inputComponent?.value.length : 0;\r\n if (length > 0) {\r\n this.inputComponent?.setSelectionRange(length, length);\r\n }\r\n }\r\n\r\n isCancelBeforeStart(): boolean {\r\n return !!this.props.eventKey && this.props.eventKey.length === 1 && '1234567890'.indexOf(this.props.eventKey) < 0;\r\n }\r\n\r\n render() {\r\n let mask = \"\";\r\n for (let i = 0; i < this.props.hexaStringMaxLength; i++) {\r\n mask += \"** \";\r\n }\r\n\r\n return (\r\n <MaskInput\r\n getReference={component => {\r\n this.inputComponent = component;\r\n component.className = \"ant-input ant-input-sm\";\r\n }}\r\n value={this.state.value !== undefined && this.state.value !== null ? this.state.value.toUpperCase() : \"\"}\r\n onValueChange={event => {\r\n const value = event.value;\r\n if (KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n // ignore navigational keystrokes ALT+cursor arrow\r\n return;\r\n }\r\n\r\n if (/^[0-9A-Fa-f ]+$/.test(value)) {\r\n this.setState({value: value.toUpperCase()});\r\n this.props.onValueChange(value.toUpperCase());\r\n } else if (value === \"\") {\r\n this.setState({value: \"\"});\r\n this.props.onValueChange(\"\");\r\n }\r\n }}\r\n mask={mask.trim()}\r\n maskChar=\" \"\r\n showMask={false}\r\n />\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * ag-grid cell editor for an octet string written as hexadecimal bytes separated by spaces (e.g. `0A FF 12`), registered\r\n * in `DataGrid` as `hexaOctetStringCellEditor`. Uses a masked input limited to `hexaStringMaxLength` octets. Starts from\r\n * `initialValue` or from `null` on Backspace/Delete; a printable non-digit key cancels editing. Reports the upper-cased\r\n * string (or `\"\"` when emptied) through `onValueChange`; input containing non-hex characters is not reported.\r\n */\r\nexport default withAgGridHooks(HexaOctetStringCellEditor)"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CustomCellEditorProps } from "ag-grid-react";
|
|
3
|
+
/**
|
|
4
|
+
* ag-grid cell editor for an integer entered as a hexadecimal string (registered in `DataGrid` as
|
|
5
|
+
* `hexaValueCellEditor`), based on `HexaFormattedInput`. The cell value is a hex string without prefix; starts from
|
|
6
|
+
* `value` (which a `cellEditorParams.value` overrides) or from `null` on Backspace/Delete; a printable non-digit key
|
|
7
|
+
* cancels editing. Reports the hex string, or `null` when empty, through `onValueChange`.
|
|
8
|
+
*/
|
|
3
9
|
declare const _default: (props: CustomCellEditorProps) => React.JSX.Element;
|
|
4
10
|
export default _default;
|
|
@@ -12,15 +12,18 @@ class HexaValueCellEditor extends DataGridCellEditorComponent {
|
|
|
12
12
|
getInitialState(props) {
|
|
13
13
|
let value;
|
|
14
14
|
if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {
|
|
15
|
+
// if backspace or delete pressed, we clear the cell
|
|
15
16
|
value = null;
|
|
16
17
|
props.onValueChange(null);
|
|
17
18
|
}
|
|
18
19
|
else if (props.eventKey && props.eventKey.length === 1) {
|
|
20
|
+
// if a letter was pressed, we start with the letter
|
|
19
21
|
const parsedValue = Number.parseInt(props.eventKey);
|
|
20
22
|
value = isNaN(parsedValue) ? props.value : parsedValue;
|
|
21
23
|
props.onValueChange(value);
|
|
22
24
|
}
|
|
23
25
|
else {
|
|
26
|
+
// otherwise we start with the current value
|
|
24
27
|
value = props.value;
|
|
25
28
|
}
|
|
26
29
|
return { value: value };
|
|
@@ -35,6 +38,10 @@ class HexaValueCellEditor extends DataGridCellEditorComponent {
|
|
|
35
38
|
}
|
|
36
39
|
placeCursorToEnd() {
|
|
37
40
|
var _a, _b, _c, _d, _e;
|
|
41
|
+
// when we started editing, we want the carot at the end, not the start.
|
|
42
|
+
// this comes into play in two scenarios: a) when user hits F2 and b)
|
|
43
|
+
// when user hits a printable character, then on IE (and only IE) the carot
|
|
44
|
+
// was placed after the first character, thus 'apply' would end up as 'pplea'
|
|
38
45
|
const length = ((_b = (_a = this.inputComponent) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.value) ? (_c = this.inputComponent) === null || _c === void 0 ? void 0 : _c.input.value.length : 0;
|
|
39
46
|
if (length > 0) {
|
|
40
47
|
(_e = (_d = this.inputComponent) === null || _d === void 0 ? void 0 : _d.input) === null || _e === void 0 ? void 0 : _e.setSelectionRange(length, length);
|
|
@@ -49,6 +56,7 @@ class HexaValueCellEditor extends DataGridCellEditorComponent {
|
|
|
49
56
|
this.inputComponent = component;
|
|
50
57
|
}, value: (_a = this.state.value) !== null && _a !== void 0 ? _a : "", maxLength: this.props.maxLength, onChange: value => {
|
|
51
58
|
if (KeyboardUtils.isKeyPressed(Key.Alt)) {
|
|
59
|
+
// ignore navigational keystrokes ALT+cursor arrow
|
|
52
60
|
return;
|
|
53
61
|
}
|
|
54
62
|
if (value) {
|
|
@@ -62,5 +70,11 @@ class HexaValueCellEditor extends DataGridCellEditorComponent {
|
|
|
62
70
|
}, size: "small" }));
|
|
63
71
|
}
|
|
64
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* ag-grid cell editor for an integer entered as a hexadecimal string (registered in `DataGrid` as
|
|
75
|
+
* `hexaValueCellEditor`), based on `HexaFormattedInput`. The cell value is a hex string without prefix; starts from
|
|
76
|
+
* `value` (which a `cellEditorParams.value` overrides) or from `null` on Backspace/Delete; a printable non-digit key
|
|
77
|
+
* cancels editing. Reports the hex string, or `null` when empty, through `onValueChange`.
|
|
78
|
+
*/
|
|
65
79
|
export default withAgGridHooks(HexaValueCellEditor);
|
|
66
80
|
//# sourceMappingURL=hexaValueCellEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hexaValueCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/hexaValueCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,kBAAkB,MAAM,8CAA8C,CAA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AK,CAAC,SAAS,EAC/B,QAAQ,EAAE,KAAK,CAAC,EAAE;gBACd,IAAI,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;oBACtC,kDAAkD;oBAClD,OAAO;gBACX,CAAC;gBACD,IAAI,KAAK,EAAE,CAAC;oBACR,IAAI,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;oBAC9B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACpC,CAAC;qBAAM,CAAC;oBACJ,IAAI,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;oBAC7B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBACnC,CAAC;YACL,CAAC,EACD,IAAI,EAAE,OAAO,GACf,CACL,CAAA;IACL,CAAC;CACJ;AAED;;;;;GAKG;AACH,eAAe,eAAe,CAAC,mBAAmB,CAAC,CAAA","sourcesContent":["import React from 'react';\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport HexaFormattedInput from \"d2coreui/components/input/hexaFormattedInput\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\n/** Props of {@link HexaValueCellEditor}: ag-grid cell editor props plus these `cellEditorParams`. */\r\ninterface HexaValueCellEditorProps extends CustomCellEditorProps {\r\n /** Maximum number of hex digits; `HexaFormattedInput` left-pads the value with zeros to this length. */\r\n maxLength: number\r\n}\r\n\r\ninterface HexaValueCellEditorState {\r\n value: string | null\r\n}\r\n\r\nclass HexaValueCellEditor extends DataGridCellEditorComponent<HexaValueCellEditorProps, HexaValueCellEditorState> {\r\n private inputComponent: HexaFormattedInput | null = null;\r\n\r\n constructor(props: Readonly<HexaValueCellEditorProps>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<HexaValueCellEditorProps>): HexaValueCellEditorState {\r\n let value: number | null;\r\n if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {\r\n // if backspace or delete pressed, we clear the cell\r\n value = null;\r\n props.onValueChange(null);\r\n } else if (props.eventKey && props.eventKey.length === 1) {\r\n // if a letter was pressed, we start with the letter\r\n const parsedValue = Number.parseInt(props.eventKey);\r\n value = isNaN(parsedValue) ? props.value : parsedValue;\r\n props.onValueChange(value);\r\n } else {\r\n // otherwise we start with the current value\r\n value = props.value;\r\n }\r\n return {value: value} as HexaValueCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.inputComponent?.focus();\r\n }\r\n\r\n select() {\r\n this.inputComponent?.input?.select();\r\n }\r\n\r\n placeCursorToEnd() {\r\n // when we started editing, we want the carot at the end, not the start.\r\n // this comes into play in two scenarios: a) when user hits F2 and b)\r\n // when user hits a printable character, then on IE (and only IE) the carot\r\n // was placed after the first character, thus 'apply' would end up as 'pplea'\r\n const length = this.inputComponent?.input?.value ? this.inputComponent?.input.value.length : 0;\r\n if (length > 0) {\r\n this.inputComponent?.input?.setSelectionRange(length, length);\r\n }\r\n }\r\n\r\n isCancelBeforeStart(): boolean {\r\n return !!this.props.eventKey && this.props.eventKey.length === 1 && '1234567890'.indexOf(this.props.eventKey) < 0;\r\n }\r\n\r\n render() {\r\n return (\r\n <HexaFormattedInput\r\n ref={(component) => {\r\n this.inputComponent = component;\r\n }}\r\n value={this.state.value ?? \"\"}\r\n maxLength={this.props.maxLength}\r\n onChange={value => {\r\n if (KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n // ignore navigational keystrokes ALT+cursor arrow\r\n return;\r\n }\r\n if (value) {\r\n this.setState({value: value});\r\n this.props.onValueChange(value);\r\n } else {\r\n this.setState({value: null});\r\n this.props.onValueChange(null);\r\n }\r\n }}\r\n size={\"small\"}\r\n />\r\n )\r\n }\r\n}\r\n\r\n/**\r\n * ag-grid cell editor for an integer entered as a hexadecimal string (registered in `DataGrid` as\r\n * `hexaValueCellEditor`), based on `HexaFormattedInput`. The cell value is a hex string without prefix; starts from\r\n * `value` (which a `cellEditorParams.value` overrides) or from `null` on Backspace/Delete; a printable non-digit key\r\n * cancels editing. Reports the hex string, or `null` when empty, through `onValueChange`.\r\n */\r\nexport default withAgGridHooks(HexaValueCellEditor)"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CustomCellEditorProps } from "ag-grid-react";
|
|
3
|
+
/**
|
|
4
|
+
* ag-grid cell editor for numbers (registered in `DataGrid` as `numberCellEditor`), based on antd `InputNumber`.
|
|
5
|
+
* Starts from `value` (which a `cellEditorParams.value` overrides), from the typed digit, or from `null` on
|
|
6
|
+
* Backspace/Delete; typing any other printable character cancels editing before it starts. Reports `number | null`
|
|
7
|
+
* through `onValueChange`. Alt+Arrow Up/Down and Ctrl+A are swallowed by the input.
|
|
8
|
+
*/
|
|
3
9
|
declare const _default: (props: CustomCellEditorProps) => React.JSX.Element;
|
|
4
10
|
export default _default;
|
|
@@ -13,15 +13,18 @@ class NumberCellEditor extends DataGridCellEditorComponent {
|
|
|
13
13
|
getInitialState(props) {
|
|
14
14
|
let value;
|
|
15
15
|
if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {
|
|
16
|
+
// if backspace or delete pressed, we clear the cell
|
|
16
17
|
value = null;
|
|
17
18
|
props.onValueChange(null);
|
|
18
19
|
}
|
|
19
20
|
else if (props.eventKey && props.eventKey.length === 1) {
|
|
21
|
+
// if a letter was pressed, we start with the letter
|
|
20
22
|
const parsedValue = Number.parseInt(props.eventKey);
|
|
21
23
|
value = isNaN(parsedValue) ? props.value : parsedValue;
|
|
22
24
|
props.onValueChange(value);
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
27
|
+
// otherwise we start with the current value
|
|
25
28
|
value = props.value;
|
|
26
29
|
}
|
|
27
30
|
return {
|
|
@@ -38,6 +41,10 @@ class NumberCellEditor extends DataGridCellEditorComponent {
|
|
|
38
41
|
}
|
|
39
42
|
placeCursorToEnd() {
|
|
40
43
|
var _a, _b, _c;
|
|
44
|
+
// when we started editing, we want the carot at the end, not the start.
|
|
45
|
+
// this comes into play in two scenarios: a) when user hits F2 and b)
|
|
46
|
+
// when user hits a printable character, then on IE (and only IE) the carot
|
|
47
|
+
// was placed after the first character, thus 'apply' would end up as 'pplea'
|
|
41
48
|
const length = ((_a = this.inputComponent) === null || _a === void 0 ? void 0 : _a.value) ? (_b = this.inputComponent) === null || _b === void 0 ? void 0 : _b.value.length : 0;
|
|
42
49
|
if (length > 0) {
|
|
43
50
|
(_c = this.inputComponent) === null || _c === void 0 ? void 0 : _c.setSelectionRange(length, length);
|
|
@@ -51,6 +58,7 @@ class NumberCellEditor extends DataGridCellEditorComponent {
|
|
|
51
58
|
this.inputComponent = component;
|
|
52
59
|
}, size: "small", autoFocus: true, decimalSeparator: this.props.decimalSeparator, precision: this.props.precision, min: this.props.min, max: this.props.max, placeholder: this.state.value === null ? "NULL" : "", value: this.state.value !== null ? this.state.value : undefined, onChange: value => {
|
|
53
60
|
if (KeyboardUtils.isKeyPressed(Key.Alt)) {
|
|
61
|
+
// ignore navigational keystrokes ALT+cursor arrow
|
|
54
62
|
return;
|
|
55
63
|
}
|
|
56
64
|
if (typeof value === "number") {
|
|
@@ -63,6 +71,7 @@ class NumberCellEditor extends DataGridCellEditorComponent {
|
|
|
63
71
|
}
|
|
64
72
|
}, onKeyDown: (e) => {
|
|
65
73
|
if (CellEditorUtils.shouldIgnoreKeyEvent(e)) {
|
|
74
|
+
// this.props.onKeyDown(e.nativeEvent);
|
|
66
75
|
e.preventDefault();
|
|
67
76
|
e.nativeEvent.stopImmediatePropagation();
|
|
68
77
|
e.nativeEvent.preventDefault();
|
|
@@ -70,5 +79,11 @@ class NumberCellEditor extends DataGridCellEditorComponent {
|
|
|
70
79
|
}, style: { width: '100%' } }));
|
|
71
80
|
}
|
|
72
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* ag-grid cell editor for numbers (registered in `DataGrid` as `numberCellEditor`), based on antd `InputNumber`.
|
|
84
|
+
* Starts from `value` (which a `cellEditorParams.value` overrides), from the typed digit, or from `null` on
|
|
85
|
+
* Backspace/Delete; typing any other printable character cancels editing before it starts. Reports `number | null`
|
|
86
|
+
* through `onValueChange`. Alt+Arrow Up/Down and Ctrl+A are swallowed by the input.
|
|
87
|
+
*/
|
|
73
88
|
export default withAgGridHooks(NumberCellEditor);
|
|
74
89
|
//# sourceMappingURL=numberCellEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/numberCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAC,MAAM,MAAM,CAAC;AACjC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"numberCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/numberCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAC,MAAM,MAAM,CAAC;AACjC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAChC,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAmB3F,MAAM,gBAAiB,SAAQ,2BAA+E;IAG1G,YAAY,KAA2C;QACnD,KAAK,CA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AAK,QAAQ,EAAE,CAAC;oBAC5B,IAAI,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;oBAC9B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACpC,CAAC;qBAAM,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;oBACxC,IAAI,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;oBAC7B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBACnC,CAAC;YACL,CAAC,EACD,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;gBACb,IAAI,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC1C,uCAAuC;oBACvC,CAAC,CAAC,cAAc,EAAE,CAAC;oBACnB,CAAC,CAAC,WAAW,CAAC,wBAAwB,EAAE,CAAC;oBACzC,CAAC,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;gBACnC,CAAC;YACL,CAAC,EACD,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAC,GACxB,CACL,CAAC;IACN,CAAC;CACJ;AAED;;;;;GAKG;AACH,eAAe,eAAe,CAAC,gBAAgB,CAAC,CAAA","sourcesContent":["import React from 'react';\r\nimport {InputNumber} from \"antd\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport {CellEditorUtils} from \"./cellEditorUtils\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\n\r\n/** Props of {@link NumberCellEditor}: ag-grid cell editor props plus these `cellEditorParams`. */\r\ninterface NumberCellEditorProperties extends CustomCellEditorProps {\r\n /** Decimal separator of the antd `InputNumber`. */\r\n decimalSeparator?: string\r\n /** Number of decimal places the value is rounded to. */\r\n precision?: number\r\n /** Minimum allowed value. */\r\n min?: number\r\n /** Maximum allowed value. */\r\n max?: number\r\n}\r\n\r\ninterface NumericCellEditorState {\r\n value: number | null\r\n}\r\n\r\nclass NumberCellEditor extends DataGridCellEditorComponent<NumberCellEditorProperties, NumericCellEditorState> {\r\n private inputComponent: HTMLInputElement | null = null;\r\n\r\n constructor(props: Readonly<NumberCellEditorProperties>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<NumberCellEditorProperties>): NumericCellEditorState {\r\n let value: number | null;\r\n\r\n if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {\r\n // if backspace or delete pressed, we clear the cell\r\n value = null;\r\n props.onValueChange(null);\r\n } else if (props.eventKey && props.eventKey.length === 1) {\r\n // if a letter was pressed, we start with the letter\r\n const parsedValue = Number.parseInt(props.eventKey);\r\n value = isNaN(parsedValue) ? props.value : parsedValue;\r\n props.onValueChange(value);\r\n } else {\r\n // otherwise we start with the current value\r\n value = props.value;\r\n }\r\n return {\r\n value: value,\r\n } as NumericCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.inputComponent?.focus();\r\n }\r\n\r\n select() {\r\n this.inputComponent?.select();\r\n }\r\n\r\n placeCursorToEnd() {\r\n // when we started editing, we want the carot at the end, not the start.\r\n // this comes into play in two scenarios: a) when user hits F2 and b)\r\n // when user hits a printable character, then on IE (and only IE) the carot\r\n // was placed after the first character, thus 'apply' would end up as 'pplea'\r\n const length = this.inputComponent?.value ? this.inputComponent?.value.length : 0;\r\n if (length > 0) {\r\n this.inputComponent?.setSelectionRange(length, length);\r\n }\r\n }\r\n\r\n\r\n isCancelBeforeStart(): boolean {\r\n return !!this.props.eventKey && this.props.eventKey.length === 1 && '1234567890'.indexOf(this.props.eventKey) < 0;\r\n }\r\n\r\n\r\n render() {\r\n return (\r\n <InputNumber\r\n ref={(component) => {\r\n this.inputComponent = component;\r\n }}\r\n size=\"small\"\r\n autoFocus\r\n decimalSeparator={this.props.decimalSeparator}\r\n precision={this.props.precision}\r\n min={this.props.min}\r\n max={this.props.max}\r\n placeholder={this.state.value === null ? \"NULL\" : \"\"}\r\n value={this.state.value !== null ? this.state.value : undefined}\r\n onChange={value => {\r\n if (KeyboardUtils.isKeyPressed(Key.Alt)) {\r\n // ignore navigational keystrokes ALT+cursor arrow\r\n return;\r\n }\r\n if (typeof value === \"number\") {\r\n this.setState({value: value});\r\n this.props.onValueChange(value);\r\n } else if (value === null || value === \"\") {\r\n this.setState({value: null});\r\n this.props.onValueChange(null);\r\n }\r\n }}\r\n onKeyDown={(e) => {\r\n if (CellEditorUtils.shouldIgnoreKeyEvent(e)) {\r\n // this.props.onKeyDown(e.nativeEvent);\r\n e.preventDefault();\r\n e.nativeEvent.stopImmediatePropagation();\r\n e.nativeEvent.preventDefault();\r\n }\r\n }}\r\n style={{width: '100%'}}\r\n />\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * ag-grid cell editor for numbers (registered in `DataGrid` as `numberCellEditor`), based on antd `InputNumber`.\r\n * Starts from `value` (which a `cellEditorParams.value` overrides), from the typed digit, or from `null` on\r\n * Backspace/Delete; typing any other printable character cancels editing before it starts. Reports `number | null`\r\n * through `onValueChange`. Alt+Arrow Up/Down and Ctrl+A are swallowed by the input.\r\n */\r\nexport default withAgGridHooks(NumberCellEditor)"]}
|