cozy-ui 59.2.0 → 59.3.0

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 CHANGED
@@ -1,3 +1,15 @@
1
+ # [59.3.0](https://github.com/cozy/cozy-ui/compare/v59.2.0...v59.3.0) (2022-01-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * CozyDialogs doesn't show title block anymore if undefined ([1c7170c](https://github.com/cozy/cozy-ui/commit/1c7170c))
7
+
8
+
9
+ ### Features
10
+
11
+ * Add `disableGutters` prop to CozyDialogs ([a55f5fb](https://github.com/cozy/cozy-ui/commit/a55f5fb))
12
+
1
13
  # [59.2.0](https://github.com/cozy/cozy-ui/compare/v59.1.0...v59.2.0) (2022-01-11)
2
14
 
3
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "59.2.0",
3
+ "version": "59.3.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -15,7 +15,8 @@ const ConfirmDialog = props => {
15
15
  dialogTitleProps,
16
16
  fullScreen,
17
17
  id,
18
- dialogActionsProps
18
+ dialogActionsProps,
19
+ dialogContentProps
19
20
  } = useCozyDialog({ ...props, isFluidTitle: true })
20
21
 
21
22
  const onBackOrClose = onBack || onClose
@@ -40,11 +41,13 @@ const ConfirmDialog = props => {
40
41
  onClick={onBackOrClose}
41
42
  />
42
43
  )}
43
- <DialogContent>
44
+ <DialogContent {...dialogContentProps}>
44
45
  <div className="dialogContentInner withFluidActions">
45
- <div className="dialogTitleFluidContainer">
46
- <DialogTitle {...dialogTitleProps}>{title}</DialogTitle>
47
- </div>
46
+ {title && (
47
+ <div className="dialogTitleFluidContainer">
48
+ <DialogTitle {...dialogTitleProps}>{title}</DialogTitle>
49
+ </div>
50
+ )}
48
51
  {content}
49
52
  {actions && (
50
53
  <DialogActions
@@ -16,7 +16,8 @@ const Dialog = props => {
16
16
  dialogTitleProps,
17
17
  fullScreen,
18
18
  id,
19
- dialogActionsProps
19
+ dialogActionsProps,
20
+ dialogContentProps
20
21
  } = useCozyDialog(props)
21
22
 
22
23
  const onBackOrClose = onBack || onClose
@@ -41,9 +42,13 @@ const Dialog = props => {
41
42
  onClick={onBackOrClose}
42
43
  />
43
44
  )}
44
- <DialogTitle {...dialogTitleProps}>{title}</DialogTitle>
45
- <Divider />
46
- <DialogContent>
45
+ {title && (
46
+ <>
47
+ <DialogTitle {...dialogTitleProps}>{title}</DialogTitle>
48
+ <Divider />
49
+ </>
50
+ )}
51
+ <DialogContent {...dialogContentProps}>
47
52
  <div className="dialogContentInner withFluidActions">
48
53
  {content}
49
54
  {actions && (
@@ -16,7 +16,8 @@ const FixedActionsDialog = props => {
16
16
  dialogTitleProps,
17
17
  fullScreen,
18
18
  id,
19
- dialogActionsProps
19
+ dialogActionsProps,
20
+ dialogContentProps
20
21
  } = useCozyDialog({ ...props, isFluidTitle: true })
21
22
 
22
23
  const onBackOrClose = onBack || onClose
@@ -41,11 +42,13 @@ const FixedActionsDialog = props => {
41
42
  onClick={onBackOrClose}
42
43
  />
43
44
  )}
44
- <DialogContent>
45
+ <DialogContent {...dialogContentProps}>
45
46
  <div className="dialogContentInner">
46
- <div className="dialogTitleFluidContainer">
47
- <DialogTitle {...dialogTitleProps}>{title}</DialogTitle>
48
- </div>
47
+ {title && (
48
+ <div className="dialogTitleFluidContainer">
49
+ <DialogTitle {...dialogTitleProps}>{title}</DialogTitle>
50
+ </div>
51
+ )}
49
52
  {content}
50
53
  </div>
51
54
  </DialogContent>
@@ -16,7 +16,8 @@ const FixedDialog = props => {
16
16
  dialogTitleProps,
17
17
  fullScreen,
18
18
  id,
19
- dialogActionsProps
19
+ dialogActionsProps,
20
+ dialogContentProps
20
21
  } = useCozyDialog(props)
21
22
 
22
23
  const onBackOrClose = onBack || onClose
@@ -41,9 +42,13 @@ const FixedDialog = props => {
41
42
  onClick={onBackOrClose}
42
43
  />
43
44
  )}
44
- <DialogTitle {...dialogTitleProps}>{title}</DialogTitle>
45
- <Divider />
46
- <DialogContent>
45
+ {title && (
46
+ <>
47
+ <DialogTitle {...dialogTitleProps}>{title}</DialogTitle>
48
+ <Divider />
49
+ </>
50
+ )}
51
+ <DialogContent {...dialogContentProps}>
47
52
  <div className="dialogContentInner">{content}</div>
48
53
  </DialogContent>
49
54
  <Divider />
@@ -15,7 +15,8 @@ const IllustrationDialog = props => {
15
15
  dialogTitleProps,
16
16
  id,
17
17
  fullScreen,
18
- dialogActionsProps
18
+ dialogActionsProps,
19
+ dialogContentProps
19
20
  } = useCozyDialog({ ...props, isFluidTitle: true })
20
21
 
21
22
  const onBackOrClose = onBack || onClose
@@ -40,11 +41,13 @@ const IllustrationDialog = props => {
40
41
  onClick={onBackOrClose}
41
42
  />
42
43
  )}
