reso-ui 3.5.0 → 3.6.1

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/README.md CHANGED
@@ -530,6 +530,8 @@ When no container is registered (the default), breakpoints work exactly as befor
530
530
 
531
531
  ### Available context values
532
532
 
533
+ **Top-level (resolved)** — breakpoints computed from `Math.min(viewportWidth, containerWidth)`:
534
+
533
535
  | Field | Type | Description |
534
536
  |-------|------|-------------|
535
537
  | `isMobile` | `boolean` | Effective width < 640 |
@@ -539,10 +541,44 @@ When no container is registered (the default), breakpoints work exactly as befor
539
541
  | `isXLgDesktop` | `boolean` | Effective width >= 1280 |
540
542
  | `windowWidth` | `number` | Actual viewport width |
541
543
  | `windowHeight` | `number` | Actual viewport height |
542
- | `containerWidth` | `number` | Tracked container width (0 if none registered) |
543
- | `containerHeight` | `number` | Tracked container height (0 if none registered) |
544
544
  | `setContainerRef` | `(el: HTMLElement \| null) => void` | Register/unregister a container element |
545
545
 
546
+ **`viewport`** — always based on the viewport, ignoring container. Use this for structural layout decisions (e.g., whether to show a sidebar):
547
+
548
+ | Field | Type | Description |
549
+ |-------|------|-------------|
550
+ | `viewport.isMobile` | `boolean` | Viewport width < 640 |
551
+ | `viewport.isTablet` | `boolean` | 640 <= viewport width < 768 |
552
+ | `viewport.isMdDesktop` | `boolean` | 768 <= viewport width < 1024 |
553
+ | `viewport.isLgDesktop` | `boolean` | 1024 <= viewport width < 1280 |
554
+ | `viewport.isXLgDesktop` | `boolean` | Viewport width >= 1280 |
555
+ | `viewport.width` | `number` | Viewport width |
556
+ | `viewport.height` | `number` | Viewport height |
557
+
558
+ **`container`** — breakpoints and dimensions of the tracked container element:
559
+
560
+ | Field | Type | Description |
561
+ |-------|------|-------------|
562
+ | `container.isMobile` | `boolean` | Container width < 640 (true when none registered) |
563
+ | `container.isTablet` | `boolean` | 640 <= container width < 768 |
564
+ | `container.isMdDesktop` | `boolean` | 768 <= container width < 1024 |
565
+ | `container.isLgDesktop` | `boolean` | 1024 <= container width < 1280 |
566
+ | `container.isXLgDesktop` | `boolean` | Container width >= 1280 |
567
+ | `container.width` | `number` | Container width (0 if none registered) |
568
+ | `container.height` | `number` | Container height (0 if none registered) |
569
+
570
+ ### When to use which
571
+
572
+ ```tsx
573
+ // Page layout — use top-level (resolved)
574
+ const { isMobile } = useContext(ResponsiveContext);
575
+ return <View pt={isMobile ? 7 : 9}>{/* ... */}</View>;
576
+
577
+ // Structural decisions (show/hide panels) — use viewport
578
+ const { viewport } = useContext(ResponsiveContext);
579
+ const showSidebar = !viewport.isMobile && !viewport.isTablet;
580
+ ```
581
+
546
582
  ---
547
583
 
548
584
  ## Overriding the Color Palette
@@ -2,16 +2,19 @@
2
2
 
3
3
  var React = require('react');
4
4
 
