orcs-design-system 3.3.13 → 3.3.15
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.
|
@@ -12,10 +12,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
12
12
|
library.add(far);
|
|
13
13
|
export default {
|
|
14
14
|
title: "Components/FloatingPanels",
|
|
15
|
-
decorators: [storyFn => /*#__PURE__*/_jsx(Box, {
|
|
16
|
-
minHeight: "600px",
|
|
17
|
-
children: storyFn()
|
|
18
|
-
})],
|
|
19
15
|
component: FloatingPanels
|
|
20
16
|
};
|
|
21
17
|
const Properties = () => {
|
|
@@ -45,36 +41,68 @@ const Properties = () => {
|
|
|
45
41
|
}, "textInput1")]
|
|
46
42
|
});
|
|
47
43
|
};
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
const createPanels = function () {
|
|
45
|
+
let shouldUseAsControl = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
46
|
+
const panels = [{
|
|
47
|
+
id: "view-options",
|
|
48
|
+
iconName: "eye",
|
|
49
|
+
title: "View Options",
|
|
50
|
+
expanded: true,
|
|
51
|
+
content: /*#__PURE__*/_jsx(Properties, {})
|
|
52
|
+
}, {
|
|
53
|
+
id: "properties",
|
|
54
|
+
iconName: "sun",
|
|
55
|
+
title: "Properties",
|
|
56
|
+
content: /*#__PURE__*/_jsx(Properties, {})
|
|
57
|
+
}, {
|
|
58
|
+
id: "person-details",
|
|
59
|
+
iconName: "user",
|
|
60
|
+
title: "Person Details",
|
|
61
|
+
content: /*#__PURE__*/_jsx(Properties, {})
|
|
62
|
+
}];
|
|
63
|
+
if (shouldUseAsControl) {
|
|
64
|
+
return panels;
|
|
65
|
+
}
|
|
66
|
+
return panels.map(panel => ({
|
|
67
|
+
...panel,
|
|
68
|
+
expanded: panel.id === "person-details" ? true : false,
|
|
69
|
+
content: null,
|
|
70
|
+
stopToggling: panel.id === "view-options" ? false : true,
|
|
71
|
+
noActiveState: panel.id === "view-options" ? true : false
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
65
74
|
export const defaultFloatingPanels = () => {
|
|
75
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
76
|
+
minHeight: "600px",
|
|
77
|
+
children: /*#__PURE__*/_jsx(FloatingPanels, {
|
|
78
|
+
panels: createPanels(),
|
|
79
|
+
containerHeight: 500,
|
|
80
|
+
position: {
|
|
81
|
+
right: 20,
|
|
82
|
+
top: 20
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
defaultFloatingPanels.storyName = "Default Floating Panels";
|
|
88
|
+
export const floatingActionsPanel = () => {
|
|
66
89
|
return /*#__PURE__*/_jsx(FloatingPanels, {
|
|
67
|
-
panels:
|
|
68
|
-
containerHeight: 500,
|
|
90
|
+
panels: createPanels(false),
|
|
69
91
|
position: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
92
|
+
bottom: 10
|
|
93
|
+
},
|
|
94
|
+
centered: true,
|
|
95
|
+
onClick: panelId => alert(`Panel ${panelId} clicked`)
|
|
73
96
|
});
|
|
74
97
|
};
|
|
75
|
-
|
|
98
|
+
floatingActionsPanel.storyName = "Floating Panels as Controls";
|
|
76
99
|
defaultFloatingPanels.__docgenInfo = {
|
|
77
100
|
"description": "",
|
|
78
101
|
"methods": [],
|
|
79
102
|
"displayName": "defaultFloatingPanels"
|
|
103
|
+
};
|
|
104
|
+
floatingActionsPanel.__docgenInfo = {
|
|
105
|
+
"description": "",
|
|
106
|
+
"methods": [],
|
|
107
|
+
"displayName": "floatingActionsPanel"
|
|
80
108
|
};
|
|
@@ -4,7 +4,7 @@ const panelWidth = "300px";
|
|
|
4
4
|
export const ComponentContainer = styled.div.withConfig({
|
|
5
5
|
displayName: "FloatingPanelsstyles__ComponentContainer",
|
|
6
6
|
componentId: "sc-1by914f-0"
|
|
7
|
-
})(["z-index:2;position:absolute;display:flex;flex-direction:column;align-items:flex-end;gap:8px;max-height:", ";", ""], _ref => {
|
|
7
|
+
})(["z-index:2;position:absolute;display:flex;flex-direction:column;align-items:flex-end;gap:8px;max-height:", ";", " ", ""], _ref => {
|
|
8
8
|
let {
|
|
9
9
|
containerHeight
|
|
10
10
|
} = _ref;
|
|
@@ -20,23 +20,32 @@ export const ComponentContainer = styled.div.withConfig({
|
|
|
20
20
|
let [key, value] = _ref4;
|
|
21
21
|
return `${key}: ${typeof value === "number" ? `${value}px` : value};`;
|
|
22
22
|
}).join("\n");
|
|
23
|
+
}, _ref5 => {
|
|
24
|
+
let {
|
|
25
|
+
centered
|
|
26
|
+
} = _ref5;
|
|
27
|
+
return centered ? `
|
|
28
|
+
margin-left: 50%;
|
|
29
|
+
transform: translateX(-50%);
|
|
30
|
+
right: auto;
|
|
31
|
+
` : "";
|
|
23
32
|
});
|
|
24
33
|
export const PanelContainer = styled.div.withConfig({
|
|
25
34
|
displayName: "FloatingPanelsstyles__PanelContainer",
|
|
26
35
|
componentId: "sc-1by914f-1"
|
|
27
|
-
})(["display:flex;flex-direction:column;align-items:flex-end;box-shadow:0 1px 3px rgba(0,0,0,0.1);gap:8px;border-radius:calc(", " + 1px);overflow:hidden;background:transparent;width:", ";max-height:", ";"], themeGet("radii.2"), panelWidth,
|
|
36
|
+
})(["display:flex;flex-direction:column;align-items:flex-end;box-shadow:0 1px 3px rgba(0,0,0,0.1);gap:8px;border-radius:calc(", " + 1px);overflow:hidden;background:transparent;width:", ";max-height:", ";"], themeGet("radii.2"), panelWidth, _ref6 => {
|
|
28
37
|
let {
|
|
29
38
|
containerHeight
|
|
30
|
-
} =
|
|
39
|
+
} = _ref6;
|
|
31
40
|
return containerHeight ? `${containerHeight}px` : "100%";
|
|
32
41
|
});
|
|
33
42
|
export const PanelWrapper = styled.div.withConfig({
|
|
34
43
|
displayName: "FloatingPanelsstyles__PanelWrapper",
|
|
35
44
|
componentId: "sc-1by914f-2"
|
|
36
|
-
})(["display:", ";background:white;width:", ";border:1px solid ", ";border-radius:8px;border-radius:0 0 8px 8px;overflow-y:auto;padding:\"0 12px 12px 12px\";margin-top:37px;transition:max-height 0.3s ease-in-out;"],
|
|
45
|
+
})(["display:", ";background:white;width:", ";border:1px solid ", ";border-radius:8px;border-radius:0 0 8px 8px;overflow-y:auto;padding:\"0 12px 12px 12px\";margin-top:37px;transition:max-height 0.3s ease-in-out;"], _ref7 => {
|
|
37
46
|
let {
|
|
38
47
|
isExpanded
|
|
39
|
-
} =
|
|
48
|
+
} = _ref7;
|
|
40
49
|
return isExpanded ? "block" : "none";
|
|
41
50
|
}, panelWidth, themeGet("colors.greyLighter"));
|
|
42
51
|
export const PanelHeader = styled.button.withConfig({
|
|
@@ -58,28 +67,28 @@ export const PanelBar = styled.div.withConfig({
|
|
|
58
67
|
export const IconButton = styled.button.withConfig({
|
|
59
68
|
displayName: "FloatingPanelsstyles__IconButton",
|
|
60
69
|
componentId: "sc-1by914f-7"
|
|
61
|
-
})(["font-family:", ";appearance:none;background-color:", ";border:none;width:36px;cursor:pointer;height:36px;display:flex;border-radius:", ";align-items:center;justify-content:center;transition:", ";&:hover{background-color:", ";}"], themeGet("fonts.main"),
|
|
70
|
+
})(["font-family:", ";appearance:none;background-color:", ";border:none;width:36px;cursor:pointer;height:36px;display:flex;border-radius:", ";align-items:center;justify-content:center;transition:", ";&:hover{background-color:", ";}"], themeGet("fonts.main"), _ref8 => {
|
|
62
71
|
let {
|
|
63
72
|
isExpanded
|
|
64
|
-
} =
|
|
73
|
+
} = _ref8;
|
|
65
74
|
return isExpanded ? themeGet("colors.primaryLightest") : themeGet("colors.white");
|
|
66
75
|
}, themeGet("radii.2"), themeGet("transition.transitionDefault"), themeGet("colors.primaryLightest"));
|
|
67
76
|
export const PanelContent = styled.div.withConfig({
|
|
68
77
|
displayName: "FloatingPanelsstyles__PanelContent",
|
|
69
78
|
componentId: "sc-1by914f-8"
|
|
70
|
-
})(["padding:8px;width:inerhit;display:", ";height:", ";opacity:", ";"],
|
|
79
|
+
})(["padding:8px;width:inerhit;display:", ";height:", ";opacity:", ";"], _ref9 => {
|
|
71
80
|
let {
|
|
72
81
|
isExpanded
|
|
73
|
-
} =
|
|
82
|
+
} = _ref9;
|
|
74
83
|
return isExpanded ? "block" : "none";
|
|
75
|
-
},
|
|
84
|
+
}, _ref10 => {
|
|
76
85
|
let {
|
|
77
86
|
isExpanded
|
|
78
|
-
} =
|
|
87
|
+
} = _ref10;
|
|
79
88
|
return isExpanded ? "100%" : "0";
|
|
80
|
-
},
|
|
89
|
+
}, _ref11 => {
|
|
81
90
|
let {
|
|
82
91
|
isExpanded
|
|
83
|
-
} =
|
|
92
|
+
} = _ref11;
|
|
84
93
|
return isExpanded ? "1" : "0";
|
|
85
94
|
});
|
|
@@ -14,6 +14,9 @@ export const Panel = _ref => {
|
|
|
14
14
|
toggleExpanded
|
|
15
15
|
} = _ref;
|
|
16
16
|
const [isHovered, setIsHovered] = useState(false);
|
|
17
|
+
if (!content) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
17
20
|
return /*#__PURE__*/_jsxs(PanelWrapper, {
|
|
18
21
|
containerHeight: containerHeight,
|
|
19
22
|
isExpanded: isExpanded,
|
|
@@ -11,21 +11,30 @@ const FloatingPanels = _ref => {
|
|
|
11
11
|
right: 20,
|
|
12
12
|
top: 20
|
|
13
13
|
},
|
|
14
|
+
centered = false,
|
|
14
15
|
onClick = () => {}
|
|
15
16
|
} = _ref;
|
|
16
17
|
const [expandedPanelId, setExpandedPanelId] = useState(null);
|
|
17
18
|
useEffect(() => {
|
|
18
19
|
const expandedPanel = panels.find(panel => panel.expanded);
|
|
19
|
-
if (expandedPanel?.id) {
|
|
20
|
+
if (expandedPanel?.id && !expandedPanel.noActiveState) {
|
|
20
21
|
setExpandedPanelId(expandedPanel.id);
|
|
21
22
|
}
|
|
22
23
|
}, [panels]);
|
|
23
24
|
const togglePanel = panelId => {
|
|
25
|
+
const selectedPanel = panels.find(panel => panel.id === panelId);
|
|
26
|
+
if (selectedPanel?.stopToggling && expandedPanelId === panelId) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
onClick(panelId);
|
|
24
30
|
const selectedPanelId = expandedPanelId === panelId ? null : panelId;
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
if (!selectedPanel.noActiveState) {
|
|
32
|
+
setExpandedPanelId(selectedPanelId);
|
|
33
|
+
}
|
|
27
34
|
};
|
|
35
|
+
const shouldDisplayPanelContainer = panels?.some(panel => panel?.content);
|
|
28
36
|
return /*#__PURE__*/_jsxs(ComponentContainer, {
|
|
37
|
+
centered: centered,
|
|
29
38
|
containerHeight: containerHeight,
|
|
30
39
|
position: position,
|
|
31
40
|
children: [/*#__PURE__*/_jsx(PanelBar, {
|
|
@@ -35,7 +44,7 @@ const FloatingPanels = _ref => {
|
|
|
35
44
|
isExpanded: expandedPanelId === panel.id,
|
|
36
45
|
toggleExpanded: () => togglePanel(panel.id)
|
|
37
46
|
}, panel?.id))
|
|
38
|
-
}), /*#__PURE__*/_jsx(PanelContainer, {
|
|
47
|
+
}), shouldDisplayPanelContainer && /*#__PURE__*/_jsx(PanelContainer, {
|
|
39
48
|
containerHeight: containerHeight,
|
|
40
49
|
children: panels.map(panel => /*#__PURE__*/_jsx(Panel, {
|
|
41
50
|
...panel,
|
|
@@ -61,7 +70,8 @@ FloatingPanels.propTypes = {
|
|
|
61
70
|
bottom: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
62
71
|
left: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
63
72
|
}),
|
|
64
|
-
onClick: PropTypes.func
|
|
73
|
+
onClick: PropTypes.func,
|
|
74
|
+
centered: PropTypes.bool
|
|
65
75
|
};
|
|
66
76
|
FloatingPanels.defaultProps = {
|
|
67
77
|
position: {
|
|
@@ -123,6 +133,17 @@ FloatingPanels.__docgenInfo = {
|
|
|
123
133
|
},
|
|
124
134
|
"required": false
|
|
125
135
|
},
|
|
136
|
+
"centered": {
|
|
137
|
+
"defaultValue": {
|
|
138
|
+
"value": "false",
|
|
139
|
+
"computed": false
|
|
140
|
+
},
|
|
141
|
+
"description": "",
|
|
142
|
+
"type": {
|
|
143
|
+
"name": "bool"
|
|
144
|
+
},
|
|
145
|
+
"required": false
|
|
146
|
+
},
|
|
126
147
|
"onClick": {
|
|
127
148
|
"defaultValue": {
|
|
128
149
|
"value": "() => {}",
|