@smart-react-components/ui 2.0.0-alpha-78 → 2.0.0-alpha-80
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/FixedBox/index.d.ts +1 -0
- package/FixedBox/index.js +2 -2
- package/components/Radio/RadioElement.js +12 -6
- package/package.json +1 -1
- package/util/fixed-box.d.ts +1 -1
- package/util/fixed-box.js +11 -5
package/FixedBox/index.d.ts
CHANGED
package/FixedBox/index.js
CHANGED
|
@@ -16,13 +16,13 @@ const OverlayElement_1 = __importDefault(require("../components/FixedBox/Overlay
|
|
|
16
16
|
var types_2 = require("../types");
|
|
17
17
|
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_2.Position; } });
|
|
18
18
|
Object.defineProperty(exports, "TriggerInteraction", { enumerable: true, get: function () { return types_2.TriggerInteraction; } });
|
|
19
|
-
const FixedBox = ({ afterHide, afterShow, beforeHide, beforeShow, breakpoint = 'medium', children, elementProps = {}, hasHideAnimation = true, hasShowAnimation = true, isDismissible = true, maxWidth, minWidth, position = types_1.Position.BOTTOM, setStatus, space = 0, status, transitionClassName, transitionDuration, triggerInteraction = types_1.TriggerInteraction.CLICK, }) => {
|
|
19
|
+
const FixedBox = ({ afterHide, afterShow, beforeHide, beforeShow, breakpoint = 'medium', children, elementProps = {}, hasHideAnimation = true, hasShowAnimation = true, isDismissible = true, isOverflowPrevented, maxWidth, minWidth, position = types_1.Position.BOTTOM, setStatus, space = 0, status, transitionClassName, transitionDuration, triggerInteraction = types_1.TriggerInteraction.CLICK, }) => {
|
|
20
20
|
var _a;
|
|
21
21
|
const theme = react_1.default.useContext(styled_components_1.ThemeContext);
|
|
22
22
|
const triggerEl = react_1.default.useRef(null);
|
|
23
23
|
const boxEl = react_1.default.useRef(null);
|
|
24
24
|
const getTriggerEl = () => { var _a; return ((_a = children[0].ref) !== null && _a !== void 0 ? _a : triggerEl).current; };
|
|
25
|
-
const handlePosition = e => (0, fixed_box_1.calculatePosition)(getTriggerEl(), boxEl.current, e, position, maxWidth, minWidth, space);
|
|
25
|
+
const handlePosition = e => (0, fixed_box_1.calculatePosition)(getTriggerEl(), boxEl.current, e, position, maxWidth, minWidth, space, isOverflowPrevented);
|
|
26
26
|
const { getStatus, handleBeforeShow, } = (0, useFixedBoxMethods_1.default)({ beforeShow, boxEl, getTriggerEl, handlePosition, isDismissible, key: 'fixed-box', setStatus, status, triggerInteraction });
|
|
27
27
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
28
28
|
react_1.default.cloneElement(children[0], { ref: (_a = children[0].ref) !== null && _a !== void 0 ? _a : triggerEl }),
|
|
@@ -8,7 +8,9 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
9
|
const css_1 = require("../../util/css");
|
|
10
10
|
const radio_1 = require("../../util/radio");
|
|
11
|
-
const Container = styled_components_1.default.div(
|
|
11
|
+
const Container = styled_components_1.default.div.attrs({
|
|
12
|
+
className: 'src-radio-container',
|
|
13
|
+
})(({ theme }) => `
|
|
12
14
|
align-items: center;
|
|
13
15
|
border: solid 2px ${theme.$.color.dynamic.accent};
|
|
14
16
|
border-radius: 100%;
|
|
@@ -17,7 +19,9 @@ const Container = styled_components_1.default.div(({ theme }) => `
|
|
|
17
19
|
justify-content: center;
|
|
18
20
|
height: 100%;
|
|
19
21
|
`);
|
|
20
|
-
const OuterCircle = styled_components_1.default.div
|
|
22
|
+
const OuterCircle = styled_components_1.default.div.attrs({
|
|
23
|
+
className: 'src-radio-outer-circle',
|
|
24
|
+
}) `
|
|
21
25
|
align-items: center;
|
|
22
26
|
border-radius: 100%;
|
|
23
27
|
display: flex;
|
|
@@ -27,7 +31,9 @@ const OuterCircle = styled_components_1.default.div `
|
|
|
27
31
|
transition: 200ms 0s ease-in-out;
|
|
28
32
|
transition-property: height, width;
|
|
29
33
|
`;
|
|
30
|
-
const InnerCircle = styled_components_1.default.div(
|
|
34
|
+
const InnerCircle = styled_components_1.default.div.attrs({
|
|
35
|
+
className: 'src-radio-inner-circle',
|
|
36
|
+
})(({ theme }) => `
|
|
31
37
|
background: ${theme.$.color.dynamic.background};
|
|
32
38
|
border-radius: 100%;
|
|
33
39
|
flex: 0 0 auto;
|
|
@@ -42,7 +48,7 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ child
|
|
|
42
48
|
height: ${t.$.size.radio[v]};
|
|
43
49
|
width: ${t.$.size.radio[v]};
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
.src-radio-inner-circle {
|
|
46
52
|
height: ${(0, css_1.toCSSValue)(t.$.size.radio[v])(v => (0, radio_1.calculateRadioInnerCircleSize)(v))};
|
|
47
53
|
width: ${(0, css_1.toCSSValue)(t.$.size.radio[v])(v => (0, radio_1.calculateRadioInnerCircleSize)(v))};
|
|
48
54
|
}
|
|
@@ -52,13 +58,13 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ child
|
|
|
52
58
|
|
|
53
59
|
${!isOutline
|
|
54
60
|
? `
|
|
55
|
-
|
|
61
|
+
.src-radio-container {
|
|
56
62
|
background: ${theme.$.color.dynamic.accent};
|
|
57
63
|
}
|
|
58
64
|
`
|
|
59
65
|
: ''}
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
.src-radio-outer-circle {
|
|
62
68
|
background: ${!isSoft ? theme.$.palette[palette].main : theme.$.palette[palette].soft};
|
|
63
69
|
|
|
64
70
|
${!isChecked
|
package/package.json
CHANGED
package/util/fixed-box.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { Position } from '../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Calculated fixed box position and size.
|
|
5
5
|
*/
|
|
6
|
-
export declare const calculatePosition: (triggerEl: HTMLElement, boxEl: HTMLDivElement | null, e: Nullable<MouseEvent>, position: Position, maxWidth: number | undefined, minWidth: number | undefined, space: number) => void;
|
|
6
|
+
export declare const calculatePosition: (triggerEl: HTMLElement, boxEl: HTMLDivElement | null, e: Nullable<MouseEvent>, position: Position, maxWidth: number | undefined, minWidth: number | undefined, space: number, isOverflowPrevented: boolean) => void;
|
package/util/fixed-box.js
CHANGED
|
@@ -6,7 +6,7 @@ const dom_1 = require("./dom");
|
|
|
6
6
|
/**
|
|
7
7
|
* Calculated fixed box position and size.
|
|
8
8
|
*/
|
|
9
|
-
const calculatePosition = (triggerEl, boxEl, e, position, maxWidth, minWidth, space) => {
|
|
9
|
+
const calculatePosition = (triggerEl, boxEl, e, position, maxWidth, minWidth, space, isOverflowPrevented) => {
|
|
10
10
|
if (!boxEl) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
@@ -27,14 +27,14 @@ const calculatePosition = (triggerEl, boxEl, e, position, maxWidth, minWidth, sp
|
|
|
27
27
|
}
|
|
28
28
|
boxEl.style.width = `${width}px`;
|
|
29
29
|
boxEl.setAttribute('style', position & (types_1.Position.LEFT | types_1.Position.RIGHT)
|
|
30
|
-
? calculatePositionBasedOnXAxis(triggerRect, boxEl, e, position, space, windowWidth, windowHeight)
|
|
31
|
-
: calculatePositionBasedOnYAxis(triggerRect, boxEl, e, position, space, windowWidth, windowHeight));
|
|
30
|
+
? calculatePositionBasedOnXAxis(triggerRect, boxEl, e, position, space, windowWidth, windowHeight, isOverflowPrevented)
|
|
31
|
+
: calculatePositionBasedOnYAxis(triggerRect, boxEl, e, position, space, windowWidth, windowHeight, isOverflowPrevented));
|
|
32
32
|
};
|
|
33
33
|
exports.calculatePosition = calculatePosition;
|
|
34
34
|
/**
|
|
35
35
|
* Calculates fixed box position and sized based on X axis position.
|
|
36
36
|
*/
|
|
37
|
-
const calculatePositionBasedOnXAxis = (triggerRect, boxEl, e, position, space, windowWidth, windowHeight) => {
|
|
37
|
+
const calculatePositionBasedOnXAxis = (triggerRect, boxEl, e, position, space, windowWidth, windowHeight, isOverflowPrevented) => {
|
|
38
38
|
var _a, _b;
|
|
39
39
|
// left & width
|
|
40
40
|
let left;
|
|
@@ -50,6 +50,9 @@ const calculatePositionBasedOnXAxis = (triggerRect, boxEl, e, position, space, w
|
|
|
50
50
|
else {
|
|
51
51
|
left = triggerLeft + triggerWidth + space;
|
|
52
52
|
}
|
|
53
|
+
if (isOverflowPrevented) {
|
|
54
|
+
left = Math.max(0, Math.min(windowWidth - width, left));
|
|
55
|
+
}
|
|
53
56
|
// top & height
|
|
54
57
|
let top;
|
|
55
58
|
let height = boxEl.offsetHeight;
|
|
@@ -75,7 +78,7 @@ const calculatePositionBasedOnXAxis = (triggerRect, boxEl, e, position, space, w
|
|
|
75
78
|
/**
|
|
76
79
|
* Calculates fixed box position and sized based on Y axis position.
|
|
77
80
|
*/
|
|
78
|
-
const calculatePositionBasedOnYAxis = (triggerRect, boxEl, e, position, space, windowWidth, windowHeight) => {
|
|
81
|
+
const calculatePositionBasedOnYAxis = (triggerRect, boxEl, e, position, space, windowWidth, windowHeight, isOverflowPrevented) => {
|
|
79
82
|
var _a, _b;
|
|
80
83
|
// left & width
|
|
81
84
|
let left;
|
|
@@ -90,6 +93,9 @@ const calculatePositionBasedOnYAxis = (triggerRect, boxEl, e, position, space, w
|
|
|
90
93
|
else {
|
|
91
94
|
left = triggerLeft + triggerWidth - width;
|
|
92
95
|
}
|
|
96
|
+
if (isOverflowPrevented) {
|
|
97
|
+
left = Math.max(0, Math.min(windowWidth - width, left));
|
|
98
|
+
}
|
|
93
99
|
// top & height
|
|
94
100
|
let top;
|
|
95
101
|
let height = boxEl.offsetHeight;
|