d2coreui 23.0.54 → 23.0.56
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 +65 -40
- package/README.md +154 -154
- package/components/date/dateRangeInput.d.ts +5 -0
- package/components/date/dateRangeInput.js +20 -11
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateRangeInputAdvancedPanel.js +15 -4
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
- package/components/date/dateRangeInputConfirm.js +16 -13
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +12 -0
- package/components/date/dateTimeInput.js +72 -30
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/grid/dataGrid.js +3 -3
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/export/worker/pdfExport.js.map +1 -1
- package/components/grid/extendedDataGrid.js +8 -8
- package/components/grid/extendedDataGrid.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/style/withCss.d.ts +9 -4
- package/components/style/withCss.js +7 -3
- package/components/style/withCss.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,EAAE,SAAS,EAAC,EAAE,EAAE;IAC5E,MAAM,QAAQ,GAAG,IAAI,SAAS,QAAQ,CAAC;IAEvC,gGAAgG;IAChG,MAAM,oBAAoB,GAAG,KAAK,CAAC,0BAA0B,CAAC;IAE9D;;;;;OAKG;IACH,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,CAAC;IACvC,MAAM,iBAAiB,GAAG,oBAAoB,GAAG,cAAc,CAAC;IAEhE,MAAM,aAAa,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAElD,qGAAqG;IACrG,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,MAAM,cAAc,GAAG,EAAE,CAAC;IAC1B,iDAAiD;IACjD,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,OAAO;QACH,IAAI,EAAE,GAAG,CAAA;;;cAGH,QAAQ;;;;;;;;;;;;cAYR,QAAQ;;;;;cAKR,QAAQ;;;;;;;;;;;;;6BAaO,cAAc;;;cAG7B,QAAQ;cACR,QAAQ;;;;;;;;kCAQY,cAAc;;;;;;;;cAQlC,QAAQ;;iCAEW,KAAK,CAAC,QAAQ;;;;;;;;cAQjC,QAAQ;2BACK,KAAK,CAAC,OAAO,MAAM,oBAAoB;8BACpC,KAAK,CAAC,QAAQ;;;;;;;;;cAS9B,QAAQ;oCACc,aAAa,CAAC,iBAAiB;;;;;;;;;;;;;;;;cAgBrD,QAAQ;;;;kCAIY,iBAAiB;;SAE1C;QACD;;;;;WAKG;QACH,iBAAiB,EAAE,GAAG,CAAA;cAChB,QAAQ,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
|
+
{"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,MAAM,oBAAoB,GAAG,KAAK,CAAC,0BAA0B,CAAC;IAE9D;;;;;OAKG;IACH,MAAM,cAAc,GAAG,KAAK,CAAC,SAAS,CAAC;IACvC,MAAM,iBAAiB,GAAG,oBAAoB,GAAG,cAAc,CAAC;IAEhE,MAAM,aAAa,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAElD,qGAAqG;IACrG,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,MAAM,cAAc,GAAG,EAAE,CAAC;IAC1B,iDAAiD;IACjD,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,OAAO;QACH,IAAI,EAAE,GAAG,CAAA;;;cAGH,QAAQ;;;;;;;;;;;;cAYR,QAAQ;;;;;cAKR,QAAQ;;;;;;;;;;;;;6BAaO,cAAc;;;cAG7B,QAAQ;cACR,QAAQ;;;;;;;;kCAQY,cAAc;;;;;;;;cAQlC,QAAQ;;iCAEW,KAAK,CAAC,QAAQ;;;;;;;;cAQjC,QAAQ;2BACK,KAAK,CAAC,OAAO,MAAM,oBAAoB;8BACpC,KAAK,CAAC,QAAQ;;;;;;;;;cAS9B,QAAQ;oCACc,aAAa,CAAC,iBAAiB;;;;;;;;;;;;;;;;cAgBrD,QAAQ;;;;kCAIY,iBAAiB;;SAE1C;QACD;;;;;WAKG;QACH,iBAAiB,EAAE,GAAG,CAAA;cAChB,QAAQ,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\";\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 +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/\
|
|
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,9 +1,13 @@
|
|
|
1
1
|
import { BaseReturnType } from 'antd-style';
|
|
2
2
|
import { ReturnStyles } from "antd-style/lib/factories/createStyles/types";
|
|
3
|
-
import { SizeType } from "antd/
|
|
3
|
+
import { SizeType } from "antd/es/config-provider/SizeContext";
|
|
4
4
|
import { Variant } from "antd/es/config-provider";
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Render function of {@link WithCss}; receives the result of `useStyles` (`styles`, `cx`, `theme`, ...) and the
|
|
7
|
+
* resolved `size` and `variant` - read them from here, not from the component's own props, which may leave them to
|
|
8
|
+
* the antd context.
|
|
9
|
+
*/
|
|
10
|
+
type WithCssChildren<T extends BaseReturnType> = (css: ReturnStyles<T>, resolved: WithCssInjectedProps) => any;
|
|
7
11
|
/** Props that {@link WithCss} resolves before passing them to `useStyles`. */
|
|
8
12
|
type WithCssOwnProps = {
|
|
9
13
|
size?: SizeType;
|
|
@@ -28,7 +32,8 @@ interface WithCssProperties<T extends BaseReturnType, P extends WithCssOwnProps>
|
|
|
28
32
|
}
|
|
29
33
|
/**
|
|
30
34
|
* Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.
|
|
31
|
-
* `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then
|
|
35
|
+
* `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then the `ConfigProvider`
|
|
36
|
+
* `componentSize`, then `'middle'`; `variant` as
|
|
32
37
|
* `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.
|
|
33
38
|
*/
|
|
34
39
|
export default function WithCss<T extends BaseReturnType, P extends WithCssOwnProps = {}>({ useStyles, children, props }: WithCssProperties<T, P>): any;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
2
|
import { SpaceCompactItemContext } from "antd/es/space/Compact";
|
|
3
|
+
import SizeContext from "antd/es/config-provider/SizeContext";
|
|
3
4
|
import { ConfigContext } from "antd/es/config-provider";
|
|
4
5
|
/**
|
|
5
6
|
* Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.
|
|
6
|
-
* `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then
|
|
7
|
+
* `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then the `ConfigProvider`
|
|
8
|
+
* `componentSize`, then `'middle'`; `variant` as
|
|
7
9
|
* `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.
|
|
8
10
|
*/
|
|
9
11
|
export default function WithCss({ useStyles, children, props }) {
|
|
10
12
|
var _a, _b;
|
|
11
13
|
const contextSize = useContext(SpaceCompactItemContext);
|
|
14
|
+
const configSize = useContext(SizeContext);
|
|
12
15
|
const { variant: configVariant } = useContext(ConfigContext);
|
|
13
|
-
|
|
16
|
+
// same precedence as antd's internal useSize: own prop > Space.Compact > ConfigProvider > middle
|
|
17
|
+
const mergedSize = (props === null || props === void 0 ? void 0 : props.size) || (contextSize === null || contextSize === void 0 ? void 0 : contextSize.compactSize) || configSize || 'middle';
|
|
14
18
|
// same precedence as antd's internal useVariant: own prop > ConfigProvider > outlined
|
|
15
19
|
const mergedVariant = (_b = (_a = props === null || props === void 0 ? void 0 : props.variant) !== null && _a !== void 0 ? _a : configVariant) !== null && _b !== void 0 ? _b : 'outlined';
|
|
16
20
|
const css = useStyles(Object.assign(Object.assign({}, props), { size: mergedSize, variant: mergedVariant }));
|
|
17
|
-
return children(css);
|
|
21
|
+
return children(css, { size: mergedSize, variant: mergedVariant });
|
|
18
22
|
}
|
|
19
23
|
;
|
|
20
24
|
//# sourceMappingURL=withCss.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withCss.js","sourceRoot":"","sources":["../../../../components/style/withCss.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"withCss.js","sourceRoot":"","sources":["../../../../components/style/withCss.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,OAAO,CAAC;AACjC,OAAO,EAAC,uBAAuB,EAAC,MAAM,uBAAuB,CAAC;AAC9D,OAAO,WAAuB,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAC,aAAa,EAAU,MAAM,yBAAyB,CAAC;AA4B/D;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAA4D,EAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAA0B;;IAC5I,MAAM,WAAW,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;IACxD,MAAM,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,EAAC,OAAO,EAAE,aAAa,EAAC,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3D,iGAAiG;IACjG,MAAM,UAAU,GAA0B,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAA,IAAI,UAAU,IAAI,QAAQ,CAAC;IAC5G,sFAAsF;IACtF,MAAM,aAAa,GAAY,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,mCAAI,aAAa,mCAAI,UAAU,CAAC;IAC7E,MAAM,GAAG,GAAG,SAAS,iCAAM,KAAW,KAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,IAAE,CAAC;IACnF,OAAO,QAAQ,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAC,CAAC,CAAC;AACrE,CAAC;AAAA,CAAC","sourcesContent":["import {BaseReturnType} from 'antd-style';\r\nimport {ReturnStyles} from \"antd-style/lib/factories/createStyles/types\";\r\nimport {useContext} from \"react\";\r\nimport {SpaceCompactItemContext} from \"antd/es/space/Compact\";\r\nimport SizeContext, {SizeType} from \"antd/es/config-provider/SizeContext\";\r\nimport {ConfigContext, Variant} from \"antd/es/config-provider\";\r\n\r\n/**\r\n * Render function of {@link WithCss}; receives the result of `useStyles` (`styles`, `cx`, `theme`, ...) and the\r\n * resolved `size` and `variant` - read them from here, not from the component's own props, which may leave them to\r\n * the antd context.\r\n */\r\ntype WithCssChildren<T extends BaseReturnType> = (css: ReturnStyles<T>, resolved: WithCssInjectedProps) => any;\r\n\r\n/** Props that {@link WithCss} resolves before passing them to `useStyles`. */\r\ntype WithCssOwnProps = { size?: SizeType, variant?: Variant };\r\n\r\n/**\r\n * Props always passed to `useStyles` by {@link WithCss}. `size` and `variant` are resolved from the passed props\r\n * and the antd context, so they are never `undefined`.\r\n */\r\nexport type WithCssInjectedProps = { size: NonNullable<SizeType>, variant: Variant };\r\n\r\n/** Props of {@link WithCss}. */\r\ninterface WithCssProperties<T extends BaseReturnType, P extends WithCssOwnProps> {\r\n /** Render function called with the computed styles. */\r\n children: WithCssChildren<T>;\r\n /** Style hook created by antd-style `createStyles`. */\r\n useStyles: (props?: P & WithCssInjectedProps) => ReturnStyles<T>\r\n /** Props passed to `useStyles`, merged with the resolved `size` and `variant`. */\r\n props?: P;\r\n}\r\n\r\n/**\r\n * Lets class components use an antd-style `createStyles` hook: calls `useStyles` and renders `children(css)`.\r\n * `size` is resolved as `props.size`, then the enclosing `Space.Compact` size, then the `ConfigProvider`\r\n * `componentSize`, then `'middle'`; `variant` as\r\n * `props.variant`, then the `ConfigProvider` variant, then `'outlined'`.\r\n */\r\nexport default function WithCss<T extends BaseReturnType, P extends WithCssOwnProps = {}> ({useStyles, children, props}: WithCssProperties<T, P>) {\r\n const contextSize = useContext(SpaceCompactItemContext);\r\n const configSize = useContext(SizeContext);\r\n const {variant: configVariant} = useContext(ConfigContext);\r\n // same precedence as antd's internal useSize: own prop > Space.Compact > ConfigProvider > middle\r\n const mergedSize: NonNullable<SizeType> = props?.size || contextSize?.compactSize || configSize || 'middle';\r\n // same precedence as antd's internal useVariant: own prop > ConfigProvider > outlined\r\n const mergedVariant: Variant = props?.variant ?? configVariant ?? 'outlined';\r\n const css = useStyles({...(props as P), size: mergedSize, variant: mergedVariant});\r\n return children(css, {size: mergedSize, variant: mergedVariant});\r\n};\r\n"]}
|