stargazer-ui 1.5.13 → 1.5.14
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 +15 -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 +11 -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/{types/components/Card → Card}/Card.d.ts +12 -12
- package/Card/Card.js +42 -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.d.ts +135 -0
- package/Dropdown/Dropdown.js +377 -0
- package/Dropdown/Dropdown.js.map +1 -0
- package/{types/components/Dropdown → Dropdown}/Dropdown.types.d.ts +12 -11
- package/Dropdown/DropdownOld.d.ts +135 -0
- 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 +20 -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 +15 -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 +227 -0
- package/Form/Form.js.map +1 -0
- package/Form/Form.types.d.ts +159 -0
- package/Form/FormSelect.d.ts +14 -0
- package/Form/FormSelect.js +436 -0
- package/Form/FormSelect.js.map +1 -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 +17 -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 +77 -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 +19 -19
- package/Modal/Modal.js +157 -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/{types/components/Nav → Nav}/Nav.d.ts +12 -12
- package/Nav/Nav.js +29 -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 +7 -8
- 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/NavDropdown/NavDropdown.d.ts +99 -0
- package/NavDropdown/NavDropdown.js +75 -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 +242 -0
- package/Overlay/Overlay.js.map +1 -0
- package/Overlay/Overlay.types.d.ts +22 -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/{types/components/Popout → Popout}/Popout.d.ts +6 -6
- package/Popout/Popout.js +111 -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 +11 -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 +12 -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 +162 -0
- package/Tabs/Tabs.js.map +1 -0
- package/{types/components/Tabs → Tabs}/Tabs.types.d.ts +12 -2
- 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 +18 -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} +6 -7
- package/hooks/index.js +7 -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/useQueryParams.d.ts +2 -0
- package/hooks/useQueryParams.js +13 -0
- package/hooks/useQueryParams.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/styles/stargazerui.css +6552 -0
- package/styles/stargazerui.css.map +1 -0
- package/{src/utils/BaseTypes.ts → utils/BaseTypes.d.ts} +25 -32
- package/utils/ContrastingColor.d.ts +1 -0
- package/utils/CreateSyntheticEvent.d.ts +2 -0
- package/utils/CreateSyntheticEvent.js +33 -0
- package/utils/CreateSyntheticEvent.js.map +1 -0
- package/utils/IsInputKey.d.ts +7 -0
- package/utils/IsInputKey.js +20 -0
- package/utils/IsInputKey.js.map +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 +1 -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 -46
- package/dev/index.scss +0 -74
- package/dev/pages/ButtonPage.jsx +0 -44
- package/dev/pages/CardPage.jsx +0 -81
- package/dev/pages/DropdownPage.jsx +0 -32
- package/dev/pages/FormPage.jsx +0 -155
- package/dev/pages/ListPage.jsx +0 -52
- package/dev/pages/ModalPage.jsx +0 -38
- package/dev/pages/OverlayPage.jsx +0 -39
- package/dev/pages/components.jsx +0 -19
- package/dev/stargazerui.css +0 -3762
- package/dev/stargazerui.css.map +0 -1
- package/dev/test.jsx +0 -87
- 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 -20
- 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 -440
- package/src/Dropdown/Dropdown.types.ts +0 -60
- package/src/Dropdown/DropdownOld.tsx +0 -409
- 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 -398
- package/src/Form/Form.types.ts +0 -169
- package/src/Form/FormSelect.tsx +0 -527
- package/src/Form/index.ts +0 -4
- package/src/InputGroup/InputGroup.tsx +0 -46
- package/src/InputGroup/InputGroup.types.ts +0 -22
- 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 -229
- 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 -309
- package/src/Overlay/Overlay.types.ts +0 -24
- 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 -233
- package/src/Tabs/Tabs.types.ts +0 -52
- 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/assets/tooltip-pointer.svg +0 -3
- package/src/assets/warning.svg +0 -39
- package/src/hooks/useClassname.ts +0 -5
- package/src/hooks/useDraggable.ts +0 -186
- package/src/hooks/useKeepElementFocused.ts +0 -37
- package/src/hooks/useQueryParams.ts +0 -12
- 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 -134
- package/src/styles/_Dropdown.scss +0 -127
- 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 -33
- package/src/styles/_OffCanvas.scss +0 -260
- package/src/styles/_OverLay.scss +0 -64
- 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 -237
- package/src/styles/_utilities.scss +0 -2480
- package/src/styles/_variables.scss +0 -164
- package/src/styles/forms/_FormCheck.scss +0 -270
- package/src/styles/forms/_FormControl.scss +0 -135
- package/src/styles/forms/_FormGroup.scss +0 -26
- package/src/styles/forms/_FormLabel.scss +0 -3
- package/src/styles/forms/_FormSelect.scss +0 -196
- 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/CreateSyntheticEvent.ts +0 -30
- package/src/utils/FileImportExport.js +0 -50
- package/src/utils/IsInputKey.ts +0 -18
- 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/Dropdown.d.ts +0 -71
- 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/NavDropdown.d.ts +0 -35
- 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/CloseButton → CloseButton}/CloseButton.d.ts +0 -0
- /package/{types/components/FloatingLabel → FloatingLabel}/FloatingLabel.d.ts +0 -0
- /package/{types/components/NavDropdown → NavDropdown}/NavDropdown.types.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,99 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const _default: React.ForwardRefExoticComponent<(Omit<{
|
|
3
|
+
toggleProps?: any;
|
|
4
|
+
menuProps?: any;
|
|
5
|
+
} & {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
navDropdown?: boolean;
|
|
9
|
+
onSelect?: Function;
|
|
10
|
+
onToggle?: Function;
|
|
11
|
+
controlId: string;
|
|
12
|
+
drop?: string;
|
|
13
|
+
align?: string;
|
|
14
|
+
autoClose?: boolean;
|
|
15
|
+
show?: boolean;
|
|
16
|
+
label: string;
|
|
17
|
+
as?: React.ElementType;
|
|
18
|
+
variant?: string;
|
|
19
|
+
menuRef?: any;
|
|
20
|
+
menuProps: import("..").DropdownMenuType;
|
|
21
|
+
} & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
|
|
22
|
+
toggleProps?: any;
|
|
23
|
+
menuProps?: any;
|
|
24
|
+
} & {
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
className?: string;
|
|
27
|
+
navDropdown?: boolean;
|
|
28
|
+
onSelect?: Function;
|
|
29
|
+
onToggle?: Function;
|
|
30
|
+
controlId: string;
|
|
31
|
+
drop?: string;
|
|
32
|
+
align?: string;
|
|
33
|
+
autoClose?: boolean;
|
|
34
|
+
show?: boolean;
|
|
35
|
+
label: string;
|
|
36
|
+
as?: React.ElementType;
|
|
37
|
+
variant?: string;
|
|
38
|
+
menuRef?: any;
|
|
39
|
+
menuProps: import("..").DropdownMenuType;
|
|
40
|
+
} & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement>, "ref"> | Omit<{
|
|
41
|
+
toggleProps?: any;
|
|
42
|
+
menuProps?: any;
|
|
43
|
+
} & {
|
|
44
|
+
children: React.ReactNode;
|
|
45
|
+
className?: string;
|
|
46
|
+
navDropdown?: boolean;
|
|
47
|
+
onSelect?: Function;
|
|
48
|
+
onToggle?: Function;
|
|
49
|
+
controlId: string;
|
|
50
|
+
drop?: string;
|
|
51
|
+
align?: string;
|
|
52
|
+
autoClose?: boolean;
|
|
53
|
+
show?: boolean;
|
|
54
|
+
label: string;
|
|
55
|
+
as?: React.ElementType;
|
|
56
|
+
variant?: string;
|
|
57
|
+
menuRef?: any;
|
|
58
|
+
menuProps: import("..").DropdownMenuType;
|
|
59
|
+
} & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>, "ref">) & React.RefAttributes<HTMLDivElement>> & {
|
|
60
|
+
Toggle: React.ForwardRefExoticComponent<(Omit<{
|
|
61
|
+
children: React.ReactNode;
|
|
62
|
+
className?: string;
|
|
63
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
64
|
+
navDropdown?: boolean;
|
|
65
|
+
as?: React.ElementType;
|
|
66
|
+
variant?: string;
|
|
67
|
+
label: string;
|
|
68
|
+
} & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
|
|
69
|
+
children: React.ReactNode;
|
|
70
|
+
className?: string;
|
|
71
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
72
|
+
navDropdown?: boolean;
|
|
73
|
+
as?: React.ElementType;
|
|
74
|
+
variant?: string;
|
|
75
|
+
label: string;
|
|
76
|
+
} & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement>, "ref"> | Omit<{
|
|
77
|
+
children: React.ReactNode;
|
|
78
|
+
className?: string;
|
|
79
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
80
|
+
navDropdown?: boolean;
|
|
81
|
+
as?: React.ElementType;
|
|
82
|
+
variant?: string;
|
|
83
|
+
label: string;
|
|
84
|
+
} & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>, "ref">) & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
85
|
+
Menu: React.ForwardRefExoticComponent<Omit<import("..").DropdownMenuType, "ref"> & React.RefAttributes<HTMLUListElement>>;
|
|
86
|
+
Item: React.ForwardRefExoticComponent<(Omit<{
|
|
87
|
+
children: React.ReactNode;
|
|
88
|
+
as?: React.ElementType;
|
|
89
|
+
className?: string;
|
|
90
|
+
liProps: import("..").BaseLItemType;
|
|
91
|
+
} & React.ClassAttributes<HTMLAnchorElement> & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
|
|
92
|
+
children: React.ReactNode;
|
|
93
|
+
as?: React.ElementType;
|
|
94
|
+
className?: string;
|
|
95
|
+
liProps: import("..").BaseLItemType;
|
|
96
|
+
} & React.ClassAttributes<HTMLButtonElement> & React.ButtonHTMLAttributes<HTMLButtonElement>, "ref">) & React.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>;
|
|
97
|
+
Divider: React.ForwardRefExoticComponent<Omit<import("..").DropdownDividerType, "ref"> & React.RefAttributes<HTMLHRElement>>;
|
|
98
|
+
};
|
|
99
|
+
export default _default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useState, useCallback, useMemo } from 'react';
|
|
4
|
+
import Dropdown, { DropdownContextProvider } from '../Dropdown/Dropdown.js';
|
|
5
|
+
|
|
6
|
+
const getDropdownMenuPlacement = (alignEnd, dropDirection, isRTL = false) => {
|
|
7
|
+
const topStart = isRTL ? 'top-end' : 'top-start';
|
|
8
|
+
const topEnd = isRTL ? 'top-start' : 'top-end';
|
|
9
|
+
const bottomStart = isRTL ? 'bottom-end' : 'bottom-start';
|
|
10
|
+
const bottomEnd = isRTL ? 'bottom-start' : 'bottom-end';
|
|
11
|
+
const leftStart = isRTL ? 'right-start' : 'left-start';
|
|
12
|
+
const leftEnd = isRTL ? 'right-end' : 'left-end';
|
|
13
|
+
const rightStart = isRTL ? 'left-start' : 'right-start';
|
|
14
|
+
const rightEnd = isRTL ? 'left-end' : 'right-end';
|
|
15
|
+
let placement = alignEnd ? bottomEnd : bottomStart;
|
|
16
|
+
if (dropDirection === 'up') {
|
|
17
|
+
placement = alignEnd ? topEnd : topStart;
|
|
18
|
+
}
|
|
19
|
+
else if (dropDirection === 'end') {
|
|
20
|
+
placement = alignEnd ? rightEnd : rightStart;
|
|
21
|
+
}
|
|
22
|
+
else if (dropDirection === 'start') {
|
|
23
|
+
placement = alignEnd ? leftEnd : leftStart;
|
|
24
|
+
}
|
|
25
|
+
else if (dropDirection === 'down-centered') {
|
|
26
|
+
placement = 'bottom';
|
|
27
|
+
}
|
|
28
|
+
else if (dropDirection === 'up-centered') {
|
|
29
|
+
placement = 'top';
|
|
30
|
+
}
|
|
31
|
+
return placement;
|
|
32
|
+
};
|
|
33
|
+
const NavDropdown = forwardRef(({ children, className, onSelect, onToggle, controlId, toggleProps, title, menuProps, drop = "down", align = "start", autoClose = true, show = "default", ...restProps }, ref) => {
|
|
34
|
+
const [showInternal, setShowInternal] = useState(show === "default" ? false : show);
|
|
35
|
+
// this is an object like {index: string} because we need it to rerender even if the case is the same
|
|
36
|
+
// aka we use a "next/previous" case to navigate through the dropdown menu so need to rerender consecutive "next" cases
|
|
37
|
+
const [activeDescendant, setActiveDescendant] = useState({ case: "" });
|
|
38
|
+
const internalOnToggle = useCallback((event) => {
|
|
39
|
+
event.stopPropagation();
|
|
40
|
+
setShowInternal(prev => !prev);
|
|
41
|
+
}, []);
|
|
42
|
+
const alignEnd = align === "end";
|
|
43
|
+
const placement = getDropdownMenuPlacement(alignEnd, drop);
|
|
44
|
+
const controlIdcomputed = controlId;
|
|
45
|
+
const contextValue = useMemo(() => ({
|
|
46
|
+
align,
|
|
47
|
+
drop,
|
|
48
|
+
showInternal: show != "default" && onToggle ? show : showInternal,
|
|
49
|
+
handleToggle: show != "default" && onToggle ? onToggle : internalOnToggle,
|
|
50
|
+
placement,
|
|
51
|
+
directionClasses: {
|
|
52
|
+
down: "dropdown",
|
|
53
|
+
'down-centered': `dropdown-center`,
|
|
54
|
+
up: 'dropup',
|
|
55
|
+
'up-centered': 'dropup-center dropup',
|
|
56
|
+
end: 'dropend',
|
|
57
|
+
start: 'dropstart'
|
|
58
|
+
},
|
|
59
|
+
controlId: controlIdcomputed,
|
|
60
|
+
activeDescendant,
|
|
61
|
+
setActiveDescendant,
|
|
62
|
+
navDropdown: false
|
|
63
|
+
}), [align, drop, show, showInternal, onToggle, internalOnToggle, placement, controlId, activeDescendant, setActiveDescendant]);
|
|
64
|
+
return (jsx("div", { ref: ref, id: controlId + "-wrapper", className: `sg-dropdown${className ? " " + className : ""} sg-nav-item`, ...restProps, children: jsxs(DropdownContextProvider, { value: contextValue, children: [jsx(Dropdown.Toggle, { navDropdown: true, ...toggleProps, children: title }), jsx(Dropdown.Menu, { ...menuProps, children: children })] }) }));
|
|
65
|
+
});
|
|
66
|
+
NavDropdown.displayName = "NavDropdown";
|
|
67
|
+
var NavDropdown$1 = Object.assign(NavDropdown, {
|
|
68
|
+
Toggle: Dropdown.Toggle,
|
|
69
|
+
Menu: Dropdown.Menu,
|
|
70
|
+
Item: Dropdown.Item,
|
|
71
|
+
Divider: Dropdown.Divider
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export { NavDropdown$1 as default };
|
|
75
|
+
//# sourceMappingURL=NavDropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavDropdown.js","sources":["../../src/NavDropdown/NavDropdown.tsx"],"sourcesContent":[null],"names":["_jsx","_j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AAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;AAE/H,IAAA,QACIA,GAAA,CAAA,KAAA,EAAA,EAAK,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS,GAAC,UAAU,EAAE,SAAS,EAAE,CAAc,WAAA,EAAA,SAAS,GAAE,GAAG,GAAC,SAAS,GAAC,EAAE,CAAc,YAAA,CAAA,EAAA,GAAM,SAAS,EACtH,QAAA,EAAAC,IAAA,CAAC,uBAAuB,EAAA,EAAC,KAAK,EAAE,YAAY,EAAA,QAAA,EAAA,CACxCD,GAAC,CAAA,QAAQ,CAAC,MAAM,EAAC,EAAA,WAAW,EAAE,IAAI,KAAM,WAAW,EAAA,QAAA,EAC9C,KAAK,EAAA,CACQ,EAClBA,GAAA,CAAC,QAAQ,CAAC,IAAI,EAAA,EAAA,GAAK,SAAS,EAAA,QAAA,EACvB,QAAQ,EAAA,CACG,CACM,EAAA,CAAA,EAAA,CACxB;AAEd,CAAC,CAAC;AACF,WAAW,CAAC,WAAW,GAAG,aAAa;AAEvC,oBAAgB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;IACvC,MAAM,EAAE,QAAQ,CAAC,MAAM;IACvB,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,OAAO,EAAE,QAAQ,CAAC;AACrB,CAAA,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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,242 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef, useRef, useState, useLayoutEffect, useEffect, cloneElement } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import mergeRefs from '../utils/MergeRefs.js';
|
|
6
|
+
import mergeClassnames from '../utils/MergeClassnames.js';
|
|
7
|
+
|
|
8
|
+
const setPosition = (referenceElement, overlayElement, position, arrowElement, isArrow = false, boundaryCorrection = { top: 0, left: 0, bottom: 0, right: 0 }) => {
|
|
9
|
+
if (!overlayElement.current)
|
|
10
|
+
return { top: 0, left: 0 };
|
|
11
|
+
const refCurrent = referenceElement.current;
|
|
12
|
+
const overlayCurrent = overlayElement.current;
|
|
13
|
+
const arrowCurrent = arrowElement.current;
|
|
14
|
+
const refTop = refCurrent.getBoundingClientRect().top;
|
|
15
|
+
const refHeight = refCurrent.offsetHeight;
|
|
16
|
+
const refLeft = refCurrent.getBoundingClientRect().left;
|
|
17
|
+
const refWidth = refCurrent.offsetWidth;
|
|
18
|
+
const overlayHeight = overlayCurrent.getBoundingClientRect().height;
|
|
19
|
+
const overlayWidth = overlayCurrent.getBoundingClientRect().width;
|
|
20
|
+
const arrowHeight = arrowCurrent.getBoundingClientRect().height;
|
|
21
|
+
const arrowWidth = arrowCurrent.getBoundingClientRect().width;
|
|
22
|
+
//console.log(refTop, arrowHeight, arrowWidth)
|
|
23
|
+
const overlayBorderWidth = parseFloat(getComputedStyle(overlayCurrent).borderWidth.split("px")[0]);
|
|
24
|
+
const arrowOffsetHeight = isArrow ? arrowHeight / 2 : arrowHeight - overlayBorderWidth;
|
|
25
|
+
const arrowOffsetWidth = isArrow ? arrowWidth / 2 : arrowWidth - overlayBorderWidth;
|
|
26
|
+
let tempPos;
|
|
27
|
+
switch (position) {
|
|
28
|
+
case "top":
|
|
29
|
+
tempPos = {
|
|
30
|
+
top: refTop - overlayHeight - arrowOffsetHeight,
|
|
31
|
+
left: refLeft + refWidth / 2 - (isArrow ? arrowOffsetWidth / 2 : overlayWidth / 2)
|
|
32
|
+
};
|
|
33
|
+
//tempPos.right = correctPosition("right", 12, 0)
|
|
34
|
+
//tempPos.left = correctPosition("left", 0, 0)
|
|
35
|
+
return tempPos;
|
|
36
|
+
case "right":
|
|
37
|
+
tempPos = {
|
|
38
|
+
top: refTop + refHeight / 2 - overlayHeight / 2,
|
|
39
|
+
left: refLeft + refWidth + arrowOffsetWidth
|
|
40
|
+
};
|
|
41
|
+
//tempPos.bottom = correctPosition("bottom", window.scrollY + window.innerHeight, 0)
|
|
42
|
+
//tempPos.top = correctPosition("top", window.scrollY, 48)
|
|
43
|
+
return tempPos;
|
|
44
|
+
case "bottom":
|
|
45
|
+
tempPos = {
|
|
46
|
+
top: refTop + refHeight + arrowOffsetHeight,
|
|
47
|
+
left: refLeft + refWidth / 2 - overlayWidth / 2
|
|
48
|
+
};
|
|
49
|
+
//tempPos.right = correctPosition("right", 12, 0)
|
|
50
|
+
//tempPos.left = correctPosition("left", 0, 0)
|
|
51
|
+
return tempPos;
|
|
52
|
+
case "left":
|
|
53
|
+
tempPos = {
|
|
54
|
+
top: refTop + refHeight / 2 - overlayHeight / 2,
|
|
55
|
+
left: refLeft - overlayWidth - arrowOffsetWidth
|
|
56
|
+
};
|
|
57
|
+
//tempPos.bottom = correctPosition("bottom", window.scrollY + window.innerHeight, 0)
|
|
58
|
+
//tempPos.top = correctPosition("top", window.scrollY, 48)
|
|
59
|
+
return tempPos;
|
|
60
|
+
default:
|
|
61
|
+
//this is just top
|
|
62
|
+
return { top: refTop - overlayHeight - arrowHeight, left: refLeft + refWidth / 2 - overlayWidth / 2 };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const updateAutoPosition = (autoPositionRef, positionRef, overlayRef, arrowRef) => {
|
|
66
|
+
let topDistance = positionRef.current.getBoundingClientRect().top;
|
|
67
|
+
let bottomDistance = window.innerHeight - positionRef.current.getBoundingClientRect().bottom;
|
|
68
|
+
positionRef.current.getBoundingClientRect().left;
|
|
69
|
+
let rightDistance = window.innerWidth - positionRef.current.getBoundingClientRect().right;
|
|
70
|
+
let totalOverlayWidth = overlayRef.current.clientWidth + arrowRef.current.clientWidth + 48;
|
|
71
|
+
let totalOverlayHeight = overlayRef.current.clientHeight + arrowRef.current.clientHeight + 48;
|
|
72
|
+
//console.log(autoPositionRef.current, positionRef.current, overlayRef.current, arrowRef.current)
|
|
73
|
+
if (topDistance >= totalOverlayHeight) {
|
|
74
|
+
return "top";
|
|
75
|
+
}
|
|
76
|
+
else if (topDistance >= totalOverlayHeight / 2) {
|
|
77
|
+
return rightDistance >= totalOverlayWidth ? "right" : "left";
|
|
78
|
+
}
|
|
79
|
+
else if (bottomDistance >= totalOverlayHeight) {
|
|
80
|
+
return "bottom";
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return autoPositionRef.current;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const Overlay = forwardRef(({ children, overlay, tooltip, show = false, onToggle, position = "auto", trigger = "click", defaultShow = false, tooltipClassname, tooltipStyle, arrowClassname, arrowStyle }, ref) => {
|
|
87
|
+
if (Array.isArray(children)) {
|
|
88
|
+
throw new Error("Overlay can only wrap a single element, either introduce a wrapper or remove all but one trigger element!");
|
|
89
|
+
}
|
|
90
|
+
const positionRef = useRef(null);
|
|
91
|
+
const overlayRef = useRef(null);
|
|
92
|
+
const arrowRef = useRef(null);
|
|
93
|
+
const [arrowPosition, setArrowPosition] = useState({ top: 0, left: 0 });
|
|
94
|
+
const [overlayPosition, setOverlayPosition] = useState({ top: 0, left: 0 });
|
|
95
|
+
const [internalShow, setInternalShow] = useState(defaultShow);
|
|
96
|
+
const internalShowRef = useRef(internalShow);
|
|
97
|
+
const setInternalShowRef = (updatedValue) => {
|
|
98
|
+
internalShowRef.current = updatedValue;
|
|
99
|
+
setInternalShow(updatedValue);
|
|
100
|
+
};
|
|
101
|
+
if (show && show != internalShow) {
|
|
102
|
+
console.log("show");
|
|
103
|
+
setInternalShowRef(show);
|
|
104
|
+
}
|
|
105
|
+
//const positionsList = ["top", "right", "bottom", "left"]
|
|
106
|
+
const [autoPosition, setAutoPosition] = useState(position === "auto" ? "top" : position);
|
|
107
|
+
const autoPositionRef = useRef(autoPosition);
|
|
108
|
+
const setAutoPositionRef = (updatedValue) => {
|
|
109
|
+
autoPositionRef.current = updatedValue;
|
|
110
|
+
setAutoPosition(updatedValue);
|
|
111
|
+
};
|
|
112
|
+
const [isHovering, setIsHovering] = useState(false);
|
|
113
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
114
|
+
const [firstClick, setFirstClick] = useState(true);
|
|
115
|
+
const triggerArray = Array.isArray(trigger) ? trigger : [trigger];
|
|
116
|
+
const positionSetter = (positionRef, overlayRef, arrowRef) => {
|
|
117
|
+
setOverlayPosition(setPosition(positionRef, overlayRef, autoPositionRef.current, arrowRef));
|
|
118
|
+
setArrowPosition(setPosition(positionRef, arrowRef, autoPositionRef.current, arrowRef, true));
|
|
119
|
+
};
|
|
120
|
+
const handleScroll = () => {
|
|
121
|
+
if (internalShowRef.current) {
|
|
122
|
+
positionSetter(positionRef, overlayRef, arrowRef);
|
|
123
|
+
}
|
|
124
|
+
if (internalShowRef.current && position === "auto") {
|
|
125
|
+
let updatedPosition = updateAutoPosition(autoPositionRef, positionRef, overlayRef, arrowRef);
|
|
126
|
+
setAutoPositionRef(updatedPosition);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const resizeHandler = () => {
|
|
130
|
+
if (internalShowRef.current) {
|
|
131
|
+
positionSetter(positionRef, overlayRef, arrowRef);
|
|
132
|
+
}
|
|
133
|
+
if (!internalShowRef.current && position === "auto") ;
|
|
134
|
+
};
|
|
135
|
+
const { onClick, onHover, onFocus, onBlur, onMouseOver, onMouseLeave } = children.props;
|
|
136
|
+
//console.log(children)
|
|
137
|
+
/* Event handler funtions */
|
|
138
|
+
const handleClick = (event) => {
|
|
139
|
+
if (isFocused && firstClick) {
|
|
140
|
+
//this is needed in case both "focus" and "click" are triggers, otherwise there's weird behaviour
|
|
141
|
+
setFirstClick(false);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
setInternalShowRef(!internalShow);
|
|
145
|
+
if (onToggle) {
|
|
146
|
+
onToggle(!internalShow);
|
|
147
|
+
}
|
|
148
|
+
if (onClick) {
|
|
149
|
+
onClick(event);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const handleHover = (event) => {
|
|
153
|
+
setInternalShowRef(true);
|
|
154
|
+
if (!isHovering) {
|
|
155
|
+
setIsHovering(true);
|
|
156
|
+
if (onToggle) {
|
|
157
|
+
onToggle(true);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (onHover) {
|
|
161
|
+
onHover(event);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const handleFocus = (event) => {
|
|
165
|
+
//console.log("focus")
|
|
166
|
+
setInternalShowRef(true);
|
|
167
|
+
setIsFocused(true);
|
|
168
|
+
if (onToggle) {
|
|
169
|
+
onToggle(true);
|
|
170
|
+
}
|
|
171
|
+
if (onFocus) {
|
|
172
|
+
onFocus(event);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const handleBlur = (event) => {
|
|
176
|
+
//console.log("blur")
|
|
177
|
+
if (isHovering) {
|
|
178
|
+
setIsHovering(false);
|
|
179
|
+
}
|
|
180
|
+
else if (isFocused) {
|
|
181
|
+
setIsFocused(false);
|
|
182
|
+
setFirstClick(true);
|
|
183
|
+
}
|
|
184
|
+
setInternalShowRef(false);
|
|
185
|
+
if (onToggle) {
|
|
186
|
+
onToggle(false);
|
|
187
|
+
}
|
|
188
|
+
if (onBlur) {
|
|
189
|
+
onBlur(event);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
useLayoutEffect(() => {
|
|
193
|
+
if (overlayRef.current && arrowRef.current) {
|
|
194
|
+
positionSetter(positionRef, overlayRef, arrowRef);
|
|
195
|
+
}
|
|
196
|
+
}, []);
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
if (overlayRef.current && arrowRef.current) {
|
|
199
|
+
positionSetter(positionRef, overlayRef, arrowRef);
|
|
200
|
+
}
|
|
201
|
+
//setInternalShowRef(show)
|
|
202
|
+
}, [internalShow, overlayRef, positionRef, autoPosition]);
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
window.addEventListener("scroll", handleScroll, true);
|
|
205
|
+
window.addEventListener("resize", resizeHandler, true);
|
|
206
|
+
return function cleanup() {
|
|
207
|
+
window.removeEventListener("scroll", handleScroll, true);
|
|
208
|
+
window.removeEventListener("resize", resizeHandler, true);
|
|
209
|
+
};
|
|
210
|
+
}, []);
|
|
211
|
+
const checkRefPositionStyle = (positionRef) => {
|
|
212
|
+
let elementComputedPositionStyle = getComputedStyle(positionRef.current)["position"];
|
|
213
|
+
if (elementComputedPositionStyle === "fixed") {
|
|
214
|
+
return "fixed";
|
|
215
|
+
}
|
|
216
|
+
else if (elementComputedPositionStyle === "sticky") {
|
|
217
|
+
return "sticky";
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
return "absolute";
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const tooltipClassnames = mergeClassnames("sg-overlay-wrapper", "sg-tooltip-wrapper", tooltipClassname);
|
|
224
|
+
const arrowClassnames = mergeClassnames("sg-overlay-arrow", autoPosition ? " overlay-position-" + autoPosition : "", tooltip ? "sg-tooltip-arrow" : "", arrowClassname);
|
|
225
|
+
return (jsxs(Fragment, { children: [cloneElement(children, {
|
|
226
|
+
ref: mergeRefs([positionRef, children.ref]),
|
|
227
|
+
onClick: triggerArray.find(trigger => trigger === "click") ? handleClick : onClick,
|
|
228
|
+
onMouseOver: triggerArray.find(trigger => trigger === "hover") ? handleHover : onMouseOver,
|
|
229
|
+
onMouseLeave: triggerArray.find(trigger => trigger === "hover") ? handleBlur : onMouseLeave,
|
|
230
|
+
onFocus: triggerArray.find(trigger => trigger === "focus") ? handleFocus : onFocus,
|
|
231
|
+
onBlur: triggerArray.find(trigger => trigger === "focus") ? handleBlur : onBlur,
|
|
232
|
+
}), internalShow ? createPortal(jsxs(Fragment, { children: [overlay ?
|
|
233
|
+
jsxs(Fragment, { children: [jsx("div", { className: "sg-overlay-wrapper", ref: mergeRefs([ref, overlayRef]), style: { position: checkRefPositionStyle(positionRef), top: overlayPosition.top, left: overlayPosition.left }, children: overlay }), jsx("div", { ref: arrowRef, "aria-hidden": true, className: arrowClassnames, style: { ...arrowStyle, position: checkRefPositionStyle(positionRef), top: arrowPosition.top, left: arrowPosition.left, } })] })
|
|
234
|
+
: null, tooltip ?
|
|
235
|
+
jsxs(Fragment, { children: [jsx("div", { className: tooltipClassnames, ref: mergeRefs([ref, overlayRef]), style: { ...tooltipStyle, position: checkRefPositionStyle(positionRef), top: overlayPosition.top, left: overlayPosition.left }, children: tooltip }), jsx("div", { ref: arrowRef, "aria-hidden": true, className: arrowClassnames, style: { ...arrowStyle, position: checkRefPositionStyle(positionRef), top: arrowPosition.top, left: arrowPosition.left, } })] })
|
|
236
|
+
:
|
|
237
|
+
null] }), document.body) : null] }));
|
|
238
|
+
});
|
|
239
|
+
Overlay.displayName = "Overlay";
|
|
240
|
+
|
|
241
|
+
export { Overlay as default };
|
|
242
|
+
//# sourceMappingURL=Overlay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Overlay.js","sources":["../../src/Overlay/Overlay.tsx"],"sourcesContent":[null],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;;AAQA,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;IACpM,IAAG,CAAC,cAAc,CAAC,OAAO;QAAE,OAAO,EAAC,GAAG,EAAC,CAA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AAG,EAAE,SAAS,CAAC,CAAC,GAAG,EAAC,UAAU,CAAC,CAAC,EAChC,KAAK,EAAE,EAAC,GAAG,YAAY,EAAE,QAAQ,EAAC,qBAAqB,CAAC,WAAW,CAAC,EAAE,GAAG,EAAC,eAAgB,CAAC,GAAG,EAAE,IAAI,EAAC,eAAgB,CAAC,IAAI,EAAE,EAAA,QAAA,EAC9H,OAAO,EAAO,CAAA,EAChBA,GACI,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,QAAQ,EAAA,aAAA,EAAA,IAAA,EACb,SAAS,EAAE,eAAe,EAC1B,KAAK,EAAE,EAAC,GAAG,UAAU,EAAE,QAAQ,EAAC,qBAAqB,CAAC,WAAW,CAAC,EAAE,GAAG,EAAC,aAAc,CAAC,GAAG,EAAE,IAAI,EAAC,aAAc,CAAC,IAAI,GAAE,GACpH,CACP,EAAA;;AAEP,4BAAA,IAAI,CACL,EAAA,CAAA,EACL,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CACxB,EAAA,CAAA;AAEX,CAAC;AACD,OAAO,CAAC,WAAW,GAAG,SAAS;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactNode, CSSProperties } 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 | string;
|
|
7
|
+
show?: boolean;
|
|
8
|
+
onToggle?: Function;
|
|
9
|
+
position?: "auto" | "top" | "bottom" | "right" | "left";
|
|
10
|
+
trigger?: string | string[];
|
|
11
|
+
defaultShow?: boolean;
|
|
12
|
+
tooltipClassname?: string;
|
|
13
|
+
tooltipStyle?: CSSProperties;
|
|
14
|
+
arrowClassname?: string;
|
|
15
|
+
arrowStyle?: CSSProperties;
|
|
16
|
+
} & BaseDivType;
|
|
17
|
+
export type PositionObject = {
|
|
18
|
+
top?: number;
|
|
19
|
+
bottom?: number;
|
|
20
|
+
left?: number;
|
|
21
|
+
right?: number;
|
|
22
|
+
};
|
|
@@ -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"}}
|
|
@@ -3,16 +3,16 @@ import { PopoutType, PopoutBodyType, PopoutFooterType, PopoutTextType, PopoutTit
|
|
|
3
3
|
declare const _default: React.ForwardRefExoticComponent<Omit<PopoutType, "ref"> & React.RefAttributes<HTMLDialogElement>> & {
|
|
4
4
|
Header: React.ForwardRefExoticComponent<(Omit<{
|
|
5
5
|
children: React.ReactNode;
|
|
6
|
-
className?: string
|
|
7
|
-
as?: React.ElementType
|
|
6
|
+
className?: string;
|
|
7
|
+
as?: React.ElementType;
|
|
8
8
|
} & React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>, "ref"> | Omit<{
|
|
9
9
|
children: React.ReactNode;
|
|
10
|
-
className?: string
|
|
11
|
-
as?: React.ElementType
|
|
10
|
+
className?: string;
|
|
11
|
+
as?: React.ElementType;
|
|
12
12
|
} & React.ClassAttributes<HTMLHeadingElement> & React.HTMLAttributes<HTMLHeadingElement>, "ref"> | Omit<{
|
|
13
13
|
children: React.ReactNode;
|
|
14
|
-
className?: string
|
|
15
|
-
as?: React.ElementType
|
|
14
|
+
className?: string;
|
|
15
|
+
as?: React.ElementType;
|
|
16
16
|
} & React.ClassAttributes<HTMLSpanElement> & React.HTMLAttributes<HTMLSpanElement>, "ref">) & React.RefAttributes<HTMLDivElement | HTMLHeadingElement | HTMLSpanElement>>;
|
|
17
17
|
Title: React.ForwardRefExoticComponent<Omit<PopoutTitleType, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
18
18
|
Body: React.ForwardRefExoticComponent<Omit<PopoutBodyType, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
package/Popout/Popout.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { forwardRef, useState, useRef, useEffect } from 'react';
|
|
5
|
+
import mergeRefs from '../utils/MergeRefs.js';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
export const useEventListener = (eventType: keyof HTMLElementEventMap, callback: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions | undefined, customOptions: {element: HTMLElement}) => {
|
|
9
|
+
const element = customOptions ? customOptions.element : document.body
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if(element) {
|
|
12
|
+
element.addEventListener(eventType, callback, options)
|
|
13
|
+
return function cleanup() {
|
|
14
|
+
element.removeEventListener(eventType, callback, options)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}, [callback, element])
|
|
18
|
+
}
|
|
19
|
+
*/
|
|
20
|
+
const Popout = forwardRef(({ children, initialPosition = { top: 0, left: 0 }, id, resize = false, move = false, className, style, ...restProps }, ref) => {
|
|
21
|
+
const [coordinates, setCoordinates] = useState({ offSetTop: 0, offSetLeft: 0, ...initialPosition });
|
|
22
|
+
const resizeComputed = resize ? "true" : "false";
|
|
23
|
+
const moveComputed = move ? "true" : "false";
|
|
24
|
+
const passedRef = useRef(ref);
|
|
25
|
+
const popupRef = useRef(null);
|
|
26
|
+
const [isMouseDown, setIsMouseDown] = useState(false);
|
|
27
|
+
const isMouseDownRef = useRef(isMouseDown);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
isMouseDownRef.current = isMouseDown;
|
|
30
|
+
}, [isMouseDown]);
|
|
31
|
+
const onMouseDown = (event) => {
|
|
32
|
+
const eventTarget = event.target;
|
|
33
|
+
if (move && eventTarget.className.includes("sg-popout-title") || eventTarget.className.includes("sg-popout-header")) {
|
|
34
|
+
const { top, left } = popupRef.current.getBoundingClientRect();
|
|
35
|
+
setCoordinates(prev => ({
|
|
36
|
+
...prev,
|
|
37
|
+
offSetTop: event.clientY - top,
|
|
38
|
+
offSetLeft: event.clientX - left
|
|
39
|
+
}));
|
|
40
|
+
popupRef.current.style.setProperty("user-select", "none");
|
|
41
|
+
popupRef.current.setPointerCapture(event.pointerId); //event.pointerId)//"moveable-popup-"+id);
|
|
42
|
+
setIsMouseDown(true);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const onMouseUp = () => {
|
|
46
|
+
if (move) {
|
|
47
|
+
popupRef.current.style.removeProperty("user-select");
|
|
48
|
+
setIsMouseDown(false);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const onMouseMove = (event) => {
|
|
52
|
+
if (move && isMouseDownRef.current && popupRef.current) {
|
|
53
|
+
const isTopOver = event.clientY - coordinates.offSetTop < 0;
|
|
54
|
+
const isBottomOver = window.innerHeight - (event.clientY - coordinates.offSetTop + popupRef.current.offsetHeight) < 0;
|
|
55
|
+
const isLeftOver = event.clientX - coordinates.offSetLeft < 0;
|
|
56
|
+
const isRightOver = window.innerWidth - (event.clientX - coordinates.offSetLeft + popupRef.current.offsetWidth) < 0;
|
|
57
|
+
let topCoordinate = isTopOver ? 0 : event.clientY - coordinates.offSetTop;
|
|
58
|
+
topCoordinate = isBottomOver ? window.innerHeight - popupRef.current.offsetHeight : topCoordinate;
|
|
59
|
+
let leftCoordinate = isLeftOver ? 0 : event.clientX - coordinates.offSetLeft;
|
|
60
|
+
leftCoordinate = isRightOver ? window.innerWidth - popupRef.current.offsetWidth : leftCoordinate;
|
|
61
|
+
//console.log(event.clientX - coordinates.offSetLeft, event.clientY - coordinates.offSetTop)
|
|
62
|
+
setCoordinates(prev => ({
|
|
63
|
+
...prev,
|
|
64
|
+
top: topCoordinate,
|
|
65
|
+
left: leftCoordinate
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
document.body.addEventListener("pointerup", () => onMouseUp(), true);
|
|
71
|
+
return function cleanup() {
|
|
72
|
+
document.body.removeEventListener("pointerup", () => onMouseUp(), true);
|
|
73
|
+
};
|
|
74
|
+
}, []);
|
|
75
|
+
return (createPortal(jsx("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: children }), document.body));
|
|
76
|
+
});
|
|
77
|
+
Popout.displayName = "Popout";
|
|
78
|
+
const Header = forwardRef(({ children, className, as = "div", ...restProps }, ref) => {
|
|
79
|
+
let validAs = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"];
|
|
80
|
+
let Component = validAs.find(valid => valid === as) ? as : "div";
|
|
81
|
+
return (jsx(Component, { ref: ref, className: `sg-popout-header ${className}`, ...restProps, children: children }));
|
|
82
|
+
});
|
|
83
|
+
Header.displayName = "PopoutHeader";
|
|
84
|
+
const Title = forwardRef(({ as = "h4", className, children, ...restProps }, ref) => {
|
|
85
|
+
let validAs = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
86
|
+
let Component = validAs.find(valid => valid === as) ? as : "h5";
|
|
87
|
+
return (jsx(Component, { ref: ref, className: `sg-popout-title ${className}`, ...restProps, children: children }));
|
|
88
|
+
});
|
|
89
|
+
Title.displayName = "PopoutTitle";
|
|
90
|
+
const Body = forwardRef(({ children, className, ...restProps }, ref) => {
|
|
91
|
+
return (jsx("div", { ref: ref, className: `sg-popout-body ${className}`, ...restProps, children: children }));
|
|
92
|
+
});
|
|
93
|
+
Body.displayName = "PopoutBody";
|
|
94
|
+
const Text = forwardRef(({ children, className, ...restProps }, ref) => {
|
|
95
|
+
return (jsx("p", { ref: ref, className: `sg-popout-text ${className}`, ...restProps, children: children }));
|
|
96
|
+
});
|
|
97
|
+
Text.displayName = "PopoutText";
|
|
98
|
+
const Footer = forwardRef(({ children, className, ...restProps }, ref) => {
|
|
99
|
+
return (jsx("div", { ref: ref, className: `sg-popout-footer ${className}`, ...restProps, children: children }));
|
|
100
|
+
});
|
|
101
|
+
Footer.displayName = "PopoutFooter";
|
|
102
|
+
var Popout$1 = Object.assign(Popout, {
|
|
103
|
+
Header: Header,
|
|
104
|
+
Title: Title,
|
|
105
|
+
Body: Body,
|
|
106
|
+
Text: Text,
|
|
107
|
+
Footer: Footer
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export { Popout$1 as default };
|
|
111
|
+
//# sourceMappingURL=Popout.js.map
|