d2coreui 23.0.52 → 23.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +154 -0
- package/components/clipboard/clipboardUtils.d.ts +11 -0
- package/components/clipboard/clipboardUtils.js +16 -4
- package/components/clipboard/clipboardUtils.js.map +1 -1
- package/components/codemirror/SyntaxHighlighter.d.ts +13 -0
- package/components/codemirror/SyntaxHighlighter.js +6 -1
- package/components/codemirror/SyntaxHighlighter.js.map +1 -1
- package/components/collapse/expandable.d.ts +10 -0
- package/components/collapse/expandable.js +4 -0
- package/components/collapse/expandable.js.map +1 -1
- package/components/color/colorPicker.d.ts +16 -0
- package/components/color/colorPicker.js +4 -0
- package/components/color/colorPicker.js.map +1 -1
- package/components/color/colorSwatch.d.ts +16 -0
- package/components/color/colorSwatch.js +23 -2
- package/components/color/colorSwatch.js.map +1 -1
- package/components/color/colorUtils.d.ts +9 -0
- package/components/color/colorUtils.js +15 -0
- package/components/color/colorUtils.js.map +1 -1
- package/components/date/dateRangeInput.d.ts +76 -0
- package/components/date/dateRangeInput.js +63 -12
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -0
- package/components/date/dateRangeInputAdvancedPanel.js +7 -0
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
- package/components/date/dateRangeInputConfirm.d.ts +18 -0
- package/components/date/dateRangeInputConfirm.js +12 -0
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +99 -0
- package/components/date/dateTimeInput.js +78 -6
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/date/durationInput.d.ts +37 -0
- package/components/date/durationInput.js +26 -3
- package/components/date/durationInput.js.map +1 -1
- package/components/date/savedIntervals.d.ts +63 -0
- package/components/date/savedIntervals.js +37 -0
- package/components/date/savedIntervals.js.map +1 -1
- package/components/date/savedIntervalsDialog.d.ts +13 -0
- package/components/date/savedIntervalsDialog.js +7 -2
- package/components/date/savedIntervalsDialog.js.map +1 -1
- package/components/form/NiceFormItem.d.ts +9 -0
- package/components/form/NiceFormItem.js +4 -0
- package/components/form/NiceFormItem.js.map +1 -1
- package/components/grid/cell/beanAccessor.d.ts +12 -0
- package/components/grid/cell/beanAccessor.js +8 -0
- package/components/grid/cell/beanAccessor.js.map +1 -1
- package/components/grid/cell/bigNumberCellEditor.d.ts +9 -0
- package/components/grid/cell/bigNumberCellEditor.js +19 -0
- package/components/grid/cell/bigNumberCellEditor.js.map +1 -1
- package/components/grid/cell/cellControl.d.ts +4 -0
- package/components/grid/cell/cellControl.js +14 -0
- package/components/grid/cell/cellControl.js.map +1 -1
- package/components/grid/cell/cellEditorUtils.d.ts +6 -0
- package/components/grid/cell/cellEditorUtils.js +6 -0
- package/components/grid/cell/cellEditorUtils.js.map +1 -1
- package/components/grid/cell/customEnumCellEditor.d.ts +6 -0
- package/components/grid/cell/customEnumCellEditor.js +10 -0
- package/components/grid/cell/customEnumCellEditor.js.map +1 -1
- package/components/grid/cell/dataGridCellEditorComponent.d.ts +26 -0
- package/components/grid/cell/dataGridCellEditorComponent.js +21 -0
- package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -1
- package/components/grid/cell/dateCellEditor.d.ts +6 -0
- package/components/grid/cell/dateCellEditor.js +10 -0
- package/components/grid/cell/dateCellEditor.js.map +1 -1
- package/components/grid/cell/dragListenerFeature.d.ts +6 -0
- package/components/grid/cell/dragListenerFeature.js +6 -0
- package/components/grid/cell/dragListenerFeature.js.map +1 -1
- package/components/grid/cell/durationCellEditor.d.ts +6 -0
- package/components/grid/cell/durationCellEditor.js +14 -0
- package/components/grid/cell/durationCellEditor.js.map +1 -1
- package/components/grid/cell/hexaOctetStringCellEditor.d.ts +6 -0
- package/components/grid/cell/hexaOctetStringCellEditor.js +14 -0
- package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
- package/components/grid/cell/hexaValueCellEditor.d.ts +6 -0
- package/components/grid/cell/hexaValueCellEditor.js +14 -0
- package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
- package/components/grid/cell/numberCellEditor.d.ts +6 -0
- package/components/grid/cell/numberCellEditor.js +15 -0
- package/components/grid/cell/numberCellEditor.js.map +1 -1
- package/components/grid/cell/rangeSelector.d.ts +7 -0
- package/components/grid/cell/rangeSelector.js +59 -5
- package/components/grid/cell/rangeSelector.js.map +1 -1
- package/components/grid/cell/simpleStatusTextCellEditor.d.ts +7 -0
- package/components/grid/cell/simpleStatusTextCellEditor.js +11 -0
- package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
- package/components/grid/cell/statusTextCellEditor.d.ts +7 -0
- package/components/grid/cell/statusTextCellEditor.js +17 -0
- package/components/grid/cell/statusTextCellEditor.js.map +1 -1
- package/components/grid/cell/tableDefaultRowStyleRules.d.ts +31 -0
- package/components/grid/cell/tableDefaultRowStyleRules.js +5 -0
- package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
- package/components/grid/cell/textCellEditor.d.ts +6 -0
- package/components/grid/cell/textCellEditor.js +15 -0
- package/components/grid/cell/textCellEditor.js.map +1 -1
- package/components/grid/cell/withAgGridHooks.d.ts +8 -0
- package/components/grid/cell/withAgGridHooks.js +8 -0
- package/components/grid/cell/withAgGridHooks.js.map +1 -1
- package/components/grid/columnUtils.d.ts +7 -0
- package/components/grid/columnUtils.js +7 -0
- package/components/grid/columnUtils.js.map +1 -1
- package/components/grid/config/columnTransfer.d.ts +18 -0
- package/components/grid/config/columnTransfer.js +14 -3
- package/components/grid/config/columnTransfer.js.map +1 -1
- package/components/grid/config/dataGridEditor.d.ts +31 -0
- package/components/grid/config/dataGridEditor.js +14 -2
- package/components/grid/config/dataGridEditor.js.map +1 -1
- package/components/grid/config/rowHeightCalculator.d.ts +11 -0
- package/components/grid/config/rowHeightCalculator.js +11 -0
- package/components/grid/config/rowHeightCalculator.js.map +1 -1
- package/components/grid/config/rowStylePicker.d.ts +19 -0
- package/components/grid/config/rowStylePicker.js +12 -0
- package/components/grid/config/rowStylePicker.js.map +1 -1
- package/components/grid/dataGrid.d.ts +331 -0
- package/components/grid/dataGrid.js +168 -11
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/detail/detailHeaderPanel.d.ts +11 -0
- package/components/grid/detail/detailHeaderPanel.js +5 -0
- package/components/grid/detail/detailHeaderPanel.js.map +1 -1
- package/components/grid/export/contextMenu.d.ts +31 -0
- package/components/grid/export/contextMenu.js +8 -0
- package/components/grid/export/contextMenu.js.map +1 -1
- package/components/grid/export/progressPopup.d.ts +21 -0
- package/components/grid/export/progressPopup.js +17 -0
- package/components/grid/export/progressPopup.js.map +1 -1
- package/components/grid/export/worker/pdfExport.js +5 -0
- package/components/grid/export/worker/pdfExport.js.map +1 -1
- package/components/grid/extendedDataGrid.d.ts +240 -0
- package/components/grid/extendedDataGrid.js +116 -2
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/grid/filter/customColumnFilter.d.ts +5 -0
- package/components/grid/filter/customColumnFilter.js +5 -0
- package/components/grid/filter/customColumnFilter.js.map +1 -1
- package/components/grid/filter/dataGridColumnFilter.d.ts +19 -0
- package/components/grid/filter/dataGridColumnFilter.js +19 -0
- package/components/grid/filter/dataGridColumnFilter.js.map +1 -1
- package/components/grid/filter/dateColumnFilter.d.ts +6 -0
- package/components/grid/filter/dateColumnFilter.js +6 -0
- package/components/grid/filter/dateColumnFilter.js.map +1 -1
- package/components/grid/filter/textColumnFilter.d.ts +6 -0
- package/components/grid/filter/textColumnFilter.js +6 -0
- package/components/grid/filter/textColumnFilter.js.map +1 -1
- package/components/grid/filter/wildcardQuickFilterEngine.d.ts +21 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js +21 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -1
- package/components/grid/header/simpleHeader.d.ts +17 -0
- package/components/grid/header/simpleHeader.js +20 -0
- package/components/grid/header/simpleHeader.js.map +1 -1
- package/components/grid/panel/dataGridPagination.d.ts +10 -0
- package/components/grid/panel/dataGridPagination.js +5 -0
- package/components/grid/panel/dataGridPagination.js.map +1 -1
- package/components/grid/panel/loadingOverlay.d.ts +5 -0
- package/components/grid/panel/loadingOverlay.js +4 -0
- package/components/grid/panel/loadingOverlay.js.map +1 -1
- package/components/grid/panel/noRecordsOverlay.d.ts +6 -0
- package/components/grid/panel/noRecordsOverlay.js +5 -0
- package/components/grid/panel/noRecordsOverlay.js.map +1 -1
- package/components/grid/panel/tablePagination.d.ts +4 -0
- package/components/grid/panel/tablePagination.js +4 -0
- package/components/grid/panel/tablePagination.js.map +1 -1
- package/components/icons/dropdownArrow.d.ts +3 -0
- package/components/icons/dropdownArrow.js +2 -0
- package/components/icons/dropdownArrow.js.map +1 -1
- package/components/icons/undoIcon.d.ts +2 -0
- package/components/icons/undoIcon.js +2 -0
- package/components/icons/undoIcon.js.map +1 -1
- package/components/input/autoCompleteInput.d.ts +29 -0
- package/components/input/autoCompleteInput.js +7 -0
- package/components/input/autoCompleteInput.js.map +1 -1
- package/components/input/draftUtils.d.ts +7 -0
- package/components/input/draftUtils.js +9 -0
- package/components/input/draftUtils.js.map +1 -1
- package/components/input/hexaFormattedInput.d.ts +9 -0
- package/components/input/hexaFormattedInput.js +3 -0
- package/components/input/hexaFormattedInput.js.map +1 -1
- package/components/input/mask/helpers.d.ts +27 -0
- package/components/input/mask/helpers.js +27 -0
- package/components/input/mask/helpers.js.map +1 -1
- package/components/input/mask/inputMaskCore.d.ts +80 -0
- package/components/input/mask/inputMaskCore.js +90 -0
- package/components/input/mask/inputMaskCore.js.map +1 -1
- package/components/input/mask/pattern.d.ts +24 -0
- package/components/input/mask/pattern.js +26 -0
- package/components/input/mask/pattern.js.map +1 -1
- package/components/input/maskedInput.d.ts +53 -0
- package/components/input/maskedInput.js +44 -4
- package/components/input/maskedInput.js.map +1 -1
- package/components/input/passwordInput.d.ts +7 -0
- package/components/input/passwordInput.js +8 -0
- package/components/input/passwordInput.js.map +1 -1
- package/components/input/simpleAutoComplete.d.ts +6 -0
- package/components/input/simpleAutoComplete.js +6 -0
- package/components/input/simpleAutoComplete.js.map +1 -1
- package/components/input/textarea/extractSpansOfClasses.d.ts +17 -0
- package/components/input/textarea/extractSpansOfClasses.js +26 -1
- package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
- package/components/input/textarea/getRanges.d.ts +7 -0
- package/components/input/textarea/getRanges.js +11 -0
- package/components/input/textarea/getRanges.js.map +1 -1
- package/components/input/textarea/getType.d.ts +5 -0
- package/components/input/textarea/getType.js +5 -0
- package/components/input/textarea/getType.js.map +1 -1
- package/components/input/textarea/highlighedContents.d.ts +4 -0
- package/components/input/textarea/highlighedContents.js +5 -0
- package/components/input/textarea/highlighedContents.js.map +1 -1
- package/components/input/textarea/mentionsWithHighlighting.d.ts +25 -0
- package/components/input/textarea/mentionsWithHighlighting.js +14 -0
- package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
- package/components/keyboard/keyboardUtils.d.ts +6 -0
- package/components/keyboard/keyboardUtils.js +6 -0
- package/components/keyboard/keyboardUtils.js.map +1 -1
- package/components/modal/draggableModalProvider.d.ts +6 -0
- package/components/modal/draggableModalProvider.js +7 -0
- package/components/modal/draggableModalProvider.js.map +1 -1
- package/components/modal/impl/clamp.js +1 -0
- package/components/modal/impl/clamp.js.map +1 -1
- package/components/modal/impl/draggableModal.d.ts +1 -0
- package/components/modal/impl/draggableModal.js +6 -0
- package/components/modal/impl/draggableModal.js.map +1 -1
- package/components/modal/impl/draggableModalContext.js +1 -0
- package/components/modal/impl/draggableModalContext.js.map +1 -1
- package/components/modal/impl/draggableModalInner.js +12 -1
- package/components/modal/impl/draggableModalInner.js.map +1 -1
- package/components/modal/impl/draggableModalReducer.d.ts +7 -1
- package/components/modal/impl/draggableModalReducer.js +6 -1
- package/components/modal/impl/draggableModalReducer.js.map +1 -1
- package/components/modal/impl/draggableModalStyles.d.ts +17 -0
- package/components/modal/impl/draggableModalStyles.js +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,15 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/** A piece of text produced by {@link extractSpansOfClasses}, optionally marked as highlighted. */
|
|
2
3
|
declare class Span {
|
|
4
|
+
/** Offset of the first character in the original text. */
|
|
3
5
|
beginIndex: number;
|
|
6
|
+
/** Offset just after the last character in the original text. */
|
|
4
7
|
endIndex: number;
|
|
8
|
+
/** The text of the piece. */
|
|
5
9
|
text: string;
|
|
10
|
+
/** Whether the piece is highlighted. */
|
|
6
11
|
isMark: boolean;
|
|
12
|
+
/** CSS classes of the highlight. */
|
|
7
13
|
markClasses: Set<string>;
|
|
8
14
|
constructor(text: string, beginIndex: number);
|
|
15
|
+
/** Marks the piece as highlighted and adds the space-separated `className` classes. */
|
|
9
16
|
setMark(className: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Cuts the piece at the original-text offset `beginIndex2`, keeping the left part.
|
|
19
|
+
* @returns the right part, with the same mark state.
|
|
20
|
+
*/
|
|
10
21
|
carve(beginIndex2: number): Span;
|
|
22
|
+
/** The sorted, space-joined highlight classes, or an empty string. */
|
|
11
23
|
get className(): string;
|
|
24
|
+
/** Renders the piece as `<mark>` (highlighted) or `<span>`, keyed by `beginIndex` and titled with its text. */
|
|
12
25
|
render(): React.JSX.Element;
|
|
13
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Splits `value` into consecutive {@link Span} pieces so that each range from `ranges` (as produced by `getRanges`,
|
|
29
|
+
* optionally carrying a `className` property) becomes a marked piece; overlapping ranges combine their classes.
|
|
30
|
+
*/
|
|
14
31
|
export default function extractSpansOfClasses(value: string, ranges: number[][]): Span[];
|
|
15
32
|
export {};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/** A piece of text produced by {@link extractSpansOfClasses}, optionally marked as highlighted. */
|
|
2
3
|
class Span {
|
|
3
4
|
constructor(text, beginIndex) {
|
|
4
5
|
this.beginIndex = beginIndex;
|
|
5
|
-
this.endIndex = beginIndex + text.length;
|
|
6
|
+
this.endIndex = beginIndex + text.length; // Like String.slice, it is inclusive.
|
|
6
7
|
this.text = text;
|
|
7
8
|
this.isMark = false;
|
|
8
9
|
this.markClasses = new Set();
|
|
9
10
|
}
|
|
11
|
+
/** Marks the piece as highlighted and adds the space-separated `className` classes. */
|
|
10
12
|
setMark(className) {
|
|
11
13
|
this.isMark = true;
|
|
12
14
|
if (className) {
|
|
@@ -15,7 +17,12 @@ class Span {
|
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Cuts the piece at the original-text offset `beginIndex2`, keeping the left part.
|
|
22
|
+
* @returns the right part, with the same mark state.
|
|
23
|
+
*/
|
|
18
24
|
carve(beginIndex2) {
|
|
25
|
+
// Carves self to take a bit off the right and returns that carving.
|
|
19
26
|
let rightText = this.text.slice(beginIndex2 - this.beginIndex);
|
|
20
27
|
this.text = this.text.slice(0, beginIndex2 - this.beginIndex);
|
|
21
28
|
this.endIndex = beginIndex2;
|
|
@@ -24,6 +31,7 @@ class Span {
|
|
|
24
31
|
right.markClasses = new Set([...this.markClasses]);
|
|
25
32
|
return right;
|
|
26
33
|
}
|
|
34
|
+
/** The sorted, space-joined highlight classes, or an empty string. */
|
|
27
35
|
get className() {
|
|
28
36
|
if (this.markClasses && this.markClasses.size > 0) {
|
|
29
37
|
return [...this.markClasses].sort().join(" ");
|
|
@@ -32,6 +40,7 @@ class Span {
|
|
|
32
40
|
return "";
|
|
33
41
|
}
|
|
34
42
|
}
|
|
43
|
+
/** Renders the piece as `<mark>` (highlighted) or `<span>`, keyed by `beginIndex` and titled with its text. */
|
|
35
44
|
render() {
|
|
36
45
|
if (this.isMark) {
|
|
37
46
|
let className = this.className;
|
|
@@ -47,7 +56,14 @@ class Span {
|
|
|
47
56
|
}
|
|
48
57
|
}
|
|
49
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Splits `value` into consecutive {@link Span} pieces so that each range from `ranges` (as produced by `getRanges`,
|
|
61
|
+
* optionally carrying a `className` property) becomes a marked piece; overlapping ranges combine their classes.
|
|
62
|
+
*/
|
|
50
63
|
export default function extractSpansOfClasses(value, ranges) {
|
|
64
|
+
/* Returns value broken into a series of Span classes. These
|
|
65
|
+
* can be converted to JSX via the render command.
|
|
66
|
+
*/
|
|
51
67
|
let spans = [new Span(value, 0)];
|
|
52
68
|
for (let range of ranges) {
|
|
53
69
|
let beginIndex = range[0];
|
|
@@ -55,9 +71,12 @@ export default function extractSpansOfClasses(value, ranges) {
|
|
|
55
71
|
let className = range.className;
|
|
56
72
|
for (let i = 0; i < spans.length; i++) {
|
|
57
73
|
let span = spans[i];
|
|
74
|
+
// since spans are sorted, So this is always true: beginIndex >= span.beginIndex.
|
|
58
75
|
if (beginIndex < span.endIndex) {
|
|
59
76
|
if (beginIndex == span.beginIndex) {
|
|
60
77
|
if (endIndex < span.endIndex) {
|
|
78
|
+
// [range]
|
|
79
|
+
// [s p a n]
|
|
61
80
|
let span2 = span.carve(endIndex);
|
|
62
81
|
span.setMark(className);
|
|
63
82
|
spans.splice(i + 1, 0, span2);
|
|
@@ -65,12 +84,16 @@ export default function extractSpansOfClasses(value, ranges) {
|
|
|
65
84
|
i += 1;
|
|
66
85
|
}
|
|
67
86
|
else {
|
|
87
|
+
// [range] or [r a n g e]
|
|
88
|
+
// [span-] [span]
|
|
68
89
|
span.setMark(className);
|
|
69
90
|
beginIndex = span.endIndex;
|
|
70
91
|
}
|
|
71
92
|
}
|
|
72
93
|
else {
|
|
73
94
|
if (endIndex < span.endIndex) {
|
|
95
|
+
// [range]
|
|
96
|
+
// [s p a n]
|
|
74
97
|
let span2 = span.carve(beginIndex);
|
|
75
98
|
let span3 = span2.carve(endIndex);
|
|
76
99
|
span2.setMark(className);
|
|
@@ -79,6 +102,8 @@ export default function extractSpansOfClasses(value, ranges) {
|
|
|
79
102
|
i += 2;
|
|
80
103
|
}
|
|
81
104
|
else {
|
|
105
|
+
// [range] or [range]
|
|
106
|
+
// [s p a n] [span]
|
|
82
107
|
let span2 = span.carve(beginIndex);
|
|
83
108
|
span2.setMark(className);
|
|
84
109
|
spans.splice(i + 1, 0, span2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractSpansOfClasses.js","sourceRoot":"","sources":["../../../../../components/input/textarea/extractSpansOfClasses.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,IAAI;
|
|
1
|
+
{"version":3,"file":"extractSpansOfClasses.js","sourceRoot":"","sources":["../../../../../components/input/textarea/extractSpansOfClasses.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,mGAAmG;AACnG,MAAM,IAAI;IAYN,YAAY,IAAW,EAAE,UAAiB;QACtC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,sCAAsC;QAChF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,uFAAuF;IACvF,OAAO,CAAC,SAAiB;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,SAAS,EAAE,CAAC;YACZ,KAAK,IAAI,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;gBACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAA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AAC;AACjB,CAAC","sourcesContent":["import React from 'react';\r\n\r\n/** A piece of text produced by {@link extractSpansOfClasses}, optionally marked as highlighted. */\r\nclass Span {\r\n /** Offset of the first character in the original text. */\r\n beginIndex: number\r\n /** Offset just after the last character in the original text. */\r\n endIndex: number\r\n /** The text of the piece. */\r\n text: string\r\n /** Whether the piece is highlighted. */\r\n isMark: boolean\r\n /** CSS classes of the highlight. */\r\n markClasses: Set<string>\r\n\r\n constructor(text:string, beginIndex:number) {\r\n this.beginIndex = beginIndex;\r\n this.endIndex = beginIndex + text.length; // Like String.slice, it is inclusive.\r\n this.text = text;\r\n this.isMark = false;\r\n this.markClasses = new Set();\r\n }\r\n\r\n /** Marks the piece as highlighted and adds the space-separated `className` classes. */\r\n setMark(className: string) {\r\n this.isMark = true;\r\n if (className) {\r\n for (let c of className.split(' ')) {\r\n this.markClasses.add(c);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Cuts the piece at the original-text offset `beginIndex2`, keeping the left part.\r\n * @returns the right part, with the same mark state.\r\n */\r\n carve(beginIndex2: number) {\r\n // Carves self to take a bit off the right and returns that carving.\r\n let rightText = this.text.slice(beginIndex2 - this.beginIndex);\r\n this.text = this.text.slice(0, beginIndex2 - this.beginIndex);\r\n this.endIndex = beginIndex2;\r\n\r\n let right = new Span(rightText, beginIndex2);\r\n right.isMark = this.isMark;\r\n right.markClasses = new Set([...this.markClasses]);\r\n\r\n return right;\r\n }\r\n\r\n /** The sorted, space-joined highlight classes, or an empty string. */\r\n get className() {\r\n if (this.markClasses && this.markClasses.size > 0) {\r\n return [...this.markClasses].sort().join(\" \");\r\n } else {\r\n return \"\";\r\n }\r\n }\r\n\r\n /** Renders the piece as `<mark>` (highlighted) or `<span>`, keyed by `beginIndex` and titled with its text. */\r\n render() {\r\n if (this.isMark) {\r\n let className = this.className;\r\n if (className) {\r\n return(\r\n <mark key={this.beginIndex} className={className} title={this.text}>\r\n {this.text}\r\n </mark>\r\n );\r\n } else {\r\n return(<mark key={this.beginIndex} title={this.text}>{this.text}</mark>);\r\n }\r\n } else {\r\n return(<span key={this.beginIndex} title={this.text}>{this.text}</span>);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Splits `value` into consecutive {@link Span} pieces so that each range from `ranges` (as produced by `getRanges`,\r\n * optionally carrying a `className` property) becomes a marked piece; overlapping ranges combine their classes.\r\n */\r\nexport default function extractSpansOfClasses(value:string, ranges:number[][]) {\r\n /* Returns value broken into a series of Span classes. These\r\n * can be converted to JSX via the render command.\r\n */\r\n \r\n let spans = [new Span(value, 0)];\r\n\r\n for (let range of ranges) {\r\n let beginIndex = range[0];\r\n let endIndex = range[1];\r\n let className = (range as any).className as string;\r\n\r\n for (let i = 0; i < spans.length; i++) {\r\n let span = spans[i];\r\n\r\n // since spans are sorted, So this is always true: beginIndex >= span.beginIndex.\r\n if (beginIndex < span.endIndex) {\r\n if (beginIndex == span.beginIndex) {\r\n if (endIndex < span.endIndex) {\r\n // [range]\r\n // [s p a n]\r\n let span2 = span.carve(endIndex);\r\n span.setMark(className);\r\n spans.splice(i + 1, 0, span2);\r\n beginIndex = endIndex;\r\n i += 1;\r\n } else {\r\n // [range] or [r a n g e]\r\n // [span-] [span]\r\n span.setMark(className);\r\n beginIndex = span.endIndex;\r\n }\r\n } else {\r\n if (endIndex < span.endIndex) {\r\n // [range]\r\n // [s p a n]\r\n let span2 = span.carve(beginIndex);\r\n let span3 = span2.carve(endIndex);\r\n span2.setMark(className);\r\n spans.splice(i + 1, 0, span2, span3);\r\n beginIndex = endIndex;\r\n i += 2;\r\n } else {\r\n // [range] or [range]\r\n // [s p a n] [span]\r\n let span2 = span.carve(beginIndex);\r\n span2.setMark(className);\r\n spans.splice(i + 1, 0, span2);\r\n beginIndex = span2.endIndex;\r\n i += 1;\r\n }\r\n }\r\n }\r\n if (beginIndex == endIndex) {\r\n break;\r\n }\r\n }\r\n }\r\n return spans;\r\n}"]}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a highlight specification (see `HighlightType` from `mentionsWithHighlighting`) against `input` into `[start, end)` character ranges:
|
|
3
|
+
* a string matches all case-insensitive occurrences, a RegExp its matches (only the first unless global), a
|
|
4
|
+
* `[start, end]` pair is taken as is, an array is the union of its items, a function is called with `input` and its
|
|
5
|
+
* result resolved again, and `{highlight, className}` resolves `highlight` and attaches `className` to each range as
|
|
6
|
+
* an extra array property. Falsy values give no ranges; unsupported values are logged as an error.
|
|
7
|
+
*/
|
|
1
8
|
export default function getRanges(input: any, highlight: any): number[][];
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import getType from './getType';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a highlight specification (see `HighlightType` from `mentionsWithHighlighting`) against `input` into `[start, end)` character ranges:
|
|
4
|
+
* a string matches all case-insensitive occurrences, a RegExp its matches (only the first unless global), a
|
|
5
|
+
* `[start, end]` pair is taken as is, an array is the union of its items, a function is called with `input` and its
|
|
6
|
+
* result resolved again, and `{highlight, className}` resolves `highlight` and attaches `className` to each range as
|
|
7
|
+
* an extra array property. Falsy values give no ranges; unsupported values are logged as an error.
|
|
8
|
+
*/
|
|
2
9
|
export default function getRanges(input, highlight) {
|
|
3
10
|
let type = getType(highlight);
|
|
4
11
|
switch (type) {
|
|
@@ -16,6 +23,7 @@ export default function getRanges(input, highlight) {
|
|
|
16
23
|
return getCustomRanges(input, highlight);
|
|
17
24
|
default:
|
|
18
25
|
if (!highlight) {
|
|
26
|
+
// do nothing for falsey values
|
|
19
27
|
return [];
|
|
20
28
|
}
|
|
21
29
|
else {
|
|
@@ -37,6 +45,8 @@ function getRegExpRanges(input, regex) {
|
|
|
37
45
|
while (match = regex.exec(input), match !== null) {
|
|
38
46
|
ranges.push([match.index, match.index + match[0].length]);
|
|
39
47
|
if (!regex.global) {
|
|
48
|
+
// non-global regexes do not increase lastIndex, causing an infinite loop,
|
|
49
|
+
// but we can just break manually after the first match
|
|
40
50
|
break;
|
|
41
51
|
}
|
|
42
52
|
}
|
|
@@ -60,6 +70,7 @@ function getCustomRanges(input, custom) {
|
|
|
60
70
|
let ranges = getRanges(input, custom.highlight);
|
|
61
71
|
if (custom.className) {
|
|
62
72
|
ranges.forEach(function (range) {
|
|
73
|
+
// persist class name as a property of the array
|
|
63
74
|
let customRange = range;
|
|
64
75
|
if (customRange.className) {
|
|
65
76
|
customRange.className = custom.className + ' ' + customRange.className;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRanges.js","sourceRoot":"","sources":["../../../../../components/input/textarea/getRanges.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAU,EAAE,SAAc;IACxD,IAAI,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9B,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,OAAO;YACR,OAAO,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC5C,KAAK,UAAU;YACX,OAAO,iBAAiB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC/C,KAAK,QAAQ;YACT,OAAO,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC7C,KAAK,QAAQ;YACT,OAAO,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC7C,KAAK,OAAO;YACR,OAAO,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC5C,KAAK,QAAQ;YACT,OAAO,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAC7C;YACI,IAAI,CAAC,SAAS,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"getRanges.js","sourceRoot":"","sources":["../../../../../components/input/textarea/getRanges.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAU,EAAE,SAAc;IACxD,IA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Y,CAAC;YAC/B,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC;gBACxB,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,GAAG,GAAG,GAAG,WAAW,CAAC,SAAS,CAAC;YAC3E,CAAC;iBAAM,CAAC;gBACJ,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;YAC7C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import getType from './getType';\r\n\r\n/**\r\n * Resolves a highlight specification (see `HighlightType` from `mentionsWithHighlighting`) against `input` into `[start, end)` character ranges:\r\n * a string matches all case-insensitive occurrences, a RegExp its matches (only the first unless global), a\r\n * `[start, end]` pair is taken as is, an array is the union of its items, a function is called with `input` and its\r\n * result resolved again, and `{highlight, className}` resolves `highlight` and attaches `className` to each range as\r\n * an extra array property. Falsy values give no ranges; unsupported values are logged as an error.\r\n */\r\nexport default function getRanges(input: any, highlight: any): number[][] {\r\n let type = getType(highlight);\r\n switch (type) {\r\n case 'array':\r\n return getArrayRanges(input, highlight);\r\n case 'function':\r\n return getFunctionRanges(input, highlight);\r\n case 'regexp':\r\n return getRegExpRanges(input, highlight);\r\n case 'string':\r\n return getStringRanges(input, highlight);\r\n case 'range':\r\n return getRangeRanges(input, highlight);\r\n case 'custom':\r\n return getCustomRanges(input, highlight);\r\n default:\r\n if (!highlight) {\r\n // do nothing for falsey values\r\n return [];\r\n } else {\r\n console.error('unrecognized highlight type');\r\n return [];\r\n }\r\n }\r\n}\r\n\r\nfunction getArrayRanges(input: any[], arr: any[]): number[][] {\r\n let ranges = arr.map(getRanges.bind(null, input));\r\n return Array.prototype.concat.apply([], ranges);\r\n}\r\n\r\nfunction getFunctionRanges(input: string, func: (input: string) => string): number[][] {\r\n return getRanges(input, func(input));\r\n}\r\n\r\nfunction getRegExpRanges(input: string, regex: RegExp) {\r\n let ranges = [];\r\n let match;\r\n while (match = regex.exec(input), match !== null) {\r\n ranges.push([match.index, match.index + match[0].length]);\r\n if (!regex.global) {\r\n // non-global regexes do not increase lastIndex, causing an infinite loop,\r\n // but we can just break manually after the first match\r\n break;\r\n }\r\n }\r\n return ranges;\r\n}\r\n\r\nfunction getStringRanges(input: string, str: string): number[][] {\r\n let ranges = [];\r\n let inputLower = input.toLowerCase();\r\n let strLower = str.toLowerCase();\r\n let index = 0;\r\n while (index = inputLower.indexOf(strLower, index), index !== -1) {\r\n ranges.push([index, index + strLower.length]);\r\n index += strLower.length;\r\n }\r\n return ranges;\r\n}\r\n\r\nfunction getRangeRanges(_input: string, range: number[]): number[][] {\r\n return [range];\r\n}\r\n\r\nfunction getCustomRanges(input: string, custom: { className?: string, highlight: any }): number[][] {\r\n let ranges = getRanges(input, custom.highlight);\r\n if (custom.className) {\r\n ranges.forEach(function (range) {\r\n // persist class name as a property of the array\r\n let customRange = range as any;\r\n if (customRange.className) {\r\n customRange.className = custom.className + ' ' + customRange.className;\r\n } else {\r\n customRange.className = custom.className;\r\n }\r\n });\r\n }\r\n return ranges;\r\n}\r\n"]}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classifies a highlight specification for `getRanges`.
|
|
3
|
+
* @returns one of `falsey`, `range` (a two-number array), `array`, `regexp`, `custom` (an object with a `highlight`
|
|
4
|
+
* property), `function`, `string` or `other`.
|
|
5
|
+
*/
|
|
1
6
|
export default function getType(instance: any): string;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classifies a highlight specification for `getRanges`.
|
|
3
|
+
* @returns one of `falsey`, `range` (a two-number array), `array`, `regexp`, `custom` (an object with a `highlight`
|
|
4
|
+
* property), `function`, `string` or `other`.
|
|
5
|
+
*/
|
|
1
6
|
export default function getType(instance) {
|
|
2
7
|
let type = typeof instance;
|
|
3
8
|
if (!instance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getType.js","sourceRoot":"","sources":["../../../../../components/input/textarea/getType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getType.js","sourceRoot":"","sources":["../../../../../components/input/textarea/getType.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,QAAY;IACxC,IAAI,IAAI,GAAG,OAAO,QAAQ,CAAC;IAC3B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,QAAQ,CAAC;IACpB,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC9F,OAAO,OAAO,CAAC;QACnB,CAAC;aAAM,CAAC;YACJ,OAAO,OAAO,CAAC;QACnB,CAAC;IACL,CAAC;SAAM,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,IAAI,QAAQ,YAAY,MAAM,EAAE,CAAC;YAC7B,OAAO,QAAQ,CAAC;QACpB,CAAC;aAAM,IAAI,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;YAC9C,OAAO,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;SAAM,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QAClD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["/**\r\n * Classifies a highlight specification for `getRanges`.\r\n * @returns one of `falsey`, `range` (a two-number array), `array`, `regexp`, `custom` (an object with a `highlight`\r\n * property), `function`, `string` or `other`.\r\n */\r\nexport default function getType(instance:any):string {\r\n let type = typeof instance;\r\n if (!instance) {\r\n return 'falsey';\r\n } else if (Array.isArray(instance)) {\r\n if (instance.length === 2 && typeof instance[0] === 'number' && typeof instance[1] === 'number') {\r\n return 'range';\r\n } else {\r\n return 'array';\r\n }\r\n } else if (type === 'object') {\r\n if (instance instanceof RegExp) {\r\n return 'regexp';\r\n } else if (instance.hasOwnProperty('highlight')) {\r\n return 'custom';\r\n }\r\n } else if (type === 'function' || type === 'string') {\r\n return type;\r\n }\r\n\r\n return 'other';\r\n}"]}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Renders `value` with the parts matched by `highlight` (see `getRanges`) wrapped in `<mark>` elements, inside a
|
|
4
|
+
* `div.highlight-highlights.highlight-content`. Used as the backdrop of `MentionsWithHighlighting`.
|
|
5
|
+
*/
|
|
2
6
|
declare const HighlighedContents: ({ value, highlight }: {
|
|
3
7
|
value: any;
|
|
4
8
|
highlight: any;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import getRanges from './getRanges';
|
|
3
3
|
import extractSpansOfClasses from './extractSpansOfClasses';
|
|
4
|
+
/**
|
|
5
|
+
* Renders `value` with the parts matched by `highlight` (see `getRanges`) wrapped in `<mark>` elements, inside a
|
|
6
|
+
* `div.highlight-highlights.highlight-content`. Used as the backdrop of `MentionsWithHighlighting`.
|
|
7
|
+
*/
|
|
8
|
+
// @ts-ignore
|
|
4
9
|
const HighlighedContents = ({ value, highlight }) => {
|
|
5
10
|
let ranges = getRanges(value, highlight);
|
|
6
11
|
let parts = extractSpansOfClasses(value, ranges);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highlighedContents.js","sourceRoot":"","sources":["../../../../../components/input/textarea/highlighedContents.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"highlighedContents.js","sourceRoot":"","sources":["../../../../../components/input/textarea/highlighedContents.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAE5D;;;GAGG;AACH,aAAa;AACb,MAAM,kBAAkB,GAAG,CAAC,EAAC,KAAK,EAAE,SAAS,EAAC,EAAE,EAAE;IAE9C,IAAI,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACzC,IAAI,KAAK,GAAG,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEjD,OAAO,CACH;QACI,6BAAK,SAAS,EAAE,wCAAwC,IACnD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAC9B,CACL,CACT,CAAC;AACN,CAAC,CAAA;AAED,eAAe,kBAAkB,CAAA","sourcesContent":["import React from 'react';\r\nimport getRanges from './getRanges';\r\nimport extractSpansOfClasses from './extractSpansOfClasses';\r\n\r\n/**\r\n * Renders `value` with the parts matched by `highlight` (see `getRanges`) wrapped in `<mark>` elements, inside a\r\n * `div.highlight-highlights.highlight-content`. Used as the backdrop of `MentionsWithHighlighting`.\r\n */\r\n// @ts-ignore\r\nconst HighlighedContents = ({value, highlight}) => {\r\n \r\n let ranges = getRanges(value, highlight);\r\n let parts = extractSpansOfClasses(value, ranges);\r\n\r\n return (\r\n <div>\r\n <div className={`highlight-highlights highlight-content`} >\r\n {parts.map(part => part.render())}\r\n </div>\r\n </div>\r\n ); \r\n}\r\n\r\nexport default HighlighedContents"]}
|
|
@@ -1,26 +1,51 @@
|
|
|
1
1
|
import React, { CSSProperties } from 'react';
|
|
2
2
|
import './highlightedTextarea.css';
|
|
3
3
|
import { MentionProps } from "antd/lib/mentions";
|
|
4
|
+
/** A highlight whose matches get an extra CSS class. */
|
|
4
5
|
export interface HighlightItem {
|
|
6
|
+
/** What to highlight. */
|
|
5
7
|
highlight: HighlightType;
|
|
8
|
+
/** CSS class(es) added to the `<mark>` elements of the matches. */
|
|
6
9
|
className: string;
|
|
7
10
|
}
|
|
11
|
+
/** Computes the highlight from the current text; called on every render. */
|
|
8
12
|
export type AssignHighlightFunction = (value: string) => HighlightType;
|
|
13
|
+
/**
|
|
14
|
+
* What to highlight in the text: a string (all case-insensitive occurrences), a RegExp (all matches if global,
|
|
15
|
+
* otherwise the first), a `[start, end)` character range, a function returning another highlight, or an array of
|
|
16
|
+
* any of these, including {@link HighlightItem}s. `false` highlights nothing; `true` is not supported (it is
|
|
17
|
+
* logged as an error).
|
|
18
|
+
*/
|
|
9
19
|
export type HighlightType = boolean | string | RegExp | [number, number] | HighlightType[] | AssignHighlightFunction | HighlightItem[];
|
|
10
20
|
interface MentionsWithHighlightingProps extends MentionProps {
|
|
21
|
+
/** Parts of the text to highlight. */
|
|
11
22
|
highlight?: HighlightType;
|
|
23
|
+
/** Style of the wrapping element; `style` applies to the textarea. */
|
|
12
24
|
containerStyle?: CSSProperties;
|
|
25
|
+
/** Extra class of the wrapping element (which always has `highlight-container`). */
|
|
13
26
|
containerClassName?: string;
|
|
14
27
|
}
|
|
15
28
|
interface MentionsWithHighlightingState {
|
|
16
29
|
fakeValue: string;
|
|
17
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* antd `Mentions` textarea that highlights parts of its text (see {@link HighlightType}) by rendering them as
|
|
33
|
+
* `<mark>` elements in a backdrop behind the transparent textarea. Based on
|
|
34
|
+
* https://github.com/bonafideduck/react-highlight-within-textarea.
|
|
35
|
+
* Controlled only: the highlights follow the `value` prop, so pass `value` together with `onChange`.
|
|
36
|
+
* Manual resizing is disabled (`resize: none` is forced into `style`).
|
|
37
|
+
*/
|
|
18
38
|
export declare class MentionsWithHighlighting extends React.Component<MentionsWithHighlightingProps, MentionsWithHighlightingState> {
|
|
39
|
+
/** The rendered antd `Mentions` instance. */
|
|
19
40
|
mentionsComponent: any | null;
|
|
41
|
+
/** The element behind the textarea that renders the highlights. */
|
|
20
42
|
backdropComponent: HTMLDivElement | null;
|
|
21
43
|
constructor(props: Readonly<MentionsWithHighlightingProps>);
|
|
44
|
+
/** Keeps the highlight backdrop scrolled in step with the textarea. Replaces any `onScroll` prop. */
|
|
22
45
|
handleScroll: () => void;
|
|
46
|
+
/** Not used by the component: stores `value` in the unused internal state. */
|
|
23
47
|
onChange: (value?: string) => void;
|
|
48
|
+
/** The underlying DOM textarea, or `undefined` before mount. */
|
|
24
49
|
get textarea(): HTMLTextAreaElement | undefined;
|
|
25
50
|
render(): React.JSX.Element;
|
|
26
51
|
}
|
|
@@ -13,12 +13,22 @@ import React from 'react';
|
|
|
13
13
|
import './highlightedTextarea.css';
|
|
14
14
|
import HighlighedContents from './highlighedContents';
|
|
15
15
|
import { Mentions } from "antd";
|
|
16
|
+
/**
|
|
17
|
+
* antd `Mentions` textarea that highlights parts of its text (see {@link HighlightType}) by rendering them as
|
|
18
|
+
* `<mark>` elements in a backdrop behind the transparent textarea. Based on
|
|
19
|
+
* https://github.com/bonafideduck/react-highlight-within-textarea.
|
|
20
|
+
* Controlled only: the highlights follow the `value` prop, so pass `value` together with `onChange`.
|
|
21
|
+
* Manual resizing is disabled (`resize: none` is forced into `style`).
|
|
22
|
+
*/
|
|
16
23
|
export class MentionsWithHighlighting extends React.Component {
|
|
17
24
|
constructor(props) {
|
|
18
25
|
var _a;
|
|
19
26
|
super(props);
|
|
27
|
+
/** The rendered antd `Mentions` instance. */
|
|
20
28
|
this.mentionsComponent = null;
|
|
29
|
+
/** The element behind the textarea that renders the highlights. */
|
|
21
30
|
this.backdropComponent = null;
|
|
31
|
+
/** Keeps the highlight backdrop scrolled in step with the textarea. Replaces any `onScroll` prop. */
|
|
22
32
|
this.handleScroll = () => {
|
|
23
33
|
if (this.backdropComponent) {
|
|
24
34
|
if (this.mentionsComponent) {
|
|
@@ -28,7 +38,9 @@ export class MentionsWithHighlighting extends React.Component {
|
|
|
28
38
|
}
|
|
29
39
|
}
|
|
30
40
|
};
|
|
41
|
+
/** Not used by the component: stores `value` in the unused internal state. */
|
|
31
42
|
this.onChange = (value) => {
|
|
43
|
+
// To properly work, value and onChange must be supplied. Give a hint for new users.
|
|
32
44
|
if (value == undefined) {
|
|
33
45
|
value = this.state.fakeValue;
|
|
34
46
|
}
|
|
@@ -38,6 +50,7 @@ export class MentionsWithHighlighting extends React.Component {
|
|
|
38
50
|
fakeValue: (_a = props.value) !== null && _a !== void 0 ? _a : ""
|
|
39
51
|
};
|
|
40
52
|
}
|
|
53
|
+
/** The underlying DOM textarea, or `undefined` before mount. */
|
|
41
54
|
get textarea() {
|
|
42
55
|
var _a;
|
|
43
56
|
return (_a = this.mentionsComponent) === null || _a === void 0 ? void 0 : _a.textarea;
|
|
@@ -46,6 +59,7 @@ export class MentionsWithHighlighting extends React.Component {
|
|
|
46
59
|
let _a = this.props, { value, onChange, highlight = {}, className = "", style = {}, containerStyle = {}, containerClassName = "", onScroll } = _a, restProps = __rest(_a, ["value", "onChange", "highlight", "className", "style", "containerStyle", "containerClassName", "onScroll"]);
|
|
47
60
|
className = `highlight-input ${!this.props.disabled ? "highlight-content" : ""} ${className}`;
|
|
48
61
|
containerClassName = `highlight-container ${containerClassName}`;
|
|
62
|
+
// Resizing is currently not supported
|
|
49
63
|
style.resize = "none";
|
|
50
64
|
style.wordWrap = "break-word";
|
|
51
65
|
return (React.createElement("div", { className: containerClassName, style: containerStyle },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mentionsWithHighlighting.js","sourceRoot":"","sources":["../../../../../components/input/textarea/mentionsWithHighlighting.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,2BAA2B,CAAC;AACnC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAC,QAAQ,EAAC,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"mentionsWithHighlighting.js","sourceRoot":"","sources":["../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CACJ","sourcesContent":["import React, {CSSProperties} from 'react';\r\nimport './highlightedTextarea.css';\r\nimport HighlighedContents from './highlighedContents';\r\nimport {MentionProps} from \"antd/lib/mentions\";\r\nimport {Mentions} from \"antd\";\r\n\r\n/** A highlight whose matches get an extra CSS class. */\r\nexport interface HighlightItem {\r\n /** What to highlight. */\r\n highlight: HighlightType\r\n /** CSS class(es) added to the `<mark>` elements of the matches. */\r\n className: string\r\n}\r\n\r\n/** Computes the highlight from the current text; called on every render. */\r\nexport type AssignHighlightFunction = (value: string) => HighlightType;\r\n/**\r\n * What to highlight in the text: a string (all case-insensitive occurrences), a RegExp (all matches if global,\r\n * otherwise the first), a `[start, end)` character range, a function returning another highlight, or an array of\r\n * any of these, including {@link HighlightItem}s. `false` highlights nothing; `true` is not supported (it is\r\n * logged as an error).\r\n */\r\nexport type HighlightType =\r\n boolean\r\n | string\r\n | RegExp\r\n | [number, number]\r\n | HighlightType[]\r\n | AssignHighlightFunction\r\n | HighlightItem[];\r\n\r\ninterface MentionsWithHighlightingProps extends MentionProps {\r\n /** Parts of the text to highlight. */\r\n highlight?: HighlightType\r\n /** Style of the wrapping element; `style` applies to the textarea. */\r\n containerStyle?: CSSProperties\r\n /** Extra class of the wrapping element (which always has `highlight-container`). */\r\n containerClassName?: string\r\n}\r\n\r\ninterface MentionsWithHighlightingState {\r\n fakeValue: string\r\n}\r\n\r\n/**\r\n * antd `Mentions` textarea that highlights parts of its text (see {@link HighlightType}) by rendering them as\r\n * `<mark>` elements in a backdrop behind the transparent textarea. Based on\r\n * https://github.com/bonafideduck/react-highlight-within-textarea.\r\n * Controlled only: the highlights follow the `value` prop, so pass `value` together with `onChange`.\r\n * Manual resizing is disabled (`resize: none` is forced into `style`).\r\n */\r\nexport class MentionsWithHighlighting extends React.Component<MentionsWithHighlightingProps, MentionsWithHighlightingState> {\r\n /** The rendered antd `Mentions` instance. */\r\n mentionsComponent: any | null = null;\r\n /** The element behind the textarea that renders the highlights. */\r\n backdropComponent: HTMLDivElement | null = null;\r\n\r\n constructor(props: Readonly<MentionsWithHighlightingProps>) {\r\n super(props);\r\n this.state = {\r\n fakeValue: props.value ?? \"\"\r\n }\r\n }\r\n\r\n /** Keeps the highlight backdrop scrolled in step with the textarea. Replaces any `onScroll` prop. */\r\n handleScroll = () => {\r\n if (this.backdropComponent) {\r\n if (this.mentionsComponent) {\r\n const textArea = (this.mentionsComponent as any).textarea as HTMLTextAreaElement\r\n this.backdropComponent.scrollTop = textArea.scrollTop;\r\n this.backdropComponent.scrollLeft = textArea.scrollLeft;\r\n }\r\n }\r\n };\r\n\r\n /** Not used by the component: stores `value` in the unused internal state. */\r\n onChange = (value?:string) => {\r\n // To properly work, value and onChange must be supplied. Give a hint for new users.\r\n if (value == undefined) {\r\n value = this.state.fakeValue;\r\n }\r\n this.setState({fakeValue: value});\r\n };\r\n\r\n /** The underlying DOM textarea, or `undefined` before mount. */\r\n get textarea() : HTMLTextAreaElement | undefined {\r\n return (this.mentionsComponent as any)?.textarea as HTMLTextAreaElement;\r\n }\r\n\r\n render() {\r\n let {value, onChange, highlight = {}, className = \"\", style = {}, containerStyle = {}, containerClassName = \"\", onScroll, ...restProps} = this.props;\r\n\r\n className = `highlight-input ${!this.props.disabled ? \"highlight-content\": \"\"} ${className}`;\r\n containerClassName = `highlight-container ${containerClassName}`;\r\n\r\n // Resizing is currently not supported\r\n style.resize = \"none\";\r\n style.wordWrap = \"break-word\";\r\n\r\n\r\n\r\n return (\r\n <div className={containerClassName} style={containerStyle}>\r\n <div className={\"highlight-backdrop\"} ref={(component)=> {\r\n this.backdropComponent = component;\r\n }}>\r\n <HighlighedContents value={value} highlight={highlight}/>\r\n </div>\r\n <Mentions value={value} onChange={onChange} style={{...style}} className={className} {...restProps}\r\n onScroll={this.handleScroll} ref={(component) => {\r\n this.mentionsComponent = component\r\n }}>\r\n </Mentions>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Key } from "ts-key-enum";
|
|
2
|
+
/**
|
|
3
|
+
* Global keyboard and mouse state. Importing this module installs `keydown`/`keyup`/`mousedown`/`mouseup`
|
|
4
|
+
* listeners on `window`; pressed keys are reset when the window loses focus.
|
|
5
|
+
*/
|
|
2
6
|
export default class KeyboardUtils {
|
|
7
|
+
/** Returns whether the key (compared with `KeyboardEvent.key`) is currently held down. */
|
|
3
8
|
static isKeyPressed(key: Key): boolean;
|
|
9
|
+
/** Returns whether any mouse button is currently held down within the window. */
|
|
4
10
|
static isMouseDown(): boolean;
|
|
5
11
|
}
|
|
@@ -22,10 +22,16 @@ window.addEventListener("keyup", keyUp);
|
|
|
22
22
|
window.addEventListener("blur", reset);
|
|
23
23
|
window.addEventListener("mousedown", onMouseDown);
|
|
24
24
|
window.addEventListener("mouseup", onMouseUp);
|
|
25
|
+
/**
|
|
26
|
+
* Global keyboard and mouse state. Importing this module installs `keydown`/`keyup`/`mousedown`/`mouseup`
|
|
27
|
+
* listeners on `window`; pressed keys are reset when the window loses focus.
|
|
28
|
+
*/
|
|
25
29
|
export default class KeyboardUtils {
|
|
30
|
+
/** Returns whether the key (compared with `KeyboardEvent.key`) is currently held down. */
|
|
26
31
|
static isKeyPressed(key) {
|
|
27
32
|
return !!pressedKeys[key];
|
|
28
33
|
}
|
|
34
|
+
/** Returns whether any mouse button is currently held down within the window. */
|
|
29
35
|
static isMouseDown() {
|
|
30
36
|
return mouseDown > 0;
|
|
31
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardUtils.js","sourceRoot":"","sources":["../../../../components/keyboard/keyboardUtils.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAQ,EAAE,CAAC;AAC5B,IAAI,SAAS,GAAW,CAAC,CAAC;AAE1B,SAAS,OAAO,CAAC,CAAgB;IAC7B,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAC9B,CAAC;AAED,SAAS,KAAK,CAAC,CAAgB;IAC3B,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC/B,CAAC;AAED,SAAS,KAAK;IACV,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACrC,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC7B,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,WAAW;IAChB,SAAS,EAAE,CAAC;AAChB,CAAC;AAED,SAAS,SAAS;IACd,SAAS,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC5C,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACxC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACvC,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAClD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAE9C,MAAM,CAAC,OAAO,OAAO,aAAa;IAC9B,MAAM,CAAC,YAAY,CAAC,GAAQ;QACxB,OAAO,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,WAAW;QACd,OAAO,SAAS,GAAG,CAAC,CAAC;IACzB,CAAC;CACJ","sourcesContent":["import {Key} from \"ts-key-enum\";\r\n\r\nconst pressedKeys: any = {};\r\nlet mouseDown: number = 0;\r\n\r\nfunction keyDown(e: KeyboardEvent) {\r\n pressedKeys[e.key] = true;\r\n}\r\n\r\nfunction keyUp(e: KeyboardEvent) {\r\n pressedKeys[e.key] = false;\r\n}\r\n\r\nfunction reset() {\r\n Object.keys(pressedKeys).forEach((key) => {\r\n pressedKeys[key] = false;\r\n });\r\n}\r\n\r\nfunction onMouseDown() {\r\n mouseDown++;\r\n}\r\n\r\nfunction onMouseUp() {\r\n mouseDown--;\r\n}\r\n\r\nwindow.addEventListener(\"keydown\", keyDown);\r\nwindow.addEventListener(\"keyup\", keyUp);\r\nwindow.addEventListener(\"blur\", reset);\r\nwindow.addEventListener(\"mousedown\", onMouseDown);\r\nwindow.addEventListener(\"mouseup\", onMouseUp);\r\n\r\nexport default class KeyboardUtils {\r\n static isKeyPressed(key: Key): boolean {\r\n return !!pressedKeys[key];\r\n }\r\n\r\n static isMouseDown() :boolean {\r\n return mouseDown > 0;\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"file":"keyboardUtils.js","sourceRoot":"","sources":["../../../../components/keyboard/keyboardUtils.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAQ,EAAE,CAAC;AAC5B,IAAI,SAAS,GAAW,CAAC,CAAC;AAE1B,SAAS,OAAO,CAAC,CAAgB;IAC7B,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAC9B,CAAC;AAED,SAAS,KAAK,CAAC,CAAgB;IAC3B,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC/B,CAAC;AAED,SAAS,KAAK;IACV,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACrC,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC7B,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,WAAW;IAChB,SAAS,EAAE,CAAC;AAChB,CAAC;AAED,SAAS,SAAS;IACd,SAAS,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC5C,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AACxC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACvC,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAClD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAC9B,0FAA0F;IAC1F,MAAM,CAAC,YAAY,CAAC,GAAQ;QACxB,OAAO,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,iFAAiF;IACjF,MAAM,CAAC,WAAW;QACd,OAAO,SAAS,GAAG,CAAC,CAAC;IACzB,CAAC;CACJ","sourcesContent":["import {Key} from \"ts-key-enum\";\r\n\r\nconst pressedKeys: any = {};\r\nlet mouseDown: number = 0;\r\n\r\nfunction keyDown(e: KeyboardEvent) {\r\n pressedKeys[e.key] = true;\r\n}\r\n\r\nfunction keyUp(e: KeyboardEvent) {\r\n pressedKeys[e.key] = false;\r\n}\r\n\r\nfunction reset() {\r\n Object.keys(pressedKeys).forEach((key) => {\r\n pressedKeys[key] = false;\r\n });\r\n}\r\n\r\nfunction onMouseDown() {\r\n mouseDown++;\r\n}\r\n\r\nfunction onMouseUp() {\r\n mouseDown--;\r\n}\r\n\r\nwindow.addEventListener(\"keydown\", keyDown);\r\nwindow.addEventListener(\"keyup\", keyUp);\r\nwindow.addEventListener(\"blur\", reset);\r\nwindow.addEventListener(\"mousedown\", onMouseDown);\r\nwindow.addEventListener(\"mouseup\", onMouseUp);\r\n\r\n/**\r\n * Global keyboard and mouse state. Importing this module installs `keydown`/`keyup`/`mousedown`/`mouseup`\r\n * listeners on `window`; pressed keys are reset when the window loses focus.\r\n */\r\nexport default class KeyboardUtils {\r\n /** Returns whether the key (compared with `KeyboardEvent.key`) is currently held down. */\r\n static isKeyPressed(key: Key): boolean {\r\n return !!pressedKeys[key];\r\n }\r\n\r\n /** Returns whether any mouse button is currently held down within the window. */\r\n static isMouseDown() :boolean {\r\n return mouseDown > 0;\r\n }\r\n}"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Holds the position and size of all draggable dialogs (e.g. `ModalDialog` rendered as a component) and keeps them
|
|
4
|
+
* inside the window when it is resized. Render it once around the part of the app that shows such dialogs; they
|
|
5
|
+
* throw when no provider is found.
|
|
6
|
+
*/
|
|
2
7
|
export declare const DraggableModalProvider: ({ children, }: {
|
|
8
|
+
/** Content that may render draggable dialogs. */
|
|
3
9
|
children: React.ReactNode;
|
|
4
10
|
}) => React.ReactElement;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
// https://github.com/CUBETIQ/antd-modal/
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { useEffect, useReducer } from 'react';
|
|
3
4
|
import { DraggableModalContext } from 'd2coreui/components/modal/impl/draggableModalContext';
|
|
4
5
|
import { getWindowSize } from 'd2coreui/components/modal/impl/getWindowSize';
|
|
5
6
|
import { draggableModalReducer, initialModalsState } from 'd2coreui/components/modal/impl/draggableModalReducer';
|
|
7
|
+
/**
|
|
8
|
+
* Holds the position and size of all draggable dialogs (e.g. `ModalDialog` rendered as a component) and keeps them
|
|
9
|
+
* inside the window when it is resized. Render it once around the part of the app that shows such dialogs; they
|
|
10
|
+
* throw when no provider is found.
|
|
11
|
+
*/
|
|
6
12
|
export const DraggableModalProvider = ({ children, }) => {
|
|
7
13
|
const [state, dispatch] = useReducer(draggableModalReducer, initialModalsState);
|
|
8
14
|
useEffect(() => {
|
|
9
15
|
if (typeof window !== 'object') {
|
|
16
|
+
// @ts-ignore
|
|
10
17
|
return;
|
|
11
18
|
}
|
|
12
19
|
const onResize = () => dispatch({ type: 'windowResize', size: getWindowSize() });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggableModalProvider.js","sourceRoot":"","sources":["../../../../components/modal/draggableModalProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"draggableModalProvider.js","sourceRoot":"","sources":["../../../../components/modal/draggableModalProvider.tsx"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,sDAAsD,CAAA;AAC1F,OAAO,EAAC,aAAa,EAAC,MAAM,8CAA8C,CAAA;AAC1E,OAAO,EAAC,qBAAqB,EAAE,kBAAkB,EAAC,MAAM,sDAAsD,CAAA;AAE9G;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACnC,QAAQ,GAIX,EAAsB,EAAE;IACrB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,CAAA;IAE/E,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC7B,aAAa;YACb,OAAO;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,GAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC,CAAA;QACtF,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC3C,QAAQ,EAAE,CAAA;QACV,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAC/D,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEd,OAAO,CACH,oBAAC,qBAAqB,CAAC,QAAQ,IAC3B,KAAK,EAAE;YACH,KAAK;YACL,QAAQ;SACX,IAEA,QAAQ,CACoB,CACpC,CAAA;AACL,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {useEffect, useReducer} from 'react'\r\nimport {DraggableModalContext} from 'd2coreui/components/modal/impl/draggableModalContext'\r\nimport {getWindowSize} from 'd2coreui/components/modal/impl/getWindowSize'\r\nimport {draggableModalReducer, initialModalsState} from 'd2coreui/components/modal/impl/draggableModalReducer'\r\n\r\n/**\r\n * Holds the position and size of all draggable dialogs (e.g. `ModalDialog` rendered as a component) and keeps them\r\n * inside the window when it is resized. Render it once around the part of the app that shows such dialogs; they\r\n * throw when no provider is found.\r\n */\r\nexport const DraggableModalProvider = ({\r\n children,\r\n}: {\r\n /** Content that may render draggable dialogs. */\r\n children: React.ReactNode\r\n}): React.ReactElement => {\r\n const [state, dispatch] = useReducer(draggableModalReducer, initialModalsState)\r\n\r\n useEffect(() => {\r\n if (typeof window !== 'object') {\r\n // @ts-ignore\r\n return;\r\n }\r\n const onResize = (): void => dispatch({ type: 'windowResize', size: getWindowSize() })\r\n window.addEventListener('resize', onResize)\r\n onResize()\r\n return () => window.removeEventListener('resize', onResize)\r\n }, [dispatch])\r\n\r\n return (\r\n <DraggableModalContext.Provider\r\n value={{\r\n state,\r\n dispatch,\r\n }}\r\n >\r\n {children}\r\n </DraggableModalContext.Provider>\r\n )\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../../../../components/modal/impl/clamp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clamp.js","sourceRoot":"","sources":["../../../../../components/modal/impl/clamp.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,GAAW,EAAE,KAAa,EAAU,EAAE,CACrE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nexport const clamp = (min: number, max: number, value: number): number =>\r\n Math.max(min, Math.min(max, value));\r\n"]}
|
|
@@ -3,6 +3,7 @@ import { ModalProps } from 'antd/lib/modal';
|
|
|
3
3
|
export interface DraggableModalProps extends Omit<ModalProps, "width"> {
|
|
4
4
|
initialWidth?: number;
|
|
5
5
|
initialHeight?: number;
|
|
6
|
+
/** show the maximize/restore button next to the close button (default true) */
|
|
6
7
|
maximizable?: boolean;
|
|
7
8
|
onResize?(size: {
|
|
8
9
|
width: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// https://github.com/CUBETIQ/antd-modal/
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { useContext } from 'react';
|
|
3
4
|
import { useUID } from 'react-uid';
|
|
@@ -5,13 +6,18 @@ import { DraggableModalContext } from './draggableModalContext';
|
|
|
5
6
|
import { DraggableModalInner } from './draggableModalInner';
|
|
6
7
|
import { getModalState } from './draggableModalReducer';
|
|
7
8
|
export const DraggableModal = (props) => {
|
|
9
|
+
// Get the unique ID of this modal.
|
|
8
10
|
const id = useUID();
|
|
11
|
+
// Get modal provider.
|
|
9
12
|
const modalProvider = useContext(DraggableModalContext);
|
|
10
13
|
if (!modalProvider) {
|
|
11
14
|
throw new Error('No Provider');
|
|
12
15
|
}
|
|
13
16
|
const { dispatch, state } = modalProvider;
|
|
14
17
|
const modalState = getModalState({ state, id, initialWidth: props.initialWidth, initialHeight: props.initialHeight });
|
|
18
|
+
// We do this so that we don't re-render all modals for every state change.
|
|
19
|
+
// DraggableModalInner uses React.memo, so it only re-renders if
|
|
20
|
+
// if props change (e.g. modalState).
|
|
15
21
|
return React.createElement(DraggableModalInner, Object.assign({ id: id, dispatch: dispatch, modalState: modalState }, props));
|
|
16
22
|
};
|
|
17
23
|
//# sourceMappingURL=draggableModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggableModal.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"draggableModal.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModal.tsx"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAoB,UAAU,EAAC,MAAM,OAAO,CAAA;AACnD,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AAYrD,MAAM,CAAC,MAAM,cAAc,GAA2C,CAAC,KAA0B,EAAsB,EAAE;IACrH,mCAAmC;IACnC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAEpB,sBAAsB;IACtB,MAAM,aAAa,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;IACxD,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;IAClC,CAAC;IAED,MAAM,EAAC,QAAQ,EAAE,KAAK,EAAC,GAAG,aAAa,CAAC;IACxC,MAAM,UAAU,GAAG,aAAa,CAAC,EAAC,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,aAAa,EAAE,KAAK,CAAC,aAAa,EAAC,CAAC,CAAC;IAEpH,2EAA2E;IAC3E,gEAAgE;IAChE,qCAAqC;IACrC,OAAO,oBAAC,mBAAmB,kBAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,IAAM,KAAK,EAAI,CAAA;AACjG,CAAC,CAAC","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {FunctionComponent, useContext} from 'react'\r\nimport {useUID} from 'react-uid'\r\nimport {DraggableModalContext} from './draggableModalContext'\r\nimport {DraggableModalInner} from './draggableModalInner'\r\nimport {getModalState} from './draggableModalReducer'\r\nimport {ModalProps} from 'antd/lib/modal'\r\n\r\nexport interface DraggableModalProps extends Omit<ModalProps, \"width\"> {\r\n initialWidth?: number,\r\n initialHeight?: number\r\n /** show the maximize/restore button next to the close button (default true) */\r\n maximizable?: boolean\r\n // resize dialog handler\r\n onResize?(size: { width: number, height: number }): void\r\n}\r\n\r\nexport const DraggableModal: FunctionComponent<DraggableModalProps> = (props: DraggableModalProps): React.ReactElement => {\r\n // Get the unique ID of this modal.\r\n const id = useUID();\r\n\r\n // Get modal provider.\r\n const modalProvider = useContext(DraggableModalContext);\r\n if (!modalProvider) {\r\n throw new Error('No Provider')\r\n }\r\n\r\n const {dispatch, state} = modalProvider;\r\n const modalState = getModalState({state, id, initialWidth: props.initialWidth, initialHeight: props.initialHeight});\r\n\r\n // We do this so that we don't re-render all modals for every state change.\r\n // DraggableModalInner uses React.memo, so it only re-renders if\r\n // if props change (e.g. modalState).\r\n return <DraggableModalInner id={id} dispatch={dispatch} modalState={modalState} {...props} />\r\n};\r\n"]}
|