@onesy/ui-react 1.0.133 → 1.0.135
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/MainProgress/MainProgress.d.ts +4 -27
- package/MainProgress/MainProgress.js +46 -155
- package/MainProgressMaterial/Context.d.ts +2 -0
- package/MainProgressMaterial/Context.js +10 -0
- package/MainProgressMaterial/MainProgressMaterial.d.ts +33 -0
- package/MainProgressMaterial/MainProgressMaterial.js +198 -0
- package/MainProgressMaterial/index.d.ts +4 -0
- package/MainProgressMaterial/index.js +33 -0
- package/MainProgressMaterial/package.json +6 -0
- package/MainProgressMaterial/useMainProgressMaterial.d.ts +2 -0
- package/MainProgressMaterial/useMainProgressMaterial.js +13 -0
- package/TableCell/TableCell.js +18 -9
- package/esm/MainProgress/MainProgress.js +45 -151
- package/esm/MainProgressMaterial/Context.js +3 -0
- package/esm/MainProgressMaterial/MainProgressMaterial.js +182 -0
- package/esm/MainProgressMaterial/index.js +4 -0
- package/esm/MainProgressMaterial/useMainProgressMaterial.js +6 -0
- package/esm/TableCell/TableCell.js +18 -9
- package/esm/index.js +14 -4
- package/esm/useOnline/index.js +1 -0
- package/esm/useOnline/useOnline.js +17 -0
- package/esm/useOpen/index.js +1 -0
- package/esm/useOpen/useOpen.js +46 -0
- package/esm/useResize/index.js +1 -0
- package/esm/useResize/useResize.js +20 -0
- package/esm/useTabs/index.js +1 -0
- package/esm/useTabs/useTabs.js +17 -0
- package/esm/utils.js +1 -1
- package/index.d.ts +12 -2
- package/index.js +102 -7
- package/package.json +1 -1
- package/useOnline/index.d.ts +1 -0
- package/useOnline/index.js +13 -0
- package/useOnline/package.json +6 -0
- package/useOnline/useOnline.d.ts +2 -0
- package/useOnline/useOnline.js +24 -0
- package/useOpen/index.d.ts +1 -0
- package/useOpen/index.js +13 -0
- package/useOpen/package.json +6 -0
- package/useOpen/useOpen.d.ts +15 -0
- package/useOpen/useOpen.js +53 -0
- package/useResize/index.d.ts +1 -0
- package/useResize/index.js +13 -0
- package/useResize/package.json +6 -0
- package/useResize/useResize.d.ts +2 -0
- package/useResize/useResize.js +27 -0
- package/useTabs/index.d.ts +1 -0
- package/useTabs/index.js +13 -0
- package/useTabs/package.json +6 -0
- package/useTabs/useTabs.d.ts +10 -0
- package/useTabs/useTabs.js +24 -0
- package/utils.d.ts +1 -1
- package/utils.js +1 -1
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
const _excluded = ["
|
|
4
|
+
const _excluded = ["children", "className"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import LinearProgressElement from '../LinearProgress';
|
|
8
|
+
import { classNames, style, useOnesyTheme } from '@onesy/style-react';
|
|
9
|
+
import useOpen from '../useOpen';
|
|
10
|
+
import LineElement from '../Line';
|
|
12
11
|
import MainProgressContext from './Context';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'&.onesy-LinearProgress-root': {
|
|
18
|
-
height: '2px'
|
|
12
|
+
const useStyle = style(theme => ({
|
|
13
|
+
'@keyframes move': {
|
|
14
|
+
from: {
|
|
15
|
+
transform: 'translateX(-100%)'
|
|
19
16
|
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
fixed: {
|
|
25
|
-
insetInline: '0',
|
|
26
|
-
'&.onesy-LinearProgress-root': {
|
|
27
|
-
position: 'fixed'
|
|
17
|
+
to: {
|
|
18
|
+
transform: 'translateX(250%)'
|
|
28
19
|
}
|
|
29
20
|
},
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
root: {
|
|
22
|
+
position: 'fixed',
|
|
23
|
+
top: 0,
|
|
24
|
+
left: 0,
|
|
25
|
+
height: 3,
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
pointerEvents: 'none',
|
|
28
|
+
transition: theme.methods.transitions.make('opacity'),
|
|
29
|
+
zIndex: theme.z_index.tooltip
|
|
32
30
|
},
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
loader: {
|
|
32
|
+
position: 'relative',
|
|
33
|
+
width: '50%',
|
|
34
|
+
height: '100%',
|
|
35
|
+
background: `linear-gradient(to right, transparent, ${theme.palette.color.primary[50]}, transparent)`,
|
|
36
|
+
animation: '$move 2s linear infinite'
|
|
35
37
|
}
|
|
36
38
|
}), {
|
|
37
39
|
name: 'onesy-MainProgress'
|
|
@@ -39,144 +41,36 @@ const useStyle = styleMethod(theme => ({
|
|
|
39
41
|
const MainProgress = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
40
42
|
const theme = useOnesyTheme();
|
|
41
43
|
const props = React.useMemo(() => _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyMainProgress?.props?.default), props_), [props_]);
|
|
42
|
-
const Fade = React.useMemo(() => theme?.elements?.Fade || FadeElement, [theme]);
|
|
43
|
-
const LinearProgress = React.useMemo(() => theme?.elements?.LinearProgress || LinearProgressElement, [theme]);
|
|
44
44
|
const {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
firstIncrement = true,
|
|
48
|
-
incrementMin = 4,
|
|
49
|
-
incrementMax = 14,
|
|
50
|
-
stepMin = 1,
|
|
51
|
-
stepMax = 4,
|
|
52
|
-
stepInterval = 700,
|
|
53
|
-
onStart,
|
|
54
|
-
onIncrement,
|
|
55
|
-
onUpdate,
|
|
56
|
-
onDone,
|
|
57
|
-
fixed = true,
|
|
58
|
-
position = 'top',
|
|
59
|
-
TransitionComponent = Fade,
|
|
60
|
-
TransitionComponentProps = {},
|
|
61
|
-
className,
|
|
62
|
-
children
|
|
45
|
+
children,
|
|
46
|
+
className
|
|
63
47
|
} = props,
|
|
64
48
|
other = _objectWithoutProperties(props, _excluded);
|
|
65
49
|
const {
|
|
66
50
|
classes
|
|
67
51
|
} = useStyle();
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
value: React.useRef(null),
|
|
73
|
-
min: React.useRef(null),
|
|
74
|
-
max: React.useRef(null),
|
|
75
|
-
firstIncrement: React.useRef(null),
|
|
76
|
-
incrementMin: React.useRef(null),
|
|
77
|
-
incrementMax: React.useRef(null),
|
|
78
|
-
stepInterval: React.useRef(null),
|
|
79
|
-
stepMin: React.useRef(null),
|
|
80
|
-
stepMax: React.useRef(null),
|
|
81
|
-
TransitionComponentProps: React.useRef(null),
|
|
82
|
-
linearProgress: React.useRef(null),
|
|
83
|
-
interval: React.useRef(null),
|
|
84
|
-
props: React.useRef(null)
|
|
85
|
-
};
|
|
86
|
-
refs.value.current = value;
|
|
87
|
-
refs.props.current = props;
|
|
88
|
-
refs.min.current = min;
|
|
89
|
-
refs.max.current = max;
|
|
90
|
-
refs.firstIncrement.current = firstIncrement;
|
|
91
|
-
refs.incrementMin.current = incrementMin;
|
|
92
|
-
refs.incrementMax.current = incrementMax;
|
|
93
|
-
refs.stepInterval.current = stepInterval;
|
|
94
|
-
refs.stepMin.current = stepMin;
|
|
95
|
-
refs.stepMax.current = stepMax;
|
|
96
|
-
refs.TransitionComponentProps.current = TransitionComponentProps;
|
|
97
|
-
const clear = () => {
|
|
98
|
-
if (refs.interval.current) {
|
|
99
|
-
clearInterval(refs.interval.current);
|
|
100
|
-
refs.interval.current = undefined;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
const start = React.useCallback(value_ => {
|
|
104
|
-
// Reset
|
|
105
|
-
clear();
|
|
106
|
-
|
|
107
|
-
// Update
|
|
108
|
-
refs.linearProgress.current = value_;
|
|
109
|
-
|
|
110
|
-
// Open
|
|
111
|
-
setInProp(true);
|
|
112
|
-
|
|
113
|
-
// Set initial value to min
|
|
114
|
-
const min_ = refs.min.current !== undefined ? refs.min.current : 0;
|
|
115
|
-
const max_ = refs.max.current !== undefined ? refs.max.current : 0;
|
|
116
|
-
setValue(min_);
|
|
117
|
-
|
|
118
|
-
// start inc interval for steps
|
|
119
|
-
// in refs.interval
|
|
120
|
-
|
|
121
|
-
// in interval, remove interval if value is >= max
|
|
122
|
-
if (min_ < max_) {
|
|
123
|
-
const stepInterval_ = refs.stepInterval.current !== undefined ? refs.stepInterval.current : 700;
|
|
124
|
-
refs.interval.current = setInterval(() => {
|
|
125
|
-
if (refs.value.current >= max_) clearInterval(refs.interval.current);
|
|
126
|
-
setValue(previousValue => clamp(previousValue + random(refs.stepMin.current, refs.stepMax.current), refs.min.current, refs.max.current));
|
|
127
|
-
}, stepInterval_);
|
|
128
|
-
}
|
|
129
|
-
if (is('function', onStart)) onStart();
|
|
52
|
+
const Line = React.useMemo(() => theme?.elements?.Line || LineElement, [theme]);
|
|
53
|
+
const open = useOpen();
|
|
54
|
+
const start = React.useCallback(() => {
|
|
55
|
+
open.onOpen();
|
|
130
56
|
}, []);
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
let valueNew = refs.value.current;
|
|
134
|
-
valueNew += clamp(random(refs.incrementMin.current, refs.incrementMax.current), refs.min.current, refs.max.current);
|
|
135
|
-
setValue(valueNew);
|
|
136
|
-
if (is('function', onIncrement)) onIncrement(valueNew);
|
|
57
|
+
const done = React.useCallback(() => {
|
|
58
|
+
open.onClose();
|
|
137
59
|
}, []);
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
60
|
+
const value = React.useMemo(() => {
|
|
61
|
+
return {
|
|
62
|
+
start,
|
|
63
|
+
done
|
|
64
|
+
};
|
|
142
65
|
}, []);
|
|
143
|
-
const done = React.useCallback(async () => {
|
|
144
|
-
clear();
|
|
145
|
-
|
|
146
|
-
// Update value to 100
|
|
147
|
-
setValue(100);
|
|
148
|
-
|
|
149
|
-
// Update inProp to false with the timeout value
|
|
150
|
-
const timeout = theme.transitions.duration.rg + 44;
|
|
151
|
-
await wait(timeout);
|
|
152
|
-
setInProp(false);
|
|
153
|
-
if (is('function', onDone)) onDone();
|
|
154
|
-
}, []);
|
|
155
|
-
const onExited = () => {
|
|
156
|
-
// Reset
|
|
157
|
-
setValue(0);
|
|
158
|
-
};
|
|
159
|
-
React.useEffect(() => {
|
|
160
|
-
if (inProp) {
|
|
161
|
-
if (refs.firstIncrement.current) increment();
|
|
162
|
-
}
|
|
163
|
-
}, [inProp]);
|
|
164
|
-
TransitionComponentProps.in = inProp;
|
|
165
|
-
refs.value_.current.start = start;
|
|
166
|
-
refs.value_.current.increment = increment;
|
|
167
|
-
refs.value_.current.update = update;
|
|
168
|
-
refs.value_.current.done = done;
|
|
169
66
|
return /*#__PURE__*/React.createElement(MainProgressContext.Provider, {
|
|
170
|
-
value:
|
|
171
|
-
}, /*#__PURE__*/React.createElement(
|
|
172
|
-
in: inProp,
|
|
173
|
-
onExited: onExited
|
|
174
|
-
}, TransitionComponentProps), /*#__PURE__*/React.createElement(LinearProgress, _extends({
|
|
67
|
+
value: value
|
|
68
|
+
}, open.open && /*#__PURE__*/React.createElement(Line, _extends({
|
|
175
69
|
ref: ref,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
70
|
+
fullWidth: true,
|
|
71
|
+
className: classNames(['onesy-MainProgress-root', className, classes.root])
|
|
72
|
+
}, other), /*#__PURE__*/React.createElement(Line, {
|
|
73
|
+
className: classes.loader
|
|
74
|
+
})), children);
|
|
180
75
|
});
|
|
181
|
-
MainProgress.displayName = 'onesy-MainProgress';
|
|
182
76
|
export default MainProgress;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
+
const _excluded = ["min", "max", "firstIncrement", "incrementMin", "incrementMax", "stepMin", "stepMax", "stepInterval", "onStart", "onIncrement", "onUpdate", "onDone", "fixed", "position", "TransitionComponent", "TransitionComponentProps", "className", "children"];
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { is, wait, random, clamp } from '@onesy/utils';
|
|
9
|
+
import { classNames, style as styleMethod, useOnesyTheme } from '@onesy/style-react';
|
|
10
|
+
import FadeElement from '../Fade';
|
|
11
|
+
import LinearProgressElement from '../LinearProgress';
|
|
12
|
+
import MainProgressMaterialContext from './Context';
|
|
13
|
+
import { staticClassName } from '../utils';
|
|
14
|
+
const useStyle = styleMethod(theme => ({
|
|
15
|
+
root: {
|
|
16
|
+
zIndex: theme.z_index.tooltip - 14,
|
|
17
|
+
'&.onesy-LinearProgress-root': {
|
|
18
|
+
height: '2px'
|
|
19
|
+
},
|
|
20
|
+
'& .onesy-LinearProgress-buffer': {
|
|
21
|
+
background: 'transparent'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
fixed: {
|
|
25
|
+
insetInline: '0',
|
|
26
|
+
'&.onesy-LinearProgress-root': {
|
|
27
|
+
position: 'fixed'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
position_top: {
|
|
31
|
+
top: '0'
|
|
32
|
+
},
|
|
33
|
+
position_bottom: {
|
|
34
|
+
bottom: '0'
|
|
35
|
+
}
|
|
36
|
+
}), {
|
|
37
|
+
name: 'onesy-MainProgressMaterial'
|
|
38
|
+
});
|
|
39
|
+
const MainProgressMaterial = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
40
|
+
const theme = useOnesyTheme();
|
|
41
|
+
const props = React.useMemo(() => _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyMainProgressMaterial?.props?.default), props_), [props_]);
|
|
42
|
+
const Fade = React.useMemo(() => theme?.elements?.Fade || FadeElement, [theme]);
|
|
43
|
+
const LinearProgress = React.useMemo(() => theme?.elements?.LinearProgress || LinearProgressElement, [theme]);
|
|
44
|
+
const {
|
|
45
|
+
min = 0,
|
|
46
|
+
max = 99,
|
|
47
|
+
firstIncrement = true,
|
|
48
|
+
incrementMin = 4,
|
|
49
|
+
incrementMax = 14,
|
|
50
|
+
stepMin = 1,
|
|
51
|
+
stepMax = 4,
|
|
52
|
+
stepInterval = 700,
|
|
53
|
+
onStart,
|
|
54
|
+
onIncrement,
|
|
55
|
+
onUpdate,
|
|
56
|
+
onDone,
|
|
57
|
+
fixed = true,
|
|
58
|
+
position = 'top',
|
|
59
|
+
TransitionComponent = Fade,
|
|
60
|
+
TransitionComponentProps = {},
|
|
61
|
+
className,
|
|
62
|
+
children
|
|
63
|
+
} = props,
|
|
64
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
65
|
+
const {
|
|
66
|
+
classes
|
|
67
|
+
} = useStyle();
|
|
68
|
+
const [inProp, setInProp] = React.useState(false);
|
|
69
|
+
const [value, setValue] = React.useState(min);
|
|
70
|
+
const refs = {
|
|
71
|
+
value_: React.useRef({}),
|
|
72
|
+
value: React.useRef(null),
|
|
73
|
+
min: React.useRef(null),
|
|
74
|
+
max: React.useRef(null),
|
|
75
|
+
firstIncrement: React.useRef(null),
|
|
76
|
+
incrementMin: React.useRef(null),
|
|
77
|
+
incrementMax: React.useRef(null),
|
|
78
|
+
stepInterval: React.useRef(null),
|
|
79
|
+
stepMin: React.useRef(null),
|
|
80
|
+
stepMax: React.useRef(null),
|
|
81
|
+
TransitionComponentProps: React.useRef(null),
|
|
82
|
+
linearProgress: React.useRef(null),
|
|
83
|
+
interval: React.useRef(null),
|
|
84
|
+
props: React.useRef(null)
|
|
85
|
+
};
|
|
86
|
+
refs.value.current = value;
|
|
87
|
+
refs.props.current = props;
|
|
88
|
+
refs.min.current = min;
|
|
89
|
+
refs.max.current = max;
|
|
90
|
+
refs.firstIncrement.current = firstIncrement;
|
|
91
|
+
refs.incrementMin.current = incrementMin;
|
|
92
|
+
refs.incrementMax.current = incrementMax;
|
|
93
|
+
refs.stepInterval.current = stepInterval;
|
|
94
|
+
refs.stepMin.current = stepMin;
|
|
95
|
+
refs.stepMax.current = stepMax;
|
|
96
|
+
refs.TransitionComponentProps.current = TransitionComponentProps;
|
|
97
|
+
const clear = () => {
|
|
98
|
+
if (refs.interval.current) {
|
|
99
|
+
clearInterval(refs.interval.current);
|
|
100
|
+
refs.interval.current = undefined;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const start = React.useCallback(value_ => {
|
|
104
|
+
// Reset
|
|
105
|
+
clear();
|
|
106
|
+
|
|
107
|
+
// Update
|
|
108
|
+
refs.linearProgress.current = value_;
|
|
109
|
+
|
|
110
|
+
// Open
|
|
111
|
+
setInProp(true);
|
|
112
|
+
|
|
113
|
+
// Set initial value to min
|
|
114
|
+
const min_ = refs.min.current !== undefined ? refs.min.current : 0;
|
|
115
|
+
const max_ = refs.max.current !== undefined ? refs.max.current : 0;
|
|
116
|
+
setValue(min_);
|
|
117
|
+
|
|
118
|
+
// start inc interval for steps
|
|
119
|
+
// in refs.interval
|
|
120
|
+
|
|
121
|
+
// in interval, remove interval if value is >= max
|
|
122
|
+
if (min_ < max_) {
|
|
123
|
+
const stepInterval_ = refs.stepInterval.current !== undefined ? refs.stepInterval.current : 700;
|
|
124
|
+
refs.interval.current = setInterval(() => {
|
|
125
|
+
if (refs.value.current >= max_) clearInterval(refs.interval.current);
|
|
126
|
+
setValue(previousValue => clamp(previousValue + random(refs.stepMin.current, refs.stepMax.current), refs.min.current, refs.max.current));
|
|
127
|
+
}, stepInterval_);
|
|
128
|
+
}
|
|
129
|
+
if (is('function', onStart)) onStart();
|
|
130
|
+
}, []);
|
|
131
|
+
const increment = React.useCallback(() => {
|
|
132
|
+
// Inc value random between incrementMin, incrementMax, with clam to min, max
|
|
133
|
+
let valueNew = refs.value.current;
|
|
134
|
+
valueNew += clamp(random(refs.incrementMin.current, refs.incrementMax.current), refs.min.current, refs.max.current);
|
|
135
|
+
setValue(valueNew);
|
|
136
|
+
if (is('function', onIncrement)) onIncrement(valueNew);
|
|
137
|
+
}, []);
|
|
138
|
+
const update = React.useCallback(value_ => {
|
|
139
|
+
const valueNew = value_;
|
|
140
|
+
setValue(valueNew);
|
|
141
|
+
if (is('function', onUpdate)) onUpdate(valueNew);
|
|
142
|
+
}, []);
|
|
143
|
+
const done = React.useCallback(async () => {
|
|
144
|
+
clear();
|
|
145
|
+
|
|
146
|
+
// Update value to 100
|
|
147
|
+
setValue(100);
|
|
148
|
+
|
|
149
|
+
// Update inProp to false with the timeout value
|
|
150
|
+
const timeout = theme.transitions.duration.rg + 44;
|
|
151
|
+
await wait(timeout);
|
|
152
|
+
setInProp(false);
|
|
153
|
+
if (is('function', onDone)) onDone();
|
|
154
|
+
}, []);
|
|
155
|
+
const onExited = () => {
|
|
156
|
+
// Reset
|
|
157
|
+
setValue(0);
|
|
158
|
+
};
|
|
159
|
+
React.useEffect(() => {
|
|
160
|
+
if (inProp) {
|
|
161
|
+
if (refs.firstIncrement.current) increment();
|
|
162
|
+
}
|
|
163
|
+
}, [inProp]);
|
|
164
|
+
TransitionComponentProps.in = inProp;
|
|
165
|
+
refs.value_.current.start = start;
|
|
166
|
+
refs.value_.current.increment = increment;
|
|
167
|
+
refs.value_.current.update = update;
|
|
168
|
+
refs.value_.current.done = done;
|
|
169
|
+
return /*#__PURE__*/React.createElement(MainProgressMaterialContext.Provider, {
|
|
170
|
+
value: refs.value_.current
|
|
171
|
+
}, /*#__PURE__*/React.createElement(TransitionComponent, _extends({
|
|
172
|
+
in: inProp,
|
|
173
|
+
onExited: onExited
|
|
174
|
+
}, TransitionComponentProps), /*#__PURE__*/React.createElement(LinearProgress, _extends({
|
|
175
|
+
ref: ref,
|
|
176
|
+
value: value,
|
|
177
|
+
version: "determinate",
|
|
178
|
+
className: classNames([staticClassName('MainProgressMaterial', theme) && [`onesy-MainProgressMaterial-root`], className, classes.root, classes[`position_${position}`], fixed && classes.fixed])
|
|
179
|
+
}, other, refs.linearProgress.current))), children);
|
|
180
|
+
});
|
|
181
|
+
MainProgressMaterial.displayName = 'onesy-MainProgressMaterial';
|
|
182
|
+
export default MainProgressMaterial;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default } from './MainProgressMaterial';
|
|
2
|
+
export { default as MainProgressMaterialContext } from './Context';
|
|
3
|
+
export { default as MainProgressMaterial } from './MainProgressMaterial';
|
|
4
|
+
export { default as useMainProgressMaterial } from './useMainProgressMaterial';
|
|
@@ -14,6 +14,7 @@ import TypeElement from '../Type';
|
|
|
14
14
|
import DividerElement from '../Divider';
|
|
15
15
|
import { getOverflowParent, staticClassName } from '../utils';
|
|
16
16
|
import Tooltip from '../Tooltip';
|
|
17
|
+
import useResize from '../useResize';
|
|
17
18
|
const useStyle = styleMethod(theme => ({
|
|
18
19
|
root: _objectSpread(_objectSpread({
|
|
19
20
|
display: 'table-cell',
|
|
@@ -121,6 +122,7 @@ const useStyle = styleMethod(theme => ({
|
|
|
121
122
|
});
|
|
122
123
|
const TableCell = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
123
124
|
const theme = useOnesyTheme();
|
|
125
|
+
const windowWidth = useResize();
|
|
124
126
|
const l = theme.l;
|
|
125
127
|
const props = React.useMemo(() => _objectSpread(_objectSpread(_objectSpread({}, theme?.ui?.elements?.all?.props?.default), theme?.ui?.elements?.onesyTableCell?.props?.default), props_), [props_]);
|
|
126
128
|
const Line = React.useMemo(() => theme?.elements?.Line || LineElement, [theme]);
|
|
@@ -184,28 +186,35 @@ const TableCell = /*#__PURE__*/React.forwardRef((props_, ref) => {
|
|
|
184
186
|
React.useEffect(() => {
|
|
185
187
|
// init
|
|
186
188
|
init();
|
|
187
|
-
}, []);
|
|
189
|
+
}, [windowWidth]);
|
|
188
190
|
React.useEffect(() => {
|
|
189
191
|
if (sortedBy !== sortedBy_) setSortedBy(sortedBy_);
|
|
190
192
|
}, [sortedBy_]);
|
|
191
193
|
React.useEffect(() => {
|
|
192
194
|
if (sticky) {
|
|
193
195
|
if (root) {
|
|
194
|
-
const parentOverflow = getOverflowParent(root, false);
|
|
195
|
-
|
|
196
|
+
const parentOverflow = getOverflowParent(root.parentElement, false);
|
|
197
|
+
root.style.position = 'unset';
|
|
198
|
+
const offsetOriginal = root.offsetLeft;
|
|
199
|
+
root.style.position = 'sticky';
|
|
196
200
|
const method = () => {
|
|
197
|
-
const offsetNew =
|
|
198
|
-
setStickyActive(
|
|
201
|
+
const offsetNew = root.offsetLeft;
|
|
202
|
+
setStickyActive(offsetOriginal !== offsetNew);
|
|
199
203
|
};
|
|
200
|
-
if (parentOverflow)
|
|
201
|
-
|
|
202
|
-
|
|
204
|
+
if (parentOverflow) {
|
|
205
|
+
parentOverflow.addEventListener('scroll', method, {
|
|
206
|
+
passive: false
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// initial
|
|
210
|
+
method();
|
|
211
|
+
}
|
|
203
212
|
return () => {
|
|
204
213
|
parentOverflow.removeEventListener('scroll', method);
|
|
205
214
|
};
|
|
206
215
|
}
|
|
207
216
|
}
|
|
208
|
-
}, [sticky, stickyPosition, root]);
|
|
217
|
+
}, [windowWidth, sticky, stickyPosition, root]);
|
|
209
218
|
const onSort = React.useCallback(() => {
|
|
210
219
|
let valueNew;
|
|
211
220
|
setSortedBy(item => {
|
package/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license UiReact v1.0.
|
|
1
|
+
/** @license UiReact v1.0.134
|
|
2
2
|
*
|
|
3
3
|
* This source code is licensed under the MIT license found in the
|
|
4
4
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -226,8 +226,8 @@ export { default as ViewSplit } from './ViewSplit';
|
|
|
226
226
|
export * from './ViewSplit';
|
|
227
227
|
export { default as WindowSplit } from './WindowSplit';
|
|
228
228
|
export * from './WindowSplit';
|
|
229
|
-
export { default as
|
|
230
|
-
export * from './
|
|
229
|
+
export { default as MainProgressMaterial } from './MainProgressMaterial';
|
|
230
|
+
export * from './MainProgressMaterial';
|
|
231
231
|
export { default as Image } from './Image';
|
|
232
232
|
export * from './Image';
|
|
233
233
|
export { default as SpyScroll } from './SpyScroll';
|
|
@@ -427,4 +427,14 @@ export * from './CalendarMenu';
|
|
|
427
427
|
export { default as Whiteboard } from './Whiteboard';
|
|
428
428
|
export * from './Whiteboard';
|
|
429
429
|
export { default as CookieBanner } from './CookieBanner';
|
|
430
|
-
export * from './CookieBanner';
|
|
430
|
+
export * from './CookieBanner';
|
|
431
|
+
export { default as MainProgress } from './MainProgress';
|
|
432
|
+
export * from './MainProgress';
|
|
433
|
+
export { default as useOnline } from './useOnline';
|
|
434
|
+
export * from './useOnline';
|
|
435
|
+
export { default as useOpen } from './useOpen';
|
|
436
|
+
export * from './useOpen';
|
|
437
|
+
export { default as useResize } from './useResize';
|
|
438
|
+
export * from './useResize';
|
|
439
|
+
export { default as useTabs } from './useTabs';
|
|
440
|
+
export * from './useTabs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './useOnline';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { isEnvironment } from '@onesy/utils';
|
|
3
|
+
const useOnline = () => {
|
|
4
|
+
const [online, setOnline] = React.useState(isEnvironment('browser') ? window.navigator.onLine : true);
|
|
5
|
+
React.useEffect(() => {
|
|
6
|
+
const onOnline = () => setOnline(true);
|
|
7
|
+
const onOffline = () => setOnline(false);
|
|
8
|
+
window.addEventListener('online', onOnline);
|
|
9
|
+
window.addEventListener('offline', onOffline);
|
|
10
|
+
return () => {
|
|
11
|
+
window.removeEventListener('online', onOnline);
|
|
12
|
+
window.removeEventListener('offline', onOffline);
|
|
13
|
+
};
|
|
14
|
+
}, []);
|
|
15
|
+
return online;
|
|
16
|
+
};
|
|
17
|
+
export default useOnline;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './useOpen';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { is } from '@onesy/utils';
|
|
6
|
+
const useOpen = props => {
|
|
7
|
+
const {
|
|
8
|
+
open: openProps
|
|
9
|
+
} = props || {};
|
|
10
|
+
const [open, setOpen] = React.useState(_objectSpread({
|
|
11
|
+
open: false
|
|
12
|
+
}, openProps));
|
|
13
|
+
const onOpen = React.useCallback(item => {
|
|
14
|
+
setOpen(_objectSpread({
|
|
15
|
+
open: true
|
|
16
|
+
}, item));
|
|
17
|
+
}, []);
|
|
18
|
+
const onClose = React.useCallback(() => {
|
|
19
|
+
setOpen(previous => _objectSpread(_objectSpread({}, previous), {}, {
|
|
20
|
+
open: false
|
|
21
|
+
}));
|
|
22
|
+
}, []);
|
|
23
|
+
const onToggle = React.useCallback(() => {
|
|
24
|
+
setOpen(previous => _objectSpread(_objectSpread({}, previous), {}, {
|
|
25
|
+
open: !previous?.open
|
|
26
|
+
}));
|
|
27
|
+
}, []);
|
|
28
|
+
const onChange = React.useCallback(value => {
|
|
29
|
+
setOpen(() => _objectSpread(_objectSpread({}, value), {}, {
|
|
30
|
+
open: is('boolean', value) ? value : !!value?.open
|
|
31
|
+
}));
|
|
32
|
+
}, []);
|
|
33
|
+
const result = React.useMemo(() => {
|
|
34
|
+
return {
|
|
35
|
+
open: open?.open,
|
|
36
|
+
item: open,
|
|
37
|
+
onOpen,
|
|
38
|
+
onClose,
|
|
39
|
+
onToggle,
|
|
40
|
+
onChange,
|
|
41
|
+
setOpen
|
|
42
|
+
};
|
|
43
|
+
}, [open, setOpen]);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
export default useOpen;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './useResize';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { isEnvironment } from '@onesy/utils';
|
|
3
|
+
const useWindowWidth = () => {
|
|
4
|
+
const [windowWidth, setWindowWidth] = React.useState(() => {
|
|
5
|
+
if (isEnvironment('browser')) return window.innerWidth;
|
|
6
|
+
return 0;
|
|
7
|
+
});
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const onResize = () => {
|
|
10
|
+
setWindowWidth(window.innerWidth);
|
|
11
|
+
};
|
|
12
|
+
if (isEnvironment('browser')) {
|
|
13
|
+
setWindowWidth(window.innerWidth);
|
|
14
|
+
window.addEventListener('resize', onResize);
|
|
15
|
+
return () => window.removeEventListener('resize', onResize);
|
|
16
|
+
}
|
|
17
|
+
}, []);
|
|
18
|
+
return windowWidth;
|
|
19
|
+
};
|
|
20
|
+
export default useWindowWidth;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './useTabs';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { is } from '@onesy/utils';
|
|
3
|
+
const useTabs = props => {
|
|
4
|
+
const [tab, setTab] = React.useState(is('string', props) ? props : props?.tab);
|
|
5
|
+
const onChange = React.useCallback(item => {
|
|
6
|
+
setTab(item);
|
|
7
|
+
}, []);
|
|
8
|
+
const result = React.useMemo(() => {
|
|
9
|
+
return {
|
|
10
|
+
value: tab,
|
|
11
|
+
onChange,
|
|
12
|
+
setTab
|
|
13
|
+
};
|
|
14
|
+
}, [tab]);
|
|
15
|
+
return result;
|
|
16
|
+
};
|
|
17
|
+
export default useTabs;
|
package/esm/utils.js
CHANGED
|
@@ -216,7 +216,7 @@ export const getOverflowParent = (element, vertical = true) => {
|
|
|
216
216
|
|
|
217
217
|
// width
|
|
218
218
|
if (!vertical && element.scrollWidth > element.clientWidth) return element;
|
|
219
|
-
return getOverflowParent(element.parentElement);
|
|
219
|
+
return getOverflowParent(element.parentElement, vertical);
|
|
220
220
|
};
|
|
221
221
|
export const keyboardStandardCommands = ['a', 'c', 'v', 'y', 'z'];
|
|
222
222
|
export const keyboardStyleCommands = ['b', 'i', 'u'];
|