cozy-ui 93.2.0 → 93.4.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,17 @@
1
+ # [93.4.0](https://github.com/cozy/cozy-ui/compare/v93.3.0...v93.4.0) (2023-09-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add Alert provider ([ebccf42](https://github.com/cozy/cozy-ui/commit/ebccf42))
7
+
8
+ # [93.3.0](https://github.com/cozy/cozy-ui/compare/v93.2.0...v93.3.0) (2023-09-28)
9
+
10
+
11
+ ### Features
12
+
13
+ * **Icon:** Add LabelOutlined ([b0efd5a](https://github.com/cozy/cozy-ui/commit/b0efd5a))
14
+
1
15
  # [93.2.0](https://github.com/cozy/cozy-ui/compare/v93.1.1...v93.2.0) (2023-09-22)
2
16
 
3
17
 
@@ -0,0 +1 @@
1
+ <svg width="17" height="17" viewBox="0 0 17 17" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.002 4.5H2v8h8.002l4-4-4-4Zm0-2H2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h8.002a2 2 0 0 0 1.414-.586l4-4a2 2 0 0 0 0-2.828l-4-4a2 2 0 0 0-1.414-.586Z"/></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "93.2.0",
3
+ "version": "93.4.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -153,6 +153,7 @@ import Image from 'cozy-ui/transpiled/react/Icons/Image'
153
153
  import Info from 'cozy-ui/transpiled/react/Icons/Info'
154
154
  import InfoOutlined from 'cozy-ui/transpiled/react/Icons/InfoOutlined'
155
155
  import Key from 'cozy-ui/transpiled/react/Icons/Key'
156
+ import LabelOutlined from 'cozy-ui/transpiled/react/Icons/LabelOutlined'
156
157
  import Laptop from 'cozy-ui/transpiled/react/Icons/Laptop'
157
158
  import Left from 'cozy-ui/transpiled/react/Icons/Left'
158
159
  import Lightbulb from 'cozy-ui/transpiled/react/Icons/Lightbulb'
@@ -391,6 +392,7 @@ const icons = [
391
392
  Info,
392
393
  InfoOutlined,
393
394
  Key,
395
+ LabelOutlined,
394
396
  Laptop,
395
397
  Left,
396
398
  Lightbulb,
@@ -883,7 +885,7 @@ import Typography from 'cozy-ui/transpiled/react/Typography'
883
885
 
884
886
  const colors = ['#297EF2', '#08b442', '#B449E7', '#F52D2D', '#FF962F']
885
887
  let i = 0
886
- const availableIcons = ['album-add','album-remove','album','answer','apple','archive','arrowUp','attachment','attention','bank','banking-add','banking','bell','bike','bill','bottom','browser-brave','browser-chrome','browser-duckduckgo','browser-edge','browser-edge-chromium','browser-firefox','browser-ie','browser-opera','browser-safari','burger','bus','calendar','camera','car','carbonCopy','carpooling','categories','certified','check-circle','check-list','check-square','check','checkbox','circle-filled','clock','clock-outline','cloud-happy','cloud','collect','cocktail','comment','company','compare','compass','connector','contract','contrast','copy','cozy-circle','cozy-laugh', 'cozy-lock', 'cozy-text', 'cozy-release', 'credit-card-add','credit-card','credit','crop','cross-circle','cross-medium','cross-small','cross','cube','dash','dashboard','data-control','debit','devices','dots','down','download','drawing-arrow-up','dropdown-close','dropdown-open','dropdown','dropup','electric-bike','electric-car','electric-scooter','email-notification','email','eu','euro','exchange','eye-closed','eye','file-add','file-duotone','file-new','file-none','file-outline','file','filter','fingerprint','fitness','flag-outlined','flag','flash-auto','flashlight','folder-add','folder-moveto','folder','forbidden','from-user','gear','globe','graph-circle','grid','group-list','groups','hand','heart','help','help-outlined','history','home','hourglass','image','info-outlined','info','key','laptop','left','lightbulb','link-out','link','list','location','lock', 'lock-screen', 'logout','magic-trick','magnet','magnifier','merge','moped','motorcycle','mountain','movement-in','movement-out','mouvement','moveto','multi-files','music','new','next','note','notification-email','offline','online', 'openapp', 'openwith','palette','paper','paperplane','password','pen','people','percent-circle','percent','personal-data','phone-download','phone-upload','phone','pie-chart','pin','plane','plus-small','plus','previous','printer','qualify','radio-checked','radio-unchecked','refresh','repare','reply','restaurant','restore-straight','restore','right','rise','rotate-left','rotate-right','sad-cozy','safe','school','scooter','select-all','setting','share-circle','share','shield','shop','sound','spinner','sport-bag','stack','star','stats','subway', 'swap', 'sync-cozy','sync','tag','target','team','telephone','to-the-cloud','top','train','tram','trash','trophy','unknow','unlink','unlock','up','upload','videos','walk','wallet-add','wallet-new','wallet','warn','warning-circle','warning','wrench-circle','work']
888
+ const availableIcons = ['album-add','album-remove','album','answer','apple','archive','arrowUp','attachment','attention','bank','banking-add','banking','bell','bike','bill','bottom','browser-brave','browser-chrome','browser-duckduckgo','browser-edge','browser-edge-chromium','browser-firefox','browser-ie','browser-opera','browser-safari','burger','bus','calendar','camera','car','carbonCopy','carpooling','categories','certified','check-circle','check-list','check-square','check','checkbox','circle-filled','clock','clock-outline','cloud-happy','cloud','collect','cocktail','comment','company','compare','compass','connector','contract','contrast','copy','cozy-circle','cozy-laugh', 'cozy-lock', 'cozy-text', 'cozy-release', 'credit-card-add','credit-card','credit','crop','cross-circle','cross-medium','cross-small','cross','cube','dash','dashboard','data-control','debit','devices','dots','down','download','drawing-arrow-up','dropdown-close','dropdown-open','dropdown','dropup','electric-bike','electric-car','electric-scooter','email-notification','email','eu','euro','exchange','eye-closed','eye','file-add','file-duotone','file-new','file-none','file-outline','file','filter','fingerprint','fitness','flag-outlined','flag','flash-auto','flashlight','folder-add','folder-moveto','folder','forbidden','from-user','gear','globe','graph-circle','grid','group-list','groups','hand','heart','help','help-outlined','history','home','hourglass','image','info-outlined','info','key','label-outlined','laptop','left','lightbulb','link-out','link','list','location','lock', 'lock-screen', 'logout','magic-trick','magnet','magnifier','merge','moped','motorcycle','mountain','movement-in','movement-out','mouvement','moveto','multi-files','music','new','next','note','notification-email','offline','online', 'openapp', 'openwith','palette','paper','paperplane','password','pen','people','percent-circle','percent','personal-data','phone-download','phone-upload','phone','pie-chart','pin','plane','plus-small','plus','previous','printer','qualify','radio-checked','radio-unchecked','refresh','repare','reply','restaurant','restore-straight','restore','right','rise','rotate-left','rotate-right','sad-cozy','safe','school','scooter','select-all','setting','share-circle','share','shield','shop','sound','spinner','sport-bag','stack','star','stats','subway', 'swap', 'sync-cozy','sync','tag','target','team','telephone','to-the-cloud','top','train','tram','trash','trophy','unknow','unlink','unlock','up','upload','videos','walk','wallet-add','wallet-new','wallet','warn','warning-circle','warning','wrench-circle','work']
887
889
  ;
888
890
  <div style={{ fontSize: '2rem', display: 'grid', gridTemplateColumns: 'repeat(6, 1fr)' }}>
889
891
  <Sprite />
@@ -426,7 +426,7 @@ animation: checkmark 0.5s ease-in-out 0.16s backwards
426
426
  <path fill-rule="evenodd" d="M8 16A8 8 0 1 1 8 0a8 8 0 0 1 0 16zm0-1A7 7 0 1 0 8 1a7 7 0 0 0 0 14zM7 4c0-.552.444-1 1-1 .552 0 1 .444 1 1 0 .552-.444 1-1 1-.552 0-1-.444-1-1zm1.001 2C8.553 6 9 6.444 9 7v4h1v2H7.999A.997.997 0 0 1 7 12V8H6V6h2.001z"/>
427
427
  </symbol><symbol id="info" viewBox="0 0 16 16"><use fill-rule="evenodd" xlink:href="#info"/></symbol><symbol id="key" viewBox="0 0 16 16">
428
428
  <path fill-rule="evenodd" d="M9 9.584V10H7v2H5v2H3v2H0v-3l6.297-6.297A5 5 0 1 1 9 9.584zM11 3a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"/>
429
- </symbol><symbol id="laptop" viewBox="0 0 16 16">
429
+ </symbol><symbol id="label-outlined" viewBox="0 0 17 17"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.002 4.5H2v8h8.002l4-4-4-4Zm0-2H2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h8.002a2 2 0 0 0 1.414-.586l4-4a2 2 0 0 0 0-2.828l-4-4a2 2 0 0 0-1.414-.586Z"/></symbol><symbol id="laptop" viewBox="0 0 16 16">
430
430
  <path fill-rule="evenodd" d="M3 4v5h10V4H3zm11.5 7h-13a.5.5 0 0 1-.5-.5V4c0-1.103.896-2 2-2h10c1.102 0 2 .897 2 2v6.5a.5.5 0 0 1-.5.5zm-4 1h5a.5.5 0 0 1 .5.5c0 .827-.674 1.5-1.5 1.5h-13C.673 14 0 13.327 0 12.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5h4v-.5a.5.5 0 0 1 .5-.5z"/>
431
431
  </symbol><symbol id="left" viewBox="0 0 16 16">
432
432
  <path fill-rule="evenodd" d="M10.70725,2.70725 C11.09825,2.31625 11.09825,1.68425 10.70725,1.29325 C10.31625,0.90225 9.68425,0.90225 9.29325,1.29325 L3.29325,7.29325 C2.90225,7.68425 2.90225,8.31625 3.29325,8.70725 L9.29325,14.70725 C9.68425,15.09825 10.31625,15.09825 10.70725,14.70725 C11.09825,14.31625 11.09825,13.68425 10.70725,13.29325 L5.41425,8.00025 L10.70725,2.70725 Z"/>
@@ -0,0 +1,16 @@
1
+ // Automatically created, please run `scripts/generate-svgr-icon.sh assets/icons/ui/label-outlined.svg` to regenerate;
2
+ import React from 'react'
3
+
4
+ function SvgLabelOutlined(props) {
5
+ return (
6
+ <svg viewBox="0 0 17 17" {...props}>
7
+ <path
8
+ fillRule="evenodd"
9
+ clipRule="evenodd"
10
+ d="M10.002 4.5H2v8h8.002l4-4-4-4zm0-2H2a2 2 0 00-2 2v8a2 2 0 002 2h8.002a2 2 0 001.414-.586l4-4a2 2 0 000-2.828l-4-4a2 2 0 00-1.414-.586z"
11
+ />
12
+ </svg>
13
+ )
14
+ }
15
+
16
+ export default SvgLabelOutlined
@@ -55,7 +55,7 @@ initialState = { open: isTesting() }
55
55
 
56
56
  const handleToggle = () => {setState(state => ({ open: !state.open }))}
57
57
 
58
- const initialVariants = [{ primary: true, secondary: true, success: false, error: false, warning: false, info: false }]
58
+ const initialVariants = [{ primary: true, secondary: false, success: false, error: false, warning: false, info: false }]
59
59
 
60
60
  ;
61
61
 
package/react/index.js CHANGED
@@ -131,3 +131,4 @@ export { default as TimelineDot } from './TimelineDot'
131
131
  export { default as TimelineItem } from './TimelineItem'
132
132
  export { default as TimelineOppositeContent } from './TimelineOppositeContent'
133
133
  export { default as TimelineSeparator } from './TimelineSeparator'
134
+ export { default as AlertProvider, useAlert } from './Alert'
@@ -0,0 +1,28 @@
1
+ ```jsx
2
+ import Variants from 'cozy-ui/docs/components/Variants'
3
+ import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
4
+ import AlertProvider, { useAlert } from 'cozy-ui/transpiled/react/providers/Alert'
5
+ import Button from 'cozy-ui/transpiled/react/Buttons'
6
+
7
+ const initialVariants = [{ primary: true, secondary: false, success: false, error: false, warning: false, info: false }]
8
+
9
+ const Component = ({ variant }) => {
10
+ const { showAlert } = useAlert()
11
+
12
+ return <Button label="show alert" onClick={() => showAlert('Alert message', variant)}/>
13
+ }
14
+
15
+ ;
16
+
17
+ <BreakpointsProvider>
18
+ <AlertProvider>
19
+ <Variants initialVariants={initialVariants} radio>
20
+ {variant => (
21
+ <>
22
+ <Component variant={Object.keys(variant).find(key => variant[key])} />
23
+ </>
24
+ )}
25
+ </Variants>
26
+ </AlertProvider>
27
+ </BreakpointsProvider>
28
+ ```
@@ -0,0 +1,51 @@
1
+ import React, { createContext, useState, useContext, useMemo } from 'react'
2
+
3
+ import Snackbar from '../../Snackbar'
4
+ import Alert from '../../Alert'
5
+
6
+ export const AlertContext = createContext()
7
+
8
+ export const useAlert = () => {
9
+ const context = useContext(AlertContext)
10
+
11
+ if (!context) {
12
+ throw new Error('useAlert must be used within a AlertProvider')
13
+ }
14
+ return context
15
+ }
16
+
17
+ const defaultState = { message: '', severity: 'primary', open: false }
18
+ const handleClose = (state, setState) => () => {
19
+ return setState({ ...state, open: false })
20
+ }
21
+
22
+ const AlertProvider = ({ children }) => {
23
+ const [state, setState] = useState(defaultState)
24
+
25
+ const value = useMemo(
26
+ () => ({
27
+ showAlert: (message, severity) => {
28
+ setState({ message, severity, open: true })
29
+ }
30
+ }),
31
+ []
32
+ )
33
+
34
+ return (
35
+ <AlertContext.Provider value={value}>
36
+ {children}
37
+ <Snackbar open={state.open} onClose={handleClose(state, setState)}>
38
+ <Alert
39
+ variant="filled"
40
+ elevation={6}
41
+ severity={state.severity}
42
+ onClose={handleClose(state, setState)}
43
+ >
44
+ {state.message}
45
+ </Alert>
46
+ </Snackbar>
47
+ </AlertContext.Provider>
48
+ )
49
+ }
50
+
51
+ export default React.memo(AlertProvider)