43
- <DialogContent>
44
+ <DialogContent {...dialogContentProps}>
44
45
  <div className="dialogContentInner withFluidActions">
45
- <DialogTitle {...dialogTitleProps}>
46
- <div className="u-flex u-flex-justify-center">{title}</div>
47
- </DialogTitle>
46
+ {title && (
47
+ <DialogTitle {...dialogTitleProps}>
48
+ <div className="u-flex u-flex-justify-center">{title}</div>
49
+ </DialogTitle>
50
+ )}
48
51
  {content}
49
52
  {actions && (
50
53
  <DialogActions
@@ -1,10 +1,12 @@
1
1
  Pre-built modals ready to be directly used in applications, based on MUI Dialog.
2
2
 
3
- * Dialog : default Cozy modal
4
- * ConfirmDialog : used for confirmation popups
5
- * IllustrationDialog : used for illustration as title
6
- * FixedDialog : default one but with both title/actions fixed
7
- * FixedActionsDialog : default one but with title fluid and actions fixed
3
+ ### Usage
4
+
5
+ * **Dialog** : default Cozy modal
6
+ * **ConfirmDialog** : used for confirmation popups
7
+ * **IllustrationDialog** : used for illustration as title
8
+ * **FixedDialog** : default one but with both title/actions fixed
9
+ * **FixedActionsDialog** : default one but with title fluid and actions fixed
8
10
 
9
11
  Will automatically:
10
12
 
@@ -13,23 +15,26 @@ Will automatically:
13
15
 
14
16
  ### Props
15
17
 
16
- * size : `<string>` Can be "s", "m" (default) or "l"
17
- * opened : `<boolean>` (required) To open/close the modal
18
- * onClose : `<function>` (required) Triggered function on modal close action
19
- * onBack : `<function>` (optional) Triggered function on modal back action
18
+ * **size** : `<string>` Can be "s", "m" (default) or "l"
19
+ * **open** : `<boolean>` (required) To open/close the modal
20
+ * **onClose** : `<function>` (required) Triggered function on modal close action
21
+ * **onBack** : `<function>` (optional) Triggered function on modal back action
20
22
  * if defined and in desktop mode then a back button is shown in addition to the close button and it will trigger onBack() on click
21
23
  * if defined and in mobile mode then the back button will trigger onBack() instead of onClose()
22
24
  * if not defined and in mobile mode then the back button will trigger onClose()
23
- * disableTitleAutoPadding : `<boolean>` (optional) Disable title padding calculation that would prevent overlapping with close and back buttons
25
+ * **disableTitleAutoPadding** : `<boolean>` (optional) Disable title padding calculation that would prevent overlapping with close and back buttons
24
26
  * if set to `true` then you should handle those CSS properties by yourself or title will take 100% of width
25
27
  * if set to `false` then title will take only available space between close and back buttons regarding which of `onClose` or `onBack` props are defined or not
26
- * title : `<node>` Title of the modal
27
- * content : `<node>` Content of the modal
28
- * actions : `<node>` Actions of the modal
29
- * actionsLayout : `<string>` Can be "row" or "column"
28
+ * **disableGutters** : `<boolean>` To disable the margins and paddings of the inner content
29
+ * **title** : `<node>` Title of the modal
30
+ * **content** : `<node>` Content of the modal
31
+ * **actions** : `<node>` Actions of the modal
32
+ * **actionsLayout** : `<string>` – Can be "row" or "column"
30
33
 
31
34
  Additionally, all the CozyDialogs support [MUI Dialog's props](https://v3.material-ui.com/api/dialog/).
32
35
 
36
+ ### Exemples
37
+
33
38
  ```jsx
34
39
  import {
35
40
  Dialog,
@@ -151,7 +156,9 @@ initialState = {
151
156
  content: 'default',
152
157
  theme: 'normal',
153
158
  align: 'middle',
154
- showActions: true
159
+ showActions: true,
160
+ disableGutters: false,
161
+ hideTitle: false
155
162
  }
156
163
 
157
164
  ;
@@ -174,6 +181,10 @@ initialState = {
174
181
  <StateRadio value='short' name='title' /> short{' '}
175
182
  <StateRadio value='long' name='title' /> long
176
183
  </p>
184
+ <p>Hide title:
185
+ <StateRadio value={true} name='hideTitle' /> yes{' '}
186
+ <StateRadio value={false} name='hideTitle' /> no
187
+ </p>
177
188
  <p>Content:
178
189
  <StateRadio value='default' name='content' /> default{' '}
179
190
  <StateRadio value='short' name='content' /> short{' '}
@@ -196,6 +207,10 @@ initialState = {
196
207
  <StateRadio value='middle' name='align' /> middle
197
208
  <StateRadio value='top' name='align' /> top{' '}
198
209
  </p>
210
+ <p>Disable gutters (inner padding):
211
+ <StateRadio value={true} name='disableGutters' /> yes
212
+ <StateRadio value={false} name='disableGutters' /> no{' '}
213
+ </p>
199
214
  <DialogComponent
200
215
  size={DialogComponent !== ConfirmDialog ? state.size : undefined}
201
216
  open={state.modalOpened}
@@ -203,10 +218,13 @@ initialState = {
203
218
  onBack={state.withBackButton ? handleBack : undefined}
204
219
  disableTitleAutoPadding={state.disableTitleAutoPadding}
205
220
  align={state.align}
206
- title={DialogComponent !== IllustrationDialog && state.title === "long"
207
- ? `${dialogTitles[DialogComponent.name]} - ${content.ada.short}`
208
- : dialogTitles[DialogComponent.name]
221
+ title={state.hideTitle
222
+ ? undefined
223
+ : DialogComponent !== IllustrationDialog && state.title === "long"
224
+ ? `${dialogTitles[DialogComponent.name]} - ${content.ada.short}`
225
+ : dialogTitles[DialogComponent.name]
209
226
  }
227
+ disableGutters={state.disableGutters}
210
228
  content={
211
229
  <Typography variant='body1' color='textPrimary'>
212
230
  { state.content == 'default'
@@ -27,6 +27,7 @@ const useCozyDialog = props => {
27
27
  align,
28
28
  disableTitleAutoPadding,
29
29
  isFluidTitle,
30
+ disableGutters,
30
31
  ...otherProps
31
32
  } = props
32
33
  const { isMobile } = useBreakpoints()
@@ -91,6 +92,14 @@ const useCozyDialog = props => {
91
92
  }
92
93
  }
93
94
 
95
+ const dialogContentProps = {
96
+ classes: {
97
+ root: cx({
98
+ disableGutters
99
+ })
100
+ }
101
+ }
102
+
94
103
  return {
95
104
  dialogProps,
96
105
  dialogTitleProps,
@@ -98,7 +107,8 @@ const useCozyDialog = props => {
98
107
  id,
99
108
  fullScreen,
100
109
  dividerProps,
101
- dialogActionsProps
110
+ dialogActionsProps,
111
+ dialogContentProps
102
112
  }
103
113
  }
104
114
 
@@ -442,6 +442,17 @@ const makeOverrides = theme => ({
442
442
  [theme.breakpoints.down('sm')]: {
443
443
  padding: '24px 16px 0'
444
444
  },
445
+ '&.disableGutters': {
446
+ padding: 0,
447
+ '& .dialogContentInner': {
448
+ marginBottom: 0
449
+ },
450
+ '& .dialogTitleFluidContainer': {
451
+ marginLeft: 0,
452
+ marginRight: 0,
453
+ marginTop: 0
454
+ }
455
+ },
445
456
  '& .dialogContentInner': {
446
457
  marginBottom: '24px',
447
458
  '&.withFluidActions': {
@@ -23,7 +23,8 @@ var ConfirmDialog = function ConfirmDialog(props) {
23
23
  dialogTitleProps = _useCozyDialog.dialogTitleProps,
24
24
  fullScreen = _useCozyDialog.fullScreen,
25
25
  id = _useCozyDialog.id,
26
- dialogActionsProps = _useCozyDialog.dialogActionsProps;
26
+ dialogActionsProps = _useCozyDialog.dialogActionsProps,
27
+ dialogContentProps = _useCozyDialog.dialogContentProps;
27
28
 
28
29
  var onBackOrClose = onBack || onClose;
29
30
  return React.createElement(Dialog, dialogProps, !fullScreen && onClose && React.createElement(DialogCloseButton, {
@@ -35,9 +36,9 @@ var ConfirmDialog = function ConfirmDialog(props) {
35
36
  }), fullScreen && onBackOrClose && React.createElement(DialogBackButton, {
36
37
  "data-test-id": "modal-backclose-button-".concat(id),
37
38
  onClick: onBackOrClose
38
- }), React.createElement(DialogContent, null, React.createElement("div", {
39
+ }), React.createElement(DialogContent, dialogContentProps, React.createElement("div", {
39
40
  className: "dialogContentInner withFluidActions"
40
- }, React.createElement("div", {
41
+ }, title && React.createElement("div", {
41
42
  className: "dialogTitleFluidContainer"
42
43
  }, React.createElement(DialogTitle, dialogTitleProps, title)), content, actions && React.createElement(DialogActions, _extends({}, dialogActionsProps, {
43
44
  disableSpacing: true,
@@ -21,7 +21,8 @@ var Dialog = function Dialog(props) {
21
21
  dialogTitleProps = _useCozyDialog.dialogTitleProps,
22
22
  fullScreen = _useCozyDialog.fullScreen,
23
23
  id = _useCozyDialog.id,
24
- dialogActionsProps = _useCozyDialog.dialogActionsProps;
24
+ dialogActionsProps = _useCozyDialog.dialogActionsProps,
25
+ dialogContentProps = _useCozyDialog.dialogContentProps;
25
26
 
26
27
  var onBackOrClose = onBack || onClose;
27
28
  return React.createElement(MUIDialog, dialogProps, !fullScreen && onClose && React.createElement(DialogCloseButton, {
@@ -33,7 +34,7 @@ var Dialog = function Dialog(props) {
33
34
  }), fullScreen && onBackOrClose && React.createElement(DialogBackButton, {
34
35
  "data-test-id": "modal-backclose-button-".concat(id),
35
36
  onClick: onBackOrClose
36
- }), React.createElement(DialogTitle, dialogTitleProps, title), React.createElement(Divider, null), React.createElement(DialogContent, null, React.createElement("div", {
37
+ }), title && React.createElement(React.Fragment, null, React.createElement(DialogTitle, dialogTitleProps, title), React.createElement(Divider, null)), React.createElement(DialogContent, dialogContentProps, React.createElement("div", {
37
38
  className: "dialogContentInner withFluidActions"
38
39
  }, content, actions && React.createElement(DialogActions, _extends({}, dialogActionsProps, {
39
40
  disableSpacing: true,
@@ -24,7 +24,8 @@ var FixedActionsDialog = function FixedActionsDialog(props) {
24
24
  dialogTitleProps = _useCozyDialog.dialogTitleProps,
25
25
  fullScreen = _useCozyDialog.fullScreen,
26
26
  id = _useCozyDialog.id,
27
- dialogActionsProps = _useCozyDialog.dialogActionsProps;
27
+ dialogActionsProps = _useCozyDialog.dialogActionsProps,
28
+ dialogContentProps = _useCozyDialog.dialogContentProps;
28
29
 
29
30
  var onBackOrClose = onBack || onClose;
30
31
  return React.createElement(Dialog, dialogProps, !fullScreen && onClose && React.createElement(DialogCloseButton, {
@@ -36,9 +37,9 @@ var FixedActionsDialog = function FixedActionsDialog(props) {
36
37
  }), fullScreen && onBackOrClose && React.createElement(DialogBackButton, {
37
38
  "data-test-id": "modal-backclose-button-".concat(id),
38
39
  onClick: onBackOrClose
39
- }), React.createElement(DialogContent, null, React.createElement("div", {
40
+ }), React.createElement(DialogContent, dialogContentProps, React.createElement("div", {
40
41
  className: "dialogContentInner"
41
- }, React.createElement("div", {
42
+ }, title && React.createElement("div", {
42
43
  className: "dialogTitleFluidContainer"
43
44
  }, React.createElement(DialogTitle, dialogTitleProps, title)), content)), React.createElement(Divider, null), actions && React.createElement(DialogActions, _extends({}, dialogActionsProps, {
44
45
  disableSpacing: true,
@@ -21,7 +21,8 @@ var FixedDialog = function FixedDialog(props) {
21
21
  dialogTitleProps = _useCozyDialog.dialogTitleProps,
22
22
  fullScreen = _useCozyDialog.fullScreen,
23
23
  id = _useCozyDialog.id,
24
- dialogActionsProps = _useCozyDialog.dialogActionsProps;
24
+ dialogActionsProps = _useCozyDialog.dialogActionsProps,
25
+ dialogContentProps = _useCozyDialog.dialogContentProps;
25
26
 
26
27
  var onBackOrClose = onBack || onClose;
27
28
  return React.createElement(Dialog, dialogProps, !fullScreen && onClose && React.createElement(DialogCloseButton, {
@@ -33,7 +34,7 @@ var FixedDialog = function FixedDialog(props) {
33
34
  }), fullScreen && onBackOrClose && React.createElement(DialogBackButton, {
34
35
  "data-test-id": "modal-backclose-button-".concat(id),
35
36
  onClick: onBackOrClose
36
- }), React.createElement(DialogTitle, dialogTitleProps, title), React.createElement(Divider, null), React.createElement(DialogContent, null, React.createElement("div", {
37
+ }), title && React.createElement(React.Fragment, null, React.createElement(DialogTitle, dialogTitleProps, title), React.createElement(Divider, null)), React.createElement(DialogContent, dialogContentProps, React.createElement("div", {
37
38
  className: "dialogContentInner"
38
39
  }, content)), React.createElement(Divider, null), actions && React.createElement(DialogActions, _extends({}, dialogActionsProps, {
39
40
  disableSpacing: true,
@@ -23,7 +23,8 @@ var IllustrationDialog = function IllustrationDialog(props) {
23
23
  dialogTitleProps = _useCozyDialog.dialogTitleProps,
24
24
  id = _useCozyDialog.id,
25
25
  fullScreen = _useCozyDialog.fullScreen,
26
- dialogActionsProps = _useCozyDialog.dialogActionsProps;
26
+ dialogActionsProps = _useCozyDialog.dialogActionsProps,
27
+ dialogContentProps = _useCozyDialog.dialogContentProps;
27
28
 
28
29
  var onBackOrClose = onBack || onClose;
29
30
  return React.createElement(Dialog, dialogProps, !fullScreen && onClose && React.createElement(DialogCloseButton, {
@@ -35,9 +36,9 @@ var IllustrationDialog = function IllustrationDialog(props) {
35
36
  }), fullScreen && onBackOrClose && React.createElement(DialogBackButton, {
36
37
  "data-test-id": "modal-backclose-button-".concat(id),
37
38
  onClick: onBackOrClose
38
- }), React.createElement(DialogContent, null, React.createElement("div", {
39
+ }), React.createElement(DialogContent, dialogContentProps, React.createElement("div", {
39
40
  className: "dialogContentInner withFluidActions"
40
- }, React.createElement(DialogTitle, dialogTitleProps, React.createElement("div", {
41
+ }, title && React.createElement(DialogTitle, dialogTitleProps, React.createElement("div", {
41
42
  className: "u-flex u-flex-justify-center"
42
43
  }, title)), content, actions && React.createElement(DialogActions, _extends({}, dialogActionsProps, {
43
44
  disableSpacing: true,
@@ -28,7 +28,8 @@ var useCozyDialog = function useCozyDialog(props) {
28
28
  align = props.align,
29
29
  disableTitleAutoPadding = props.disableTitleAutoPadding,
30
30
  isFluidTitle = props.isFluidTitle,
31
- otherProps = _objectWithoutProperties(props, ["size", "actions", "actionsLayout", "title", "content", "open", "opened", "onBack", "onClose", "align", "disableTitleAutoPadding", "isFluidTitle"]);
31
+ disableGutters = props.disableGutters,
32
+ otherProps = _objectWithoutProperties(props, ["size", "actions", "actionsLayout", "title", "content", "open", "opened", "onBack", "onClose", "align", "disableTitleAutoPadding", "isFluidTitle", "disableGutters"]);
32
33
 
33
34
  var _useBreakpoints = useBreakpoints(),
34
35
  isMobile = _useBreakpoints.isMobile;
@@ -89,6 +90,13 @@ var useCozyDialog = function useCozyDialog(props) {
89
90
  root: dialogActionsClassName
90
91
  }
91
92
  };
93
+ var dialogContentProps = {
94
+ classes: {
95
+ root: cx({
96
+ disableGutters: disableGutters
97
+ })
98
+ }
99
+ };
92
100
  return {
93
101
  dialogProps: dialogProps,
94
102
  dialogTitleProps: dialogTitleProps,
@@ -96,7 +104,8 @@ var useCozyDialog = function useCozyDialog(props) {
96
104
  id: id,
97
105
  fullScreen: fullScreen,
98
106
  dividerProps: dividerProps,
99
- dialogActionsProps: dialogActionsProps
107
+ dialogActionsProps: dialogActionsProps,
108
+ dialogContentProps: dialogContentProps
100
109
  };
101
110
  };
102
111
 
@@ -416,6 +416,16 @@ var makeOverrides = function makeOverrides(theme) {
416
416
  padding: '24px 32px 0'
417
417
  }, _defineProperty(_root2, theme.breakpoints.down('sm'), {
418
418
  padding: '24px 16px 0'
419
+ }), _defineProperty(_root2, '&.disableGutters', {
420
+ padding: 0,
421
+ '& .dialogContentInner': {
422
+ marginBottom: 0
423
+ },
424
+ '& .dialogTitleFluidContainer': {
425
+ marginLeft: 0,
426
+ marginRight: 0,
427
+ marginTop: 0
428
+ }
419
429
  }), _defineProperty(_root2, '& .dialogContentInner', {
420
430
  marginBottom: '24px',
421
431
  '&.withFluidActions': _defineProperty({}, theme.breakpoints.down('sm'), {