cozy-ui 111.13.0 → 111.14.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.
Files changed (27) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/package.json +1 -1
  3. package/react/BottomSheet/BottomSheet.jsx +5 -1
  4. package/react/BottomSheet/README.md +2 -0
  5. package/react/BottomSheet/helpers.js +2 -0
  6. package/react/BottomSheet/helpers.spec.js +12 -0
  7. package/react/CozyDialogs/Readme.md +8 -1
  8. package/react/CozyDialogs/dialogPropTypes.js +1 -1
  9. package/react/CozyDialogs/useCozyDialog.js +4 -1
  10. package/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +4 -0
  11. package/react/SearchBar/Readme.md +56 -3
  12. package/react/SearchBar/index.jsx +105 -27
  13. package/react/SearchBar/locales/en.json +1 -1
  14. package/react/SearchBar/locales/fr.json +1 -1
  15. package/react/providers/DemoProvider.jsx +3 -9
  16. package/transpiled/react/BottomSheet/BottomSheet.js +7 -1
  17. package/transpiled/react/BottomSheet/helpers.js +3 -1
  18. package/transpiled/react/CozyDialogs/dialogPropTypes.js +1 -1
  19. package/transpiled/react/CozyDialogs/useCozyDialog.js +12 -7
  20. package/transpiled/react/MuiCozyTheme/overrides/makeDarkInvertedOverrides.d.ts +4 -0
  21. package/transpiled/react/MuiCozyTheme/overrides/makeDarkNormalOverrides.d.ts +4 -0
  22. package/transpiled/react/MuiCozyTheme/overrides/makeLightInvertedOverrides.d.ts +4 -0
  23. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.d.ts +4 -0
  24. package/transpiled/react/MuiCozyTheme/overrides/makeLightNormalOverrides.js +4 -0
  25. package/transpiled/react/SearchBar/index.js +113 -30
  26. package/transpiled/react/SearchBar/locales/withOnlyLocales.js +2 -2
  27. package/transpiled/react/providers/DemoProvider.js +5 -10
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # [111.14.0](https://github.com/cozy/cozy-ui/compare/v111.13.0...v111.14.0) (2024-10-03)
2
+
3
+
4
+ ### Features
5
+
6
+ * **BottomSheet:** Add `hasMinHeightOffset` prop ([0e1af92](https://github.com/cozy/cozy-ui/commit/0e1af92))
7
+ * **CozyDialogs:** Add `full` size ([d141068](https://github.com/cozy/cozy-ui/commit/d141068))
8
+ * **CozyDialogs:** We can now propagates props to inner components ([01d9d48](https://github.com/cozy/cozy-ui/commit/01d9d48))
9
+ * **SearchBar:** Add `auto` size and possibility to control it in the app ([038555f](https://github.com/cozy/cozy-ui/commit/038555f))
10
+ * **SearchBar:** Add multiple props to improve component management ([13f8450](https://github.com/cozy/cozy-ui/commit/13f8450))
11
+
1
12
  # [111.13.0](https://github.com/cozy/cozy-ui/compare/v111.12.0...v111.13.0) (2024-09-25)
2
13
 
3
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "111.13.0",
3
+ "version": "111.14.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -129,6 +129,7 @@ export const defaultBottomSheetSpringConfig = {
129
129
  const defaultSettings = {
130
130
  mediumHeightRatio: 0.75,
131
131
  mediumHeight: null,
132
+ hasMinHeightOffset: false,
132
133
  isOpenMin: false
133
134
  }
134
135
 
@@ -142,7 +143,7 @@ const BottomSheet = memo(
142
143
  offset,
143
144
  children
144
145
  }) => {
145
- const { mediumHeightRatio, mediumHeight, isOpenMin } = {
146
+ const { mediumHeightRatio, mediumHeight, isOpenMin, hasMinHeightOffset } = {
146
147
  ...defaultSettings,
147
148
  ...settings
148
149
  }
@@ -244,6 +245,7 @@ const BottomSheet = memo(
244
245
  isClosable,
245
246
  isOpenMin,
246
247
  headerRef,
248
+ offset: hasMinHeightOffset ? offset : 0,
247
249
  actionButtonsHeight,
248
250
  actionButtonsBottomMargin
249
251
  })
@@ -418,6 +420,8 @@ BottomSheet.propTypes = {
418
420
  mediumHeight: PropTypes.number,
419
421
  /** Height of the middle snap point, expressed as a percentage of the viewport height */
420
422
  mediumHeightRatio: PropTypes.number,
423
+ /** To include the offset in the min height value */
424
+ hasMinHeightOffset: PropTypes.bool,
421
425
  /** To open the BottomSheet at the minimum height, if have an header */
422
426
  isOpenMin: PropTypes.bool
423
427
  }),
@@ -46,6 +46,8 @@ import BottomSheet, { BottomSheetItem, BottomSheetTitle } from 'cozy-ui/transp
46
46
  * **settings** : `<object>` – Settings that can be modified
47
47
  * **mediumHeight** : `<number>` – Height in pixel of the middle snap point
48
48
  * **mediumHeightRatio** : `<number>` – Height of the middle snap point, expressed as a percentage of the viewport height
49
+ * **isOpenMin** : `<boolean>` – To open the BottomSheet at the minimum height, if have an header
50
+ * **hasMinHeightOffset** : `<boolean>` – To include the offset in the min height value
49
51
  * **backdrop** : `<boolean>` – To add a backdrop
50
52
  * **skipAnimation** : `<boolean>` – To remove animations
51
53
  * **offset** : `<number>` – Add an offset at the bottom
@@ -57,6 +57,7 @@ export const computeMinHeight = ({
57
57
  isClosable,
58
58
  isOpenMin,
59
59
  headerRef,
60
+ offset = 0,
60
61
  actionButtonsHeight,
61
62
  actionButtonsBottomMargin
62
63
  }) => {
@@ -64,6 +65,7 @@ export const computeMinHeight = ({
64
65
 
65
66
  return (
66
67
  headerRef.current.offsetHeight +
68
+ offset +
67
69
  actionButtonsHeight +
68
70
  actionButtonsBottomMargin +
69
71
  (getFlagshipMetadata().navbarHeight || 0) +
@@ -152,6 +152,18 @@ describe('computeMinHeight', () => {
152
152
 
153
153
  expect(res).toBe(85)
154
154
  })
155
+
156
+ it('should return correct value with offset', () => {
157
+ const res = computeMinHeight({
158
+ isClosable: false,
159
+ headerRef: { current: { offsetHeight: 10 } },
160
+ offset: 10,
161
+ actionButtonsHeight: 20,
162
+ actionButtonsBottomMargin: 30
163
+ })
164
+
165
+ expect(res).toBe(95)
166
+ })
155
167
  })
156
168
 
157
169
  describe('setTopPosition', () => {
@@ -33,7 +33,7 @@ import Button from 'cozy-ui/transpiled/react/Buttons'
33
33
 
34
34
  * **componentsProps** : `<object>` – overriden properties of specific components
35
35
  * **dialogTitle** : `<object>` – DialogTitle component properties
36
- * **size** : `<string>` – Can be "s", "m" (default) or "l"
36
+ * **size** : `<string>` – Can be "small", "medium" (default), "large" or "full"
37
37
  * **open** : `<boolean>` (required) – To open/close the modal
38
38
  * **disableTitleAutoPadding** : `<boolean>` (optional) – Disable title padding calculation that would prevent overlapping with close and back buttons
39
39
  * if set to `true` then you should handle those CSS properties by yourself or title will take 100% of width
@@ -205,6 +205,7 @@ const initialVariants = [{
205
205
  showActions: true,
206
206
  disableGutters: false,
207
207
  hideTitle: false,
208
+ fullScreen: false,
208
209
  withBackground: false
209
210
  }]
210
211
 
@@ -264,6 +265,11 @@ const initialVariants = [{
264
265
  label="Large"
265
266
  control={<Radio />}
266
267
  />
268
+ <FormControlLabel
269
+ value="full"
270
+ label="Full"
271
+ control={<Radio />}
272
+ />
267
273
  </RadioGroup>
268
274
  </FormControl>
269
275
  <div className="u-mt-1">
@@ -283,6 +289,7 @@ const initialVariants = [{
283
289
  {state.modalOpened && (
284
290
  <DialogComponent
285
291
  open
292
+ {...(variant.fullScreen && { fullScreen: true })}
286
293
  size={DialogComponent !== ConfirmDialog ? state.size : undefined}
287
294
  onClose={variant.withCloseButton ? handleClose : undefined}
288
295
  onBack={variant.withBackButton ? handleBack : undefined}
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types'
2
2
 
3
3
  export default {
4
- size: PropTypes.oneOf(['small', 'medium', 'large']),
4
+ size: PropTypes.oneOf(['small', 'medium', 'large', 'full']),
5
5
  open: PropTypes.bool.isRequired,
6
6
  disableTitleAutoPadding: PropTypes.bool,
7
7
  background: PropTypes.string,
@@ -6,7 +6,7 @@ import useBreakpoints from '../providers/Breakpoints'
6
6
  import { makeStyles } from '../styles'
7
7
 
8
8
  let globalId = 0
9
- const modalSizes = ['small', 'medium', 'large']
9
+ const modalSizes = ['small', 'medium', 'large', 'full']
10
10
 
11
11
  const useStyles = makeStyles({
12
12
  paper: {
@@ -92,6 +92,7 @@ const useCozyDialog = props => {
92
92
 
93
93
  const dividerClassName = 'divider--dialog'
94
94
  const dividerProps = {
95
+ ...componentsProps?.divider,
95
96
  classes: {
96
97
  root: dividerClassName
97
98
  }
@@ -99,12 +100,14 @@ const useCozyDialog = props => {
99
100
 
100
101
  const dialogActionsClassName = 'cozyDialogActions'
101
102
  const dialogActionsProps = {
103
+ ...componentsProps?.dialogActions,
102
104
  classes: {
103
105
  root: dialogActionsClassName
104
106
  }
105
107
  }
106
108
 
107
109
  const dialogContentProps = {
110
+ ...componentsProps?.dialogContent,
108
111
  classes: {
109
112
  root: cx({
110
113
  disableGutters
@@ -455,6 +455,10 @@ export const makeLightNormalOverrides = theme => ({
455
455
  maxWidth: '800px'
456
456
  }
457
457
  },
458
+ '&.full': {
459
+ width: '100%',
460
+ maxWidth: '100%'
461
+ },
458
462
  '&.overflow': {
459
463
  overflowY: 'visible !important', // Allow the icon to overflow the dialog, otherwise it will be cut off,
460
464
  '& .cozyDialogContent': {
@@ -3,8 +3,15 @@ import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
3
3
  import Variants from 'cozy-ui/docs/components/Variants'
4
4
  import SearchBar from 'cozy-ui/transpiled/react/SearchBar'
5
5
  import Typography from 'cozy-ui/transpiled/react/Typography'
6
+ import CloudIcon from 'cozy-ui/transpiled/react/Icons/Cloud'
7
+ import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
8
+ import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup'
9
+ import Radio from 'cozy-ui/transpiled/react/Radios'
10
+ import FormControl from 'cozy-ui/transpiled/react/FormControl'
11
+ import FormLabel from 'cozy-ui/transpiled/react/FormLabel'
6
12
 
7
- const initialVariants = [{ elevation: true }]
13
+ const initialVariants = [{ elevation: true, button: false, customIcon: false, disabledClear: false }]
14
+ initialState = { size: 'small' }
8
15
 
9
16
  ;
10
17
 
@@ -12,10 +19,56 @@ const initialVariants = [{ elevation: true }]
12
19
  <Variants initialVariants={initialVariants} screenshotAllVariants>
13
20
  {variant => (
14
21
  <>
22
+ <FormControl component="fieldset">
23
+ <FormLabel component="legend">Size</FormLabel>
24
+ <RadioGroup
25
+ aria-label="radio"
26
+ name="size"
27
+ row
28
+ value={state.size}
29
+ onChange={event => { setState({ size: event.target.value }) }}
30
+ >
31
+ <FormControlLabel
32
+ value="small"
33
+ label="Small"
34
+ control={<Radio />}
35
+ />
36
+ <FormControlLabel
37
+ value="medium"
38
+ label="Medium"
39
+ control={<Radio />}
40
+ />
41
+ <FormControlLabel
42
+ value="large"
43
+ label="Large"
44
+ control={<Radio />}
45
+ />
46
+ <FormControlLabel
47
+ value="auto"
48
+ label="Auto"
49
+ control={<Radio />}
50
+ />
51
+ </RadioGroup>
52
+ </FormControl>
15
53
  <Typography className="u-mb-half">Normal</Typography>
16
- <SearchBar className="u-mb-2" elevation={variant.elevation} />
54
+ <SearchBar className="u-mb-2"
55
+ elevation={variant.elevation}
56
+ size={state.size}
57
+ disabledClear={variant.disabledClear}
58
+ type={variant.button ? "button" : "search"}
59
+ icon={variant.customIcon ? CloudIcon : undefined}
60
+ label={variant.button ? <Typography color="primary">This is a label</Typography> : undefined}
61
+ />
17
62
  <Typography className="u-mb-half">Disabled</Typography>
18
- <SearchBar elevation={variant.elevation} disabled />
63
+ <SearchBar
64
+ disabled
65
+ elevation={variant.elevation}
66
+ size={state.size}
67
+ disabledClear={variant.disabledClear}
68
+ type={variant.button ? "button" : "search"}
69
+ icon={variant.customIcon ? CloudIcon : undefined}
70
+ label={variant.button ? <Typography color="primary">This is a label</Typography> : undefined}
71
+ />
19
72
  </>
20
73
  )}
21
74
  </Variants>
@@ -3,25 +3,42 @@ import debounce from 'lodash/debounce'
3
3
  import PropTypes from 'prop-types'
4
4
  import React, { forwardRef, useState, useMemo } from 'react'
5
5
 
6
- import withOnlyLocales from './locales/withOnlyLocales'
6
+ import { locales } from './locales/withOnlyLocales'
7
+ import ButtonBase from '../ButtonBase'
7
8
  import Icon from '../Icon'
9
+ import { iconPropType } from '../Icon'
8
10
  import IconButton from '../IconButton'
9
11
  import CrossCircleIcon from '../Icons/CrossCircle'
10
12
  import MagnifierIcon from '../Icons/Magnifier'
11
13
  import InputBase from '../InputBase'
12
14
  import Paper from '../Paper'
13
- import { useI18n } from '../providers/I18n'
15
+ import Typography from '../Typography'
16
+ import { useI18n, useExtendI18n } from '../providers/I18n'
14
17
  import { makeStyles } from '../styles'
15
18
 
19
+ const sizeToPixel = {
20
+ small: 40,
21
+ medium: 48,
22
+ large: 56,
23
+ auto: 'auto'
24
+ }
25
+
26
+ const radiusBySize = {
27
+ small: 20,
28
+ medium: 24,
29
+ large: 28,
30
+ auto: 24
31
+ }
32
+
16
33
  const useStyles = makeStyles(theme => ({
17
34
  root: {
18
35
  display: 'flex',
19
36
  boxSizing: 'border-box',
20
37
  position: 'relative',
21
38
  alignItems: 'center',
22
- height: 40,
39
+ height: ({ size }) => sizeToPixel[size],
23
40
  flex: 1,
24
- borderRadius: 99,
41
+ borderRadius: ({ size }) => radiusBySize[size],
25
42
  borderStyle: 'solid',
26
43
  borderWidth: 1,
27
44
  borderColor: 'transparent',
@@ -37,7 +54,19 @@ const useStyles = makeStyles(theme => ({
37
54
  backgroundColor: theme.palette.background.contrast
38
55
  },
39
56
  inputBase: {
40
- flex: 1
57
+ flex: 1,
58
+ paddingLeft: ({ icon }) => !icon && '1rem'
59
+ },
60
+ buttonBase: {
61
+ flex: 1,
62
+ justifyContent: 'start',
63
+ height: '100%',
64
+ borderRadius: 99
65
+ },
66
+ typography: {
67
+ color: 'currentColor',
68
+ opacity: 0.42,
69
+ paddingLeft: ({ icon }) => !icon && '1rem'
41
70
  },
42
71
  icon: {
43
72
  color: theme.palette.text.secondary,
@@ -81,8 +110,15 @@ const SearchBar = forwardRef(
81
110
  (
82
111
  {
83
112
  placeholder: placeholderProp,
113
+ icon,
114
+ size,
115
+ type,
116
+ label: labelProp,
117
+ componentsProps,
118
+ disabledClear,
84
119
  className,
85
120
  defaultValue,
121
+ value,
86
122
  elevation,
87
123
  disabled,
88
124
  onChange,
@@ -93,23 +129,25 @@ const SearchBar = forwardRef(
93
129
  ref
94
130
  ) => {
95
131
  const { t } = useI18n()
96
- const classes = useStyles()
132
+ const classes = useStyles({ size, type, icon })
97
133
  const [currentValue, setCurrentValue] = useState(defaultValue)
98
134
  const [isFocused, setIsFocused] = useState(false)
99
135
 
100
- const placeholder = placeholderProp || t('search.placeholder')
136
+ const placeholder = placeholderProp || t('SearchBar.placeholder')
137
+ const label = labelProp || t('SearchBar.placeholder')
138
+ const spreadValue = value || currentValue
139
+ const isSelfControlledComp = typeof value === 'undefined'
101
140
 
102
- const delayedOnChange = useMemo(
103
- () => debounce(event => onChange(event), 375),
104
- [onChange]
105
- )
141
+ const delayedOnChange = useMemo(() => debounce(onChange, 375), [onChange])
106
142
 
107
143
  const handleChange = ev => {
108
- const value = ev.target.value
144
+ if (!isSelfControlledComp) return onChange(ev)
109
145
 
110
- if (value.length >= 1) {
146
+ const _value = ev.target.value
147
+
148
+ if (_value.length >= 1) {
111
149
  delayedOnChange(ev)
112
- setCurrentValue(value)
150
+ setCurrentValue(_value)
113
151
  } else {
114
152
  handleClear(ev)
115
153
  }
@@ -143,18 +181,32 @@ const SearchBar = forwardRef(
143
181
  ref={ref}
144
182
  {...props}
145
183
  >
146
- <Icon className={classes.icon} icon={MagnifierIcon} />
147
- <InputBase
148
- className={classes.inputBase}
149
- placeholder={disabled ? null : placeholder}
150
- value={disabled ? placeholder : currentValue}
151
- disabled={disabled}
152
- aria-label={placeholder}
153
- onChange={handleChange}
154
- onFocus={handleFocus}
155
- onBlur={handleBlur}
156
- />
157
- {currentValue && (
184
+ {type === 'button' ? (
185
+ <ButtonBase className={classes.buttonBase}>
186
+ {icon && <Icon className={classes.icon} icon={icon} />}
187
+ {typeof label === 'string' ? (
188
+ <Typography className={classes.typography}>{label}</Typography>
189
+ ) : (
190
+ label
191
+ )}
192
+ </ButtonBase>
193
+ ) : (
194
+ <>
195
+ {icon && <Icon className={classes.icon} icon={icon} />}
196
+ <InputBase
197
+ {...componentsProps?.inputBase}
198
+ className={classes.inputBase}
199
+ placeholder={disabled ? null : placeholder}
200
+ value={disabled ? placeholder : spreadValue}
201
+ disabled={disabled}
202
+ aria-label={placeholder}
203
+ onChange={handleChange}
204
+ onFocus={handleFocus}
205
+ onBlur={handleBlur}
206
+ />
207
+ </>
208
+ )}
209
+ {spreadValue && !disabledClear && (
158
210
  <IconButton size="medium" onClick={handleClear}>
159
211
  <Icon icon={CrossCircleIcon} />
160
212
  </IconButton>
@@ -174,6 +226,10 @@ SearchBar.displayName = 'SearchBar'
174
226
 
175
227
  SearchBar.defaultProps = {
176
228
  elevation: true,
229
+ icon: MagnifierIcon,
230
+ size: 'small',
231
+ type: 'search',
232
+ disabledClear: false,
177
233
  defaultValue: '',
178
234
  onChange: () => {},
179
235
  onFocus: () => {},
@@ -182,13 +238,35 @@ SearchBar.defaultProps = {
182
238
 
183
239
  SearchBar.propTypes = {
184
240
  className: PropTypes.string,
241
+ type: PropTypes.oneOf(['button', 'search']),
242
+ icon: iconPropType,
243
+ size: PropTypes.oneOf(['small', 'medium', 'large', 'auto']),
244
+ componentsProps: PropTypes.shape({
245
+ /** Props spread to InputBase component */
246
+ inputBase: PropTypes.object
247
+ }),
248
+ /** Used to control the component outside of it */
249
+ value: PropTypes.string,
250
+ /** Used only with self-controlled component */
185
251
  defaultValue: PropTypes.string,
252
+ disabledClear: PropTypes.bool,
186
253
  elevation: PropTypes.bool,
187
254
  placeholder: PropTypes.string,
255
+ label: PropTypes.oneOfType([
256
+ PropTypes.string,
257
+ PropTypes.func,
258
+ PropTypes.object
259
+ ]),
188
260
  disabled: PropTypes.bool,
189
261
  onChange: PropTypes.func,
190
262
  onFocus: PropTypes.func,
191
263
  onBlur: PropTypes.func
192
264
  }
193
265
 
194
- export default withOnlyLocales(SearchBar)
266
+ const SearchBarWithLocales = props => {
267
+ useExtendI18n(locales)
268
+
269
+ return <SearchBar {...props} />
270
+ }
271
+
272
+ export default SearchBarWithLocales
@@ -1,5 +1,5 @@
1
1
  {
2
- "search": {
2
+ "SearchBar": {
3
3
  "placeholder": "Search"
4
4
  }
5
5
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "search": {
2
+ "SearchBar": {
3
3
  "placeholder": "Rechercher"
4
4
  }
5
5
  }
@@ -4,7 +4,7 @@ import { CozyProvider } from 'cozy-client'
4
4
 
5
5
  import { BreakpointsProvider } from './Breakpoints'
6
6
  import CozyTheme from './CozyTheme'
7
- import { I18nContext } from '../providers/I18n'
7
+ import I18n from '../providers/I18n'
8
8
 
9
9
  const defaultClient = {
10
10
  plugins: {
@@ -28,15 +28,9 @@ const DemoProvider = ({ client, variant, children }) => {
28
28
  return (
29
29
  <CozyProvider client={client || defaultClient}>
30
30
  <BreakpointsProvider>
31
- <I18nContext.Provider
32
- value={{
33
- t: x => x,
34
- f: () => '01 Jan. 2022',
35
- lang
36
- }}
37
- >
31
+ <I18n lang={lang} dictRequire={() => ({})}>
38
32
  <CozyTheme variant={variant}>{children}</CozyTheme>
39
- </I18nContext.Provider>
33
+ </I18n>
40
34
  </BreakpointsProvider>
41
35
  </CozyProvider>
42
36
  )
@@ -126,6 +126,7 @@ export var defaultBottomSheetSpringConfig = {
126
126
  var defaultSettings = {
127
127
  mediumHeightRatio: 0.75,
128
128
  mediumHeight: null,
129
+ hasMinHeightOffset: false,
129
130
  isOpenMin: false
130
131
  };
131
132
  var BottomSheet = /*#__PURE__*/memo(function (_ref3) {
@@ -140,7 +141,8 @@ var BottomSheet = /*#__PURE__*/memo(function (_ref3) {
140
141
  var _defaultSettings$sett = _objectSpread(_objectSpread({}, defaultSettings), settings),
141
142
  mediumHeightRatio = _defaultSettings$sett.mediumHeightRatio,
142
143
  mediumHeight = _defaultSettings$sett.mediumHeight,
143
- isOpenMin = _defaultSettings$sett.isOpenMin;
144
+ isOpenMin = _defaultSettings$sett.isOpenMin,
145
+ hasMinHeightOffset = _defaultSettings$sett.hasMinHeightOffset;
144
146
 
145
147
  var innerContentRef = useRef();
146
148
  var headerRef = useRef();
@@ -269,6 +271,7 @@ var BottomSheet = /*#__PURE__*/memo(function (_ref3) {
269
271
  isClosable: isClosable,
270
272
  isOpenMin: isOpenMin,
271
273
  headerRef: headerRef,
274
+ offset: hasMinHeightOffset ? offset : 0,
272
275
  actionButtonsHeight: actionButtonsHeight,
273
276
  actionButtonsBottomMargin: actionButtonsBottomMargin
274
277
  });
@@ -409,6 +412,9 @@ BottomSheet.propTypes = {
409
412
  /** Height of the middle snap point, expressed as a percentage of the viewport height */
410
413
  mediumHeightRatio: PropTypes.number,
411
414
 
415
+ /** To include the offset in the min height value */
416
+ hasMinHeightOffset: PropTypes.bool,
417
+
412
418
  /** To open the BottomSheet at the minimum height, if have an header */
413
419
  isOpenMin: PropTypes.bool
414
420
  }),
@@ -45,10 +45,12 @@ export var computeMinHeight = function computeMinHeight(_ref2) {
45
45
  var isClosable = _ref2.isClosable,
46
46
  isOpenMin = _ref2.isOpenMin,
47
47
  headerRef = _ref2.headerRef,
48
+ _ref2$offset = _ref2.offset,
49
+ offset = _ref2$offset === void 0 ? 0 : _ref2$offset,
48
50
  actionButtonsHeight = _ref2.actionButtonsHeight,
49
51
  actionButtonsBottomMargin = _ref2.actionButtonsBottomMargin;
50
52
  if (isClosable && !isOpenMin) return 0;
51
- return headerRef.current.offsetHeight + actionButtonsHeight + actionButtonsBottomMargin + (getFlagshipMetadata().navbarHeight || 0) + getSafeAreaValue('bottom');
53
+ return headerRef.current.offsetHeight + offset + actionButtonsHeight + actionButtonsBottomMargin + (getFlagshipMetadata().navbarHeight || 0) + getSafeAreaValue('bottom');
52
54
  };
53
55
  export var makeOverridenChildren = function makeOverridenChildren(children, headerContentRef) {
54
56
  return React.Children.map(children, function (child) {
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  export default {
3
- size: PropTypes.oneOf(['small', 'medium', 'large']),
3
+ size: PropTypes.oneOf(['small', 'medium', 'large', 'full']),
4
4
  open: PropTypes.bool.isRequired,
5
5
  disableTitleAutoPadding: PropTypes.bool,
6
6
  background: PropTypes.string,
@@ -13,7 +13,7 @@ import DialogTransition from "cozy-ui/transpiled/react/CozyDialogs/DialogTransit
13
13
  import useBreakpoints from "cozy-ui/transpiled/react/providers/Breakpoints";
14
14
  import { makeStyles } from "cozy-ui/transpiled/react/styles";
15
15
  var globalId = 0;
16
- var modalSizes = ['small', 'medium', 'large'];
16
+ var modalSizes = ['small', 'medium', 'large', 'full'];
17
17
  var useStyles = makeStyles({
18
18
  paper: {
19
19
  background: function background(_ref) {
@@ -97,25 +97,30 @@ var useCozyDialog = function useCozyDialog(props) {
97
97
  }
98
98
  };
99
99
  var dividerClassName = 'divider--dialog';
100
- var dividerProps = {
100
+
101
+ var dividerProps = _objectSpread(_objectSpread({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.divider), {}, {
101
102
  classes: {
102
103
  root: dividerClassName
103
104
  }
104
- };
105
+ });
106
+
105
107
  var dialogActionsClassName = 'cozyDialogActions';
106
- var dialogActionsProps = {
108
+
109
+ var dialogActionsProps = _objectSpread(_objectSpread({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.dialogActions), {}, {
107
110
  classes: {
108
111
  root: dialogActionsClassName
109
112
  }
110
- };
111
- var dialogContentProps = {
113
+ });
114
+
115
+ var dialogContentProps = _objectSpread(_objectSpread({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.dialogContent), {}, {
112
116
  classes: {
113
117
  root: cx({
114
118
  disableGutters: disableGutters
115
119
  })
116
120
  },
117
121
  className: 'cozyDialogContent'
118
- };
122
+ });
123
+
119
124
  return {
120
125
  dialogProps: dialogProps,
121
126
  dialogTitleProps: dialogTitleProps,
@@ -527,6 +527,10 @@ export function makeDarkInvertedOverrides(theme: any): {
527
527
  maxWidth: string;
528
528
  };
529
529
  };
530
+ '&.full': {
531
+ width: string;
532
+ maxWidth: string;
533
+ };
530
534
  '&.overflow': {
531
535
  overflowY: string;
532
536
  '& .cozyDialogContent': {
@@ -527,6 +527,10 @@ export function makeDarkNormalOverrides(theme: any): {
527
527
  maxWidth: string;
528
528
  };
529
529
  };
530
+ '&.full': {
531
+ width: string;
532
+ maxWidth: string;
533
+ };
530
534
  '&.overflow': {
531
535
  overflowY: string;
532
536
  '& .cozyDialogContent': {
@@ -527,6 +527,10 @@ export function makeLightInvertedOverrides(theme: any): {
527
527
  maxWidth: string;
528
528
  };
529
529
  };
530
+ '&.full': {
531
+ width: string;
532
+ maxWidth: string;
533
+ };
530
534
  '&.overflow': {
531
535
  overflowY: string;
532
536
  '& .cozyDialogContent': {
@@ -527,6 +527,10 @@ export function makeLightNormalOverrides(theme: any): {
527
527
  maxWidth: string;
528
528
  };
529
529
  };
530
+ '&.full': {
531
+ width: string;
532
+ maxWidth: string;
533
+ };
530
534
  '&.overflow': {
531
535
  overflowY: string;
532
536
  '& .cozyDialogContent': {
@@ -425,6 +425,10 @@ export var makeLightNormalOverrides = function makeLightNormalOverrides(theme) {
425
425
  width: '800px',
426
426
  maxWidth: '800px'
427
427
  }),
428
+ '&.full': {
429
+ width: '100%',
430
+ maxWidth: '100%'
431
+ },
428
432
  '&.overflow': {
429
433
  overflowY: 'visible !important',
430
434
  // Allow the icon to overflow the dialog, otherwise it will be cut off,
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["placeholder", "className", "defaultValue", "elevation", "disabled", "onChange", "onFocus", "onBlur"];
5
+ var _excluded = ["placeholder", "icon", "size", "type", "label", "componentsProps", "disabledClear", "className", "defaultValue", "value", "elevation", "disabled", "onChange", "onFocus", "onBlur"];
6
6
 
7
7
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
8
 
@@ -12,15 +12,30 @@ import cx from 'classnames';
12
12
  import debounce from 'lodash/debounce';
13
13
  import PropTypes from 'prop-types';
14
14
  import React, { forwardRef, useState, useMemo } from 'react';
15
- import withOnlyLocales from "cozy-ui/transpiled/react/SearchBar/locales/withOnlyLocales";
15
+ import { locales } from "cozy-ui/transpiled/react/SearchBar/locales/withOnlyLocales";
16
+ import ButtonBase from "cozy-ui/transpiled/react/ButtonBase";
16
17
  import Icon from "cozy-ui/transpiled/react/Icon";
18
+ import { iconPropType } from "cozy-ui/transpiled/react/Icon";
17
19
  import IconButton from "cozy-ui/transpiled/react/IconButton";
18
20
  import CrossCircleIcon from "cozy-ui/transpiled/react/Icons/CrossCircle";
19
21
  import MagnifierIcon from "cozy-ui/transpiled/react/Icons/Magnifier";
20
22
  import InputBase from "cozy-ui/transpiled/react/InputBase";
21
23
  import Paper from "cozy-ui/transpiled/react/Paper";
22
- import { useI18n } from "cozy-ui/transpiled/react/providers/I18n";
24
+ import Typography from "cozy-ui/transpiled/react/Typography";
25
+ import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
23
26
  import { makeStyles } from "cozy-ui/transpiled/react/styles";
27
+ var sizeToPixel = {
28
+ small: 40,
29
+ medium: 48,
30
+ large: 56,
31
+ auto: 'auto'
32
+ };
33
+ var radiusBySize = {
34
+ small: 20,
35
+ medium: 24,
36
+ large: 28,
37
+ auto: 24
38
+ };
24
39
  var useStyles = makeStyles(function (theme) {
25
40
  return {
26
41
  root: {
@@ -28,9 +43,15 @@ var useStyles = makeStyles(function (theme) {
28
43
  boxSizing: 'border-box',
29
44
  position: 'relative',
30
45
  alignItems: 'center',
31
- height: 40,
46
+ height: function height(_ref) {
47
+ var size = _ref.size;
48
+ return sizeToPixel[size];
49
+ },
32
50
  flex: 1,
33
- borderRadius: 99,
51
+ borderRadius: function borderRadius(_ref2) {
52
+ var size = _ref2.size;
53
+ return radiusBySize[size];
54
+ },
34
55
  borderStyle: 'solid',
35
56
  borderWidth: 1,
36
57
  borderColor: 'transparent',
@@ -46,7 +67,25 @@ var useStyles = makeStyles(function (theme) {
46
67
  backgroundColor: theme.palette.background.contrast
47
68
  },
48
69
  inputBase: {
49
- flex: 1
70
+ flex: 1,
71
+ paddingLeft: function paddingLeft(_ref3) {
72
+ var icon = _ref3.icon;
73
+ return !icon && '1rem';
74
+ }
75
+ },
76
+ buttonBase: {
77
+ flex: 1,
78
+ justifyContent: 'start',
79
+ height: '100%',
80
+ borderRadius: 99
81
+ },
82
+ typography: {
83
+ color: 'currentColor',
84
+ opacity: 0.42,
85
+ paddingLeft: function paddingLeft(_ref4) {
86
+ var icon = _ref4.icon;
87
+ return !icon && '1rem';
88
+ }
50
89
  },
51
90
  icon: {
52
91
  color: theme.palette.text.secondary,
@@ -86,23 +125,34 @@ var useStyles = makeStyles(function (theme) {
86
125
  }
87
126
  };
88
127
  });
89
- var SearchBar = /*#__PURE__*/forwardRef(function (_ref, ref) {
128
+ var SearchBar = /*#__PURE__*/forwardRef(function (_ref5, ref) {
90
129
  var _cx;
91
130
 
92
- var placeholderProp = _ref.placeholder,
93
- className = _ref.className,
94
- defaultValue = _ref.defaultValue,
95
- elevation = _ref.elevation,
96
- disabled = _ref.disabled,
97
- onChange = _ref.onChange,
98
- onFocus = _ref.onFocus,
99
- onBlur = _ref.onBlur,
100
- props = _objectWithoutProperties(_ref, _excluded);
131
+ var placeholderProp = _ref5.placeholder,
132
+ icon = _ref5.icon,
133
+ size = _ref5.size,
134
+ type = _ref5.type,
135
+ labelProp = _ref5.label,
136
+ componentsProps = _ref5.componentsProps,
137
+ disabledClear = _ref5.disabledClear,
138
+ className = _ref5.className,
139
+ defaultValue = _ref5.defaultValue,
140
+ value = _ref5.value,
141
+ elevation = _ref5.elevation,
142
+ disabled = _ref5.disabled,
143
+ onChange = _ref5.onChange,
144
+ onFocus = _ref5.onFocus,
145
+ onBlur = _ref5.onBlur,
146
+ props = _objectWithoutProperties(_ref5, _excluded);
101
147
 
102
148
  var _useI18n = useI18n(),
103
149
  t = _useI18n.t;
104
150
 
105
- var classes = useStyles();
151
+ var classes = useStyles({
152
+ size: size,
153
+ type: type,
154
+ icon: icon
155
+ });
106
156
 
107
157
  var _useState = useState(defaultValue),
108
158
  _useState2 = _slicedToArray(_useState, 2),
@@ -114,19 +164,21 @@ var SearchBar = /*#__PURE__*/forwardRef(function (_ref, ref) {
114
164
  isFocused = _useState4[0],
115
165
  setIsFocused = _useState4[1];
116
166
 
117
- var placeholder = placeholderProp || t('search.placeholder');
167
+ var placeholder = placeholderProp || t('SearchBar.placeholder');
168
+ var label = labelProp || t('SearchBar.placeholder');
169
+ var spreadValue = value || currentValue;
170
+ var isSelfControlledComp = typeof value === 'undefined';
118
171
  var delayedOnChange = useMemo(function () {
119
- return debounce(function (event) {
120
- return onChange(event);
121
- }, 375);
172
+ return debounce(onChange, 375);
122
173
  }, [onChange]);
123
174
 
124
175
  var handleChange = function handleChange(ev) {
125
- var value = ev.target.value;
176
+ if (!isSelfControlledComp) return onChange(ev);
177
+ var _value = ev.target.value;
126
178
 
127
- if (value.length >= 1) {
179
+ if (_value.length >= 1) {
128
180
  delayedOnChange(ev);
129
- setCurrentValue(value);
181
+ setCurrentValue(_value);
130
182
  } else {
131
183
  handleClear(ev);
132
184
  }
@@ -156,19 +208,26 @@ var SearchBar = /*#__PURE__*/forwardRef(function (_ref, ref) {
156
208
  elevation: elevation ? 1 : 0,
157
209
  className: cx(className, classes.root, (_cx = {}, _defineProperty(_cx, classes.flat, !elevation), _defineProperty(_cx, classes.elevation, elevation), _defineProperty(_cx, classes.focused, isFocused), _defineProperty(_cx, classes.disabled, disabled), _cx)),
158
210
  ref: ref
159
- }, props), /*#__PURE__*/React.createElement(Icon, {
211
+ }, props), type === 'button' ? /*#__PURE__*/React.createElement(ButtonBase, {
212
+ className: classes.buttonBase
213
+ }, icon && /*#__PURE__*/React.createElement(Icon, {
160
214
  className: classes.icon,
161
- icon: MagnifierIcon
162
- }), /*#__PURE__*/React.createElement(InputBase, {
215
+ icon: icon
216
+ }), typeof label === 'string' ? /*#__PURE__*/React.createElement(Typography, {
217
+ className: classes.typography
218
+ }, label) : label) : /*#__PURE__*/React.createElement(React.Fragment, null, icon && /*#__PURE__*/React.createElement(Icon, {
219
+ className: classes.icon,
220
+ icon: icon
221
+ }), /*#__PURE__*/React.createElement(InputBase, _extends({}, componentsProps === null || componentsProps === void 0 ? void 0 : componentsProps.inputBase, {
163
222
  className: classes.inputBase,
164
223
  placeholder: disabled ? null : placeholder,
165
- value: disabled ? placeholder : currentValue,
224
+ value: disabled ? placeholder : spreadValue,
166
225
  disabled: disabled,
167
226
  "aria-label": placeholder,
168
227
  onChange: handleChange,
169
228
  onFocus: handleFocus,
170
229
  onBlur: handleBlur
171
- }), currentValue && /*#__PURE__*/React.createElement(IconButton, {
230
+ }))), spreadValue && !disabledClear && /*#__PURE__*/React.createElement(IconButton, {
172
231
  size: "medium",
173
232
  onClick: handleClear
174
233
  }, /*#__PURE__*/React.createElement(Icon, {
@@ -182,6 +241,10 @@ var SearchBar = /*#__PURE__*/forwardRef(function (_ref, ref) {
182
241
  SearchBar.displayName = 'SearchBar';
183
242
  SearchBar.defaultProps = {
184
243
  elevation: true,
244
+ icon: MagnifierIcon,
245
+ size: 'small',
246
+ type: 'search',
247
+ disabledClear: false,
185
248
  defaultValue: '',
186
249
  onChange: function onChange() {},
187
250
  onFocus: function onFocus() {},
@@ -189,12 +252,32 @@ SearchBar.defaultProps = {
189
252
  };
190
253
  SearchBar.propTypes = {
191
254
  className: PropTypes.string,
255
+ type: PropTypes.oneOf(['button', 'search']),
256
+ icon: iconPropType,
257
+ size: PropTypes.oneOf(['small', 'medium', 'large', 'auto']),
258
+ componentsProps: PropTypes.shape({
259
+ /** Props spread to InputBase component */
260
+ inputBase: PropTypes.object
261
+ }),
262
+
263
+ /** Used to control the component outside of it */
264
+ value: PropTypes.string,
265
+
266
+ /** Used only with self-controlled component */
192
267
  defaultValue: PropTypes.string,
268
+ disabledClear: PropTypes.bool,
193
269
  elevation: PropTypes.bool,
194
270
  placeholder: PropTypes.string,
271
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.object]),
195
272
  disabled: PropTypes.bool,
196
273
  onChange: PropTypes.func,
197
274
  onFocus: PropTypes.func,
198
275
  onBlur: PropTypes.func
199
276
  };
200
- export default withOnlyLocales(SearchBar);
277
+
278
+ var SearchBarWithLocales = function SearchBarWithLocales(props) {
279
+ useExtendI18n(locales);
280
+ return /*#__PURE__*/React.createElement(SearchBar, props);
281
+ };
282
+
283
+ export default SearchBarWithLocales;
@@ -1,10 +1,10 @@
1
1
  var en = {
2
- search: {
2
+ SearchBar: {
3
3
  placeholder: "Search"
4
4
  }
5
5
  };
6
6
  var fr = {
7
- search: {
7
+ SearchBar: {
8
8
  placeholder: "Rechercher"
9
9
  }
10
10
  };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { CozyProvider } from 'cozy-client';
3
3
  import { BreakpointsProvider } from "cozy-ui/transpiled/react/providers/Breakpoints";
4
4
  import CozyTheme from "cozy-ui/transpiled/react/providers/CozyTheme";
5
- import { I18nContext } from "cozy-ui/transpiled/react/providers/I18n";
5
+ import I18n from "cozy-ui/transpiled/react/providers/I18n";
6
6
  var defaultClient = {
7
7
  plugins: {
8
8
  realtime: {
@@ -30,15 +30,10 @@ var DemoProvider = function DemoProvider(_ref) {
30
30
  var lang = localStorage.getItem('lang') || 'en';
31
31
  return /*#__PURE__*/React.createElement(CozyProvider, {
32
32
  client: client || defaultClient
33
- }, /*#__PURE__*/React.createElement(BreakpointsProvider, null, /*#__PURE__*/React.createElement(I18nContext.Provider, {
34
- value: {
35
- t: function t(x) {
36
- return x;
37
- },
38
- f: function f() {
39
- return '01 Jan. 2022';
40
- },
41
- lang: lang
33
+ }, /*#__PURE__*/React.createElement(BreakpointsProvider, null, /*#__PURE__*/React.createElement(I18n, {
34
+ lang: lang,
35
+ dictRequire: function dictRequire() {
36
+ return {};
42
37
  }
43
38
  }, /*#__PURE__*/React.createElement(CozyTheme, {
44
39
  variant: variant