5
- const ResponsiveContext = React.createContext({
5
+ const defaultBreakpoints = {
6
6
  isMobile: false,
7
7
  isTablet: false,
8
8
  isMdDesktop: false,
9
9
  isLgDesktop: false,
10
10
  isXLgDesktop: false,
11
+ };
12
+ const ResponsiveContext = React.createContext({
13
+ ...defaultBreakpoints,
11
14
  windowWidth: 0,
12
15
  windowHeight: 0,
13
- containerWidth: 0,
14
- containerHeight: 0,
16
+ viewport: { ...defaultBreakpoints, width: 0, height: 0 },
17
+ container: { ...defaultBreakpoints, isMobile: true, width: 0, height: 0 },
15
18
  setContainerRef: () => { },
16
19
  });
17
20
 
@@ -1 +1 @@
1
- {"version":3,"file":"ResponsiveContext.js","sources":["../../../src/library/context/ResponsiveContext.ts"],"sourcesContent":[null],"names":["createContext"],"mappings":";;;;AAeO,MAAM,iBAAiB,GAAGA,mBAAa,CAAqB;AACjE,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,YAAY,EAAE,KAAK;AACnB,IAAA,WAAW,EAAE,CAAC;AACd,IAAA,YAAY,EAAE,CAAC;AACf,IAAA,cAAc,EAAE,CAAC;AACjB,IAAA,eAAe,EAAE,CAAC;AAClB,IAAA,eAAe,EAAE,MAAK,EAAE,CAAC;AAC1B,CAAA;;;;"}
1
+ {"version":3,"file":"ResponsiveContext.js","sources":["../../../src/library/context/ResponsiveContext.ts"],"sourcesContent":[null],"names":["createContext"],"mappings":";;;;AA4BA,MAAM,kBAAkB,GAAiB;AACvC,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,YAAY,EAAE,KAAK;CACpB;AAEM,MAAM,iBAAiB,GAAGA,mBAAa,CAAqB;AACjE,IAAA,GAAG,kBAAkB;AACrB,IAAA,WAAW,EAAE,CAAC;AACd,IAAA,YAAY,EAAE,CAAC;AACf,IAAA,QAAQ,EAAE,EAAE,GAAG,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;AACxD,IAAA,SAAS,EAAE,EAAE,GAAG,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;AACzE,IAAA,eAAe,EAAE,MAAK,EAAE,CAAC;AAC1B,CAAA;;;;"}
@@ -14,7 +14,10 @@ const ResponsiveProvider = ({ children }) => {
14
14
  setContainerSize({ width: 0, height: 0 });
15
15
  return;
16
16
  }
17
- setContainerSize({ width: containerEl.offsetWidth, height: containerEl.offsetHeight });
17
+ setContainerSize({
18
+ width: containerEl.offsetWidth,
19
+ height: containerEl.offsetHeight,
20
+ });
18
21
  const observer = new ResizeObserver((entries) => {
19
22
  if (entries[0]) {
20
23
  setContainerSize({
@@ -29,16 +32,33 @@ const ResponsiveProvider = ({ children }) => {
29
32
  const effectiveWidth = containerEl
30
33
  ? Math.min(windowWidth, containerSize.width)
31
34
  : windowWidth;
35
+ // default band takes the effective width, which is the min of containerEl width and window width
32
36
  const band = responsive.computeBreakpointBand(effectiveWidth);
37
+ // viewport band essentially takes the absolute window width
38
+ const viewportBand = responsive.computeBreakpointBand(windowWidth);
39
+ // containerElBand takes the width of the absolute containerEl width
40
+ const containerElBand = responsive.computeBreakpointBand(containerSize.width);
33
41
  const breakpoints = React.useMemo(() => responsive.computeBreakpoints(effectiveWidth), [band]);
42
+ const viewportBreakpoints = React.useMemo(() => responsive.computeBreakpoints(windowWidth), [viewportBand]);
43
+ const containerElBreakpoints = React.useMemo(() => responsive.computeBreakpoints(containerSize.width), [containerElBand]);
44
+ const viewport = React.useMemo(() => ({
45
+ ...viewportBreakpoints,
46
+ width: windowWidth,
47
+ height: windowHeight,
48
+ }), [viewportBreakpoints, windowWidth, windowHeight]);
49
+ const container = React.useMemo(() => ({
50
+ ...containerElBreakpoints,
51
+ width: containerSize.width,
52
+ height: containerSize.height,
53
+ }), [containerElBreakpoints, containerSize.width, containerSize.height]);
34
54
  const value = React.useMemo(() => ({
35
55
  ...breakpoints,
36
56
  windowWidth,
37
57
  windowHeight,
38
- containerWidth: containerSize.width,
39
- containerHeight: containerSize.height,
58
+ viewport,
59
+ container,
40
60
  setContainerRef: setContainerEl,
41
- }), [breakpoints, windowWidth, windowHeight, containerSize.width, containerSize.height]);
61
+ }), [breakpoints, windowWidth, windowHeight, viewport, container]);
42
62
  return (React.createElement(ResponsiveContext.ResponsiveContext.Provider, { value: value }, children));
43
63
  };
44
64
 
@@ -1 +1 @@
1
- {"version":3,"file":"ResponsiveProvider.js","sources":["../../../src/library/providers/ResponsiveProvider.tsx"],"sourcesContent":[null],"names":["useWindowSize","useState","useEffect","computeBreakpointBand","useMemo","computeBreakpoints","ResponsiveContext"],"mappings":";;;;;;;MAKa,kBAAkB,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAI;IACjD,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,GAAGA,2BAAa,EAAE;IAEnD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAGC,cAAQ,CAAq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cAAc,EAAE,aAAa,CAAC,KAAK;QACnC,eAAe,EAAE,aAAa,CAAC,MAAM;AACrC,QAAA,eAAe,EAAE,cAAc;AAChC,KAAA,CAAC,EACF,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CACpF;AAED,IAAA,QACE,KAAA,CAAA,aAAA,CAACE,mCAAiB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,EACrC,QAAQ,CACkB;AAEjC;;;;"}
1
+ {"version":3,"file":"ResponsiveProvider.js","sources":["../../../src/library/providers/ResponsiveProvider.tsx"],"sourcesContent":[null],"names":["useWindowSize","useState","useEffect","computeBreakpointBand","useMemo","computeBreakpoints","ResponsiveContext"],"mappings":";;;;;;;MAKa,kBAAkB,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAI;IACjD,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,GAAGA,2BAAa,EAAE;IAEnD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAGC,cAAQ,CAAqB,IAAI,CAAC;AACxE,IAAA,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAGA,cAAQ,CAG/C,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAE3BC,eAAS,CAAC,MAAK;QACb,IAAI,CAAC,WAAW,EAAE;YAChB,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;YACzC;QACF;AAEA,QAAA,gBAAgB,CAAC;YACf,KAAK,EAAE,WAAW,CAAC,WAAW;YAC9B,MAAM,EAAE,WAAW,CAAC,YAAY;AACjC,SAAA,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,CAAC,OAAO,KAAI;AAC9C,YAAA,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;AACd,gBAAA,gBAAgB,CAAC;oBAC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,EAAE,aAAa,CAAC,KAAK;QAC1B,MAAM,EAAE,aAAa,CAAC,MAAM;AAC7B,KAAA,CAAC,EACF,CAAC,sBAAsB,EAAE,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CACpE;AAED,IAAA,MAAM,KAAK,GAAGA,aAAO,CACnB,OAAO;AACL,QAAA,GAAG,WAAW;QACd,WAAW;QACX,YAAY;QACZ,QAAQ;QACR,SAAS;AACT,QAAA,eAAe,EAAE,cAAc;AAChC,KAAA,CAAC,EACF,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,CAC9D;AAED,IAAA,QACE,KAAA,CAAA,aAAA,CAACE,mCAAiB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,EACrC,QAAQ,CACkB;AAEjC;;;;"}
@@ -1,13 +1,23 @@
1
- export interface IResponsiveContext {
1
+ export interface IBreakpoints {
2
2
  isMobile: boolean;
3
3
  isTablet: boolean;
4
4
  isMdDesktop: boolean;
5
5
  isLgDesktop: boolean;
6
6
  isXLgDesktop: boolean;
7
+ }
8
+ export interface IViewportContext extends IBreakpoints {
9
+ width: number;
10
+ height: number;
11
+ }
12
+ export interface IContainerContext extends IBreakpoints {
13
+ width: number;
14
+ height: number;
15
+ }
16
+ export interface IResponsiveContext extends IBreakpoints {
7
17
  windowWidth: number;
8
18
  windowHeight: number;
9
- containerWidth: number;
10
- containerHeight: number;
19
+ viewport: IViewportContext;
20
+ container: IContainerContext;
11
21
  setContainerRef: (el: HTMLElement | null) => void;
12
22
  }
13
23
  export declare const ResponsiveContext: import("react").Context<IResponsiveContext>;
@@ -1,15 +1,18 @@
1
1
  import { createContext } from 'react';
2
2
 
3
- const ResponsiveContext = createContext({
3
+ const defaultBreakpoints = {
4
4
  isMobile: false,
5
5
  isTablet: false,
6
6
  isMdDesktop: false,
7
7
  isLgDesktop: false,
8
8
  isXLgDesktop: false,
9
+ };
10
+ const ResponsiveContext = createContext({
11
+ ...defaultBreakpoints,
9
12
  windowWidth: 0,
10
13
  windowHeight: 0,
11
- containerWidth: 0,
12
- containerHeight: 0,
14
+ viewport: { ...defaultBreakpoints, width: 0, height: 0 },
15
+ container: { ...defaultBreakpoints, isMobile: true, width: 0, height: 0 },
13
16
  setContainerRef: () => { },
14
17
  });
15
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"ResponsiveContext.js","sources":["../../../src/library/context/ResponsiveContext.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAeO,MAAM,iBAAiB,GAAG,aAAa,CAAqB;AACjE,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,YAAY,EAAE,KAAK;AACnB,IAAA,WAAW,EAAE,CAAC;AACd,IAAA,YAAY,EAAE,CAAC;AACf,IAAA,cAAc,EAAE,CAAC;AACjB,IAAA,eAAe,EAAE,CAAC;AAClB,IAAA,eAAe,EAAE,MAAK,EAAE,CAAC;AAC1B,CAAA;;;;"}
1
+ {"version":3,"file":"ResponsiveContext.js","sources":["../../../src/library/context/ResponsiveContext.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA4BA,MAAM,kBAAkB,GAAiB;AACvC,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,YAAY,EAAE,KAAK;CACpB;AAEM,MAAM,iBAAiB,GAAG,aAAa,CAAqB;AACjE,IAAA,GAAG,kBAAkB;AACrB,IAAA,WAAW,EAAE,CAAC;AACd,IAAA,YAAY,EAAE,CAAC;AACf,IAAA,QAAQ,EAAE,EAAE,GAAG,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;AACxD,IAAA,SAAS,EAAE,EAAE,GAAG,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;AACzE,IAAA,eAAe,EAAE,MAAK,EAAE,CAAC;AAC1B,CAAA;;;;"}
@@ -1,7 +1,7 @@
1
1
  import React__default, { useState, useEffect, useMemo } from 'react';
2
2
  import { useWindowSize } from '../hooks/useWindowSize.js';
3
3
  import { ResponsiveContext } from '../context/ResponsiveContext.js';
4
- import { computeBreakpoints, computeBreakpointBand } from '../utils/responsive.js';
4
+ import { computeBreakpointBand, computeBreakpoints } from '../utils/responsive.js';
5
5
 
6
6
  const ResponsiveProvider = ({ children }) => {
7
7
  const [windowWidth, windowHeight] = useWindowSize();
@@ -12,7 +12,10 @@ const ResponsiveProvider = ({ children }) => {
12
12
  setContainerSize({ width: 0, height: 0 });
13
13
  return;
14
14
  }
15
- setContainerSize({ width: containerEl.offsetWidth, height: containerEl.offsetHeight });
15
+ setContainerSize({
16
+ width: containerEl.offsetWidth,
17
+ height: containerEl.offsetHeight,
18
+ });
16
19
  const observer = new ResizeObserver((entries) => {
17
20
  if (entries[0]) {
18
21
  setContainerSize({
@@ -27,16 +30,33 @@ const ResponsiveProvider = ({ children }) => {
27
30
  const effectiveWidth = containerEl
28
31
  ? Math.min(windowWidth, containerSize.width)
29
32
  : windowWidth;
33
+ // default band takes the effective width, which is the min of containerEl width and window width
30
34
  const band = computeBreakpointBand(effectiveWidth);
35
+ // viewport band essentially takes the absolute window width
36
+ const viewportBand = computeBreakpointBand(windowWidth);
37
+ // containerElBand takes the width of the absolute containerEl width
38
+ const containerElBand = computeBreakpointBand(containerSize.width);
31
39
  const breakpoints = useMemo(() => computeBreakpoints(effectiveWidth), [band]);
40
+ const viewportBreakpoints = useMemo(() => computeBreakpoints(windowWidth), [viewportBand]);
41
+ const containerElBreakpoints = useMemo(() => computeBreakpoints(containerSize.width), [containerElBand]);
42
+ const viewport = useMemo(() => ({
43
+ ...viewportBreakpoints,
44
+ width: windowWidth,
45
+ height: windowHeight,
46
+ }), [viewportBreakpoints, windowWidth, windowHeight]);
47
+ const container = useMemo(() => ({
48
+ ...containerElBreakpoints,
49
+ width: containerSize.width,
50
+ height: containerSize.height,
51
+ }), [containerElBreakpoints, containerSize.width, containerSize.height]);
32
52
  const value = useMemo(() => ({
33
53
  ...breakpoints,
34
54
  windowWidth,
35
55
  windowHeight,
36
- containerWidth: containerSize.width,
37
- containerHeight: containerSize.height,
56
+ viewport,
57
+ container,
38
58
  setContainerRef: setContainerEl,
39
- }), [breakpoints, windowWidth, windowHeight, containerSize.width, containerSize.height]);
59
+ }), [breakpoints, windowWidth, windowHeight, viewport, container]);
40
60
  return (React__default.createElement(ResponsiveContext.Provider, { value: value }, children));
41
61
  };
42
62
 
@@ -1 +1 @@
1
- {"version":3,"file":"ResponsiveProvider.js","sources":["../../../src/library/providers/ResponsiveProvider.tsx"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;MAKa,kBAAkB,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAI;IACjD,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,GAAG,aAAa,EAAE;IAEnD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAqB,IAAI,CAAC;AACxE,IAAA,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAoC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAE9G,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,WAAW,EAAE;YAChB,gBAAgB,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;YACzC;QACF;AAEA,QAAA,gBAAgB,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,YAAY,EAAE,CAAC;QAEtF,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,CAAC,OAAO,KAAI;AAC9C,YAAA,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;AACd,gBAAA,gBAAgB,CAAC;oBACf,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK;oBACnC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM;AACtC,iBAAA,CAAC;YACJ;AACF,QAAA,CAAC,CAAC;AAEF,QAAA,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC;AAC7B,QAAA,OAAO,MAAM,QAAQ,CAAC,UAAU,EAAE;AACpC,IAAA,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAEjB,MAAM,cAAc,GAAG;UACnB,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC,KAAK;UACzC,WAAW;AAEf,IAAA,MAAM,IAAI,GAAG,qBAAqB,CAAC,cAAc,CAAC;AAElD,IAAA,MAAM,WAAW,GAAG,OAAO,CACzB,MAAM,kBAAkB,CAAC,cAAc,CAAC,EACxC,CAAC,IAAI,CAAC,CACP;AAED,IAAA,MAAM,KAAK,GAAG,OAAO,CACnB,OAAO;AACL,QAAA,GAAG,WAAW;QACd,WAAW;QACX,YAAY;QACZ,cAAc,EAAE,aAAa,CAAC,KAAK;QACnC,eAAe,EAAE,aAAa,CAAC,MAAM;AACrC,QAAA,eAAe,EAAE,cAAc;AAChC,KAAA,CAAC,EACF,CAAC,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CACpF;AAED,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,iBAAiB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,EACrC,QAAQ,CACkB;AAEjC;;;;"}
1
+ {"version":3,"file":"ResponsiveProvider.js","sources":["../../../src/library/providers/ResponsiveProvider.tsx"],"sourcesContent":[null],"names":["React"],"mappings":";;;;;MAKa,kBAAkB,GAAG,CAAC,EAAE,QAAQ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{
23
23
  okButtonStyles?: React.CSSProperties;
24
24
  rootClassName?: string;
25
25
  rootStyles?: React.CSSProperties;
26
+ pa?: 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
26
27
  pv?: 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
27
28
  ph?: 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
28
- pa?: 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
29
29
  pt?: 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
30
30
  pb?: 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
31
31
  pr?: 0 | 2 | 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
@@ -1,13 +1,23 @@
1
- export interface IResponsiveContext {
1
+ export interface IBreakpoints {
2
2
  isMobile: boolean;
3
3
  isTablet: boolean;
4
4
  isMdDesktop: boolean;
5
5
  isLgDesktop: boolean;
6
6
  isXLgDesktop: boolean;
7
+ }
8
+ export interface IViewportContext extends IBreakpoints {
9
+ width: number;
10
+ height: number;
11
+ }
12
+ export interface IContainerContext extends IBreakpoints {
13
+ width: number;
14
+ height: number;
15
+ }
16
+ export interface IResponsiveContext extends IBreakpoints {
7
17
  windowWidth: number;
8
18
  windowHeight: number;
9
- containerWidth: number;
10
- containerHeight: number;
19
+ viewport: IViewportContext;
20
+ container: IContainerContext;
11
21
  setContainerRef: (el: HTMLElement | null) => void;
12
22
  }
13
23
  export declare const ResponsiveContext: import("react").Context<IResponsiveContext>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reso-ui",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "description": "Reusable React components in Typescript",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",