d2coreui 23.0.57 → 23.0.59
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 +21 -0
- package/README.md +154 -154
- package/components/date/dateRangeInputAdvancedPanel.js +14 -14
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
- package/components/date/dateRangeInputConfirm.js +5 -5
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.js +61 -61
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/grid/config/columnTransfer.js +61 -43
- package/components/grid/config/columnTransfer.js.map +1 -1
- package/components/grid/dataGrid.d.ts +24 -1
- package/components/grid/dataGrid.js +106 -45
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/export/worker/pdfExport.js.map +1 -1
- package/components/grid/extendedDataGrid.js +1 -0
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/grid/header/simpleHeader.d.ts +1 -1
- package/components/grid/header/simpleHeader.js +3 -2
- package/components/grid/header/simpleHeader.js.map +1 -1
- package/components/grid/panel/dataGridPagination.d.ts +4 -1
- package/components/grid/panel/dataGridPagination.js +13 -8
- package/components/grid/panel/dataGridPagination.js.map +1 -1
- package/components/input/autoCompleteInput.d.ts +3 -0
- package/components/input/autoCompleteInput.js +18 -3
- package/components/input/autoCompleteInput.js.map +1 -1
- package/components/modal/impl/draggableModal.d.ts +1 -1
- package/components/modal/impl/draggableModal.js.map +1 -1
- package/components/modal/impl/draggableModalInner.js +1 -1
- package/components/modal/impl/draggableModalInner.js.map +1 -1
- package/components/modal/impl/draggableModalStyles.js +126 -126
- package/components/modal/impl/draggableModalStyles.js.map +1 -1
- package/components/modal/impl/resizeHandle.js.map +1 -1
- package/components/modal/modalDialog.d.ts +2 -2
- package/components/modal/modalDialog.js +2 -2
- package/components/modal/modalDialog.js.map +1 -1
- package/package.json +1 -1
- package/style/index.less +240 -240
|
@@ -44,103 +44,103 @@ export const useDraggableModalStyles = createStyles(({ token, css, prefixCls })
|
|
|
44
44
|
// the visible corner marker inside the grab area
|
|
45
45
|
const markerSize = 12;
|
|
46
46
|
return {
|
|
47
|
-
wrap: css `
|
|
48
|
-
overflow: hidden !important;
|
|
49
|
-
|
|
50
|
-
${modalCls} {
|
|
51
|
-
display: flex;
|
|
52
|
-
max-width: none;
|
|
53
|
-
transform-origin: 50% 50% !important;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/*
|
|
57
|
-
* rc-dialog puts an unclassed wrapper div between .ant-modal and .ant-modal-content.
|
|
58
|
-
* As a flex item with width:auto it only shrink-wraps its content, so the dialog would
|
|
59
|
-
* not follow the resized width. The focus sentinels matched by the same selector keep
|
|
60
|
-
* their inline width:0, so they are not affected.
|
|
61
|
-
*/
|
|
62
|
-
${modalCls} > div {
|
|
63
|
-
width: 100%;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/* the height comes from the modal state - content has to fill it and lay the parts out vertically */
|
|
67
|
-
${modalCls}-content {
|
|
68
|
-
display: flex;
|
|
69
|
-
flex-direction: column;
|
|
70
|
-
flex: 1;
|
|
71
|
-
width: 100%;
|
|
72
|
-
height: 100%;
|
|
73
|
-
/*
|
|
74
|
-
* Deliberate deviation from the antd 5 default: the content carries no inset at all.
|
|
75
|
-
* The top one belongs to the title (so the whole header area can be grabbed for
|
|
76
|
-
* dragging) and the bottom one to the footer, which keeps both dividers surrounded by
|
|
77
|
-
* padding instead of glued to the text. Horizontally it keeps only the slice the
|
|
78
|
-
* body's scrollbars are drawn in, so they never sit on the dialog edge.
|
|
79
|
-
*/
|
|
80
|
-
padding: 0 ${scrollbarInset}px;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
${modalCls}-header,
|
|
84
|
-
${modalCls}-footer {
|
|
85
|
-
flex: 0 0 auto;
|
|
86
|
-
/*
|
|
87
|
-
* When the app configures dividers (Modal headerBorderBottom / footerBorderTop
|
|
88
|
-
* tokens - d2ui does), antd draws them on the header/footer box. Bleed the box back
|
|
89
|
-
* out over the content's scrollbar slice so the lines still span the dialog; the
|
|
90
|
-
* title/buttons keep their own full inset and do not move.
|
|
91
|
-
*/
|
|
92
|
-
margin-inline: -${scrollbarInset}px;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/*
|
|
96
|
-
* The header contributes no spacing of its own - all of it lives on the drag area inside
|
|
97
|
-
* (see the title style below), so every pixel down to the divider drags the dialog. The gap
|
|
98
|
-
* to the body stays at the antd default (marginXS) and sits below the divider.
|
|
99
|
-
*/
|
|
100
|
-
${modalCls}-header {
|
|
101
|
-
padding: 0;
|
|
102
|
-
margin-bottom: ${token.marginXS}px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/*
|
|
106
|
-
* Mirror of the header: the footer carries the content's bottom inset itself, so the
|
|
107
|
-
* divider has padding below it instead of sitting right on the buttons. The gap above the
|
|
108
|
-
* divider stays at the antd default (marginSM).
|
|
109
|
-
*/
|
|
110
|
-
${modalCls}-footer {
|
|
111
|
-
padding: ${token.padding}px ${contentPaddingInline}px;
|
|
112
|
-
margin-top: ${token.marginSM}px;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/*
|
|
116
|
-
* The maximize button reuses antd's .ant-modal-close markup so it looks and behaves like
|
|
117
|
-
* the close button next to it (hover, focus ring, icon size); it only gets parked one
|
|
118
|
-
* button width to the left. antd positions the close button with a two-class selector, so
|
|
119
|
-
* this override has to be at least as specific.
|
|
120
|
-
*/
|
|
121
|
-
${modalCls} .ant-design-draggable-modal-maximize {
|
|
122
|
-
inset-inline-end: ${headerButtons.secondButtonInset}px;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/*
|
|
126
|
-
* The only part that shrinks/grows with the dialog; min-height:0 lets it actually shrink
|
|
127
|
-
* in a flex column.
|
|
128
|
-
*
|
|
129
|
-
* Most of the horizontal inset lives here and not on the content on purpose. The body is
|
|
130
|
-
* the scroll container, so anything sticking out of its content box becomes a horizontal
|
|
131
|
-
* scrollbar - and antd's own <Row gutter={n}> does exactly that: it sets
|
|
132
|
-
* margin-inline: -n/2 and is therefore n px wider than its parent (the matching padding
|
|
133
|
-
* on each Col puts the visible content back, so only the scrollbar shows it). With the
|
|
134
|
-
* whole inset on the content the body was flush with its children and every dialog whose
|
|
135
|
-
* form starts with a gutter row had a permanent n/2 px horizontal scrollbar. Owning the
|
|
136
|
-
* padding, the body absorbs those negative margins like a plain antd modal body does.
|
|
137
|
-
*/
|
|
138
|
-
${modalCls}-body {
|
|
139
|
-
flex: 1 1 auto;
|
|
140
|
-
min-height: 0;
|
|
141
|
-
overflow: auto;
|
|
142
|
-
padding-inline: ${bodyPaddingInline}px;
|
|
143
|
-
}
|
|
47
|
+
wrap: css `
|
|
48
|
+
overflow: hidden !important;
|
|
49
|
+
|
|
50
|
+
${modalCls} {
|
|
51
|
+
display: flex;
|
|
52
|
+
max-width: none;
|
|
53
|
+
transform-origin: 50% 50% !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* rc-dialog puts an unclassed wrapper div between .ant-modal and .ant-modal-content.
|
|
58
|
+
* As a flex item with width:auto it only shrink-wraps its content, so the dialog would
|
|
59
|
+
* not follow the resized width. The focus sentinels matched by the same selector keep
|
|
60
|
+
* their inline width:0, so they are not affected.
|
|
61
|
+
*/
|
|
62
|
+
${modalCls} > div {
|
|
63
|
+
width: 100%;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* the height comes from the modal state - content has to fill it and lay the parts out vertically */
|
|
67
|
+
${modalCls}-content {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
flex: 1;
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
/*
|
|
74
|
+
* Deliberate deviation from the antd 5 default: the content carries no inset at all.
|
|
75
|
+
* The top one belongs to the title (so the whole header area can be grabbed for
|
|
76
|
+
* dragging) and the bottom one to the footer, which keeps both dividers surrounded by
|
|
77
|
+
* padding instead of glued to the text. Horizontally it keeps only the slice the
|
|
78
|
+
* body's scrollbars are drawn in, so they never sit on the dialog edge.
|
|
79
|
+
*/
|
|
80
|
+
padding: 0 ${scrollbarInset}px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
${modalCls}-header,
|
|
84
|
+
${modalCls}-footer {
|
|
85
|
+
flex: 0 0 auto;
|
|
86
|
+
/*
|
|
87
|
+
* When the app configures dividers (Modal headerBorderBottom / footerBorderTop
|
|
88
|
+
* tokens - d2ui does), antd draws them on the header/footer box. Bleed the box back
|
|
89
|
+
* out over the content's scrollbar slice so the lines still span the dialog; the
|
|
90
|
+
* title/buttons keep their own full inset and do not move.
|
|
91
|
+
*/
|
|
92
|
+
margin-inline: -${scrollbarInset}px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* The header contributes no spacing of its own - all of it lives on the drag area inside
|
|
97
|
+
* (see the title style below), so every pixel down to the divider drags the dialog. The gap
|
|
98
|
+
* to the body stays at the antd default (marginXS) and sits below the divider.
|
|
99
|
+
*/
|
|
100
|
+
${modalCls}-header {
|
|
101
|
+
padding: 0;
|
|
102
|
+
margin-bottom: ${token.marginXS}px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/*
|
|
106
|
+
* Mirror of the header: the footer carries the content's bottom inset itself, so the
|
|
107
|
+
* divider has padding below it instead of sitting right on the buttons. The gap above the
|
|
108
|
+
* divider stays at the antd default (marginSM).
|
|
109
|
+
*/
|
|
110
|
+
${modalCls}-footer {
|
|
111
|
+
padding: ${token.padding}px ${contentPaddingInline}px;
|
|
112
|
+
margin-top: ${token.marginSM}px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/*
|
|
116
|
+
* The maximize button reuses antd's .ant-modal-close markup so it looks and behaves like
|
|
117
|
+
* the close button next to it (hover, focus ring, icon size); it only gets parked one
|
|
118
|
+
* button width to the left. antd positions the close button with a two-class selector, so
|
|
119
|
+
* this override has to be at least as specific.
|
|
120
|
+
*/
|
|
121
|
+
${modalCls} .ant-design-draggable-modal-maximize {
|
|
122
|
+
inset-inline-end: ${headerButtons.secondButtonInset}px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/*
|
|
126
|
+
* The only part that shrinks/grows with the dialog; min-height:0 lets it actually shrink
|
|
127
|
+
* in a flex column.
|
|
128
|
+
*
|
|
129
|
+
* Most of the horizontal inset lives here and not on the content on purpose. The body is
|
|
130
|
+
* the scroll container, so anything sticking out of its content box becomes a horizontal
|
|
131
|
+
* scrollbar - and antd's own <Row gutter={n}> does exactly that: it sets
|
|
132
|
+
* margin-inline: -n/2 and is therefore n px wider than its parent (the matching padding
|
|
133
|
+
* on each Col puts the visible content back, so only the scrollbar shows it). With the
|
|
134
|
+
* whole inset on the content the body was flush with its children and every dialog whose
|
|
135
|
+
* form starts with a gutter row had a permanent n/2 px horizontal scrollbar. Owning the
|
|
136
|
+
* padding, the body absorbs those negative margins like a plain antd modal body does.
|
|
137
|
+
*/
|
|
138
|
+
${modalCls}-body {
|
|
139
|
+
flex: 1 1 auto;
|
|
140
|
+
min-height: 0;
|
|
141
|
+
overflow: auto;
|
|
142
|
+
padding-inline: ${bodyPaddingInline}px;
|
|
143
|
+
}
|
|
144
144
|
`,
|
|
145
145
|
/*
|
|
146
146
|
* The bottom inset normally lives on the footer (see above). Dialogs rendered without one -
|
|
@@ -148,38 +148,38 @@ export const useDraggableModalStyles = createStyles(({ token, css, prefixCls })
|
|
|
148
148
|
* their content flush against the bottom edge, so the content takes the inset back. The
|
|
149
149
|
* extra selector level is needed to outweigh the padding-block: 0 above.
|
|
150
150
|
*/
|
|
151
|
-
wrapWithoutFooter: css `
|
|
152
|
-
${modalCls} ${modalCls}-content {
|
|
153
|
-
padding-bottom: ${token.padding}px;
|
|
154
|
-
}
|
|
151
|
+
wrapWithoutFooter: css `
|
|
152
|
+
${modalCls} ${modalCls}-content {
|
|
153
|
+
padding-bottom: ${token.padding}px;
|
|
154
|
+
}
|
|
155
155
|
`,
|
|
156
|
-
title: css `
|
|
157
|
-
cursor: move;
|
|
158
|
-
user-select: none;
|
|
159
|
-
/*
|
|
160
|
-
* Carries the whole header inset - the content's vertical padding and the horizontal
|
|
161
|
-
* padding the header would otherwise have - so the entire header area is a drag handle,
|
|
162
|
-
* right up to the dialog edges and down to the divider.
|
|
163
|
-
*/
|
|
164
|
-
padding: ${token.padding}px ${contentPaddingInline}px;
|
|
156
|
+
title: css `
|
|
157
|
+
cursor: move;
|
|
158
|
+
user-select: none;
|
|
159
|
+
/*
|
|
160
|
+
* Carries the whole header inset - the content's vertical padding and the horizontal
|
|
161
|
+
* padding the header would otherwise have - so the entire header area is a drag handle,
|
|
162
|
+
* right up to the dialog edges and down to the divider.
|
|
163
|
+
*/
|
|
164
|
+
padding: ${token.padding}px ${contentPaddingInline}px;
|
|
165
165
|
`,
|
|
166
|
-
resizeHandle: css `
|
|
167
|
-
position: absolute;
|
|
168
|
-
right: -${handleOverhang}px;
|
|
169
|
-
bottom: -${handleOverhang}px;
|
|
170
|
-
width: ${handleSize}px;
|
|
171
|
-
height: ${handleSize}px;
|
|
172
|
-
cursor: se-resize;
|
|
166
|
+
resizeHandle: css `
|
|
167
|
+
position: absolute;
|
|
168
|
+
right: -${handleOverhang}px;
|
|
169
|
+
bottom: -${handleOverhang}px;
|
|
170
|
+
width: ${handleSize}px;
|
|
171
|
+
height: ${handleSize}px;
|
|
172
|
+
cursor: se-resize;
|
|
173
173
|
`,
|
|
174
|
-
resizeHandleInner: css `
|
|
175
|
-
position: absolute;
|
|
176
|
-
right: ${handleOverhang + token.paddingXXS}px;
|
|
177
|
-
bottom: ${handleOverhang + token.paddingXXS}px;
|
|
178
|
-
width: ${markerSize}px;
|
|
179
|
-
height: ${markerSize}px;
|
|
180
|
-
border: ${token.lineWidthBold}px ${token.lineType} ${token.colorTextTertiary};
|
|
181
|
-
border-top: 0;
|
|
182
|
-
border-left: 0;
|
|
174
|
+
resizeHandleInner: css `
|
|
175
|
+
position: absolute;
|
|
176
|
+
right: ${handleOverhang + token.paddingXXS}px;
|
|
177
|
+
bottom: ${handleOverhang + token.paddingXXS}px;
|
|
178
|
+
width: ${markerSize}px;
|
|
179
|
+
height: ${markerSize}px;
|
|
180
|
+
border: ${token.lineWidthBold}px ${token.lineType} ${token.colorTextTertiary};
|
|
181
|
+
border-top: 0;
|
|
182
|
+
border-left: 0;
|
|
183
183
|
`,
|
|
184
184
|
};
|
|
185
185
|
});
|
|
@@ -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;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,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;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAC,CAAC,EAAC,KAAK,EAAE,GAAG,EAA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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\";\n\n/** the antd tokens the header-button geometry is derived from */\ninterface HeaderButtonToken {\n controlHeight: number\n padding: number\n marginXXS: number\n lineHeightHeading5: number\n fontSizeHeading5: number\n}\n\n/**\n * Geometry of the buttons in the top-right corner of the header. Mirrors antd's own close-button\n * math (prepareToken in antd/es/modal/style) so our maximize button lines up with antd's close\n * button, and so the title knows how much room to leave for them.\n */\nexport const headerButtonGeometry = (token: HeaderButtonToken) => {\n const size = token.controlHeight;\n const headerHeight = token.lineHeightHeading5 * token.fontSizeHeading5 + token.padding * 2;\n const inset = (headerHeight - size) / 2;\n const gap = token.marginXXS;\n return {\n /** inset-inline-end of the button sitting left of the close button */\n secondButtonInset: inset + size + gap,\n /** horizontal space the title has to leave free so `count` buttons do not cover it */\n reserve: (count: number): number => count <= 0 ? 0 : inset + count * size + (count - 1) * gap,\n }\n};\n\n/**\n * Styles of the resizable/draggable modal.\n *\n * Only what dragging + resizing actually needs is defined here (flex layout so the body can\n * grow/scroll, the drag cursor on the title, the resize handle). Everything that antd 5 styles\n * through its own Modal tokens - header/footer spacing, title typography - is deliberately NOT\n * overridden, so the dialog looks like a plain antd 5 Modal. The exception is the content inset,\n * see below.\n */\nexport const useDraggableModalStyles = createStyles(({token, css, prefixCls}) => {\n const modalCls = `.${prefixCls}-modal`;\n\n // antd's default horizontal contentPadding, mirrored here because the parts carry it themselves\n const contentPaddingInline = token.paddingContentHorizontalLG;\n\n /*\n * That inset is split between the content and the body. The body is the scroll container, and a\n * scrollbar is always drawn at its border edge - so the content keeps the outer slice to push the\n * body's scrollbars off the dialog edge, and the body keeps the rest as the gap between a\n * scrollbar and the text (which is also what absorbs negative margins, see the body rule).\n */\n const scrollbarInset = token.paddingXS;\n const bodyPaddingInline = contentPaddingInline - scrollbarInset;\n\n const headerButtons = headerButtonGeometry(token);\n\n // the grab area reaches slightly outside the content so it does not sit on top of the footer buttons\n const handleSize = 44;\n const handleOverhang = 10;\n // the visible corner marker inside the grab area\n const markerSize = 12;\n\n return {\n wrap: css`\n overflow: hidden !important;\n\n ${modalCls} {\n display: flex;\n max-width: none;\n transform-origin: 50% 50% !important;\n }\n\n /*\n * rc-dialog puts an unclassed wrapper div between .ant-modal and .ant-modal-content.\n * As a flex item with width:auto it only shrink-wraps its content, so the dialog would\n * not follow the resized width. The focus sentinels matched by the same selector keep\n * their inline width:0, so they are not affected.\n */\n ${modalCls} > div {\n width: 100%;\n }\n\n /* the height comes from the modal state - content has to fill it and lay the parts out vertically */\n ${modalCls}-content {\n display: flex;\n flex-direction: column;\n flex: 1;\n width: 100%;\n height: 100%;\n /*\n * Deliberate deviation from the antd 5 default: the content carries no inset at all.\n * The top one belongs to the title (so the whole header area can be grabbed for\n * dragging) and the bottom one to the footer, which keeps both dividers surrounded by\n * padding instead of glued to the text. Horizontally it keeps only the slice the\n * body's scrollbars are drawn in, so they never sit on the dialog edge.\n */\n padding: 0 ${scrollbarInset}px;\n }\n\n ${modalCls}-header,\n ${modalCls}-footer {\n flex: 0 0 auto;\n /*\n * When the app configures dividers (Modal headerBorderBottom / footerBorderTop\n * tokens - d2ui does), antd draws them on the header/footer box. Bleed the box back\n * out over the content's scrollbar slice so the lines still span the dialog; the\n * title/buttons keep their own full inset and do not move.\n */\n margin-inline: -${scrollbarInset}px;\n }\n\n /*\n * The header contributes no spacing of its own - all of it lives on the drag area inside\n * (see the title style below), so every pixel down to the divider drags the dialog. The gap\n * to the body stays at the antd default (marginXS) and sits below the divider.\n */\n ${modalCls}-header {\n padding: 0;\n margin-bottom: ${token.marginXS}px;\n }\n\n /*\n * Mirror of the header: the footer carries the content's bottom inset itself, so the\n * divider has padding below it instead of sitting right on the buttons. The gap above the\n * divider stays at the antd default (marginSM).\n */\n ${modalCls}-footer {\n padding: ${token.padding}px ${contentPaddingInline}px;\n margin-top: ${token.marginSM}px;\n }\n\n /*\n * The maximize button reuses antd's .ant-modal-close markup so it looks and behaves like\n * the close button next to it (hover, focus ring, icon size); it only gets parked one\n * button width to the left. antd positions the close button with a two-class selector, so\n * this override has to be at least as specific.\n */\n ${modalCls} .ant-design-draggable-modal-maximize {\n inset-inline-end: ${headerButtons.secondButtonInset}px;\n }\n\n /*\n * The only part that shrinks/grows with the dialog; min-height:0 lets it actually shrink\n * in a flex column.\n *\n * Most of the horizontal inset lives here and not on the content on purpose. The body is\n * the scroll container, so anything sticking out of its content box becomes a horizontal\n * scrollbar - and antd's own <Row gutter={n}> does exactly that: it sets\n * margin-inline: -n/2 and is therefore n px wider than its parent (the matching padding\n * on each Col puts the visible content back, so only the scrollbar shows it). With the\n * whole inset on the content the body was flush with its children and every dialog whose\n * form starts with a gutter row had a permanent n/2 px horizontal scrollbar. Owning the\n * padding, the body absorbs those negative margins like a plain antd modal body does.\n */\n ${modalCls}-body {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n padding-inline: ${bodyPaddingInline}px;\n }\n `,\n /*\n * The bottom inset normally lives on the footer (see above). Dialogs rendered without one -\n * every NO_BUTTONS ModalDialog, and anything passing footer={null} - would otherwise have\n * their content flush against the bottom edge, so the content takes the inset back. The\n * extra selector level is needed to outweigh the padding-block: 0 above.\n */\n wrapWithoutFooter: css`\n ${modalCls} ${modalCls}-content {\n padding-bottom: ${token.padding}px;\n }\n `,\n title: css`\n cursor: move;\n user-select: none;\n /*\n * Carries the whole header inset - the content's vertical padding and the horizontal\n * padding the header would otherwise have - so the entire header area is a drag handle,\n * right up to the dialog edges and down to the divider.\n */\n padding: ${token.padding}px ${contentPaddingInline}px;\n `,\n resizeHandle: css`\n position: absolute;\n right: -${handleOverhang}px;\n bottom: -${handleOverhang}px;\n width: ${handleSize}px;\n height: ${handleSize}px;\n cursor: se-resize;\n `,\n resizeHandleInner: css`\n position: absolute;\n right: ${handleOverhang + token.paddingXXS}px;\n bottom: ${handleOverhang + token.paddingXXS}px;\n width: ${markerSize}px;\n height: ${markerSize}px;\n border: ${token.lineWidthBold}px ${token.lineType} ${token.colorTextTertiary};\n border-top: 0;\n border-left: 0;\n `,\n };\n});\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,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;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAC,CAAC,EAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAC,EAAE,EAAE;IAC5E,MAAM,QAAQ,GAAG,IAAI,SAAS,QAAQ,CAAC;IAEvC,gGAAgG;IAChG,M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AK,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":"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/\n\nimport * as React from 'react'\n\nexport interface ResizeHandleProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {\n /** class of the visible corner marker inside the grab area */\n innerClassName?: string\n}\n\nexport const ResizeHandle = ({className, innerClassName, ...props}: ResizeHandleProps): React.ReactElement => (\n // the legacy class names are kept as styling hooks for the app (e.g. .compact-modal)\n <div className={`ant-design-draggable-modal-resize-handle ${className ?? ''}`} {...props}>\n <div className={`ant-design-draggable-modal-resize-handle-inner ${innerClassName ?? ''}`}/>\n </div>\n)\n"]}
|
|
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"]}
|
|
@@ -50,8 +50,8 @@ export interface ModalDialogProps extends DraggableModalProps {
|
|
|
50
50
|
/**
|
|
51
51
|
* Dialog with a predefined, localized button set (see {@link ModalDialogMode}).
|
|
52
52
|
*
|
|
53
|
-
* As a component it renders a draggable (by the title)
|
|
54
|
-
* `
|
|
53
|
+
* As a component it renders a draggable (by the title) and resizable (bottom-right handle) antd `Modal`, with
|
|
54
|
+
* `maximizable` also with a maximize / restore button, that is kept inside the window and destroyed when hidden, unless `destroyOnHidden={false}` keeps its content
|
|
55
55
|
* mounted. Every opening brings it on top of the modals opened before. It must be rendered inside a
|
|
56
56
|
* `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.
|
|
57
57
|
* Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static
|
|
@@ -39,8 +39,8 @@ export var ModalDialogMode;
|
|
|
39
39
|
/**
|
|
40
40
|
* Dialog with a predefined, localized button set (see {@link ModalDialogMode}).
|
|
41
41
|
*
|
|
42
|
-
* As a component it renders a draggable (by the title)
|
|
43
|
-
* `
|
|
42
|
+
* As a component it renders a draggable (by the title) and resizable (bottom-right handle) antd `Modal`, with
|
|
43
|
+
* `maximizable` also with a maximize / restore button, that is kept inside the window and destroyed when hidden, unless `destroyOnHidden={false}` keeps its content
|
|
44
44
|
* mounted. Every opening brings it on top of the modals opened before. It must be rendered inside a
|
|
45
45
|
* `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.
|
|
46
46
|
* Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modalDialog.js","sourceRoot":"","sources":["../../../../components/modal/modalDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AA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\";\r\nimport {ModalFuncProps} from \"antd/es/modal\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {DraggableModal, DraggableModalProps} from \"d2coreui/components/modal/impl\";\r\nimport {HookAPI} from \"antd/es/modal/useModal\";\r\n\r\n/**\r\n * Button set of a {@link ModalDialog}. Button labels are localized and can be overridden with `okText` /\r\n * `cancelText` (and `denyText`).\r\n */\r\nexport const enum ModalDialogMode {\r\n /**\r\n * No footer, unless a `footer` is given explicitly. Honored only by the component; the static methods show\r\n * antd's default buttons.\r\n */\r\n NO_BUTTONS = \"NO_BUTTONS\",\r\n /** \"OK\" and \"Cancel\" buttons. */\r\n OK_CANCEL = \"OK_CANCEL\",\r\n /** \"Yes\" and \"No\" buttons; \"No\" acts as cancel. */\r\n YES_NO = \"YES_NO\",\r\n /**\r\n * \"Yes\", \"No\" and \"Cancel\" buttons: \"Yes\" calls `onOk`, \"No\" calls `onDeny` and \"Cancel\" `onCancel`.\r\n * Supported only by the static methods; the component renders antd's default buttons in this mode.\r\n */\r\n YES_NO_CANCEL = \"YES_NO_CANCEL\",\r\n /** Only an \"OK\" button (see the note at {@link ModalDialog} about the component). */\r\n OK = \"OK\",\r\n}\r\n\r\n/**\r\n * Options of the static {@link ModalDialog} methods: antd `ModalFuncProps` plus the button mode.\r\n * `autoFocusButton` defaults to `\"ok\"`.\r\n */\r\nexport interface ModalDialogFuncProps extends ModalFuncProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n /** Label of the \"No\" button in {@link ModalDialogMode.YES_NO_CANCEL} mode; defaults to localized \"No\". */\r\n denyText?: string\r\n /**\r\n * Called with the click event when the \"No\" button is clicked in {@link ModalDialogMode.YES_NO_CANCEL} mode;\r\n * the dialog is closed afterwards.\r\n */\r\n onDeny?: (...args: any[]) => any;\r\n}\r\n\r\n/**\r\n * Props of the {@link ModalDialog} component: antd `ModalProps` (except `width`) plus `initialWidth`,\r\n * `initialHeight`, `maximizable` and `onResize` of the draggable modal, and the button mode.\r\n */\r\nexport interface ModalDialogProps extends DraggableModalProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n}\r\n\r\n/**\r\n * Dialog with a predefined, localized button set (see {@link ModalDialogMode}).\r\n *\r\n * As a component it renders a draggable (by the title), resizable (bottom-right handle) and maximizable antd\r\n * `Modal` that is kept inside the window and destroyed when hidden, unless `destroyOnHidden={false}` keeps its content\r\n * mounted. Every opening brings it on top of the modals opened before. It must be rendered inside a\r\n * `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.\r\n * Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static\r\n * methods hide it.\r\n *\r\n * The static methods open imperative antd dialogs; register the app's modal API once with\r\n * {@link ModalDialog.setModalInstance}. They modify the passed `okButtonProps` / `cancelButtonProps` objects and\r\n * replace their `style`.\r\n *\r\n * @example\r\n * <DraggableModalProvider>\r\n * <ModalDialog mode={ModalDialogMode.OK_CANCEL} open={open} title=\"Rename\"\r\n * initialWidth={480} initialHeight={240}\r\n * onOk={save} onCancel={() => setOpen(false)}>\r\n * <Input value={name} onChange={e => setName(e.target.value)}/>\r\n * </ModalDialog>\r\n * </DraggableModalProvider>\r\n *\r\n * @example\r\n * ModalDialog.confirm({\r\n * mode: ModalDialogMode.YES_NO_CANCEL,\r\n * title: \"Save changes?\",\r\n * onOk: save,\r\n * onDeny: discard,\r\n * });\r\n */\r\nexport class ModalDialog extends React.Component<ModalDialogProps, {}> {\r\n private static modalStatic: HookAPI;\r\n\r\n constructor(props: Readonly<ModalDialogProps>) {\r\n super(props);\r\n }\r\n\r\n /**\r\n * Registers the antd `modal` API from `App.useApp()` for the static methods, so that their dialogs inherit the app's\r\n * theme, locale and context. Until it is called they fall back to antd's static `Modal` functions.\r\n */\r\n public static setModalInstance(instance: HookAPI) {\r\n ModalDialog.modalStatic = instance;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog (antd `confirm`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static confirm(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an error dialog (antd `error`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static error(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.error : Modal.error;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog like {@link ModalDialog.confirm} with a danger OK button. The button is marked as\r\n * danger only when `props.okButtonProps` is passed (an empty object is enough).\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static delete(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n if (props.okButtonProps) {\r\n props.okButtonProps.danger = true;\r\n }\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a success dialog (antd `success`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static success(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.success : Modal.success;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an information dialog (antd `info`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static info(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.info : Modal.info;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n render() {\r\n const modalDialogProperties = ModalDialog.getModalProperties(this.props);\r\n return (\r\n <DraggableModal {...modalDialogProperties}>\r\n {this.props.children}\r\n </DraggableModal>);\r\n }\r\n\r\n private static getModalProperties(props: ModalDialogProps) {\r\n const {mode, ...rest} = props;\r\n if (mode === ModalDialogMode.NO_BUTTONS) {\r\n if (rest.footer === undefined) {\r\n rest.footer = null;\r\n }\r\n } else {\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelText = props.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = props.okText ?? i18n(\"Yes\");\r\n rest.cancelText = props.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = undefined;\r\n break;\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n return rest;\r\n }\r\n\r\n private static getModalFuncProperties(props: ModalDialogFuncProps, performClose: () => void) {\r\n const {mode, denyText, onDeny, ...rest} = props;\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"OK\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.YES_NO_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = (<React.Fragment>\r\n <Button onClick={(e) => {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n e.nativeEvent.stopImmediatePropagation();\r\n onDeny?.(e);\r\n performClose();\r\n }}>{denyText ?? i18n(\"No\")}</Button>\r\n <Button>{rest.cancelText ?? i18n(\"Cancel\")}</Button>\r\n </React.Fragment>\r\n );\r\n if (!rest.cancelButtonProps) {\r\n rest.cancelButtonProps = {};\r\n }\r\n rest.cancelButtonProps.type = \"text\";\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = {style: {display: \"none\"}};\r\n }\r\n if (rest.autoFocusButton === undefined) {\r\n rest.autoFocusButton = \"ok\";\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n\r\n if (mode !== ModalDialogMode.OK) {\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n\r\n if (mode === ModalDialogMode.YES_NO_CANCEL) {\r\n if (rest.cancelButtonProps && rest.cancelButtonProps.style) {\r\n rest.cancelButtonProps.style.padding = 0;\r\n rest.cancelButtonProps.style.marginTop = -1;\r\n rest.cancelButtonProps.style.cursor = \"default\";\r\n rest.cancelButtonProps.style.background = \"transparent\";\r\n }\r\n }\r\n return rest;\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"file":"modalDialog.js","sourceRoot":"","sources":["../../../../components/modal/modalDialog.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,MAAM,CAAC;AAEnC,OAAO,IAAI,MAAM,kBAAkB,CAAC;AACpC,OAAO,EAAC,cAAc,EAAsB,MAAM,gCAAgC,CAAC;AAGnF;;;GAGG;AACH,MAAM,CAAN,IAAkB,eAiBjB;AAjBD,WAAkB,eAAe;IAC7B;;;OAGG;IACH,4CAAyB,CAAA;IACzB,iCAAiC;IACjC,0CAAuB,CAAA;IACvB,mDAAmD;IACnD,oCAAiB,CAAA;IACjB;;;OAGG;IACH,kDAA+B,CAAA;IAC/B,qFAAqF;IACrF,4BAAS,CAAA;AACb,CAAC,EAjBiB,eAAe,KAAf,eAAe,QAiBhC;AA2BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,SAA+B;IAGlE,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,gBAAgB,CAAC,QAAiB;QAC5C,WAAW,CAAC,WAAW,GAAG,QAAQ,CAAC;IACvC,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,OAAO,CAAC,KAA2B;QAC7C,IAAI,aAAmF,CAAC;QACxF,MAAM,qBAAqB,GAAG,WAAW,CAAC,sBAAsB,CAAC,KAAK,EAAE,GAAG,EAAE;YACzE,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAA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CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;gBACzC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;gBAC5C,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;gBAChD,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,GAAG,aAAa,CAAC;YAC5D,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import React from \"react\";\r\nimport {Button, Modal} from \"antd\";\r\nimport {ModalFuncProps} from \"antd/es/modal\";\r\nimport i18n from \"d2core/i18n/i18n\";\r\nimport {DraggableModal, DraggableModalProps} from \"d2coreui/components/modal/impl\";\r\nimport {HookAPI} from \"antd/es/modal/useModal\";\r\n\r\n/**\r\n * Button set of a {@link ModalDialog}. Button labels are localized and can be overridden with `okText` /\r\n * `cancelText` (and `denyText`).\r\n */\r\nexport const enum ModalDialogMode {\r\n /**\r\n * No footer, unless a `footer` is given explicitly. Honored only by the component; the static methods show\r\n * antd's default buttons.\r\n */\r\n NO_BUTTONS = \"NO_BUTTONS\",\r\n /** \"OK\" and \"Cancel\" buttons. */\r\n OK_CANCEL = \"OK_CANCEL\",\r\n /** \"Yes\" and \"No\" buttons; \"No\" acts as cancel. */\r\n YES_NO = \"YES_NO\",\r\n /**\r\n * \"Yes\", \"No\" and \"Cancel\" buttons: \"Yes\" calls `onOk`, \"No\" calls `onDeny` and \"Cancel\" `onCancel`.\r\n * Supported only by the static methods; the component renders antd's default buttons in this mode.\r\n */\r\n YES_NO_CANCEL = \"YES_NO_CANCEL\",\r\n /** Only an \"OK\" button (see the note at {@link ModalDialog} about the component). */\r\n OK = \"OK\",\r\n}\r\n\r\n/**\r\n * Options of the static {@link ModalDialog} methods: antd `ModalFuncProps` plus the button mode.\r\n * `autoFocusButton` defaults to `\"ok\"`.\r\n */\r\nexport interface ModalDialogFuncProps extends ModalFuncProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n /** Label of the \"No\" button in {@link ModalDialogMode.YES_NO_CANCEL} mode; defaults to localized \"No\". */\r\n denyText?: string\r\n /**\r\n * Called with the click event when the \"No\" button is clicked in {@link ModalDialogMode.YES_NO_CANCEL} mode;\r\n * the dialog is closed afterwards.\r\n */\r\n onDeny?: (...args: any[]) => any;\r\n}\r\n\r\n/**\r\n * Props of the {@link ModalDialog} component: antd `ModalProps` (except `width`) plus `initialWidth`,\r\n * `initialHeight`, `maximizable` and `onResize` of the draggable modal, and the button mode.\r\n */\r\nexport interface ModalDialogProps extends DraggableModalProps {\r\n /** Button set of the dialog. */\r\n mode: ModalDialogMode\r\n}\r\n\r\n/**\r\n * Dialog with a predefined, localized button set (see {@link ModalDialogMode}).\r\n *\r\n * As a component it renders a draggable (by the title) and resizable (bottom-right handle) antd `Modal`, with\r\n * `maximizable` also with a maximize / restore button, that is kept inside the window and destroyed when hidden, unless `destroyOnHidden={false}` keeps its content\r\n * mounted. Every opening brings it on top of the modals opened before. It must be rendered inside a\r\n * `DraggableModalProvider` (`d2coreui/components/modal/draggableModalProvider`), otherwise it throws.\r\n * Note that in {@link ModalDialogMode.OK} mode the component still renders the Cancel button; only the static\r\n * methods hide it.\r\n *\r\n * The static methods open imperative antd dialogs; register the app's modal API once with\r\n * {@link ModalDialog.setModalInstance}. They modify the passed `okButtonProps` / `cancelButtonProps` objects and\r\n * replace their `style`.\r\n *\r\n * @example\r\n * <DraggableModalProvider>\r\n * <ModalDialog mode={ModalDialogMode.OK_CANCEL} open={open} title=\"Rename\"\r\n * initialWidth={480} initialHeight={240}\r\n * onOk={save} onCancel={() => setOpen(false)}>\r\n * <Input value={name} onChange={e => setName(e.target.value)}/>\r\n * </ModalDialog>\r\n * </DraggableModalProvider>\r\n *\r\n * @example\r\n * ModalDialog.confirm({\r\n * mode: ModalDialogMode.YES_NO_CANCEL,\r\n * title: \"Save changes?\",\r\n * onOk: save,\r\n * onDeny: discard,\r\n * });\r\n */\r\nexport class ModalDialog extends React.Component<ModalDialogProps, {}> {\r\n private static modalStatic: HookAPI;\r\n\r\n constructor(props: Readonly<ModalDialogProps>) {\r\n super(props);\r\n }\r\n\r\n /**\r\n * Registers the antd `modal` API from `App.useApp()` for the static methods, so that their dialogs inherit the app's\r\n * theme, locale and context. Until it is called they fall back to antd's static `Modal` functions.\r\n */\r\n public static setModalInstance(instance: HookAPI) {\r\n ModalDialog.modalStatic = instance;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog (antd `confirm`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static confirm(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an error dialog (antd `error`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static error(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.error : Modal.error;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a confirmation dialog like {@link ModalDialog.confirm} with a danger OK button. The button is marked as\r\n * danger only when `props.okButtonProps` is passed (an empty object is enough).\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static delete(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.confirm : Modal.confirm;\r\n if (props.okButtonProps) {\r\n props.okButtonProps.danger = true;\r\n }\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens a success dialog (antd `success`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static success(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.success : Modal.success;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n /**\r\n * Opens an information dialog (antd `info`) with the buttons of `props.mode`.\r\n * @returns a handle to close or update the dialog.\r\n */\r\n public static info(props: ModalDialogFuncProps): { destroy: () => void; update: (newConfig: ModalFuncProps) => void } {\r\n let dialogHandler: { destroy: () => void; update: (newConfig: ModalFuncProps) => void };\r\n const modalDialogProperties = ModalDialog.getModalFuncProperties(props, () => {\r\n dialogHandler?.destroy();\r\n });\r\n const method = ModalDialog.modalStatic ? ModalDialog.modalStatic.info : Modal.info;\r\n dialogHandler = method(modalDialogProperties);\r\n return dialogHandler;\r\n }\r\n\r\n render() {\r\n const modalDialogProperties = ModalDialog.getModalProperties(this.props);\r\n return (\r\n <DraggableModal {...modalDialogProperties}>\r\n {this.props.children}\r\n </DraggableModal>);\r\n }\r\n\r\n private static getModalProperties(props: ModalDialogProps) {\r\n const {mode, ...rest} = props;\r\n if (mode === ModalDialogMode.NO_BUTTONS) {\r\n if (rest.footer === undefined) {\r\n rest.footer = null;\r\n }\r\n } else {\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelText = props.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = props.okText ?? i18n(\"Yes\");\r\n rest.cancelText = props.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = undefined;\r\n break;\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n return rest;\r\n }\r\n\r\n private static getModalFuncProperties(props: ModalDialogFuncProps, performClose: () => void) {\r\n const {mode, denyText, onDeny, ...rest} = props;\r\n switch (mode) {\r\n case ModalDialogMode.OK_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"OK\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"Cancel\");\r\n break;\r\n case ModalDialogMode.YES_NO:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = rest.cancelText ?? i18n(\"No\");\r\n break;\r\n case ModalDialogMode.YES_NO_CANCEL:\r\n rest.okText = rest.okText ?? i18n(\"Yes\");\r\n rest.cancelText = (<React.Fragment>\r\n <Button onClick={(e) => {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n e.nativeEvent.stopImmediatePropagation();\r\n onDeny?.(e);\r\n performClose();\r\n }}>{denyText ?? i18n(\"No\")}</Button>\r\n <Button>{rest.cancelText ?? i18n(\"Cancel\")}</Button>\r\n </React.Fragment>\r\n );\r\n if (!rest.cancelButtonProps) {\r\n rest.cancelButtonProps = {};\r\n }\r\n rest.cancelButtonProps.type = \"text\";\r\n break;\r\n case ModalDialogMode.OK:\r\n rest.okText = props.okText ?? i18n(\"OK\");\r\n rest.cancelButtonProps = {style: {display: \"none\"}};\r\n }\r\n if (rest.autoFocusButton === undefined) {\r\n rest.autoFocusButton = \"ok\";\r\n }\r\n\r\n rest.okButtonProps = Object.assign(rest.okButtonProps !== undefined ? rest.okButtonProps : {}, {style: {marginRight: 8}});\r\n\r\n if (mode !== ModalDialogMode.OK) {\r\n rest.cancelButtonProps = Object.assign(rest.cancelButtonProps !== undefined ? rest.cancelButtonProps : {}, {style: {float: \"right\"}});\r\n }\r\n\r\n if (mode === ModalDialogMode.YES_NO_CANCEL) {\r\n if (rest.cancelButtonProps && rest.cancelButtonProps.style) {\r\n rest.cancelButtonProps.style.padding = 0;\r\n rest.cancelButtonProps.style.marginTop = -1;\r\n rest.cancelButtonProps.style.cursor = \"default\";\r\n rest.cancelButtonProps.style.background = \"transparent\";\r\n }\r\n }\r\n return rest;\r\n }\r\n}"]}
|