stargazer-ui 1.2.1 → 1.2.2
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/Bar/Bar.type.d.ts +6 -0
- package/Bar/index.js +2 -0
- package/Bar/index.js.map +1 -0
- package/Bar/package.json +1 -0
- package/Button/Button.js +12 -0
- package/Button/Button.js.map +1 -0
- package/{types/components/Button → Button}/Button.types.d.ts +1 -2
- package/Button/index.d.ts +3 -0
- package/Button/index.js +7 -0
- package/Button/index.js.map +1 -0
- package/Button/package.json +1 -0
- package/ButtonGroup/ButtonGroup.d.ts +4 -0
- package/ButtonGroup/ButtonGroup.js +10 -0
- package/ButtonGroup/ButtonGroup.js.map +1 -0
- package/ButtonGroup/ButtonGroup.types.d.ts +7 -0
- package/ButtonGroup/index.d.ts +3 -0
- package/ButtonGroup/index.js +7 -0
- package/ButtonGroup/index.js.map +1 -0
- package/ButtonGroup/package.json +1 -0
- package/Card/Card.js +41 -0
- package/Card/Card.js.map +1 -0
- package/{types/components/Card → Card}/Card.types.d.ts +3 -1
- package/Card/index.d.ts +3 -0
- package/Card/index.js +7 -0
- package/Card/index.js.map +1 -0
- package/Card/package.json +1 -0
- package/CloseButton/CloseButton.js +11 -0
- package/CloseButton/CloseButton.js.map +1 -0
- package/{types/components/CloseButton → CloseButton}/CloseButton.types.d.ts +1 -1
- package/CloseButton/index.d.ts +3 -0
- package/CloseButton/index.js +7 -0
- package/CloseButton/index.js.map +1 -0
- package/CloseButton/package.json +1 -0
- package/Dropdown/Dropdown.js +301 -0
- package/Dropdown/Dropdown.js.map +1 -0
- package/{types/components/Dropdown → Dropdown}/Dropdown.types.d.ts +3 -10
- package/Dropdown/index.d.ts +4 -0
- package/Dropdown/index.js +8 -0
- package/Dropdown/index.js.map +1 -0
- package/Dropdown/package.json +1 -0
- package/FileUploadButton/FileUploadButton.d.ts +4 -0
- package/FileUploadButton/FileUploadButton.js +21 -0
- package/FileUploadButton/FileUploadButton.js.map +1 -0
- package/FileUploadButton/FileUploadButton.types.d.ts +7 -0
- package/FileUploadButton/index.d.ts +3 -0
- package/FileUploadButton/index.js +7 -0
- package/FileUploadButton/index.js.map +1 -0
- package/FileUploadButton/package.json +1 -0
- package/FloatingLabel/FloatingLabel.js +17 -0
- package/FloatingLabel/FloatingLabel.js.map +1 -0
- package/{types/components/FloatingLabel → FloatingLabel}/FloatingLabel.types.d.ts +1 -1
- package/FloatingLabel/index.d.ts +3 -0
- package/FloatingLabel/index.js +7 -0
- package/FloatingLabel/index.js.map +1 -0
- package/FloatingLabel/package.json +1 -0
- package/Form/Form.d.ts +38 -0
- package/Form/Form.js +308 -0
- package/Form/Form.js.map +1 -0
- package/Form/Form.types.d.ts +105 -0
- package/Form/index.d.ts +4 -0
- package/Form/index.js +8 -0
- package/Form/index.js.map +1 -0
- package/Form/package.json +1 -0
- package/InputGroup/InputGroup.d.ts +7 -0
- package/InputGroup/InputGroup.js +31 -0
- package/InputGroup/InputGroup.js.map +1 -0
- package/InputGroup/InputGroup.types.d.ts +16 -0
- package/InputGroup/index.d.ts +4 -0
- package/InputGroup/index.js +7 -0
- package/InputGroup/index.js.map +1 -0
- package/InputGroup/package.json +1 -0
- package/List/List.d.ts +14 -0
- package/List/List.js +76 -0
- package/List/List.js.map +1 -0
- package/List/List.types.d.ts +28 -0
- package/List/index.d.ts +3 -0
- package/List/index.js +7 -0
- package/List/index.js.map +1 -0
- package/List/package.json +1 -0
- package/{types/components/Modal → Modal}/Modal.d.ts +1 -1
- package/Modal/Modal.js +160 -0
- package/Modal/Modal.js.map +1 -0
- package/{types/components/Modal → Modal}/Modal.types.d.ts +3 -2
- package/Modal/index.d.ts +3 -0
- package/Modal/index.js +7 -0
- package/Modal/index.js.map +1 -0
- package/Modal/package.json +1 -0
- package/Nav/Nav.js +28 -0
- package/Nav/Nav.js.map +1 -0
- package/{types/components/Nav → Nav}/Nav.types.d.ts +1 -1
- package/Nav/index.d.ts +4 -0
- package/Nav/index.js +7 -0
- package/Nav/index.js.map +1 -0
- package/Nav/package.json +1 -0
- package/{types/components/NavBar → NavBar}/Navbar.d.ts +1 -2
- package/NavBar/Navbar.js +36 -0
- package/NavBar/Navbar.js.map +1 -0
- package/{types/components/NavBar → NavBar}/Navbar.types.d.ts +2 -1
- package/NavBar/index.d.ts +4 -0
- package/NavBar/index.js +8 -0
- package/NavBar/index.js.map +1 -0
- package/NavBar/package.json +1 -0
- package/{types/components/NavDropdown → NavDropdown}/NavDropdown.d.ts +2 -2
- package/NavDropdown/NavDropdown.js +77 -0
- package/NavDropdown/NavDropdown.js.map +1 -0
- package/NavDropdown/index.d.ts +3 -0
- package/NavDropdown/index.js +7 -0
- package/NavDropdown/index.js.map +1 -0
- package/NavDropdown/package.json +1 -0
- package/Overlay/Overlay.d.ts +4 -0
- package/Overlay/Overlay.js +228 -0
- package/Overlay/Overlay.js.map +1 -0
- package/Overlay/Overlay.types.d.ts +18 -0
- package/{src/Overlay/index.ts → Overlay/index.d.ts} +3 -3
- package/Overlay/index.js +7 -0
- package/Overlay/index.js.map +1 -0
- package/Overlay/package.json +1 -0
- package/Popout/Popout.js +110 -0
- package/Popout/Popout.js.map +1 -0
- package/{types/components/Popout → Popout}/Popout.types.d.ts +1 -1
- package/Popout/index.d.ts +3 -0
- package/Popout/index.js +7 -0
- package/Popout/index.js.map +1 -0
- package/Popout/package.json +1 -0
- package/Spinner/Spinner.js +12 -0
- package/Spinner/Spinner.js.map +1 -0
- package/Spinner/index.d.ts +3 -0
- package/Spinner/index.js +7 -0
- package/Spinner/index.js.map +1 -0
- package/Spinner/package.json +1 -0
- package/Table/Table.js +11 -0
- package/Table/Table.js.map +1 -0
- package/{types/components/Table → Table}/Table.types.d.ts +1 -1
- package/Table/index.d.ts +3 -0
- package/Table/index.js +7 -0
- package/Table/index.js.map +1 -0
- package/Table/package.json +1 -0
- package/Tabs/Tabs.js +158 -0
- package/Tabs/Tabs.js.map +1 -0
- package/{types/components/Tabs → Tabs}/Tabs.types.d.ts +9 -1
- package/Tabs/index.d.ts +3 -0
- package/Tabs/index.js +7 -0
- package/Tabs/index.js.map +1 -0
- package/Tabs/package.json +1 -0
- package/ToggleButton/ToggleButton.d.ts +4 -0
- package/ToggleButton/ToggleButton.js +17 -0
- package/ToggleButton/ToggleButton.js.map +1 -0
- package/ToggleButton/ToggleButton.types.d.ts +7 -0
- package/ToggleButton/index.d.ts +3 -0
- package/ToggleButton/index.js +7 -0
- package/ToggleButton/index.js.map +1 -0
- package/ToggleButton/package.json +1 -0
- package/{src/hooks/index.ts → hooks/index.d.ts} +5 -6
- package/hooks/index.js +6 -0
- package/hooks/index.js.map +1 -0
- package/hooks/package.json +1 -0
- package/hooks/useClassname.d.ts +2 -0
- package/hooks/useClassname.js +7 -0
- package/hooks/useClassname.js.map +1 -0
- package/hooks/useDraggable.d.ts +23 -0
- package/hooks/useDraggable.js +147 -0
- package/hooks/useDraggable.js.map +1 -0
- package/hooks/useKeepElementFocused.d.ts +2 -0
- package/hooks/useKeepElementFocused.js +37 -0
- package/hooks/useKeepElementFocused.js.map +1 -0
- package/hooks/useScreenSize.d.ts +5 -0
- package/hooks/useScreenSize.js +21 -0
- package/hooks/useScreenSize.js.map +1 -0
- package/index.d.ts +18 -0
- package/index.js +19 -0
- package/index.js.map +1 -0
- package/package.json +1 -79
- package/{dev → styles}/stargazerui.css +3099 -395
- package/styles/stargazerui.css.map +1 -0
- package/{src/utils/BaseTypes.ts → utils/BaseTypes.d.ts} +23 -30
- package/utils/ContrastingColor.d.ts +1 -0
- package/utils/MergeClassnames.d.ts +2 -0
- package/utils/MergeClassnames.js +7 -0
- package/utils/MergeClassnames.js.map +1 -0
- package/utils/MergeRefs.d.ts +2 -0
- package/utils/MergeRefs.js +16 -0
- package/utils/MergeRefs.js.map +1 -0
- package/.babelrc.json +0 -10
- package/.eslintrc.cjs +0 -18
- package/.gitattributes +0 -2
- package/LICENSE +0 -21
- package/dev/index.html +0 -12
- package/dev/index.jsx +0 -49
- package/dev/index.scss +0 -59
- package/dev/pages/ButtonPage.jsx +0 -44
- package/dev/pages/CardPage.jsx +0 -81
- package/dev/pages/DropdownPage.jsx +0 -31
- package/dev/pages/FormPage.jsx +0 -130
- package/dev/pages/ListPage.jsx +0 -52
- package/dev/pages/ModalPage.jsx +0 -37
- package/dev/pages/OverlayPage.jsx +0 -35
- package/dev/pages/components.jsx +0 -19
- package/dev/stargazerui.css.map +0 -1
- package/dev/test.jsx +0 -88
- package/rollup.config.js +0 -140
- package/scripts/writePackageJsons.js +0 -42
- package/src/Bar/Bar.tsx +0 -0
- package/src/Bar/Bar.type.ts +0 -9
- package/src/Bar/index.ts +0 -0
- package/src/Button/Button.tsx +0 -17
- package/src/Button/Button.types.ts +0 -8
- package/src/Button/index.ts +0 -3
- package/src/ButtonGroup/ButtonGroup.tsx +0 -14
- package/src/ButtonGroup/ButtonGroup.types.ts +0 -8
- package/src/ButtonGroup/index.ts +0 -3
- package/src/Card/Card.tsx +0 -70
- package/src/Card/Card.types.ts +0 -33
- package/src/Card/index.ts +0 -3
- package/src/CloseButton/CloseButton.tsx +0 -14
- package/src/CloseButton/CloseButton.types.ts +0 -6
- package/src/CloseButton/index.ts +0 -3
- package/src/Dropdown/Dropdown.tsx +0 -358
- package/src/Dropdown/Dropdown.types.ts +0 -52
- package/src/Dropdown/index.ts +0 -4
- package/src/FileUploadButton/FileUploadButton.tsx +0 -27
- package/src/FileUploadButton/FileUploadButton.types.ts +0 -9
- package/src/FileUploadButton/index.ts +0 -3
- package/src/FloatingLabel/FloatingLabel.tsx +0 -22
- package/src/FloatingLabel/FloatingLabel.types.ts +0 -11
- package/src/FloatingLabel/index.ts +0 -3
- package/src/Form/Form.tsx +0 -445
- package/src/Form/Form.types.ts +0 -117
- package/src/Form/index.ts +0 -4
- package/src/InputGroup/InputGroup.tsx +0 -46
- package/src/InputGroup/InputGroup.types.ts +0 -21
- package/src/InputGroup/index.ts +0 -4
- package/src/List/List.tsx +0 -112
- package/src/List/List.types.ts +0 -34
- package/src/List/index.ts +0 -4
- package/src/Modal/Modal.tsx +0 -220
- package/src/Modal/Modal.types.ts +0 -49
- package/src/Modal/index.ts +0 -4
- package/src/Nav/Nav.tsx +0 -43
- package/src/Nav/Nav.types.ts +0 -21
- package/src/Nav/index.ts +0 -4
- package/src/NavBar/Navbar.tsx +0 -57
- package/src/NavBar/Navbar.types.ts +0 -24
- package/src/NavBar/index.ts +0 -4
- package/src/NavDropdown/NavDropdown.tsx +0 -93
- package/src/NavDropdown/NavDropdown.types.ts +0 -6
- package/src/NavDropdown/index.ts +0 -3
- package/src/Overlay/Overlay.tsx +0 -277
- package/src/Overlay/Overlay.types.ts +0 -20
- package/src/Popout/Popout.tsx +0 -155
- package/src/Popout/Popout.types.ts +0 -42
- package/src/Popout/index.ts +0 -3
- package/src/Spinner/Spinner.tsx +0 -15
- package/src/Spinner/Spinner.types.ts +0 -7
- package/src/Spinner/index.ts +0 -3
- package/src/Table/Table.tsx +0 -16
- package/src/Table/Table.types.ts +0 -9
- package/src/Table/index.ts +0 -3
- package/src/Tabs/Tabs.tsx +0 -215
- package/src/Tabs/Tabs.types.ts +0 -49
- package/src/Tabs/index.ts +0 -3
- package/src/ToggleButton/ToggleButton.tsx +0 -21
- package/src/ToggleButton/ToggleButton.types.ts +0 -8
- package/src/ToggleButton/index.ts +0 -3
- package/src/hooks/useClassname.ts +0 -5
- package/src/hooks/useDraggable.ts +0 -186
- package/src/hooks/useKeepElementFocused.ts +0 -37
- package/src/hooks/useScreenSize.ts +0 -24
- package/src/index.ts +0 -21
- package/src/styles/_Card.scss +0 -166
- package/src/styles/_CloseButton.scss +0 -51
- package/src/styles/_CustomButton.scss +0 -132
- package/src/styles/_Dropdown.scss +0 -120
- package/src/styles/_FloatingLabel.scss +0 -56
- package/src/styles/_Forms.scss +0 -7
- package/src/styles/_Grid.scss +0 -178
- package/src/styles/_InputGroup.scss +0 -71
- package/src/styles/_List.scss +0 -62
- package/src/styles/_Modal.scss +0 -234
- package/src/styles/_ModalOld.scss +0 -242
- package/src/styles/_Nav.scss +0 -36
- package/src/styles/_NavBar.scss +0 -116
- package/src/styles/_NavDropdown.scss +0 -34
- package/src/styles/_OffCanvas.scss +0 -260
- package/src/styles/_OverLay.scss +0 -56
- package/src/styles/_Popout.scss +0 -75
- package/src/styles/_Spinner.scss +0 -19
- package/src/styles/_Table.scss +0 -34
- package/src/styles/_Tabs.scss +0 -129
- package/src/styles/_colors.scss +0 -510
- package/src/styles/_components.scss +0 -40
- package/src/styles/_functions.scss +0 -134
- package/src/styles/_mixins.scss +0 -26
- package/src/styles/_reset.scss +0 -231
- package/src/styles/_utilities.scss +0 -2480
- package/src/styles/_variables.scss +0 -146
- package/src/styles/forms/_FormCheck.scss +0 -269
- package/src/styles/forms/_FormControl.scss +0 -102
- package/src/styles/forms/_FormGroup.scss +0 -21
- package/src/styles/forms/_FormLabel.scss +0 -3
- package/src/styles/forms/_FormSelect.scss +0 -164
- package/src/styles/forms/_FormSlider.scss +0 -116
- package/src/styles/forms/_FormText.scss +0 -6
- package/src/utils/ContrastingColor.ts +0 -25
- package/src/utils/FileImportExport.js +0 -50
- package/src/utils/MergeClassnames.ts +0 -5
- package/src/utils/MergeRefs.ts +0 -12
- package/src/vite-env.d.ts +0 -1
- package/tsconfig-build.json +0 -4
- package/tsconfig.json +0 -79
- package/tsconfig.node.json +0 -10
- package/types/BaseTypes.d.ts +0 -19
- package/types/components/Button/index.d.ts +0 -1
- package/types/components/Card/index.d.ts +0 -1
- package/types/components/CloseButton/index.d.ts +0 -1
- package/types/components/Dropdown/index.d.ts +0 -1
- package/types/components/FloatingLabel/index.d.ts +0 -1
- package/types/components/Form/Form.d.ts +0 -17
- package/types/components/Form/Form.types.d.ts +0 -50
- package/types/components/Form/index.d.ts +0 -1
- package/types/components/InputGroup/InputGroup.d.ts +0 -6
- package/types/components/InputGroup/InputGroup.types.d.ts +0 -10
- package/types/components/InputGroup/index.d.ts +0 -1
- package/types/components/Modal/index.d.ts +0 -1
- package/types/components/Nav/index.d.ts +0 -1
- package/types/components/NavBar/index.d.ts +0 -1
- package/types/components/NavDropdown/index.d.ts +0 -1
- package/types/components/Popout/index.d.ts +0 -1
- package/types/components/Spinner/index.d.ts +0 -1
- package/types/components/Table/index.d.ts +0 -1
- package/types/components/Tabs/index.d.ts +0 -1
- package/types/components/ToggleButton/ToggleButton.d.ts +0 -9
- package/types/components/ToggleButton/ToggleButton.types.d.ts +0 -0
- package/types/components/ToggleButton/index.d.ts +0 -1
- package/types/components/index.d.ts +0 -16
- package/types/index.d.ts +0 -1
- package/vite.config.js +0 -57
- package/vite.config.js.timestamp-1708777378490-e94428ceb2bf9.mjs +0 -42
- /package/{types/components/Button → Button}/Button.d.ts +0 -0
- /package/{types/components/Card → Card}/Card.d.ts +0 -0
- /package/{types/components/CloseButton → CloseButton}/CloseButton.d.ts +0 -0
- /package/{types/components/Dropdown → Dropdown}/Dropdown.d.ts +0 -0
- /package/{types/components/FloatingLabel → FloatingLabel}/FloatingLabel.d.ts +0 -0
- /package/{types/components/Nav → Nav}/Nav.d.ts +0 -0
- /package/{types/components/NavDropdown → NavDropdown}/NavDropdown.types.d.ts +0 -0
- /package/{types/components/Popout → Popout}/Popout.d.ts +0 -0
- /package/{types/components/Spinner → Spinner}/Spinner.d.ts +0 -0
- /package/{types/components/Spinner → Spinner}/Spinner.types.d.ts +0 -0
- /package/{types/components/Table → Table}/Table.d.ts +0 -0
- /package/{types/components/Tabs → Tabs}/Tabs.d.ts +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef, useState, useCallback, useMemo } from 'react';
|
|
3
|
+
import Dropdown, { DropdownContextProvider } from '../Dropdown/Dropdown.js';
|
|
4
|
+
|
|
5
|
+
const getDropdownMenuPlacement = (alignEnd, dropDirection, isRTL = false) => {
|
|
6
|
+
const topStart = isRTL ? 'top-end' : 'top-start';
|
|
7
|
+
const topEnd = isRTL ? 'top-start' : 'top-end';
|
|
8
|
+
const bottomStart = isRTL ? 'bottom-end' : 'bottom-start';
|
|
9
|
+
const bottomEnd = isRTL ? 'bottom-start' : 'bottom-end';
|
|
10
|
+
const leftStart = isRTL ? 'right-start' : 'left-start';
|
|
11
|
+
const leftEnd = isRTL ? 'right-end' : 'left-end';
|
|
12
|
+
const rightStart = isRTL ? 'left-start' : 'right-start';
|
|
13
|
+
const rightEnd = isRTL ? 'left-end' : 'right-end';
|
|
14
|
+
let placement = alignEnd ? bottomEnd : bottomStart;
|
|
15
|
+
if (dropDirection === 'up') {
|
|
16
|
+
placement = alignEnd ? topEnd : topStart;
|
|
17
|
+
}
|
|
18
|
+
else if (dropDirection === 'end') {
|
|
19
|
+
placement = alignEnd ? rightEnd : rightStart;
|
|
20
|
+
}
|
|
21
|
+
else if (dropDirection === 'start') {
|
|
22
|
+
placement = alignEnd ? leftEnd : leftStart;
|
|
23
|
+
}
|
|
24
|
+
else if (dropDirection === 'down-centered') {
|
|
25
|
+
placement = 'bottom';
|
|
26
|
+
}
|
|
27
|
+
else if (dropDirection === 'up-centered') {
|
|
28
|
+
placement = 'top';
|
|
29
|
+
}
|
|
30
|
+
return placement;
|
|
31
|
+
};
|
|
32
|
+
const NavDropdown = forwardRef(({ children, className, onSelect, onToggle, controlId, toggleProps, title, menuProps, drop = "down", align = "start", autoClose = true, show = "default", ...restProps }, ref) => {
|
|
33
|
+
const [showInternal, setShowInternal] = useState(show === "default" ? false : show);
|
|
34
|
+
// this is an object like {index: string} because we need it to rerender even if the case is the same
|
|
35
|
+
// aka we use a "next/previous" case to navigate through the dropdown menu so need to rerender consecutive "next" cases
|
|
36
|
+
const [activeDescendant, setActiveDescendant] = useState({ case: "" });
|
|
37
|
+
const internalOnToggle = useCallback((event) => {
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
setShowInternal(prev => !prev);
|
|
40
|
+
}, []);
|
|
41
|
+
const alignEnd = align === "end";
|
|
42
|
+
const placement = getDropdownMenuPlacement(alignEnd, drop);
|
|
43
|
+
const controlIdcomputed = controlId;
|
|
44
|
+
const contextValue = useMemo(() => ({
|
|
45
|
+
align,
|
|
46
|
+
drop,
|
|
47
|
+
showInternal: show != "default" && onToggle ? show : showInternal,
|
|
48
|
+
handleToggle: show != "default" && onToggle ? onToggle : internalOnToggle,
|
|
49
|
+
placement,
|
|
50
|
+
directionClasses: {
|
|
51
|
+
down: "dropdown",
|
|
52
|
+
'down-centered': `dropdown-center`,
|
|
53
|
+
up: 'dropup',
|
|
54
|
+
'up-centered': 'dropup-center dropup',
|
|
55
|
+
end: 'dropend',
|
|
56
|
+
start: 'dropstart'
|
|
57
|
+
},
|
|
58
|
+
controlId: controlIdcomputed,
|
|
59
|
+
activeDescendant,
|
|
60
|
+
setActiveDescendant,
|
|
61
|
+
navDropdown: false
|
|
62
|
+
}), [align, drop, show, showInternal, onToggle, internalOnToggle, placement, controlId, activeDescendant, setActiveDescendant]);
|
|
63
|
+
return (React.createElement("div", { ref: ref, id: controlId + "-wrapper", className: `sg-dropdown${className ? " " + className : ""} sg-nav-item`, ...restProps },
|
|
64
|
+
React.createElement(DropdownContextProvider, { value: contextValue },
|
|
65
|
+
React.createElement(Dropdown.Toggle, { navDropdown: true, ...toggleProps }, title),
|
|
66
|
+
React.createElement(Dropdown.Menu, { ...menuProps }, children))));
|
|
67
|
+
});
|
|
68
|
+
NavDropdown.displayName = "NavDropdown";
|
|
69
|
+
var NavDropdown$1 = Object.assign(NavDropdown, {
|
|
70
|
+
Toggle: Dropdown.Toggle,
|
|
71
|
+
Menu: Dropdown.Menu,
|
|
72
|
+
Item: Dropdown.Item,
|
|
73
|
+
Divider: Dropdown.Divider
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export { NavDropdown$1 as default };
|
|
77
|
+
//# sourceMappingURL=NavDropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavDropdown.js","sources":["../../src/NavDropdown/NavDropdown.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;;AAMA,MAAM,wBAAwB,G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
+
{"name":"stargazer-ui/NavDropdown","private":false,"module":"./index.js","types":"./index.d.ts","peerDependencies":{"lodash":"^4.17.21","react":">=17.0.0","react-dom":">=17.0.0"}}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef, useRef, useState, useLayoutEffect, useEffect, cloneElement } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import mergeRefs from '../utils/MergeRefs.js';
|
|
5
|
+
|
|
6
|
+
const setPosition = (referenceElement, overlayElement, position, arrowElement, isArrow = false, boundaryCorrection = { top: 0, left: 0, bottom: 0, right: 0 }) => {
|
|
7
|
+
const refCurrent = referenceElement.current;
|
|
8
|
+
const overlayCurrent = overlayElement.current;
|
|
9
|
+
const arrowCurrent = arrowElement.current;
|
|
10
|
+
const refTop = refCurrent.getBoundingClientRect().top;
|
|
11
|
+
const refHeight = refCurrent.offsetHeight;
|
|
12
|
+
const refLeft = refCurrent.getBoundingClientRect().left;
|
|
13
|
+
const refWidth = refCurrent.offsetWidth;
|
|
14
|
+
const overlayHeight = overlayCurrent.clientHeight;
|
|
15
|
+
const overlayWidth = overlayCurrent.clientWidth;
|
|
16
|
+
const arrowHeight = arrowCurrent.clientHeight;
|
|
17
|
+
const arrowWidth = arrowCurrent.clientWidth;
|
|
18
|
+
const arrowOffsetHeight = isArrow ? 0 : arrowHeight - 1;
|
|
19
|
+
const arrowOffsetWidth = isArrow ? 0 : arrowWidth - 1;
|
|
20
|
+
let tempPos;
|
|
21
|
+
switch (position) {
|
|
22
|
+
case "top":
|
|
23
|
+
tempPos = {
|
|
24
|
+
top: refTop - overlayHeight - arrowOffsetHeight,
|
|
25
|
+
left: refLeft + refWidth / 2 - overlayWidth / 2
|
|
26
|
+
};
|
|
27
|
+
//tempPos.right = correctPosition("right", 12, 0)
|
|
28
|
+
//tempPos.left = correctPosition("left", 0, 0)
|
|
29
|
+
return tempPos;
|
|
30
|
+
case "right":
|
|
31
|
+
tempPos = {
|
|
32
|
+
top: refTop + refHeight / 2 - overlayHeight / 2,
|
|
33
|
+
left: refLeft + refWidth + arrowOffsetWidth
|
|
34
|
+
};
|
|
35
|
+
//tempPos.bottom = correctPosition("bottom", window.scrollY + window.innerHeight, 0)
|
|
36
|
+
//tempPos.top = correctPosition("top", window.scrollY, 48)
|
|
37
|
+
return tempPos;
|
|
38
|
+
case "bottom":
|
|
39
|
+
tempPos = {
|
|
40
|
+
top: refTop + refHeight + arrowOffsetHeight,
|
|
41
|
+
left: refLeft + refWidth / 2 - overlayWidth / 2
|
|
42
|
+
};
|
|
43
|
+
//tempPos.right = correctPosition("right", 12, 0)
|
|
44
|
+
//tempPos.left = correctPosition("left", 0, 0)
|
|
45
|
+
return tempPos;
|
|
46
|
+
case "left":
|
|
47
|
+
tempPos = {
|
|
48
|
+
top: refTop + refHeight / 2 - overlayHeight / 2,
|
|
49
|
+
left: refLeft - overlayWidth - arrowOffsetWidth
|
|
50
|
+
};
|
|
51
|
+
//tempPos.bottom = correctPosition("bottom", window.scrollY + window.innerHeight, 0)
|
|
52
|
+
//tempPos.top = correctPosition("top", window.scrollY, 48)
|
|
53
|
+
return tempPos;
|
|
54
|
+
default:
|
|
55
|
+
//this is just top
|
|
56
|
+
return { top: refTop - overlayHeight - arrowHeight, left: refLeft + refWidth / 2 - overlayWidth / 2 };
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const updateAutoPosition = (autoPositionRef, positionRef, overlayRef, arrowRef) => {
|
|
60
|
+
let topDistance = positionRef.current.getBoundingClientRect().top;
|
|
61
|
+
let bottomDistance = window.innerHeight - positionRef.current.getBoundingClientRect().bottom;
|
|
62
|
+
positionRef.current.getBoundingClientRect().left;
|
|
63
|
+
let rightDistance = window.innerWidth - positionRef.current.getBoundingClientRect().right;
|
|
64
|
+
let totalOverlayWidth = overlayRef.current.clientWidth + arrowRef.current.clientWidth + 48;
|
|
65
|
+
let totalOverlayHeight = overlayRef.current.clientHeight + arrowRef.current.clientHeight + 48;
|
|
66
|
+
//console.log(autoPositionRef.current, positionRef.current, overlayRef.current, arrowRef.current)
|
|
67
|
+
if (topDistance >= totalOverlayHeight) {
|
|
68
|
+
return "top";
|
|
69
|
+
}
|
|
70
|
+
else if (topDistance >= totalOverlayHeight / 2) {
|
|
71
|
+
return rightDistance >= totalOverlayWidth ? "right" : "left";
|
|
72
|
+
}
|
|
73
|
+
else if (bottomDistance >= totalOverlayHeight) {
|
|
74
|
+
return "bottom";
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return autoPositionRef.current;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const Overlay = forwardRef(({ children, overlay, tooltip, show = false, onToggle, position = "auto", trigger = "click", defaultShow = false }, ref) => {
|
|
81
|
+
if (Array.isArray(children)) {
|
|
82
|
+
throw new Error("Overlay can only wrap a single element, either introduce a wrapper or remove all but one trigger element!");
|
|
83
|
+
}
|
|
84
|
+
const positionRef = useRef(null);
|
|
85
|
+
const overlayRef = useRef(null);
|
|
86
|
+
const arrowRef = useRef(null);
|
|
87
|
+
const [arrowPosition, setArrowPosition] = useState({ top: 0, left: 0 });
|
|
88
|
+
const [overlayPosition, setOverlayPosition] = useState({ top: 0, left: 0 });
|
|
89
|
+
const [internalShow, setInternalShow] = useState(defaultShow);
|
|
90
|
+
const internalShowRef = useRef(internalShow);
|
|
91
|
+
const setInternalShowRef = (updatedValue) => {
|
|
92
|
+
internalShowRef.current = updatedValue;
|
|
93
|
+
setInternalShow(updatedValue);
|
|
94
|
+
};
|
|
95
|
+
if (show && show != internalShow) {
|
|
96
|
+
console.log("show");
|
|
97
|
+
setInternalShowRef(show);
|
|
98
|
+
}
|
|
99
|
+
//const positionsList = ["top", "right", "bottom", "left"]
|
|
100
|
+
const [autoPosition, setAutoPosition] = useState(position === "auto" ? "top" : position);
|
|
101
|
+
const autoPositionRef = useRef(autoPosition);
|
|
102
|
+
const setAutoPositionRef = (updatedValue) => {
|
|
103
|
+
autoPositionRef.current = updatedValue;
|
|
104
|
+
setAutoPosition(updatedValue);
|
|
105
|
+
};
|
|
106
|
+
const [isHovering, setIsHovering] = useState(false);
|
|
107
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
108
|
+
const [firstClick, setFirstClick] = useState(true);
|
|
109
|
+
const triggerArray = Array.isArray(trigger) ? trigger : [trigger];
|
|
110
|
+
const positionSetter = (positionRef, overlayRef, arrowRef) => {
|
|
111
|
+
setOverlayPosition(setPosition(positionRef, overlayRef, autoPositionRef.current, arrowRef));
|
|
112
|
+
setArrowPosition(setPosition(positionRef, arrowRef, autoPositionRef.current, arrowRef, true));
|
|
113
|
+
};
|
|
114
|
+
const handleScroll = () => {
|
|
115
|
+
if (internalShowRef.current) {
|
|
116
|
+
positionSetter(positionRef, overlayRef, arrowRef);
|
|
117
|
+
}
|
|
118
|
+
if (internalShowRef.current && position === "auto") {
|
|
119
|
+
let updatedPosition = updateAutoPosition(autoPositionRef, positionRef, overlayRef, arrowRef);
|
|
120
|
+
setAutoPositionRef(updatedPosition);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const resizeHandler = () => {
|
|
124
|
+
if (internalShowRef.current) {
|
|
125
|
+
positionSetter(positionRef, overlayRef, arrowRef);
|
|
126
|
+
}
|
|
127
|
+
if (!internalShowRef.current && position === "auto") ;
|
|
128
|
+
};
|
|
129
|
+
/* Event handler funtions */
|
|
130
|
+
const onClick = (event) => {
|
|
131
|
+
//console.log("click")
|
|
132
|
+
if (isFocused && firstClick) {
|
|
133
|
+
//this is needed in case both "focus" and "click" are triggers, otherwise there's weird behaviour
|
|
134
|
+
setFirstClick(false);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
setInternalShowRef(!internalShow);
|
|
138
|
+
if (onToggle) {
|
|
139
|
+
onToggle(!internalShow);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const onHover = (event) => {
|
|
143
|
+
setInternalShowRef(true);
|
|
144
|
+
if (!isHovering) {
|
|
145
|
+
setIsHovering(true);
|
|
146
|
+
if (onToggle) {
|
|
147
|
+
onToggle(true);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const onFocus = (event) => {
|
|
152
|
+
//console.log("focus")
|
|
153
|
+
setInternalShowRef(true);
|
|
154
|
+
setIsFocused(true);
|
|
155
|
+
if (onToggle) {
|
|
156
|
+
onToggle(true);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const onBlur = (event) => {
|
|
160
|
+
//console.log("blur")
|
|
161
|
+
if (isHovering) {
|
|
162
|
+
setIsHovering(false);
|
|
163
|
+
}
|
|
164
|
+
else if (isFocused) {
|
|
165
|
+
setIsFocused(false);
|
|
166
|
+
setFirstClick(true);
|
|
167
|
+
}
|
|
168
|
+
setInternalShowRef(false);
|
|
169
|
+
if (onToggle) {
|
|
170
|
+
onToggle(false);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
useLayoutEffect(() => {
|
|
174
|
+
if (overlayRef.current && arrowRef.current) {
|
|
175
|
+
positionSetter(positionRef, overlayRef, arrowRef);
|
|
176
|
+
}
|
|
177
|
+
}, []);
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
if (overlayRef.current && arrowRef.current) {
|
|
180
|
+
positionSetter(positionRef, overlayRef, arrowRef);
|
|
181
|
+
}
|
|
182
|
+
//setInternalShowRef(show)
|
|
183
|
+
}, [internalShow, overlayRef, positionRef, autoPosition]);
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
window.addEventListener("scroll", handleScroll, true);
|
|
186
|
+
window.addEventListener("resize", resizeHandler, true);
|
|
187
|
+
return function cleanup() {
|
|
188
|
+
window.removeEventListener("scroll", handleScroll, true);
|
|
189
|
+
window.removeEventListener("resize", resizeHandler, true);
|
|
190
|
+
};
|
|
191
|
+
}, []);
|
|
192
|
+
const checkRefPositionStyle = (positionRef) => {
|
|
193
|
+
let elementComputedPositionStyle = getComputedStyle(positionRef.current)["position"];
|
|
194
|
+
if (elementComputedPositionStyle === "fixed") {
|
|
195
|
+
return "fixed";
|
|
196
|
+
}
|
|
197
|
+
else if (elementComputedPositionStyle === "sticky") {
|
|
198
|
+
return "sticky";
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return "absolute";
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
return (React.createElement(React.Fragment, null,
|
|
205
|
+
cloneElement(children, {
|
|
206
|
+
ref: positionRef,
|
|
207
|
+
onClick: triggerArray.find(trigger => trigger === "click") ? onClick : null,
|
|
208
|
+
onMouseOver: triggerArray.find(trigger => trigger === "hover") ? onHover : null,
|
|
209
|
+
onMouseLeave: triggerArray.find(trigger => trigger === "hover") ? onBlur : null,
|
|
210
|
+
onFocus: triggerArray.find(trigger => trigger === "focus") ? onFocus : null,
|
|
211
|
+
onBlur: triggerArray.find(trigger => trigger === "focus") ? onBlur : null,
|
|
212
|
+
}),
|
|
213
|
+
internalShow ? createPortal(overlay ?
|
|
214
|
+
React.createElement(React.Fragment, null,
|
|
215
|
+
React.createElement("div", { className: "sg-overlay-wrapper", ref: mergeRefs([ref, overlayRef]), style: { position: checkRefPositionStyle(positionRef), top: overlayPosition.top, left: overlayPosition.left } }, overlay),
|
|
216
|
+
React.createElement("div", { ref: arrowRef, "aria-hidden": true, className: `sg-overlay-arrow${autoPosition ? " overlay-position-" + autoPosition : ""}`, style: { position: checkRefPositionStyle(positionRef), top: arrowPosition.top, left: arrowPosition.left, } }))
|
|
217
|
+
:
|
|
218
|
+
tooltip ?
|
|
219
|
+
React.createElement(React.Fragment, null,
|
|
220
|
+
React.createElement("div", { className: "sg-overlay-wrapper sg-tooltip-wrapper", ref: mergeRefs([ref, overlayRef]), style: { position: checkRefPositionStyle(positionRef), top: overlayPosition.top, left: overlayPosition.left } }, tooltip),
|
|
221
|
+
React.createElement("div", { ref: arrowRef, "aria-hidden": true, className: `sg-overlay-arrow sg-tooltip-arrow${autoPosition ? " overlay-position-" + autoPosition : ""}`, style: { position: checkRefPositionStyle(positionRef), top: arrowPosition.top, left: arrowPosition.left, } }))
|
|
222
|
+
:
|
|
223
|
+
null, document.body) : null));
|
|
224
|
+
});
|
|
225
|
+
Overlay.displayName = "Overlay";
|
|
226
|
+
|
|
227
|
+
export { Overlay as default };
|
|
228
|
+
//# sourceMappingURL=Overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Overlay.js","sources":["../../src/Overlay/Overlay.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAMA,MAAM,WAAW,GAAG,CAAC,gBAAoB,EAAE,cAAkB,EAAE,QAAe,EAAE,YAAiB,EAAE,OAAiB,GAAA,KAAK,EAAE,kBAAqC,GAAA,EAAC,GAAG,EAAC,CAAC,EAAE,IAAI,EAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAC,KAAI;AACpM,IAAA,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAsB,CAAA;AAC1D,IAAA,MAAM,cAAc,GAAG,cAAc,CAAC,OAAsB,CAAA;AAC5D,IAAA,MAAM,YAAY,GAAG,YAAY,CAAC,OAAsB,CAAA;IAExD,MAAM,MAAM,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC,GAAG,CAAA;AACrD,IAAA,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,CAAA;IACzC,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC,IAAI,CAAA;AACvD,IAAA,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,CAAA;AAEvC,IAAA,MAAM,aAAa,GAAG,cAAc,CAAC,YAAY,CAAA;AACjD,IAAA,MAAM,YAAY,GAAG,cAAc,CAAC,WAAW,CAAA;AAE/C,IAAA,MAAM,WAAW,GAAG,YAAY,CAAC,YAAY,CAAA;AAC7C,IAAA,MAAM,UAAU,GAAG,YAAY,CAAC,WAAW,CAAA;AAE3C,IAAA,MAAM,iBAAiB,GAAG,OAAO,GAAG,CA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,GAAC,YAAY,GAAG,EAAE,EAAE,EACrF,KAAK,EAAE,EAAC,QAAQ,EAAC,qBAAqB,CAAC,WAAW,CAAC,EAAE,GAAG,EAAC,aAAc,CAAC,GAAG,EAAE,IAAI,EAAC,aAAc,CAAC,IAAI,GAAE,GACrG,CACP;;AAEP,gBAAA,OAAO;AACH,oBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;AACI,wBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,uCAAuC,EAClD,GAAG,EAAE,SAAS,CAAC,CAAC,GAAG,EAAC,UAAU,CAAC,CAAC,EAChC,KAAK,EAAE,EAAE,QAAQ,EAAC,qBAAqB,CAAC,WAAW,CAAC,EAAE,GAAG,EAAC,eAAgB,CAAC,GAAG,EAAE,IAAI,EAAC,eAAgB,CAAC,IAAI,EAAE,EAAA,EAC9G,OAAO,CAAO;AAChB,wBAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACI,GAAG,EAAE,QAAQ,uBACb,SAAS,EAAE,oCAAoC,YAAY,GAAG,oBAAoB,GAAC,YAAY,GAAG,EAAE,EAAE,EACtG,KAAK,EAAE,EAAC,QAAQ,EAAC,qBAAqB,CAAC,WAAW,CAAC,EAAE,GAAG,EAAC,aAAc,CAAC,GAAG,EAAE,IAAI,EAAC,aAAc,CAAC,IAAI,GAAE,GACrG,CACP;;wBAEP,IAAI,EACN,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CACxB,EACN;AACL,CAAC,EAAC;AACF,OAAO,CAAC,WAAW,GAAG,SAAS;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { BaseDivType } from "../utils/BaseTypes";
|
|
3
|
+
export type OverlayType = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
overlay?: React.JSX.Element;
|
|
6
|
+
tooltip?: React.JSX.Element;
|
|
7
|
+
show?: boolean;
|
|
8
|
+
onToggle?: Function;
|
|
9
|
+
position?: string;
|
|
10
|
+
trigger?: string | string[];
|
|
11
|
+
defaultShow?: boolean;
|
|
12
|
+
} & BaseDivType;
|
|
13
|
+
export type PositionObject = {
|
|
14
|
+
top?: number;
|
|
15
|
+
bottom?: number;
|
|
16
|
+
left?: number;
|
|
17
|
+
right?: number;
|
|
18
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import Overlay from "./Overlay";
|
|
2
|
-
export default Overlay
|
|
3
|
-
export type { OverlayType, PositionObject } from "./Overlay.types"
|
|
1
|
+
import Overlay from "./Overlay";
|
|
2
|
+
export default Overlay;
|
|
3
|
+
export type { OverlayType, PositionObject } from "./Overlay.types";
|
package/Overlay/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"stargazer-ui/Overlay","private":false,"module":"./index.js","types":"./index.d.ts","peerDependencies":{"lodash":"^4.17.21","react":">=17.0.0","react-dom":">=17.0.0"}}
|
package/Popout/Popout.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import React, { forwardRef, useState, useRef, useEffect } from 'react';
|
|
4
|
+
import mergeRefs from '../utils/MergeRefs.js';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
export const useEventListener = (eventType: keyof HTMLElementEventMap, callback: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions | undefined, customOptions: {element: HTMLElement}) => {
|
|
8
|
+
const element = customOptions ? customOptions.element : document.body
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if(element) {
|
|
11
|
+
element.addEventListener(eventType, callback, options)
|
|
12
|
+
return function cleanup() {
|
|
13
|
+
element.removeEventListener(eventType, callback, options)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}, [callback, element])
|
|
17
|
+
}
|
|
18
|
+
*/
|
|
19
|
+
const Popout = forwardRef(({ children, initialPosition = { top: 0, left: 0 }, id, resize = false, move = false, className, style, ...restProps }, ref) => {
|
|
20
|
+
const [coordinates, setCoordinates] = useState({ offSetTop: 0, offSetLeft: 0, ...initialPosition });
|
|
21
|
+
const resizeComputed = resize ? "true" : "false";
|
|
22
|
+
const moveComputed = move ? "true" : "false";
|
|
23
|
+
const passedRef = useRef(ref);
|
|
24
|
+
const popupRef = useRef(null);
|
|
25
|
+
const [isMouseDown, setIsMouseDown] = useState(false);
|
|
26
|
+
const isMouseDownRef = useRef(isMouseDown);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
isMouseDownRef.current = isMouseDown;
|
|
29
|
+
}, [isMouseDown]);
|
|
30
|
+
const onMouseDown = (event) => {
|
|
31
|
+
const eventTarget = event.target;
|
|
32
|
+
if (move && eventTarget.className.includes("sg-popout-title") || eventTarget.className.includes("sg-popout-header")) {
|
|
33
|
+
const { top, left } = popupRef.current.getBoundingClientRect();
|
|
34
|
+
setCoordinates(prev => ({
|
|
35
|
+
...prev,
|
|
36
|
+
offSetTop: event.clientY - top,
|
|
37
|
+
offSetLeft: event.clientX - left
|
|
38
|
+
}));
|
|
39
|
+
popupRef.current.style.setProperty("user-select", "none");
|
|
40
|
+
popupRef.current.setPointerCapture(event.pointerId); //event.pointerId)//"moveable-popup-"+id);
|
|
41
|
+
setIsMouseDown(true);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const onMouseUp = () => {
|
|
45
|
+
if (move) {
|
|
46
|
+
popupRef.current.style.removeProperty("user-select");
|
|
47
|
+
setIsMouseDown(false);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const onMouseMove = (event) => {
|
|
51
|
+
if (move && isMouseDownRef.current && popupRef.current) {
|
|
52
|
+
const isTopOver = event.clientY - coordinates.offSetTop < 0;
|
|
53
|
+
const isBottomOver = window.innerHeight - (event.clientY - coordinates.offSetTop + popupRef.current.offsetHeight) < 0;
|
|
54
|
+
const isLeftOver = event.clientX - coordinates.offSetLeft < 0;
|
|
55
|
+
const isRightOver = window.innerWidth - (event.clientX - coordinates.offSetLeft + popupRef.current.offsetWidth) < 0;
|
|
56
|
+
let topCoordinate = isTopOver ? 0 : event.clientY - coordinates.offSetTop;
|
|
57
|
+
topCoordinate = isBottomOver ? window.innerHeight - popupRef.current.offsetHeight : topCoordinate;
|
|
58
|
+
let leftCoordinate = isLeftOver ? 0 : event.clientX - coordinates.offSetLeft;
|
|
59
|
+
leftCoordinate = isRightOver ? window.innerWidth - popupRef.current.offsetWidth : leftCoordinate;
|
|
60
|
+
//console.log(event.clientX - coordinates.offSetLeft, event.clientY - coordinates.offSetTop)
|
|
61
|
+
setCoordinates(prev => ({
|
|
62
|
+
...prev,
|
|
63
|
+
top: topCoordinate,
|
|
64
|
+
left: leftCoordinate
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
document.body.addEventListener("pointerup", () => onMouseUp(), true);
|
|
70
|
+
return function cleanup() {
|
|
71
|
+
document.body.removeEventListener("pointerup", () => onMouseUp(), true);
|
|
72
|
+
};
|
|
73
|
+
}, []);
|
|
74
|
+
return (createPortal(React.createElement("dialog", { "data-resize": resizeComputed, "data-move": moveComputed, "data-passedref": passedRef, ref: mergeRefs([ref, popupRef]), id: id, className: `sg-moveable-popout${className ? " " + className : ""}`, style: { ...style, top: coordinates.top, left: coordinates.left, bottom: coordinates.bottom, right: coordinates.right }, onPointerDown: onMouseDown, onPointerMove: (event) => onMouseMove(event), ...restProps }, children), document.body));
|
|
75
|
+
});
|
|
76
|
+
Popout.displayName = "Popout";
|
|
77
|
+
const Header = forwardRef(({ children, className, as = "div", ...restProps }, ref) => {
|
|
78
|
+
let validAs = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"];
|
|
79
|
+
let Component = validAs.find(valid => valid === as) ? as : "div";
|
|
80
|
+
return (React.createElement(Component, { ref: ref, className: `sg-popout-header ${className}`, ...restProps }, children));
|
|
81
|
+
});
|
|
82
|
+
Header.displayName = "PopoutHeader";
|
|
83
|
+
const Title = forwardRef(({ as = "h4", className, children, ...restProps }, ref) => {
|
|
84
|
+
let validAs = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
85
|
+
let Component = validAs.find(valid => valid === as) ? as : "h5";
|
|
86
|
+
return (React.createElement(Component, { ref: ref, className: `sg-popout-title ${className}`, ...restProps }, children));
|
|
87
|
+
});
|
|
88
|
+
Title.displayName = "PopoutTitle";
|
|
89
|
+
const Body = forwardRef(({ children, className, ...restProps }, ref) => {
|
|
90
|
+
return (React.createElement("div", { ref: ref, className: `sg-popout-body ${className}`, ...restProps }, children));
|
|
91
|
+
});
|
|
92
|
+
Body.displayName = "PopoutBody";
|
|
93
|
+
const Text = forwardRef(({ children, className, ...restProps }, ref) => {
|
|
94
|
+
return (React.createElement("p", { ref: ref, className: `sg-popout-text ${className}`, ...restProps }, children));
|
|
95
|
+
});
|
|
96
|
+
Text.displayName = "PopoutText";
|
|
97
|
+
const Footer = forwardRef(({ children, className, ...restProps }, ref) => {
|
|
98
|
+
return (React.createElement("div", { ref: ref, className: `sg-popout-footer ${className}`, ...restProps }, children));
|
|
99
|
+
});
|
|
100
|
+
Footer.displayName = "PopoutFooter";
|
|
101
|
+
var Popout$1 = Object.assign(Popout, {
|
|
102
|
+
Header: Header,
|
|
103
|
+
Title: Title,
|
|
104
|
+
Body: Body,
|
|
105
|
+
Text: Text,
|
|
106
|
+
Footer: Footer
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export { Popout$1 as default };
|
|
110
|
+
//# sourceMappingURL=Popout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popout.js","sources":["../../src/Popout/Popout.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAMA;;;;;;;;;;;;AAYE;AAEF,MAAM,MAAM,GAA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,SAAS,EAAE,CAAoB,iBAAA,EAAA,SAAS,EAAE,EAAM,GAAA,SAAS,IACnE,QAAQ,CACP,EACT;AACL,CAAC,CAAC,CAAA;AACF,MAAM,CAAC,WAAW,GAAG,cAAc,CAAA;AAEnC,eAAgB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;AAClC,IAAA,MAAM,EAAE,MAAM;AACd,IAAA,KAAK,EAAE,KAAK;AACZ,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,MAAM,EAAE,MAAM;AACjB,CAAA,CAAC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import { BaseDialogType, BaseDivType, BaseHeadingType, BaseParagraphType, BaseSpanType } from "
|
|
2
|
+
import { BaseDialogType, BaseDivType, BaseHeadingType, BaseParagraphType, BaseSpanType } from "../utils/BaseTypes";
|
|
3
3
|
export type PopoutType = {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
initialPosition?: {
|
package/Popout/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"stargazer-ui/Popout","private":false,"module":"./index.js","types":"./index.d.ts","peerDependencies":{"lodash":"^4.17.21","react":">=17.0.0","react-dom":">=17.0.0"}}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
const Spinner = forwardRef(({ size = "1em", color = "white", label, className, controlId, ...restProps }, ref) => {
|
|
5
|
+
return (React.createElement(React.Fragment, null,
|
|
6
|
+
React.createElement("div", { "aria-labelledby": controlId, role: "status", ref: ref, className: `sg-spinner${className ? " " + className : ""}`, style: { width: size, height: size, borderColor: color }, ...restProps }),
|
|
7
|
+
React.createElement("label", { id: controlId, className: "sg-visually-hidden" }, label)));
|
|
8
|
+
});
|
|
9
|
+
Spinner.displayName = "Spinner";
|
|
10
|
+
|
|
11
|
+
export { Spinner as default };
|
|
12
|
+
//# sourceMappingURL=Spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spinner.js","sources":["../../src/Spinner/Spinner.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;AAIM,MAAA,OAAO,GAAG,UAAU,CAA+B,CAAC,EAAC,IAAI,GAAC,KAAK,EAAE,KAAK,GAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,SAAS,EAAC,EAAE,GAAG,KAAI;AACrI,IAAA,QACI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;AACI,QAAA,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,iBAAA,EAAsB,SAAS,EAAE,IAAI,EAAC,QAAQ,EAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,aAAa,SAAS,GAAG,GAAG,GAAC,SAAS,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,EAAC,KAAK,EAAC,IAAI,EAAE,MAAM,EAAC,IAAI,EAAE,WAAW,EAAC,KAAK,EAAC,EAAA,GAAM,SAAS,EAAQ,CAAA;AAC7L,QAAA,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAO,EAAE,EAAE,SAAS,EAAE,SAAS,EAAC,oBAAoB,EAAA,EAAE,KAAK,CAAS,CACrE,EACN;AACL,CAAC,EAAC;AACF,OAAO,CAAC,WAAW,GAAG,SAAS;;;;"}
|
package/Spinner/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"stargazer-ui/Spinner","private":false,"module":"./index.js","types":"./index.d.ts","peerDependencies":{"lodash":"^4.17.21","react":">=17.0.0","react-dom":">=17.0.0"}}
|
package/Table/Table.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
const Table = forwardRef(({ children, size = "lg", className, ...restProps }, ref) => {
|
|
5
|
+
let classesComputed = `sg-table${className ? " " + className : ""}${size === "sm" ? " " + "sg-table-sm" : ""}`;
|
|
6
|
+
return (React.createElement("table", { ref: ref, className: classesComputed, ...restProps }, children));
|
|
7
|
+
});
|
|
8
|
+
Table.displayName = "Table";
|
|
9
|
+
|
|
10
|
+
export { Table as default };
|
|
11
|
+
//# sourceMappingURL=Table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.js","sources":["../../src/Table/Table.tsx"],"sourcesContent":[null],"names":[],"mappings":";;;AAKM,MAAA,KAAK,GAAG,UAAU,CAA+B,CAAC,EAAC,QAAQ,EAAE,IAAI,GAAC,IAAI,EAAE,SAAS,EAAE,GAAG,SAAS,EAAC,EAAE,GAAG,KAAI;AAC3G,IAAA,IAAI,eAAe,GAAG,CAAW,QAAA,EAAA,SAAS,GAAG,GAAG,GAAC,SAAS,GAAC,EAAE,CAAG,EAAA,IAAI,KAAK,IAAI,GAAG,GAAG,GAAC,aAAa,GAAC,EAAE,EAAE,CAAA;AACtG,IAAA,QACI,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAO,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,eAAe,KAAM,SAAS,EAAA,EACrD,QAAQ,CACL,EACX;AACL,CAAC,EAAC;AACF,KAAK,CAAC,WAAW,GAAG,OAAO;;;;"}
|
package/Table/index.d.ts
ADDED