@vincentgraul/react-components 1.0.40 → 1.0.41
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/package.json +2 -1
- package/.circleci/config.yml +0 -52
- package/.prettierrc.json +0 -4
- package/.storybook/main.ts +0 -17
- package/.storybook/preview.ts +0 -15
- package/doc/.nojekyll +0 -1
- package/doc/assets/highlight.css +0 -22
- package/doc/assets/main.js +0 -54
- package/doc/assets/search.js +0 -1
- package/doc/assets/style.css +0 -1224
- package/doc/assets/widgets.png +0 -0
- package/doc/assets/widgets@2x.png +0 -0
- package/doc/enums/numbered_pagination_NumberedPagination.ArrowPosition.html +0 -78
- package/doc/functions/match_device_useMatchDevice.default.html +0 -70
- package/doc/functions/match_resolution_useMatchResolution.default.html +0 -82
- package/doc/functions/mount_react_hook_mountReactHook.default.html +0 -74
- package/doc/functions/numbered_pagination_NumberedPagination.default.html +0 -75
- package/doc/functions/pagination_usePagination.default.html +0 -85
- package/doc/functions/scroll_to_useScrollTo.default.html +0 -73
- package/doc/functions/table_Table.Td.html +0 -85
- package/doc/functions/table_Table.Th.html +0 -85
- package/doc/functions/table_Table.Tr.html +0 -85
- package/doc/functions/table_Table.default.html +0 -84
- package/doc/functions/visible_useVisible.default.html +0 -69
- package/doc/index.html +0 -98
- package/doc/interfaces/match_device_useMatchDevice.Device.html +0 -96
- package/doc/interfaces/match_resolution_useMatchResolution.Breakpoints.html +0 -159
- package/doc/interfaces/match_resolution_useMatchResolution.MatchResolution.html +0 -102
- package/doc/interfaces/match_resolution_useMatchResolution.Resolution.html +0 -159
- package/doc/interfaces/mount_react_hook_mountReactHook.MountedHook.html +0 -97
- package/doc/interfaces/numbered_pagination_NumberedPagination.Props.html +0 -234
- package/doc/interfaces/pagination_usePagination.Pagination.html +0 -178
- package/doc/interfaces/pagination_usePagination.Props.html +0 -103
- package/doc/interfaces/scroll_to_useScrollTo.ScrollEvents.html +0 -83
- package/doc/interfaces/table_Table.Column.html +0 -85
- package/doc/interfaces/table_Table.Props.html +0 -245
- package/doc/modules/match_device_useMatchDevice.html +0 -66
- package/doc/modules/match_resolution_useMatchResolution.html +0 -75
- package/doc/modules/mount_react_hook_mountReactHook.html +0 -66
- package/doc/modules/numbered_pagination_NumberedPagination.html +0 -71
- package/doc/modules/pagination_usePagination.html +0 -68
- package/doc/modules/scroll_to_useScrollTo.html +0 -66
- package/doc/modules/table_Table.html +0 -74
- package/doc/modules/visible_useVisible.html +0 -61
- package/doc/modules.html +0 -58
- package/doc/variables/match_resolution_useMatchResolution.defaultBreakpoints.html +0 -58
- package/eslint.config.js +0 -36
- package/jest.config.js +0 -5
- package/renovate.json +0 -14
- package/src/breadcrumb/breadcrumb.module.css +0 -17
- package/src/breadcrumb/breadcrumb.tsx +0 -30
- package/src/breadcrumb/icons/arrow.tsx +0 -24
- package/src/breadcrumb/icons/index.ts +0 -1
- package/src/breadcrumb/index.ts +0 -3
- package/src/country-selector/country-selector.module.css +0 -5
- package/src/country-selector/country-selector.tsx +0 -42
- package/src/country-selector/country-selector.types.ts +0 -6
- package/src/country-selector/icons/Ad.tsx +0 -86
- package/src/country-selector/icons/Ae.tsx +0 -22
- package/src/country-selector/icons/Af.tsx +0 -28
- package/src/country-selector/icons/Ag.tsx +0 -23
- package/src/country-selector/icons/Ai.tsx +0 -38
- package/src/country-selector/icons/Al.tsx +0 -17
- package/src/country-selector/icons/Am.tsx +0 -18
- package/src/country-selector/icons/Ao.tsx +0 -21
- package/src/country-selector/icons/Ar.tsx +0 -19
- package/src/country-selector/icons/As.tsx +0 -43
- package/src/country-selector/icons/At.tsx +0 -14
- package/src/country-selector/icons/Au.tsx +0 -25
- package/src/country-selector/icons/Aw.tsx +0 -22
- package/src/country-selector/icons/Az.tsx +0 -22
- package/src/country-selector/icons/Ba.tsx +0 -18
- package/src/country-selector/icons/Bb.tsx +0 -22
- package/src/country-selector/icons/Bd.tsx +0 -14
- package/src/country-selector/icons/Be.tsx +0 -18
- package/src/country-selector/icons/Bf.tsx +0 -21
- package/src/country-selector/icons/Bg.tsx +0 -18
- package/src/country-selector/icons/Bh.tsx +0 -17
- package/src/country-selector/icons/Bi.tsx +0 -45
- package/src/country-selector/icons/Bj.tsx +0 -21
- package/src/country-selector/icons/Bm.tsx +0 -103
- package/src/country-selector/icons/Bo.tsx +0 -177
- package/src/country-selector/icons/Br.tsx +0 -22
- package/src/country-selector/icons/Bs.tsx +0 -18
- package/src/country-selector/icons/Bt.tsx +0 -49
- package/src/country-selector/icons/Bw.tsx +0 -15
- package/src/country-selector/icons/By.tsx +0 -25
- package/src/country-selector/icons/Bz.tsx +0 -193
- package/src/country-selector/icons/Ca.tsx +0 -17
- package/src/country-selector/icons/Cd.tsx +0 -25
- package/src/country-selector/icons/Cf.tsx +0 -24
- package/src/country-selector/icons/Cg.tsx +0 -21
- package/src/country-selector/icons/Ch.tsx +0 -17
- package/src/country-selector/icons/Ci.tsx +0 -18
- package/src/country-selector/icons/Ck.tsx +0 -29
- package/src/country-selector/icons/Cl.tsx +0 -25
- package/src/country-selector/icons/Cm.tsx +0 -18
- package/src/country-selector/icons/Cn.tsx +0 -17
- package/src/country-selector/icons/Co.tsx +0 -18
- package/src/country-selector/icons/Cr.tsx +0 -79
- package/src/country-selector/icons/Cu.tsx +0 -24
- package/src/country-selector/icons/Cv.tsx +0 -19
- package/src/country-selector/icons/Cw.tsx +0 -18
- package/src/country-selector/icons/Cy.tsx +0 -22
- package/src/country-selector/icons/Cz.tsx +0 -21
- package/src/country-selector/icons/De.tsx +0 -18
- package/src/country-selector/icons/Dj.tsx +0 -25
- package/src/country-selector/icons/Dk.tsx +0 -17
- package/src/country-selector/icons/Dm.tsx +0 -60
- package/src/country-selector/icons/Do.tsx +0 -127
- package/src/country-selector/icons/Dz.tsx +0 -21
- package/src/country-selector/icons/Ec.tsx +0 -123
- package/src/country-selector/icons/Ee.tsx +0 -18
- package/src/country-selector/icons/Eg.tsx +0 -22
- package/src/country-selector/icons/Er.tsx +0 -25
- package/src/country-selector/icons/Es.tsx +0 -80
- package/src/country-selector/icons/Et.tsx +0 -26
- package/src/country-selector/icons/Fi.tsx +0 -17
- package/src/country-selector/icons/Fj.tsx +0 -112
- package/src/country-selector/icons/Fk.tsx +0 -96
- package/src/country-selector/icons/Fm.tsx +0 -17
- package/src/country-selector/icons/Fo.tsx +0 -21
- package/src/country-selector/icons/Fr.tsx +0 -18
- package/src/country-selector/icons/Ga.tsx +0 -18
- package/src/country-selector/icons/Gb.tsx +0 -21
- package/src/country-selector/icons/Gd.tsx +0 -24
- package/src/country-selector/icons/Ge.tsx +0 -17
- package/src/country-selector/icons/Gg.tsx +0 -21
- package/src/country-selector/icons/Gh.tsx +0 -22
- package/src/country-selector/icons/Gi.tsx +0 -25
- package/src/country-selector/icons/Gl.tsx +0 -21
- package/src/country-selector/icons/Gm.tsx +0 -19
- package/src/country-selector/icons/Gn.tsx +0 -18
- package/src/country-selector/icons/Gq.tsx +0 -42
- package/src/country-selector/icons/Gr.tsx +0 -23
- package/src/country-selector/icons/Gt.tsx +0 -102
- package/src/country-selector/icons/Gu.tsx +0 -42
- package/src/country-selector/icons/Gw.tsx +0 -25
- package/src/country-selector/icons/Hk.tsx +0 -18
- package/src/country-selector/icons/Hn.tsx +0 -18
- package/src/country-selector/icons/Hr.tsx +0 -78
- package/src/country-selector/icons/Ht.tsx +0 -17
- package/src/country-selector/icons/Hu.tsx +0 -18
- package/src/country-selector/icons/Id.tsx +0 -17
- package/src/country-selector/icons/Ie.tsx +0 -18
- package/src/country-selector/icons/Il.tsx +0 -18
- package/src/country-selector/icons/Im.tsx +0 -76
- package/src/country-selector/icons/In.tsx +0 -34
- package/src/country-selector/icons/Io.tsx +0 -37
- package/src/country-selector/icons/Iq.tsx +0 -22
- package/src/country-selector/icons/Ir.tsx +0 -25
- package/src/country-selector/icons/Is.tsx +0 -21
- package/src/country-selector/icons/It.tsx +0 -18
- package/src/country-selector/icons/Je.tsx +0 -74
- package/src/country-selector/icons/Jm.tsx +0 -18
- package/src/country-selector/icons/Jo.tsx +0 -26
- package/src/country-selector/icons/Jp.tsx +0 -14
- package/src/country-selector/icons/Ke.tsx +0 -35
- package/src/country-selector/icons/Kg.tsx +0 -17
- package/src/country-selector/icons/Kh.tsx +0 -18
- package/src/country-selector/icons/Ki.tsx +0 -38
- package/src/country-selector/icons/Km.tsx +0 -27
- package/src/country-selector/icons/Kn.tsx +0 -29
- package/src/country-selector/icons/Kp.tsx +0 -20
- package/src/country-selector/icons/Kr.tsx +0 -25
- package/src/country-selector/icons/Kw.tsx +0 -22
- package/src/country-selector/icons/Ky.tsx +0 -134
- package/src/country-selector/icons/Kz.tsx +0 -19
- package/src/country-selector/icons/La.tsx +0 -15
- package/src/country-selector/icons/Lb.tsx +0 -18
- package/src/country-selector/icons/Li.tsx +0 -25
- package/src/country-selector/icons/Lk.tsx +0 -67
- package/src/country-selector/icons/Lr.tsx +0 -34
- package/src/country-selector/icons/Ls.tsx +0 -22
- package/src/country-selector/icons/Lt.tsx +0 -18
- package/src/country-selector/icons/Lu.tsx +0 -18
- package/src/country-selector/icons/Lv.tsx +0 -14
- package/src/country-selector/icons/Ly.tsx +0 -22
- package/src/country-selector/icons/Ma.tsx +0 -17
- package/src/country-selector/icons/Mc.tsx +0 -17
- package/src/country-selector/icons/Md.tsx +0 -100
- package/src/country-selector/icons/Me.tsx +0 -33
- package/src/country-selector/icons/Mg.tsx +0 -18
- package/src/country-selector/icons/Mh.tsx +0 -25
- package/src/country-selector/icons/Mk.tsx +0 -17
- package/src/country-selector/icons/Ml.tsx +0 -18
- package/src/country-selector/icons/Mm.tsx +0 -22
- package/src/country-selector/icons/Mn.tsx +0 -24
- package/src/country-selector/icons/Mo.tsx +0 -21
- package/src/country-selector/icons/Mp.tsx +0 -53
- package/src/country-selector/icons/Mq.tsx +0 -17
- package/src/country-selector/icons/Mr.tsx +0 -17
- package/src/country-selector/icons/Ms.tsx +0 -62
- package/src/country-selector/icons/Mt.tsx +0 -51
- package/src/country-selector/icons/Mu.tsx +0 -19
- package/src/country-selector/icons/Mv.tsx +0 -18
- package/src/country-selector/icons/Mw.tsx +0 -21
- package/src/country-selector/icons/Mx.tsx +0 -65
- package/src/country-selector/icons/My.tsx +0 -37
- package/src/country-selector/icons/Mz.tsx +0 -36
- package/src/country-selector/icons/Na.tsx +0 -26
- package/src/country-selector/icons/Nato.tsx +0 -17
- package/src/country-selector/icons/Ne.tsx +0 -19
- package/src/country-selector/icons/Nf.tsx +0 -18
- package/src/country-selector/icons/Ng.tsx +0 -18
- package/src/country-selector/icons/Ni.tsx +0 -73
- package/src/country-selector/icons/Nl.tsx +0 -18
- package/src/country-selector/icons/No.tsx +0 -21
- package/src/country-selector/icons/Np.tsx +0 -25
- package/src/country-selector/icons/Nr.tsx +0 -18
- package/src/country-selector/icons/Nu.tsx +0 -30
- package/src/country-selector/icons/Nz.tsx +0 -49
- package/src/country-selector/icons/Om.tsx +0 -29
- package/src/country-selector/icons/Pa.tsx +0 -25
- package/src/country-selector/icons/Pe.tsx +0 -18
- package/src/country-selector/icons/Pf.tsx +0 -30
- package/src/country-selector/icons/Pg.tsx +0 -25
- package/src/country-selector/icons/Ph.tsx +0 -25
- package/src/country-selector/icons/Pk.tsx +0 -17
- package/src/country-selector/icons/Pl.tsx +0 -17
- package/src/country-selector/icons/Pn.tsx +0 -153
- package/src/country-selector/icons/Pr.tsx +0 -27
- package/src/country-selector/icons/Ps.tsx +0 -22
- package/src/country-selector/icons/Pt.tsx +0 -39
- package/src/country-selector/icons/Pw.tsx +0 -14
- package/src/country-selector/icons/Py.tsx +0 -31
- package/src/country-selector/icons/Qa.tsx +0 -17
- package/src/country-selector/icons/Ro.tsx +0 -18
- package/src/country-selector/icons/Rs.tsx +0 -89
- package/src/country-selector/icons/Ru.tsx +0 -18
- package/src/country-selector/icons/Rw.tsx +0 -22
- package/src/country-selector/icons/Sa.tsx +0 -23
- package/src/country-selector/icons/Sb.tsx +0 -25
- package/src/country-selector/icons/Sc.tsx +0 -29
- package/src/country-selector/icons/Sd.tsx +0 -22
- package/src/country-selector/icons/Se.tsx +0 -17
- package/src/country-selector/icons/Sg.tsx +0 -17
- package/src/country-selector/icons/Si.tsx +0 -33
- package/src/country-selector/icons/Sk.tsx +0 -34
- package/src/country-selector/icons/Sl.tsx +0 -18
- package/src/country-selector/icons/Sm.tsx +0 -102
- package/src/country-selector/icons/Sn.tsx +0 -22
- package/src/country-selector/icons/So.tsx +0 -17
- package/src/country-selector/icons/Sq.tsx +0 -41
- package/src/country-selector/icons/Sr.tsx +0 -19
- package/src/country-selector/icons/Ss.tsx +0 -30
- package/src/country-selector/icons/St.tsx +0 -22
- package/src/country-selector/icons/Sv.tsx +0 -141
- package/src/country-selector/icons/Sx.tsx +0 -71
- package/src/country-selector/icons/Sy.tsx +0 -22
- package/src/country-selector/icons/Sz.tsx +0 -60
- package/src/country-selector/icons/Tc.tsx +0 -53
- package/src/country-selector/icons/Td.tsx +0 -18
- package/src/country-selector/icons/Tg.tsx +0 -27
- package/src/country-selector/icons/Th.tsx +0 -14
- package/src/country-selector/icons/Tibet.tsx +0 -260
- package/src/country-selector/icons/Tj.tsx +0 -22
- package/src/country-selector/icons/Tk.tsx +0 -21
- package/src/country-selector/icons/Tm.tsx +0 -59
- package/src/country-selector/icons/Tn.tsx +0 -21
- package/src/country-selector/icons/To.tsx +0 -21
- package/src/country-selector/icons/Tr.tsx +0 -17
- package/src/country-selector/icons/Tt.tsx +0 -18
- package/src/country-selector/icons/Tv.tsx +0 -29
- package/src/country-selector/icons/Tw.tsx +0 -21
- package/src/country-selector/icons/Tz.tsx +0 -22
- package/src/country-selector/icons/Ua.tsx +0 -17
- package/src/country-selector/icons/Ug.tsx +0 -51
- package/src/country-selector/icons/Us.tsx +0 -25
- package/src/country-selector/icons/Uy.tsx +0 -53
- package/src/country-selector/icons/Uz.tsx +0 -27
- package/src/country-selector/icons/Ve.tsx +0 -22
- package/src/country-selector/icons/Vi.tsx +0 -42
- package/src/country-selector/icons/Vn.tsx +0 -17
- package/src/country-selector/icons/Vu.tsx +0 -29
- package/src/country-selector/icons/Ws.tsx +0 -21
- package/src/country-selector/icons/Ye.tsx +0 -18
- package/src/country-selector/icons/Za.tsx +0 -25
- package/src/country-selector/icons/Zm.tsx +0 -23
- package/src/country-selector/icons/Zw.tsx +0 -41
- package/src/country-selector/icons/index.ts +0 -223
- package/src/country-selector/index.ts +0 -2
- package/src/index.ts +0 -17
- package/src/input/index.ts +0 -2
- package/src/input/input.module.css +0 -71
- package/src/input/input.tsx +0 -38
- package/src/input/input.types.ts +0 -10
- package/src/loader/index.ts +0 -1
- package/src/loader/loader.module.css +0 -40
- package/src/loader/loader.tsx +0 -30
- package/src/modal/index.ts +0 -1
- package/src/modal/modal.module.css +0 -22
- package/src/modal/modal.tsx +0 -27
- package/src/mount-react-hook/index.ts +0 -2
- package/src/mount-react-hook/mount-react-hook.tsx +0 -28
- package/src/mount-react-hook/mount-react-hook.types.ts +0 -5
- package/src/pagination/index.ts +0 -2
- package/src/pagination/pagination.module.css +0 -31
- package/src/pagination/pagination.tsx +0 -90
- package/src/pagination/pagination.types.ts +0 -4
- package/src/select/icons/ArrowBottom.tsx +0 -12
- package/src/select/icons/index.ts +0 -1
- package/src/select/index.ts +0 -2
- package/src/select/select.module.css +0 -54
- package/src/select/select.tsx +0 -85
- package/src/select/select.types.ts +0 -9
- package/src/table/index.ts +0 -2
- package/src/table/table.module.css +0 -33
- package/src/table/table.tsx +0 -83
- package/src/table/table.types.ts +0 -5
- package/src/use-breadcrumb/index.ts +0 -2
- package/src/use-breadcrumb/use-breadcrumb.tsx +0 -35
- package/src/use-breadcrumb/use-breadcrumb.types.ts +0 -12
- package/src/use-match-device/index.ts +0 -2
- package/src/use-match-device/use-match-device.ts +0 -41
- package/src/use-match-device/use-match-device.types.ts +0 -6
- package/src/use-match-resolution/index.ts +0 -2
- package/src/use-match-resolution/use-match-resolution.ts +0 -72
- package/src/use-match-resolution/use-match-resolution.types.ts +0 -37
- package/src/use-outside-alerter/index.ts +0 -2
- package/src/use-outside-alerter/use-outside-alerter.tsx +0 -29
- package/src/use-outside-alerter/use-outside-alerter.types.ts +0 -4
- package/src/use-pagination/index.ts +0 -2
- package/src/use-pagination/use-pagination.ts +0 -86
- package/src/use-pagination/use-pagination.types.ts +0 -11
- package/src/use-scroll-to/index.ts +0 -2
- package/src/use-scroll-to/use-scroll-to.tsx +0 -25
- package/src/use-scroll-to/use-scroll-to.types.ts +0 -3
- package/src/use-visible/index.ts +0 -1
- package/src/use-visible/use-visible.ts +0 -31
- package/src/wizard/index.ts +0 -2
- package/src/wizard/wizard.tsx +0 -44
- package/src/wizard/wizard.types.ts +0 -7
- package/stories/breadcrumb/breadcrumb.stories.tsx +0 -21
- package/stories/country-selector/country-selector.stories.tsx +0 -14
- package/stories/input/input.stories.tsx +0 -42
- package/stories/loader/assets/white-loader.svg +0 -20
- package/stories/loader/loader.stories.tsx +0 -12
- package/stories/modal/modal.stories.tsx +0 -21
- package/stories/pagination/assets/double-left-arrow.svg +0 -13
- package/stories/pagination/assets/double-right-arrow.svg +0 -13
- package/stories/pagination/assets/single-left-arrow.svg +0 -10
- package/stories/pagination/assets/single-right-arrow.svg +0 -10
- package/stories/pagination/pagination.stories.tsx +0 -89
- package/stories/select/select.stories.tsx +0 -33
- package/stories/table/assets/double-left-arrow.svg +0 -13
- package/stories/table/assets/double-right-arrow.svg +0 -13
- package/stories/table/assets/single-left-arrow.svg +0 -10
- package/stories/table/assets/single-right-arrow.svg +0 -10
- package/stories/table/table.stories.tsx +0 -219
- package/stories/use-match-device/use-match-device.stories.tsx +0 -22
- package/stories/use-match-resolution/use-match-resolution.stories.tsx +0 -31
- package/stories/use-outside-alerter/use-outside-alerter.stories.tsx +0 -19
- package/stories/use-scroll-to/use-scroll-to.stories.tsx +0 -74
- package/stories/use-visible/use-visible.stories.tsx +0 -71
- package/stories/wizard/wizard.stories.tsx +0 -35
- package/tests/pagination/use-pagination.test.ts +0 -23
- package/tests/setup.js +0 -23
- package/tests/use-match-resolution/use-match-resolution.test.ts +0 -32
- package/tests/use-visible/use-visible.test.tsx +0 -53
- package/tsconfig.json +0 -16
- package/typedoc.json +0 -7
- package/types.d.ts +0 -5
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React, { ComponentType } from "react";
|
|
2
|
-
import { render } from "@testing-library/react";
|
|
3
|
-
import { MountedHook } from "./mount-react-hook.types";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* React hook to mount a hook in an unit test.
|
|
7
|
-
* @public
|
|
8
|
-
* @param Component - The component to be tested.
|
|
9
|
-
* @param props - Props passed to the component.
|
|
10
|
-
* @returns The component, the value it returns and a function to unmount the component.
|
|
11
|
-
*/
|
|
12
|
-
export const mountReactHook = (
|
|
13
|
-
Component: ComponentType,
|
|
14
|
-
props: ObjectLiteral = {},
|
|
15
|
-
): MountedHook => {
|
|
16
|
-
let value: ObjectLiteral | Primitive = null;
|
|
17
|
-
|
|
18
|
-
const { container, unmount } = render(
|
|
19
|
-
<Component {...props}>
|
|
20
|
-
{(hookValue: ObjectLiteral | Primitive) => {
|
|
21
|
-
value = hookValue;
|
|
22
|
-
return null;
|
|
23
|
-
}}
|
|
24
|
-
</Component>,
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
return { container, unmount, value };
|
|
28
|
-
};
|
package/src/pagination/index.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
--hover-background-color: lightgrey;
|
|
3
|
-
--hover-text-color: black;
|
|
4
|
-
--selected-background-color: black;
|
|
5
|
-
--selected-text-color: white;
|
|
6
|
-
|
|
7
|
-
display: flex;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.item {
|
|
11
|
-
border-style: solid;
|
|
12
|
-
border-width: 1px 1px 1px 0;
|
|
13
|
-
padding: 0.5rem 1rem 0.5rem 1rem;
|
|
14
|
-
display: flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
|
|
18
|
-
&:first-child {
|
|
19
|
-
border-width: 1px 1px 1px 1px;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&:hover:not(.selected) {
|
|
23
|
-
background-color: var(--hover-background-color);
|
|
24
|
-
color: var(--hover-text-color);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&.selected {
|
|
28
|
-
background-color: var(--selected-background-color);
|
|
29
|
-
color: var(--selected-text-color);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import styles from "./pagination.module.css";
|
|
4
|
-
import { PaginationData, PaginationColors } from "..";
|
|
5
|
-
|
|
6
|
-
export enum ArrowPosition {
|
|
7
|
-
LEFT,
|
|
8
|
-
RIGHT,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
type Props = PaginationData & {
|
|
12
|
-
colors?: PaginationColors;
|
|
13
|
-
renderSingleArrow?: (position: ArrowPosition) => ReactNode;
|
|
14
|
-
renderDoubleArrow?: (position: ArrowPosition) => ReactNode;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* React component used to display a pagination (with numbers).
|
|
19
|
-
* @public
|
|
20
|
-
* @param props - An object which contains:
|
|
21
|
-
* - properties inherited from the Pagination interface in usePagination hook
|
|
22
|
-
* - some properties to customise the rendering
|
|
23
|
-
* @returns A React component.
|
|
24
|
-
*/
|
|
25
|
-
export const Pagination = ({
|
|
26
|
-
page,
|
|
27
|
-
total,
|
|
28
|
-
items,
|
|
29
|
-
colors,
|
|
30
|
-
goToFirst,
|
|
31
|
-
goToLeft,
|
|
32
|
-
goToRight,
|
|
33
|
-
goToLast,
|
|
34
|
-
goToPage,
|
|
35
|
-
renderSingleArrow,
|
|
36
|
-
renderDoubleArrow,
|
|
37
|
-
}: Props) => {
|
|
38
|
-
const CSSVariables = {
|
|
39
|
-
"--hover-background-color": colors?.hover.background,
|
|
40
|
-
"--hover-text-color": colors?.hover.text,
|
|
41
|
-
"--selected-background-color": colors?.selected.background,
|
|
42
|
-
"--selected-text-color": colors?.selected.text,
|
|
43
|
-
} as CSSProperties;
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<div className={styles.container} style={CSSVariables}>
|
|
47
|
-
{page > 1 && (
|
|
48
|
-
<>
|
|
49
|
-
{renderDoubleArrow && (
|
|
50
|
-
<div className={styles.item} onClick={() => goToFirst()}>
|
|
51
|
-
{renderDoubleArrow(ArrowPosition.LEFT)}
|
|
52
|
-
</div>
|
|
53
|
-
)}
|
|
54
|
-
|
|
55
|
-
{renderSingleArrow && (
|
|
56
|
-
<div className={styles.item} onClick={() => goToLeft()}>
|
|
57
|
-
{renderSingleArrow(ArrowPosition.LEFT)}
|
|
58
|
-
</div>
|
|
59
|
-
)}
|
|
60
|
-
</>
|
|
61
|
-
)}
|
|
62
|
-
|
|
63
|
-
{items.map((currentPage: number, index: number) => (
|
|
64
|
-
<div
|
|
65
|
-
className={clsx(styles.item, currentPage === page && styles.selected)}
|
|
66
|
-
key={index}
|
|
67
|
-
onClick={() => goToPage(currentPage)}
|
|
68
|
-
>
|
|
69
|
-
{currentPage}
|
|
70
|
-
</div>
|
|
71
|
-
))}
|
|
72
|
-
|
|
73
|
-
{page < total && (
|
|
74
|
-
<>
|
|
75
|
-
{renderSingleArrow && (
|
|
76
|
-
<div className={styles.item} onClick={() => goToRight()}>
|
|
77
|
-
{renderSingleArrow(ArrowPosition.RIGHT)}
|
|
78
|
-
</div>
|
|
79
|
-
)}
|
|
80
|
-
|
|
81
|
-
{renderDoubleArrow && (
|
|
82
|
-
<div className={styles.item} onClick={() => goToLast()}>
|
|
83
|
-
{renderDoubleArrow(ArrowPosition.RIGHT)}
|
|
84
|
-
</div>
|
|
85
|
-
)}
|
|
86
|
-
</>
|
|
87
|
-
)}
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { SVGProps } from "react";
|
|
3
|
-
const SvgArrowBottom = (props: SVGProps<SVGSVGElement>) => (
|
|
4
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 18" {...props}>
|
|
5
|
-
<path
|
|
6
|
-
fill="#171D27"
|
|
7
|
-
fillRule="nonzero"
|
|
8
|
-
d="m17.202 17.352 13.46-13.577a2.224 2.224 0 0 0 0-3.127 2.179 2.179 0 0 0-3.1 0l-11.91 12.014L3.742.648a2.18 2.18 0 0 0-3.1 0 2.225 2.225 0 0 0 0 3.127l13.46 13.578a2.175 2.175 0 0 0 3.1 0Z"
|
|
9
|
-
/>
|
|
10
|
-
</svg>
|
|
11
|
-
);
|
|
12
|
-
export default SvgArrowBottom;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as ArrowBottom } from "./ArrowBottom";
|
package/src/select/index.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
width: fit-content;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.selected-option-container {
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
user-select: none;
|
|
10
|
-
padding: 10px;
|
|
11
|
-
background-color: white;
|
|
12
|
-
border-radius: 5px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.selected-option-text {
|
|
16
|
-
padding-right: 10px;
|
|
17
|
-
border-right: 1px solid black;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.selected-option-arrow {
|
|
21
|
-
width: 15px;
|
|
22
|
-
margin-left: 10px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.options-list {
|
|
26
|
-
width: 100%;
|
|
27
|
-
list-style: none;
|
|
28
|
-
padding: 0;
|
|
29
|
-
margin: 10px 0 0 0;
|
|
30
|
-
user-select: none;
|
|
31
|
-
background-color: white;
|
|
32
|
-
border-radius: 5px;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.option {
|
|
36
|
-
padding: 10px;
|
|
37
|
-
cursor: pointer;
|
|
38
|
-
|
|
39
|
-
&:hover {
|
|
40
|
-
background-color: #ecf0f1;
|
|
41
|
-
|
|
42
|
-
&:first-child {
|
|
43
|
-
border-radius: 5px 5px 0 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
&:last-child {
|
|
47
|
-
border-radius: 0 0 5px 5px;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&:only-child {
|
|
51
|
-
border-radius: 5px;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
package/src/select/select.tsx
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import styles from "./select.module.css";
|
|
3
|
-
import { SelectOptionWithoutId, SelectOption } from "./select.types";
|
|
4
|
-
import { useOutsideAlerter } from "..";
|
|
5
|
-
import { ArrowBottom } from "./icons";
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
options: SelectOptionWithoutId[];
|
|
9
|
-
selectedValue?: string;
|
|
10
|
-
onChange?: (option: SelectOption) => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const Select = ({ options: optionsProps, selectedValue, onChange }: Props) => {
|
|
14
|
-
const [options, setOptions] = useState<SelectOption[]>(null);
|
|
15
|
-
const [isListVisible, setListVisibility] = useState<boolean>(false);
|
|
16
|
-
const [selectedOption, setSelectedOption] = useState<SelectOption>(null);
|
|
17
|
-
const ref = useRef(null);
|
|
18
|
-
const { hasClickedOutside, onReset: onResetOutsideAlerter } = useOutsideAlerter(ref);
|
|
19
|
-
|
|
20
|
-
const handleSelectedOptionClick = () => {
|
|
21
|
-
onResetOutsideAlerter();
|
|
22
|
-
setListVisibility(!isListVisible);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const handleOptionClick = (option: SelectOption) => {
|
|
26
|
-
setSelectedOption(option);
|
|
27
|
-
setListVisibility(false);
|
|
28
|
-
|
|
29
|
-
if (onChange) {
|
|
30
|
-
onChange(option);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
setOptions(
|
|
36
|
-
optionsProps.map((option: SelectOptionWithoutId, index: number) => ({
|
|
37
|
-
...option,
|
|
38
|
-
id: index,
|
|
39
|
-
})),
|
|
40
|
-
);
|
|
41
|
-
}, [optionsProps]);
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (options && !selectedOption) {
|
|
45
|
-
setSelectedOption(
|
|
46
|
-
selectedValue ? options.find((option) => option.value === selectedValue) : options[0],
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}, [options]);
|
|
50
|
-
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
if (hasClickedOutside) {
|
|
53
|
-
setListVisibility(false);
|
|
54
|
-
}
|
|
55
|
-
}, [hasClickedOutside]);
|
|
56
|
-
|
|
57
|
-
if (!options || !selectedOption) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div className={styles.container} ref={ref}>
|
|
63
|
-
<div className={styles["selected-option-container"]} onClick={handleSelectedOptionClick}>
|
|
64
|
-
<span className={styles["selected-option-text"]}>{selectedOption.label}</span>
|
|
65
|
-
<ArrowBottom className={styles["selected-option-arrow"]} />
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
{isListVisible && (
|
|
69
|
-
<ul className={styles["options-list"]}>
|
|
70
|
-
{options
|
|
71
|
-
.filter((option: SelectOption) => option.id !== selectedOption.id)
|
|
72
|
-
.map((option: SelectOption) => (
|
|
73
|
-
<li
|
|
74
|
-
className={styles.option}
|
|
75
|
-
key={option.id}
|
|
76
|
-
onClick={() => handleOptionClick(option)}
|
|
77
|
-
>
|
|
78
|
-
{option.label}
|
|
79
|
-
</li>
|
|
80
|
-
))}
|
|
81
|
-
</ul>
|
|
82
|
-
)}
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
};
|
package/src/table/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
.container {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-flow: column;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.main {
|
|
7
|
-
width: 100%;
|
|
8
|
-
table-layout: fixed;
|
|
9
|
-
border-collapse: collapse;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.tbody {
|
|
13
|
-
user-select: text;
|
|
14
|
-
tr:last-child {
|
|
15
|
-
border: none;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.th {
|
|
20
|
-
padding: 2rem 1rem 1rem 0;
|
|
21
|
-
word-wrap: break-word;
|
|
22
|
-
white-space: nowrap;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.tr {
|
|
26
|
-
text-align: center;
|
|
27
|
-
border-bottom: 2px solid black;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.td {
|
|
31
|
-
padding: 2rem 1rem 1rem 0;
|
|
32
|
-
word-wrap: break-word;
|
|
33
|
-
}
|
package/src/table/table.tsx
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, PropsWithChildren } from "react";
|
|
2
|
-
import styles from "./table.module.css";
|
|
3
|
-
import { Column } from "./table.types";
|
|
4
|
-
|
|
5
|
-
type Props<T> = {
|
|
6
|
-
columns: Column[];
|
|
7
|
-
records: T[];
|
|
8
|
-
renderHeader?: () => ReactNode;
|
|
9
|
-
renderFooter?: () => ReactNode;
|
|
10
|
-
renderColumnsRow?: (columns: ReactNode) => ReactNode;
|
|
11
|
-
renderColumnsCell?: (column: Column, key: string) => ReactNode;
|
|
12
|
-
renderRecordsRow?: (cells: ReactNode, key: string) => ReactNode;
|
|
13
|
-
renderRecordsCell?: (cell: Primitive, key: string) => ReactNode;
|
|
14
|
-
renderRecordsEmptyCell?: (key: string) => ReactNode;
|
|
15
|
-
renderNoRecords?: () => ReactNode;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* React component used to display a data table.
|
|
20
|
-
* @public
|
|
21
|
-
* @param props - An Object which contains:
|
|
22
|
-
* - columns: the table columns
|
|
23
|
-
* - records: the table records
|
|
24
|
-
* - some properties to customise the rendering
|
|
25
|
-
* @returns A React component.
|
|
26
|
-
*/
|
|
27
|
-
export const Table = <T,>({
|
|
28
|
-
columns,
|
|
29
|
-
records,
|
|
30
|
-
renderHeader = () => null,
|
|
31
|
-
renderFooter = () => null,
|
|
32
|
-
renderColumnsRow = (columns: ReactNode) => <tr>{columns}</tr>,
|
|
33
|
-
renderColumnsCell = (column: Column, key: string) => <Th key={key}>{column.name}</Th>,
|
|
34
|
-
renderRecordsRow = (cells: ReactNode, key: string) => <Tr key={key}>{cells}</Tr>,
|
|
35
|
-
renderRecordsCell = (cell: Primitive, key: string) => <Td key={key}>{cell}</Td>,
|
|
36
|
-
renderRecordsEmptyCell = (key: string) => <Td key={key}>X</Td>,
|
|
37
|
-
renderNoRecords = () => null,
|
|
38
|
-
}: Props<T>) => {
|
|
39
|
-
const displayColumns = () =>
|
|
40
|
-
renderColumnsRow(
|
|
41
|
-
columns.map((column: Column, index: number) => renderColumnsCell(column, `column-${index}`)),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const displayRows = () => {
|
|
45
|
-
const columnNames: string[] = columns.map((column: Column) => column.name);
|
|
46
|
-
|
|
47
|
-
return records.map((record: T, rowIndex: number) => {
|
|
48
|
-
const cells: Primitive[] = columnNames.map((name: string) => (record as ObjectLiteral)[name]);
|
|
49
|
-
|
|
50
|
-
return renderRecordsRow(
|
|
51
|
-
cells.map((cell: Primitive, cellIndex: number) =>
|
|
52
|
-
cell
|
|
53
|
-
? renderRecordsCell(cell, `cell-${cellIndex}`)
|
|
54
|
-
: renderRecordsEmptyCell(`cell-${cellIndex}`),
|
|
55
|
-
),
|
|
56
|
-
`row-${rowIndex}`,
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div className={styles.container}>
|
|
63
|
-
{renderHeader()}
|
|
64
|
-
|
|
65
|
-
{records.length === 0 ? (
|
|
66
|
-
renderNoRecords()
|
|
67
|
-
) : (
|
|
68
|
-
<>
|
|
69
|
-
<table className={styles.main}>
|
|
70
|
-
<thead>{displayColumns()}</thead>
|
|
71
|
-
<tbody className={styles.tbody}>{displayRows()}</tbody>
|
|
72
|
-
</table>
|
|
73
|
-
</>
|
|
74
|
-
)}
|
|
75
|
-
|
|
76
|
-
{renderFooter()}
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const Th = ({ children }: PropsWithChildren) => <th className={styles.th}>{children}</th>;
|
|
82
|
-
export const Tr = ({ children }: PropsWithChildren) => <tr className={styles.tr}>{children}</tr>;
|
|
83
|
-
export const Td = ({ children }: PropsWithChildren) => <th className={styles.td}>{children}</th>;
|
package/src/table/table.types.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { BreadcrumbType, BreadcrumbElementType } from "./use-breadcrumb.types";
|
|
3
|
-
|
|
4
|
-
export const useBreadcrumb = ({
|
|
5
|
-
url = new URL(location.href),
|
|
6
|
-
mapping,
|
|
7
|
-
}: BreadcrumbType): BreadcrumbElementType[] => {
|
|
8
|
-
const [elements, setElements] = useState<BreadcrumbElementType[]>([]);
|
|
9
|
-
|
|
10
|
-
const prepareElements = (paths: string[]) => {
|
|
11
|
-
let previousPath: string = "";
|
|
12
|
-
paths.shift();
|
|
13
|
-
|
|
14
|
-
return paths.map((path: string) => {
|
|
15
|
-
let label: string = path;
|
|
16
|
-
const url = `${previousPath}/${path}`;
|
|
17
|
-
previousPath = url;
|
|
18
|
-
|
|
19
|
-
if (mapping) {
|
|
20
|
-
const value = mapping.find((value) => value.url === path);
|
|
21
|
-
label = value ? value.label : path;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return { label, url };
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
const paths: string[] = url.pathname.split("/");
|
|
30
|
-
|
|
31
|
-
setElements(prepareElements(paths));
|
|
32
|
-
}, []);
|
|
33
|
-
|
|
34
|
-
return elements;
|
|
35
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import UAParser from "ua-parser-js";
|
|
3
|
-
import { Device } from "./use-match-device.types";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* React hook to detect the device (mobile, tablet or desktop) based on the user agent.
|
|
7
|
-
* @public
|
|
8
|
-
* @param UA - The user agent.
|
|
9
|
-
* @returns An object with multiple properties (isMobile, isTablet...) used to detect the device.
|
|
10
|
-
*/
|
|
11
|
-
export const useMatchDevice = (UA: string): Device => {
|
|
12
|
-
const isClientSide: boolean = typeof window !== "undefined";
|
|
13
|
-
|
|
14
|
-
const compute = () => {
|
|
15
|
-
const parser = new UAParser.UAParser(UA);
|
|
16
|
-
const { type } = parser.getDevice();
|
|
17
|
-
|
|
18
|
-
const device: Device = {
|
|
19
|
-
isMobile: type === "mobile",
|
|
20
|
-
isTablet: type === "tablet",
|
|
21
|
-
isMobileOrTablet: false,
|
|
22
|
-
isDesktop: !type,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
device.isMobileOrTablet = device.isMobile || device.isTablet;
|
|
26
|
-
|
|
27
|
-
return device;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
if (!isClientSide) {
|
|
31
|
-
return compute();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const [device, setDevice] = useState<Device>(compute());
|
|
35
|
-
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
setDevice(compute());
|
|
38
|
-
}, [UA]);
|
|
39
|
-
|
|
40
|
-
return device;
|
|
41
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { Breakpoints, MatchResolution, Resolution } from "./use-match-resolution.types";
|
|
3
|
-
import { useMatchDevice } from "..";
|
|
4
|
-
|
|
5
|
-
export const defaultBreakpoints: Breakpoints = {
|
|
6
|
-
desktop: "(min-width: 1281px)",
|
|
7
|
-
laptop: "(min-width: 1025px) and (max-width: 1280px)",
|
|
8
|
-
laptopOrUpper: "(min-width: 1025px)",
|
|
9
|
-
laptopOrLower: "(max-width: 1280px)",
|
|
10
|
-
tablet: "(min-width: 768px) and (max-width: 1024px)",
|
|
11
|
-
tabletOrUpper: "(min-width: 768px)",
|
|
12
|
-
tabletOrLower: "(max-width: 1024px)",
|
|
13
|
-
largeMobile: "(min-width: 481px) and (max-width: 767px)",
|
|
14
|
-
largeMobileOrUpper: "(min-width: 481px)",
|
|
15
|
-
largeMobileOrLower: "(max-width: 767px)",
|
|
16
|
-
mobile: "(min-width: 320px) and (max-width: 480px)",
|
|
17
|
-
portrait: "(orientation: portrait)",
|
|
18
|
-
landscape: "(orientation: landscape)",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* React hook to detect the resolution (desktop, laptop, tablet, mobile...).
|
|
23
|
-
* @public
|
|
24
|
-
* @param breakpoints - List of breakpoints (used for determine when a resolution is a "desktop", a "laptop" etc.).
|
|
25
|
-
* @param UA - The user agent (used for determine the resolution in case of SSR).
|
|
26
|
-
* @returns An object with three properties:
|
|
27
|
-
* - resolution: object with multiple properties (isDesktop, isLaptop...) used for know the current resolution
|
|
28
|
-
* - breakpoints: the breakpoints passed as parameters
|
|
29
|
-
* - match: function used to detect the current resolution with a custom breakpoint
|
|
30
|
-
*/
|
|
31
|
-
export const useMatchResolution = (
|
|
32
|
-
breakpoints: Breakpoints = defaultBreakpoints,
|
|
33
|
-
UA: string = "",
|
|
34
|
-
): MatchResolution => {
|
|
35
|
-
const isClientSide: boolean = typeof window !== "undefined";
|
|
36
|
-
const { isDesktop, isMobile } = useMatchDevice(UA);
|
|
37
|
-
|
|
38
|
-
const match = (query: string): boolean => isClientSide && window.matchMedia(query).matches;
|
|
39
|
-
|
|
40
|
-
const compute = (): Resolution => ({
|
|
41
|
-
isDesktop: isClientSide ? match(breakpoints.desktop) : isDesktop,
|
|
42
|
-
isLaptop: isClientSide ? match(breakpoints.laptop) : isDesktop,
|
|
43
|
-
isLaptopOrUpper: isClientSide ? match(breakpoints.laptopOrUpper) : isDesktop,
|
|
44
|
-
isLaptopOrLower: isClientSide ? match(breakpoints.laptopOrLower) : false,
|
|
45
|
-
isTablet: isClientSide ? match(breakpoints.tablet) : isMobile,
|
|
46
|
-
isTabletOrUpper: isClientSide ? match(breakpoints.tabletOrUpper) : false,
|
|
47
|
-
isTabletOrLower: isClientSide ? match(breakpoints.tabletOrLower) : isMobile,
|
|
48
|
-
isLargeMobile: isClientSide ? match(breakpoints.largeMobile) : isMobile,
|
|
49
|
-
isLargeMobileOrUpper: isClientSide ? match(breakpoints.largeMobileOrUpper) : false,
|
|
50
|
-
isLargeMobileOrLower: isClientSide ? match(breakpoints.largeMobileOrLower) : isMobile,
|
|
51
|
-
isMobile: isClientSide ? match(breakpoints.mobile) : isMobile,
|
|
52
|
-
isPortrait: isClientSide ? match(breakpoints.portrait) : false,
|
|
53
|
-
isLandscape: isClientSide ? match(breakpoints.landscape) : false,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const [resolution, setResolution] = useState<Resolution>(compute());
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
const onResize = () => setResolution(compute());
|
|
60
|
-
|
|
61
|
-
window.addEventListener("resize", onResize);
|
|
62
|
-
return () => {
|
|
63
|
-
window.removeEventListener("resize", onResize);
|
|
64
|
-
};
|
|
65
|
-
}, []);
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
setResolution(compute());
|
|
69
|
-
}, [breakpoints]);
|
|
70
|
-
|
|
71
|
-
return { resolution, breakpoints, match };
|
|
72
|
-
};
|