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
|
@@ -2,41 +2,126 @@ import React from "react";
|
|
|
2
2
|
import { ModalFuncProps } from "antd/es/modal";
|
|
3
3
|
import { DraggableModalProps } from "d2coreui/components/modal/impl";
|
|
4
4
|
import { HookAPI } from "antd/es/modal/useModal";
|
|
5
|
+
/**
|
|
6
|
+
* Button set of a {@link ModalDialog}. Button labels are localized and can be overridden with `okText` /
|
|
7
|
+
* `cancelText` (and `denyText`).
|
|
8
|
+
*/
|
|
5
9
|
export declare const enum ModalDialogMode {
|
|
10
|
+
/**
|
|
11
|
+
* No footer, unless a `footer` is given explicitly. Honored only by the component; the static methods show
|
|
12
|
+
* antd's default buttons.
|
|
13
|
+
*/
|
|
6
14
|
NO_BUTTONS = "NO_BUTTONS",
|
|
15
|
+
/** "OK" and "Cancel" buttons. */
|
|
7
16
|
OK_CANCEL = "OK_CANCEL",
|
|
17
|
+
/** "Yes" and "No" buttons; "No" acts as cancel. */
|
|
8
18
|
YES_NO = "YES_NO",
|
|
19
|
+
/**
|
|
20
|
+
* "Yes", "No" and "Cancel" buttons: "Yes" calls `onOk`, "No" calls `onDeny` and "Cancel" `onCancel`.
|
|
21
|
+
* Supported only by the static methods; the component renders antd's default buttons in this mode.
|
|
22
|
+
*/
|
|
9
23
|
YES_NO_CANCEL = "YES_NO_CANCEL",
|
|
24
|
+
/** Only an "OK" button (see the note at {@link ModalDialog} about the component). */
|
|
10
25
|
OK = "OK"
|
|
11
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Options of the static {@link ModalDialog} methods: antd `ModalFuncProps` plus the button mode.
|
|
29
|
+
* `autoFocusButton` defaults to `"ok"`.
|
|
30
|
+
*/
|
|
12
31
|
export interface ModalDialogFuncProps extends ModalFuncProps {
|
|
32
|
+
/** Button set of the dialog. */
|
|
13
33
|
mode: ModalDialogMode;
|
|
34
|
+
/** Label of the "No" button in {@link ModalDialogMode.YES_NO_CANCEL} mode; defaults to localized "No". */
|
|
14
35
|
denyText?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Called with the click event when the "No" button is clicked in {@link ModalDialogMode.YES_NO_CANCEL} mode;
|
|
38
|
+
* the dialog is closed afterwards.
|
|
39
|
+
*/
|
|
15
40
|
onDeny?: (...args: any[]) => any;
|
|
16
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Props of the {@link ModalDialog} component: antd `ModalProps` (except `width`) plus `initialWidth`,
|
|
44
|
+
* `initialHeight`, `maximizable` and `onResize` of the draggable modal, and the button mode.
|
|
45
|
+
*/
|
|
17
46
|
export interface ModalDialogProps extends DraggableModalProps {
|
|
47
|
+
/** Button set of the dialog. */
|
|
18
48
|
mode: ModalDialogMode;
|
|
19
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Dialog with a predefined, localized button set (see {@link ModalDialogMode}).
|
|
52
|
+
*
|
|
53
|
+
* As a component it renders a draggable (by the title), resizable (bottom-right handle) and maximizable antd
|
|
54
|
+
* `Modal` that is kept inside the window and destroyed when hidden. It must be rendered inside a
|
|
55
|
+
* `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.
|
|
56
|
+
* Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static
|
|
57
|
+
* methods hide it.
|
|
58
|
+
*
|
|
59
|
+
* The static methods open imperative antd dialogs; register the app's modal API once with
|
|
60
|
+
* {@link ModalDialog.setModalInstance}. They modify the passed `okButtonProps` / `cancelButtonProps` objects and
|
|
61
|
+
* replace their `style`.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* <DraggableModalProvider>
|
|
65
|
+
* <ModalDialog mode={ModalDialogMode.OK_CANCEL} open={open} title="Rename"
|
|
66
|
+
* initialWidth={480} initialHeight={240}
|
|
67
|
+
* onOk={save} onCancel={() => setOpen(false)}>
|
|
68
|
+
* <Input value={name} onChange={e => setName(e.target.value)}/>
|
|
69
|
+
* </ModalDialog>
|
|
70
|
+
* </DraggableModalProvider>
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ModalDialog.confirm({
|
|
74
|
+
* mode: ModalDialogMode.YES_NO_CANCEL,
|
|
75
|
+
* title: "Save changes?",
|
|
76
|
+
* onOk: save,
|
|
77
|
+
* onDeny: discard,
|
|
78
|
+
* });
|
|
79
|
+
*/
|
|
20
80
|
export declare class ModalDialog extends React.Component<ModalDialogProps, {}> {
|
|
21
81
|
private static modalStatic;
|
|
22
82
|
constructor(props: Readonly<ModalDialogProps>);
|
|
83
|
+
/**
|
|
84
|
+
* Registers the antd `modal` API from `App.useApp()` for the static methods, so that their dialogs inherit the app's
|
|
85
|
+
* theme, locale and context. Until it is called they fall back to antd's static `Modal` functions.
|
|
86
|
+
*/
|
|
23
87
|
static setModalInstance(instance: HookAPI): void;
|
|
88
|
+
/**
|
|
89
|
+
* Opens a confirmation dialog (antd `confirm`) with the buttons of `props.mode`.
|
|
90
|
+
* @returns a handle to close or update the dialog.
|
|
91
|
+
*/
|
|
24
92
|
static confirm(props: ModalDialogFuncProps): {
|
|
25
93
|
destroy: () => void;
|
|
26
94
|
update: (newConfig: ModalFuncProps) => void;
|
|
27
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Opens an error dialog (antd `error`) with the buttons of `props.mode`.
|
|
98
|
+
* @returns a handle to close or update the dialog.
|
|
99
|
+
*/
|
|
28
100
|
static error(props: ModalDialogFuncProps): {
|
|
29
101
|
destroy: () => void;
|
|
30
102
|
update: (newConfig: ModalFuncProps) => void;
|
|
31
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* Opens a confirmation dialog like {@link ModalDialog.confirm} with a danger OK button. The button is marked as
|
|
106
|
+
* danger only when `props.okButtonProps` is passed (an empty object is enough).
|
|
107
|
+
* @returns a handle to close or update the dialog.
|
|
108
|
+
*/
|
|
32
109
|
static delete(props: ModalDialogFuncProps): {
|
|
33
110
|
destroy: () => void;
|
|
34
111
|
update: (newConfig: ModalFuncProps) => void;
|
|
35
112
|
};
|
|
113
|
+
/**
|
|
114
|
+
* Opens a success dialog (antd `success`) with the buttons of `props.mode`.
|
|
115
|
+
* @returns a handle to close or update the dialog.
|
|
116
|
+
*/
|
|
36
117
|
static success(props: ModalDialogFuncProps): {
|
|
37
118
|
destroy: () => void;
|
|
38
119
|
update: (newConfig: ModalFuncProps) => void;
|
|
39
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* Opens an information dialog (antd `info`) with the buttons of `props.mode`.
|
|
123
|
+
* @returns a handle to close or update the dialog.
|
|
124
|
+
*/
|
|
40
125
|
static info(props: ModalDialogFuncProps): {
|
|
41
126
|
destroy: () => void;
|
|
42
127
|
update: (newConfig: ModalFuncProps) => void;
|
|
@@ -13,21 +13,74 @@ import React from "react";
|
|
|
13
13
|
import { Button, Modal } from "antd";
|
|
14
14
|
import i18n from "d2core/i18n/i18n";
|
|
15
15
|
import { DraggableModal } from "d2coreui/components/modal/impl";
|
|
16
|
+
/**
|
|
17
|
+
* Button set of a {@link ModalDialog}. Button labels are localized and can be overridden with `okText` /
|
|
18
|
+
* `cancelText` (and `denyText`).
|
|
19
|
+
*/
|
|
16
20
|
export var ModalDialogMode;
|
|
17
21
|
(function (ModalDialogMode) {
|
|
22
|
+
/**
|
|
23
|
+
* No footer, unless a `footer` is given explicitly. Honored only by the component; the static methods show
|
|
24
|
+
* antd's default buttons.
|
|
25
|
+
*/
|
|
18
26
|
ModalDialogMode["NO_BUTTONS"] = "NO_BUTTONS";
|
|
27
|
+
/** "OK" and "Cancel" buttons. */
|
|
19
28
|
ModalDialogMode["OK_CANCEL"] = "OK_CANCEL";
|
|
29
|
+
/** "Yes" and "No" buttons; "No" acts as cancel. */
|
|
20
30
|
ModalDialogMode["YES_NO"] = "YES_NO";
|
|
31
|
+
/**
|
|
32
|
+
* "Yes", "No" and "Cancel" buttons: "Yes" calls `onOk`, "No" calls `onDeny` and "Cancel" `onCancel`.
|
|
33
|
+
* Supported only by the static methods; the component renders antd's default buttons in this mode.
|
|
34
|
+
*/
|
|
21
35
|
ModalDialogMode["YES_NO_CANCEL"] = "YES_NO_CANCEL";
|
|
36
|
+
/** Only an "OK" button (see the note at {@link ModalDialog} about the component). */
|
|
22
37
|
ModalDialogMode["OK"] = "OK";
|
|
23
38
|
})(ModalDialogMode || (ModalDialogMode = {}));
|
|
39
|
+
/**
|
|
40
|
+
* Dialog with a predefined, localized button set (see {@link ModalDialogMode}).
|
|
41
|
+
*
|
|
42
|
+
* As a component it renders a draggable (by the title), resizable (bottom-right handle) and maximizable antd
|
|
43
|
+
* `Modal` that is kept inside the window and destroyed when hidden. It must be rendered inside a
|
|
44
|
+
* `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.
|
|
45
|
+
* Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static
|
|
46
|
+
* methods hide it.
|
|
47
|
+
*
|
|
48
|
+
* The static methods open imperative antd dialogs; register the app's modal API once with
|
|
49
|
+
* {@link ModalDialog.setModalInstance}. They modify the passed `okButtonProps` / `cancelButtonProps` objects and
|
|
50
|
+
* replace their `style`.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* <DraggableModalProvider>
|
|
54
|
+
* <ModalDialog mode={ModalDialogMode.OK_CANCEL} open={open} title="Rename"
|
|
55
|
+
* initialWidth={480} initialHeight={240}
|
|
56
|
+
* onOk={save} onCancel={() => setOpen(false)}>
|
|
57
|
+
* <Input value={name} onChange={e => setName(e.target.value)}/>
|
|
58
|
+
* </ModalDialog>
|
|
59
|
+
* </DraggableModalProvider>
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ModalDialog.confirm({
|
|
63
|
+
* mode: ModalDialogMode.YES_NO_CANCEL,
|
|
64
|
+
* title: "Save changes?",
|
|
65
|
+
* onOk: save,
|
|
66
|
+
* onDeny: discard,
|
|
67
|
+
* });
|
|
68
|
+
*/
|
|
24
69
|
export class ModalDialog extends React.Component {
|
|
25
70
|
constructor(props) {
|
|
26
71
|
super(props);
|
|
27
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Registers the antd `modal` API from `App.useApp()` for the static methods, so that their dialogs inherit the app's
|
|
75
|
+
* theme, locale and context. Until it is called they fall back to antd's static `Modal` functions.
|
|
76
|
+
*/
|
|
28
77
|
static setModalInstance(instance) {
|
|
29
78
|
ModalDialog.modalStatic = instance;
|
|
30
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Opens a confirmation dialog (antd `confirm`) with the buttons of `props.mode`.
|
|
82
|
+
* @returns a handle to close or update the dialog.
|
|
83
|
+
*/
|
|
31
84
|
static confirm(props) {
|
|
32
85
|
let dialogHandler;
|
|
33
86
|
const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {
|
|
@@ -37,6 +90,10 @@ export class ModalDialog extends React.Component {
|
|
|
37
90
|
dialogHandler = method(modalDialogProperties);
|
|
38
91
|
return dialogHandler;
|
|
39
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Opens an error dialog (antd `error`) with the buttons of `props.mode`.
|
|
95
|
+
* @returns a handle to close or update the dialog.
|
|
96
|
+
*/
|
|
40
97
|
static error(props) {
|
|
41
98
|
let dialogHandler;
|
|
42
99
|
const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {
|
|
@@ -46,6 +103,11 @@ export class ModalDialog extends React.Component {
|
|
|
46
103
|
dialogHandler = method(modalDialogProperties);
|
|
47
104
|
return dialogHandler;
|
|
48
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Opens a confirmation dialog like {@link ModalDialog.confirm} with a danger OK button. The button is marked as
|
|
108
|
+
* danger only when `props.okButtonProps` is passed (an empty object is enough).
|
|
109
|
+
* @returns a handle to close or update the dialog.
|
|
110
|
+
*/
|
|
49
111
|
static delete(props) {
|
|
50
112
|
let dialogHandler;
|
|
51
113
|
const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {
|
|
@@ -58,6 +120,10 @@ export class ModalDialog extends React.Component {
|
|
|
58
120
|
dialogHandler = method(modalDialogProperties);
|
|
59
121
|
return dialogHandler;
|
|
60
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Opens a success dialog (antd `success`) with the buttons of `props.mode`.
|
|
125
|
+
* @returns a handle to close or update the dialog.
|
|
126
|
+
*/
|
|
61
127
|
static success(props) {
|
|
62
128
|
let dialogHandler;
|
|
63
129
|
const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {
|
|
@@ -67,6 +133,10 @@ export class ModalDialog extends React.Component {
|
|
|
67
133
|
dialogHandler = method(modalDialogProperties);
|
|
68
134
|
return dialogHandler;
|
|
69
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Opens an information dialog (antd `info`) with the buttons of `props.mode`.
|
|
138
|
+
* @returns a handle to close or update the dialog.
|
|
139
|
+
*/
|
|
70
140
|
static info(props) {
|
|
71
141
|
let dialogHandler;
|
|
72
142
|
const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {
|
|
@@ -83,22 +153,22 @@ export class ModalDialog extends React.Component {
|
|
|
83
153
|
static getModalProperties(props) {
|
|
84
154
|
var _a, _b, _c, _d, _e;
|
|
85
155
|
const { mode } = props, rest = __rest(props, ["mode"]);
|
|
86
|
-
if (mode === "NO_BUTTONS") {
|
|
156
|
+
if (mode === "NO_BUTTONS" /* ModalDialogMode.NO_BUTTONS */) {
|
|
87
157
|
if (rest.footer === undefined) {
|
|
88
158
|
rest.footer = null;
|
|
89
159
|
}
|
|
90
160
|
}
|
|
91
161
|
else {
|
|
92
162
|
switch (mode) {
|
|
93
|
-
case "OK_CANCEL"
|
|
163
|
+
case "OK_CANCEL" /* ModalDialogMode.OK_CANCEL */:
|
|
94
164
|
rest.okText = (_a = props.okText) !== null && _a !== void 0 ? _a : i18n("OK");
|
|
95
165
|
rest.cancelText = (_b = props.cancelText) !== null && _b !== void 0 ? _b : i18n("Cancel");
|
|
96
166
|
break;
|
|
97
|
-
case "YES_NO"
|
|
167
|
+
case "YES_NO" /* ModalDialogMode.YES_NO */:
|
|
98
168
|
rest.okText = (_c = props.okText) !== null && _c !== void 0 ? _c : i18n("Yes");
|
|
99
169
|
rest.cancelText = (_d = props.cancelText) !== null && _d !== void 0 ? _d : i18n("No");
|
|
100
170
|
break;
|
|
101
|
-
case "OK"
|
|
171
|
+
case "OK" /* ModalDialogMode.OK */:
|
|
102
172
|
rest.okText = (_e = props.okText) !== null && _e !== void 0 ? _e : i18n("OK");
|
|
103
173
|
rest.cancelButtonProps = undefined;
|
|
104
174
|
break;
|
|
@@ -112,15 +182,15 @@ export class ModalDialog extends React.Component {
|
|
|
112
182
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
113
183
|
const { mode, denyText, onDeny } = props, rest = __rest(props, ["mode", "denyText", "onDeny"]);
|
|
114
184
|
switch (mode) {
|
|
115
|
-
case "OK_CANCEL"
|
|
185
|
+
case "OK_CANCEL" /* ModalDialogMode.OK_CANCEL */:
|
|
116
186
|
rest.okText = (_a = rest.okText) !== null && _a !== void 0 ? _a : i18n("OK");
|
|
117
187
|
rest.cancelText = (_b = rest.cancelText) !== null && _b !== void 0 ? _b : i18n("Cancel");
|
|
118
188
|
break;
|
|
119
|
-
case "YES_NO"
|
|
189
|
+
case "YES_NO" /* ModalDialogMode.YES_NO */:
|
|
120
190
|
rest.okText = (_c = rest.okText) !== null && _c !== void 0 ? _c : i18n("Yes");
|
|
121
191
|
rest.cancelText = (_d = rest.cancelText) !== null && _d !== void 0 ? _d : i18n("No");
|
|
122
192
|
break;
|
|
123
|
-
case "YES_NO_CANCEL"
|
|
193
|
+
case "YES_NO_CANCEL" /* ModalDialogMode.YES_NO_CANCEL */:
|
|
124
194
|
rest.okText = (_e = rest.okText) !== null && _e !== void 0 ? _e : i18n("Yes");
|
|
125
195
|
rest.cancelText = (React.createElement(React.Fragment, null,
|
|
126
196
|
React.createElement(Button, { onClick: (e) => {
|
|
@@ -136,7 +206,7 @@ export class ModalDialog extends React.Component {
|
|
|
136
206
|
}
|
|
137
207
|
rest.cancelButtonProps.type = "text";
|
|
138
208
|
break;
|
|
139
|
-
case "OK"
|
|
209
|
+
case "OK" /* ModalDialogMode.OK */:
|
|
140
210
|
rest.okText = (_g = props.okText) !== null && _g !== void 0 ? _g : i18n("OK");
|
|
141
211
|
rest.cancelButtonProps = { style: { display: "none" } };
|
|
142
212
|
}
|
|
@@ -144,10 +214,10 @@ export class ModalDialog extends React.Component {
|
|
|
144
214
|
rest.autoFocusButton = "ok";
|
|
145
215
|
}
|
|
146
216
|
rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, { style: { marginRight: 8 } });
|
|
147
|
-
if (mode !== "OK") {
|
|
217
|
+
if (mode !== "OK" /* ModalDialogMode.OK */) {
|
|
148
218
|
rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, { style: { float: "right" } });
|
|
149
219
|
}
|
|
150
|
-
if (mode === "YES_NO_CANCEL") {
|
|
220
|
+
if (mode === "YES_NO_CANCEL" /* ModalDialogMode.YES_NO_CANCEL */) {
|
|
151
221
|
if (rest.cancelButtonProps && rest.cancelButtonProps.style) {
|
|
152
222
|
rest.cancelButtonProps.style.padding = 0;
|
|
153
223
|
rest.cancelButtonProps.style.marginTop = -1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modalDialog.js","sourceRoot":"","sources":["../../../../components/modal/modalDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AAEnC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,cAAc,EAAsB,MAAM,gCAAgC,CAAC;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,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,EAAC,KAAK,EAAE,EAAC,WAAW,EAAE,CAAC,EAAC,EAAC,CAAC,CAAC;QAE1H,IAAI,IAAI,SAAuB,EAAE,CAAC;YAC9B,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAC,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,EAAC,CAAC,CAAC;QAC1I,CAAC;QAED,IAAI,IAAI,oBAAkC,EAAE,CAAC;YACzC,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;gBACzD,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;gBAC5C,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;gBAChD,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,GAAG,aAAa,CAAC;YAC5D,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Button, Modal} from \"antd\";\r\nimport {ModalFuncProps} from \"antd/es/modal\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {DraggableModal, DraggableModalProps} from \"d2coreui/components/modal/impl\";\r\nimport {HookAPI} from \"antd/es/modal/useModal\";\r\n\r\nexport const enum ModalDialogMode {\r\n NO_BUTTONS = \"NO_BUTTONS\",\r\n OK_CANCEL = \"OK_CANCEL\",\r\n YES_NO = \"YES_NO\",\r\n YES_NO_CANCEL = \"YES_NO_CANCEL\",\r\n OK = \"OK\",\r\n}\r\n\r\nexport interface ModalDialogFuncProps extends ModalFuncProps {\r\n mode: ModalDialogMode\r\n denyText?: string\r\n onDeny?: (...args: any[]) => any;\r\n}\r\n\r\nexport interface ModalDialogProps extends DraggableModalProps {\r\n mode: ModalDialogMode\r\n}\r\n\r\nexport class ModalDialog extends React.Component<ModalDialogProps, {}> {\r\n private static modalStatic: HookAPI;\r\n\r\n constructor(props: Readonly<ModalDialogProps>) {\r\n super(props);\r\n }\r\n\r\n public static setModalInstance(instance: HookAPI) {\r\n ModalDialog.modalStatic = instance;\r\n }\r\n\r\n public static confirm(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n public static error(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.error : Modal.error;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n public static delete(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n if (props.okButtonProps) {\r\n props.okButtonProps.danger = true;\r\n }\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n public static success(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.success : Modal.success;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n public static info(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.info : Modal.info;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n render() {\r\n const modalDialogProperties = ModalDialog.getModalProperties(this.props);\r\n return (\r\n <DraggableModal {...modalDialogProperties}>\r\n {this.props.children}\r\n </DraggableModal>);\r\n }\r\n\r\n private static getModalProperties(props: ModalDialogProps) {\r\n const {mode, ...rest} = props;\r\n if (mode === ModalDialogMode.NO_BUTTONS) {\r\n if (rest.footer === undefined) {\r\n rest.footer = null;\r\n }\r\n } else {\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelText = props.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = props.okText ?? i18n(\"Yes\");\r\n rest.cancelText = props.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = undefined;\r\n break;\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n return rest;\r\n }\r\n\r\n private static getModalFuncProperties(props: ModalDialogFuncProps, performClose: () => void) {\r\n const {mode, denyText, onDeny, ...rest} = props;\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"OK\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.YES_NO_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = (<React.Fragment>\r\n <Button onClick={(e) => {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n e.nativeEvent.stopImmediatePropagation();\r\n onDeny?.(e);\r\n performClose();\r\n }}>{denyText ?? i18n(\"No\")}</Button>\r\n <Button>{rest.cancelText ?? i18n(\"Cancel\")}</Button>\r\n </React.Fragment>\r\n );\r\n if (!rest.cancelButtonProps) {\r\n rest.cancelButtonProps = {};\r\n }\r\n rest.cancelButtonProps.type = \"text\";\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = {style: {display: \"none\"}};\r\n }\r\n if (rest.autoFocusButton === undefined) {\r\n rest.autoFocusButton = \"ok\";\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n\r\n if (mode !== ModalDialogMode.OK) {\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n\r\n if (mode === ModalDialogMode.YES_NO_CANCEL) {\r\n if (rest.cancelButtonProps && rest.cancelButtonProps.style) {\r\n rest.cancelButtonProps.style.padding = 0;\r\n rest.cancelButtonProps.style.marginTop = -1;\r\n rest.cancelButtonProps.style.cursor = \"default\";\r\n rest.cancelButtonProps.style.background = \"transparent\";\r\n }\r\n }\r\n return rest;\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"file":"modalDialog.js","sourceRoot":"","sources":["../../../../components/modal/modalDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AAEnC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,cAAc,EAAsB,MAAM,gCAAgC,CAAC;AAGnF;;;GAGG;AACH,MAAM,CAAN,IAAkB,eAiBjB;AAjBD,WAAkB,eAAe;IAC7B;;;OAGG;IACH,4CAAyB,CAAA;IACzB,iCAAiC;IACjC,0CAAuB,CAAA;IACvB,mDAAmD;IACnD,oCAAiB,CAAA;IACjB;;;OAGG;IACH,kDAA+B,CAAA;IAC/B,qFAAqF;IACrF,4BAAS,CAAA;AACb,CAAC,EAjBiB,eAAe,KAAf,eAAe,QAiBhC;AA2BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,SAA+B;IAGlE,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,gBAAgB,CAAC,QAAiB;QAC5C,WAAW,CAAC,WAAW,GAAG,QAAQ,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,OAAO,CAAC,KAA2B;QAC7C,IAAI,aAAmF,CAAC;QACxF,MAAM,qBAAqB,GAAG,WAAW,CAAC,sBAAsB,CAAC,KAAK,EAAE,GAAG,EAAE;YACzE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO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AAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;gBAC5C,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;gBAChD,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,GAAG,aAAa,CAAC;YAC5D,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Button, Modal} from \"antd\";\r\nimport {ModalFuncProps} from \"antd/es/modal\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {DraggableModal, DraggableModalProps} from \"d2coreui/components/modal/impl\";\r\nimport {HookAPI} from \"antd/es/modal/useModal\";\r\n\r\n/**\r\n * Button set of a {@link ModalDialog}. Button labels are localized and can be overridden with `okText` /\r\n * `cancelText` (and `denyText`).\r\n */\r\nexport const enum ModalDialogMode {\r\n /**\r\n * No footer, unless a `footer` is given explicitly. Honored only by the component; the static methods show\r\n * antd's default buttons.\r\n */\r\n NO_BUTTONS = \"NO_BUTTONS\",\r\n /** \"OK\" and \"Cancel\" buttons. */\r\n OK_CANCEL = \"OK_CANCEL\",\r\n /** \"Yes\" and \"No\" buttons; \"No\" acts as cancel. */\r\n YES_NO = \"YES_NO\",\r\n /**\r\n * \"Yes\", \"No\" and \"Cancel\" buttons: \"Yes\" calls `onOk`, \"No\" calls `onDeny` and \"Cancel\" `onCancel`.\r\n * Supported only by the static methods; the component renders antd's default buttons in this mode.\r\n */\r\n YES_NO_CANCEL = \"YES_NO_CANCEL\",\r\n /** Only an \"OK\" button (see the note at {@link ModalDialog} about the component). */\r\n OK = \"OK\",\r\n}\r\n\r\n/**\r\n * Options of the static {@link ModalDialog} methods: antd `ModalFuncProps` plus the button mode.\r\n * `autoFocusButton` defaults to `\"ok\"`.\r\n */\r\nexport interface ModalDialogFuncProps extends ModalFuncProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n /** Label of the \"No\" button in {@link ModalDialogMode.YES_NO_CANCEL} mode; defaults to localized \"No\". */\r\n denyText?: string\r\n /**\r\n * Called with the click event when the \"No\" button is clicked in {@link ModalDialogMode.YES_NO_CANCEL} mode;\r\n * the dialog is closed afterwards.\r\n */\r\n onDeny?: (...args: any[]) => any;\r\n}\r\n\r\n/**\r\n * Props of the {@link ModalDialog} component: antd `ModalProps` (except `width`) plus `initialWidth`,\r\n * `initialHeight`, `maximizable` and `onResize` of the draggable modal, and the button mode.\r\n */\r\nexport interface ModalDialogProps extends DraggableModalProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n}\r\n\r\n/**\r\n * Dialog with a predefined, localized button set (see {@link ModalDialogMode}).\r\n *\r\n * As a component it renders a draggable (by the title), resizable (bottom-right handle) and maximizable antd\r\n * `Modal` that is kept inside the window and destroyed when hidden. It must be rendered inside a\r\n * `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.\r\n * Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static\r\n * methods hide it.\r\n *\r\n * The static methods open imperative antd dialogs; register the app's modal API once with\r\n * {@link ModalDialog.setModalInstance}. They modify the passed `okButtonProps` / `cancelButtonProps` objects and\r\n * replace their `style`.\r\n *\r\n * @example\r\n * <DraggableModalProvider>\r\n * <ModalDialog mode={ModalDialogMode.OK_CANCEL} open={open} title=\"Rename\"\r\n * initialWidth={480} initialHeight={240}\r\n * onOk={save} onCancel={() => setOpen(false)}>\r\n * <Input value={name} onChange={e => setName(e.target.value)}/>\r\n * </ModalDialog>\r\n * </DraggableModalProvider>\r\n *\r\n * @example\r\n * ModalDialog.confirm({\r\n * mode: ModalDialogMode.YES_NO_CANCEL,\r\n * title: \"Save changes?\",\r\n * onOk: save,\r\n * onDeny: discard,\r\n * });\r\n */\r\nexport class ModalDialog extends React.Component<ModalDialogProps, {}> {\r\n private static modalStatic: HookAPI;\r\n\r\n constructor(props: Readonly<ModalDialogProps>) {\r\n super(props);\r\n }\r\n\r\n /**\r\n * Registers the antd `modal` API from `App.useApp()` for the static methods, so that their dialogs inherit the app's\r\n * theme, locale and context. Until it is called they fall back to antd's static `Modal` functions.\r\n */\r\n public static setModalInstance(instance: HookAPI) {\r\n ModalDialog.modalStatic = instance;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog (antd `confirm`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static confirm(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an error dialog (antd `error`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static error(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.error : Modal.error;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog like {@link ModalDialog.confirm} with a danger OK button. The button is marked as\r\n * danger only when `props.okButtonProps` is passed (an empty object is enough).\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static delete(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n if (props.okButtonProps) {\r\n props.okButtonProps.danger = true;\r\n }\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a success dialog (antd `success`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static success(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.success : Modal.success;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an information dialog (antd `info`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static info(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.info : Modal.info;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n render() {\r\n const modalDialogProperties = ModalDialog.getModalProperties(this.props);\r\n return (\r\n <DraggableModal {...modalDialogProperties}>\r\n {this.props.children}\r\n </DraggableModal>);\r\n }\r\n\r\n private static getModalProperties(props: ModalDialogProps) {\r\n const {mode, ...rest} = props;\r\n if (mode === ModalDialogMode.NO_BUTTONS) {\r\n if (rest.footer === undefined) {\r\n rest.footer = null;\r\n }\r\n } else {\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelText = props.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = props.okText ?? i18n(\"Yes\");\r\n rest.cancelText = props.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = undefined;\r\n break;\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n return rest;\r\n }\r\n\r\n private static getModalFuncProperties(props: ModalDialogFuncProps, performClose: () => void) {\r\n const {mode, denyText, onDeny, ...rest} = props;\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"OK\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.YES_NO_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = (<React.Fragment>\r\n <Button onClick={(e) => {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n e.nativeEvent.stopImmediatePropagation();\r\n onDeny?.(e);\r\n performClose();\r\n }}>{denyText ?? i18n(\"No\")}</Button>\r\n <Button>{rest.cancelText ?? i18n(\"Cancel\")}</Button>\r\n </React.Fragment>\r\n );\r\n if (!rest.cancelButtonProps) {\r\n rest.cancelButtonProps = {};\r\n }\r\n rest.cancelButtonProps.type = \"text\";\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = {style: {display: \"none\"}};\r\n }\r\n if (rest.autoFocusButton === undefined) {\r\n rest.autoFocusButton = \"ok\";\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n\r\n if (mode !== ModalDialogMode.OK) {\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n\r\n if (mode === ModalDialogMode.YES_NO_CANCEL) {\r\n if (rest.cancelButtonProps && rest.cancelButtonProps.style) {\r\n rest.cancelButtonProps.style.padding = 0;\r\n rest.cancelButtonProps.style.marginTop = -1;\r\n rest.cancelButtonProps.style.cursor = \"default\";\r\n rest.cancelButtonProps.style.background = \"transparent\";\r\n }\r\n }\r\n return rest;\r\n }\r\n}"]}
|
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SelectProps } from "antd";
|
|
3
3
|
import { DefaultOptionType } from "rc-select/lib/Select";
|
|
4
|
+
/** Type of enum values supported by {@link EnumValuePicker}. */
|
|
4
5
|
type EnumTypes = string | number;
|
|
6
|
+
/** Enum object mapping enum keys to their values. */
|
|
5
7
|
type EnumRepresentation<T extends EnumTypes> = {
|
|
6
8
|
[key in string]: T;
|
|
7
9
|
};
|
|
10
|
+
/** Props of {@link EnumValuePicker}; other props are passed to antd `Select`. */
|
|
8
11
|
interface EnumValuePickerProps<T extends EnumTypes> extends Omit<SelectProps<T>, "onChange"> {
|
|
12
|
+
/**
|
|
13
|
+
* Restricts the offered options to these values; a current `value` not in the list is displayed as empty.
|
|
14
|
+
* Options are rebuilt only when `values` changes, not when this list changes.
|
|
15
|
+
*/
|
|
9
16
|
allowedValueTypes?: T[];
|
|
17
|
+
/** The enum object (TypeScript enum or plain key-to-value map); one option per key, labelled by the key. */
|
|
10
18
|
values: EnumRepresentation<T>;
|
|
19
|
+
/** Translates option labels with `i18n`. */
|
|
11
20
|
translateValue?: boolean;
|
|
21
|
+
/** Prefix prepended to the key to form the translation key when {@link EnumValuePickerProps.translateValue} is set. */
|
|
12
22
|
translationPrefix?: string;
|
|
23
|
+
/** Called with the selected enum value; `undefined` when the selection is cleared. */
|
|
13
24
|
onChange?: (value?: T) => void;
|
|
14
25
|
}
|
|
26
|
+
/** State of {@link EnumValuePicker}. */
|
|
15
27
|
interface EnumValuePickerState {
|
|
28
|
+
/** Select options built from the enum. */
|
|
16
29
|
options: DefaultOptionType[];
|
|
17
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* antd `Select` offering the values of an enum, labelled by the (optionally translated) enum keys.
|
|
33
|
+
* Numeric keys (reverse mappings of numeric TypeScript enums) are skipped.
|
|
34
|
+
*/
|
|
18
35
|
export default class EnumValuePicker<T extends EnumTypes> extends React.Component<EnumValuePickerProps<T>, EnumValuePickerState> {
|
|
19
36
|
constructor(props: Readonly<EnumValuePickerProps<T>>);
|
|
20
37
|
componentDidUpdate(prevProps: Readonly<EnumValuePickerProps<T>>): void;
|
|
@@ -12,6 +12,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React from "react";
|
|
13
13
|
import { Select } from "antd";
|
|
14
14
|
import i18n from "d2core/i18n/i18n";
|
|
15
|
+
/**
|
|
16
|
+
* antd `Select` offering the values of an enum, labelled by the (optionally translated) enum keys.
|
|
17
|
+
* Numeric keys (reverse mappings of numeric TypeScript enums) are skipped.
|
|
18
|
+
*/
|
|
15
19
|
export default class EnumValuePicker extends React.Component {
|
|
16
20
|
constructor(props) {
|
|
17
21
|
super(props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enumValuePicker.js","sourceRoot":"","sources":["../../../../components/picker/enumValuePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAc,MAAM,MAAM,CAAC;AAEzC,OAAO,IAAI,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"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\"react\";\r\nimport {Select, SelectProps} from \"antd\";\r\nimport {DefaultOptionType} from \"rc-select/lib/Select\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\n\r\n/** Type of enum values supported by {@link EnumValuePicker}. */\r\ntype EnumTypes = string | number;\r\n/** Enum object mapping enum keys to their values. */\r\ntype EnumRepresentation<T extends EnumTypes> = { [key in string]: T };\r\n\r\n/** Props of {@link EnumValuePicker}; other props are passed to antd `Select`. */\r\ninterface EnumValuePickerProps<T extends EnumTypes> extends Omit<SelectProps<T>, \"onChange\"> {\r\n /**\r\n * Restricts the offered options to these values; a current `value` not in the list is displayed as empty.\r\n * Options are rebuilt only when `values` changes, not when this list changes.\r\n */\r\n allowedValueTypes?: T[]\r\n /** The enum object (TypeScript enum or plain key-to-value map); one option per key, labelled by the key. */\r\n values: EnumRepresentation<T>\r\n /** Translates option labels with `i18n`. */\r\n translateValue?: boolean\r\n /** Prefix prepended to the key to form the translation key when {@link EnumValuePickerProps.translateValue} is set. */\r\n translationPrefix?: string\r\n\r\n /** Called with the selected enum value; `undefined` when the selection is cleared. */\r\n onChange?: (value?: T) => void\r\n}\r\n\r\n/** State of {@link EnumValuePicker}. */\r\ninterface EnumValuePickerState {\r\n /** Select options built from the enum. */\r\n options: DefaultOptionType[]\r\n}\r\n\r\n/**\r\n * antd `Select` offering the values of an enum, labelled by the (optionally translated) enum keys.\r\n * Numeric keys (reverse mappings of numeric TypeScript enums) are skipped.\r\n */\r\nexport default class EnumValuePicker<T extends EnumTypes> extends React.Component<EnumValuePickerProps<T>, EnumValuePickerState> {\r\n constructor(props: Readonly<EnumValuePickerProps<T>>) {\r\n super(props);\r\n this.state = {\r\n options: this.getOptions(props.values, props.allowedValueTypes, props.translateValue, props.translationPrefix),\r\n }\r\n }\r\n\r\n componentDidUpdate(prevProps: Readonly<EnumValuePickerProps<T>>) {\r\n if (prevProps.values !== this.props.values) {\r\n const {values, allowedValueTypes, translateValue, translationPrefix} = this.props;\r\n this.setState({options: this.getOptions(values, allowedValueTypes, translateValue, translationPrefix)});\r\n }\r\n }\r\n\r\n render() {\r\n const {value, allowedValueTypes, onChange, translationPrefix, values, translateValue, ...others} = this.props;\r\n let selectValue: T | null | undefined = value;\r\n\r\n if (selectValue !== undefined && selectValue !== null && allowedValueTypes) {\r\n if (!allowedValueTypes.includes(selectValue)) {\r\n selectValue = undefined;\r\n }\r\n }\r\n\r\n return (\r\n <Select<T> value={selectValue}\r\n onChange={(value) => {\r\n onChange?.(value !== \"\" ? value : undefined);\r\n }}\r\n options={this.state.options}\r\n {...others} />\r\n );\r\n }\r\n\r\n private getOptions(enumValue: EnumRepresentation<T>, allowedValueTypes?: T[], translateValue?: boolean, translationPrefix?: string): DefaultOptionType[] {\r\n return Object.keys(enumValue)\r\n .filter((key) => isNaN(Number(key)) && (!allowedValueTypes || allowedValueTypes.includes(enumValue[key])))\r\n .map((key) => [enumValue[key], key])\r\n .map(([k, v]) => {\r\n let text: EnumTypes = v;\r\n\r\n if (translateValue) {\r\n text = i18n((translationPrefix ?? \"\") + text);\r\n }\r\n\r\n return {\r\n value: k,\r\n label: text,\r\n } as DefaultOptionType\r\n });\r\n }\r\n}"]}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hooks through which d2coreui components (e.g. the data grid configuration and export) call into the hosting
|
|
3
|
+
* application. This base implementation is a browser-only fallback with mostly no-op methods; the host replaces
|
|
4
|
+
* {@link PlatformSpecific.INSTANCE} with a subclass at startup.
|
|
5
|
+
*/
|
|
1
6
|
export default class PlatformSpecific {
|
|
7
|
+
/** The implementation used by the components; assign a subclass instance to customize the behavior. */
|
|
2
8
|
static INSTANCE: PlatformSpecific;
|
|
9
|
+
/** Returns the display name of the current window (used e.g. in saved configuration names); `""` in the base implementation. */
|
|
3
10
|
getCurrentWindowName(): string;
|
|
11
|
+
/** Returns `true` when the user must not change and save configurations (e.g. grid layout, row styles); `false` in the base implementation. */
|
|
4
12
|
configurationChangesDisabled(): boolean;
|
|
13
|
+
/** Reloads the current window with its predefined (saved) configuration; no-op in the base implementation. */
|
|
5
14
|
reloadPageInPredefinedState(): void;
|
|
15
|
+
/** Reloads the current window with its factory (default) configuration; no-op in the base implementation. */
|
|
6
16
|
reloadPageInFactoryState(): void;
|
|
17
|
+
/** Saves the configuration of the current window; no-op in the base implementation. */
|
|
7
18
|
saveWindowConfiguration(): void;
|
|
19
|
+
/** Exports the configuration of the current window to a file; no-op in the base implementation. */
|
|
8
20
|
exportWindowConfiguration(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Saves content to a file. The base implementation triggers a browser download of a `data:text/plain` URL.
|
|
23
|
+
* @param encodeContent `true` when `content` is raw text that the implementation must encode (the base one
|
|
24
|
+
* URI-encodes it); `false` when it is already encoded
|
|
25
|
+
*/
|
|
9
26
|
saveContent(fileName: string, content: string, encodeContent?: boolean): void;
|
|
10
27
|
}
|
|
@@ -1,18 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hooks through which d2coreui components (e.g. the data grid configuration and export) call into the hosting
|
|
3
|
+
* application. This base implementation is a browser-only fallback with mostly no-op methods; the host replaces
|
|
4
|
+
* {@link PlatformSpecific.INSTANCE} with a subclass at startup.
|
|
5
|
+
*/
|
|
1
6
|
export default class PlatformSpecific {
|
|
7
|
+
/** Returns the display name of the current window (used e.g. in saved configuration names); `""` in the base implementation. */
|
|
2
8
|
getCurrentWindowName() {
|
|
3
9
|
return "";
|
|
4
10
|
}
|
|
11
|
+
/** Returns `true` when the user must not change and save configurations (e.g. grid layout, row styles); `false` in the base implementation. */
|
|
5
12
|
configurationChangesDisabled() {
|
|
6
13
|
return false;
|
|
7
14
|
}
|
|
15
|
+
/** Reloads the current window with its predefined (saved) configuration; no-op in the base implementation. */
|
|
8
16
|
reloadPageInPredefinedState() {
|
|
9
17
|
}
|
|
18
|
+
/** Reloads the current window with its factory (default) configuration; no-op in the base implementation. */
|
|
10
19
|
reloadPageInFactoryState() {
|
|
11
20
|
}
|
|
21
|
+
/** Saves the configuration of the current window; no-op in the base implementation. */
|
|
12
22
|
saveWindowConfiguration() {
|
|
13
23
|
}
|
|
24
|
+
/** Exports the configuration of the current window to a file; no-op in the base implementation. */
|
|
14
25
|
exportWindowConfiguration() {
|
|
15
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Saves content to a file. The base implementation triggers a browser download of a `data:text/plain` URL.
|
|
29
|
+
* @param encodeContent `true` when `content` is raw text that the implementation must encode (the base one
|
|
30
|
+
* URI-encodes it); `false` when it is already encoded
|
|
31
|
+
*/
|
|
16
32
|
saveContent(fileName, content, encodeContent) {
|
|
17
33
|
var element = document.createElement('a');
|
|
18
34
|
const encodedContent = encodeContent ? encodeURIComponent(content) : content;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformSpecific.js","sourceRoot":"","sources":["../../../components/platformSpecific.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,gBAAgB;
|
|
1
|
+
{"version":3,"file":"platformSpecific.js","sourceRoot":"","sources":["../../../components/platformSpecific.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAIjC,gIAAgI;IAChI,oBAAoB;QAChB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,+IAA+I;IAC/I,4BAA4B;QACxB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,8GAA8G;IAC9G,2BAA2B;IAC3B,CAAC;IAED,6GAA6G;IAC7G,wBAAwB;IAExB,CAAC;IAED,uFAAuF;IACvF,uBAAuB;IAEvB,CAAC;IAED,mGAAmG;IACnG,yBAAyB;IAEzB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,QAAgB,EAAE,OAAe,EAAE,aAAuB;QAClE,IAAI,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,cAAc,GAAG,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAC7E,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,gCAAgC,GAAG,cAAc,CAAC,CAAC;QAChF,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACJ;AAED,gBAAgB,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC","sourcesContent":["/**\r\n * Hooks through which d2coreui components (e.g. the data grid configuration and export) call into the hosting\r\n * application. This base implementation is a browser-only fallback with mostly no-op methods; the host replaces\r\n * {@link PlatformSpecific.INSTANCE} with a subclass at startup.\r\n */\r\nexport default class PlatformSpecific {\r\n /** The implementation used by the components; assign a subclass instance to customize the behavior. */\r\n static INSTANCE: PlatformSpecific;\r\n\r\n /** Returns the display name of the current window (used e.g. in saved configuration names); `\"\"` in the base implementation. */\r\n getCurrentWindowName(): string {\r\n return \"\";\r\n }\r\n\r\n /** Returns `true` when the user must not change and save configurations (e.g. grid layout, row styles); `false` in the base implementation. */\r\n configurationChangesDisabled(): boolean {\r\n return false;\r\n }\r\n\r\n /** Reloads the current window with its predefined (saved) configuration; no-op in the base implementation. */\r\n reloadPageInPredefinedState(): void {\r\n }\r\n\r\n /** Reloads the current window with its factory (default) configuration; no-op in the base implementation. */\r\n reloadPageInFactoryState(): void {\r\n\r\n }\r\n\r\n /** Saves the configuration of the current window; no-op in the base implementation. */\r\n saveWindowConfiguration(): void {\r\n\r\n }\r\n\r\n /** Exports the configuration of the current window to a file; no-op in the base implementation. */\r\n exportWindowConfiguration(): void {\r\n\r\n }\r\n\r\n /**\r\n * Saves content to a file. The base implementation triggers a browser download of a `data:text/plain` URL.\r\n * @param encodeContent `true` when `content` is raw text that the implementation must encode (the base one\r\n * URI-encodes it); `false` when it is already encoded\r\n */\r\n saveContent(fileName: string, content: string, encodeContent?: boolean) {\r\n var element = document.createElement('a');\r\n const encodedContent = encodeContent ? encodeURIComponent(content) : content;\r\n element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodedContent);\r\n element.setAttribute('download', fileName);\r\n element.style.display = 'none';\r\n document.body.appendChild(element);\r\n element.click();\r\n document.body.removeChild(element);\r\n }\r\n}\r\n\r\nPlatformSpecific.INSTANCE = new PlatformSpecific();"]}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
/** Converts a primitive React child to text; `undefined`, `null`, booleans and empty objects give an empty string. */
|
|
2
3
|
export declare const childToString: (child?: React.Key | boolean | {} | null) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Extracts the plain text of React children by concatenating all nested string and number children; elements
|
|
6
|
+
* without children (e.g. `<br/>`, icons) contribute nothing.
|
|
7
|
+
*/
|
|
3
8
|
declare const onlyText: (children: ReactNode) => string;
|
|
4
9
|
export default onlyText;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Children, isValidElement } from 'react';
|
|
2
2
|
const hasChildren = (element) => isValidElement(element) && Boolean(element.props.children);
|
|
3
|
+
/** Converts a primitive React child to text; `undefined`, `null`, booleans and empty objects give an empty string. */
|
|
3
4
|
export const childToString = (child) => {
|
|
4
5
|
if (typeof child === 'undefined' || child === null || typeof child === 'boolean') {
|
|
5
6
|
return '';
|
|
@@ -9,6 +10,10 @@ export const childToString = (child) => {
|
|
|
9
10
|
}
|
|
10
11
|
return child.toString();
|
|
11
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the plain text of React children by concatenating all nested string and number children; elements
|
|
15
|
+
* without children (e.g. `<br/>`, icons) contribute nothing.
|
|
16
|
+
*/
|
|
12
17
|
const onlyText = (children) => {
|
|
13
18
|
if (!(children instanceof Array) && !isValidElement(children)) {
|
|
14
19
|
return childToString(children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onlyText.js","sourceRoot":"","sources":["../../../../components/scrollTo/onlyText.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAC,MAAM,OAAO,CAAC;AAE/C,MAAM,WAAW,GAAG,CAAC,OAAkB,EAAsD,EAAE,CAC3F,cAAc,CAA6B,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAE3F,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAuC,EAAU,EAAE;IAC7E,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/E,OAAO,EAAE,CAAC;IACd,CAAC;IAED,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO,EAAE,CAAC;IACd,CAAC;IAED,OAAQ,KAAyB,CAAC,QAAQ,EAAE,CAAC;AACjD,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,QAAmB,EAAU,EAAE;IAC7C,IAAI,CAAC,CAAC,QAAQ,YAAY,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5D,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAY,EAAE,KAAgB,EAAU,EAAE;QAChF,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;aAAM,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,OAAO,GAAG,EAAE,CAAC;QACjB,CAAC;aAAM,CAAC;YACJ,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,EAAE,EAAE,CAAW,CAAC;AACrB,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import type {ReactElement, ReactNode} from 'react';\r\nimport {Children, isValidElement} from 'react';\r\n\r\nconst hasChildren = (element: ReactNode): element is ReactElement<{ children: ReactNode[] }> =>\r\n isValidElement<{ children?: ReactNode[] }>(element) && Boolean(element.props.children);\r\n\r\nexport const childToString = (child?: React.Key | boolean | {} | null): string => {\r\n if (typeof child === 'undefined' || child === null || typeof child === 'boolean') {\r\n return '';\r\n }\r\n\r\n if (JSON.stringify(child) === '{}') {\r\n return '';\r\n }\r\n\r\n return (child as number | string).toString();\r\n};\r\n\r\nconst onlyText = (children: ReactNode): string => {\r\n if (!(children instanceof Array) && !isValidElement(children)) {\r\n return childToString(children);\r\n }\r\n return Children.toArray(children).reduce((text: string, child: ReactNode): string => {\r\n let newText = '';\r\n if (isValidElement(child) && hasChildren(child)) {\r\n newText = onlyText(child.props.children);\r\n } else if (isValidElement(child) && !hasChildren(child)) {\r\n newText = '';\r\n } else {\r\n newText = childToString(child);\r\n }\r\n return text.concat(newText);\r\n }, '') as string;\r\n};\r\n\r\nexport default onlyText;"]}
|
|
1
|
+
{"version":3,"file":"onlyText.js","sourceRoot":"","sources":["../../../../components/scrollTo/onlyText.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAC,MAAM,OAAO,CAAC;AAE/C,MAAM,WAAW,GAAG,CAAC,OAAkB,EAAsD,EAAE,CAC3F,cAAc,CAA6B,OAAO,CAAC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,CAAC,EAAE,EAAE,CAAW,CAAC;AACrB,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import type {ReactElement, ReactNode} from 'react';\r\nimport {Children, isValidElement} from 'react';\r\n\r\nconst hasChildren = (element: ReactNode): element is ReactElement<{ children: ReactNode[] }> =>\r\n isValidElement<{ children?: ReactNode[] }>(element) && Boolean(element.props.children);\r\n\r\n/** Converts a primitive React child to text; `undefined`, `null`, booleans and empty objects give an empty string. */\r\nexport const childToString = (child?: React.Key | boolean | {} | null): string => {\r\n if (typeof child === 'undefined' || child === null || typeof child === 'boolean') {\r\n return '';\r\n }\r\n\r\n if (JSON.stringify(child) === '{}') {\r\n return '';\r\n }\r\n\r\n return (child as number | string).toString();\r\n};\r\n\r\n/**\r\n * Extracts the plain text of React children by concatenating all nested string and number children; elements\r\n * without children (e.g. `<br/>`, icons) contribute nothing.\r\n */\r\nconst onlyText = (children: ReactNode): string => {\r\n if (!(children instanceof Array) && !isValidElement(children)) {\r\n return childToString(children);\r\n }\r\n return Children.toArray(children).reduce((text: string, child: ReactNode): string => {\r\n let newText = '';\r\n if (isValidElement(child) && hasChildren(child)) {\r\n newText = onlyText(child.props.children);\r\n } else if (isValidElement(child) && !hasChildren(child)) {\r\n newText = '';\r\n } else {\r\n newText = childToString(child);\r\n }\r\n return text.concat(newText);\r\n }, '') as string;\r\n};\r\n\r\nexport default onlyText;"]}
|