linear-react-components-ui 2.2.0-beta.0 → 2.2.0-beta.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/lib/form2/useForm/index.js +0 -1
- package/lib/form2/useForm/index.js.map +1 -1
- package/lib/hooks/useScrollEndReached/index.d.ts +8 -0
- package/lib/hooks/useScrollEndReached/index.js +103 -0
- package/lib/hooks/useScrollEndReached/index.js.map +1 -0
- package/lib/hooks/useScrollEndReached/types.d.ts +6 -0
- package/lib/inputs2/selectfield/base.js +3 -1
- package/lib/inputs2/selectfield/base.js.map +1 -1
- package/lib/inputs2/selectfield/listbox.d.ts +2 -1
- package/lib/inputs2/selectfield/listbox.js +8 -0
- package/lib/inputs2/selectfield/listbox.js.map +1 -1
- package/lib/inputs2/selectfield/types.d.ts +2 -1
- package/lib/inputs2/selectfield/types.js.map +1 -1
- package/lib/node_modules/lodash/lodash.js +2 -2
- package/lib/node_modules/lodash/lodash.js.map +1 -1
- package/lib/panel/Content.js +20 -77
- package/lib/panel/Content.js.map +1 -1
- package/lib/panel/helpers.js +1 -16
- package/lib/panel/helpers.js.map +1 -1
- package/lib/panel/types.d.ts +3 -6
- package/package.json +1 -1
package/lib/panel/Content.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c as compilerRuntimeExports } from "../_virtual/compiler-runtime.js";
|
|
3
|
-
import { useContext, useRef
|
|
4
|
-
import PanelContext
|
|
3
|
+
import { useContext, useRef } from "react";
|
|
4
|
+
import PanelContext from "./helpers.js";
|
|
5
5
|
import NoPermission from "../noPermission/index.js";
|
|
6
|
+
import { useScrollEndReached } from "../hooks/useScrollEndReached/index.js";
|
|
6
7
|
const PanelContent = (t0) => {
|
|
7
|
-
const $ = compilerRuntimeExports.c(
|
|
8
|
+
const $ = compilerRuntimeExports.c(13);
|
|
8
9
|
let children;
|
|
9
10
|
let customClass;
|
|
10
11
|
let rest;
|
|
@@ -31,28 +32,12 @@ const PanelContent = (t0) => {
|
|
|
31
32
|
} = useContext(PanelContext);
|
|
32
33
|
const onEndReachedThreshold = t1 === void 0 ? 0.1 : t1;
|
|
33
34
|
const rootElementRef = useRef(null);
|
|
34
|
-
const lastScrollHeight = useRef(0);
|
|
35
|
-
const enableOnEndReached = useRef(true);
|
|
36
35
|
let t2;
|
|
37
36
|
if ($[4] !== onEndReached || $[5] !== onEndReachedThreshold) {
|
|
38
|
-
t2 =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
scrollTop,
|
|
43
|
-
scrollHeight,
|
|
44
|
-
clientHeight
|
|
45
|
-
} = element;
|
|
46
|
-
const scrollOffset = scrollHeight - clientHeight - scrollTop - 1;
|
|
47
|
-
const threshold = getCurrentThreshold(element, onEndReachedThreshold);
|
|
48
|
-
if (scrollOffset <= threshold && enableOnEndReached.current) {
|
|
49
|
-
enableOnEndReached.current = false;
|
|
50
|
-
await new Promise((resolve) => {
|
|
51
|
-
resolve(onEndReached());
|
|
52
|
-
});
|
|
53
|
-
lastScrollHeight.current = scrollHeight;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
37
|
+
t2 = {
|
|
38
|
+
elementRef: rootElementRef,
|
|
39
|
+
onEndReached,
|
|
40
|
+
onEndReachedThreshold
|
|
56
41
|
};
|
|
57
42
|
$[4] = onEndReached;
|
|
58
43
|
$[5] = onEndReachedThreshold;
|
|
@@ -60,65 +45,23 @@ const PanelContent = (t0) => {
|
|
|
60
45
|
} else {
|
|
61
46
|
t2 = $[6];
|
|
62
47
|
}
|
|
63
|
-
|
|
64
|
-
let t3;
|
|
65
|
-
if ($[7] !== onEndReached || $[8] !== onScrollEndReached) {
|
|
66
|
-
t3 = () => {
|
|
67
|
-
let observer;
|
|
68
|
-
if (rootElementRef?.current && onEndReached) {
|
|
69
|
-
observer = new ResizeObserver(() => {
|
|
70
|
-
const currentElement = rootElementRef.current;
|
|
71
|
-
if (currentElement) {
|
|
72
|
-
const {
|
|
73
|
-
scrollHeight: scrollHeight_0
|
|
74
|
-
} = currentElement;
|
|
75
|
-
if (scrollHeight_0 && scrollHeight_0 !== lastScrollHeight.current) {
|
|
76
|
-
enableOnEndReached.current = true;
|
|
77
|
-
observer?.disconnect();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
observer.observe(rootElementRef.current);
|
|
82
|
-
rootElementRef.current.addEventListener("scroll", onScrollEndReached);
|
|
83
|
-
rootElementRef.current.addEventListener("resize", onScrollEndReached);
|
|
84
|
-
}
|
|
85
|
-
return () => {
|
|
86
|
-
rootElementRef.current?.removeEventListener("scroll", onScrollEndReached);
|
|
87
|
-
rootElementRef.current?.removeEventListener("resize", onScrollEndReached);
|
|
88
|
-
observer?.disconnect();
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
$[7] = onEndReached;
|
|
92
|
-
$[8] = onScrollEndReached;
|
|
93
|
-
$[9] = t3;
|
|
94
|
-
} else {
|
|
95
|
-
t3 = $[9];
|
|
96
|
-
}
|
|
97
|
-
let t4;
|
|
98
|
-
if ($[10] !== onScrollEndReached) {
|
|
99
|
-
t4 = [onScrollEndReached];
|
|
100
|
-
$[10] = onScrollEndReached;
|
|
101
|
-
$[11] = t4;
|
|
102
|
-
} else {
|
|
103
|
-
t4 = $[11];
|
|
104
|
-
}
|
|
105
|
-
useEffect(t3, t4);
|
|
48
|
+
useScrollEndReached(t2);
|
|
106
49
|
if (!opened) {
|
|
107
50
|
return null;
|
|
108
51
|
}
|
|
109
|
-
let
|
|
110
|
-
if ($[
|
|
111
|
-
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
114
|
-
$[
|
|
115
|
-
$[
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
52
|
+
let t3;
|
|
53
|
+
if ($[7] !== children || $[8] !== customClass || $[9] !== hideContent || $[10] !== opened || $[11] !== rest) {
|
|
54
|
+
t3 = hideContent ? /* @__PURE__ */ jsx(NoPermission, {}) : /* @__PURE__ */ jsx("div", { ref: rootElementRef, className: `panel-content ${customClass ?? ""}`, ...rest, children: opened && children });
|
|
55
|
+
$[7] = children;
|
|
56
|
+
$[8] = customClass;
|
|
57
|
+
$[9] = hideContent;
|
|
58
|
+
$[10] = opened;
|
|
59
|
+
$[11] = rest;
|
|
60
|
+
$[12] = t3;
|
|
118
61
|
} else {
|
|
119
|
-
|
|
62
|
+
t3 = $[12];
|
|
120
63
|
}
|
|
121
|
-
return
|
|
64
|
+
return t3;
|
|
122
65
|
};
|
|
123
66
|
export {
|
|
124
67
|
PanelContent as default
|
package/lib/panel/Content.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Content.js","sources":["../../src/lib/panel/Content.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"Content.js","sources":["../../src/lib/panel/Content.tsx"],"sourcesContent":["import { useContext, useRef } from 'react';\nimport PanelContext from './helpers';\nimport NoPermission from '../noPermission';\nimport { IPanelContentProps } from './types';\nimport { useScrollEndReached } from '../hooks/useScrollEndReached';\n\nconst PanelContent = ({ customClass, children, ...rest }: IPanelContentProps) => {\n const {\n opened, onEndReached, onEndReachedThreshold = 0.1, hideContent,\n } = useContext(PanelContext);\n const rootElementRef = useRef<HTMLDivElement>(null);\n \n useScrollEndReached({\n elementRef: rootElementRef,\n onEndReached,\n onEndReachedThreshold,\n });\n\n if (!opened) return null;\n return (\n hideContent\n ? (\n <NoPermission />\n )\n : (\n <div\n ref={rootElementRef}\n className={`panel-content ${customClass ?? ''}`}\n {...rest}>\n {opened && children}\n </div>\n )\n );\n};\n\nexport default PanelContent;\n"],"names":["PanelContent","t0","$","_c","children","customClass","rest","opened","onEndReached","onEndReachedThreshold","t1","hideContent","useContext","PanelContext","undefined","rootElementRef","useRef","t2","elementRef","useScrollEndReached","t3"],"mappings":";;;;;;AAMA,MAAMA,eAAeC,CAAAA,OAAA;AAAA,QAAAC,IAAAC,uBAAAA,EAAA,EAA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SAAAlB,EAAA,EAAA;AAAA,EAAA;AAAA,SAXLkB;AAWK;"}
|
package/lib/panel/helpers.js
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
|
-
function getCurrentThreshold(scrollableElement, scrollThreshold) {
|
|
3
|
-
const MIN_THRESHOLD = 0;
|
|
4
|
-
const MAX_THRESHOLD = 1;
|
|
5
|
-
if (scrollThreshold < MIN_THRESHOLD) return MIN_THRESHOLD;
|
|
6
|
-
if (scrollThreshold > MAX_THRESHOLD) return MAX_THRESHOLD;
|
|
7
|
-
const {
|
|
8
|
-
scrollHeight,
|
|
9
|
-
clientHeight
|
|
10
|
-
} = scrollableElement;
|
|
11
|
-
const offsetHeight = scrollHeight - clientHeight;
|
|
12
|
-
const calculatedScrollThreshold = Math.round(scrollHeight * scrollThreshold);
|
|
13
|
-
const maxScrollThreshold = Math.round(offsetHeight - offsetHeight * 0.3);
|
|
14
|
-
return Math.min(calculatedScrollThreshold, maxScrollThreshold);
|
|
15
|
-
}
|
|
16
2
|
const PanelContext = createContext({});
|
|
17
3
|
export {
|
|
18
|
-
PanelContext as default
|
|
19
|
-
getCurrentThreshold
|
|
4
|
+
PanelContext as default
|
|
20
5
|
};
|
|
21
6
|
//# sourceMappingURL=helpers.js.map
|
package/lib/panel/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sources":["../../src/lib/panel/helpers.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { ContextProps } from './types';\n\nexport function getCurrentThreshold(\n scrollableElement: HTMLDivElement,\n scrollThreshold: number,\n): number {\n const MIN_THRESHOLD = 0;\n const MAX_THRESHOLD = 1;\n if (scrollThreshold < MIN_THRESHOLD) return MIN_THRESHOLD;\n if (scrollThreshold > MAX_THRESHOLD) return MAX_THRESHOLD;\n const { scrollHeight, clientHeight } = scrollableElement;\n const offsetHeight = scrollHeight - clientHeight;\n\n const calculatedScrollThreshold = Math.round(scrollHeight * scrollThreshold);\n const maxScrollThreshold = Math.round(offsetHeight - (offsetHeight * 0.3));\n\n return Math.min(calculatedScrollThreshold, maxScrollThreshold);\n}\n\nconst PanelContext = createContext<ContextProps>({} as ContextProps);\n\nexport default PanelContext;\n"],"names":["
|
|
1
|
+
{"version":3,"file":"helpers.js","sources":["../../src/lib/panel/helpers.ts"],"sourcesContent":["import { createContext } from 'react';\nimport { ContextProps } from './types';\n\nexport function getCurrentThreshold(\n scrollableElement: HTMLDivElement,\n scrollThreshold: number,\n): number {\n const MIN_THRESHOLD = 0;\n const MAX_THRESHOLD = 1;\n if (scrollThreshold < MIN_THRESHOLD) return MIN_THRESHOLD;\n if (scrollThreshold > MAX_THRESHOLD) return MAX_THRESHOLD;\n const { scrollHeight, clientHeight } = scrollableElement;\n const offsetHeight = scrollHeight - clientHeight;\n\n const calculatedScrollThreshold = Math.round(scrollHeight * scrollThreshold);\n const maxScrollThreshold = Math.round(offsetHeight - (offsetHeight * 0.3));\n\n return Math.min(calculatedScrollThreshold, maxScrollThreshold);\n}\n\nconst PanelContext = createContext<ContextProps>({} as ContextProps);\n\nexport default PanelContext;\n"],"names":["PanelContext","createContext"],"mappings":";AAoBA,MAAMA,eAAeC,cAA4B,CAAA,CAAkB;"}
|
package/lib/panel/types.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { ComponentPropsWithoutRef, ReactElement, ReactNode } from 'react';
|
|
|
2
2
|
import { PermissionAttr } from '../@types/PermissionAttr';
|
|
3
3
|
import { default as ColorStyles } from '../internals/colorStyles';
|
|
4
4
|
import { IconNames } from '../@types/Icon';
|
|
5
|
+
import { UseScrollEndReachedParams } from '../hooks/useScrollEndReached/types';
|
|
5
6
|
export type Func = () => void;
|
|
6
7
|
export type AsyncFunc = () => Promise<void>;
|
|
7
|
-
export interface IPanelProps extends Omit<ComponentPropsWithoutRef<'div'>, 'className'
|
|
8
|
+
export interface IPanelProps extends Omit<ComponentPropsWithoutRef<'div'>, 'className'>, UseScrollEndReachedParams {
|
|
8
9
|
customClass?: string;
|
|
9
10
|
startOpened?: boolean;
|
|
10
11
|
toggleable?: boolean;
|
|
@@ -12,8 +13,6 @@ export interface IPanelProps extends Omit<ComponentPropsWithoutRef<'div'>, 'clas
|
|
|
12
13
|
colorStyle?: typeof ColorStyles | string;
|
|
13
14
|
gridCols?: string;
|
|
14
15
|
title?: string;
|
|
15
|
-
onEndReached?: Func | AsyncFunc;
|
|
16
|
-
onEndReachedThreshold?: number;
|
|
17
16
|
permissionAttr?: PermissionAttr | PermissionAttr[];
|
|
18
17
|
}
|
|
19
18
|
export interface IPanelContentProps extends Omit<ComponentPropsWithoutRef<'div'>, 'className'> {
|
|
@@ -28,13 +27,11 @@ export interface IPanelHeaderProps extends Omit<ComponentPropsWithoutRef<'div'>,
|
|
|
28
27
|
customClassForTitle?: string;
|
|
29
28
|
headerColored?: boolean;
|
|
30
29
|
}
|
|
31
|
-
export type ContextProps = {
|
|
30
|
+
export type ContextProps = UseScrollEndReachedParams & {
|
|
32
31
|
toggleable: boolean;
|
|
33
32
|
handlerToggleable: () => void;
|
|
34
33
|
opened: boolean;
|
|
35
34
|
hideContent: boolean;
|
|
36
|
-
onEndReached?: Func | AsyncFunc;
|
|
37
|
-
onEndReachedThreshold: number;
|
|
38
35
|
};
|
|
39
36
|
export interface IParameterFunction {
|
|
40
37
|
props: any;
|