d2coreui 23.0.52 → 23.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +154 -0
- package/components/clipboard/clipboardUtils.d.ts +11 -0
- package/components/clipboard/clipboardUtils.js +16 -4
- package/components/clipboard/clipboardUtils.js.map +1 -1
- package/components/codemirror/SyntaxHighlighter.d.ts +13 -0
- package/components/codemirror/SyntaxHighlighter.js +6 -1
- package/components/codemirror/SyntaxHighlighter.js.map +1 -1
- package/components/collapse/expandable.d.ts +10 -0
- package/components/collapse/expandable.js +4 -0
- package/components/collapse/expandable.js.map +1 -1
- package/components/color/colorPicker.d.ts +16 -0
- package/components/color/colorPicker.js +4 -0
- package/components/color/colorPicker.js.map +1 -1
- package/components/color/colorSwatch.d.ts +16 -0
- package/components/color/colorSwatch.js +23 -2
- package/components/color/colorSwatch.js.map +1 -1
- package/components/color/colorUtils.d.ts +9 -0
- package/components/color/colorUtils.js +15 -0
- package/components/color/colorUtils.js.map +1 -1
- package/components/date/dateRangeInput.d.ts +76 -0
- package/components/date/dateRangeInput.js +63 -12
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -0
- package/components/date/dateRangeInputAdvancedPanel.js +7 -0
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
- package/components/date/dateRangeInputConfirm.d.ts +18 -0
- package/components/date/dateRangeInputConfirm.js +12 -0
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +99 -0
- package/components/date/dateTimeInput.js +78 -6
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/date/durationInput.d.ts +37 -0
- package/components/date/durationInput.js +26 -3
- package/components/date/durationInput.js.map +1 -1
- package/components/date/savedIntervals.d.ts +63 -0
- package/components/date/savedIntervals.js +37 -0
- package/components/date/savedIntervals.js.map +1 -1
- package/components/date/savedIntervalsDialog.d.ts +13 -0
- package/components/date/savedIntervalsDialog.js +7 -2
- package/components/date/savedIntervalsDialog.js.map +1 -1
- package/components/form/NiceFormItem.d.ts +9 -0
- package/components/form/NiceFormItem.js +4 -0
- package/components/form/NiceFormItem.js.map +1 -1
- package/components/grid/cell/beanAccessor.d.ts +12 -0
- package/components/grid/cell/beanAccessor.js +8 -0
- package/components/grid/cell/beanAccessor.js.map +1 -1
- package/components/grid/cell/bigNumberCellEditor.d.ts +9 -0
- package/components/grid/cell/bigNumberCellEditor.js +19 -0
- package/components/grid/cell/bigNumberCellEditor.js.map +1 -1
- package/components/grid/cell/cellControl.d.ts +4 -0
- package/components/grid/cell/cellControl.js +14 -0
- package/components/grid/cell/cellControl.js.map +1 -1
- package/components/grid/cell/cellEditorUtils.d.ts +6 -0
- package/components/grid/cell/cellEditorUtils.js +6 -0
- package/components/grid/cell/cellEditorUtils.js.map +1 -1
- package/components/grid/cell/customEnumCellEditor.d.ts +6 -0
- package/components/grid/cell/customEnumCellEditor.js +10 -0
- package/components/grid/cell/customEnumCellEditor.js.map +1 -1
- package/components/grid/cell/dataGridCellEditorComponent.d.ts +26 -0
- package/components/grid/cell/dataGridCellEditorComponent.js +21 -0
- package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -1
- package/components/grid/cell/dateCellEditor.d.ts +6 -0
- package/components/grid/cell/dateCellEditor.js +10 -0
- package/components/grid/cell/dateCellEditor.js.map +1 -1
- package/components/grid/cell/dragListenerFeature.d.ts +6 -0
- package/components/grid/cell/dragListenerFeature.js +6 -0
- package/components/grid/cell/dragListenerFeature.js.map +1 -1
- package/components/grid/cell/durationCellEditor.d.ts +6 -0
- package/components/grid/cell/durationCellEditor.js +14 -0
- package/components/grid/cell/durationCellEditor.js.map +1 -1
- package/components/grid/cell/hexaOctetStringCellEditor.d.ts +6 -0
- package/components/grid/cell/hexaOctetStringCellEditor.js +14 -0
- package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
- package/components/grid/cell/hexaValueCellEditor.d.ts +6 -0
- package/components/grid/cell/hexaValueCellEditor.js +14 -0
- package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
- package/components/grid/cell/numberCellEditor.d.ts +6 -0
- package/components/grid/cell/numberCellEditor.js +15 -0
- package/components/grid/cell/numberCellEditor.js.map +1 -1
- package/components/grid/cell/rangeSelector.d.ts +7 -0
- package/components/grid/cell/rangeSelector.js +59 -5
- package/components/grid/cell/rangeSelector.js.map +1 -1
- package/components/grid/cell/simpleStatusTextCellEditor.d.ts +7 -0
- package/components/grid/cell/simpleStatusTextCellEditor.js +11 -0
- package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
- package/components/grid/cell/statusTextCellEditor.d.ts +7 -0
- package/components/grid/cell/statusTextCellEditor.js +17 -0
- package/components/grid/cell/statusTextCellEditor.js.map +1 -1
- package/components/grid/cell/tableDefaultRowStyleRules.d.ts +31 -0
- package/components/grid/cell/tableDefaultRowStyleRules.js +5 -0
- package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
- package/components/grid/cell/textCellEditor.d.ts +6 -0
- package/components/grid/cell/textCellEditor.js +15 -0
- package/components/grid/cell/textCellEditor.js.map +1 -1
- package/components/grid/cell/withAgGridHooks.d.ts +8 -0
- package/components/grid/cell/withAgGridHooks.js +8 -0
- package/components/grid/cell/withAgGridHooks.js.map +1 -1
- package/components/grid/columnUtils.d.ts +10 -1
- package/components/grid/columnUtils.js +11 -0
- package/components/grid/columnUtils.js.map +1 -1
- package/components/grid/config/columnTransfer.d.ts +18 -0
- package/components/grid/config/columnTransfer.js +45 -29
- package/components/grid/config/columnTransfer.js.map +1 -1
- package/components/grid/config/dataGridEditor.d.ts +31 -0
- package/components/grid/config/dataGridEditor.js +14 -2
- package/components/grid/config/dataGridEditor.js.map +1 -1
- package/components/grid/config/rowHeightCalculator.d.ts +11 -0
- package/components/grid/config/rowHeightCalculator.js +11 -0
- package/components/grid/config/rowHeightCalculator.js.map +1 -1
- package/components/grid/config/rowStylePicker.d.ts +19 -0
- package/components/grid/config/rowStylePicker.js +12 -0
- package/components/grid/config/rowStylePicker.js.map +1 -1
- package/components/grid/dataGrid.d.ts +361 -12
- package/components/grid/dataGrid.js +201 -28
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/detail/detailHeaderPanel.d.ts +11 -0
- package/components/grid/detail/detailHeaderPanel.js +5 -0
- package/components/grid/detail/detailHeaderPanel.js.map +1 -1
- package/components/grid/export/contextMenu.d.ts +31 -0
- package/components/grid/export/contextMenu.js +8 -0
- package/components/grid/export/contextMenu.js.map +1 -1
- package/components/grid/export/progressPopup.d.ts +21 -0
- package/components/grid/export/progressPopup.js +17 -0
- package/components/grid/export/progressPopup.js.map +1 -1
- package/components/grid/export/worker/pdfExport.js +5 -0
- package/components/grid/export/worker/pdfExport.js.map +1 -1
- package/components/grid/extendedDataGrid.d.ts +249 -4
- package/components/grid/extendedDataGrid.js +160 -19
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/grid/filter/customColumnFilter.d.ts +5 -0
- package/components/grid/filter/customColumnFilter.js +5 -0
- package/components/grid/filter/customColumnFilter.js.map +1 -1
- package/components/grid/filter/dataGridColumnFilter.d.ts +19 -0
- package/components/grid/filter/dataGridColumnFilter.js +19 -0
- package/components/grid/filter/dataGridColumnFilter.js.map +1 -1
- package/components/grid/filter/dateColumnFilter.d.ts +6 -0
- package/components/grid/filter/dateColumnFilter.js +6 -0
- package/components/grid/filter/dateColumnFilter.js.map +1 -1
- package/components/grid/filter/textColumnFilter.d.ts +6 -0
- package/components/grid/filter/textColumnFilter.js +6 -0
- package/components/grid/filter/textColumnFilter.js.map +1 -1
- package/components/grid/filter/wildcardQuickFilterEngine.d.ts +21 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js +21 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -1
- package/components/grid/header/simpleHeader.d.ts +17 -0
- package/components/grid/header/simpleHeader.js +20 -0
- package/components/grid/header/simpleHeader.js.map +1 -1
- package/components/grid/panel/dataGridPagination.d.ts +10 -0
- package/components/grid/panel/dataGridPagination.js +5 -0
- package/components/grid/panel/dataGridPagination.js.map +1 -1
- package/components/grid/panel/loadingOverlay.d.ts +5 -0
- package/components/grid/panel/loadingOverlay.js +4 -0
- package/components/grid/panel/loadingOverlay.js.map +1 -1
- package/components/grid/panel/noRecordsOverlay.d.ts +6 -0
- package/components/grid/panel/noRecordsOverlay.js +5 -0
- package/components/grid/panel/noRecordsOverlay.js.map +1 -1
- package/components/grid/panel/tablePagination.d.ts +4 -0
- package/components/grid/panel/tablePagination.js +4 -0
- package/components/grid/panel/tablePagination.js.map +1 -1
- package/components/icons/dropdownArrow.d.ts +3 -0
- package/components/icons/dropdownArrow.js +2 -0
- package/components/icons/dropdownArrow.js.map +1 -1
- package/components/icons/undoIcon.d.ts +2 -0
- package/components/icons/undoIcon.js +2 -0
- package/components/icons/undoIcon.js.map +1 -1
- package/components/input/autoCompleteInput.d.ts +29 -0
- package/components/input/autoCompleteInput.js +7 -0
- package/components/input/autoCompleteInput.js.map +1 -1
- package/components/input/draftUtils.d.ts +7 -0
- package/components/input/draftUtils.js +9 -0
- package/components/input/draftUtils.js.map +1 -1
- package/components/input/hexaFormattedInput.d.ts +9 -0
- package/components/input/hexaFormattedInput.js +3 -0
- package/components/input/hexaFormattedInput.js.map +1 -1
- package/components/input/mask/helpers.d.ts +27 -0
- package/components/input/mask/helpers.js +27 -0
- package/components/input/mask/helpers.js.map +1 -1
- package/components/input/mask/inputMaskCore.d.ts +80 -0
- package/components/input/mask/inputMaskCore.js +90 -0
- package/components/input/mask/inputMaskCore.js.map +1 -1
- package/components/input/mask/pattern.d.ts +24 -0
- package/components/input/mask/pattern.js +26 -0
- package/components/input/mask/pattern.js.map +1 -1
- package/components/input/maskedInput.d.ts +53 -0
- package/components/input/maskedInput.js +44 -4
- package/components/input/maskedInput.js.map +1 -1
- package/components/input/passwordInput.d.ts +7 -0
- package/components/input/passwordInput.js +8 -0
- package/components/input/passwordInput.js.map +1 -1
- package/components/input/simpleAutoComplete.d.ts +6 -0
- package/components/input/simpleAutoComplete.js +6 -0
- package/components/input/simpleAutoComplete.js.map +1 -1
- package/components/input/textarea/extractSpansOfClasses.d.ts +17 -0
- package/components/input/textarea/extractSpansOfClasses.js +26 -1
- package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
- package/components/input/textarea/getRanges.d.ts +7 -0
- package/components/input/textarea/getRanges.js +11 -0
- package/components/input/textarea/getRanges.js.map +1 -1
- package/components/input/textarea/getType.d.ts +5 -0
- package/components/input/textarea/getType.js +5 -0
- package/components/input/textarea/getType.js.map +1 -1
- package/components/input/textarea/highlighedContents.d.ts +4 -0
- package/components/input/textarea/highlighedContents.js +5 -0
- package/components/input/textarea/highlighedContents.js.map +1 -1
- package/components/input/textarea/mentionsWithHighlighting.d.ts +25 -0
- package/components/input/textarea/mentionsWithHighlighting.js +14 -0
- package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
- package/components/keyboard/keyboardUtils.d.ts +6 -0
- package/components/keyboard/keyboardUtils.js +6 -0
- package/components/keyboard/keyboardUtils.js.map +1 -1
- package/components/modal/draggableModalProvider.d.ts +6 -0
- package/components/modal/draggableModalProvider.js +7 -0
- package/components/modal/draggableModalProvider.js.map +1 -1
- package/components/modal/impl/clamp.js +1 -0
- package/components/modal/impl/clamp.js.map +1 -1
- package/components/modal/impl/draggableModal.d.ts +1 -0
- package/components/modal/impl/draggableModal.js +6 -0
- package/components/modal/impl/draggableModal.js.map +1 -1
- package/components/modal/impl/draggableModalContext.js +1 -0
- package/components/modal/impl/draggableModalContext.js.map +1 -1
- package/components/modal/impl/draggableModalInner.js +12 -1
- package/components/modal/impl/draggableModalInner.js.map +1 -1
- package/components/modal/impl/draggableModalReducer.d.ts +7 -1
- package/components/modal/impl/draggableModalReducer.js +6 -1
- package/components/modal/impl/draggableModalReducer.js.map +1 -1
- package/components/modal/impl/draggableModalStyles.d.ts +17 -0
- package/components/modal/impl/draggableModalStyles.js +31 -0
- package/components/modal/impl/draggableModalStyles.js.map +1 -1
- package/components/modal/impl/getWindowSize.js +1 -0
- package/components/modal/impl/getWindowSize.js.map +1 -1
- package/components/modal/impl/index.js +1 -0
- package/components/modal/impl/index.js.map +1 -1
- package/components/modal/impl/resizeHandle.d.ts +1 -0
- package/components/modal/impl/resizeHandle.js +4 -1
- package/components/modal/impl/resizeHandle.js.map +1 -1
- package/components/modal/impl/useDrag.js +1 -0
- package/components/modal/impl/useDrag.js.map +1 -1
- package/components/modal/impl/usePrevious.js +1 -0
- package/components/modal/impl/usePrevious.js.map +1 -1
- package/components/modal/impl/useResize.js +1 -0
- package/components/modal/impl/useResize.js.map +1 -1
- package/components/modal/modalDialog.d.ts +85 -0
- package/components/modal/modalDialog.js +80 -10
- package/components/modal/modalDialog.js.map +1 -1
- package/components/picker/enumValuePicker.d.ts +17 -0
- package/components/picker/enumValuePicker.js +4 -0
- package/components/picker/enumValuePicker.js.map +1 -1
- package/components/platformSpecific.d.ts +17 -0
- package/components/platformSpecific.js +16 -0
- package/components/platformSpecific.js.map +1 -1
- package/components/scrollTo/onlyText.d.ts +5 -0
- package/components/scrollTo/onlyText.js +5 -0
- package/components/scrollTo/onlyText.js.map +1 -1
- package/components/scrollTo/scrollTo.d.ts +56 -0
- package/components/scrollTo/scrollTo.js +40 -3
- package/components/scrollTo/scrollTo.js.map +1 -1
- package/components/style/withCss.d.ts +15 -0
- package/components/style/withCss.js +6 -0
- package/components/style/withCss.js.map +1 -1
- package/components/table/dragSortingTable.d.ts +15 -0
- package/components/table/dragSortingTable.js +12 -0
- package/components/table/dragSortingTable.js.map +1 -1
- package/components/text/impl/innerSize.js +2 -0
- package/components/text/impl/innerSize.js.map +1 -1
- package/components/text/impl/series.d.ts +10 -0
- package/components/text/impl/series.js +10 -0
- package/components/text/impl/series.js.map +1 -1
- package/components/text/impl/shallowEqual.js +1 -0
- package/components/text/impl/shallowEqual.js.map +1 -1
- package/components/text/impl/whilst.d.ts +7 -0
- package/components/text/impl/whilst.js +7 -0
- package/components/text/impl/whilst.js.map +1 -1
- package/components/text/textFit.d.ts +24 -0
- package/components/text/textFit.js +29 -1
- package/components/text/textFit.js.map +1 -1
- package/i18n/componentsLocaleHolder.d.ts +9 -0
- package/i18n/componentsLocaleHolder.js +9 -0
- package/i18n/componentsLocaleHolder.js.map +1 -1
- package/package.json +66 -65
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggableModalContext.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"draggableModalContext.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalContext.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAW9B,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC,aAAa,CAAoC,IAAI,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {Action, ModalsState} from './draggableModalReducer'\r\n\r\nexport interface DraggableModalContextMethods {\r\n dispatch: (action: Action) => void\r\n}\r\n\r\nexport interface DraggableModalContextValue extends DraggableModalContextMethods {\r\n state: ModalsState\r\n}\r\n\r\nexport const DraggableModalContext = React.createContext<DraggableModalContextValue | null>(null)\r\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// https://github.com/CUBETIQ/antd-modal/
|
|
1
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
3
|
var t = {};
|
|
3
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -22,19 +23,25 @@ import { useResize } from './useResize';
|
|
|
22
23
|
import { getWindowSize } from './getWindowSize';
|
|
23
24
|
import { headerButtonGeometry, useDraggableModalStyles } from "./draggableModalStyles";
|
|
24
25
|
const modalStyle = { margin: 0, paddingBottom: 0, pointerEvents: 'auto' };
|
|
26
|
+
/** free space left around a maximized dialog, in total (half on each side) */
|
|
25
27
|
const MAXIMIZE_MARGIN = 32;
|
|
26
28
|
export const DraggableModalInner = memo((_a) => {
|
|
27
29
|
var { id, modalState, dispatch, open, children, title, initialWidth, initialHeight, onResize, maximizable = true } = _a, otherProps = __rest(_a, ["id", "modalState", "dispatch", "open", "children", "title", "initialWidth", "initialHeight", "onResize", "maximizable"]);
|
|
28
30
|
const { styles, cx, theme } = useDraggableModalStyles();
|
|
29
31
|
const { getPrefixCls } = useContext(ConfigContext);
|
|
30
32
|
const modalPrefixCls = getPrefixCls('modal');
|
|
33
|
+
// NO_BUTTONS dialogs (and anyone passing footer={null}) render no footer, which is where the
|
|
34
|
+
// bottom inset normally lives - the content has to take it back
|
|
31
35
|
const hasFooter = otherProps.footer !== null;
|
|
36
|
+
// room the title has to leave in the top-right corner so the buttons do not cover it
|
|
32
37
|
const titleReserve = headerButtonGeometry(theme)
|
|
33
38
|
.reserve((otherProps.closable === false ? 0 : 1) + (maximizable ? 1 : 0));
|
|
39
|
+
// Call on mount and unmount.
|
|
34
40
|
useEffect(() => {
|
|
35
41
|
dispatch({ type: 'mount', id, intialState: { initialWidth, initialHeight } });
|
|
36
42
|
return () => dispatch({ type: 'unmount', id });
|
|
37
43
|
}, [dispatch, id, initialWidth, initialHeight]);
|
|
44
|
+
// Bring this to the front if it's been opened with props.
|
|
38
45
|
const visiblePrevious = usePrevious(open);
|
|
39
46
|
useEffect(() => {
|
|
40
47
|
if (open !== visiblePrevious) {
|
|
@@ -68,7 +75,11 @@ export const DraggableModalInner = memo((_a) => {
|
|
|
68
75
|
}, [dispatch, id, onResize, restore]);
|
|
69
76
|
const onMouseDrag = useDrag(x, y, onDragWithID);
|
|
70
77
|
const onMouseResize = useResize(x, y, width, height, onResizeWithID);
|
|
71
|
-
const titleElement = useMemo(() => (React.createElement("div", {
|
|
78
|
+
const titleElement = useMemo(() => (React.createElement("div", {
|
|
79
|
+
// the legacy class name is kept as a styling hook for the app (e.g. .compact-modal)
|
|
80
|
+
className: cx("ant-design-draggable-modal-title", styles.title),
|
|
81
|
+
// inline so it wins over the class padding without a specificity contest
|
|
82
|
+
style: titleReserve > 0 ? { paddingInlineEnd: titleReserve } : undefined, onMouseDown: onMouseDrag, onClick: onFocus }, title)), [onMouseDrag, onFocus, title, cx, styles.title, titleReserve]);
|
|
72
83
|
return (React.createElement(Modal, Object.assign({ wrapClassName: cx("ant-design-draggable-modal", styles.wrap, !hasFooter && styles.wrapWithoutFooter), style: style, destroyOnHidden: true, width: width, title: titleElement, open: open }, otherProps),
|
|
73
84
|
children,
|
|
74
85
|
maximizable && React.createElement("button", { type: "button", "aria-label": maximized ? i18n("Restore") : i18n("Maximize"), title: maximized ? i18n("Restore") : i18n("Maximize"), className: `${modalPrefixCls}-close ant-design-draggable-modal-maximize`, onClick: onToggleMaximize },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggableModalInner.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalInner.tsx"],"names":[],"mappings":";;;;;;;;;;;AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AACvE,OAAO,EAAC,KAAK,EAAC,MAAM,MAAM,CAAA;AAC1B,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AAC5E,OAAO,IAAI,MAAM,kBAAkB,CAAA;AACnC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,iB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KAAK,YAAY,EAAE,CAAC;IACxC,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAC3D,CAAC","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {memo, useCallback, useContext, useEffect, useMemo} from 'react'\r\nimport {Modal} from 'antd'\r\nimport {ConfigContext} from 'antd/es/config-provider'\r\nimport {FullscreenExitOutlined, FullscreenOutlined} from '@ant-design/icons'\r\nimport i18n from 'd2core/i18n/i18n'\r\nimport {ResizeHandle} from './resizeHandle'\r\nimport {useDrag} from './useDrag'\r\nimport {DraggableModalContextMethods} from './draggableModalContext'\r\nimport {usePrevious} from './usePrevious'\r\nimport {ModalID, ModalState} from './draggableModalReducer'\r\nimport {useResize} from './useResize'\r\nimport {getWindowSize} from './getWindowSize'\r\nimport {DraggableModalProps} from \"./draggableModal\";\r\nimport {headerButtonGeometry, useDraggableModalStyles} from \"./draggableModalStyles\";\r\n\r\nconst modalStyle: React.CSSProperties = {margin: 0, paddingBottom: 0, pointerEvents: 'auto'}\r\n\r\n/** free space left around a maximized dialog, in total (half on each side) */\r\nconst MAXIMIZE_MARGIN = 32\r\n\r\ninterface ContextProps extends DraggableModalContextMethods {\r\n id: ModalID\r\n modalState: ModalState\r\n initialWidth?: number\r\n initialHeight?: number\r\n}\r\n\r\n//export type DraggableModalInnerProps = ModalProps & { children?: React.ReactNode } & ContextProps\r\nexport interface DraggableModalInnerProps extends DraggableModalProps, ContextProps {\r\n children?: React.ReactNode\r\n}\r\n\r\nexport const DraggableModalInner = memo(\r\n ({\r\n id,\r\n modalState,\r\n dispatch,\r\n open,\r\n children,\r\n title,\r\n initialWidth,\r\n initialHeight,\r\n onResize,\r\n maximizable = true,\r\n ...otherProps\r\n }: DraggableModalInnerProps) => {\r\n const {styles, cx, theme} = useDraggableModalStyles();\r\n const {getPrefixCls} = useContext(ConfigContext);\r\n const modalPrefixCls = getPrefixCls('modal');\r\n\r\n // NO_BUTTONS dialogs (and anyone passing footer={null}) render no footer, which is where the\r\n // bottom inset normally lives - the content has to take it back\r\n const hasFooter = otherProps.footer !== null;\r\n // room the title has to leave in the top-right corner so the buttons do not cover it\r\n const titleReserve = headerButtonGeometry(theme)\r\n .reserve((otherProps.closable === false ? 0 : 1) + (maximizable ? 1 : 0));\r\n\r\n // Call on mount and unmount.\r\n useEffect(() => {\r\n dispatch({type: 'mount', id, intialState: {initialWidth, initialHeight}});\r\n return () => dispatch({type: 'unmount', id})\r\n }, [dispatch, id, initialWidth, initialHeight]);\r\n\r\n // Bring this to the front if it's been opened with props.\r\n const visiblePrevious = usePrevious(open);\r\n useEffect(() => {\r\n if (open !== visiblePrevious) {\r\n if (open) {\r\n dispatch({type: 'show', id})\r\n } else {\r\n dispatch({type: 'hide', id})\r\n }\r\n }\r\n }, [open, visiblePrevious, id, dispatch]);\r\n\r\n const {x, y, width, height} = modalState;\r\n\r\n const style: React.CSSProperties = useMemo(\r\n () => ({...modalStyle, top: y, left: x, height}),\r\n [y, x, height],\r\n );\r\n\r\n const onFocus = useCallback(() => dispatch({type: 'focus', id}), [id, dispatch])\r\n\r\n const onDragWithID = useCallback((args: any) => dispatch({type: 'drag', id, ...args}), [\r\n dispatch,\r\n id,\r\n ]);\r\n\r\n const onResizeWithID = useCallback((args: any) => {\r\n onResize?.({width: args.width, height: args.height});\r\n return dispatch({type: 'resize', id, ...args})\r\n }, [dispatch, id,]);\r\n\r\n const {restore} = modalState;\r\n const maximized = restore !== undefined;\r\n\r\n const onToggleMaximize = useCallback(() => {\r\n const windowSize = getWindowSize();\r\n onResize?.(restore\r\n ? {width: restore.width, height: restore.height}\r\n : {width: windowSize.width - MAXIMIZE_MARGIN, height: windowSize.height - MAXIMIZE_MARGIN});\r\n dispatch({type: 'maximize', id, margin: MAXIMIZE_MARGIN})\r\n }, [dispatch, id, onResize, restore]);\r\n\r\n const onMouseDrag = useDrag(x, y, onDragWithID);\r\n const onMouseResize = useResize(x, y, width, height, onResizeWithID);\r\n\r\n const titleElement = useMemo(\r\n () => (\r\n <div\r\n // the legacy class name is kept as a styling hook for the app (e.g. .compact-modal)\r\n className={cx(\"ant-design-draggable-modal-title\", styles.title)}\r\n // inline so it wins over the class padding without a specificity contest\r\n style={titleReserve > 0 ? {paddingInlineEnd: titleReserve} : undefined}\r\n onMouseDown={onMouseDrag}\r\n onClick={onFocus}\r\n >\r\n {title}\r\n </div>\r\n ),\r\n [onMouseDrag, onFocus, title, cx, styles.title, titleReserve],\r\n );\r\n\r\n return (\r\n <Modal\r\n wrapClassName={cx(\"ant-design-draggable-modal\", styles.wrap, !hasFooter && styles.wrapWithoutFooter)}\r\n style={style}\r\n destroyOnHidden\r\n width={width}\r\n title={titleElement}\r\n open={open}\r\n {...otherProps}\r\n >\r\n {children}\r\n {/* reuses antd's close-button markup so it matches the button it sits next to */}\r\n {maximizable && <button type=\"button\"\r\n aria-label={maximized ? i18n(\"Restore\") : i18n(\"Maximize\")}\r\n title={maximized ? i18n(\"Restore\") : i18n(\"Maximize\")}\r\n className={`${modalPrefixCls}-close ant-design-draggable-modal-maximize`}\r\n onClick={onToggleMaximize}>\r\n <span className={`${modalPrefixCls}-close-x`}>\r\n {maximized ? <FullscreenExitOutlined/> : <FullscreenOutlined/>}\r\n </span>\r\n </button>}\r\n <ResizeHandle className={styles.resizeHandle} innerClassName={styles.resizeHandleInner}\r\n onMouseDown={onMouseResize}/>\r\n </Modal>\r\n )\r\n }\r\n);\r\n\r\nif (process.env.NODE_ENV !== 'production') {\r\n DraggableModalInner.displayName = 'DraggableModalInner'\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"draggableModalInner.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalInner.tsx"],"names":[],"mappings":"AAAA,yCAAyC;;;;;;;;;;;;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CA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,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAC1D,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EACrD,SAAS,EAAE,GAAG,cAAc,4CAA4C,EACxE,OAAO,EAAE,gBAAgB;YAC7B,8BAAM,SAAS,EAAE,GAAG,cAAc,UAAU,IACvC,SAAS,CAAC,CAAC,CAAC,oBAAC,sBAAsB,OAAE,CAAC,CAAC,CAAC,oBAAC,kBAAkB,OAAE,CAC3D,CACF;QACT,oBAAC,YAAY,IAAC,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,cAAc,EAAE,MAAM,CAAC,iBAAiB,EACxE,WAAW,EAAE,aAAa,GAAG,CACvC,CACX,CAAA;AACL,CAAC,CACJ,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;IACxC,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAA;AAC3D,CAAC","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {memo, useCallback, useContext, useEffect, useMemo} from 'react'\r\nimport {Modal} from 'antd'\r\nimport {ConfigContext} from 'antd/es/config-provider'\r\nimport {FullscreenExitOutlined, FullscreenOutlined} from '@ant-design/icons'\r\nimport i18n from 'd2core/i18n/i18n'\r\nimport {ResizeHandle} from './resizeHandle'\r\nimport {useDrag} from './useDrag'\r\nimport {DraggableModalContextMethods} from './draggableModalContext'\r\nimport {usePrevious} from './usePrevious'\r\nimport {ModalID, ModalState} from './draggableModalReducer'\r\nimport {useResize} from './useResize'\r\nimport {getWindowSize} from './getWindowSize'\r\nimport {DraggableModalProps} from \"./draggableModal\";\r\nimport {headerButtonGeometry, useDraggableModalStyles} from \"./draggableModalStyles\";\r\n\r\nconst modalStyle: React.CSSProperties = {margin: 0, paddingBottom: 0, pointerEvents: 'auto'}\r\n\r\n/** free space left around a maximized dialog, in total (half on each side) */\r\nconst MAXIMIZE_MARGIN = 32\r\n\r\ninterface ContextProps extends DraggableModalContextMethods {\r\n id: ModalID\r\n modalState: ModalState\r\n initialWidth?: number\r\n initialHeight?: number\r\n}\r\n\r\n//export type DraggableModalInnerProps = ModalProps & { children?: React.ReactNode } & ContextProps\r\nexport interface DraggableModalInnerProps extends DraggableModalProps, ContextProps {\r\n children?: React.ReactNode\r\n}\r\n\r\nexport const DraggableModalInner = memo(\r\n ({\r\n id,\r\n modalState,\r\n dispatch,\r\n open,\r\n children,\r\n title,\r\n initialWidth,\r\n initialHeight,\r\n onResize,\r\n maximizable = true,\r\n ...otherProps\r\n }: DraggableModalInnerProps) => {\r\n const {styles, cx, theme} = useDraggableModalStyles();\r\n const {getPrefixCls} = useContext(ConfigContext);\r\n const modalPrefixCls = getPrefixCls('modal');\r\n\r\n // NO_BUTTONS dialogs (and anyone passing footer={null}) render no footer, which is where the\r\n // bottom inset normally lives - the content has to take it back\r\n const hasFooter = otherProps.footer !== null;\r\n // room the title has to leave in the top-right corner so the buttons do not cover it\r\n const titleReserve = headerButtonGeometry(theme)\r\n .reserve((otherProps.closable === false ? 0 : 1) + (maximizable ? 1 : 0));\r\n\r\n // Call on mount and unmount.\r\n useEffect(() => {\r\n dispatch({type: 'mount', id, intialState: {initialWidth, initialHeight}});\r\n return () => dispatch({type: 'unmount', id})\r\n }, [dispatch, id, initialWidth, initialHeight]);\r\n\r\n // Bring this to the front if it's been opened with props.\r\n const visiblePrevious = usePrevious(open);\r\n useEffect(() => {\r\n if (open !== visiblePrevious) {\r\n if (open) {\r\n dispatch({type: 'show', id})\r\n } else {\r\n dispatch({type: 'hide', id})\r\n }\r\n }\r\n }, [open, visiblePrevious, id, dispatch]);\r\n\r\n const {x, y, width, height} = modalState;\r\n\r\n const style: React.CSSProperties = useMemo(\r\n () => ({...modalStyle, top: y, left: x, height}),\r\n [y, x, height],\r\n );\r\n\r\n const onFocus = useCallback(() => dispatch({type: 'focus', id}), [id, dispatch])\r\n\r\n const onDragWithID = useCallback((args: any) => dispatch({type: 'drag', id, ...args}), [\r\n dispatch,\r\n id,\r\n ]);\r\n\r\n const onResizeWithID = useCallback((args: any) => {\r\n onResize?.({width: args.width, height: args.height});\r\n return dispatch({type: 'resize', id, ...args})\r\n }, [dispatch, id,]);\r\n\r\n const {restore} = modalState;\r\n const maximized = restore !== undefined;\r\n\r\n const onToggleMaximize = useCallback(() => {\r\n const windowSize = getWindowSize();\r\n onResize?.(restore\r\n ? {width: restore.width, height: restore.height}\r\n : {width: windowSize.width - MAXIMIZE_MARGIN, height: windowSize.height - MAXIMIZE_MARGIN});\r\n dispatch({type: 'maximize', id, margin: MAXIMIZE_MARGIN})\r\n }, [dispatch, id, onResize, restore]);\r\n\r\n const onMouseDrag = useDrag(x, y, onDragWithID);\r\n const onMouseResize = useResize(x, y, width, height, onResizeWithID);\r\n\r\n const titleElement = useMemo(\r\n () => (\r\n <div\r\n // the legacy class name is kept as a styling hook for the app (e.g. .compact-modal)\r\n className={cx(\"ant-design-draggable-modal-title\", styles.title)}\r\n // inline so it wins over the class padding without a specificity contest\r\n style={titleReserve > 0 ? {paddingInlineEnd: titleReserve} : undefined}\r\n onMouseDown={onMouseDrag}\r\n onClick={onFocus}\r\n >\r\n {title}\r\n </div>\r\n ),\r\n [onMouseDrag, onFocus, title, cx, styles.title, titleReserve],\r\n );\r\n\r\n return (\r\n <Modal\r\n wrapClassName={cx(\"ant-design-draggable-modal\", styles.wrap, !hasFooter && styles.wrapWithoutFooter)}\r\n style={style}\r\n destroyOnHidden\r\n width={width}\r\n title={titleElement}\r\n open={open}\r\n {...otherProps}\r\n >\r\n {children}\r\n {/* reuses antd's close-button markup so it matches the button it sits next to */}\r\n {maximizable && <button type=\"button\"\r\n aria-label={maximized ? i18n(\"Restore\") : i18n(\"Maximize\")}\r\n title={maximized ? i18n(\"Restore\") : i18n(\"Maximize\")}\r\n className={`${modalPrefixCls}-close ant-design-draggable-modal-maximize`}\r\n onClick={onToggleMaximize}>\r\n <span className={`${modalPrefixCls}-close-x`}>\r\n {maximized ? <FullscreenExitOutlined/> : <FullscreenOutlined/>}\r\n </span>\r\n </button>}\r\n <ResizeHandle className={styles.resizeHandle} innerClassName={styles.resizeHandleInner}\r\n onMouseDown={onMouseResize}/>\r\n </Modal>\r\n )\r\n }\r\n);\r\n\r\nif (process.env.NODE_ENV !== 'production') {\r\n DraggableModalInner.displayName = 'DraggableModalInner'\r\n}\r\n"]}
|
|
@@ -5,6 +5,7 @@ export interface ModalState {
|
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
7
7
|
visible: boolean;
|
|
8
|
+
/** rectangle to return to when un-maximizing; set only while the dialog is maximized */
|
|
8
9
|
restore?: {
|
|
9
10
|
x: number;
|
|
10
11
|
y: number;
|
|
@@ -53,7 +54,12 @@ export type Action = {
|
|
|
53
54
|
id: ModalID;
|
|
54
55
|
x: number;
|
|
55
56
|
y: number;
|
|
56
|
-
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Toggle: fills the window leaving `margin` px of free space in total (half of it on each side),
|
|
60
|
+
* or returns to the rectangle from before maximizing.
|
|
61
|
+
*/
|
|
62
|
+
| {
|
|
57
63
|
type: 'maximize';
|
|
58
64
|
id: ModalID;
|
|
59
65
|
margin: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// https://github.com/CUBETIQ/antd-modal/
|
|
1
2
|
import { getWindowSize } from './getWindowSize';
|
|
2
3
|
import { clamp } from './clamp';
|
|
3
4
|
const mapObject = (o, f) => Object.assign({}, ...Object.keys(o).map(k => ({ [k]: f(o[k]) })));
|
|
@@ -34,11 +35,15 @@ export const draggableModalReducer = (state, action) => {
|
|
|
34
35
|
switch (action.type) {
|
|
35
36
|
case 'resize':
|
|
36
37
|
const size = clampResize(state.windowSize.width, state.windowSize.height, action.x, action.y, action.width, action.height);
|
|
37
|
-
return Object.assign(Object.assign({}, state), { modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign(Object.assign({}, state.modals[action.id]), size), {
|
|
38
|
+
return Object.assign(Object.assign({}, state), { modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign(Object.assign({}, state.modals[action.id]), size), {
|
|
39
|
+
// resizing by hand takes the dialog out of the maximized state
|
|
40
|
+
restore: undefined }) }) });
|
|
38
41
|
case 'maximize': {
|
|
39
42
|
const modalState = state.modals[action.id];
|
|
40
43
|
const { restore } = modalState;
|
|
41
44
|
if (restore) {
|
|
45
|
+
// the window may have shrunk in the meantime, so the old rectangle goes through the
|
|
46
|
+
// same clamping as a manual drag/resize
|
|
42
47
|
const position = clampDrag(state.windowSize.width, state.windowSize.height, restore.x, restore.y, restore.width, restore.height);
|
|
43
48
|
const size = clampResize(state.windowSize.width, state.windowSize.height, position.x, position.y, restore.width, restore.height);
|
|
44
49
|
return Object.assign(Object.assign({}, state), { modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign(Object.assign(Object.assign({}, modalState), position), size), { restore: undefined }) }) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggableModalReducer.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalReducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAE7B,MAAM,SAAS,GAAG,CAAI,CAAuB,EAAE,CAAkB,EAAwB,EAAE,CACvF,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAA;AA2BnE,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC3C,UA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CAAC,KAAK,EACtB,KAAK,CAAC,UAAU,CAAC,MAAM,EACvB,UAAU,CAAC,CAAC,EACZ,UAAU,CAAC,CAAC,EACZ,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CACpB,CAAA;oBACD,MAAM,IAAI,GAAG,WAAW,CACpB,KAAK,CAAC,UAAU,CAAC,KAAK,EACtB,KAAK,CAAC,UAAU,CAAC,MAAM,EACvB,QAAQ,CAAC,CAAC,EACV,QAAQ,CAAC,CAAC,EACV,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CACpB,CAAA;oBACD,qDACO,UAAU,GACV,QAAQ,GACR,IAAI,EACV;gBACL,CAAC,CAAC,IACL;QACL;YACI,MAAM,IAAI,KAAK,EAAE,CAAA;IACzB,CAAC;AACL,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport {getWindowSize} from './getWindowSize'\r\nimport {clamp} from './clamp'\r\n\r\nconst mapObject = <T>(o: { [key: string]: T }, f: (value: T) => T): { [key: string]: T } =>\r\n Object.assign({}, ...Object.keys(o).map(k => ({[k]: f(o[k])})))\r\n\r\n// ID for a specific modal.\r\nexport type ModalID = string\r\n\r\n// State for a specific modal.\r\nexport interface ModalState {\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n visible: boolean\r\n /** rectangle to return to when un-maximizing; set only while the dialog is maximized */\r\n restore?: { x: number; y: number; width: number; height: number }\r\n}\r\n\r\n// State of all modals.\r\nexport interface ModalsState {\r\n windowSize: {\r\n width: number\r\n height: number\r\n }\r\n modals: {\r\n [key: string]: ModalState\r\n }\r\n}\r\n\r\nexport const initialModalsState: ModalsState = {\r\n windowSize: getWindowSize(),\r\n modals: {},\r\n};\r\n\r\nexport const initialModalState: ModalState = {\r\n x: 0,\r\n y: 0,\r\n width: 400,\r\n height: 400,\r\n visible: false,\r\n};\r\n\r\nconst getInitialModalState = ({\r\n initialWidth = initialModalState.width,\r\n initialHeight = initialModalState.height,\r\n }: {\r\n initialWidth?: number\r\n initialHeight?: number\r\n}) => {\r\n return {\r\n ...initialModalState,\r\n width: initialWidth,\r\n height: initialHeight,\r\n }\r\n}\r\n\r\nexport type Action =\r\n | { type: 'show'; id: ModalID }\r\n | { type: 'hide'; id: ModalID }\r\n | { type: 'focus'; id: ModalID }\r\n | { type: 'unmount'; id: ModalID }\r\n | { type: 'mount'; id: ModalID, intialState: { initialWidth?: number; initialHeight?: number } }\r\n | { type: 'windowResize'; size: { width: number; height: number } }\r\n | { type: 'drag'; id: ModalID; x: number; y: number }\r\n /**\r\n * Toggle: fills the window leaving `margin` px of free space in total (half of it on each side),\r\n * or returns to the rectangle from before maximizing.\r\n */\r\n | { type: 'maximize'; id: ModalID; margin: number }\r\n | {\r\n type: 'resize'\r\n id: ModalID\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n}\r\n\r\nexport const getModalState = ({\r\n state,\r\n id,\r\n initialWidth,\r\n initialHeight,\r\n }: {\r\n state: ModalsState\r\n id: ModalID\r\n initialWidth?: number\r\n initialHeight?: number\r\n}): ModalState => state.modals[id] || getInitialModalState({ initialWidth, initialHeight })\r\n\r\nconst clampDrag = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { x: number; y: number } => {\r\n const maxX = windowWidth - width;\r\n const maxY = windowHeight - height;\r\n const clampedX = clamp(0, maxX, x);\r\n const clampedY = clamp(0, maxY, y);\r\n return {x: clampedX, y: clampedY}\r\n}\r\n\r\nconst clampResize = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { width: number; height: number } => {\r\n const maxWidth = windowWidth - x;\r\n const maxHeight = windowHeight - y;\r\n const clampedWidth = clamp(200, maxWidth, width);\r\n const clampedHeight = clamp(200, maxHeight, height);\r\n return {width: clampedWidth, height: clampedHeight}\r\n}\r\n\r\nexport const draggableModalReducer = (state: ModalsState, action: Action): ModalsState => {\r\n switch (action.type) {\r\n case 'resize':\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n action.width,\r\n action.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...size,\r\n // resizing by hand takes the dialog out of the maximized state\r\n restore: undefined,\r\n },\r\n },\r\n }\r\n case 'maximize': {\r\n const modalState = state.modals[action.id];\r\n const {restore} = modalState;\r\n if (restore) {\r\n // the window may have shrunk in the meantime, so the old rectangle goes through the\r\n // same clamping as a manual drag/resize\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n restore.x,\r\n restore.y,\r\n restore.width,\r\n restore.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n restore.width,\r\n restore.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n restore: undefined,\r\n },\r\n },\r\n }\r\n }\r\n const inset = action.margin / 2;\r\n const maximized = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n inset,\r\n inset,\r\n state.windowSize.width - action.margin,\r\n state.windowSize.height - action.margin,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n x: inset,\r\n y: inset,\r\n ...maximized,\r\n restore: {\r\n x: modalState.x,\r\n y: modalState.y,\r\n width: modalState.width,\r\n height: modalState.height,\r\n },\r\n },\r\n },\r\n }\r\n }\r\n case 'drag':\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n state.modals[action.id].width,\r\n state.modals[action.id].height,\r\n ),\r\n },\r\n },\r\n }\r\n case 'show': {\r\n const modalState = state.modals[action.id]\r\n const centerX = state.windowSize.width / 2 - modalState.width / 2\r\n const centerY = state.windowSize.height / 2 - modalState.height / 2\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n centerX,\r\n centerY,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n visible: true,\r\n },\r\n },\r\n }\r\n }\r\n case 'focus':\r\n const modalState = state.modals[action.id]\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n },\r\n },\r\n }\r\n case 'hide': {\r\n const modalState = state.modals[action.id]\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n visible: false,\r\n },\r\n },\r\n }\r\n }\r\n case 'mount':\r\n const initialState = getInitialModalState(action.intialState);\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...initialState,\r\n x: state.windowSize.width / 2 - initialState.width / 2,\r\n y: state.windowSize.height / 2 - initialState.height / 2,\r\n },\r\n },\r\n };\r\n case 'unmount':\r\n const modalsClone = {...state.modals};\r\n delete modalsClone[action.id];\r\n return {\r\n ...state,\r\n modals: modalsClone,\r\n };\r\n case 'windowResize':\r\n return {\r\n ...state,\r\n windowSize: action.size,\r\n modals: mapObject(state.modals, (modalState: ModalState) => {\r\n if (!modalState.visible) {\r\n return modalState\r\n }\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n modalState.x,\r\n modalState.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n return {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n }\r\n }),\r\n }\r\n default:\r\n throw new Error()\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"draggableModalReducer.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalReducer.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAE7B,MAAM,SAAS,GAAG,CAAI,CAAuB,EAAE,CAAkB,EAAwB,EAAE,CACvF,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAA;AA2BnE,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC3C,UAAU,EAAE,aAAa,EAAE;IAC3B,MAAM,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAe;IACzC,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,KAAK;CACjB,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,EACI,YAAY,GAAG,iBAAiB,CAAC,KAAK,EACtC,aAAa,GAAG,iBAAiB,CAAC,MAAM,GAIzE,EAAE,EAAE;IACD,uCACO,iBAAiB,KACpB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,aAAa,IACxB;AACL,CAAC,CAAA;AAwBD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EACI,KAAK,EACL,EAAE,EACF,YAAY,EACZ,aAAa,GAM9C,EA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AC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport {getWindowSize} from './getWindowSize'\r\nimport {clamp} from './clamp'\r\n\r\nconst mapObject = <T>(o: { [key: string]: T }, f: (value: T) => T): { [key: string]: T } =>\r\n Object.assign({}, ...Object.keys(o).map(k => ({[k]: f(o[k])})))\r\n\r\n// ID for a specific modal.\r\nexport type ModalID = string\r\n\r\n// State for a specific modal.\r\nexport interface ModalState {\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n visible: boolean\r\n /** rectangle to return to when un-maximizing; set only while the dialog is maximized */\r\n restore?: { x: number; y: number; width: number; height: number }\r\n}\r\n\r\n// State of all modals.\r\nexport interface ModalsState {\r\n windowSize: {\r\n width: number\r\n height: number\r\n }\r\n modals: {\r\n [key: string]: ModalState\r\n }\r\n}\r\n\r\nexport const initialModalsState: ModalsState = {\r\n windowSize: getWindowSize(),\r\n modals: {},\r\n};\r\n\r\nexport const initialModalState: ModalState = {\r\n x: 0,\r\n y: 0,\r\n width: 400,\r\n height: 400,\r\n visible: false,\r\n};\r\n\r\nconst getInitialModalState = ({\r\n initialWidth = initialModalState.width,\r\n initialHeight = initialModalState.height,\r\n }: {\r\n initialWidth?: number\r\n initialHeight?: number\r\n}) => {\r\n return {\r\n ...initialModalState,\r\n width: initialWidth,\r\n height: initialHeight,\r\n }\r\n}\r\n\r\nexport type Action =\r\n | { type: 'show'; id: ModalID }\r\n | { type: 'hide'; id: ModalID }\r\n | { type: 'focus'; id: ModalID }\r\n | { type: 'unmount'; id: ModalID }\r\n | { type: 'mount'; id: ModalID, intialState: { initialWidth?: number; initialHeight?: number } }\r\n | { type: 'windowResize'; size: { width: number; height: number } }\r\n | { type: 'drag'; id: ModalID; x: number; y: number }\r\n /**\r\n * Toggle: fills the window leaving `margin` px of free space in total (half of it on each side),\r\n * or returns to the rectangle from before maximizing.\r\n */\r\n | { type: 'maximize'; id: ModalID; margin: number }\r\n | {\r\n type: 'resize'\r\n id: ModalID\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n}\r\n\r\nexport const getModalState = ({\r\n state,\r\n id,\r\n initialWidth,\r\n initialHeight,\r\n }: {\r\n state: ModalsState\r\n id: ModalID\r\n initialWidth?: number\r\n initialHeight?: number\r\n}): ModalState => state.modals[id] || getInitialModalState({ initialWidth, initialHeight })\r\n\r\nconst clampDrag = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { x: number; y: number } => {\r\n const maxX = windowWidth - width;\r\n const maxY = windowHeight - height;\r\n const clampedX = clamp(0, maxX, x);\r\n const clampedY = clamp(0, maxY, y);\r\n return {x: clampedX, y: clampedY}\r\n}\r\n\r\nconst clampResize = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { width: number; height: number } => {\r\n const maxWidth = windowWidth - x;\r\n const maxHeight = windowHeight - y;\r\n const clampedWidth = clamp(200, maxWidth, width);\r\n const clampedHeight = clamp(200, maxHeight, height);\r\n return {width: clampedWidth, height: clampedHeight}\r\n}\r\n\r\nexport const draggableModalReducer = (state: ModalsState, action: Action): ModalsState => {\r\n switch (action.type) {\r\n case 'resize':\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n action.width,\r\n action.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...size,\r\n // resizing by hand takes the dialog out of the maximized state\r\n restore: undefined,\r\n },\r\n },\r\n }\r\n case 'maximize': {\r\n const modalState = state.modals[action.id];\r\n const {restore} = modalState;\r\n if (restore) {\r\n // the window may have shrunk in the meantime, so the old rectangle goes through the\r\n // same clamping as a manual drag/resize\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n restore.x,\r\n restore.y,\r\n restore.width,\r\n restore.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n restore.width,\r\n restore.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n restore: undefined,\r\n },\r\n },\r\n }\r\n }\r\n const inset = action.margin / 2;\r\n const maximized = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n inset,\r\n inset,\r\n state.windowSize.width - action.margin,\r\n state.windowSize.height - action.margin,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n x: inset,\r\n y: inset,\r\n ...maximized,\r\n restore: {\r\n x: modalState.x,\r\n y: modalState.y,\r\n width: modalState.width,\r\n height: modalState.height,\r\n },\r\n },\r\n },\r\n }\r\n }\r\n case 'drag':\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n state.modals[action.id].width,\r\n state.modals[action.id].height,\r\n ),\r\n },\r\n },\r\n }\r\n case 'show': {\r\n const modalState = state.modals[action.id]\r\n const centerX = state.windowSize.width / 2 - modalState.width / 2\r\n const centerY = state.windowSize.height / 2 - modalState.height / 2\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n centerX,\r\n centerY,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n visible: true,\r\n },\r\n },\r\n }\r\n }\r\n case 'focus':\r\n const modalState = state.modals[action.id]\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n },\r\n },\r\n }\r\n case 'hide': {\r\n const modalState = state.modals[action.id]\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n visible: false,\r\n },\r\n },\r\n }\r\n }\r\n case 'mount':\r\n const initialState = getInitialModalState(action.intialState);\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...initialState,\r\n x: state.windowSize.width / 2 - initialState.width / 2,\r\n y: state.windowSize.height / 2 - initialState.height / 2,\r\n },\r\n },\r\n };\r\n case 'unmount':\r\n const modalsClone = {...state.modals};\r\n delete modalsClone[action.id];\r\n return {\r\n ...state,\r\n modals: modalsClone,\r\n };\r\n case 'windowResize':\r\n return {\r\n ...state,\r\n windowSize: action.size,\r\n modals: mapObject(state.modals, (modalState: ModalState) => {\r\n if (!modalState.visible) {\r\n return modalState\r\n }\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n modalState.x,\r\n modalState.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n return {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n }\r\n }),\r\n }\r\n default:\r\n throw new Error()\r\n }\r\n}\r\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** the antd tokens the header-button geometry is derived from */
|
|
1
2
|
interface HeaderButtonToken {
|
|
2
3
|
controlHeight: number;
|
|
3
4
|
padding: number;
|
|
@@ -5,10 +6,26 @@ interface HeaderButtonToken {
|
|
|
5
6
|
lineHeightHeading5: number;
|
|
6
7
|
fontSizeHeading5: number;
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Geometry of the buttons in the top-right corner of the header. Mirrors antd's own close-button
|
|
11
|
+
* math (prepareToken in antd/es/modal/style) so our maximize button lines up with antd's close
|
|
12
|
+
* button, and so the title knows how much room to leave for them.
|
|
13
|
+
*/
|
|
8
14
|
export declare const headerButtonGeometry: (token: HeaderButtonToken) => {
|
|
15
|
+
/** inset-inline-end of the button sitting left of the close button */
|
|
9
16
|
secondButtonInset: number;
|
|
17
|
+
/** horizontal space the title has to leave free so `count` buttons do not cover it */
|
|
10
18
|
reserve: (count: number) => number;
|
|
11
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Styles of the resizable/draggable modal.
|
|
22
|
+
*
|
|
23
|
+
* Only what dragging + resizing actually needs is defined here (flex layout so the body can
|
|
24
|
+
* grow/scroll, the drag cursor on the title, the resize handle). Everything that antd 5 styles
|
|
25
|
+
* through its own Modal tokens - header/footer spacing, title typography - is deliberately NOT
|
|
26
|
+
* overridden, so the dialog looks like a plain antd 5 Modal. The exception is the content inset,
|
|
27
|
+
* see below.
|
|
28
|
+
*/
|
|
12
29
|
export declare const useDraggableModalStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
|
|
13
30
|
wrap: import("antd-style").SerializedStyles;
|
|
14
31
|
wrapWithoutFooter: import("antd-style").SerializedStyles;
|
|
@@ -1,22 +1,47 @@
|
|
|
1
1
|
import { createStyles } from "antd-style";
|
|
2
|
+
/**
|
|
3
|
+
* Geometry of the buttons in the top-right corner of the header. Mirrors antd's own close-button
|
|
4
|
+
* math (prepareToken in antd/es/modal/style) so our maximize button lines up with antd's close
|
|
5
|
+
* button, and so the title knows how much room to leave for them.
|
|
6
|
+
*/
|
|
2
7
|
export const headerButtonGeometry = (token) => {
|
|
3
8
|
const size = token.controlHeight;
|
|
4
9
|
const headerHeight = token.lineHeightHeading5 * token.fontSizeHeading5 + token.padding * 2;
|
|
5
10
|
const inset = (headerHeight - size) / 2;
|
|
6
11
|
const gap = token.marginXXS;
|
|
7
12
|
return {
|
|
13
|
+
/** inset-inline-end of the button sitting left of the close button */
|
|
8
14
|
secondButtonInset: inset + size + gap,
|
|
15
|
+
/** horizontal space the title has to leave free so `count` buttons do not cover it */
|
|
9
16
|
reserve: (count) => count <= 0 ? 0 : inset + count * size + (count - 1) * gap,
|
|
10
17
|
};
|
|
11
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Styles of the resizable/draggable modal.
|
|
21
|
+
*
|
|
22
|
+
* Only what dragging + resizing actually needs is defined here (flex layout so the body can
|
|
23
|
+
* grow/scroll, the drag cursor on the title, the resize handle). Everything that antd 5 styles
|
|
24
|
+
* through its own Modal tokens - header/footer spacing, title typography - is deliberately NOT
|
|
25
|
+
* overridden, so the dialog looks like a plain antd 5 Modal. The exception is the content inset,
|
|
26
|
+
* see below.
|
|
27
|
+
*/
|
|
12
28
|
export const useDraggableModalStyles = createStyles(({ token, css, prefixCls }) => {
|
|
13
29
|
const modalCls = `.${prefixCls}-modal`;
|
|
30
|
+
// antd's default horizontal contentPadding, mirrored here because the parts carry it themselves
|
|
14
31
|
const contentPaddingInline = token.paddingContentHorizontalLG;
|
|
32
|
+
/*
|
|
33
|
+
* That inset is split between the content and the body. The body is the scroll container, and a
|
|
34
|
+
* scrollbar is always drawn at its border edge - so the content keeps the outer slice to push the
|
|
35
|
+
* body's scrollbars off the dialog edge, and the body keeps the rest as the gap between a
|
|
36
|
+
* scrollbar and the text (which is also what absorbs negative margins, see the body rule).
|
|
37
|
+
*/
|
|
15
38
|
const scrollbarInset = token.paddingXS;
|
|
16
39
|
const bodyPaddingInline = contentPaddingInline - scrollbarInset;
|
|
17
40
|
const headerButtons = headerButtonGeometry(token);
|
|
41
|
+
// the grab area reaches slightly outside the content so it does not sit on top of the footer buttons
|
|
18
42
|
const handleSize = 44;
|
|
19
43
|
const handleOverhang = 10;
|
|
44
|
+
// the visible corner marker inside the grab area
|
|
20
45
|
const markerSize = 12;
|
|
21
46
|
return {
|
|
22
47
|
wrap: css `
|
|
@@ -117,6 +142,12 @@ export const useDraggableModalStyles = createStyles(({ token, css, prefixCls })
|
|
|
117
142
|
padding-inline: ${bodyPaddingInline}px;
|
|
118
143
|
}
|
|
119
144
|
`,
|
|
145
|
+
/*
|
|
146
|
+
* The bottom inset normally lives on the footer (see above). Dialogs rendered without one -
|
|
147
|
+
* every NO_BUTTONS ModalDialog, and anything passing footer={null} - would otherwise have
|
|
148
|
+
* their content flush against the bottom edge, so the content takes the inset back. The
|
|
149
|
+
* extra selector level is needed to outweigh the padding-block: 0 above.
|
|
150
|
+
*/
|
|
120
151
|
wrapWithoutFooter: css `
|
|
121
152
|
${modalCls} ${modalCls}-content {
|
|
122
153
|
padding-bottom: ${token.padding}px;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggableModalStyles.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAgBxC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAwB,EAAE,EAAE;IAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC;IACjC,MAAM,YAAY,GAAG,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;IAC3F,MAAM,KAAK,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO;QAEH,iBAAiB,EAAE,KAAK,GAAG,IAAI,GAAG,GAAG;QAErC,OAAO,EAAE,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,GAAG;KAChG,CAAA;AACL,CAAC,CAAC;AAWF,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAC,CAAC,EAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAC,EAAE,EAAE;I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KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,iBAAiB;;;SAG/E;KACJ,CAAC;AACN,CAAC,CAAC,CAAC","sourcesContent":["import {createStyles} from \"antd-style\";\r\n\r\n/** the antd tokens the header-button geometry is derived from */\r\ninterface HeaderButtonToken {\r\n controlHeight: number\r\n padding: number\r\n marginXXS: number\r\n lineHeightHeading5: number\r\n fontSizeHeading5: number\r\n}\r\n\r\n/**\r\n * Geometry of the buttons in the top-right corner of the header. Mirrors antd's own close-button\r\n * math (prepareToken in antd/es/modal/style) so our maximize button lines up with antd's close\r\n * button, and so the title knows how much room to leave for them.\r\n */\r\nexport const headerButtonGeometry = (token: HeaderButtonToken) => {\r\n const size = token.controlHeight;\r\n const headerHeight = token.lineHeightHeading5 * token.fontSizeHeading5 + token.padding * 2;\r\n const inset = (headerHeight - size) / 2;\r\n const gap = token.marginXXS;\r\n return {\r\n /** inset-inline-end of the button sitting left of the close button */\r\n secondButtonInset: inset + size + gap,\r\n /** horizontal space the title has to leave free so `count` buttons do not cover it */\r\n reserve: (count: number): number => count <= 0 ? 0 : inset + count * size + (count - 1) * gap,\r\n }\r\n};\r\n\r\n/**\r\n * Styles of the resizable/draggable modal.\r\n *\r\n * Only what dragging + resizing actually needs is defined here (flex layout so the body can\r\n * grow/scroll, the drag cursor on the title, the resize handle). Everything that antd 5 styles\r\n * through its own Modal tokens - header/footer spacing, title typography - is deliberately NOT\r\n * overridden, so the dialog looks like a plain antd 5 Modal. The exception is the content inset,\r\n * see below.\r\n */\r\nexport const useDraggableModalStyles = createStyles(({token, css, prefixCls}) => {\r\n const modalCls = `.${prefixCls}-modal`;\r\n\r\n // antd's default horizontal contentPadding, mirrored here because the parts carry it themselves\r\n const contentPaddingInline = token.paddingContentHorizontalLG;\r\n\r\n /*\r\n * That inset is split between the content and the body. The body is the scroll container, and a\r\n * scrollbar is always drawn at its border edge - so the content keeps the outer slice to push the\r\n * body's scrollbars off the dialog edge, and the body keeps the rest as the gap between a\r\n * scrollbar and the text (which is also what absorbs negative margins, see the body rule).\r\n */\r\n const scrollbarInset = token.paddingXS;\r\n const bodyPaddingInline = contentPaddingInline - scrollbarInset;\r\n\r\n const headerButtons = headerButtonGeometry(token);\r\n\r\n // the grab area reaches slightly outside the content so it does not sit on top of the footer buttons\r\n const handleSize = 44;\r\n const handleOverhang = 10;\r\n // the visible corner marker inside the grab area\r\n const markerSize = 12;\r\n\r\n return {\r\n wrap: css`\r\n overflow: hidden !important;\r\n\r\n ${modalCls} {\r\n display: flex;\r\n max-width: none;\r\n transform-origin: 50% 50% !important;\r\n }\r\n\r\n /*\r\n * rc-dialog puts an unclassed wrapper div between .ant-modal and .ant-modal-content.\r\n * As a flex item with width:auto it only shrink-wraps its content, so the dialog would\r\n * not follow the resized width. The focus sentinels matched by the same selector keep\r\n * their inline width:0, so they are not affected.\r\n */\r\n ${modalCls} > div {\r\n width: 100%;\r\n }\r\n\r\n /* the height comes from the modal state - content has to fill it and lay the parts out vertically */\r\n ${modalCls}-content {\r\n display: flex;\r\n flex-direction: column;\r\n flex: 1;\r\n width: 100%;\r\n height: 100%;\r\n /*\r\n * Deliberate deviation from the antd 5 default: the content carries no inset at all.\r\n * The top one belongs to the title (so the whole header area can be grabbed for\r\n * dragging) and the bottom one to the footer, which keeps both dividers surrounded by\r\n * padding instead of glued to the text. Horizontally it keeps only the slice the\r\n * body's scrollbars are drawn in, so they never sit on the dialog edge.\r\n */\r\n padding: 0 ${scrollbarInset}px;\r\n }\r\n\r\n ${modalCls}-header,\r\n ${modalCls}-footer {\r\n flex: 0 0 auto;\r\n /*\r\n * When the app configures dividers (Modal headerBorderBottom / footerBorderTop\r\n * tokens - d2ui does), antd draws them on the header/footer box. Bleed the box back\r\n * out over the content's scrollbar slice so the lines still span the dialog; the\r\n * title/buttons keep their own full inset and do not move.\r\n */\r\n margin-inline: -${scrollbarInset}px;\r\n }\r\n\r\n /*\r\n * The header contributes no spacing of its own - all of it lives on the drag area inside\r\n * (see the title style below), so every pixel down to the divider drags the dialog. The gap\r\n * to the body stays at the antd default (marginXS) and sits below the divider.\r\n */\r\n ${modalCls}-header {\r\n padding: 0;\r\n margin-bottom: ${token.marginXS}px;\r\n }\r\n\r\n /*\r\n * Mirror of the header: the footer carries the content's bottom inset itself, so the\r\n * divider has padding below it instead of sitting right on the buttons. The gap above the\r\n * divider stays at the antd default (marginSM).\r\n */\r\n ${modalCls}-footer {\r\n padding: ${token.padding}px ${contentPaddingInline}px;\r\n margin-top: ${token.marginSM}px;\r\n }\r\n\r\n /*\r\n * The maximize button reuses antd's .ant-modal-close markup so it looks and behaves like\r\n * the close button next to it (hover, focus ring, icon size); it only gets parked one\r\n * button width to the left. antd positions the close button with a two-class selector, so\r\n * this override has to be at least as specific.\r\n */\r\n ${modalCls} .ant-design-draggable-modal-maximize {\r\n inset-inline-end: ${headerButtons.secondButtonInset}px;\r\n }\r\n\r\n /*\r\n * The only part that shrinks/grows with the dialog; min-height:0 lets it actually shrink\r\n * in a flex column.\r\n *\r\n * Most of the horizontal inset lives here and not on the content on purpose. The body is\r\n * the scroll container, so anything sticking out of its content box becomes a horizontal\r\n * scrollbar - and antd's own <Row gutter={n}> does exactly that: it sets\r\n * margin-inline: -n/2 and is therefore n px wider than its parent (the matching padding\r\n * on each Col puts the visible content back, so only the scrollbar shows it). With the\r\n * whole inset on the content the body was flush with its children and every dialog whose\r\n * form starts with a gutter row had a permanent n/2 px horizontal scrollbar. Owning the\r\n * padding, the body absorbs those negative margins like a plain antd modal body does.\r\n */\r\n ${modalCls}-body {\r\n flex: 1 1 auto;\r\n min-height: 0;\r\n overflow: auto;\r\n padding-inline: ${bodyPaddingInline}px;\r\n }\r\n `,\r\n /*\r\n * The bottom inset normally lives on the footer (see above). Dialogs rendered without one -\r\n * every NO_BUTTONS ModalDialog, and anything passing footer={null} - would otherwise have\r\n * their content flush against the bottom edge, so the content takes the inset back. The\r\n * extra selector level is needed to outweigh the padding-block: 0 above.\r\n */\r\n wrapWithoutFooter: css`\r\n ${modalCls} ${modalCls}-content {\r\n padding-bottom: ${token.padding}px;\r\n }\r\n `,\r\n title: css`\r\n cursor: move;\r\n user-select: none;\r\n /*\r\n * Carries the whole header inset - the content's vertical padding and the horizontal\r\n * padding the header would otherwise have - so the entire header area is a drag handle,\r\n * right up to the dialog edges and down to the divider.\r\n */\r\n padding: ${token.padding}px ${contentPaddingInline}px;\r\n `,\r\n resizeHandle: css`\r\n position: absolute;\r\n right: -${handleOverhang}px;\r\n bottom: -${handleOverhang}px;\r\n width: ${handleSize}px;\r\n height: ${handleSize}px;\r\n cursor: se-resize;\r\n `,\r\n resizeHandleInner: css`\r\n position: absolute;\r\n right: ${handleOverhang + token.paddingXXS}px;\r\n bottom: ${handleOverhang + token.paddingXXS}px;\r\n width: ${markerSize}px;\r\n height: ${markerSize}px;\r\n border: ${token.lineWidthBold}px ${token.lineType} ${token.colorTextTertiary};\r\n border-top: 0;\r\n border-left: 0;\r\n `,\r\n };\r\n});\r\n"]}
|
|
1
|
+
{"version":3,"file":"draggableModalStyles.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalStyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AAWxC;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAwB,EAAE,EAAE;IAC7D,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC;IACjC,MAAM,YAAY,GAAG,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;IAC3F,MAAM,KAAK,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC;IAC5B,OAAO;QACH,sEAAsE;QACtE,iBAAiB,EAAE,KAAK,GAAG,IAAI,GAAG,GAAG;QACrC,sFAAsF;QACtF,OAAO,EAAE,CAAC,KAAa,EAAU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Q,IAAI,QAAQ;kCACA,KAAK,CAAC,OAAO;;SAEtC;QACD,KAAK,EAAE,GAAG,CAAA;;;;;;;;uBAQK,KAAK,CAAC,OAAO,MAAM,oBAAoB;SACrD;QACD,YAAY,EAAE,GAAG,CAAA;;sBAEH,cAAc;uBACb,cAAc;qBAChB,UAAU;sBACT,UAAU;;SAEvB;QACD,iBAAiB,EAAE,GAAG,CAAA;;qBAET,cAAc,GAAG,KAAK,CAAC,UAAU;sBAChC,cAAc,GAAG,KAAK,CAAC,UAAU;qBAClC,UAAU;sBACT,UAAU;sBACV,KAAK,CAAC,aAAa,MAAM,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,iBAAiB;;;SAG/E;KACJ,CAAC;AACN,CAAC,CAAC,CAAC","sourcesContent":["import {createStyles} from \"antd-style\";\r\n\r\n/** the antd tokens the header-button geometry is derived from */\r\ninterface HeaderButtonToken {\r\n controlHeight: number\r\n padding: number\r\n marginXXS: number\r\n lineHeightHeading5: number\r\n fontSizeHeading5: number\r\n}\r\n\r\n/**\r\n * Geometry of the buttons in the top-right corner of the header. Mirrors antd's own close-button\r\n * math (prepareToken in antd/es/modal/style) so our maximize button lines up with antd's close\r\n * button, and so the title knows how much room to leave for them.\r\n */\r\nexport const headerButtonGeometry = (token: HeaderButtonToken) => {\r\n const size = token.controlHeight;\r\n const headerHeight = token.lineHeightHeading5 * token.fontSizeHeading5 + token.padding * 2;\r\n const inset = (headerHeight - size) / 2;\r\n const gap = token.marginXXS;\r\n return {\r\n /** inset-inline-end of the button sitting left of the close button */\r\n secondButtonInset: inset + size + gap,\r\n /** horizontal space the title has to leave free so `count` buttons do not cover it */\r\n reserve: (count: number): number => count <= 0 ? 0 : inset + count * size + (count - 1) * gap,\r\n }\r\n};\r\n\r\n/**\r\n * Styles of the resizable/draggable modal.\r\n *\r\n * Only what dragging + resizing actually needs is defined here (flex layout so the body can\r\n * grow/scroll, the drag cursor on the title, the resize handle). Everything that antd 5 styles\r\n * through its own Modal tokens - header/footer spacing, title typography - is deliberately NOT\r\n * overridden, so the dialog looks like a plain antd 5 Modal. The exception is the content inset,\r\n * see below.\r\n */\r\nexport const useDraggableModalStyles = createStyles(({token, css, prefixCls}) => {\r\n const modalCls = `.${prefixCls}-modal`;\r\n\r\n // antd's default horizontal contentPadding, mirrored here because the parts carry it themselves\r\n const contentPaddingInline = token.paddingContentHorizontalLG;\r\n\r\n /*\r\n * That inset is split between the content and the body. The body is the scroll container, and a\r\n * scrollbar is always drawn at its border edge - so the content keeps the outer slice to push the\r\n * body's scrollbars off the dialog edge, and the body keeps the rest as the gap between a\r\n * scrollbar and the text (which is also what absorbs negative margins, see the body rule).\r\n */\r\n const scrollbarInset = token.paddingXS;\r\n const bodyPaddingInline = contentPaddingInline - scrollbarInset;\r\n\r\n const headerButtons = headerButtonGeometry(token);\r\n\r\n // the grab area reaches slightly outside the content so it does not sit on top of the footer buttons\r\n const handleSize = 44;\r\n const handleOverhang = 10;\r\n // the visible corner marker inside the grab area\r\n const markerSize = 12;\r\n\r\n return {\r\n wrap: css`\r\n overflow: hidden !important;\r\n\r\n ${modalCls} {\r\n display: flex;\r\n max-width: none;\r\n transform-origin: 50% 50% !important;\r\n }\r\n\r\n /*\r\n * rc-dialog puts an unclassed wrapper div between .ant-modal and .ant-modal-content.\r\n * As a flex item with width:auto it only shrink-wraps its content, so the dialog would\r\n * not follow the resized width. The focus sentinels matched by the same selector keep\r\n * their inline width:0, so they are not affected.\r\n */\r\n ${modalCls} > div {\r\n width: 100%;\r\n }\r\n\r\n /* the height comes from the modal state - content has to fill it and lay the parts out vertically */\r\n ${modalCls}-content {\r\n display: flex;\r\n flex-direction: column;\r\n flex: 1;\r\n width: 100%;\r\n height: 100%;\r\n /*\r\n * Deliberate deviation from the antd 5 default: the content carries no inset at all.\r\n * The top one belongs to the title (so the whole header area can be grabbed for\r\n * dragging) and the bottom one to the footer, which keeps both dividers surrounded by\r\n * padding instead of glued to the text. Horizontally it keeps only the slice the\r\n * body's scrollbars are drawn in, so they never sit on the dialog edge.\r\n */\r\n padding: 0 ${scrollbarInset}px;\r\n }\r\n\r\n ${modalCls}-header,\r\n ${modalCls}-footer {\r\n flex: 0 0 auto;\r\n /*\r\n * When the app configures dividers (Modal headerBorderBottom / footerBorderTop\r\n * tokens - d2ui does), antd draws them on the header/footer box. Bleed the box back\r\n * out over the content's scrollbar slice so the lines still span the dialog; the\r\n * title/buttons keep their own full inset and do not move.\r\n */\r\n margin-inline: -${scrollbarInset}px;\r\n }\r\n\r\n /*\r\n * The header contributes no spacing of its own - all of it lives on the drag area inside\r\n * (see the title style below), so every pixel down to the divider drags the dialog. The gap\r\n * to the body stays at the antd default (marginXS) and sits below the divider.\r\n */\r\n ${modalCls}-header {\r\n padding: 0;\r\n margin-bottom: ${token.marginXS}px;\r\n }\r\n\r\n /*\r\n * Mirror of the header: the footer carries the content's bottom inset itself, so the\r\n * divider has padding below it instead of sitting right on the buttons. The gap above the\r\n * divider stays at the antd default (marginSM).\r\n */\r\n ${modalCls}-footer {\r\n padding: ${token.padding}px ${contentPaddingInline}px;\r\n margin-top: ${token.marginSM}px;\r\n }\r\n\r\n /*\r\n * The maximize button reuses antd's .ant-modal-close markup so it looks and behaves like\r\n * the close button next to it (hover, focus ring, icon size); it only gets parked one\r\n * button width to the left. antd positions the close button with a two-class selector, so\r\n * this override has to be at least as specific.\r\n */\r\n ${modalCls} .ant-design-draggable-modal-maximize {\r\n inset-inline-end: ${headerButtons.secondButtonInset}px;\r\n }\r\n\r\n /*\r\n * The only part that shrinks/grows with the dialog; min-height:0 lets it actually shrink\r\n * in a flex column.\r\n *\r\n * Most of the horizontal inset lives here and not on the content on purpose. The body is\r\n * the scroll container, so anything sticking out of its content box becomes a horizontal\r\n * scrollbar - and antd's own <Row gutter={n}> does exactly that: it sets\r\n * margin-inline: -n/2 and is therefore n px wider than its parent (the matching padding\r\n * on each Col puts the visible content back, so only the scrollbar shows it). With the\r\n * whole inset on the content the body was flush with its children and every dialog whose\r\n * form starts with a gutter row had a permanent n/2 px horizontal scrollbar. Owning the\r\n * padding, the body absorbs those negative margins like a plain antd modal body does.\r\n */\r\n ${modalCls}-body {\r\n flex: 1 1 auto;\r\n min-height: 0;\r\n overflow: auto;\r\n padding-inline: ${bodyPaddingInline}px;\r\n }\r\n `,\r\n /*\r\n * The bottom inset normally lives on the footer (see above). Dialogs rendered without one -\r\n * every NO_BUTTONS ModalDialog, and anything passing footer={null} - would otherwise have\r\n * their content flush against the bottom edge, so the content takes the inset back. The\r\n * extra selector level is needed to outweigh the padding-block: 0 above.\r\n */\r\n wrapWithoutFooter: css`\r\n ${modalCls} ${modalCls}-content {\r\n padding-bottom: ${token.padding}px;\r\n }\r\n `,\r\n title: css`\r\n cursor: move;\r\n user-select: none;\r\n /*\r\n * Carries the whole header inset - the content's vertical padding and the horizontal\r\n * padding the header would otherwise have - so the entire header area is a drag handle,\r\n * right up to the dialog edges and down to the divider.\r\n */\r\n padding: ${token.padding}px ${contentPaddingInline}px;\r\n `,\r\n resizeHandle: css`\r\n position: absolute;\r\n right: -${handleOverhang}px;\r\n bottom: -${handleOverhang}px;\r\n width: ${handleSize}px;\r\n height: ${handleSize}px;\r\n cursor: se-resize;\r\n `,\r\n resizeHandleInner: css`\r\n position: absolute;\r\n right: ${handleOverhang + token.paddingXXS}px;\r\n bottom: ${handleOverhang + token.paddingXXS}px;\r\n width: ${markerSize}px;\r\n height: ${markerSize}px;\r\n border: ${token.lineWidthBold}px ${token.lineType} ${token.colorTextTertiary};\r\n border-top: 0;\r\n border-left: 0;\r\n `,\r\n };\r\n});\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getWindowSize.js","sourceRoot":"","sources":["../../../../../components/modal/impl/getWindowSize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getWindowSize.js","sourceRoot":"","sources":["../../../../../components/modal/impl/getWindowSize.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAsC,EAAE,CAAC,CAAC;IACnE,KAAK,EAAE,MAAM,CAAC,UAAU,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,WAAW,IAAI,CAAC;CAClC,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nexport const getWindowSize = (): { width: number; height: number } => ({\r\n width: window.innerWidth || 0,\r\n height: window.innerHeight || 0,\r\n})\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../components/modal/impl/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../components/modal/impl/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nexport * from './draggableModal'\r\nexport * from './draggableModalContext'\r\nexport * from '../draggableModalProvider'\r\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
export interface ResizeHandleProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
3
|
+
/** class of the visible corner marker inside the grab area */
|
|
3
4
|
innerClassName?: string;
|
|
4
5
|
}
|
|
5
6
|
export declare const ResizeHandle: ({ className, innerClassName, ...props }: ResizeHandleProps) => React.ReactElement;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// https://github.com/CUBETIQ/antd-modal/
|
|
1
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
3
|
var t = {};
|
|
3
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -12,7 +13,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
13
|
import * as React from 'react';
|
|
13
14
|
export const ResizeHandle = (_a) => {
|
|
14
15
|
var { className, innerClassName } = _a, props = __rest(_a, ["className", "innerClassName"]);
|
|
15
|
-
return (
|
|
16
|
+
return (
|
|
17
|
+
// the legacy class names are kept as styling hooks for the app (e.g. .compact-modal)
|
|
18
|
+
React.createElement("div", Object.assign({ className: `ant-design-draggable-modal-resize-handle ${className !== null && className !== void 0 ? className : ''}` }, props),
|
|
16
19
|
React.createElement("div", { className: `ant-design-draggable-modal-resize-handle-inner ${innerClassName !== null && innerClassName !== void 0 ? innerClassName : ''}` })));
|
|
17
20
|
};
|
|
18
21
|
//# sourceMappingURL=resizeHandle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizeHandle.js","sourceRoot":"","sources":["../../../../../components/modal/impl/resizeHandle.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resizeHandle.js","sourceRoot":"","sources":["../../../../../components/modal/impl/resizeHandle.tsx"],"names":[],"mappings":"AAAA,yCAAyC;;;;;;;;;;;;AAEzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAwD,EAAsB,EAAE;QAAhF,EAAC,SAAS,EAAE,cAAc,OAA8B,EAAzB,KAAK,cAApC,+BAAqC,CAAD;IAA6C,OAAA;IAC1G,qFAAqF;IACrF,2CAAK,SAAS,EAAE,4CAA4C,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,EAAE,IAAM,KAAK;QACpF,6BAAK,SAAS,EAAE,kDAAkD,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,EAAE,EAAE,GAAG,CACzF,CACT,CAAA;CAAA,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\n\r\nexport interface ResizeHandleProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {\r\n /** class of the visible corner marker inside the grab area */\r\n innerClassName?: string\r\n}\r\n\r\nexport const ResizeHandle = ({className, innerClassName, ...props}: ResizeHandleProps): React.ReactElement => (\r\n // the legacy class names are kept as styling hooks for the app (e.g. .compact-modal)\r\n <div className={`ant-design-draggable-modal-resize-handle ${className ?? ''}`} {...props}>\r\n <div className={`ant-design-draggable-modal-resize-handle-inner ${innerClassName ?? ''}`}/>\r\n </div>\r\n)\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDrag.js","sourceRoot":"","sources":["../../../../../components/modal/impl/useDrag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDrag.js","sourceRoot":"","sources":["../../../../../components/modal/impl/useDrag.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAGzC,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AAEtD,MAAM,CAAC,MAAM,OAAO,GAAG,CACnB,CAAS,EACT,CAAS,EACT,MAAgD,EACjB,EAAE;IACjC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC;QACrD,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,CAAC;QACR,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,CAAC;KAChB,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,WAAW,CAC3B,CAAC,CAAmB,EAAE,EAAE;QACpB,CAAC,CAAC,cAAc,EAAE,CAAA;QAClB,mBAAmB,CAAC;YAChB,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,CAAC;YACR,UAAU,EAAE,CAAC,CAAC,OAAO;YACrB,UAAU,EAAE,CAAC,CAAC,OAAO;SACxB,CAAC,CAAA;QACF,WAAW,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC,EACD,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAC3C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export const useDrag = (\r\n x: number,\r\n y: number,\r\n onDrag: (args: { x: number; y: number }) => void,\r\n): ((e: React.MouseEvent) => void) => {\r\n const [dragging, setDragging] = useState(false)\r\n const [initialDragState, setInitialDragState] = useState({\r\n initX: 0,\r\n initY: 0,\r\n mouseDownX: 0,\r\n mouseDownY: 0,\r\n })\r\n\r\n const onMouseDown = useCallback(\r\n (e: React.MouseEvent) => {\r\n e.preventDefault()\r\n setInitialDragState({\r\n initX: x,\r\n initY: y,\r\n mouseDownX: e.clientX,\r\n mouseDownY: e.clientY,\r\n })\r\n setDragging(true)\r\n },\r\n [x, y, setDragging, setInitialDragState],\r\n )\r\n\r\n useEffect(() => {\r\n const onMouseMove = (e: MouseEvent): void => {\r\n if (dragging) {\r\n const { initX, mouseDownX, initY, mouseDownY } = initialDragState\r\n let dx = e.clientX - mouseDownX\r\n let dy = e.clientY - mouseDownY\r\n const x = initX + dx\r\n const y = initY + dy\r\n onDrag({ x, y })\r\n }\r\n }\r\n window.addEventListener('mousemove', onMouseMove, { passive: true })\r\n return () => window.removeEventListener('mousemove', onMouseMove)\r\n }, [initialDragState, dragging, onDrag])\r\n\r\n useEffect(() => {\r\n const onMouseUp = (): void => {\r\n setDragging(false)\r\n }\r\n window.addEventListener('mouseup', onMouseUp)\r\n return () => window.removeEventListener('mouseup', onMouseUp)\r\n }, [setDragging])\r\n\r\n return onMouseDown\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrevious.js","sourceRoot":"","sources":["../../../../../components/modal/impl/usePrevious.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePrevious.js","sourceRoot":"","sources":["../../../../../components/modal/impl/usePrevious.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAA;AAEvC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,KAAQ,EAAK,EAAE;IAC1C,MAAM,GAAG,GAAG,MAAM,CAAI,KAAK,CAAC,CAAA;IAC5B,SAAS,CAAC,GAAG,EAAE;QACX,GAAG,CAAC,OAAO,GAAG,KAAK,CAAA;IACvB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IACX,OAAO,GAAG,CAAC,OAAO,CAAA;AACtB,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport {useEffect, useRef} from 'react'\r\n\r\nexport const usePrevious = <T>(value: T): T => {\r\n const ref = useRef<T>(value)\r\n useEffect(() => {\r\n ref.current = value\r\n }, [value])\r\n return ref.current\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResize.js","sourceRoot":"","sources":["../../../../../components/modal/impl/useResize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useResize.js","sourceRoot":"","sources":["../../../../../components/modal/impl/useResize.ts"],"names":[],"mappings":"AAAA,yCAAyC;AAGzC,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AAWtD,MAAM,CAAC,MAAM,SAAS,GAAG,CACrB,CAAS,EACT,CAAS,EACT,KAAa,EACb,MAAc,EACd,QAAiF,EAClD,EAAE;IACjC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAe;QACnE,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,CAAC;QACR,SAAS,EAAE,CAAC;QACZ,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,CAAC;QACb,UAAU,EAAE,CAAC;KAChB,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,WAAW,CAC3B,CAAC,CAAmB,EAAE,EAAE;QACpB,CAAC,CAAC,cAAc,EAAE,CAAA;QAClB,mBAAmB,CAAC;YAChB,KAAK,EAAE,CAAC;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C,KAAK,CAAC,CAAA;QACtB,CAAC,CAAA;QACD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IACjE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAEjB,OAAO,WAAW,CAAA;AACtB,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {useCallback, useEffect, useState} from 'react'\r\n\r\ninterface InitialState {\r\n initX: number\r\n initY: number\r\n initWidth: number\r\n initHeight: number\r\n mouseDownX: number\r\n mouseDownY: number\r\n}\r\n\r\nexport const useResize = (\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n onResize: (args: { x: number; y: number; width: number; height: number }) => void,\r\n): ((e: React.MouseEvent) => void) => {\r\n const [dragging, setDragging] = useState(false);\r\n const [initialDragState, setInitialDragState] = useState<InitialState>({\r\n initX: 0,\r\n initY: 0,\r\n initWidth: 0,\r\n initHeight: 0,\r\n mouseDownX: 0,\r\n mouseDownY: 0,\r\n })\r\n\r\n const onMouseDown = useCallback(\r\n (e: React.MouseEvent) => {\r\n e.preventDefault()\r\n setInitialDragState({\r\n initX: x,\r\n initY: y,\r\n initWidth: width,\r\n initHeight: height,\r\n mouseDownX: e.clientX,\r\n mouseDownY: e.clientY,\r\n })\r\n setDragging(true)\r\n },\r\n [width, height, setDragging, setInitialDragState, x, y],\r\n )\r\n\r\n useEffect(() => {\r\n const onMouseMove = (e: MouseEvent): void => {\r\n if (dragging) {\r\n const {\r\n initX,\r\n initY,\r\n initWidth,\r\n mouseDownX,\r\n initHeight,\r\n mouseDownY,\r\n } = initialDragState\r\n let dx = e.clientX - mouseDownX\r\n let dy = e.clientY - mouseDownY\r\n const width = initWidth + dx;\r\n const height = initHeight + dy;\r\n return onResize({ x: initX, y: initY, width, height })\r\n }\r\n }\r\n window.addEventListener('mousemove', onMouseMove, { passive: true })\r\n return () => window.removeEventListener('mousemove', onMouseMove)\r\n }, [initialDragState, dragging, onResize])\r\n\r\n useEffect(() => {\r\n const onMouseUp = (): void => {\r\n setDragging(false)\r\n }\r\n window.addEventListener('mouseup', onMouseUp);\r\n return () => window.removeEventListener('mouseup', onMouseUp)\r\n }, [setDragging])\r\n\r\n return onMouseDown\r\n}\r\n"]}
|