d2coreui 23.0.52 → 23.0.54
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 +40 -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 +10 -1
- package/components/grid/columnUtils.js +11 -0
- package/components/grid/columnUtils.js.map +1 -1
- package/components/grid/config/columnTransfer.d.ts +18 -0
- package/components/grid/config/columnTransfer.js +45 -29
- 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 +361 -12
- package/components/grid/dataGrid.js +201 -28
- 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 +249 -4
- package/components/grid/extendedDataGrid.js +160 -19
- 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 +31 -0
- 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 +66 -65
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"savedIntervalsDialog.js","sourceRoot":"","sources":["../../../../components/date/savedIntervalsDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClE,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAC,MAAM,MAAM,CAAC;AAC5G,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG/D,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAClE,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAExD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACH,mBAAmB,EAEnB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EAEpB,gBAAgB,GACnB,MAAM,kBAAkB,CAAC;AAW1B,MAAM,SAAS,GAAG,YAAY,CAAC,CAAC,EAAC,KAAK,EAAE,GAAG,EAAC,EAAE,EAAE;IAC5C,OAAO;QACH,UAAU,EAAE,GAAG,C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CAAC,EAAC,GAAG,CAExF,CACJ,CACG,CACjB,CAAC;AACN,CAAC","sourcesContent":["import React, {useEffect, useMemo, useRef, useState} from \"react\";\r\nimport {Alert, Button, Col, Descriptions, Divider, Flex, Form, Input, InputNumber, Row, Select} from \"antd\";\r\nimport {DeleteOutlined, PlusOutlined} from \"@ant-design/icons\";\r\nimport {RowDataUpdatedEvent, SelectionChangedEvent, ValueGetterParams} from \"ag-grid-community\";\r\nimport {Dayjs} from \"dayjs\";\r\nimport dayjs from \"d2core/dayjs\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {LocaleHolder} from \"d2core/i18n/localeHolder\";\r\nimport {createStyles} from \"antd-style\";\r\nimport {ModalDialog, ModalDialogMode} from \"../modal/modalDialog\";\r\nimport ExtendedDataGrid from \"../grid/extendedDataGrid\";\r\nimport {DataGridColDef} from \"../grid/dataGrid\";\r\nimport DateTimeInput from \"./dateTimeInput\";\r\nimport {\r\n createEmptyInterval,\r\n IntervalBound,\r\n IntervalDateType,\r\n intervalDateTypeName,\r\n IntervalShiftUnit,\r\n intervalShiftUnitName,\r\n resolveIntervalBound,\r\n SavedInterval,\r\n validateInterval,\r\n} from \"./savedIntervals\";\r\n\r\nexport interface SavedIntervalsDialogProps {\r\n open: boolean\r\n intervals: SavedInterval[]\r\n\r\n onSave(intervals: SavedInterval[]): Promise<void> | void\r\n\r\n onCancel(): void\r\n}\r\n\r\nconst useStyles = createStyles(({token, css}) => {\r\n return {\r\n invalidRow: css`\r\n && .ag-cell {\r\n color: ${token.colorError};\r\n }\r\n `,\r\n grid: css`\r\n height: 220px;\r\n `,\r\n }\r\n});\r\n\r\nconst DATE_TYPES = [IntervalDateType.CURRENT_DAY, IntervalDateType.SELECTED_DAY];\r\nconst SHIFT_UNITS = [\r\n IntervalShiftUnit.DAY,\r\n IntervalShiftUnit.WEEK,\r\n IntervalShiftUnit.MONTH,\r\n IntervalShiftUnit.QUARTER,\r\n IntervalShiftUnit.YEAR,\r\n];\r\n\r\nexport default function SavedIntervalsDialog({open, intervals, onSave, onCancel}: SavedIntervalsDialogProps) {\r\n const {styles} = useStyles();\r\n const dateMask = LocaleHolder.getDateFormat(true);\r\n const [draft, setDraft] = useState<SavedInterval[]>(intervals);\r\n const [selectedId, setSelectedId] = useState<string | null>(intervals[0]?.id ?? null);\r\n const [saving, setSaving] = useState(false);\r\n const bodyRef = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n if (open) {\r\n setDraft(intervals);\r\n setSelectedId(intervals[0]?.id ?? null);\r\n }\r\n }, [open, intervals]);\r\n\r\n const errors = useMemo(() => {\r\n const map = new Map<string, string>();\r\n draft.forEach(interval => {\r\n const error = validateInterval(interval);\r\n if (error) {\r\n map.set(interval.id, error);\r\n }\r\n });\r\n return map;\r\n }, [draft]);\r\n\r\n const selected = draft.find(interval => interval.id === selectedId) ?? null;\r\n const dirty = JSON.stringify(draft) !== JSON.stringify(intervals);\r\n\r\n const updateSelected = (change: Partial<SavedInterval>) => {\r\n if (!selected) {\r\n return;\r\n }\r\n setDraft(draft.map(interval => interval.id === selected.id ? {...interval, ...change} : interval));\r\n };\r\n\r\n const updateBound = (edge: \"from\" | \"to\", change: Partial<IntervalBound>) => {\r\n if (!selected) {\r\n return;\r\n }\r\n updateSelected({[edge]: {...selected[edge], ...change}} as Partial<SavedInterval>);\r\n };\r\n\r\n const addInterval = () => {\r\n const interval = createEmptyInterval();\r\n setDraft([...draft, interval]);\r\n setSelectedId(interval.id);\r\n };\r\n\r\n const removeSelected = () => {\r\n if (!selected) {\r\n return;\r\n }\r\n const index = draft.findIndex(interval => interval.id === selected.id);\r\n const next = draft.filter(interval => interval.id !== selected.id);\r\n setDraft(next);\r\n setSelectedId(next[Math.min(index, next.length - 1)]?.id ?? null);\r\n };\r\n\r\n const formatBound = (bound: IntervalBound, edge: \"from\" | \"to\") => {\r\n const resolved = resolveIntervalBound(bound, edge);\r\n return resolved ? resolved.format(dateMask) : \"-\";\r\n };\r\n\r\n const boundColumns = (edge: \"from\" | \"to\", title: string): DataGridColDef[] => [\r\n {\r\n headerName: `${title} (${i18n(\"Shift Type\")})`,\r\n colId: `${edge}-shiftUnit`,\r\n group: title,\r\n initialWidth: 140,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) =>\r\n params.data ? intervalShiftUnitName(params.data[edge].shiftUnit) : \"\",\r\n },\r\n {\r\n headerName: `${title} (${i18n(\"Shift\")})`,\r\n colId: `${edge}-shift`,\r\n group: title,\r\n initialWidth: 100,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) => params.data?.[edge].shift,\r\n },\r\n {\r\n headerName: `${title} (${i18n(\"Date Type\")})`,\r\n colId: `${edge}-dateType`,\r\n group: title,\r\n initialWidth: 140,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) =>\r\n params.data ? intervalDateTypeName(params.data[edge].dateType) : \"\",\r\n },\r\n {\r\n headerName: `${title} (${i18n(\"Date\")})`,\r\n colId: `${edge}-date`,\r\n group: title,\r\n initialWidth: 130,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) => {\r\n const bound = params.data?.[edge];\r\n return bound && bound.dateType === IntervalDateType.SELECTED_DAY && bound.date\r\n ? dayjs(bound.date).format(dateMask)\r\n : \"\";\r\n },\r\n },\r\n ];\r\n\r\n const columns: DataGridColDef[] = [\r\n {\r\n headerName: i18n(\"Index\"),\r\n colId: \"index\",\r\n group: i18n(\"Basic Columns\"),\r\n initialWidth: 80,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) =>\r\n params.data ? draft.findIndex(interval => interval.id === params.data!.id) + 1 : \"\",\r\n },\r\n {\r\n headerName: i18n(\"Name\"),\r\n colId: \"name\",\r\n field: \"name\",\r\n group: i18n(\"Basic Columns\"),\r\n initialWidth: 200,\r\n },\r\n ...boundColumns(\"from\", i18n(\"From\")),\r\n ...boundColumns(\"to\", i18n(\"To\")),\r\n ];\r\n\r\n const renderBoundForm = (edge: \"from\" | \"to\", title: string) => {\r\n const bound = selected?.[edge];\r\n const selectedDay = bound?.dateType === IntervalDateType.SELECTED_DAY;\r\n return (\r\n <>\r\n <Divider orientation=\"left\" style={{margin: \"8px 0\"}}>{title}</Divider>\r\n <Row gutter={8}>\r\n <Col span={12}>\r\n <Form.Item label={i18n(\"Date Type\")}>\r\n <Select\r\n disabled={!selected}\r\n value={bound?.dateType}\r\n onChange={dateType => updateBound(edge, {dateType})}\r\n options={DATE_TYPES.map(type => ({value: type, label: intervalDateTypeName(type)}))}\r\n />\r\n </Form.Item>\r\n <Form.Item label={i18n(\"Shift Type\")}>\r\n <Select\r\n disabled={!selected}\r\n value={bound?.shiftUnit}\r\n onChange={shiftUnit => updateBound(edge, {shiftUnit})}\r\n options={SHIFT_UNITS.map(unit => ({value: unit, label: intervalShiftUnitName(unit)}))}\r\n />\r\n </Form.Item>\r\n </Col>\r\n <Col span={12}>\r\n <Form.Item label={i18n(\"Date\")}>\r\n <DateTimeInput\r\n mask={dateMask}\r\n allowClear\r\n disabled={!selected || !selectedDay}\r\n value={selectedDay && bound?.date ? dayjs(bound.date) : null}\r\n getPopupContainer={() => bodyRef.current ?? document.body}\r\n onChange={(value: Dayjs | null) => updateBound(edge, {date: value ? value.toISOString() : null})}\r\n />\r\n </Form.Item>\r\n <Form.Item label={i18n(\"Shift\")}>\r\n <InputNumber\r\n style={{width: \"100%\"}}\r\n disabled={!selected}\r\n precision={0}\r\n value={bound?.shift}\r\n onChange={shift => updateBound(edge, {shift: shift ?? 0})}\r\n />\r\n </Form.Item>\r\n </Col>\r\n </Row>\r\n </>\r\n );\r\n };\r\n\r\n const close = () => {\r\n if (!dirty) {\r\n onCancel();\r\n return;\r\n }\r\n ModalDialog.confirm({\r\n mode: ModalDialogMode.YES_NO,\r\n title: i18n(\"Discard changes?\"),\r\n content: i18n(\"The saved intervals have been changed. Close the dialog without saving?\"),\r\n onOk: onCancel,\r\n });\r\n };\r\n\r\n return (\r\n <ModalDialog\r\n mode={ModalDialogMode.OK_CANCEL}\r\n open={open}\r\n title={i18n(\"Saved Intervals Configuration\")}\r\n initialWidth={1000}\r\n initialHeight={800}\r\n okText={i18n(\"Save\")}\r\n okButtonProps={{disabled: errors.size > 0}}\r\n confirmLoading={saving}\r\n onOk={async () => {\r\n setSaving(true);\r\n try {\r\n await onSave(draft);\r\n } finally {\r\n setSaving(false);\r\n }\r\n }}\r\n onCancel={close}\r\n >\r\n <Flex vertical ref={bodyRef} style={{position: \"relative\"}}>\r\n <div className={styles.grid}>\r\n <ExtendedDataGrid<SavedInterval>\r\n panelStyle={{padding: 0}}\r\n defaultGridConfiguration={{pageSize: -1}}\r\n onLoadData={(callback) => callback(draft.length)}\r\n onRowDataUpdated={(event: RowDataUpdatedEvent<SavedInterval>) => {\r\n if (event.api.getDisplayedRowCount() > 0) {\r\n event.api.hideOverlay();\r\n } else {\r\n event.api.showNoRowsOverlay();\r\n }\r\n\r\n const node = selectedId ? event.api.getRowNode(selectedId) : null;\r\n\r\n if (node && !node.isSelected()) {\r\n node.setSelected(true, true);\r\n }\r\n }}\r\n columnDefs={columns}\r\n rowData={draft}\r\n rowSelection={\"single\"}\r\n selectedIds={selectedId ? [selectedId] : []}\r\n onSelectionChanged={(event: SelectionChangedEvent<SavedInterval>) =>\r\n setSelectedId(event.api.getSelectedRows()[0]?.id ?? null)}\r\n rowClassRules={{\r\n [styles.invalidRow]: (params) => !!params.data && errors.has(params.data.id),\r\n }}\r\n toolbar={{\r\n toolbarButtons: (\r\n <>\r\n <Button icon={<PlusOutlined/>} onClick={addInterval}/>\r\n <Button icon={<DeleteOutlined/>} disabled={!selected} onClick={removeSelected}/>\r\n </>\r\n ),\r\n }}\r\n />\r\n </div>\r\n <Form layout=\"horizontal\" labelCol={{flex: \"110px\"}} labelAlign=\"left\" labelWrap\r\n style={{marginTop: 12}}>\r\n <Form.Item label={i18n(\"Name\")}>\r\n <Input\r\n disabled={!selected}\r\n value={selected?.name ?? \"\"}\r\n onChange={event => updateSelected({name: event.target.value})}\r\n />\r\n </Form.Item>\r\n {renderBoundForm(\"from\", i18n(\"From\"))}\r\n {renderBoundForm(\"to\", i18n(\"To\"))}\r\n <Divider orientation=\"left\" style={{margin: \"8px 0\"}}>{i18n(\"Result\")}</Divider>\r\n <Descriptions\r\n column={2}\r\n size=\"small\"\r\n items={[\r\n {\r\n key: \"from\",\r\n label: i18n(\"From\"),\r\n children: selected ? formatBound(selected.from, \"from\") : \"-\",\r\n },\r\n {\r\n key: \"to\",\r\n label: i18n(\"To\"),\r\n children: selected ? formatBound(selected.to, \"to\") : \"-\",\r\n },\r\n ]}\r\n />\r\n {selected && errors.has(selected.id) &&\r\n <Alert type=\"error\" showIcon message={errors.get(selected.id)} style={{marginTop: 8}}/>\r\n }\r\n </Form>\r\n </Flex>\r\n </ModalDialog>\r\n );\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"savedIntervalsDialog.js","sourceRoot":"","sources":["../../../../components/date/savedIntervalsDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClE,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAC,MAAM,MAAM,CAAC;AAC5G,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAG/D,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAClE,OAAO,gBAAgB,MAAM,0BAA0B,CAAC;AAExD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,E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CAAC,CAAC,GAAG;yBAC5D;qBACJ,GACH;gBACD,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAChC,oBAAC,KAAK,IAAC,IAAI,EAAC,OAAO,EAAC,QAAQ,QAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAC,SAAS,EAAE,CAAC,EAAC,GAAG,CAExF,CACJ,CACG,CACjB,CAAC;AACN,CAAC","sourcesContent":["import React, {useEffect, useMemo, useRef, useState} from \"react\";\r\nimport {Alert, Button, Col, Descriptions, Divider, Flex, Form, Input, InputNumber, Row, Select} from \"antd\";\r\nimport {DeleteOutlined, PlusOutlined} from \"@ant-design/icons\";\r\nimport {RowDataUpdatedEvent, SelectionChangedEvent, ValueGetterParams} from \"ag-grid-community\";\r\nimport {Dayjs} from \"dayjs\";\r\nimport dayjs from \"d2core/dayjs\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {LocaleHolder} from \"d2core/i18n/localeHolder\";\r\nimport {createStyles} from \"antd-style\";\r\nimport {ModalDialog, ModalDialogMode} from \"../modal/modalDialog\";\r\nimport ExtendedDataGrid from \"../grid/extendedDataGrid\";\r\nimport {DataGridColDef} from \"../grid/dataGrid\";\r\nimport DateTimeInput from \"./dateTimeInput\";\r\nimport {\r\n createEmptyInterval,\r\n IntervalBound,\r\n IntervalDateType,\r\n intervalDateTypeName,\r\n IntervalShiftUnit,\r\n intervalShiftUnitName,\r\n resolveIntervalBound,\r\n SavedInterval,\r\n validateInterval,\r\n} from \"./savedIntervals\";\r\n\r\n/** Props of {@link SavedIntervalsDialog}. */\r\nexport interface SavedIntervalsDialogProps {\r\n /** Whether the dialog is shown; on opening, the edited copy is reset to {@link SavedIntervalsDialogProps.intervals}. */\r\n open: boolean\r\n /** Intervals to edit; the dialog works on a copy and never modifies this array. */\r\n intervals: SavedInterval[]\r\n\r\n /**\r\n * Called with the edited list when \"Save\" is clicked (disabled while any interval is invalid). The OK button\r\n * shows a spinner until the returned promise settles; the dialog does not close itself - the caller sets `open`.\r\n */\r\n onSave(intervals: SavedInterval[]): Promise<void> | void\r\n\r\n /** Called when the dialog is dismissed - immediately without changes, or after the user confirms discarding them. */\r\n onCancel(): void\r\n}\r\n\r\nconst useStyles = createStyles(({token, css}) => {\r\n return {\r\n invalidRow: css`\r\n && .ag-cell {\r\n color: ${token.colorError};\r\n }\r\n `,\r\n grid: css`\r\n height: 220px;\r\n `,\r\n }\r\n});\r\n\r\nconst DATE_TYPES = [IntervalDateType.CURRENT_DAY, IntervalDateType.SELECTED_DAY];\r\nconst SHIFT_UNITS = [\r\n IntervalShiftUnit.DAY,\r\n IntervalShiftUnit.WEEK,\r\n IntervalShiftUnit.MONTH,\r\n IntervalShiftUnit.QUARTER,\r\n IntervalShiftUnit.YEAR,\r\n];\r\n\r\n/**\r\n * Modal editor of {@link SavedInterval}s: a grid of intervals with add/remove, a form for the selected one and\r\n * a preview of its resolved dates. Invalid intervals (see {@link validateInterval}) are highlighted and block saving.\r\n * Must be rendered inside a `DraggableModalProvider`, like any {@link ModalDialog}.\r\n */\r\nexport default function SavedIntervalsDialog({open, intervals, onSave, onCancel}: SavedIntervalsDialogProps) {\r\n const {styles} = useStyles();\r\n const dateMask = LocaleHolder.getDateFormat(true);\r\n const [draft, setDraft] = useState<SavedInterval[]>(intervals);\r\n const [selectedId, setSelectedId] = useState<string | null>(intervals[0]?.id ?? null);\r\n const [saving, setSaving] = useState(false);\r\n const bodyRef = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n if (open) {\r\n setDraft(intervals);\r\n setSelectedId(intervals[0]?.id ?? null);\r\n }\r\n }, [open, intervals]);\r\n\r\n const errors = useMemo(() => {\r\n const map = new Map<string, string>();\r\n draft.forEach(interval => {\r\n const error = validateInterval(interval);\r\n if (error) {\r\n map.set(interval.id, error);\r\n }\r\n });\r\n return map;\r\n }, [draft]);\r\n\r\n const selected = draft.find(interval => interval.id === selectedId) ?? null;\r\n const dirty = JSON.stringify(draft) !== JSON.stringify(intervals);\r\n\r\n const updateSelected = (change: Partial<SavedInterval>) => {\r\n if (!selected) {\r\n return;\r\n }\r\n setDraft(draft.map(interval => interval.id === selected.id ? {...interval, ...change} : interval));\r\n };\r\n\r\n const updateBound = (edge: \"from\" | \"to\", change: Partial<IntervalBound>) => {\r\n if (!selected) {\r\n return;\r\n }\r\n updateSelected({[edge]: {...selected[edge], ...change}} as Partial<SavedInterval>);\r\n };\r\n\r\n const addInterval = () => {\r\n const interval = createEmptyInterval();\r\n setDraft([...draft, interval]);\r\n setSelectedId(interval.id);\r\n };\r\n\r\n const removeSelected = () => {\r\n if (!selected) {\r\n return;\r\n }\r\n const index = draft.findIndex(interval => interval.id === selected.id);\r\n const next = draft.filter(interval => interval.id !== selected.id);\r\n setDraft(next);\r\n setSelectedId(next[Math.min(index, next.length - 1)]?.id ?? null);\r\n };\r\n\r\n const formatBound = (bound: IntervalBound, edge: \"from\" | \"to\") => {\r\n const resolved = resolveIntervalBound(bound, edge);\r\n return resolved ? resolved.format(dateMask) : \"-\";\r\n };\r\n\r\n const boundColumns = (edge: \"from\" | \"to\", title: string): DataGridColDef[] => [\r\n {\r\n headerName: `${title} (${i18n(\"Shift Type\")})`,\r\n colId: `${edge}-shiftUnit`,\r\n group: title,\r\n initialWidth: 140,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) =>\r\n params.data ? intervalShiftUnitName(params.data[edge].shiftUnit) : \"\",\r\n },\r\n {\r\n headerName: `${title} (${i18n(\"Shift\")})`,\r\n colId: `${edge}-shift`,\r\n group: title,\r\n initialWidth: 100,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) => params.data?.[edge].shift,\r\n },\r\n {\r\n headerName: `${title} (${i18n(\"Date Type\")})`,\r\n colId: `${edge}-dateType`,\r\n group: title,\r\n initialWidth: 140,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) =>\r\n params.data ? intervalDateTypeName(params.data[edge].dateType) : \"\",\r\n },\r\n {\r\n headerName: `${title} (${i18n(\"Date\")})`,\r\n colId: `${edge}-date`,\r\n group: title,\r\n initialWidth: 130,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) => {\r\n const bound = params.data?.[edge];\r\n return bound && bound.dateType === IntervalDateType.SELECTED_DAY && bound.date\r\n ? dayjs(bound.date).format(dateMask)\r\n : \"\";\r\n },\r\n },\r\n ];\r\n\r\n const columns: DataGridColDef[] = [\r\n {\r\n headerName: i18n(\"Index\"),\r\n colId: \"index\",\r\n group: i18n(\"Basic Columns\"),\r\n initialWidth: 80,\r\n valueGetter: (params: ValueGetterParams<SavedInterval>) =>\r\n params.data ? draft.findIndex(interval => interval.id === params.data!.id) + 1 : \"\",\r\n },\r\n {\r\n headerName: i18n(\"Name\"),\r\n colId: \"name\",\r\n field: \"name\",\r\n group: i18n(\"Basic Columns\"),\r\n initialWidth: 200,\r\n },\r\n ...boundColumns(\"from\", i18n(\"From\")),\r\n ...boundColumns(\"to\", i18n(\"To\")),\r\n ];\r\n\r\n const renderBoundForm = (edge: \"from\" | \"to\", title: string) => {\r\n const bound = selected?.[edge];\r\n const selectedDay = bound?.dateType === IntervalDateType.SELECTED_DAY;\r\n return (\r\n <>\r\n <Divider orientation=\"left\" style={{margin: \"8px 0\"}}>{title}</Divider>\r\n <Row gutter={8}>\r\n <Col span={12}>\r\n <Form.Item label={i18n(\"Date Type\")}>\r\n <Select\r\n disabled={!selected}\r\n value={bound?.dateType}\r\n onChange={dateType => updateBound(edge, {dateType})}\r\n options={DATE_TYPES.map(type => ({value: type, label: intervalDateTypeName(type)}))}\r\n />\r\n </Form.Item>\r\n <Form.Item label={i18n(\"Shift Type\")}>\r\n <Select\r\n disabled={!selected}\r\n value={bound?.shiftUnit}\r\n onChange={shiftUnit => updateBound(edge, {shiftUnit})}\r\n options={SHIFT_UNITS.map(unit => ({value: unit, label: intervalShiftUnitName(unit)}))}\r\n />\r\n </Form.Item>\r\n </Col>\r\n <Col span={12}>\r\n <Form.Item label={i18n(\"Date\")}>\r\n <DateTimeInput\r\n mask={dateMask}\r\n allowClear\r\n disabled={!selected || !selectedDay}\r\n value={selectedDay && bound?.date ? dayjs(bound.date) : null}\r\n getPopupContainer={() => bodyRef.current ?? document.body}\r\n onChange={(value: Dayjs | null) => updateBound(edge, {date: value ? value.toISOString() : null})}\r\n />\r\n </Form.Item>\r\n <Form.Item label={i18n(\"Shift\")}>\r\n <InputNumber\r\n style={{width: \"100%\"}}\r\n disabled={!selected}\r\n precision={0}\r\n value={bound?.shift}\r\n onChange={shift => updateBound(edge, {shift: shift ?? 0})}\r\n />\r\n </Form.Item>\r\n </Col>\r\n </Row>\r\n </>\r\n );\r\n };\r\n\r\n const close = () => {\r\n if (!dirty) {\r\n onCancel();\r\n return;\r\n }\r\n ModalDialog.confirm({\r\n mode: ModalDialogMode.YES_NO,\r\n title: i18n(\"Discard changes?\"),\r\n content: i18n(\"The saved intervals have been changed. Close the dialog without saving?\"),\r\n onOk: onCancel,\r\n });\r\n };\r\n\r\n return (\r\n <ModalDialog\r\n mode={ModalDialogMode.OK_CANCEL}\r\n open={open}\r\n title={i18n(\"Saved Intervals Configuration\")}\r\n initialWidth={1000}\r\n initialHeight={800}\r\n okText={i18n(\"Save\")}\r\n okButtonProps={{disabled: errors.size > 0}}\r\n confirmLoading={saving}\r\n onOk={async () => {\r\n setSaving(true);\r\n try {\r\n await onSave(draft);\r\n } finally {\r\n setSaving(false);\r\n }\r\n }}\r\n onCancel={close}\r\n >\r\n <Flex vertical ref={bodyRef} style={{position: \"relative\"}}>\r\n <div className={styles.grid}>\r\n <ExtendedDataGrid<SavedInterval>\r\n panelStyle={{padding: 0}}\r\n defaultGridConfiguration={{pageSize: -1}}\r\n onLoadData={(callback) => callback(draft.length)}\r\n onRowDataUpdated={(event: RowDataUpdatedEvent<SavedInterval>) => {\r\n if (event.api.getDisplayedRowCount() > 0) {\r\n event.api.hideOverlay();\r\n } else {\r\n event.api.showNoRowsOverlay();\r\n }\r\n\r\n const node = selectedId ? event.api.getRowNode(selectedId) : null;\r\n\r\n if (node && !node.isSelected()) {\r\n node.setSelected(true, true);\r\n }\r\n }}\r\n columnDefs={columns}\r\n rowData={draft}\r\n rowSelection={\"single\"}\r\n selectedIds={selectedId ? [selectedId] : []}\r\n onSelectionChanged={(event: SelectionChangedEvent<SavedInterval>) =>\r\n setSelectedId(event.api.getSelectedRows()[0]?.id ?? null)}\r\n rowClassRules={{\r\n [styles.invalidRow]: (params) => !!params.data && errors.has(params.data.id),\r\n }}\r\n toolbar={{\r\n toolbarButtons: (\r\n <>\r\n <Button icon={<PlusOutlined/>} onClick={addInterval}/>\r\n <Button icon={<DeleteOutlined/>} disabled={!selected} onClick={removeSelected}/>\r\n </>\r\n ),\r\n }}\r\n />\r\n </div>\r\n <Form layout=\"horizontal\" labelCol={{flex: \"110px\"}} labelAlign=\"left\" labelWrap\r\n style={{marginTop: 12}}>\r\n <Form.Item label={i18n(\"Name\")}>\r\n <Input\r\n disabled={!selected}\r\n value={selected?.name ?? \"\"}\r\n onChange={event => updateSelected({name: event.target.value})}\r\n />\r\n </Form.Item>\r\n {renderBoundForm(\"from\", i18n(\"From\"))}\r\n {renderBoundForm(\"to\", i18n(\"To\"))}\r\n <Divider orientation=\"left\" style={{margin: \"8px 0\"}}>{i18n(\"Result\")}</Divider>\r\n <Descriptions\r\n column={2}\r\n size=\"small\"\r\n items={[\r\n {\r\n key: \"from\",\r\n label: i18n(\"From\"),\r\n children: selected ? formatBound(selected.from, \"from\") : \"-\",\r\n },\r\n {\r\n key: \"to\",\r\n label: i18n(\"To\"),\r\n children: selected ? formatBound(selected.to, \"to\") : \"-\",\r\n },\r\n ]}\r\n />\r\n {selected && errors.has(selected.id) &&\r\n <Alert type=\"error\" showIcon message={errors.get(selected.id)} style={{marginTop: 8}}/>\r\n }\r\n </Form>\r\n </Flex>\r\n </ModalDialog>\r\n );\r\n}\r\n"]}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import React, { CSSProperties } from "react";
|
|
2
2
|
import { FormItemProps } from "antd";
|
|
3
3
|
import "../../style/form/niceFormItem.css";
|
|
4
|
+
/** Props of {@link NiceFormItem}; all other props are passed to antd `Form.Item`. */
|
|
4
5
|
export interface NiceFormItemProps extends FormItemProps {
|
|
6
|
+
/** Wraps the children in a bordered box. */
|
|
5
7
|
border?: boolean;
|
|
8
|
+
/** Marks the item as disabled; it does not disable the wrapped control (set `disabled` on the control itself). */
|
|
6
9
|
disabled?: boolean;
|
|
10
|
+
/** Style of the floating label. */
|
|
7
11
|
labelStyle?: CSSProperties;
|
|
8
12
|
}
|
|
13
|
+
/** State of {@link NiceFormItem} (empty). */
|
|
9
14
|
export interface NiceFormItemState {
|
|
10
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* antd `Form.Item` whose `label` is rendered as a floating label over the control
|
|
18
|
+
* instead of the standard antd label.
|
|
19
|
+
*/
|
|
11
20
|
export declare class NiceFormItem extends React.Component<NiceFormItemProps, NiceFormItemState> {
|
|
12
21
|
constructor(props: Readonly<NiceFormItemProps> | NiceFormItemProps);
|
|
13
22
|
render(): React.JSX.Element;
|
|
@@ -12,6 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React from "react";
|
|
13
13
|
import { Form } from "antd";
|
|
14
14
|
import "../../style/form/niceFormItem.css";
|
|
15
|
+
/**
|
|
16
|
+
* antd `Form.Item` whose `label` is rendered as a floating label over the control
|
|
17
|
+
* instead of the standard antd label.
|
|
18
|
+
*/
|
|
15
19
|
export class NiceFormItem extends React.Component {
|
|
16
20
|
constructor(props) {
|
|
17
21
|
super(props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NiceFormItem.js","sourceRoot":"","sources":["../../../../components/form/NiceFormItem.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AACtD,OAAO,EAAC,IAAI,EAAgB,MAAM,MAAM,CAAA;AACxC,OAAO,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"NiceFormItem.js","sourceRoot":"","sources":["../../../../components/form/NiceFormItem.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAiC,MAAM,OAAO,CAAC;AACtD,OAAO,EAAC,IAAI,EAAgB,MAAM,MAAM,CAAA;AACxC,OAAO,mCAAmC,CAAA;AAgB1C;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK,CAAC,SAA+C;IACnF,YAAY,KAAsD;QAC9D,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,MAAM;QACF,MAAM,KAAsE,IAAI,CAAC,KAAK,EAAhF,EAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,OAAuB,EAAlB,IAAI,cAAlE,sEAAmE,CAAa,CAAC;QACvF,MAAM,WAAW,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,mBAAK,UAAU,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACjF,MAAM,UAAU,GAAG,gBAAgB,GAAG,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,CAAA;QAEvD,OAAO,CACH,oBAAC,IAAI,CAAC,IAAI,oBAAK,IAAI,IAAE,SAAS,EAAE,UAAU;YACtC,6BAAK,SAAS,EAAC,kBAAkB;gBAC5B,CAAC,MAAM,CAAC,CAAC,CAAC,iCAAS,SAAS,EAAC,oBAAoB,IAAE,QAAqB,CAAW,CAAC,CAAC,CAAC,QAAQ,CAAc;gBAC7G,+BAAO,SAAS,EAAC,6BAA6B,EAAC,KAAK,EAAE,WAAW,IAAG,KAAK,CAAS,CAChF,CACE,CAAC,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import React, {CSSProperties, ReactNode} from \"react\";\r\nimport {Form, FormItemProps} from \"antd\"\r\nimport \"../../style/form/niceFormItem.css\"\r\n\r\n/** Props of {@link NiceFormItem}; all other props are passed to antd `Form.Item`. */\r\nexport interface NiceFormItemProps extends FormItemProps {\r\n /** Wraps the children in a bordered box. */\r\n border?: boolean\r\n /** Marks the item as disabled; it does not disable the wrapped control (set `disabled` on the control itself). */\r\n disabled?: boolean\r\n /** Style of the floating label. */\r\n labelStyle?: CSSProperties\r\n}\r\n\r\n/** State of {@link NiceFormItem} (empty). */\r\nexport interface NiceFormItemState {\r\n}\r\n\r\n/**\r\n * antd `Form.Item` whose `label` is rendered as a floating label over the control\r\n * instead of the standard antd label.\r\n */\r\nexport class NiceFormItem extends React.Component<NiceFormItemProps, NiceFormItemState> {\r\n constructor(props: Readonly<NiceFormItemProps> | NiceFormItemProps) {\r\n super(props);\r\n }\r\n\r\n render() {\r\n const {label, children, border, disabled, className, labelStyle, ...rest} = this.props;\r\n const eLabelStyle = !!labelStyle ? {...labelStyle} : (disabled ? {} : undefined);\r\n const classNames = \"nice-form-item\" + (className ?? \"\")\r\n \r\n return (\r\n <Form.Item {...rest} className={classNames}>\r\n <div className=\"nice-float-label\">\r\n {(border ? <section className=\"nice-form-item-box\">{children as ReactNode}</section> : children) as ReactNode}\r\n <label className=\"nice-label nice-label-float\" style={eLabelStyle}>{label}</label>\r\n </div>\r\n </Form.Item>);\r\n }\r\n}"]}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { BeanCollection, BeanStub, GridApi, NamedBean } from "ag-grid-community";
|
|
2
|
+
/**
|
|
3
|
+
* ag-grid {@link GridApi} augmented with the grid's internal bean collection, which {@link BeanAccessor}
|
|
4
|
+
* attaches to it. Only available on grids that register {@link BeanAccessor} (such as `DataGrid`).
|
|
5
|
+
*/
|
|
2
6
|
export interface GridApiWithPrivateAccess extends GridApi {
|
|
7
|
+
/** ag-grid's internal (non-public) service beans, e.g. `gos` or `ctrlsSvc`; their API may change between ag-grid versions. */
|
|
3
8
|
beans: BeanCollection;
|
|
4
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* ag-grid bean that exposes the grid's internal {@link BeanCollection} as `gridApi.beans`
|
|
12
|
+
* (see {@link GridApiWithPrivateAccess}). Register it in a module's `beans` list, as `DataGrid` does.
|
|
13
|
+
*/
|
|
5
14
|
export default class BeanAccessor extends BeanStub implements NamedBean {
|
|
15
|
+
/** Bean name under which ag-grid registers this bean. */
|
|
6
16
|
beanName: "beanAccessor";
|
|
17
|
+
/** Called by ag-grid during bean wiring; stores `beans` on `beans.gridApi`. */
|
|
7
18
|
wireBeans(beans: BeanCollection): void;
|
|
19
|
+
/** ag-grid lifecycle hook; does nothing. */
|
|
8
20
|
postConstruct(): void;
|
|
9
21
|
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { BeanStub } from "ag-grid-community";
|
|
2
|
+
/**
|
|
3
|
+
* ag-grid bean that exposes the grid's internal {@link BeanCollection} as `gridApi.beans`
|
|
4
|
+
* (see {@link GridApiWithPrivateAccess}). Register it in a module's `beans` list, as `DataGrid` does.
|
|
5
|
+
*/
|
|
2
6
|
export default class BeanAccessor extends BeanStub {
|
|
3
7
|
constructor() {
|
|
4
8
|
super(...arguments);
|
|
9
|
+
/** Bean name under which ag-grid registers this bean. */
|
|
10
|
+
// @ts-ignore
|
|
5
11
|
this.beanName = "beanAccessor";
|
|
6
12
|
}
|
|
13
|
+
/** Called by ag-grid during bean wiring; stores `beans` on `beans.gridApi`. */
|
|
7
14
|
wireBeans(beans) {
|
|
8
15
|
beans.gridApi.beans = beans;
|
|
9
16
|
}
|
|
17
|
+
/** ag-grid lifecycle hook; does nothing. */
|
|
10
18
|
postConstruct() {
|
|
11
19
|
}
|
|
12
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beanAccessor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/beanAccessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAqB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"beanAccessor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/beanAccessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,QAAQ,EAAqB,MAAM,mBAAmB,CAAC;AAW/E;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,QAAQ;IAAlD;;QACI,yDAAyD;QACzD,aAAa;QACb,aAAQ,GAAG,cAAuB,CAAA;IAUtC,CAAC;IARG,+EAA+E;IACxE,SAAS,CAAC,KAAqB;QACjC,KAAK,CAAC,OAAoC,CAAC,KAAK,GAAG,KAAK,CAAC;IAC9D,CAAC;IAED,4CAA4C;IACrC,aAAa;IACpB,CAAC;CACJ","sourcesContent":["import {BeanCollection, BeanStub, GridApi, NamedBean} from \"ag-grid-community\";\r\n\r\n/**\r\n * ag-grid {@link GridApi} augmented with the grid's internal bean collection, which {@link BeanAccessor}\r\n * attaches to it. Only available on grids that register {@link BeanAccessor} (such as `DataGrid`).\r\n */\r\nexport interface GridApiWithPrivateAccess extends GridApi {\r\n /** ag-grid's internal (non-public) service beans, e.g. `gos` or `ctrlsSvc`; their API may change between ag-grid versions. */\r\n beans: BeanCollection;\r\n}\r\n\r\n/**\r\n * ag-grid bean that exposes the grid's internal {@link BeanCollection} as `gridApi.beans`\r\n * (see {@link GridApiWithPrivateAccess}). Register it in a module's `beans` list, as `DataGrid` does.\r\n */\r\nexport default class BeanAccessor extends BeanStub implements NamedBean {\r\n /** Bean name under which ag-grid registers this bean. */\r\n // @ts-ignore\r\n beanName = \"beanAccessor\" as const\r\n\r\n /** Called by ag-grid during bean wiring; stores `beans` on `beans.gridApi`. */\r\n public wireBeans(beans: BeanCollection) {\r\n (beans.gridApi as GridApiWithPrivateAccess).beans = beans;\r\n }\r\n\r\n /** ag-grid lifecycle hook; does nothing. */\r\n public postConstruct(): void {\r\n }\r\n}"]}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CustomCellEditorProps } from "ag-grid-react";
|
|
3
|
+
/** Smallest signed 64-bit integer; the default lower bound of `bigNumberCellEditor`. */
|
|
3
4
|
export declare const MIN_SIGNED_64_BIT_INT: bigint;
|
|
5
|
+
/** Largest signed 64-bit integer; the default upper bound of `bigNumberCellEditor`. */
|
|
4
6
|
export declare const MAX_SIGNED_64_BIT_INT: bigint;
|
|
7
|
+
/**
|
|
8
|
+
* ag-grid cell editor for 64-bit integers (registered in `DataGrid` as `bigNumberCellEditor`), based on antd
|
|
9
|
+
* `InputNumber` in string mode. Starts like `numberCellEditor` (from `value`, the typed digit, or `null` on
|
|
10
|
+
* Backspace/Delete; other printable keys cancel editing). Reports through `onValueChange` a `number` when the integer
|
|
11
|
+
* is within the safe integer range, otherwise its decimal `string`, and `null` when cleared; input that is not an
|
|
12
|
+
* integer is not reported. Alt+Arrow Up/Down and Ctrl+A are swallowed by the input.
|
|
13
|
+
*/
|
|
5
14
|
declare const _default: (props: CustomCellEditorProps) => React.JSX.Element;
|
|
6
15
|
export default _default;
|
|
@@ -4,8 +4,11 @@ import { Key } from "ts-key-enum";
|
|
|
4
4
|
import KeyboardUtils from "d2coreui/components/keyboard/keyboardUtils";
|
|
5
5
|
import { CellEditorUtils } from "./cellEditorUtils";
|
|
6
6
|
import { DataGridCellEditorComponent, withAgGridHooks } from "./dataGridCellEditorComponent";
|
|
7
|
+
/** Smallest signed 64-bit integer; the default lower bound of `bigNumberCellEditor`. */
|
|
7
8
|
export const MIN_SIGNED_64_BIT_INT = BigInt("-9223372036854775808");
|
|
9
|
+
/** Largest signed 64-bit integer; the default upper bound of `bigNumberCellEditor`. */
|
|
8
10
|
export const MAX_SIGNED_64_BIT_INT = BigInt("9223372036854775807");
|
|
11
|
+
// same as NumberCellEditor, but values that are not in range of safe integer values are returned as string
|
|
9
12
|
class BigNumberCellEditor extends DataGridCellEditorComponent {
|
|
10
13
|
constructor(props) {
|
|
11
14
|
super(props);
|
|
@@ -15,15 +18,18 @@ class BigNumberCellEditor extends DataGridCellEditorComponent {
|
|
|
15
18
|
getInitialState(props) {
|
|
16
19
|
let value;
|
|
17
20
|
if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {
|
|
21
|
+
// if backspace or delete pressed, we clear the cell
|
|
18
22
|
value = null;
|
|
19
23
|
props.onValueChange(null);
|
|
20
24
|
}
|
|
21
25
|
else if (props.eventKey && props.eventKey.length === 1) {
|
|
26
|
+
// if a letter was pressed, we start with the letter
|
|
22
27
|
const parsedValue = Number.parseInt(props.eventKey);
|
|
23
28
|
value = isNaN(parsedValue) ? props.value : parsedValue;
|
|
24
29
|
props.onValueChange(value);
|
|
25
30
|
}
|
|
26
31
|
else {
|
|
32
|
+
// otherwise we start with the current value
|
|
27
33
|
value = props.value;
|
|
28
34
|
}
|
|
29
35
|
return {
|
|
@@ -40,6 +46,10 @@ class BigNumberCellEditor extends DataGridCellEditorComponent {
|
|
|
40
46
|
}
|
|
41
47
|
placeCursorToEnd() {
|
|
42
48
|
var _a, _b, _c;
|
|
49
|
+
// when we started editing, we want the carot at the end, not the start.
|
|
50
|
+
// this comes into play in two scenarios: a) when user hits F2 and b)
|
|
51
|
+
// when user hits a printable character, then on IE (and only IE) the carot
|
|
52
|
+
// was placed after the first character, thus 'apply' would end up as 'pplea'
|
|
43
53
|
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;
|
|
44
54
|
if (length > 0) {
|
|
45
55
|
(_c = this.inputComponent) === null || _c === void 0 ? void 0 : _c.setSelectionRange(length, length);
|
|
@@ -53,6 +63,7 @@ class BigNumberCellEditor extends DataGridCellEditorComponent {
|
|
|
53
63
|
this.inputComponent = component;
|
|
54
64
|
}, size: "small", autoFocus: true, stringMode: true, decimalSeparator: this.props.decimalSeparator, precision: this.props.precision, min: this.props.min ? String(this.props.min) : MIN_SIGNED_64_BIT_INT.toString(), max: this.props.max ? String(this.props.max) : MAX_SIGNED_64_BIT_INT.toString(), placeholder: this.state.value === null ? "NULL" : "", value: this.state.value !== null ? this.state.value : undefined, onChange: value => {
|
|
55
65
|
if (KeyboardUtils.isKeyPressed(Key.Alt)) {
|
|
66
|
+
// ignore navigational keystrokes ALT+cursor arrow
|
|
56
67
|
return;
|
|
57
68
|
}
|
|
58
69
|
if (typeof value === "string" && value !== "") {
|
|
@@ -72,6 +83,7 @@ class BigNumberCellEditor extends DataGridCellEditorComponent {
|
|
|
72
83
|
}
|
|
73
84
|
}, onKeyDown: (e) => {
|
|
74
85
|
if (CellEditorUtils.shouldIgnoreKeyEvent(e)) {
|
|
86
|
+
// this.props.onKeyDown(e.nativeEvent);
|
|
75
87
|
e.preventDefault();
|
|
76
88
|
e.nativeEvent.stopImmediatePropagation();
|
|
77
89
|
e.nativeEvent.preventDefault();
|
|
@@ -79,5 +91,12 @@ class BigNumberCellEditor extends DataGridCellEditorComponent {
|
|
|
79
91
|
}, style: { width: '100%' } }));
|
|
80
92
|
}
|
|
81
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* ag-grid cell editor for 64-bit integers (registered in `DataGrid` as `bigNumberCellEditor`), based on antd
|
|
96
|
+
* `InputNumber` in string mode. Starts like `numberCellEditor` (from `value`, the typed digit, or `null` on
|
|
97
|
+
* Backspace/Delete; other printable keys cancel editing). Reports through `onValueChange` a `number` when the integer
|
|
98
|
+
* is within the safe integer range, otherwise its decimal `string`, and `null` when cleared; input that is not an
|
|
99
|
+
* integer is not reported. Alt+Arrow Up/Down and Ctrl+A are swallowed by the input.
|
|
100
|
+
*/
|
|
82
101
|
export default withAgGridHooks(BigNumberCellEditor);
|
|
83
102
|
//# sourceMappingURL=bigNumberCellEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bigNumberCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/bigNumberCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,WAAW,EAA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,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;oBAE1C,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,eAAe,eAAe,CAAC,mBAAmB,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\nexport const MIN_SIGNED_64_BIT_INT = BigInt(\"-9223372036854775808\");\r\nexport const MAX_SIGNED_64_BIT_INT = BigInt(\"9223372036854775807\");\r\n\r\ninterface BigNumberCellEditorProperties extends CustomCellEditorProps {\r\n decimalSeparator?: string\r\n precision?: number\r\n min?: number\r\n max?: number\r\n}\r\n\r\ninterface NumericCellEditorState {\r\n value: string | null\r\n}\r\n\r\n// same as NumberCellEditor, but values that are not in range of safe integer values are returned as string\r\nclass BigNumberCellEditor extends DataGridCellEditorComponent<BigNumberCellEditorProperties, NumericCellEditorState> {\r\n private inputComponent: HTMLInputElement | null = null;\r\n\r\n constructor(props: Readonly<BigNumberCellEditorProperties>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<BigNumberCellEditorProperties>): NumericCellEditorState {\r\n let value: string | 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 };\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\r\n render() {\r\n return (\r\n <InputNumber<string>\r\n ref={(component) => {\r\n this.inputComponent = component;\r\n }}\r\n size=\"small\"\r\n autoFocus\r\n stringMode\r\n decimalSeparator={this.props.decimalSeparator}\r\n precision={this.props.precision}\r\n min={this.props.min ? String(this.props.min) : MIN_SIGNED_64_BIT_INT.toString()}\r\n max={this.props.max ? String(this.props.max) : MAX_SIGNED_64_BIT_INT.toString()}\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 === \"string\" && value !== \"\") {\r\n this.setState({value: value});\r\n if (value !== null && /^(?:-?\\d+)?$/.test(value)) {\r\n if (BigInt(value) > Number.MAX_SAFE_INTEGER || BigInt(value) < Number.MIN_SAFE_INTEGER) {\r\n this.props.onValueChange(value);\r\n } else {\r\n this.props.onValueChange(parseInt(value, 10));\r\n }\r\n }\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\nexport default withAgGridHooks(BigNumberCellEditor)"]}
|
|
1
|
+
{"version":3,"file":"bigNumberCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/bigNumberCellEditor.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;AAG3F,wFAAwF;AACxF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AACpE,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAkBnE,2GAA2G;AAC3G,MAAM,mBAAoB,SAAQ,2BAAkF;IAGhH,YAAY,KAA8C;QACtD,KAAK,CAAC,KAAK,CAAC,CAAC;QA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AAW,CAAC,cAAc,EAAE,CAAC;gBACnC,CAAC;YACL,CAAC,EACD,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAC,GACxB,CACL,CAAC;IACN,CAAC;CACJ;AAED;;;;;;GAMG;AACH,eAAe,eAAe,CAAC,mBAAmB,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/** Smallest signed 64-bit integer; the default lower bound of `bigNumberCellEditor`. */\r\nexport const MIN_SIGNED_64_BIT_INT = BigInt(\"-9223372036854775808\");\r\n/** Largest signed 64-bit integer; the default upper bound of `bigNumberCellEditor`. */\r\nexport const MAX_SIGNED_64_BIT_INT = BigInt(\"9223372036854775807\");\r\n\r\n/** Props of {@link BigNumberCellEditor}: ag-grid cell editor props plus these `cellEditorParams`. */\r\ninterface BigNumberCellEditorProperties 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; when not set (or `0`), {@link MIN_SIGNED_64_BIT_INT} is used. */\r\n min?: number\r\n /** Maximum allowed value; when not set (or `0`), {@link MAX_SIGNED_64_BIT_INT} is used. */\r\n max?: number\r\n}\r\n\r\ninterface NumericCellEditorState {\r\n value: string | null\r\n}\r\n\r\n// same as NumberCellEditor, but values that are not in range of safe integer values are returned as string\r\nclass BigNumberCellEditor extends DataGridCellEditorComponent<BigNumberCellEditorProperties, NumericCellEditorState> {\r\n private inputComponent: HTMLInputElement | null = null;\r\n\r\n constructor(props: Readonly<BigNumberCellEditorProperties>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n }\r\n\r\n getInitialState(props: Readonly<BigNumberCellEditorProperties>): NumericCellEditorState {\r\n let value: string | 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 };\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\r\n render() {\r\n return (\r\n <InputNumber<string>\r\n ref={(component) => {\r\n this.inputComponent = component;\r\n }}\r\n size=\"small\"\r\n autoFocus\r\n stringMode\r\n decimalSeparator={this.props.decimalSeparator}\r\n precision={this.props.precision}\r\n min={this.props.min ? String(this.props.min) : MIN_SIGNED_64_BIT_INT.toString()}\r\n max={this.props.max ? String(this.props.max) : MAX_SIGNED_64_BIT_INT.toString()}\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 === \"string\" && value !== \"\") {\r\n this.setState({value: value});\r\n if (value !== null && /^(?:-?\\d+)?$/.test(value)) {\r\n if (BigInt(value) > Number.MAX_SAFE_INTEGER || BigInt(value) < Number.MIN_SAFE_INTEGER) {\r\n this.props.onValueChange(value);\r\n } else {\r\n this.props.onValueChange(parseInt(value, 10));\r\n }\r\n }\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 64-bit integers (registered in `DataGrid` as `bigNumberCellEditor`), based on antd\r\n * `InputNumber` in string mode. Starts like `numberCellEditor` (from `value`, the typed digit, or `null` on\r\n * Backspace/Delete; other printable keys cancel editing). Reports through `onValueChange` a `number` when the integer\r\n * is within the safe integer range, otherwise its decimal `string`, and `null` when cleared; input that is not an\r\n * integer is not reported. Alt+Arrow Up/Down and Ctrl+A are swallowed by the input.\r\n */\r\nexport default withAgGridHooks(BigNumberCellEditor)"]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ag-grid bean (name `CellControl`) registered by `DataGrid`'s module. It only obtains ag-grid's internal edit service;
|
|
3
|
+
* its customisation of popup-editor closing is currently disabled, so it has no effect on grid behavior.
|
|
4
|
+
*/
|
|
1
5
|
export class CellControl extends BeanStub<"destroyed"> {
|
|
2
6
|
constructor();
|
|
3
7
|
beanName: string;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { BeanStub } from "ag-grid-community";
|
|
2
|
+
/**
|
|
3
|
+
* ag-grid bean (name `CellControl`) registered by `DataGrid`'s module. It only obtains ag-grid's internal edit service;
|
|
4
|
+
* its customisation of popup-editor closing is currently disabled, so it has no effect on grid behavior.
|
|
5
|
+
*/
|
|
2
6
|
export class CellControl extends BeanStub {
|
|
3
7
|
constructor() {
|
|
4
8
|
super(...arguments);
|
|
@@ -8,6 +12,16 @@ export class CellControl extends BeanStub {
|
|
|
8
12
|
this.editSvc = beans.editSvc;
|
|
9
13
|
}
|
|
10
14
|
postConstruct() {
|
|
15
|
+
// this.editSvc.onPopupEditorClosed = function () {
|
|
16
|
+
// if (!this.editSvc?.isEditing(this, {withOpenEditor: true})) {
|
|
17
|
+
// return;
|
|
18
|
+
// }
|
|
19
|
+
//
|
|
20
|
+
// // note: this happens because of a click outside of the grid or if the popupEditor
|
|
21
|
+
// // is closed with `Escape` key. if another cell was clicked, then the editing will
|
|
22
|
+
// // have already stopped and returned on the conditional above.
|
|
23
|
+
// this.editSvc?.stopEditing(this, {source: this.editSvc?.isBatchEditing() ? 'ui' : 'api', suppressNavigateAfterEdit: true});
|
|
24
|
+
// };
|
|
11
25
|
}
|
|
12
26
|
}
|
|
13
27
|
//# sourceMappingURL=cellControl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cellControl.js","sourceRoot":"","sources":["../../../../../components/grid/cell/cellControl.js"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,MAAM,OAAO,WAAY,SAAQ,QAAQ;IAAzC;;QACI,aAAQ,GAAG,aAAa,CAAC;IAmB7B,CAAC;IAjBG,SAAS,CAAC,KAAK;QACX,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,aAAa;
|
|
1
|
+
{"version":3,"file":"cellControl.js","sourceRoot":"","sources":["../../../../../components/grid/cell/cellControl.js"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,QAAQ;IAAzC;;QACI,aAAQ,GAAG,aAAa,CAAC;IAmB7B,CAAC;IAjBG,SAAS,CAAC,KAAK;QACX,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IACjC,CAAC;IAED,aAAa;QAET,mDAAmD;QACnD,oEAAoE;QACpE,kBAAkB;QAClB,QAAQ;QACR,EAAE;QACF,yFAAyF;QACzF,yFAAyF;QACzF,qEAAqE;QACrE,iIAAiI;QACjI,KAAK;IACT,CAAC;CACJ","sourcesContent":["import {BeanStub} from \"ag-grid-community\";\r\n\r\n/**\r\n * ag-grid bean (name `CellControl`) registered by `DataGrid`'s module. It only obtains ag-grid's internal edit service;\r\n * its customisation of popup-editor closing is currently disabled, so it has no effect on grid behavior.\r\n */\r\nexport class CellControl extends BeanStub {\r\n beanName = \"CellControl\";\r\n\r\n wireBeans(beans) {\r\n this.editSvc = beans.editSvc;\r\n }\r\n\r\n postConstruct() {\r\n\r\n // this.editSvc.onPopupEditorClosed = function () {\r\n // if (!this.editSvc?.isEditing(this, {withOpenEditor: true})) {\r\n // return;\r\n // }\r\n //\r\n // // note: this happens because of a click outside of the grid or if the popupEditor\r\n // // is closed with `Escape` key. if another cell was clicked, then the editing will\r\n // // have already stopped and returned on the conditional above.\r\n // this.editSvc?.stopEditing(this, {source: this.editSvc?.isBatchEditing() ? 'ui' : 'api', suppressNavigateAfterEdit: true});\r\n // };\r\n }\r\n}"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/** Keyboard helpers shared by the grid cell editors. */
|
|
2
3
|
export declare class CellEditorUtils {
|
|
4
|
+
/**
|
|
5
|
+
* Tells whether a cell editor's input should swallow the key event instead of handling it:
|
|
6
|
+
* `Alt+ArrowUp` / `Alt+ArrowDown`, or `Ctrl` with `e.key === "KeyA"`. The modifier state is read
|
|
7
|
+
* from the global {@link KeyboardUtils} tracker, not from the event.
|
|
8
|
+
*/
|
|
3
9
|
static shouldIgnoreKeyEvent<T>(e: React.KeyboardEvent<T>): boolean;
|
|
4
10
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import KeyboardUtils from "d2coreui/components/keyboard/keyboardUtils";
|
|
2
2
|
import { Key } from "ts-key-enum";
|
|
3
|
+
/** Keyboard helpers shared by the grid cell editors. */
|
|
3
4
|
export class CellEditorUtils {
|
|
5
|
+
/**
|
|
6
|
+
* Tells whether a cell editor's input should swallow the key event instead of handling it:
|
|
7
|
+
* `Alt+ArrowUp` / `Alt+ArrowDown`, or `Ctrl` with `e.key === "KeyA"`. The modifier state is read
|
|
8
|
+
* from the global {@link KeyboardUtils} tracker, not from the event.
|
|
9
|
+
*/
|
|
4
10
|
static shouldIgnoreKeyEvent(e) {
|
|
5
11
|
return ((KeyboardUtils.isKeyPressed(Key.Alt) && (e.key === Key.ArrowUp || e.key === Key.ArrowDown)) ||
|
|
6
12
|
(KeyboardUtils.isKeyPressed(Key.Control) && e.key === "KeyA"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cellEditorUtils.js","sourceRoot":"","sources":["../../../../../components/grid/cell/cellEditorUtils.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAGhC,MAAM,OAAO,eAAe;IACxB,MAAM,CAAC,oBAAoB,CAAI,CAAyB;QACpD,OAAO,CACH,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC;YAC3F,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,CAChE,CAAC;IACN,CAAC;CACJ","sourcesContent":["import KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport React from 'react';\r\n\r\nexport class CellEditorUtils {\r\n static shouldIgnoreKeyEvent<T>(e: React.KeyboardEvent<T>): boolean {\r\n return (\r\n (KeyboardUtils.isKeyPressed(Key.Alt) && (e.key === Key.ArrowUp || e.key === Key.ArrowDown)) ||\r\n (KeyboardUtils.isKeyPressed(Key.Control) && e.key === \"KeyA\")\r\n );\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"file":"cellEditorUtils.js","sourceRoot":"","sources":["../../../../../components/grid/cell/cellEditorUtils.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,4CAA4C,CAAC;AACvE,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAGhC,wDAAwD;AACxD,MAAM,OAAO,eAAe;IACxB;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAI,CAAyB;QACpD,OAAO,CACH,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC;YAC3F,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,MAAM,CAAC,CAChE,CAAC;IACN,CAAC;CACJ","sourcesContent":["import KeyboardUtils from \"d2coreui/components/keyboard/keyboardUtils\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport React from 'react';\r\n\r\n/** Keyboard helpers shared by the grid cell editors. */\r\nexport class CellEditorUtils {\r\n /**\r\n * Tells whether a cell editor's input should swallow the key event instead of handling it:\r\n * `Alt+ArrowUp` / `Alt+ArrowDown`, or `Ctrl` with `e.key === \"KeyA\"`. The modifier state is read\r\n * from the global {@link KeyboardUtils} tracker, not from the event.\r\n */\r\n static shouldIgnoreKeyEvent<T>(e: React.KeyboardEvent<T>): boolean {\r\n return (\r\n (KeyboardUtils.isKeyPressed(Key.Alt) && (e.key === Key.ArrowUp || e.key === Key.ArrowDown)) ||\r\n (KeyboardUtils.isKeyPressed(Key.Control) && e.key === \"KeyA\")\r\n );\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 that picks one of the `values` labels from an antd `Select` (registered in `DataGrid` as
|
|
5
|
+
* `customEnumCellEditor`); the cell value is the zero-based index of the label. The dropdown opens when editing starts.
|
|
6
|
+
* Starts from `initialValue`, from the typed digit as an index, or from `null` on Backspace/Delete. Reports the
|
|
7
|
+
* selected index, or `null` when cleared, through `onValueChange`.
|
|
8
|
+
*/
|
|
3
9
|
declare const _default: (props: CustomCellEditorProps) => React.JSX.Element;
|
|
4
10
|
export default _default;
|
|
@@ -15,15 +15,18 @@ class CustomEnumCellEditor extends DataGridCellEditorComponent {
|
|
|
15
15
|
getInitialState(props) {
|
|
16
16
|
let value;
|
|
17
17
|
if (props.eventKey === Key.Backspace || props.eventKey === Key.Delete) {
|
|
18
|
+
// if backspace or delete pressed, we clear the cell
|
|
18
19
|
value = null;
|
|
19
20
|
props.onValueChange(null);
|
|
20
21
|
}
|
|
21
22
|
else if (props.eventKey && props.eventKey.length === 1) {
|
|
23
|
+
// if a letter was pressed, we start with the letter
|
|
22
24
|
const parsedValue = Number.parseInt(props.eventKey);
|
|
23
25
|
value = isNaN(parsedValue) ? props.value : parsedValue;
|
|
24
26
|
props.onValueChange(value);
|
|
25
27
|
}
|
|
26
28
|
else {
|
|
29
|
+
// otherwise we start with the current value
|
|
27
30
|
value = props.initialValue;
|
|
28
31
|
}
|
|
29
32
|
return {
|
|
@@ -69,6 +72,7 @@ class CustomEnumCellEditor extends DataGridCellEditorComponent {
|
|
|
69
72
|
this.setState({ opened: visible });
|
|
70
73
|
}, getPopupContainer: () => {
|
|
71
74
|
var _a, _b;
|
|
75
|
+
// 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)
|
|
72
76
|
return ((_b = (_a = this.containerRef.current) === null || _a === void 0 ? void 0 : _a.parentNode) !== null && _b !== void 0 ? _b : document.body);
|
|
73
77
|
}, popupRender: (menu) => {
|
|
74
78
|
return (React.createElement("div", { ref: (component) => {
|
|
@@ -79,5 +83,11 @@ class CustomEnumCellEditor extends DataGridCellEditorComponent {
|
|
|
79
83
|
}))));
|
|
80
84
|
}
|
|
81
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* ag-grid cell editor that picks one of the `values` labels from an antd `Select` (registered in `DataGrid` as
|
|
88
|
+
* `customEnumCellEditor`); the cell value is the zero-based index of the label. The dropdown opens when editing starts.
|
|
89
|
+
* Starts from `initialValue`, from the typed digit as an index, or from `null` on Backspace/Delete. Reports the
|
|
90
|
+
* selected index, or `null` when cleared, through `onValueChange`.
|
|
91
|
+
*/
|
|
82
92
|
export default withAgGridHooks(CustomEnumCellEditor);
|
|
83
93
|
//# sourceMappingURL=customEnumCellEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customEnumCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/customEnumCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAEhC,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAY3F,MAAM,oBAAqB,SAAQ,2BAAiF;IAKhH,YAAY,KAA0C;QAClD,KAAK,CAAC,KAAK,CAAC,CAAC;QALT,oBAAe,GAA0B,IAAI,CAAC;QAC9C,sBAAiB,GAA0B,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CAAC,IAAI,EAAE,EAAE;oBAClB,OAAO,CACH,6BAAK,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE;4BACpB,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;wBACvC,CAAC,IACI,IAAI,CACH,CACT,CAAC;gBACN,CAAC,IAEA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBACpC,OAAO,CACH,oBAAC,MAAM,CAAC,MAAM,IAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,IAAG,KAAK,CAAiB,CACnE,CAAA;YACL,CAAC,CAAC,CACG,CACP,CACT,CAAA;IACL,CAAC;CACJ;AAED,eAAe,eAAe,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["import React from \"react\";\r\nimport {RefSelectProps} from \"antd/es/select\";\r\nimport debounce from \"lodash/debounce\";\r\nimport {Select} from \"antd\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\ninterface CustomEnumCellEditorProps extends CustomCellEditorProps {\r\n values: string[]\r\n listHeight?: number\r\n}\r\n\r\ninterface CustomEnumCellEditorState {\r\n value: number | null\r\n opened: boolean\r\n}\r\n\r\nclass CustomEnumCellEditor extends DataGridCellEditorComponent<CustomEnumCellEditorProps, CustomEnumCellEditorState> {\r\n private selectComponent: RefSelectProps | null = null;\r\n private wrappingComponent: HTMLDivElement | null = null;\r\n private containerRef = React.createRef<HTMLDivElement>();\r\n\r\n constructor(props: Readonly<CustomEnumCellEditorProps>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n this.updateValueFromPreselection = debounce(this.updateValueFromPreselection.bind(this), 200, {maxWait: 200});\r\n }\r\n\r\n getInitialState(props: Readonly<CustomEnumCellEditorProps>): CustomEnumCellEditorState {\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 {\r\n value: value,\r\n opened: true,\r\n } as CustomEnumCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.selectComponent?.focus();\r\n }\r\n\r\n select() {\r\n }\r\n\r\n placeCursorToEnd() {\r\n }\r\n\r\n private updateValueFromPreselection() {\r\n setTimeout(() => {\r\n let selectables: HTMLElement[] = Array.from(this.wrappingComponent?.getElementsByClassName(\"ant-select-item-option-active\") ?? []) as HTMLElement[];\r\n if (selectables.length > 0) {\r\n const optionStringValue = selectables[0].dataset?.optionvalue;\r\n const optionValue = optionStringValue !== undefined ? Number.parseFloat(optionStringValue) : undefined\r\n if (optionValue) {\r\n this.setState({value: optionValue});\r\n this.props.onValueChange(optionValue);\r\n }\r\n }\r\n }, 200)\r\n }\r\n\r\n render() {\r\n return (\r\n <div style={{width: \"100%\", minWidth: 150, height: 24}} ref={this.containerRef}>\r\n <Select\r\n ref={(component) => {\r\n this.selectComponent = component;\r\n }}\r\n size={\"small\"}\r\n virtual={false}\r\n className={\"select-with-one-item\"}\r\n popupMatchSelectWidth={false}\r\n style={{width: \"100%\", overflow: \"auto\", padding: 0, margin: 0}}\r\n styles={{popup: {root:{width: \"100%\", maxHeight: 400, overflow: 'auto'}}}}\r\n showAction={['focus', 'click']}\r\n listHeight={this.props.listHeight}\r\n value={this.state.value !== null ? this.state.value : undefined}\r\n onChange={(value) => {\r\n const valueToSet = value === undefined ? null : value;\r\n this.setState({value: valueToSet});\r\n this.props.onValueChange(valueToSet);\r\n }}\r\n onSelect={(value) => {\r\n const valueToSet = value === undefined ? null : value;\r\n this.setState({value: valueToSet});\r\n this.props.onValueChange(valueToSet);\r\n }}\r\n open={this.state.opened}\r\n onOpenChange={(visible) => {\r\n this.setState({opened: visible});\r\n }}\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.containerRef.current?.parentNode ?? document.body) as HTMLElement;\r\n }}\r\n popupRender={(menu) => {\r\n return (\r\n <div ref={(component) => {\r\n this.wrappingComponent = component;\r\n }}>\r\n {menu}\r\n </div>\r\n );\r\n }}\r\n >\r\n {this.props.values.map((value, index) => {\r\n return (\r\n <Select.Option value={index} key={index}>{value}</Select.Option>\r\n )\r\n })}\r\n </Select>\r\n </div>\r\n )\r\n }\r\n}\r\n\r\nexport default withAgGridHooks(CustomEnumCellEditor);"]}
|
|
1
|
+
{"version":3,"file":"customEnumCellEditor.js","sourceRoot":"","sources":["../../../../../components/grid/cell/customEnumCellEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAEhC,OAAO,EAAC,2BAA2B,EAAE,eAAe,EAAC,MAAM,+BAA+B,CAAC;AAe3F,MAAM,oBAAqB,SAAQ,2BAAiF;IAKhH,YAAY,KAA0C;QAClD,KAAK,CAAC,KAAK,CAAC,CAAC;QALT,oBAAe,GAA0B,IAAI,CAAC;QAC9C,sBAAiB,GAA0B,IAAI,CAAC;QAChD,iBAAY,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;QAIrD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,2BAA2B,GAAG,QAAQ,CAAC,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI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;gBACN,CAAC,IAEA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBACpC,OAAO,CACH,oBAAC,MAAM,CAAC,MAAM,IAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,IAAG,KAAK,CAAiB,CACnE,CAAA;YACL,CAAC,CAAC,CACG,CACP,CACT,CAAA;IACL,CAAC;CACJ;AAED;;;;;GAKG;AACH,eAAe,eAAe,CAAC,oBAAoB,CAAC,CAAC","sourcesContent":["import React from \"react\";\r\nimport {RefSelectProps} from \"antd/es/select\";\r\nimport debounce from \"lodash/debounce\";\r\nimport {Select} from \"antd\";\r\nimport {Key} from \"ts-key-enum\";\r\nimport {CustomCellEditorProps} from \"ag-grid-react\";\r\nimport {DataGridCellEditorComponent, withAgGridHooks} from \"./dataGridCellEditorComponent\";\r\n\r\n/** Props of {@link CustomEnumCellEditor}: ag-grid cell editor props plus these `cellEditorParams`. */\r\ninterface CustomEnumCellEditorProps extends CustomCellEditorProps {\r\n /** Option labels; the cell value is the index of the selected label in this array. */\r\n values: string[]\r\n /** Height of the dropdown list in pixels (antd `Select` `listHeight`). */\r\n listHeight?: number\r\n}\r\n\r\ninterface CustomEnumCellEditorState {\r\n value: number | null\r\n opened: boolean\r\n}\r\n\r\nclass CustomEnumCellEditor extends DataGridCellEditorComponent<CustomEnumCellEditorProps, CustomEnumCellEditorState> {\r\n private selectComponent: RefSelectProps | null = null;\r\n private wrappingComponent: HTMLDivElement | null = null;\r\n private containerRef = React.createRef<HTMLDivElement>();\r\n\r\n constructor(props: Readonly<CustomEnumCellEditorProps>) {\r\n super(props);\r\n this.state = this.getInitialState(props);\r\n this.updateValueFromPreselection = debounce(this.updateValueFromPreselection.bind(this), 200, {maxWait: 200});\r\n }\r\n\r\n getInitialState(props: Readonly<CustomEnumCellEditorProps>): CustomEnumCellEditorState {\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 {\r\n value: value,\r\n opened: true,\r\n } as CustomEnumCellEditorState;\r\n }\r\n\r\n focus() {\r\n this.selectComponent?.focus();\r\n }\r\n\r\n select() {\r\n }\r\n\r\n placeCursorToEnd() {\r\n }\r\n\r\n private updateValueFromPreselection() {\r\n setTimeout(() => {\r\n let selectables: HTMLElement[] = Array.from(this.wrappingComponent?.getElementsByClassName(\"ant-select-item-option-active\") ?? []) as HTMLElement[];\r\n if (selectables.length > 0) {\r\n const optionStringValue = selectables[0].dataset?.optionvalue;\r\n const optionValue = optionStringValue !== undefined ? Number.parseFloat(optionStringValue) : undefined\r\n if (optionValue) {\r\n this.setState({value: optionValue});\r\n this.props.onValueChange(optionValue);\r\n }\r\n }\r\n }, 200)\r\n }\r\n\r\n render() {\r\n return (\r\n <div style={{width: \"100%\", minWidth: 150, height: 24}} ref={this.containerRef}>\r\n <Select\r\n ref={(component) => {\r\n this.selectComponent = component;\r\n }}\r\n size={\"small\"}\r\n virtual={false}\r\n className={\"select-with-one-item\"}\r\n popupMatchSelectWidth={false}\r\n style={{width: \"100%\", overflow: \"auto\", padding: 0, margin: 0}}\r\n styles={{popup: {root:{width: \"100%\", maxHeight: 400, overflow: 'auto'}}}}\r\n showAction={['focus', 'click']}\r\n listHeight={this.props.listHeight}\r\n value={this.state.value !== null ? this.state.value : undefined}\r\n onChange={(value) => {\r\n const valueToSet = value === undefined ? null : value;\r\n this.setState({value: valueToSet});\r\n this.props.onValueChange(valueToSet);\r\n }}\r\n onSelect={(value) => {\r\n const valueToSet = value === undefined ? null : value;\r\n this.setState({value: valueToSet});\r\n this.props.onValueChange(valueToSet);\r\n }}\r\n open={this.state.opened}\r\n onOpenChange={(visible) => {\r\n this.setState({opened: visible});\r\n }}\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.containerRef.current?.parentNode ?? document.body) as HTMLElement;\r\n }}\r\n popupRender={(menu) => {\r\n return (\r\n <div ref={(component) => {\r\n this.wrappingComponent = component;\r\n }}>\r\n {menu}\r\n </div>\r\n );\r\n }}\r\n >\r\n {this.props.values.map((value, index) => {\r\n return (\r\n <Select.Option value={index} key={index}>{value}</Select.Option>\r\n )\r\n })}\r\n </Select>\r\n </div>\r\n )\r\n }\r\n}\r\n\r\n/**\r\n * ag-grid cell editor that picks one of the `values` labels from an antd `Select` (registered in `DataGrid` as\r\n * `customEnumCellEditor`); the cell value is the zero-based index of the label. The dropdown opens when editing starts.\r\n * Starts from `initialValue`, from the typed digit as an index, or from `null` on Backspace/Delete. Reports the\r\n * selected index, or `null` when cleared, through `onValueChange`.\r\n */\r\nexport default withAgGridHooks(CustomEnumCellEditor);"]}
|
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
import { CustomCellEditorProps } from "ag-grid-react";
|
|
2
2
|
import React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for class-based ag-grid React cell editors. About 200 ms after mount it calls {@link focus} and
|
|
5
|
+
* then either {@link select} (editing started by Enter, double-click or API) or {@link placeCursorToEnd}
|
|
6
|
+
* (editing started by typing a printable character or pressing F2). Subclasses override these hooks and may
|
|
7
|
+
* implement {@link isCancelBeforeStart}; wrap the subclass with {@link withAgGridHooks} before registering it
|
|
8
|
+
* as an ag-grid `cellEditor`.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam P - editor props: ag-grid's `CustomCellEditorProps` plus the column's `cellEditorParams`.
|
|
11
|
+
* @typeParam S - editor state.
|
|
12
|
+
*/
|
|
3
13
|
export declare class DataGridCellEditorComponent<P extends CustomCellEditorProps, S> extends React.Component<P, S> {
|
|
4
14
|
private focusOpId;
|
|
5
15
|
private highlightAllOnFocus;
|
|
16
|
+
/** Decides from `props.eventKey` whether the initial focus selects the content or places the caret at its end. */
|
|
6
17
|
constructor(props: P);
|
|
7
18
|
componentDidMount(): void;
|
|
8
19
|
componentWillUnmount(): void;
|
|
20
|
+
/** Moves focus into the editor's input. Called once after mount; the default does nothing. */
|
|
9
21
|
focus(): void;
|
|
22
|
+
/** 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. */
|
|
10
23
|
select(): void;
|
|
24
|
+
/** Places the caret after the last character. Called after {@link focus} when editing was started by typing or F2; the default does nothing. */
|
|
11
25
|
placeCursorToEnd(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Optional. Called by ag-grid (through {@link withAgGridHooks}) once before editing starts; returning `true`
|
|
28
|
+
* cancels editing before the editor is shown. Use it to e.g. start editing a numeric cell only when the
|
|
29
|
+
* user typed a digit, not a letter.
|
|
30
|
+
*/
|
|
12
31
|
isCancelBeforeStart?(): boolean;
|
|
13
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Wraps a class-based {@link DataGridCellEditorComponent} subclass into a function component usable as an
|
|
35
|
+
* ag-grid React `cellEditor`. It registers the ag-grid editor hooks via `useGridCellEditor`, forwarding
|
|
36
|
+
* `isCancelBeforeStart` to the class instance, and passes all ag-grid props (including `cellEditorParams`) through.
|
|
37
|
+
*
|
|
38
|
+
* @param Component - the editor class to wrap.
|
|
39
|
+
*/
|
|
14
40
|
export declare function withAgGridHooks<P extends CustomCellEditorProps, S>(Component: any): (props: CustomCellEditorProps) => React.JSX.Element;
|