@fto-consult/expo-ui 1.0.4
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/assets/adaptive-icon.png +0 -0
- package/assets/add_photo.png +0 -0
- package/assets/favicon.png +0 -0
- package/assets/icon.png +0 -0
- package/assets/logo.png +0 -0
- package/assets/splash.png +0 -0
- package/babel.config.alias.js +32 -0
- package/babel.config.js +18 -0
- package/circular-dependencies.js +24 -0
- package/compiler.config.js +28 -0
- package/expo.metro.config.js +27 -0
- package/index.js +21 -0
- package/metro.config.js +1 -0
- package/package.json +60 -0
- package/src/App.js +65 -0
- package/src/Preferences.js +5 -0
- package/src/auth/Login.js +254 -0
- package/src/auth/index.js +3 -0
- package/src/components/ActivityIndicator/index.js +9 -0
- package/src/components/Animations/Animation/index.js +95 -0
- package/src/components/Animations/Animation/utils.js +78 -0
- package/src/components/Animations/OpacityAnimation/index.js +53 -0
- package/src/components/Animations/OpacityAnimation/utils.js +38 -0
- package/src/components/Animations/index.js +6 -0
- package/src/components/AppBar/Content.js +132 -0
- package/src/components/AppBar/index.js +164 -0
- package/src/components/AppBar/utils.js +204 -0
- package/src/components/AutoLink/index.js +45 -0
- package/src/components/Avatar/AutoHeightImage/AnimatableImage.js +22 -0
- package/src/components/Avatar/AutoHeightImage/ImagePolyfill.js +33 -0
- package/src/components/Avatar/AutoHeightImage/cache.js +75 -0
- package/src/components/Avatar/AutoHeightImage/helpers.js +2 -0
- package/src/components/Avatar/AutoHeightImage/index.js +97 -0
- package/src/components/Avatar/Image.js +115 -0
- package/src/components/Avatar/Text.js +74 -0
- package/src/components/Avatar/index.js +89 -0
- package/src/components/BackToTop/index.js +89 -0
- package/src/components/Badge/index.js +141 -0
- package/src/components/Badge/index1.js +34 -0
- package/src/components/BottomSheet/Content.js +19 -0
- package/src/components/BottomSheet/Menu.js +126 -0
- package/src/components/BottomSheet/Provider.js +58 -0
- package/src/components/BottomSheet/Sheet.js +434 -0
- package/src/components/BottomSheet/index.js +8 -0
- package/src/components/BottomSheet/utils.js +30 -0
- package/src/components/Br/index.js +4 -0
- package/src/components/Br/index.web.js +3 -0
- package/src/components/Browser/index.js +4 -0
- package/src/components/Button/index.js +465 -0
- package/src/components/CardView/index.android.js +55 -0
- package/src/components/CardView/index.ios.js +36 -0
- package/src/components/CardView/index.web.js +3 -0
- package/src/components/Chart/appexchart.3.5.text +14 -0
- package/src/components/Chart/index.js +22 -0
- package/src/components/Chart/index.native.js +61 -0
- package/src/components/Chart/utils.js +0 -0
- package/src/components/Checkbox/index.js +178 -0
- package/src/components/Chip/index.js +350 -0
- package/src/components/Color/ColorPicker.js +724 -0
- package/src/components/Color/assets/black-gradient-rotated.png +0 -0
- package/src/components/Color/assets/black-gradient.png +0 -0
- package/src/components/Color/assets/color-wheel.png +0 -0
- package/src/components/Color/index.js +158 -0
- package/src/components/ContentLoader/BarChar.js +19 -0
- package/src/components/ContentLoader/Circle.js +3 -0
- package/src/components/ContentLoader/Circle.web.js +3 -0
- package/src/components/ContentLoader/Datagrid.js +28 -0
- package/src/components/ContentLoader/Form.js +39 -0
- package/src/components/ContentLoader/Loader/RLoader/index.js +3 -0
- package/src/components/ContentLoader/Loader/RLoader/index.web.js +3 -0
- package/src/components/ContentLoader/Loader/index.js +20 -0
- package/src/components/ContentLoader/PieChart.js +22 -0
- package/src/components/ContentLoader/Placeholder/Placeholder.js +52 -0
- package/src/components/ContentLoader/Placeholder/PlaceholderLine.js +59 -0
- package/src/components/ContentLoader/Placeholder/PlaceholderMedia.js +47 -0
- package/src/components/ContentLoader/Placeholder/animations/Fade.js +58 -0
- package/src/components/ContentLoader/Placeholder/animations/Loader.js +24 -0
- package/src/components/ContentLoader/Placeholder/animations/Progressive.js +62 -0
- package/src/components/ContentLoader/Placeholder/animations/Raw.js +4 -0
- package/src/components/ContentLoader/Placeholder/animations/Shine.js +56 -0
- package/src/components/ContentLoader/Placeholder/animations/ShineOverlay.js +56 -0
- package/src/components/ContentLoader/Placeholder/animations/context.js +4 -0
- package/src/components/ContentLoader/Placeholder/index.js +12 -0
- package/src/components/ContentLoader/Placeholder/tokens.js +9 -0
- package/src/components/ContentLoader/Profile.js +27 -0
- package/src/components/ContentLoader/Rect.js +3 -0
- package/src/components/ContentLoader/Rect.web.js +3 -0
- package/src/components/ContentLoader/Skeleton.js +145 -0
- package/src/components/ContentLoader/Table.js +69 -0
- package/src/components/ContentLoader/TaskList.js +27 -0
- package/src/components/ContentLoader/index copy.js +148 -0
- package/src/components/ContentLoader/index.js +151 -0
- package/src/components/ContentLoader/utils.js +8 -0
- package/src/components/CountUp/index.js +67 -0
- package/src/components/Countries/SelectCountry.js +65 -0
- package/src/components/Countries/index.js +5 -0
- package/src/components/Countries/resources/countries.json +1746 -0
- package/src/components/Countries/resources/flags/images/ad.png +0 -0
- package/src/components/Countries/resources/flags/images/ae.png +0 -0
- package/src/components/Countries/resources/flags/images/af.png +0 -0
- package/src/components/Countries/resources/flags/images/ag.png +0 -0
- package/src/components/Countries/resources/flags/images/ai.png +0 -0
- package/src/components/Countries/resources/flags/images/al.png +0 -0
- package/src/components/Countries/resources/flags/images/am.png +0 -0
- package/src/components/Countries/resources/flags/images/ao.png +0 -0
- package/src/components/Countries/resources/flags/images/ar.png +0 -0
- package/src/components/Countries/resources/flags/images/as.png +0 -0
- package/src/components/Countries/resources/flags/images/at.png +0 -0
- package/src/components/Countries/resources/flags/images/au.png +0 -0
- package/src/components/Countries/resources/flags/images/aw.png +0 -0
- package/src/components/Countries/resources/flags/images/ax.png +0 -0
- package/src/components/Countries/resources/flags/images/az.png +0 -0
- package/src/components/Countries/resources/flags/images/ba.png +0 -0
- package/src/components/Countries/resources/flags/images/bb.png +0 -0
- package/src/components/Countries/resources/flags/images/bd.png +0 -0
- package/src/components/Countries/resources/flags/images/be.png +0 -0
- package/src/components/Countries/resources/flags/images/bf.png +0 -0
- package/src/components/Countries/resources/flags/images/bg.png +0 -0
- package/src/components/Countries/resources/flags/images/bh.png +0 -0
- package/src/components/Countries/resources/flags/images/bi.png +0 -0
- package/src/components/Countries/resources/flags/images/bj.png +0 -0
- package/src/components/Countries/resources/flags/images/bl.png +0 -0
- package/src/components/Countries/resources/flags/images/bm.png +0 -0
- package/src/components/Countries/resources/flags/images/bn.png +0 -0
- package/src/components/Countries/resources/flags/images/bo.png +0 -0
- package/src/components/Countries/resources/flags/images/bq.png +0 -0
- package/src/components/Countries/resources/flags/images/br.png +0 -0
- package/src/components/Countries/resources/flags/images/bs.png +0 -0
- package/src/components/Countries/resources/flags/images/bt.png +0 -0
- package/src/components/Countries/resources/flags/images/bw.png +0 -0
- package/src/components/Countries/resources/flags/images/by.png +0 -0
- package/src/components/Countries/resources/flags/images/bz.png +0 -0
- package/src/components/Countries/resources/flags/images/ca.png +0 -0
- package/src/components/Countries/resources/flags/images/cc.png +0 -0
- package/src/components/Countries/resources/flags/images/cd.png +0 -0
- package/src/components/Countries/resources/flags/images/cf.png +0 -0
- package/src/components/Countries/resources/flags/images/cg.png +0 -0
- package/src/components/Countries/resources/flags/images/ch.png +0 -0
- package/src/components/Countries/resources/flags/images/ci.png +0 -0
- package/src/components/Countries/resources/flags/images/ck.png +0 -0
- package/src/components/Countries/resources/flags/images/cl.png +0 -0
- package/src/components/Countries/resources/flags/images/cm.png +0 -0
- package/src/components/Countries/resources/flags/images/cn.png +0 -0
- package/src/components/Countries/resources/flags/images/co.png +0 -0
- package/src/components/Countries/resources/flags/images/cr.png +0 -0
- package/src/components/Countries/resources/flags/images/cu.png +0 -0
- package/src/components/Countries/resources/flags/images/cv.png +0 -0
- package/src/components/Countries/resources/flags/images/cw.png +0 -0
- package/src/components/Countries/resources/flags/images/cx.png +0 -0
- package/src/components/Countries/resources/flags/images/cy.png +0 -0
- package/src/components/Countries/resources/flags/images/cz.png +0 -0
- package/src/components/Countries/resources/flags/images/de.png +0 -0
- package/src/components/Countries/resources/flags/images/dj.png +0 -0
- package/src/components/Countries/resources/flags/images/dk.png +0 -0
- package/src/components/Countries/resources/flags/images/dm.png +0 -0
- package/src/components/Countries/resources/flags/images/do.png +0 -0
- package/src/components/Countries/resources/flags/images/dz.png +0 -0
- package/src/components/Countries/resources/flags/images/ec.png +0 -0
- package/src/components/Countries/resources/flags/images/ee.png +0 -0
- package/src/components/Countries/resources/flags/images/eg.png +0 -0
- package/src/components/Countries/resources/flags/images/eh.png +0 -0
- package/src/components/Countries/resources/flags/images/er.png +0 -0
- package/src/components/Countries/resources/flags/images/es.png +0 -0
- package/src/components/Countries/resources/flags/images/et.png +0 -0
- package/src/components/Countries/resources/flags/images/fi.png +0 -0
- package/src/components/Countries/resources/flags/images/fj.png +0 -0
- package/src/components/Countries/resources/flags/images/fk.png +0 -0
- package/src/components/Countries/resources/flags/images/fm.png +0 -0
- package/src/components/Countries/resources/flags/images/fo.png +0 -0
- package/src/components/Countries/resources/flags/images/fr.png +0 -0
- package/src/components/Countries/resources/flags/images/ga.png +0 -0
- package/src/components/Countries/resources/flags/images/gb.png +0 -0
- package/src/components/Countries/resources/flags/images/gd.png +0 -0
- package/src/components/Countries/resources/flags/images/ge.png +0 -0
- package/src/components/Countries/resources/flags/images/gf.png +0 -0
- package/src/components/Countries/resources/flags/images/gg.png +0 -0
- package/src/components/Countries/resources/flags/images/gh.png +0 -0
- package/src/components/Countries/resources/flags/images/gi.png +0 -0
- package/src/components/Countries/resources/flags/images/gm.png +0 -0
- package/src/components/Countries/resources/flags/images/gn.png +0 -0
- package/src/components/Countries/resources/flags/images/gp.png +0 -0
- package/src/components/Countries/resources/flags/images/gq.png +0 -0
- package/src/components/Countries/resources/flags/images/gr.png +0 -0
- package/src/components/Countries/resources/flags/images/gt.png +0 -0
- package/src/components/Countries/resources/flags/images/gu.png +0 -0
- package/src/components/Countries/resources/flags/images/gw.png +0 -0
- package/src/components/Countries/resources/flags/images/gy.png +0 -0
- package/src/components/Countries/resources/flags/images/hk.png +0 -0
- package/src/components/Countries/resources/flags/images/hn.png +0 -0
- package/src/components/Countries/resources/flags/images/hr.png +0 -0
- package/src/components/Countries/resources/flags/images/ht.png +0 -0
- package/src/components/Countries/resources/flags/images/hu.png +0 -0
- package/src/components/Countries/resources/flags/images/id.png +0 -0
- package/src/components/Countries/resources/flags/images/ie.png +0 -0
- package/src/components/Countries/resources/flags/images/il.png +0 -0
- package/src/components/Countries/resources/flags/images/im.png +0 -0
- package/src/components/Countries/resources/flags/images/in.png +0 -0
- package/src/components/Countries/resources/flags/images/io.png +0 -0
- package/src/components/Countries/resources/flags/images/iq.png +0 -0
- package/src/components/Countries/resources/flags/images/ir.png +0 -0
- package/src/components/Countries/resources/flags/images/is.png +0 -0
- package/src/components/Countries/resources/flags/images/it.png +0 -0
- package/src/components/Countries/resources/flags/images/je.png +0 -0
- package/src/components/Countries/resources/flags/images/jm.png +0 -0
- package/src/components/Countries/resources/flags/images/jo.png +0 -0
- package/src/components/Countries/resources/flags/images/jp.png +0 -0
- package/src/components/Countries/resources/flags/images/ke.png +0 -0
- package/src/components/Countries/resources/flags/images/kg.png +0 -0
- package/src/components/Countries/resources/flags/images/kh.png +0 -0
- package/src/components/Countries/resources/flags/images/ki.png +0 -0
- package/src/components/Countries/resources/flags/images/km.png +0 -0
- package/src/components/Countries/resources/flags/images/kn.png +0 -0
- package/src/components/Countries/resources/flags/images/kp.png +0 -0
- package/src/components/Countries/resources/flags/images/kr.png +0 -0
- package/src/components/Countries/resources/flags/images/ks.png +0 -0
- package/src/components/Countries/resources/flags/images/kw.png +0 -0
- package/src/components/Countries/resources/flags/images/ky.png +0 -0
- package/src/components/Countries/resources/flags/images/kz.png +0 -0
- package/src/components/Countries/resources/flags/images/la.png +0 -0
- package/src/components/Countries/resources/flags/images/lb.png +0 -0
- package/src/components/Countries/resources/flags/images/lc.png +0 -0
- package/src/components/Countries/resources/flags/images/li.png +0 -0
- package/src/components/Countries/resources/flags/images/lk.png +0 -0
- package/src/components/Countries/resources/flags/images/lr.png +0 -0
- package/src/components/Countries/resources/flags/images/ls.png +0 -0
- package/src/components/Countries/resources/flags/images/lt.png +0 -0
- package/src/components/Countries/resources/flags/images/lu.png +0 -0
- package/src/components/Countries/resources/flags/images/lv.png +0 -0
- package/src/components/Countries/resources/flags/images/ly.png +0 -0
- package/src/components/Countries/resources/flags/images/ma.png +0 -0
- package/src/components/Countries/resources/flags/images/mc.png +0 -0
- package/src/components/Countries/resources/flags/images/md.png +0 -0
- package/src/components/Countries/resources/flags/images/me.png +0 -0
- package/src/components/Countries/resources/flags/images/mf.png +0 -0
- package/src/components/Countries/resources/flags/images/mg.png +0 -0
- package/src/components/Countries/resources/flags/images/mh.png +0 -0
- package/src/components/Countries/resources/flags/images/mk.png +0 -0
- package/src/components/Countries/resources/flags/images/ml.png +0 -0
- package/src/components/Countries/resources/flags/images/mm.png +0 -0
- package/src/components/Countries/resources/flags/images/mn.png +0 -0
- package/src/components/Countries/resources/flags/images/mo.png +0 -0
- package/src/components/Countries/resources/flags/images/mp.png +0 -0
- package/src/components/Countries/resources/flags/images/mq.png +0 -0
- package/src/components/Countries/resources/flags/images/mr.png +0 -0
- package/src/components/Countries/resources/flags/images/ms.png +0 -0
- package/src/components/Countries/resources/flags/images/mt.png +0 -0
- package/src/components/Countries/resources/flags/images/mu.png +0 -0
- package/src/components/Countries/resources/flags/images/mv.png +0 -0
- package/src/components/Countries/resources/flags/images/mw.png +0 -0
- package/src/components/Countries/resources/flags/images/mx.png +0 -0
- package/src/components/Countries/resources/flags/images/my.png +0 -0
- package/src/components/Countries/resources/flags/images/mz.png +0 -0
- package/src/components/Countries/resources/flags/images/na.png +0 -0
- package/src/components/Countries/resources/flags/images/nc.png +0 -0
- package/src/components/Countries/resources/flags/images/ne.png +0 -0
- package/src/components/Countries/resources/flags/images/nf.png +0 -0
- package/src/components/Countries/resources/flags/images/ng.png +0 -0
- package/src/components/Countries/resources/flags/images/ni.png +0 -0
- package/src/components/Countries/resources/flags/images/nl.png +0 -0
- package/src/components/Countries/resources/flags/images/no.png +0 -0
- package/src/components/Countries/resources/flags/images/np.png +0 -0
- package/src/components/Countries/resources/flags/images/nr.png +0 -0
- package/src/components/Countries/resources/flags/images/nu.png +0 -0
- package/src/components/Countries/resources/flags/images/nz.png +0 -0
- package/src/components/Countries/resources/flags/images/om.png +0 -0
- package/src/components/Countries/resources/flags/images/pa.png +0 -0
- package/src/components/Countries/resources/flags/images/pe.png +0 -0
- package/src/components/Countries/resources/flags/images/pf.png +0 -0
- package/src/components/Countries/resources/flags/images/pg.png +0 -0
- package/src/components/Countries/resources/flags/images/ph.png +0 -0
- package/src/components/Countries/resources/flags/images/pk.png +0 -0
- package/src/components/Countries/resources/flags/images/pl.png +0 -0
- package/src/components/Countries/resources/flags/images/pm.png +0 -0
- package/src/components/Countries/resources/flags/images/pr.png +0 -0
- package/src/components/Countries/resources/flags/images/ps.png +0 -0
- package/src/components/Countries/resources/flags/images/pt.png +0 -0
- package/src/components/Countries/resources/flags/images/pw.png +0 -0
- package/src/components/Countries/resources/flags/images/py.png +0 -0
- package/src/components/Countries/resources/flags/images/qa.png +0 -0
- package/src/components/Countries/resources/flags/images/re.png +0 -0
- package/src/components/Countries/resources/flags/images/ro.png +0 -0
- package/src/components/Countries/resources/flags/images/rs.png +0 -0
- package/src/components/Countries/resources/flags/images/ru.png +0 -0
- package/src/components/Countries/resources/flags/images/rw.png +0 -0
- package/src/components/Countries/resources/flags/images/sa.png +0 -0
- package/src/components/Countries/resources/flags/images/sb.png +0 -0
- package/src/components/Countries/resources/flags/images/sc.png +0 -0
- package/src/components/Countries/resources/flags/images/sd.png +0 -0
- package/src/components/Countries/resources/flags/images/se.png +0 -0
- package/src/components/Countries/resources/flags/images/sg.png +0 -0
- package/src/components/Countries/resources/flags/images/sh.png +0 -0
- package/src/components/Countries/resources/flags/images/si.png +0 -0
- package/src/components/Countries/resources/flags/images/sj.png +0 -0
- package/src/components/Countries/resources/flags/images/sk.png +0 -0
- package/src/components/Countries/resources/flags/images/sl.png +0 -0
- package/src/components/Countries/resources/flags/images/sm.png +0 -0
- package/src/components/Countries/resources/flags/images/sn.png +0 -0
- package/src/components/Countries/resources/flags/images/so.png +0 -0
- package/src/components/Countries/resources/flags/images/sr.png +0 -0
- package/src/components/Countries/resources/flags/images/ss.png +0 -0
- package/src/components/Countries/resources/flags/images/st.png +0 -0
- package/src/components/Countries/resources/flags/images/sv.png +0 -0
- package/src/components/Countries/resources/flags/images/sx.png +0 -0
- package/src/components/Countries/resources/flags/images/sy.png +0 -0
- package/src/components/Countries/resources/flags/images/sz.png +0 -0
- package/src/components/Countries/resources/flags/images/tc.png +0 -0
- package/src/components/Countries/resources/flags/images/td.png +0 -0
- package/src/components/Countries/resources/flags/images/tg.png +0 -0
- package/src/components/Countries/resources/flags/images/th.png +0 -0
- package/src/components/Countries/resources/flags/images/tj.png +0 -0
- package/src/components/Countries/resources/flags/images/tk.png +0 -0
- package/src/components/Countries/resources/flags/images/tl.png +0 -0
- package/src/components/Countries/resources/flags/images/tm.png +0 -0
- package/src/components/Countries/resources/flags/images/tn.png +0 -0
- package/src/components/Countries/resources/flags/images/to.png +0 -0
- package/src/components/Countries/resources/flags/images/tr.png +0 -0
- package/src/components/Countries/resources/flags/images/tt.png +0 -0
- package/src/components/Countries/resources/flags/images/tv.png +0 -0
- package/src/components/Countries/resources/flags/images/tw.png +0 -0
- package/src/components/Countries/resources/flags/images/tz.png +0 -0
- package/src/components/Countries/resources/flags/images/ua.png +0 -0
- package/src/components/Countries/resources/flags/images/ug.png +0 -0
- package/src/components/Countries/resources/flags/images/us.png +0 -0
- package/src/components/Countries/resources/flags/images/uy.png +0 -0
- package/src/components/Countries/resources/flags/images/uz.png +0 -0
- package/src/components/Countries/resources/flags/images/va.png +0 -0
- package/src/components/Countries/resources/flags/images/vc.png +0 -0
- package/src/components/Countries/resources/flags/images/ve.png +0 -0
- package/src/components/Countries/resources/flags/images/vg.png +0 -0
- package/src/components/Countries/resources/flags/images/vi.png +0 -0
- package/src/components/Countries/resources/flags/images/vn.png +0 -0
- package/src/components/Countries/resources/flags/images/vu.png +0 -0
- package/src/components/Countries/resources/flags/images/wf.png +0 -0
- package/src/components/Countries/resources/flags/images/ws.png +0 -0
- package/src/components/Countries/resources/flags/images/ye.png +0 -0
- package/src/components/Countries/resources/flags/images/yt.png +0 -0
- package/src/components/Countries/resources/flags/images/za.png +0 -0
- package/src/components/Countries/resources/flags/images/zm.png +0 -0
- package/src/components/Countries/resources/flags/images/zw.png +0 -0
- package/src/components/Countries/resources/flags/index.js +255 -0
- package/src/components/Countries/utils.js +28 -0
- package/src/components/Datagrid/Accordion/AppleSwipeable.js +123 -0
- package/src/components/Datagrid/Accordion/Filters.js +186 -0
- package/src/components/Datagrid/Accordion/GmailSwipeable.js +85 -0
- package/src/components/Datagrid/Accordion/Row.js +295 -0
- package/src/components/Datagrid/Accordion/index.js +719 -0
- package/src/components/Datagrid/Accordion/utils.js +22 -0
- package/src/components/Datagrid/Actions/Header.js +58 -0
- package/src/components/Datagrid/Actions/index.js +104 -0
- package/src/components/Datagrid/Checkbox.js +40 -0
- package/src/components/Datagrid/Common/Common.js +1866 -0
- package/src/components/Datagrid/Common/TableData.js +245 -0
- package/src/components/Datagrid/Common/factory.js +9 -0
- package/src/components/Datagrid/Common/index.js +7 -0
- package/src/components/Datagrid/Common/session.js +20 -0
- package/src/components/Datagrid/Common/setQueryLimit.js +32 -0
- package/src/components/Datagrid/Footer/Footer.js +86 -0
- package/src/components/Datagrid/Footer/index.js +93 -0
- package/src/components/Datagrid/List.js +2 -0
- package/src/components/Datagrid/RenderType.js +53 -0
- package/src/components/Datagrid/RenderTypes/index.native.js +1 -0
- package/src/components/Datagrid/RenderTypes/index.web.js +10 -0
- package/src/components/Datagrid/RenderTypes/utils.js +5 -0
- package/src/components/Datagrid/Table/Cell.js +45 -0
- package/src/components/Datagrid/Table/Datatable.js +232 -0
- package/src/components/Datagrid/Table/index.js +446 -0
- package/src/components/Datagrid/Table/renderTable.js +664 -0
- package/src/components/Datagrid/factory.js +12 -0
- package/src/components/Datagrid/getComponent.js +26 -0
- package/src/components/Datagrid/index.js +43 -0
- package/src/components/Datagrid/utils.js +185 -0
- package/src/components/Date/DatePickerModal/index.js +10 -0
- package/src/components/Date/DatePickerModal/index.native.js +22 -0
- package/src/components/Date/PickerInput/TextInputMask.js +106 -0
- package/src/components/Date/PickerInput/index.js +253 -0
- package/src/components/Date/Time.js +154 -0
- package/src/components/Date/TimePickerModal/index.js +3 -0
- package/src/components/Date/TimePickerModal/index.native.js +21 -0
- package/src/components/Date/dictionary.js +26 -0
- package/src/components/Date/index.js +11 -0
- package/src/components/Date/utils.common.js +3 -0
- package/src/components/Date/utils.common.native.js +0 -0
- package/src/components/Date/utils.js +209 -0
- package/src/components/Dialog/AppBarDialog.js +41 -0
- package/src/components/Dialog/Dialog.js +377 -0
- package/src/components/Dialog/DialogActions.js +69 -0
- package/src/components/Dialog/DialogFooter.js +36 -0
- package/src/components/Dialog/DialogTitle.js +47 -0
- package/src/components/Dialog/DropdownAlert/Queue.js +28 -0
- package/src/components/Dialog/DropdownAlert/Utils.js +36 -0
- package/src/components/Dialog/DropdownAlert/assets/cancel.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/cancel@2x.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/cancel@3x.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/error.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/error@2x.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/error@3x.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/info.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/info@2x.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/info@3x.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/success.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/success@2x.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/success@3x.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/warn.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/warn@2x.png +0 -0
- package/src/components/Dialog/DropdownAlert/assets/warn@3x.png +0 -0
- package/src/components/Dialog/DropdownAlert/index.js +685 -0
- package/src/components/Dialog/Provider.js +75 -0
- package/src/components/Dialog/confirm/Alert/Alert.old/Alert.web.js +360 -0
- package/src/components/Dialog/confirm/Alert/Alert.old/index.js +2 -0
- package/src/components/Dialog/confirm/Alert/index.js +43 -0
- package/src/components/Dialog/confirm/index.js +12 -0
- package/src/components/Dialog/confirm/showConfirmOrAlertOrPrompt.js +145 -0
- package/src/components/Dialog/dialogs.js +70 -0
- package/src/components/Dialog/index.js +17 -0
- package/src/components/Dialog/showConfirmOrAlertOrPrompt.js +90 -0
- package/src/components/Dialog/style.css +103 -0
- package/src/components/Dialog/utils.js +33 -0
- package/src/components/Divider/index.js +44 -0
- package/src/components/Drawer/DrawerHeader.js +70 -0
- package/src/components/Drawer/DrawerItems/DrawerItem.js +88 -0
- package/src/components/Drawer/DrawerItems/DrawerSection.js +34 -0
- package/src/components/Drawer/DrawerItems/ExpandableItem.js +44 -0
- package/src/components/Drawer/DrawerItems/_DrawerItem.js +173 -0
- package/src/components/Drawer/DrawerItems/index.js +155 -0
- package/src/components/Drawer/DrawerItems/utils.js +107 -0
- package/src/components/Drawer/DrawerLayout/index.js +476 -0
- package/src/components/Drawer/NavigationView.js +90 -0
- package/src/components/Drawer/Provider.js +6 -0
- package/src/components/Drawer/index.js +455 -0
- package/src/components/Drawer/session.js +28 -0
- package/src/components/Drawer/utils.js +39 -0
- package/src/components/Dropdown/index.js +1317 -0
- package/src/components/Dropdown/utils.js +19 -0
- package/src/components/ErrorBoundary/ErrorMessage.js +107 -0
- package/src/components/ErrorBoundary/Provider.js +68 -0
- package/src/components/ErrorBoundary/index.js +64 -0
- package/src/components/Expandable/Item.js +159 -0
- package/src/components/Expandable/index.js +229 -0
- package/src/components/Fab/Fab.js +46 -0
- package/src/components/Fab/Group.js +143 -0
- package/src/components/Fab/GroupComponent.js +384 -0
- package/src/components/Fab/index.js +8 -0
- package/src/components/FadeInOut/index.js +70 -0
- package/src/components/Filter/filterTextTypes.js +1 -0
- package/src/components/Filter/index.js +570 -0
- package/src/components/Filter/session.js +18 -0
- package/src/components/Filter/utils.js +289 -0
- package/src/components/Form/Action.js +112 -0
- package/src/components/Form/Fields/Checkbox.js +29 -0
- package/src/components/Form/Fields/Color.js +21 -0
- package/src/components/Form/Fields/Date.js +24 -0
- package/src/components/Form/Fields/Field.js +1048 -0
- package/src/components/Form/Fields/Html.js +21 -0
- package/src/components/Form/Fields/IdField.js +131 -0
- package/src/components/Form/Fields/Image.js +65 -0
- package/src/components/Form/Fields/PieceField.js +143 -0
- package/src/components/Form/Fields/Radio.js +31 -0
- package/src/components/Form/Fields/SelectCountry.js +12 -0
- package/src/components/Form/Fields/SelectField.js +147 -0
- package/src/components/Form/Fields/SelectStructData.js +24 -0
- package/src/components/Form/Fields/SelectTableData.js +24 -0
- package/src/components/Form/Fields/SelectTheme.js +11 -0
- package/src/components/Form/Fields/Slider.js +32 -0
- package/src/components/Form/Fields/Switch.js +34 -0
- package/src/components/Form/Fields/Tel.js +21 -0
- package/src/components/Form/Fields/TextField.js +44 -0
- package/src/components/Form/Fields/Time.js +28 -0
- package/src/components/Form/Fields/index.js +52 -0
- package/src/components/Form/Fields/selectPromptField.js +59 -0
- package/src/components/Form/Fields/sprintf.js +42 -0
- package/src/components/Form/Fields/sprintfSelectors.js +117 -0
- package/src/components/Form/Fields/utils.js +8 -0
- package/src/components/Form/Form.js +221 -0
- package/src/components/Form/FormData/Dialog.js +116 -0
- package/src/components/Form/FormData/DialogProvider.js +117 -0
- package/src/components/Form/FormData/FormData.js +403 -0
- package/src/components/Form/FormData/FormDataActions.js +155 -0
- package/src/components/Form/FormData/componentsTypes.js +117 -0
- package/src/components/Form/FormData/index.js +15 -0
- package/src/components/Form/FormData/utils.js +111 -0
- package/src/components/Form/KeyboardAvoidingView.js +23 -0
- package/src/components/Form/KeyboardEventHandler/index.js +115 -0
- package/src/components/Form/KeyboardEventHandler/keyEvents.js +139 -0
- package/src/components/Form/KeyboardEventHandler/readMe.md +1 -0
- package/src/components/Form/List/List.js +794 -0
- package/src/components/Form/List/index.js +2 -0
- package/src/components/Form/index.js +14 -0
- package/src/components/Form/utils/FormsManager.js +101 -0
- package/src/components/Form/utils/index.js +8 -0
- package/src/components/Form/utils/keyboardEvents.js +8 -0
- package/src/components/Form/utils/keyboardShortcuts.js +57 -0
- package/src/components/Grid/Cell.js +108 -0
- package/src/components/Grid/Col.js +30 -0
- package/src/components/Grid/Grid.js +35 -0
- package/src/components/Grid/Row.js +30 -0
- package/src/components/Grid/index.js +11 -0
- package/src/components/Hashtag/index.js +119 -0
- package/src/components/HeavyScreen/index.js +52 -0
- package/src/components/HeavyScreen/utils.js +36 -0
- package/src/components/HelperText/index.js +36 -0
- package/src/components/Html/AutoSizedImage.js +56 -0
- package/src/components/Html/HtmlToElement.js +173 -0
- package/src/components/Html/View.js +166 -0
- package/src/components/Icon/Checkbox.js +83 -0
- package/src/components/Icon/CrossFadeIcon.js +133 -0
- package/src/components/Icon/Icon.js +52 -0
- package/src/components/Icon/IconButton.js +155 -0
- package/src/components/Icon/MaterialCommunityIcon.js +93 -0
- package/src/components/Icon/index.js +10 -0
- package/src/components/Icon/utils.js +15 -0
- package/src/components/Image/Editor/index copy.js +42 -0
- package/src/components/Image/Editor/index.js +52 -0
- package/src/components/Image/index.js +309 -0
- package/src/components/InlineIndicator/Select.js +58 -0
- package/src/components/InlineIndicator/index.js +156 -0
- package/src/components/Label/index.js +104 -0
- package/src/components/Link/Browser.js +17 -0
- package/src/components/Link/getUrlCallback.js +10 -0
- package/src/components/Link/index.js +38 -0
- package/src/components/List/BigList.js +44 -0
- package/src/components/List/Common.js +233 -0
- package/src/components/List/FlashList.js +29 -0
- package/src/components/List/FlatList.js +34 -0
- package/src/components/List/RecyclerView.js +83 -0
- package/src/components/List/index.js +12 -0
- package/src/components/List/utils.js +23 -0
- package/src/components/Logo/Logo.js +98 -0
- package/src/components/Logo/Progress.js +21 -0
- package/src/components/Logo/index.js +3 -0
- package/src/components/Menu/Item.js +203 -0
- package/src/components/Menu/Menu.js +590 -0
- package/src/components/Menu/index.js +118 -0
- package/src/components/Menu/utils.js +81 -0
- package/src/components/Modal/index.js +212 -0
- package/src/components/NewLine/index.js +4 -0
- package/src/components/NewLine/index.web.js +3 -0
- package/src/components/Paragraph/index.js +32 -0
- package/src/components/PasswordText/index.js +29 -0
- package/src/components/PhoneInput/PhoneNumber.js +121 -0
- package/src/components/PhoneInput/country.js +54 -0
- package/src/components/PhoneInput/index.js +217 -0
- package/src/components/PhoneInput/numberType.json +14 -0
- package/src/components/PhoneInput/styles.js +52 -0
- package/src/components/Portal/index.js +5 -0
- package/src/components/Preloader/index.js +227 -0
- package/src/components/Progress/LoadingDots.js +126 -0
- package/src/components/Progress/index.js +18 -0
- package/src/components/Radio/index.js +164 -0
- package/src/components/ReadMoreText/index.js +120 -0
- package/src/components/ScrollView/index.js +34 -0
- package/src/components/Signature/Panel.js +246 -0
- package/src/components/Signature/index.js +69 -0
- package/src/components/SimpleSelect/index.js +483 -0
- package/src/components/Slider/Slider.js +770 -0
- package/src/components/Slider/index.js +144 -0
- package/src/components/Slider/styles.js +39 -0
- package/src/components/SplashScreen/index.js +194 -0
- package/src/components/SplashScreen/styles.js +74 -0
- package/src/components/StatusBar/Component/index.js +5 -0
- package/src/components/StatusBar/Component/index.web.js +88 -0
- package/src/components/StatusBar/index.js +7 -0
- package/src/components/Surface/Elevations.js +218 -0
- package/src/components/Surface/index.js +22 -0
- package/src/components/Swipeable/Swipe.js +225 -0
- package/src/components/Swipeable/SwipeableGesture.js +77 -0
- package/src/components/Swipeable/index.js +5 -0
- package/src/components/Swiper/Controls.js +277 -0
- package/src/components/Swiper/index.js +463 -0
- package/src/components/Swiper/nodeType.js +8 -0
- package/src/components/Swiper/renderNode.js +21 -0
- package/src/components/Switch/index.js +172 -0
- package/src/components/Tab/TabContent.js +72 -0
- package/src/components/Tab/TabItem.js +112 -0
- package/src/components/Tab/TabItems.js +246 -0
- package/src/components/Tab/index.js +114 -0
- package/src/components/Table/index.js +383 -0
- package/src/components/TextField/Affix.js +18 -0
- package/src/components/TextField/index.js +749 -0
- package/src/components/TextField/utils.js +64 -0
- package/src/components/Tooltip/Popover/index.js +254 -0
- package/src/components/Tooltip/Popover/index.web.js +60 -0
- package/src/components/Tooltip/index.js +42 -0
- package/src/components/TouchableRipple/index.js +0 -0
- package/src/components/View/index.js +49 -0
- package/src/components/WebView/Component/index.native.js +2 -0
- package/src/components/WebView/Component/index.web.js +154 -0
- package/src/components/WebView/Component/postMock.html +21 -0
- package/src/components/WebView/index.js +79 -0
- package/src/index.js +166 -0
- package/src/layouts/AppBar/index.js +59 -0
- package/src/layouts/AppBar/utils.js +12 -0
- package/src/layouts/Fab/actions.js +5 -0
- package/src/layouts/Fab/index.js +60 -0
- package/src/layouts/Fab/utils.js +25 -0
- package/src/layouts/Footer/index.js +8 -0
- package/src/layouts/Screen/FormData/FormData.js +103 -0
- package/src/layouts/Screen/FormData/List.js +83 -0
- package/src/layouts/Screen/FormData/index.js +3 -0
- package/src/layouts/Screen/Screen.js +173 -0
- package/src/layouts/Screen/index.js +11 -0
- package/src/media/Assets/index.js +6 -0
- package/src/media/Assets/utils.js +28 -0
- package/src/media/camera.js +1 -0
- package/src/media/camera.native.js +4 -0
- package/src/media/camera.web.js +9 -0
- package/src/media/file-system/index.js +20 -0
- package/src/media/file-system/utils/index.js +32 -0
- package/src/media/file-system/utils/utils.js +0 -0
- package/src/media/file-system/utils.native/index.js +1 -0
- package/src/media/index.js +137 -0
- package/src/navigation/Drawer/ProfilAvatar/defaultAvatar.js +1 -0
- package/src/navigation/Drawer/ProfilAvatar/index.js +142 -0
- package/src/navigation/Drawer/ProfilAvatar/style.css +18 -0
- package/src/navigation/Drawer/index.js +81 -0
- package/src/navigation/Drawer/items/SidebarFeedsItems.js +0 -0
- package/src/navigation/Drawer/items/SyncDataItem.js +20 -0
- package/src/navigation/Drawer/items/index.js +23 -0
- package/src/navigation/Drawer/items/items.js +31 -0
- package/src/navigation/Drawer/utils.js +18 -0
- package/src/navigation/index.js +45 -0
- package/src/navigation/utils.js +1 -0
- package/src/screens/Auth/index.js +31 -0
- package/src/screens/Auth/routes.js +9 -0
- package/src/screens/Auth/utils.js +5 -0
- package/src/screens/index.js +201 -0
- package/src/screens/mainScreens.js +4 -0
- package/src/screens/utils.js +13 -0
- package/webpack.config.js +31 -0
- package/workflows/release-package.yml +33 -0
|
@@ -0,0 +1,1317 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import View from "$ecomponents/View";
|
|
3
|
+
import {Dimensions,TouchableOpacity,StyleSheet,Animated,} from "react-native";
|
|
4
|
+
import {TouchableRipple} from "react-native-paper";
|
|
5
|
+
import Divider from "$ecomponents/Divider";
|
|
6
|
+
import React, {Fragment,Component as AppComponent} from "$react";
|
|
7
|
+
import theme,{Colors} from "$theme";
|
|
8
|
+
import Dialog from "$ecomponents/Dialog";
|
|
9
|
+
import {isMobileOrTabletMedia} from "$cplatform/dimensions";
|
|
10
|
+
import {isIos} from "$cplatform";
|
|
11
|
+
import {defaultVal,defaultStr,defaultObj,defaultBool,defaultFunc,debounce,isNonNullString,compare as NCompare} from "$utils";
|
|
12
|
+
import MenuComponent from "$ecomponents/Menu";
|
|
13
|
+
import HelperText from "$ecomponents/HelperText";
|
|
14
|
+
import TextField,{flatMode} from "$ecomponents/TextField";
|
|
15
|
+
import List,{MIN_HEIGHT,BigList} from "$ecomponents/List";
|
|
16
|
+
import Icon,{ICON_SIZE,ICON_OFFSET,MORE_ICON} from "$ecomponents/Icon";
|
|
17
|
+
import Label from "$ecomponents/Label";
|
|
18
|
+
import { matchOperators,getSearchTimeout,canAutoFocusSearchField} from "./utils";
|
|
19
|
+
import { ProgressBar,ActivityIndicator} from 'react-native-paper';
|
|
20
|
+
import Menu from "$ecomponents/Menu/Menu";
|
|
21
|
+
import Chip from "$ecomponents/Chip";
|
|
22
|
+
import {Content as BottomSheet,Menu as BottomSheetMenu,getContentHeight} from "$ecomponents/BottomSheet";
|
|
23
|
+
import {isWeb} from "$cplatform";
|
|
24
|
+
|
|
25
|
+
const _isIos = isIos();
|
|
26
|
+
|
|
27
|
+
const MAX_SELECTED_ITEMS = 2;
|
|
28
|
+
|
|
29
|
+
export const isValidValueKey = valueKey => isNonNullString(valueKey);
|
|
30
|
+
|
|
31
|
+
class DropdownComponent extends AppComponent {
|
|
32
|
+
constructor(props){
|
|
33
|
+
super(props);
|
|
34
|
+
const {getValueKey,getItemKey,visible,renderItem,multiple,defaultValue,selected,compare,itemValue,getItemValue} = props;
|
|
35
|
+
this.keysRefs = [];
|
|
36
|
+
Object.defineProperties(this,{
|
|
37
|
+
fieldsToSort : {
|
|
38
|
+
value : this.prepareSortableFields(),override : false, writable : false,
|
|
39
|
+
},
|
|
40
|
+
getItemKey : {value : typeof getItemKey =='function' ? getItemKey: (item,index)=>React.key(item,index),override:false,writable:false},
|
|
41
|
+
getValueKey : {
|
|
42
|
+
value : typeof getValueKey =='function'? getValueKey : (value,warn)=>{
|
|
43
|
+
const backValue = value;
|
|
44
|
+
if(typeof value ==='boolean' || typeof value =='string' || typeof value =='number'){
|
|
45
|
+
value = value+"";
|
|
46
|
+
} else {
|
|
47
|
+
if(warn === true){
|
|
48
|
+
console.warn("You must specify key value for value for dropdown component",backValue,props);
|
|
49
|
+
}
|
|
50
|
+
if(isObj(value)){
|
|
51
|
+
value = JSON.stringify(value);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return isValidValueKey(value)? value : "";
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
renderItem : {
|
|
58
|
+
value : typeof renderItem =='function'? renderItem : ({item,index}) =>{
|
|
59
|
+
if(React.isValidElement(item,true) || isDecimal(item) || typeof item =='boolean') return item;
|
|
60
|
+
if(isObj(item) ) {
|
|
61
|
+
const itemLabel = this.props.itemLabel;
|
|
62
|
+
if(isNonNullString(itemLabel) && item.hasOwnProperty(itemLabel)) return item[itemLabel];
|
|
63
|
+
if(isNonNullString(item.label)) return item.label;
|
|
64
|
+
return defaultStr(item.text,item[index]);
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
},override : false, writable : false
|
|
68
|
+
},
|
|
69
|
+
getItemValue : {
|
|
70
|
+
value : typeof itemValue =='function'? itemValue : typeof getItemValue =='function'? getItemValue : ({item,index}) =>{
|
|
71
|
+
if((isObj(item) && item.hasOwnProperty('code'))){
|
|
72
|
+
return item.code;
|
|
73
|
+
}
|
|
74
|
+
return index;
|
|
75
|
+
}, override : false, writable : false
|
|
76
|
+
},
|
|
77
|
+
canHandleMultiple : {
|
|
78
|
+
value : typeof multiple =='boolean'? multiple : false,
|
|
79
|
+
override : false, writable : false,
|
|
80
|
+
},
|
|
81
|
+
isBigList : {
|
|
82
|
+
value : multiple || this.props.dynamicContent ? true : false,
|
|
83
|
+
override : false,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
extendObj(this.state,this.prepareItems());
|
|
88
|
+
|
|
89
|
+
extendObj(this.state,{
|
|
90
|
+
initialized : false,
|
|
91
|
+
filterText : "",
|
|
92
|
+
anchorHeight : undefined,
|
|
93
|
+
isMobileMedia : isMobileOrTabletMedia(),
|
|
94
|
+
layout : {
|
|
95
|
+
height: 0,
|
|
96
|
+
width: 0,
|
|
97
|
+
},
|
|
98
|
+
visible : typeof visible ==='boolean'? visible : false,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
this.anchorRef = React.createRef(null);
|
|
102
|
+
this.inputRef = React.createRef(null);
|
|
103
|
+
this.listRef = React.createRef(null);
|
|
104
|
+
}
|
|
105
|
+
updateSelected (nState,force){
|
|
106
|
+
nState = defaultObj(nState);
|
|
107
|
+
//this.countEee = defaultNumber(this.countEee)+1;
|
|
108
|
+
if(!("selectedText" in nState)){
|
|
109
|
+
nState.selectedText = this.getSelectedText(nState.selected,nState.selectedValuesKeys);
|
|
110
|
+
}
|
|
111
|
+
const previousSelected = this.state.selected;
|
|
112
|
+
const prevValueKey = this.getValueKey(previousSelected);
|
|
113
|
+
const prevItem = prevValueKey ? this.state.valuesKeys[prevValueKey] : null;
|
|
114
|
+
//if(this.countEee ===5) return
|
|
115
|
+
//console.log(previousSelected,nState,prevItem," is dhcdddddd comparing")
|
|
116
|
+
return this.setState(nState,()=>{
|
|
117
|
+
///vérifie s'il y a eu changement call on change par exemple
|
|
118
|
+
let selectedItem = null;
|
|
119
|
+
const valueKey = this.getValueKey(this.state.selected);
|
|
120
|
+
if(this.state.initialized && !force){
|
|
121
|
+
if(!this.canHandleMultiple){
|
|
122
|
+
if(valueKey && this.state.valuesKeys[valueKey]){
|
|
123
|
+
selectedItem = this.state.valuesKeys[valueKey].item;
|
|
124
|
+
}
|
|
125
|
+
if(this.compare(previousSelected,this.state.selected) && selectedItem && prevItem) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
if(previousSelected === this.state.selected && previousSelected && prevItem) return;
|
|
130
|
+
if(previousSelected.length == this.state.selected.length){
|
|
131
|
+
if(!this.state.selected.length) return;
|
|
132
|
+
let areEquals = true;
|
|
133
|
+
for(let i in this.state.selected){
|
|
134
|
+
let found = false;
|
|
135
|
+
/*** pour chacune des nouvelles valeurs on vérifie s'il existe dans les précédentes valeurs */
|
|
136
|
+
for(let j in previousSelected){
|
|
137
|
+
if(this.compare(previousSelected[j],this.state.selected[i])){
|
|
138
|
+
found = true;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/*** si on a pas trouvé alors les valeurs sont différentes */
|
|
143
|
+
if(!found){
|
|
144
|
+
areEquals = false;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if(areEquals) return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if(this.props.onChange){
|
|
153
|
+
this.props.onChange({value:this.state.selected,selectedKey:valueKey,selectedItems : this.getSelectedItems(),selectedItem,item:selectedItem,items:this.state.data});
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
selectItem ({value,select,valueKey}){
|
|
158
|
+
let selected = this.canHandleMultiple ? [...this.state.selected] : undefined;
|
|
159
|
+
let selectedValuesKeys = {...this.state.selectedValuesKeys};
|
|
160
|
+
if(this.canHandleMultiple){
|
|
161
|
+
if(!select){
|
|
162
|
+
if(valueKey in selectedValuesKeys){
|
|
163
|
+
const newS = [];
|
|
164
|
+
delete selectedValuesKeys[valueKey];
|
|
165
|
+
for(let i in selected){
|
|
166
|
+
const vKey = this.getValueKey(selected[i]);
|
|
167
|
+
if(vKey && vKey !== valueKey){
|
|
168
|
+
newS.push(selected[i]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
selected = newS;
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
if(!(valueKey in selectedValuesKeys)){
|
|
175
|
+
selectedValuesKeys[valueKey] = true;
|
|
176
|
+
selected.push(value);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
selected = select ? value : undefined;
|
|
181
|
+
selectedValuesKeys = {};
|
|
182
|
+
if(select){
|
|
183
|
+
selectedValuesKeys[valueKey] = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
this.willHandleFilter = false;
|
|
187
|
+
let nState = {};
|
|
188
|
+
if(!this.canHandleMultiple){
|
|
189
|
+
nState.visible = false;
|
|
190
|
+
}
|
|
191
|
+
this.updateSelected({...nState,data:!this.isBigList?[...this.state.data]: this.state.data,selected,selectedValuesKeys});
|
|
192
|
+
}
|
|
193
|
+
compare (value,currentValue,avoidNullOrEmpty){
|
|
194
|
+
if(this.getValueKey(value) === this.getValueKey(currentValue)) return true;
|
|
195
|
+
if(typeof this.props.compare =='function'){
|
|
196
|
+
return this.props.compare(value,currentValue,{context:this,items:this.state.data})
|
|
197
|
+
}
|
|
198
|
+
return NCompare(value,currentValue,defaultBool(avoidNullOrEmpty,true));
|
|
199
|
+
}
|
|
200
|
+
getCallArgs ({item,items,index,_index,...rest}) {
|
|
201
|
+
return ({...rest,item,index,_index,counterIndex:_index,index,itemIndex:index,context:this,isDropdown:true,props:this.props,items,selectedColor:this.selectedColor,unselectedColor:theme.colors.text});
|
|
202
|
+
}
|
|
203
|
+
isSelected (currentValue,valueKey,forceCheck,currentSelected){
|
|
204
|
+
if(valueKey && forceCheck !== true){
|
|
205
|
+
return valueKey in this.state.selectedValuesKeys ? true : false;
|
|
206
|
+
}
|
|
207
|
+
if(this.canHandleMultiple) {
|
|
208
|
+
currentSelected = Array.isArray(currentSelected)? currentSelected : this.state.selected;
|
|
209
|
+
for(let i in currentSelected){
|
|
210
|
+
if(this.compare(currentValue,currentSelected[i])) return true;
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
} else {
|
|
214
|
+
return this.compare(currentValue,forceCheck?currentSelected:this.state.selected);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
prepareSelected({defaultValue}){
|
|
218
|
+
let s = defaultValue !== undefined ? defaultValue : undefined;
|
|
219
|
+
if(this.canHandleMultiple){
|
|
220
|
+
if(isNonNullString(s)){
|
|
221
|
+
s = s.split(",");//si c'est un tableau, ça doit être séparé de virgule
|
|
222
|
+
} else {
|
|
223
|
+
s = Array.isArray(s)? s : Object.toArray(s);
|
|
224
|
+
}
|
|
225
|
+
return Array.isArray(s)? s : [];
|
|
226
|
+
}
|
|
227
|
+
return s;
|
|
228
|
+
}
|
|
229
|
+
getNode({item,key,index,name,_index,callArgs}){
|
|
230
|
+
let content = this.renderItem(callArgs);
|
|
231
|
+
const renderText = this.props.renderText;
|
|
232
|
+
let text = React.getTextContent(typeof renderText ==='function'? renderText(callArgs) : undefined);
|
|
233
|
+
if(content && !text){
|
|
234
|
+
text = React.getTextContent(content);
|
|
235
|
+
} else if(!content || !React.isValidElement(content,true)){
|
|
236
|
+
content = text;
|
|
237
|
+
}
|
|
238
|
+
if(!React.isValidElement(content,true) || !content) {
|
|
239
|
+
if(isWeb() || isObj(item)){
|
|
240
|
+
console.warn(content," is not valid element of dropdown name ",name,content,this.props,callArgs);
|
|
241
|
+
}
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
item,
|
|
246
|
+
key,
|
|
247
|
+
index,
|
|
248
|
+
_index,
|
|
249
|
+
text : React.getTextContent(text),
|
|
250
|
+
textContent : React.getTextContent(content),
|
|
251
|
+
content,
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
getSelectedText (selectedValues,selectedValuesKeys,valuesKeys){
|
|
255
|
+
let counter = 0,sDText = "";
|
|
256
|
+
selectedValuesKeys = isObj(selectedValuesKeys)? selectedValuesKeys : isObj(this.state.selectedValuesKeys) ? this.state.selectedValuesKeys: {};
|
|
257
|
+
selectedValues = selectedValues !== undefined ? selectedValues : this.state.selected;
|
|
258
|
+
valuesKeys = isObj(valuesKeys) && Object.size(valuesKeys,true)? valuesKeys : isObj(this.state.valuesKeys)? this.state.valuesKeys: {};
|
|
259
|
+
const maxCount = MAX_SELECTED_ITEMS;
|
|
260
|
+
for(let valueKey in selectedValuesKeys){
|
|
261
|
+
if(isObj(valuesKeys[valueKey])){
|
|
262
|
+
const node = valuesKeys[valueKey];
|
|
263
|
+
/*if(this.props.dynamicContent){
|
|
264
|
+
node = this.getNode({...node,callArgs:this.getCallArgs({...node,items:this.getItemsData()})});
|
|
265
|
+
}*/
|
|
266
|
+
const text = node.text;
|
|
267
|
+
if(!this.canHandleMultiple){
|
|
268
|
+
sDText = text;
|
|
269
|
+
} else {
|
|
270
|
+
|
|
271
|
+
counter++;
|
|
272
|
+
if(counter <= maxCount){
|
|
273
|
+
sDText+= (sDText?", ":"")+text;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if(this.canHandleMultiple && counter > maxCount && sDText){
|
|
279
|
+
sDText+= ", et "+((counter-maxCount).formatNumber()+" de plus")
|
|
280
|
+
}
|
|
281
|
+
return sDText;
|
|
282
|
+
}
|
|
283
|
+
pushSelectedValue(value,selectedStateValue){
|
|
284
|
+
if(this.canHandleMultiple){
|
|
285
|
+
selectedStateValue = Array.isArray(selectedStateValue)?selectedStateValue : [];
|
|
286
|
+
selectedStateValue.push(value);
|
|
287
|
+
return selectedStateValue;
|
|
288
|
+
}
|
|
289
|
+
return value;
|
|
290
|
+
}
|
|
291
|
+
getItemsData(args){
|
|
292
|
+
args = defaultObj(args);
|
|
293
|
+
const itDatata = args.items ? args.items : this.props.items;
|
|
294
|
+
const itemsData = typeof itDatata =='function'? itDatata(this.props) : itDatata;
|
|
295
|
+
return itemsData;
|
|
296
|
+
}
|
|
297
|
+
prepareItems (args){
|
|
298
|
+
args = defaultObj(args);
|
|
299
|
+
const nodes = {};
|
|
300
|
+
const data = [];
|
|
301
|
+
const keys = [];
|
|
302
|
+
const valuesKeys = {};
|
|
303
|
+
const {filter} = this.props;
|
|
304
|
+
const currentSelected = this.prepareSelected({defaultValue:this.props.defaultValue,...args});
|
|
305
|
+
let selected = this.canHandleMultiple ? []:undefined,selectedValuesKeys={};
|
|
306
|
+
const itemProps = defaultObj(this.props.itemProps);
|
|
307
|
+
const itemsData = this.getItemsData(args);
|
|
308
|
+
Object.map(itemsData,(item,index,_index)=>{
|
|
309
|
+
const key = this.getItemKey(item,index);
|
|
310
|
+
const callArgs = this.getCallArgs({item,items:itemsData,index,_index});
|
|
311
|
+
const node = this.getNode({item,key,itemProps,index,_index,callArgs})
|
|
312
|
+
if(!node) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
node.value = this.getItemValue(callArgs);
|
|
316
|
+
const valueKey = this.getValueKey(node.value);
|
|
317
|
+
if(!valueKey) {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
nodes[key] = node;
|
|
321
|
+
node.valueKey = valueKey;
|
|
322
|
+
valuesKeys[valueKey] = node;
|
|
323
|
+
if(filter && filter({...callArgs,...nodes[key]}) === false){
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
if(typeof index =='number'){
|
|
327
|
+
_index = index;
|
|
328
|
+
}
|
|
329
|
+
if(this.isSelected(node.value,valueKey,true,currentSelected)){
|
|
330
|
+
selected = this.pushSelectedValue(node.value,selected);
|
|
331
|
+
selectedValuesKeys[valueKey] = true;
|
|
332
|
+
} else {
|
|
333
|
+
delete selectedValuesKeys[valueKey];
|
|
334
|
+
}
|
|
335
|
+
data.push(item);
|
|
336
|
+
keys.push(key);
|
|
337
|
+
});
|
|
338
|
+
return ({selected,selectedValuesKeys,currentSelected,selectedText:this.getSelectedText(selected,selectedValuesKeys,valuesKeys),valuesKeys,nodes,valuesKeys,data,keys,initialized:true});
|
|
339
|
+
}
|
|
340
|
+
getDefaultValue(){
|
|
341
|
+
return this.state.currentSelected;
|
|
342
|
+
}
|
|
343
|
+
getNodeFromValue (value){
|
|
344
|
+
const vKey= this.getValueKey(value);
|
|
345
|
+
if(!vKey || !isObj(this.state.valuesKeys[vKey])){
|
|
346
|
+
return {};
|
|
347
|
+
}
|
|
348
|
+
return {valueKey:vKey,node:this.state.valuesKeys[vKey]};
|
|
349
|
+
}
|
|
350
|
+
/**** selectionne la valeur passée en paramètre
|
|
351
|
+
* @param value {any} : la valeur à sélectionner
|
|
352
|
+
* @param selectOnlyOneOne {boolean} spécifie si seul la valeur en question sera sélectionnée
|
|
353
|
+
*/
|
|
354
|
+
selectValue (value,selectOnlyOne) {
|
|
355
|
+
let hasChanged = false;
|
|
356
|
+
selectOnlyOne = selectOnlyOne === true ? true : false;
|
|
357
|
+
let newSelected = undefined;
|
|
358
|
+
if(this.canHandleMultiple){
|
|
359
|
+
newSelected = selectOnlyOne ? [] : [...this.state.selected];
|
|
360
|
+
}
|
|
361
|
+
const selectedValuesKeys = selectOnlyOne?{}:{...this.state.selectedValuesKeys};
|
|
362
|
+
const sVal = this.prepareSelected({defaultValue:value});
|
|
363
|
+
if(this.canHandleMultiple){
|
|
364
|
+
if(sVal.length !== this.state.selected.length){
|
|
365
|
+
hasChanged = true;
|
|
366
|
+
}
|
|
367
|
+
for(let k in sVal){
|
|
368
|
+
const cVal = sVal[k];
|
|
369
|
+
const keyNode = this.getNodeFromValue(cVal);
|
|
370
|
+
if(!keyNode.valueKey) continue;
|
|
371
|
+
if(!selectedValuesKeys[keyNode.valueKey]){
|
|
372
|
+
newSelected.push(cVal);
|
|
373
|
+
hasChanged = true;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
} else {
|
|
377
|
+
const keyNode = this.getNodeFromValue(value);
|
|
378
|
+
if(!keyNode.valueKey) return;
|
|
379
|
+
if(!selectedValuesKeys[keyNode.valueKey]){
|
|
380
|
+
newSelected = value;
|
|
381
|
+
hasChanged = true;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if(hasChanged){
|
|
385
|
+
this.updateSelected({selected:newSelected,selectedValuesKeys})
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
selectAll (){
|
|
390
|
+
if(!this.canHandleMultiple) return;
|
|
391
|
+
const newSelected = [],selectedValuesKeys={};
|
|
392
|
+
this.state.data.map((item,_index)=>{
|
|
393
|
+
const key = this.keysRefs[_index];
|
|
394
|
+
if(!this.state.nodes[key]) return;
|
|
395
|
+
newSelected.push(this.state.nodes[key].value);
|
|
396
|
+
selectedValuesKeys[this.state.nodes[key].valueKey] = true;
|
|
397
|
+
});
|
|
398
|
+
this.updateSelected({selected:newSelected,selectedValuesKeys,selectedText:this.getSelectedText(newSelected,selectedValuesKeys)});
|
|
399
|
+
}
|
|
400
|
+
unselectAll() {
|
|
401
|
+
if(!this.canHandleMultiple) return;
|
|
402
|
+
this.updateSelected({selected:[],selectedValuesKeys:{},selectedText:''})
|
|
403
|
+
}
|
|
404
|
+
unselect (oState){
|
|
405
|
+
this.updateSelected({...defaultObj(oState),selected:this.canHandleMultiple ?[]:undefined,selectedValuesKeys:{},selectedText:""});
|
|
406
|
+
}
|
|
407
|
+
getSelectedValue (){
|
|
408
|
+
return this.getSelected();
|
|
409
|
+
}
|
|
410
|
+
getSelected (){
|
|
411
|
+
return this.state.selected;
|
|
412
|
+
}
|
|
413
|
+
getSelectedItems (){
|
|
414
|
+
let ret = {};
|
|
415
|
+
if(this.canHandleMultiple){
|
|
416
|
+
Object.map(this.state.selected,(value)=>{
|
|
417
|
+
const nodeKey = this.getNodeFromValue(value);
|
|
418
|
+
if(!nodeKey.valueKey) return;
|
|
419
|
+
const node = nodeKey.node;
|
|
420
|
+
ret[node.key] = node.item;
|
|
421
|
+
})
|
|
422
|
+
return ret;
|
|
423
|
+
} else {
|
|
424
|
+
const nodeKey = this.getNodeFromValue(this.state.selected);
|
|
425
|
+
if(!nodeKey.valueKey) return {};
|
|
426
|
+
const node = nodeKey.node;
|
|
427
|
+
return {[node.key]:node.item};
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
refresh = (force,cb)=>{
|
|
431
|
+
if(isObj(this.props.context) && typeof this.props.context.refresh === "function"){
|
|
432
|
+
return this.props.context.refresh (force,cb);
|
|
433
|
+
}
|
|
434
|
+
if(force === true) {
|
|
435
|
+
this.setState(this.prepareItems(),cb)
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
this.setState({sk:!this.state.sk},cb);
|
|
439
|
+
}
|
|
440
|
+
isSortable(){
|
|
441
|
+
return false && isObj(this.fieldsToSort)? true : false;
|
|
442
|
+
}
|
|
443
|
+
prepareSortableFields (){
|
|
444
|
+
let _sortFields = {},sortableFields = this.props.sortableFields;
|
|
445
|
+
let hasSortableFields = false;
|
|
446
|
+
if(isObj(sortableFields)){
|
|
447
|
+
Object.map(sortableFields,(sF,i)=>{
|
|
448
|
+
if(isNonNullString(sF)){
|
|
449
|
+
_sortFields[i] = sF;
|
|
450
|
+
hasSortableFields = true;
|
|
451
|
+
}
|
|
452
|
+
})
|
|
453
|
+
}
|
|
454
|
+
if(!hasSortableFields){
|
|
455
|
+
_sortFields = undefined;
|
|
456
|
+
}
|
|
457
|
+
return _sortFields;
|
|
458
|
+
}
|
|
459
|
+
sort (items,update,sortDir){
|
|
460
|
+
let column = sorting.column;
|
|
461
|
+
if(this.isSortable() && column){
|
|
462
|
+
let dir = sorting.dir;
|
|
463
|
+
let sortDir = defaultStr(sortDir).toLowerCase();
|
|
464
|
+
if(sortDir =="asc" || sortDir =="desc"){
|
|
465
|
+
dir = sortDir;
|
|
466
|
+
} else {
|
|
467
|
+
if(this.hasAlreadySort && column === this.state.sortableField){
|
|
468
|
+
dir = dir =="asc"? "desc" : "asc";
|
|
469
|
+
} else dir = "asc";
|
|
470
|
+
}
|
|
471
|
+
this.hasAlreadySort = true;
|
|
472
|
+
items = sortBy(items,{column,dir:dir,returnArray:true});
|
|
473
|
+
if(update !== false && (column !== this.state.sortableField || dir !== this.state.sortableDir)){
|
|
474
|
+
this._renderedItems = undefined;
|
|
475
|
+
let endItemsIndex = this.getMaxItemsToRender();
|
|
476
|
+
this.prepareFetchedItems(items);
|
|
477
|
+
this.hasFetchNewItems = true;
|
|
478
|
+
this.setState({menuItems:items,endItemsIndex,hasMore:this.canFetchMoreItems(items,endItemsIndex),sortableField : column,sortableDir:dir})
|
|
479
|
+
return items;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return items;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
onLayout (event) {
|
|
486
|
+
const layout = event.nativeEvent.layout;
|
|
487
|
+
const isMob = isMobileOrTabletMedia();
|
|
488
|
+
const prevLayout = this.state.layout;
|
|
489
|
+
const prevIsMob = this.state.isMobileMedia;
|
|
490
|
+
const prevH = Math.abs(prevLayout.height-layout.height), prevW = Math.abs(prevLayout.width,layout.width);
|
|
491
|
+
if(prevIsMob === isMob && prevH <= 20 && prevW <= 50) return;
|
|
492
|
+
this.updateVisibleState({
|
|
493
|
+
//visible: prevIsMob !== isMob? false : this.state.visible,
|
|
494
|
+
isMobileMedia : isMobileOrTabletMedia(),
|
|
495
|
+
layout,
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
isLoading(){
|
|
499
|
+
return this.props.isLoading === true ? true : false
|
|
500
|
+
}
|
|
501
|
+
open (force,cb){
|
|
502
|
+
let u = force;
|
|
503
|
+
if(typeof force =='function'){
|
|
504
|
+
u = cb;
|
|
505
|
+
cb = force;
|
|
506
|
+
if(typeof u =='boolean'){
|
|
507
|
+
force = u;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
force = typeof force !== 'boolean'? false : force;
|
|
511
|
+
if(this.props.disabled === true || this.props.editable ===false || this.props.readOnly === true || (force !== true && this.isLoading())) return;
|
|
512
|
+
if(!this.state.visible){
|
|
513
|
+
if(this.props.withBottomSheet){
|
|
514
|
+
getContentHeight(this.anchorRef).then(({height})=>{
|
|
515
|
+
this.updateVisibleState({visible:true,anchorHeight:height},cb)
|
|
516
|
+
})
|
|
517
|
+
} else {
|
|
518
|
+
this.updateVisibleState({visible:true},cb);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
show(force,cb){
|
|
523
|
+
return this.open(force,cb);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
updateVisibleState(state,cb){
|
|
527
|
+
state = defaultObj(state);
|
|
528
|
+
const visible = this.state;
|
|
529
|
+
this.setState(state,()=>{
|
|
530
|
+
const arg = {context:this,selected:this.state.selected,visible:this.state.visible};
|
|
531
|
+
if(visible !== this.state.visible){
|
|
532
|
+
if(this.state.visible){
|
|
533
|
+
if(typeof this.props.onDismiss =='function'){
|
|
534
|
+
this.props.onDismiss(arg);
|
|
535
|
+
}
|
|
536
|
+
} else if(typeof this.props.onOpen =='function'){
|
|
537
|
+
this.props.onOpen(arg);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
if(typeof cb =='function'){
|
|
541
|
+
cb (arg);
|
|
542
|
+
}
|
|
543
|
+
})
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
hide (cb){
|
|
547
|
+
return this.updateVisibleState({visible:false},cb);
|
|
548
|
+
}
|
|
549
|
+
close (cb){
|
|
550
|
+
return this.hide(cb);
|
|
551
|
+
}
|
|
552
|
+
canHandleFilter(){
|
|
553
|
+
return this.props.disabled !== true && this.props.readOnly !==true && this.props.editable !== false && this.state.visible ? true : false;
|
|
554
|
+
}
|
|
555
|
+
focus = ()=>{
|
|
556
|
+
if(this.canHandleFilter() && this.inputRef && this.inputRef.current){
|
|
557
|
+
if(this.inputRef.current.focus){
|
|
558
|
+
this.inputRef.current.focus();
|
|
559
|
+
} else if(this.inputRef.current.forceFocus){
|
|
560
|
+
this.inputRef.current.forceFocus();
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
runSearchFilter (text){
|
|
565
|
+
clearTimeout(this.doSearchFilter);
|
|
566
|
+
if(!this.state.visible) {
|
|
567
|
+
if(this.state.isFiltering){
|
|
568
|
+
this.setState({isFiltering:false});
|
|
569
|
+
}
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
this.setState({isFiltering:true,filterText:text});
|
|
573
|
+
}
|
|
574
|
+
getItems (){
|
|
575
|
+
if(!this.state.visible || this.isLoading()){
|
|
576
|
+
return [];
|
|
577
|
+
}
|
|
578
|
+
if(this.canHandleFilter() && this.state.isFiltering && this.state.filterText){
|
|
579
|
+
const filterRegex = new RegExp(this.state.filterText.replace(matchOperators, '\\$&'), 'gi');
|
|
580
|
+
this.keysRefs = [];
|
|
581
|
+
return this.state.data.filter((item,_index)=>{
|
|
582
|
+
const key = this.state.keys[_index];
|
|
583
|
+
if(!isObj(this.state.nodes[key])) return false;
|
|
584
|
+
if(this.state.nodes[key].textContent.match(filterRegex)){
|
|
585
|
+
this.keysRefs.push(key);
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
588
|
+
return false;
|
|
589
|
+
})
|
|
590
|
+
}
|
|
591
|
+
this.keysRefs = this.state.keys;
|
|
592
|
+
return this.state.data;
|
|
593
|
+
}
|
|
594
|
+
componentWillUnmount(){
|
|
595
|
+
super.componentWillUnmount();
|
|
596
|
+
if(typeof this.props.onUnmount =="function"){
|
|
597
|
+
this.props.onUnmount({context:this,selected:this.state.selected,items:this.state.data})
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
componentDidMount(){
|
|
601
|
+
super.componentDidMount();
|
|
602
|
+
if(typeof this.props.onMount =='function'){
|
|
603
|
+
this.props.onMount({context:this,selected:this.state.selected,items:this.state.data});
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
UNSAFE_componentWillReceiveProps(nextProps){
|
|
607
|
+
const {items,defaultValue,selected} = nextProps;
|
|
608
|
+
if(items !== this.props.items){
|
|
609
|
+
const nState = this.prepareItems({items,defaultValue,selected});
|
|
610
|
+
return this.updateSelected(nState);
|
|
611
|
+
}
|
|
612
|
+
let value = this.prepareSelected({defaultValue});
|
|
613
|
+
let areEquals = !this.canHandleMultiple ? this.compare(value,this.state.selected) : false;
|
|
614
|
+
if(areEquals) return;
|
|
615
|
+
let selectedValuesKeys = {}, newSelected = this.canHandleMultiple ? [] : value;
|
|
616
|
+
if(this.canHandleMultiple){
|
|
617
|
+
areEquals = value.length === this.state.selected.length;
|
|
618
|
+
if(areEquals && !value.length){
|
|
619
|
+
areEquals = true;
|
|
620
|
+
} else for(let i in value){
|
|
621
|
+
const valueKey = this.getValueKey(value[i]);
|
|
622
|
+
if(valueKey){
|
|
623
|
+
if(!selectedValuesKeys[valueKey]){
|
|
624
|
+
newSelected.push(value[i]);
|
|
625
|
+
}
|
|
626
|
+
selectedValuesKeys[valueKey] = true;
|
|
627
|
+
if(areEquals && !this.state.selectedValuesKeys[valueKey]){
|
|
628
|
+
areEquals = false;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
} else {
|
|
633
|
+
const valueKey = this.getValueKey(value);
|
|
634
|
+
if(valueKey){
|
|
635
|
+
selectedValuesKeys[valueKey] = true;
|
|
636
|
+
newSelected = value;
|
|
637
|
+
} else {
|
|
638
|
+
newSelected = undefined;
|
|
639
|
+
selectedValuesKeys = {};
|
|
640
|
+
if(!areEquals){
|
|
641
|
+
areEquals = this.state.selected === undefined || this.state.selected ===''? true : false;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
if(areEquals) return;
|
|
646
|
+
this.setState({
|
|
647
|
+
selectedValuesKeys,
|
|
648
|
+
selected:newSelected,
|
|
649
|
+
selectedText : this.getSelectedText(newSelected,selectedValuesKeys)
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
render (){
|
|
653
|
+
let {
|
|
654
|
+
multiple:_multiple,
|
|
655
|
+
itemContainerProps,
|
|
656
|
+
onDismiss,
|
|
657
|
+
onOpen,
|
|
658
|
+
onClose,
|
|
659
|
+
value,
|
|
660
|
+
selected,
|
|
661
|
+
visible: _visible,
|
|
662
|
+
itemProps,
|
|
663
|
+
disabled,
|
|
664
|
+
editable,
|
|
665
|
+
readOnly,
|
|
666
|
+
defaultValue,
|
|
667
|
+
selectedColor,
|
|
668
|
+
label,
|
|
669
|
+
display,
|
|
670
|
+
text,
|
|
671
|
+
placeholder,
|
|
672
|
+
inputProps,
|
|
673
|
+
items,
|
|
674
|
+
getItemKey,
|
|
675
|
+
helperText,
|
|
676
|
+
error,
|
|
677
|
+
onChange,
|
|
678
|
+
accessibilityLabel,
|
|
679
|
+
onMount,
|
|
680
|
+
filter,
|
|
681
|
+
onUnmount,
|
|
682
|
+
itemValue,
|
|
683
|
+
name,
|
|
684
|
+
anchorChildren,
|
|
685
|
+
compare : _compare,
|
|
686
|
+
renderItem,
|
|
687
|
+
listProps,
|
|
688
|
+
dynamicContent,
|
|
689
|
+
dropdownActions,
|
|
690
|
+
renderText,
|
|
691
|
+
sortableFields,
|
|
692
|
+
isLoading,
|
|
693
|
+
progressBarProps,
|
|
694
|
+
addIcon,
|
|
695
|
+
addIconTooltip,
|
|
696
|
+
addIconProps,
|
|
697
|
+
showAdd,
|
|
698
|
+
tagProps,
|
|
699
|
+
onAdd,
|
|
700
|
+
showSearch,
|
|
701
|
+
onAddCallback,
|
|
702
|
+
onAddPress,
|
|
703
|
+
itemLabel,
|
|
704
|
+
checkedIcon:customCheckedIcon,
|
|
705
|
+
mode,
|
|
706
|
+
withBottomSheet,
|
|
707
|
+
context : contextProps,
|
|
708
|
+
getValueKey,
|
|
709
|
+
bindResizeEvents,
|
|
710
|
+
left,
|
|
711
|
+
right,
|
|
712
|
+
...dropdownProps
|
|
713
|
+
} = this.props;
|
|
714
|
+
|
|
715
|
+
const flattenStyle = StyleSheet.flatten(dropdownProps.style) || {};
|
|
716
|
+
itemContainerProps = defaultObj(itemContainerProps);
|
|
717
|
+
dropdownProps = defaultObj(dropdownProps);
|
|
718
|
+
const multiple = this.canHandleMultiple;
|
|
719
|
+
const renderTag = multiple && (display == 'tags' || display === 'tag' )? true : false;
|
|
720
|
+
this.willRenderTag = renderTag;
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
itemProps = defaultObj(itemProps);
|
|
724
|
+
disabled = defaultBool(disabled,false);
|
|
725
|
+
readOnly = defaultBool(readOnly,false);
|
|
726
|
+
editable = defaultBool(editable,true);
|
|
727
|
+
|
|
728
|
+
if(!readOnly){
|
|
729
|
+
readOnly = editable === false ? true : false;
|
|
730
|
+
editable = !readOnly;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
listProps = defaultObj(listProps);
|
|
734
|
+
selectedColor = (Colors.isValid(selectedColor)? selectedColor : theme.colors.primaryOnSurface);
|
|
735
|
+
this.selectedColor = selectedColor;
|
|
736
|
+
|
|
737
|
+
const {layout:inputLayout,selectedText,visible,isFiltering,filterText} = this.state;
|
|
738
|
+
const self = this,state = this.state;
|
|
739
|
+
const canHandle = !this.isLoading();
|
|
740
|
+
const canFilter = !disabled && !readOnly && editable && visible;
|
|
741
|
+
const isMob = isMobileOrTabletMedia();
|
|
742
|
+
inputProps = defaultObj(inputProps);
|
|
743
|
+
const contentContainerProps = Object.assign({},inputProps.contentContainerProps);
|
|
744
|
+
const containerProps = Object.assign({},inputProps.containerProps);
|
|
745
|
+
const inputRest = {disabled,editable,label,error}
|
|
746
|
+
clearTimeout(this.doSearchFilter);
|
|
747
|
+
this.doSearchFilter = null;
|
|
748
|
+
|
|
749
|
+
const textInputProps = {
|
|
750
|
+
...inputRest,
|
|
751
|
+
editable,disabled,
|
|
752
|
+
style : StyleSheet.flatten([styles.input,inputProps.style])
|
|
753
|
+
}
|
|
754
|
+
const dimensions = Dimensions.get("window");
|
|
755
|
+
let contentContainerHeight = dimensions.height - defaultDecimal(inputLayout?.top) - defaultDecimal(inputLayout?.height)-20;
|
|
756
|
+
contentContainerHeight = Math.max(contentContainerHeight,200);
|
|
757
|
+
if(isMob){
|
|
758
|
+
contentContainerHeight = '95%';
|
|
759
|
+
}
|
|
760
|
+
const iconDisabled = !canHandle || disabled || readOnly ||!editable?true : false;
|
|
761
|
+
const pointerEvents = iconDisabled?"none":"auto";
|
|
762
|
+
addIconTooltip = defaultStr(addIconTooltip,'Ajouter un élément');
|
|
763
|
+
addIconProps = defaultObj(addIconProps);
|
|
764
|
+
if(disabled || readOnly || editable === false){
|
|
765
|
+
showAdd = false;
|
|
766
|
+
}
|
|
767
|
+
showAdd = defaultBool(showAdd,false);
|
|
768
|
+
if(addIcon ===false) {
|
|
769
|
+
showAdd = false;
|
|
770
|
+
}
|
|
771
|
+
const addIconColor = Colors.isValid(addIconProps.color)? addIconProps.color : Colors.toAlpha(theme.colors.text,theme.ALPHA);
|
|
772
|
+
const _addIconProps = {
|
|
773
|
+
icon : isNonNullString(addIcon)?addIcon:'plus-thick',
|
|
774
|
+
tooltip : addIconTooltip,
|
|
775
|
+
...addIconProps,
|
|
776
|
+
color : addIconColor,
|
|
777
|
+
onPress : (e)=>{
|
|
778
|
+
React.stopEventPropagation(e);
|
|
779
|
+
if(iconDisabled) return;
|
|
780
|
+
const aArgs = {...React.getOnPressArgs(e),isMobile:isMob,context:this,visible:state.visible,field:name,props:this.props};
|
|
781
|
+
if(onAdd){onAdd(aArgs);}
|
|
782
|
+
else if(onAddPress){
|
|
783
|
+
onAddPress(aArgs)
|
|
784
|
+
}
|
|
785
|
+
},
|
|
786
|
+
disabled : iconDisabled
|
|
787
|
+
}
|
|
788
|
+
let menuActions = [];
|
|
789
|
+
Object.map(dropdownActions,(action,index)=>{
|
|
790
|
+
if(!isObj(action) || (!action.text)) return;
|
|
791
|
+
menuActions.push(action);
|
|
792
|
+
});
|
|
793
|
+
if(this.isSortable()){
|
|
794
|
+
menuActions.push( {
|
|
795
|
+
text : 'Trier par',
|
|
796
|
+
icon : "sort",
|
|
797
|
+
items : Object.mapToArray(sortableFields,(f,i)=>{
|
|
798
|
+
return {
|
|
799
|
+
text : f,
|
|
800
|
+
icon : i == sorting.column ? (sorting.dir !="desc"?"sort-ascending":"sort-descending"):"",
|
|
801
|
+
onPress : x =>{
|
|
802
|
+
React.stopEventPropagation(x);
|
|
803
|
+
this.sort(i);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
})
|
|
807
|
+
|
|
808
|
+
})
|
|
809
|
+
}
|
|
810
|
+
if(canFilter && filterText){
|
|
811
|
+
menuActions.push({
|
|
812
|
+
icon : 'close',
|
|
813
|
+
onPress : ()=>{
|
|
814
|
+
this.setState({filterText:''});
|
|
815
|
+
},
|
|
816
|
+
text : 'Effacer le texte',
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
if(multiple){
|
|
820
|
+
menuActions.push( {
|
|
821
|
+
text : 'Tout sélectionner',
|
|
822
|
+
icon : 'checkbox-multiple-marked',
|
|
823
|
+
onPress : this.selectAll.bind(this),
|
|
824
|
+
});
|
|
825
|
+
menuActions.push({
|
|
826
|
+
text : 'Tout Désélectionner',
|
|
827
|
+
icon : 'checkbox-multiple-blank-outline',
|
|
828
|
+
onPress : this.unselectAll.bind(this),
|
|
829
|
+
});
|
|
830
|
+
} else if(!multiple && state.selected !== undefined){
|
|
831
|
+
menuActions.push( {
|
|
832
|
+
text : 'Désélectionner',
|
|
833
|
+
icon : 'select',
|
|
834
|
+
onPress : this.unselect.bind(this)
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
if(renderTag){
|
|
839
|
+
tagProps = defaultObj(tagProps);
|
|
840
|
+
}
|
|
841
|
+
helperText = <HelperText disabled = {disabled} error={error}>{helperText}</HelperText>
|
|
842
|
+
let labelTextField = defaultVal(label,text);
|
|
843
|
+
|
|
844
|
+
const isFlatMode = textInputProps.mode === flatMode;
|
|
845
|
+
let backgroundColor = Colors.isValid(textInputProps.style.backgroundColor)?textInputProps.style.backgroundColor : Colors.isValid(flattenStyle.backgroundColor)? flattenStyle.backgroundColor : theme.colors.surface;
|
|
846
|
+
const tagLabelStyle = {backgroundColor,color:Colors.setAlpha(theme.colors.text,theme.ALPHA)}
|
|
847
|
+
if(!isFlatMode && backgroundColor ==='transparent'){
|
|
848
|
+
tagLabelStyle.backgroundColor = theme.colors.surface;
|
|
849
|
+
}
|
|
850
|
+
textInputProps.style.backgroundColor = backgroundColor;
|
|
851
|
+
progressBarProps = defaultObj(progressBarProps);
|
|
852
|
+
|
|
853
|
+
const loadingElement = !canHandle ? (<View style = {[{marginRight : 20}]}>
|
|
854
|
+
<ActivityIndicator
|
|
855
|
+
color={error?theme.colors.error:theme.colors.secondary}
|
|
856
|
+
animating={true}
|
|
857
|
+
{...progressBarProps}
|
|
858
|
+
/>
|
|
859
|
+
</View>): null;
|
|
860
|
+
let tagsContent = null,hasTagContent = false;
|
|
861
|
+
if(renderTag){
|
|
862
|
+
tagsContent = <View style={[styles.tagsContent]}>
|
|
863
|
+
{state.selected.map((value,i)=>{
|
|
864
|
+
const nodeKey = this.getNodeFromValue(value);
|
|
865
|
+
if(!nodeKey.valueKey) return null;
|
|
866
|
+
const valueKey = nodeKey.valueKey;
|
|
867
|
+
const {text} = nodeKey.node;
|
|
868
|
+
const p = Colors.getAvatarStyleFromSuffix(i+1);
|
|
869
|
+
hasTagContent = true;
|
|
870
|
+
return <Chip
|
|
871
|
+
{...tagProps}
|
|
872
|
+
style = {[p.style,{color:p.color,marginBottom:5,marginRight:5},tagProps.style]}
|
|
873
|
+
textStyle = {[{color:p.color},tagProps.textStyle]}
|
|
874
|
+
key = {i}
|
|
875
|
+
onPress = {()=>{
|
|
876
|
+
this.selectItem({value,valueKey,select:false});
|
|
877
|
+
}}
|
|
878
|
+
onClose = {()=>{
|
|
879
|
+
this.selectItem({value,valueKey,select:false});
|
|
880
|
+
}}
|
|
881
|
+
>{text} </Chip>;
|
|
882
|
+
})}
|
|
883
|
+
</View>
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
const testID = defaultStr(dropdownProps.testID,"RN_DropdownComponent");
|
|
887
|
+
const defRight = defaultVal(textInputProps.right,inputProps.right);
|
|
888
|
+
const enableCopy = defaultBool(inputProps.enableCopy,textInputProps.enableCopy,(iconDisabled || (!multiple && !showAdd)) && !loadingElement ?true : false);
|
|
889
|
+
const anchor = <TouchableOpacity
|
|
890
|
+
activeOpacity = {0.3}
|
|
891
|
+
onPress={this.open.bind(this)}
|
|
892
|
+
disabled = {disabled}
|
|
893
|
+
onLayout={bindResizeEvents === false ? undefined : this.onLayout.bind(this)}
|
|
894
|
+
pointerEvents = {pointerEvents}
|
|
895
|
+
accessibilityLabel={defaultStr(accessibilityLabel,label,text)}
|
|
896
|
+
testID = {testID}
|
|
897
|
+
>
|
|
898
|
+
{<React.Fragment>{
|
|
899
|
+
<View {...dropdownProps} {...contentContainerProps} style={[contentContainerProps.style,flattenStyle]}
|
|
900
|
+
ref = {this.anchorRef}
|
|
901
|
+
collapsable = {false}
|
|
902
|
+
>
|
|
903
|
+
{<TextField
|
|
904
|
+
defaultValue={selectedText}
|
|
905
|
+
autoHeight = {renderTag}
|
|
906
|
+
useReadOnlyOpacity = {false}
|
|
907
|
+
mode = {mode}
|
|
908
|
+
{...inputProps}
|
|
909
|
+
{...textInputProps}
|
|
910
|
+
enableCopy = {enableCopy}
|
|
911
|
+
label = {labelTextField}
|
|
912
|
+
pointerEvents = "none"
|
|
913
|
+
disabled = {disabled}
|
|
914
|
+
readOnly = {readOnly}
|
|
915
|
+
//divider = {canHandle}
|
|
916
|
+
alwaysUseLabel = {renderTag?true : false}
|
|
917
|
+
editable = {false}
|
|
918
|
+
contentContainerProps = {{
|
|
919
|
+
...contentContainerProps,
|
|
920
|
+
pointerEvents:iconDisabled && (!enableCopy && disabled)?'none':'auto',
|
|
921
|
+
style : [renderTag? styles.inputContainerTag:null,contentContainerProps.style],
|
|
922
|
+
}}
|
|
923
|
+
containerProps = {{...containerProps,style:[containerProps.style,styles.mbO]}}
|
|
924
|
+
error = {!!error}
|
|
925
|
+
right = {loadingElement ? (loadingElement) : disabled? null : (props)=>{
|
|
926
|
+
let r = React.isValidElement(defRight)?<>{defRight}</> : <></>;
|
|
927
|
+
if(typeof defRight =='function'){
|
|
928
|
+
const t = defRight(props);
|
|
929
|
+
r = React.isValidElement(t)? r = <>{t}{r}</> : r;
|
|
930
|
+
}
|
|
931
|
+
if(React.isValidElement(this.props.right)){
|
|
932
|
+
r = <>{this.props.right}{r}</>
|
|
933
|
+
} else if(typeof this.props.right =='function'){
|
|
934
|
+
const t = this.props.right(props);
|
|
935
|
+
r = React.isValidElement(t)? r = <>{t}{r}</> : r;
|
|
936
|
+
}
|
|
937
|
+
if(showAdd){
|
|
938
|
+
return <>{r}<Icon {..._addIconProps} {...props}/></>
|
|
939
|
+
}
|
|
940
|
+
return r;
|
|
941
|
+
}}
|
|
942
|
+
onPress = {this.open.bind(this)}
|
|
943
|
+
placeholder={placeholder}
|
|
944
|
+
render = {!renderTag?inputProps.render : (tagProps)=>{
|
|
945
|
+
return <View pointerEvents={pointerEvents} style={[styles.tagsContentContainer,isFlatMode?styles.tagsContentContainerFlatMode:null]}>
|
|
946
|
+
{tagsContent}
|
|
947
|
+
</View>
|
|
948
|
+
}}
|
|
949
|
+
helperText = {''}
|
|
950
|
+
children = {anchorChildren}
|
|
951
|
+
/>}
|
|
952
|
+
{!canHandle && isFlatMode && <ProgressBar color={theme.colors.secondary} {...defaultObj(progressBarProps)} indeterminate />}
|
|
953
|
+
{helperText}
|
|
954
|
+
</View>
|
|
955
|
+
}</React.Fragment>}
|
|
956
|
+
</TouchableOpacity>
|
|
957
|
+
|
|
958
|
+
let restProps = {};
|
|
959
|
+
if(!isMob){
|
|
960
|
+
restProps.handleScroll = false;
|
|
961
|
+
restProps.sameWidth = true;
|
|
962
|
+
} else {
|
|
963
|
+
restProps.fullScreen = true;
|
|
964
|
+
restProps.maxActions = 0;
|
|
965
|
+
restProps.actions = [{
|
|
966
|
+
icon : 'check',
|
|
967
|
+
text : 'Fermer',
|
|
968
|
+
onPress : this.close.bind(this),
|
|
969
|
+
}]
|
|
970
|
+
}
|
|
971
|
+
const Component = withBottomSheet === true ? BottomSheet : isMob ? Dialog : Menu ;
|
|
972
|
+
const MComponent = withBottomSheet === true ? BottomSheetMenu : MenuComponent;
|
|
973
|
+
if(withBottomSheet){
|
|
974
|
+
restProps.controlled = true;
|
|
975
|
+
restProps.height = this.state.anchorHeight;
|
|
976
|
+
restProps.withScrollView = false;
|
|
977
|
+
restProps.pointerEvents = "auto";
|
|
978
|
+
}
|
|
979
|
+
const renderingItems = this.getItems();
|
|
980
|
+
const isDisabled = !editable || readOnly || disabled?true:false;
|
|
981
|
+
const isBigList = this.isBigList;
|
|
982
|
+
const ListComponent = isBigList ? BigList : List;
|
|
983
|
+
const autoFocus = canAutoFocusSearchField({visible,items:renderingItems});
|
|
984
|
+
return (
|
|
985
|
+
<Fragment>
|
|
986
|
+
{!withBottomSheet && isMob && anchor}
|
|
987
|
+
<Component
|
|
988
|
+
dismissable
|
|
989
|
+
{...restProps}
|
|
990
|
+
testID = {testID+"_ModalComponent"}
|
|
991
|
+
withScrollView = {false}
|
|
992
|
+
visible={visible && canHandle ? true : false}
|
|
993
|
+
onDismiss={this.hide.bind(this)}
|
|
994
|
+
contentStyle = {[{paddingVertical:0},restProps.contentStyle]}
|
|
995
|
+
anchor={anchor}
|
|
996
|
+
title = {defaultStr(label,text)+"[ "+self.state.data.length.formatNumber()+" ]"}
|
|
997
|
+
subtitle = {selectedText}
|
|
998
|
+
style = {[restProps.style]}
|
|
999
|
+
contentProps = {{style:{flex:1}}}
|
|
1000
|
+
>
|
|
1001
|
+
<View style={[
|
|
1002
|
+
styles.contentWrapper,
|
|
1003
|
+
{
|
|
1004
|
+
//paddingRight : 0,
|
|
1005
|
+
//paddingLeft : !isMob ? 5 : undefined,
|
|
1006
|
+
height : !isMob?contentContainerHeight:'90%',
|
|
1007
|
+
},
|
|
1008
|
+
isMob && {flex:1},
|
|
1009
|
+
]}
|
|
1010
|
+
pointerEvents = {pointerEvents}
|
|
1011
|
+
testID = {testID+"_Container"}
|
|
1012
|
+
>
|
|
1013
|
+
{showSearch !== false && <>
|
|
1014
|
+
<TextField
|
|
1015
|
+
testID = {testID+"_SearchField"}
|
|
1016
|
+
affix = {false}
|
|
1017
|
+
{...textInputProps}
|
|
1018
|
+
dynamicBackgroundColor = {false}
|
|
1019
|
+
mode = {flatMode}
|
|
1020
|
+
disabled = {iconDisabled}
|
|
1021
|
+
outlined = {false}
|
|
1022
|
+
defaultValue = {filterText}
|
|
1023
|
+
containerProps = {{style:styles.searchContainer}}
|
|
1024
|
+
contentContainerProps = {{style:[styles.inputContainer]}}
|
|
1025
|
+
placeholder = {"rechercher ["+self.state.data.length.formatNumber()+"]"}
|
|
1026
|
+
label = {""}
|
|
1027
|
+
error = {error}
|
|
1028
|
+
style = {[styles.searchInput,textInputProps.style,{backgroundColor:'transparent'}]}
|
|
1029
|
+
ref = {this.inputRef}
|
|
1030
|
+
autoFocus = {autoFocus}
|
|
1031
|
+
onMount = {()=>{
|
|
1032
|
+
if(autoFocus){
|
|
1033
|
+
this.focus();
|
|
1034
|
+
}
|
|
1035
|
+
}}
|
|
1036
|
+
onChangeText = {debounce((text)=>{
|
|
1037
|
+
if(!text && !multiple){
|
|
1038
|
+
return this.unselect({filterText:''});
|
|
1039
|
+
}
|
|
1040
|
+
return this.runSearchFilter(text);
|
|
1041
|
+
},getSearchTimeout(this.state.data.length))}
|
|
1042
|
+
left = {(props)=><Icon testID = {testID+"_Left"} icon={'magnify'} {...props} style={[styles.left,props.style]} />}
|
|
1043
|
+
right = {(props)=>{
|
|
1044
|
+
return <>
|
|
1045
|
+
{showAdd ? <Icon testID = {testID+"_ShowAddIcon"} {..._addIconProps} {...props} size={ICON_SIZE} style={[_addIconProps.style,styles.iconRight,props.style]}/> : null}
|
|
1046
|
+
<MComponent
|
|
1047
|
+
items = {menuActions}
|
|
1048
|
+
closeOnPress
|
|
1049
|
+
withBottomSheet = {withBottomSheet}
|
|
1050
|
+
anchor = {(props1)=>{
|
|
1051
|
+
return <Icon
|
|
1052
|
+
{...props1}
|
|
1053
|
+
{...props}
|
|
1054
|
+
name = {MORE_ICON}
|
|
1055
|
+
size = {ICON_SIZE}
|
|
1056
|
+
style = {[styles.iconRight,styles.anchorIcon,props.style]}
|
|
1057
|
+
/>
|
|
1058
|
+
}}
|
|
1059
|
+
/>
|
|
1060
|
+
</>
|
|
1061
|
+
}}
|
|
1062
|
+
onBlur = { (e)=>{
|
|
1063
|
+
this.isFiltering = false;
|
|
1064
|
+
}}
|
|
1065
|
+
helperText = ""
|
|
1066
|
+
/>
|
|
1067
|
+
</>}
|
|
1068
|
+
{showSearch !== false && <Divider disabled={isDisabled} style={{marginRight:10,marginBottom:5}}/>}
|
|
1069
|
+
{isMob && tagsContent}
|
|
1070
|
+
{isMob && helperText ? <View testID = {testID+"_HelperText"} style={[styles.helperText]}>
|
|
1071
|
+
{helperText}
|
|
1072
|
+
</View>: null}
|
|
1073
|
+
<ListComponent
|
|
1074
|
+
testID = {testID+"_List"}
|
|
1075
|
+
{...listProps}
|
|
1076
|
+
ref = {this.listRef}
|
|
1077
|
+
responsive = {false}
|
|
1078
|
+
style = {[listProps.style]}
|
|
1079
|
+
prepareItems = {false}
|
|
1080
|
+
items = {renderingItems}
|
|
1081
|
+
keyExtractor = {this.getItemKey.bind(this)}
|
|
1082
|
+
renderItem = {function({item,index:_index}){
|
|
1083
|
+
const key = self.keysRefs[_index];
|
|
1084
|
+
if(!isObj(self.state.nodes[key])) {
|
|
1085
|
+
return null;
|
|
1086
|
+
}
|
|
1087
|
+
if(renderTag && (self.state.nodes[key].valueKey in self.state.selectedValuesKeys)){
|
|
1088
|
+
return null;
|
|
1089
|
+
}
|
|
1090
|
+
let node = self.state.nodes[key];
|
|
1091
|
+
const {index,value,valueKey} = node;
|
|
1092
|
+
const _isSelected = self.isSelected(value,valueKey);
|
|
1093
|
+
if(dynamicContent){
|
|
1094
|
+
const callArgs = self.getCallArgs({item,index,items:renderingItems,_index:node._index});
|
|
1095
|
+
node = self.getNode({item,key,itemProps,name,selected : _isSelected,index,_index,callArgs,key})
|
|
1096
|
+
}
|
|
1097
|
+
if(!isObj(node)) return null;
|
|
1098
|
+
let {content} = node;
|
|
1099
|
+
const style = _isSelected ? {color:selectedColor,fontWeight:'bold'} : null;
|
|
1100
|
+
if(typeof (content) ==="string"){
|
|
1101
|
+
content = <Label {...itemProps} style={[itemProps.style,styles.item,style]}>{content}</Label>
|
|
1102
|
+
}
|
|
1103
|
+
const testID = "RN_DropdownItem_"+key;
|
|
1104
|
+
const select = !_isSelected;
|
|
1105
|
+
const checkedIcon = typeof customCheckedIcon == 'function'? customCheckedIcon({item,multiple,key,itemProps,name,selected : _isSelected,index,_index,callArgs,key}) : undefined;
|
|
1106
|
+
const onItemPress = (e) => {
|
|
1107
|
+
React.stopEventPropagation(e);
|
|
1108
|
+
self.selectItem({value,valueKey,select:!multiple?true:select});
|
|
1109
|
+
};
|
|
1110
|
+
return (
|
|
1111
|
+
<Fragment key={key}>
|
|
1112
|
+
<TouchableRipple
|
|
1113
|
+
testID={testID+"Container"}
|
|
1114
|
+
style={{
|
|
1115
|
+
flexDirection: "row",
|
|
1116
|
+
height : '100%',
|
|
1117
|
+
fontWeight : _isSelected ? 'bold' : 'normal',
|
|
1118
|
+
alignItems: "center",
|
|
1119
|
+
}}
|
|
1120
|
+
onPress={onItemPress}
|
|
1121
|
+
>
|
|
1122
|
+
<View testID={testID+"contentContainer"} {...itemContainerProps} style={[styles.itemContainer,{minHeight:!isBigList?MIN_HEIGHT:undefined},itemContainerProps.style]}>
|
|
1123
|
+
{_isSelected ? <Icon onPress={onItemPress} name={isNonNullString(checkedIcon)?checkedIcon : (multiple || _isIos?"check":'radiobox-marked')} style={[styles.checkedIcon]} color={selectedColor} /> : null}
|
|
1124
|
+
{content}
|
|
1125
|
+
</View>
|
|
1126
|
+
</TouchableRipple>
|
|
1127
|
+
<Divider disabled={isDisabled}/>
|
|
1128
|
+
</Fragment>
|
|
1129
|
+
)}}
|
|
1130
|
+
/>
|
|
1131
|
+
</View>
|
|
1132
|
+
</Component>
|
|
1133
|
+
</Fragment>);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
const styles = StyleSheet.create({
|
|
1138
|
+
contentWrapper : {
|
|
1139
|
+
paddingHorizontal : 0,
|
|
1140
|
+
paddingVertical:0,
|
|
1141
|
+
},
|
|
1142
|
+
inputContainerTag : {
|
|
1143
|
+
paddingTop:7,
|
|
1144
|
+
},
|
|
1145
|
+
item : {
|
|
1146
|
+
fontSize:14,
|
|
1147
|
+
},
|
|
1148
|
+
itemContainer : {
|
|
1149
|
+
flexDirection : 'row',
|
|
1150
|
+
flex : 1,
|
|
1151
|
+
alignItems : 'center',
|
|
1152
|
+
paddingHorizontal : 8,
|
|
1153
|
+
},
|
|
1154
|
+
left : {
|
|
1155
|
+
paddingHorizontal:0,
|
|
1156
|
+
marginHorizontal : 0,
|
|
1157
|
+
paddingVertical : 0,
|
|
1158
|
+
},
|
|
1159
|
+
searchInput : {
|
|
1160
|
+
paddingLeft : 8,
|
|
1161
|
+
},
|
|
1162
|
+
helperText : {
|
|
1163
|
+
paddingHorizontal : 8,
|
|
1164
|
+
},
|
|
1165
|
+
checkedIcon : {
|
|
1166
|
+
margin : 0,
|
|
1167
|
+
padding : 0,
|
|
1168
|
+
marginLeft : -8,
|
|
1169
|
+
},
|
|
1170
|
+
searchWrapper : {
|
|
1171
|
+
height : ICON_SIZE+ICON_OFFSET,
|
|
1172
|
+
justifyContent: 'space-between',
|
|
1173
|
+
alignItems: 'center',
|
|
1174
|
+
},
|
|
1175
|
+
searchContainer : {
|
|
1176
|
+
//width : undefined,
|
|
1177
|
+
marginTop : 0,
|
|
1178
|
+
marginVertical : 0,
|
|
1179
|
+
paddingVertical : 0,
|
|
1180
|
+
marginBottom:0,
|
|
1181
|
+
},
|
|
1182
|
+
inputContainer : {
|
|
1183
|
+
height : 50,
|
|
1184
|
+
minHeight : undefined,
|
|
1185
|
+
paddingVertical : 0,
|
|
1186
|
+
},
|
|
1187
|
+
mbO : {
|
|
1188
|
+
marginBottom:0,
|
|
1189
|
+
},
|
|
1190
|
+
row : {
|
|
1191
|
+
flexDirection:'row',
|
|
1192
|
+
justifyContent : 'center',
|
|
1193
|
+
alignItems : 'center'
|
|
1194
|
+
},
|
|
1195
|
+
iconRight : {
|
|
1196
|
+
width : ICON_SIZE+7,
|
|
1197
|
+
height : ICON_SIZE+7
|
|
1198
|
+
},
|
|
1199
|
+
anchorIcon : {marginRight:10,marginLeft:5},
|
|
1200
|
+
input : {},
|
|
1201
|
+
hidden : {
|
|
1202
|
+
height : 0,
|
|
1203
|
+
display : 'none',
|
|
1204
|
+
width : 0
|
|
1205
|
+
},
|
|
1206
|
+
tagsContentContainer : {
|
|
1207
|
+
flex : 1,
|
|
1208
|
+
marginTop : 0,
|
|
1209
|
+
paddingTop : 10,
|
|
1210
|
+
paddingHorizontal:5,
|
|
1211
|
+
justifyContent : 'center',
|
|
1212
|
+
},
|
|
1213
|
+
tagsContentContainerFlatMode : {
|
|
1214
|
+
marginTop : -10,
|
|
1215
|
+
paddingTop : 10,
|
|
1216
|
+
},
|
|
1217
|
+
tagsContent : {
|
|
1218
|
+
flexDirection: 'row',
|
|
1219
|
+
flexWrap: 'wrap',
|
|
1220
|
+
//paddingHorizontal: 12,
|
|
1221
|
+
marginBottom : 0,
|
|
1222
|
+
marginBottom : 0,
|
|
1223
|
+
},
|
|
1224
|
+
tagLabel : {
|
|
1225
|
+
flexGrow : 0,
|
|
1226
|
+
paddingHorizontal:5,
|
|
1227
|
+
},
|
|
1228
|
+
tagLabelFlatMode : {
|
|
1229
|
+
//paddingTop : 10,
|
|
1230
|
+
marginBottom : 10,
|
|
1231
|
+
},
|
|
1232
|
+
tagLabelOutlinedMode : {
|
|
1233
|
+
position : 'absolute',
|
|
1234
|
+
top :-10,
|
|
1235
|
+
left : 0,
|
|
1236
|
+
marginLeft : 12,
|
|
1237
|
+
}
|
|
1238
|
+
})
|
|
1239
|
+
|
|
1240
|
+
DropdownComponent.propTypes = {
|
|
1241
|
+
onAddCallback : PropTypes.func,
|
|
1242
|
+
checkedIcon : PropTypes.oneOfType([
|
|
1243
|
+
PropTypes.string,
|
|
1244
|
+
PropTypes.func,
|
|
1245
|
+
]),///l'icone des éléments sélectionnés
|
|
1246
|
+
onAddPress : PropTypes.func,//la fonction de rappel appelée lorsqu'on clique sur l'action onAdd
|
|
1247
|
+
showSearch : PropTypes.bool,
|
|
1248
|
+
/**** cette fonction est appélée pour récupérer de manière unique les clés des valeurs lorsque les valeurs retournées du Dropdown sont de type object */
|
|
1249
|
+
getValueKey : PropTypes.func,
|
|
1250
|
+
withBottomSheet : PropTypes.bool, //si le dropdown sera rendu en utilisant le composant BottomSheet
|
|
1251
|
+
anchorChildren : PropTypes.oneOfType([
|
|
1252
|
+
PropTypes.node,
|
|
1253
|
+
PropTypes.func,
|
|
1254
|
+
]), //le contenu enfant à afficher après l'anchor
|
|
1255
|
+
/**** les actions supplémentaires à ajouter au menu items */
|
|
1256
|
+
dropdownActions : PropTypes.oneOfType([
|
|
1257
|
+
PropTypes.arrayOf(PropTypes.object),
|
|
1258
|
+
PropTypes.objectOf(PropTypes.object),
|
|
1259
|
+
]),
|
|
1260
|
+
onChange : PropTypes.func,///onGoBack params : {value:selected,selectedItems : getSelectedItems(),items:state.data,keys:state.keys,selectedItem}
|
|
1261
|
+
visible: PropTypes.bool,
|
|
1262
|
+
itemContainerProps : PropTypes.object,///les props de la view wrapper à chaque item
|
|
1263
|
+
multiple : PropTypes.bool,
|
|
1264
|
+
onDismiss: PropTypes.func,
|
|
1265
|
+
onOpen: PropTypes.func,
|
|
1266
|
+
onClose: PropTypes.func,
|
|
1267
|
+
value: PropTypes.any,
|
|
1268
|
+
onMount : PropTypes.func,
|
|
1269
|
+
onUnmount : PropTypes.func,
|
|
1270
|
+
label : PropTypes.string,
|
|
1271
|
+
placeholder : PropTypes.string,
|
|
1272
|
+
mode : PropTypes.oneOf(["outlined", "flat"]),
|
|
1273
|
+
inputProps : PropTypes.object,
|
|
1274
|
+
selectedColor:PropTypes.string,
|
|
1275
|
+
accessibilityLabel : PropTypes.string,
|
|
1276
|
+
compare : PropTypes.func,
|
|
1277
|
+
temProps : PropTypes.object,
|
|
1278
|
+
itemLabel : PropTypes.string,//le nom du champ à utiliser pour le rendu du libelé la méthode appelée pour retourne le libelé de l'item
|
|
1279
|
+
itemValue : PropTypes.oneOfType([PropTypes.func]),//le nom du champ de la valeur à récupérer
|
|
1280
|
+
renderItem : PropTypes.oneOfType([PropTypes.func]),
|
|
1281
|
+
/*** la fonction permettant d'afficher le texte du dropdown */
|
|
1282
|
+
renderText : PropTypes.func,
|
|
1283
|
+
items : PropTypes.oneOfType([PropTypes.object,PropTypes.array,PropTypes.func]),
|
|
1284
|
+
/**** l'info bulle a associer à l'iconne addIcon */
|
|
1285
|
+
addIcon : PropTypes.oneOfType([PropTypes.string,PropTypes.bool]), //l'icon plus
|
|
1286
|
+
addIconTooltip : PropTypes.string,
|
|
1287
|
+
addIconProps : PropTypes.object,
|
|
1288
|
+
/** display est exploité lorsque la props multiple est à true
|
|
1289
|
+
* valeurs :
|
|
1290
|
+
*/
|
|
1291
|
+
display : PropTypes.oneOf([
|
|
1292
|
+
'menu',
|
|
1293
|
+
'tag', //le rendu des valeurs sélectionné sera en tags
|
|
1294
|
+
'tags' //le rendu sera en texte
|
|
1295
|
+
]),//le type d'affichage, valide lorsque la valeur multiple est à true
|
|
1296
|
+
//le contenu à aficher après le rendu des tags, lorsque le type de rendu, props display = tags ou tag
|
|
1297
|
+
tagContent : PropTypes.any,
|
|
1298
|
+
/*** les tagsProp sont les tags des différents éléments à afficher en cas de rendu multiple
|
|
1299
|
+
* ils sont semblables à ceux attendus du composant Chip de react native paper
|
|
1300
|
+
*/
|
|
1301
|
+
tagProps : PropTypes.shape({
|
|
1302
|
+
...defaultObj(Chip.propTypes),
|
|
1303
|
+
}),
|
|
1304
|
+
contentContainerProps : PropTypes.object,///les props du container aux TextInput
|
|
1305
|
+
filter: PropTypes.oneOfType([
|
|
1306
|
+
PropTypes.func,
|
|
1307
|
+
PropTypes.bool,
|
|
1308
|
+
]),
|
|
1309
|
+
/*** la liste des champs qu'on peut trier sur forme de clé/libelé */
|
|
1310
|
+
sortableFields : PropTypes.object,
|
|
1311
|
+
showAdd : PropTypes.bool,
|
|
1312
|
+
onAdd : PropTypes.func,
|
|
1313
|
+
getItemKey : PropTypes.func,///la fonction prenant en paramètre un item et retourne sa clé unique
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
export default DropdownComponent;
|