@vuu-ui/vuu-layout 0.9.3 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/flexbox/FlexboxLayout.js.map +1 -1
- package/cjs/flexbox/Splitter.css.js +1 -1
- package/cjs/flexbox/Splitter.js.map +1 -1
- package/cjs/flexbox/flexbox-utils.js +1 -16
- package/cjs/flexbox/flexbox-utils.js.map +1 -1
- package/cjs/flexbox/useSplitterResizing.js +22 -39
- package/cjs/flexbox/useSplitterResizing.js.map +1 -1
- package/cjs/index.js +0 -6
- package/cjs/index.js.map +1 -1
- package/cjs/layout-provider/LayoutProvider.js +3 -1
- package/cjs/layout-provider/LayoutProvider.js.map +1 -1
- package/cjs/layout-provider/useLayoutDragDrop.js.map +1 -1
- package/cjs/layout-reducer/layoutTypes.js.map +1 -1
- package/cjs/layout-view/useView.js.map +1 -1
- package/cjs/layout-view/useViewResize.js +1 -1
- package/cjs/layout-view/useViewResize.js.map +1 -1
- package/cjs/layout-view-actions/ViewContext.js.map +1 -1
- package/cjs/layout-view-actions/useViewActionDispatcher.js +5 -1
- package/cjs/layout-view-actions/useViewActionDispatcher.js.map +1 -1
- package/cjs/stack/StackLayout.js.map +1 -1
- package/cjs/use-persistent-state.js +16 -13
- package/cjs/use-persistent-state.js.map +1 -1
- package/esm/flexbox/FlexboxLayout.js.map +1 -1
- package/esm/flexbox/Splitter.css.js +1 -1
- package/esm/flexbox/Splitter.js.map +1 -1
- package/esm/flexbox/flexbox-utils.js +1 -16
- package/esm/flexbox/flexbox-utils.js.map +1 -1
- package/esm/flexbox/useSplitterResizing.js +23 -40
- package/esm/flexbox/useSplitterResizing.js.map +1 -1
- package/esm/index.js +0 -3
- package/esm/index.js.map +1 -1
- package/esm/layout-provider/LayoutProvider.js +3 -1
- package/esm/layout-provider/LayoutProvider.js.map +1 -1
- package/esm/layout-provider/useLayoutDragDrop.js.map +1 -1
- package/esm/layout-reducer/layoutTypes.js.map +1 -1
- package/esm/layout-view/useView.js.map +1 -1
- package/esm/layout-view/useViewResize.js +1 -1
- package/esm/layout-view/useViewResize.js.map +1 -1
- package/esm/layout-view-actions/ViewContext.js.map +1 -1
- package/esm/layout-view-actions/useViewActionDispatcher.js +5 -1
- package/esm/layout-view-actions/useViewActionDispatcher.js.map +1 -1
- package/esm/stack/StackLayout.js.map +1 -1
- package/esm/use-persistent-state.js +16 -13
- package/esm/use-persistent-state.js.map +1 -1
- package/package.json +12 -12
- package/types/drag-drop/BoxModel.d.ts +7 -7
- package/types/flexbox/index.d.ts +2 -4
- package/types/layout-reducer/layoutTypes.d.ts +1 -1
- package/types/layout-view/useView.d.ts +6 -5
- package/types/layout-view-actions/ViewContext.d.ts +6 -2
- package/types/responsive/index.d.ts +0 -1
- package/types/use-persistent-state.d.ts +2 -2
- package/cjs/flexbox/FluidGrid.css.js +0 -6
- package/cjs/flexbox/FluidGrid.css.js.map +0 -1
- package/cjs/flexbox/FluidGrid.js +0 -87
- package/cjs/flexbox/FluidGrid.js.map +0 -1
- package/cjs/flexbox/FluidGridLayout.js +0 -14
- package/cjs/flexbox/FluidGridLayout.js.map +0 -1
- package/cjs/flexbox/useResponsiveSizing.js +0 -62
- package/cjs/flexbox/useResponsiveSizing.js.map +0 -1
- package/cjs/responsive/breakpoints.js +0 -36
- package/cjs/responsive/breakpoints.js.map +0 -1
- package/cjs/responsive/use-breakpoints.js +0 -76
- package/cjs/responsive/use-breakpoints.js.map +0 -1
- package/esm/flexbox/FluidGrid.css.js +0 -4
- package/esm/flexbox/FluidGrid.css.js.map +0 -1
- package/esm/flexbox/FluidGrid.js +0 -85
- package/esm/flexbox/FluidGrid.js.map +0 -1
- package/esm/flexbox/FluidGridLayout.js +0 -12
- package/esm/flexbox/FluidGridLayout.js.map +0 -1
- package/esm/flexbox/useResponsiveSizing.js +0 -60
- package/esm/flexbox/useResponsiveSizing.js.map +0 -1
- package/esm/responsive/breakpoints.js +0 -33
- package/esm/responsive/breakpoints.js.map +0 -1
- package/esm/responsive/use-breakpoints.js +0 -74
- package/esm/responsive/use-breakpoints.js.map +0 -1
- package/types/flexbox/FluidGrid.d.ts +0 -5
- package/types/flexbox/FluidGridLayout.d.ts +0 -5
- package/types/flexbox/useResponsiveSizing.d.ts +0 -10
- package/types/responsive/breakpoints.d.ts +0 -4
- package/types/responsive/use-breakpoints.d.ts +0 -7
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
-
import { useResizeObserver } from './useResizeObserver.js';
|
|
3
|
-
import { breakpointRamp, getBreakPoints } from './breakpoints.js';
|
|
4
|
-
|
|
5
|
-
const EMPTY_ARRAY = [];
|
|
6
|
-
const useBreakpoints = ({ breakPoints: breakPointsProp, smallerThan }, ref) => {
|
|
7
|
-
const [breakpointMatch, setBreakpointmatch] = useState(
|
|
8
|
-
smallerThan ? false : "lg"
|
|
9
|
-
);
|
|
10
|
-
const bodyRef = useRef(document.body);
|
|
11
|
-
const breakPointsRef = useRef(
|
|
12
|
-
breakPointsProp ? breakpointRamp(breakPointsProp) : getBreakPoints()
|
|
13
|
-
);
|
|
14
|
-
const sizeRef = useRef("lg");
|
|
15
|
-
const stopFromMinWidth = useCallback(
|
|
16
|
-
(w) => {
|
|
17
|
-
if (breakPointsRef.current) {
|
|
18
|
-
for (const [name, size] of breakPointsRef.current) {
|
|
19
|
-
if (w >= size) {
|
|
20
|
-
return name;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
[breakPointsRef]
|
|
26
|
-
);
|
|
27
|
-
const matchSizeAgainstBreakpoints = useCallback(
|
|
28
|
-
(width) => {
|
|
29
|
-
if (smallerThan) {
|
|
30
|
-
const breakPointRamp = breakPointsRef.current.find(
|
|
31
|
-
([name]) => name === smallerThan
|
|
32
|
-
);
|
|
33
|
-
if (breakPointRamp) {
|
|
34
|
-
const [, , maxValue] = breakPointRamp;
|
|
35
|
-
return width < maxValue;
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
return stopFromMinWidth(width);
|
|
39
|
-
}
|
|
40
|
-
return width;
|
|
41
|
-
},
|
|
42
|
-
[smallerThan, stopFromMinWidth]
|
|
43
|
-
);
|
|
44
|
-
useResizeObserver(
|
|
45
|
-
ref || bodyRef,
|
|
46
|
-
breakPointsRef.current ? ["width"] : EMPTY_ARRAY,
|
|
47
|
-
({ width: measuredWidth }) => {
|
|
48
|
-
const result = matchSizeAgainstBreakpoints(measuredWidth);
|
|
49
|
-
if (result !== sizeRef.current) {
|
|
50
|
-
sizeRef.current = result;
|
|
51
|
-
setBreakpointmatch(result);
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
true
|
|
55
|
-
);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
const target = ref || bodyRef;
|
|
58
|
-
if (target.current) {
|
|
59
|
-
const prevSize = sizeRef.current;
|
|
60
|
-
if (breakPointsRef.current) {
|
|
61
|
-
const { clientWidth } = target.current;
|
|
62
|
-
const result = matchSizeAgainstBreakpoints(clientWidth);
|
|
63
|
-
sizeRef.current = result;
|
|
64
|
-
if (result !== prevSize) {
|
|
65
|
-
setBreakpointmatch(result);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}, [setBreakpointmatch, matchSizeAgainstBreakpoints, ref]);
|
|
70
|
-
return breakpointMatch;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export { useBreakpoints };
|
|
74
|
-
//# sourceMappingURL=use-breakpoints.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-breakpoints.js","sources":["../../src/responsive/use-breakpoints.ts"],"sourcesContent":["import { RefObject, useCallback, useEffect, useRef, useState } from \"react\";\nimport { useResizeObserver } from \"./useResizeObserver\";\nimport {\n BreakPointRamp,\n breakpointRamp,\n getBreakPoints as getDocumentBreakpoints,\n} from \"./breakpoints\";\nimport { BreakPoint, BreakPointsProp } from \"../flexbox/flexboxTypes\";\n\nconst EMPTY_ARRAY: BreakPoint[] = [];\n\nexport interface BreakpointsHookProps {\n breakPoints?: BreakPointsProp;\n smallerThan?: string;\n}\n\n// TODO how do we cater for smallerThan/greaterThan breakpoints\nexport const useBreakpoints = (\n { breakPoints: breakPointsProp, smallerThan }: BreakpointsHookProps,\n ref: RefObject<HTMLElement>\n) => {\n const [breakpointMatch, setBreakpointmatch] = useState(\n smallerThan ? false : \"lg\"\n );\n const bodyRef = useRef(document.body);\n const breakPointsRef = useRef<BreakPointRamp[]>(\n breakPointsProp ? breakpointRamp(breakPointsProp) : getDocumentBreakpoints()\n );\n\n // TODO how do we identify the default\n const sizeRef = useRef(\"lg\");\n\n const stopFromMinWidth = useCallback(\n (w) => {\n if (breakPointsRef.current) {\n for (const [name, size] of breakPointsRef.current) {\n if (w >= size) {\n return name;\n }\n }\n }\n },\n [breakPointsRef]\n );\n\n const matchSizeAgainstBreakpoints = useCallback(\n (width) => {\n if (smallerThan) {\n const breakPointRamp = breakPointsRef.current.find(\n ([name]: BreakPointRamp) => name === smallerThan\n );\n if (breakPointRamp) {\n const [, , maxValue] = breakPointRamp;\n return width < maxValue;\n }\n } else {\n return stopFromMinWidth(width);\n }\n // is this right ?\n return width;\n },\n [smallerThan, stopFromMinWidth]\n );\n\n // TODO need to make the dimension a config\n useResizeObserver(\n ref || bodyRef,\n breakPointsRef.current ? [\"width\"] : EMPTY_ARRAY,\n ({ width: measuredWidth }: { width?: number }) => {\n const result = matchSizeAgainstBreakpoints(measuredWidth);\n if (result !== sizeRef.current) {\n sizeRef.current = result;\n setBreakpointmatch(result);\n }\n },\n true\n );\n\n useEffect(() => {\n const target = ref || bodyRef;\n if (target.current) {\n const prevSize = sizeRef.current;\n if (breakPointsRef.current) {\n // We're measuring here when the resizeObserver has also measured\n // There isn't a convenient way to get the Resizeobserver to\n // notify initial size - that's not really its job, unless we\n // set a flag ?\n const { clientWidth } = target.current;\n const result = matchSizeAgainstBreakpoints(clientWidth);\n sizeRef.current = result;\n // If initial size of ref does not match the default, notify client after render\n if (result !== prevSize) {\n setBreakpointmatch(result);\n }\n }\n }\n }, [setBreakpointmatch, matchSizeAgainstBreakpoints, ref]);\n\n // No, just ass the class directly to the ref, no need to render\n return breakpointMatch;\n};\n"],"names":["getDocumentBreakpoints"],"mappings":";;;;AASA,MAAM,cAA4B,EAAC;AAQ5B,MAAM,iBAAiB,CAC5B,EAAE,aAAa,eAAiB,EAAA,WAAA,IAChC,GACG,KAAA;AACH,EAAM,MAAA,CAAC,eAAiB,EAAA,kBAAkB,CAAI,GAAA,QAAA;AAAA,IAC5C,cAAc,KAAQ,GAAA;AAAA,GACxB;AACA,EAAM,MAAA,OAAA,GAAU,MAAO,CAAA,QAAA,CAAS,IAAI,CAAA;AACpC,EAAA,MAAM,cAAiB,GAAA,MAAA;AAAA,IACrB,eAAkB,GAAA,cAAA,CAAe,eAAe,CAAA,GAAIA,cAAuB;AAAA,GAC7E;AAGA,EAAM,MAAA,OAAA,GAAU,OAAO,IAAI,CAAA;AAE3B,EAAA,MAAM,gBAAmB,GAAA,WAAA;AAAA,IACvB,CAAC,CAAM,KAAA;AACL,MAAA,IAAI,eAAe,OAAS,EAAA;AAC1B,QAAA,KAAA,MAAW,CAAC,IAAA,EAAM,IAAI,CAAA,IAAK,eAAe,OAAS,EAAA;AACjD,UAAA,IAAI,KAAK,IAAM,EAAA;AACb,YAAO,OAAA,IAAA;AAAA;AACT;AACF;AACF,KACF;AAAA,IACA,CAAC,cAAc;AAAA,GACjB;AAEA,EAAA,MAAM,2BAA8B,GAAA,WAAA;AAAA,IAClC,CAAC,KAAU,KAAA;AACT,MAAA,IAAI,WAAa,EAAA;AACf,QAAM,MAAA,cAAA,GAAiB,eAAe,OAAQ,CAAA,IAAA;AAAA,UAC5C,CAAC,CAAC,IAAI,CAAA,KAAsB,IAAS,KAAA;AAAA,SACvC;AACA,QAAA,IAAI,cAAgB,EAAA;AAClB,UAAA,MAAM,KAAK,Q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({ children: childrenProp, cols: colsProp, style, }: {
|
|
3
|
-
children: ReactElement[];
|
|
4
|
-
cols?: number;
|
|
5
|
-
style?: CSSProperties;
|
|
6
|
-
}) => {
|
|
7
|
-
cols: number;
|
|
8
|
-
content: ReactElement<any, string | import("react").JSXElementConstructor<any>>[] | undefined;
|
|
9
|
-
rootRef: import("react").MutableRefObject<null>;
|
|
10
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BreakPointsProp } from "../flexbox/flexboxTypes";
|
|
2
|
-
export type BreakPointRamp = [string, number, number];
|
|
3
|
-
export declare const breakpointRamp: (breakpoints: BreakPointsProp) => BreakPointRamp[];
|
|
4
|
-
export declare const getBreakPoints: (themeName?: string) => BreakPointRamp[];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { RefObject } from "react";
|
|
2
|
-
import { BreakPointsProp } from "../flexbox/flexboxTypes";
|
|
3
|
-
export interface BreakpointsHookProps {
|
|
4
|
-
breakPoints?: BreakPointsProp;
|
|
5
|
-
smallerThan?: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const useBreakpoints: ({ breakPoints: breakPointsProp, smallerThan }: BreakpointsHookProps, ref: RefObject<HTMLElement>) => string | boolean;
|