stargazer-ui 1.5.21 → 1.5.23
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/.babelrc.json +10 -0
- package/.eslintrc.cjs +18 -0
- package/.gitattributes +2 -0
- package/LICENSE +21 -0
- package/dev/index.html +16 -0
- package/dev/index.jsx +46 -0
- package/dev/index.scss +74 -0
- package/dev/pages/ButtonPage.jsx +44 -0
- package/dev/pages/CardPage.jsx +81 -0
- package/dev/pages/DropdownPage.jsx +32 -0
- package/dev/pages/FormPage.jsx +163 -0
- package/dev/pages/ListPage.jsx +52 -0
- package/dev/pages/ModalPage.jsx +38 -0
- package/dev/pages/OverlayPage.jsx +39 -0
- package/dev/pages/components.jsx +19 -0
- package/dev/stargazerui.css +3762 -0
- package/dev/stargazerui.css.map +1 -0
- package/dev/test.jsx +87 -0
- package/package.json +79 -1
- package/rollup.config.js +140 -0
- package/scripts/writePackageJsons.js +42 -0
- package/src/Bar/Bar.tsx +0 -0
- package/src/Bar/Bar.type.ts +9 -0
- package/src/Bar/index.ts +0 -0
- package/src/Button/Button.tsx +20 -0
- package/src/Button/Button.types.ts +8 -0
- package/src/Button/index.ts +3 -0
- package/src/ButtonGroup/ButtonGroup.tsx +14 -0
- package/src/ButtonGroup/ButtonGroup.types.ts +8 -0
- package/src/ButtonGroup/index.ts +3 -0
- package/src/Card/Card.tsx +70 -0
- package/src/Card/Card.types.ts +33 -0
- package/src/Card/index.ts +3 -0
- package/src/CloseButton/CloseButton.tsx +14 -0
- package/src/CloseButton/CloseButton.types.ts +6 -0
- package/src/CloseButton/index.ts +3 -0
- package/src/Dropdown/Dropdown.tsx +441 -0
- package/src/Dropdown/Dropdown.types.ts +60 -0
- package/src/Dropdown/index.ts +4 -0
- package/src/FileUploadButton/FileUploadButton.tsx +27 -0
- package/src/FileUploadButton/FileUploadButton.types.ts +9 -0
- package/src/FileUploadButton/index.ts +3 -0
- package/src/FloatingLabel/FloatingLabel.tsx +22 -0
- package/src/FloatingLabel/FloatingLabel.types.ts +11 -0
- package/src/FloatingLabel/index.ts +3 -0
- package/src/Form/Form.tsx +399 -0
- package/src/Form/Form.types.ts +169 -0
- package/src/Form/FormSelect.tsx +620 -0
- package/src/Form/index.ts +4 -0
- package/src/InputGroup/InputGroup.tsx +46 -0
- package/src/InputGroup/InputGroup.types.ts +22 -0
- package/src/InputGroup/index.ts +4 -0
- package/src/List/List.tsx +112 -0
- package/src/List/List.types.ts +34 -0
- package/src/List/index.ts +4 -0
- package/src/Modal/Modal.tsx +229 -0
- package/src/Modal/Modal.types.ts +49 -0
- package/src/Modal/index.ts +4 -0
- package/src/Nav/Nav.tsx +43 -0
- package/src/Nav/Nav.types.ts +21 -0
- package/src/Nav/index.ts +4 -0
- package/src/NavBar/Navbar.tsx +57 -0
- package/src/NavBar/Navbar.types.ts +24 -0
- package/src/NavBar/index.ts +4 -0
- package/src/NavDropdown/NavDropdown.tsx +93 -0
- package/src/NavDropdown/NavDropdown.types.ts +7 -0
- package/src/NavDropdown/index.ts +3 -0
- package/src/Overlay/Overlay.tsx +305 -0
- package/src/Overlay/Overlay.types.ts +24 -0
- package/{Overlay/index.d.ts → src/Overlay/index.ts} +3 -3
- package/src/Popout/Popout.tsx +155 -0
- package/src/Popout/Popout.types.ts +42 -0
- package/src/Popout/index.ts +3 -0
- package/src/Spinner/Spinner.tsx +15 -0
- package/src/Spinner/Spinner.types.ts +7 -0
- package/src/Spinner/index.ts +3 -0
- package/src/Table/Table.tsx +16 -0
- package/src/Table/Table.types.ts +9 -0
- package/src/Table/index.ts +3 -0
- package/src/Tabs/Tabs.tsx +233 -0
- package/src/Tabs/Tabs.types.ts +52 -0
- package/src/Tabs/index.ts +3 -0
- package/src/ToggleButton/ToggleButton.tsx +21 -0
- package/src/ToggleButton/ToggleButton.types.ts +8 -0
- package/src/ToggleButton/index.ts +3 -0
- package/src/assets/tooltip-pointer.svg +3 -0
- package/src/assets/warning.svg +39 -0
- package/{hooks/index.d.ts → src/hooks/index.ts} +7 -6
- package/src/hooks/useClassname.ts +5 -0
- package/src/hooks/useDraggable.ts +186 -0
- package/src/hooks/useKeepElementFocused.ts +37 -0
- package/src/hooks/useQueryParams.ts +12 -0
- package/src/hooks/useScreenSize.ts +24 -0
- package/src/index.ts +21 -0
- package/src/styles/_Card.scss +166 -0
- package/src/styles/_CloseButton.scss +51 -0
- package/src/styles/_CustomButton.scss +134 -0
- package/src/styles/_Dropdown.scss +127 -0
- package/src/styles/_FloatingLabel.scss +56 -0
- package/src/styles/_Forms.scss +7 -0
- package/src/styles/_Grid.scss +178 -0
- package/src/styles/_InputGroup.scss +71 -0
- package/src/styles/_List.scss +62 -0
- package/src/styles/_Modal.scss +234 -0
- package/src/styles/_ModalOld.scss +242 -0
- package/src/styles/_Nav.scss +36 -0
- package/src/styles/_NavBar.scss +116 -0
- package/src/styles/_NavDropdown.scss +33 -0
- package/src/styles/_OffCanvas.scss +260 -0
- package/src/styles/_OverLay.scss +79 -0
- package/src/styles/_Popout.scss +75 -0
- package/src/styles/_Resizable.scss +64 -0
- package/src/styles/_Spinner.scss +19 -0
- package/src/styles/_Table.scss +34 -0
- package/src/styles/_Tabs.scss +129 -0
- package/src/styles/_colors.scss +510 -0
- package/src/styles/_components.scss +41 -0
- package/src/styles/_functions.scss +134 -0
- package/src/styles/_mixins.scss +26 -0
- package/src/styles/_reset.scss +239 -0
- package/src/styles/_utilities.scss +2480 -0
- package/src/styles/_variables.scss +164 -0
- package/src/styles/forms/_FormCheck.scss +270 -0
- package/src/styles/forms/_FormControl.scss +135 -0
- package/src/styles/forms/_FormGroup.scss +26 -0
- package/src/styles/forms/_FormLabel.scss +3 -0
- package/src/styles/forms/_FormSelect.scss +222 -0
- package/src/styles/forms/_FormSlider.scss +116 -0
- package/src/styles/forms/_FormText.scss +6 -0
- package/{utils/BaseTypes.d.ts → src/utils/BaseTypes.ts} +32 -25
- package/src/utils/ContrastingColor.ts +25 -0
- package/src/utils/CreateSyntheticEvent.ts +30 -0
- package/src/utils/FileImportExport.js +50 -0
- package/src/utils/IsInputKey.ts +18 -0
- package/src/utils/MergeClassnames.ts +5 -0
- package/src/utils/MergeRefs.ts +12 -0
- package/src/utils/createFastContext.tsx +119 -0
- package/src/utils/index.ts +4 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig-build.json +4 -0
- package/tsconfig.json +79 -0
- package/tsconfig.node.json +10 -0
- package/types/BaseTypes.d.ts +19 -0
- package/{Button → types/components/Button}/Button.types.d.ts +2 -1
- package/types/components/Button/index.d.ts +1 -0
- package/{Card → types/components/Card}/Card.d.ts +12 -12
- package/{Card → types/components/Card}/Card.types.d.ts +1 -3
- package/types/components/Card/index.d.ts +1 -0
- package/{CloseButton → types/components/CloseButton}/CloseButton.types.d.ts +1 -1
- package/types/components/CloseButton/index.d.ts +1 -0
- package/types/components/Dropdown/Dropdown.d.ts +71 -0
- package/{Dropdown → types/components/Dropdown}/Dropdown.types.d.ts +12 -13
- package/types/components/Dropdown/index.d.ts +1 -0
- package/{FloatingLabel → types/components/FloatingLabel}/FloatingLabel.types.d.ts +1 -1
- package/types/components/FloatingLabel/index.d.ts +1 -0
- package/types/components/Form/Form.d.ts +17 -0
- package/types/components/Form/Form.types.d.ts +50 -0
- package/types/components/Form/index.d.ts +1 -0
- package/types/components/InputGroup/InputGroup.d.ts +6 -0
- package/types/components/InputGroup/InputGroup.types.d.ts +10 -0
- package/types/components/InputGroup/index.d.ts +1 -0
- package/{Modal → types/components/Modal}/Modal.d.ts +19 -19
- package/{Modal → types/components/Modal}/Modal.types.d.ts +2 -3
- package/types/components/Modal/index.d.ts +1 -0
- package/{Nav → types/components/Nav}/Nav.d.ts +12 -12
- package/{Nav → types/components/Nav}/Nav.types.d.ts +1 -1
- package/types/components/Nav/index.d.ts +1 -0
- package/{NavBar → types/components/NavBar}/Navbar.d.ts +8 -7
- package/{NavBar → types/components/NavBar}/Navbar.types.d.ts +1 -2
- package/types/components/NavBar/index.d.ts +1 -0
- package/types/components/NavDropdown/NavDropdown.d.ts +35 -0
- package/{NavDropdown → types/components/NavDropdown}/NavDropdown.types.d.ts +1 -2
- package/types/components/NavDropdown/index.d.ts +1 -0
- package/{Popout → types/components/Popout}/Popout.d.ts +6 -6
- package/{Popout → types/components/Popout}/Popout.types.d.ts +1 -1
- package/types/components/Popout/index.d.ts +1 -0
- package/types/components/Spinner/index.d.ts +1 -0
- package/{Table → types/components/Table}/Table.types.d.ts +1 -1
- package/types/components/Table/index.d.ts +1 -0
- package/{Tabs → types/components/Tabs}/Tabs.types.d.ts +2 -12
- package/types/components/Tabs/index.d.ts +1 -0
- package/types/components/ToggleButton/ToggleButton.d.ts +9 -0
- package/types/components/ToggleButton/ToggleButton.types.d.ts +0 -0
- package/types/components/ToggleButton/index.d.ts +1 -0
- package/types/components/index.d.ts +16 -0
- package/types/index.d.ts +1 -0
- package/vite.config.js +57 -0
- package/vite.config.js.timestamp-1708777378490-e94428ceb2bf9.mjs +42 -0
- package/Bar/Bar.type.d.ts +0 -6
- package/Bar/index.js +0 -2
- package/Bar/index.js.map +0 -1
- package/Bar/package.json +0 -1
- package/Button/Button.js +0 -15
- package/Button/Button.js.map +0 -1
- package/Button/index.d.ts +0 -3
- package/Button/index.js +0 -7
- package/Button/index.js.map +0 -1
- package/Button/package.json +0 -1
- package/ButtonGroup/ButtonGroup.d.ts +0 -4
- package/ButtonGroup/ButtonGroup.js +0 -11
- package/ButtonGroup/ButtonGroup.js.map +0 -1
- package/ButtonGroup/ButtonGroup.types.d.ts +0 -7
- package/ButtonGroup/index.d.ts +0 -3
- package/ButtonGroup/index.js +0 -7
- package/ButtonGroup/index.js.map +0 -1
- package/ButtonGroup/package.json +0 -1
- package/Card/Card.js +0 -42
- package/Card/Card.js.map +0 -1
- package/Card/index.d.ts +0 -3
- package/Card/index.js +0 -7
- package/Card/index.js.map +0 -1
- package/Card/package.json +0 -1
- package/CloseButton/CloseButton.js +0 -11
- package/CloseButton/CloseButton.js.map +0 -1
- package/CloseButton/index.d.ts +0 -3
- package/CloseButton/index.js +0 -7
- package/CloseButton/index.js.map +0 -1
- package/CloseButton/package.json +0 -1
- package/Dropdown/Dropdown.d.ts +0 -39
- package/Dropdown/Dropdown.js +0 -380
- package/Dropdown/Dropdown.js.map +0 -1
- package/Dropdown/index.d.ts +0 -4
- package/Dropdown/index.js +0 -8
- package/Dropdown/index.js.map +0 -1
- package/Dropdown/package.json +0 -1
- package/FileUploadButton/FileUploadButton.d.ts +0 -4
- package/FileUploadButton/FileUploadButton.js +0 -20
- package/FileUploadButton/FileUploadButton.js.map +0 -1
- package/FileUploadButton/FileUploadButton.types.d.ts +0 -7
- package/FileUploadButton/index.d.ts +0 -3
- package/FileUploadButton/index.js +0 -7
- package/FileUploadButton/index.js.map +0 -1
- package/FileUploadButton/package.json +0 -1
- package/FloatingLabel/FloatingLabel.js +0 -15
- package/FloatingLabel/FloatingLabel.js.map +0 -1
- package/FloatingLabel/index.d.ts +0 -3
- package/FloatingLabel/index.js +0 -7
- package/FloatingLabel/index.js.map +0 -1
- package/FloatingLabel/package.json +0 -1
- package/Form/Form.d.ts +0 -37
- package/Form/Form.js +0 -227
- package/Form/Form.js.map +0 -1
- package/Form/Form.types.d.ts +0 -159
- package/Form/FormSelect.d.ts +0 -12
- package/Form/FormSelect.js +0 -492
- package/Form/FormSelect.js.map +0 -1
- package/Form/index.d.ts +0 -4
- package/Form/index.js +0 -8
- package/Form/index.js.map +0 -1
- package/Form/package.json +0 -1
- package/InputGroup/InputGroup.d.ts +0 -7
- package/InputGroup/InputGroup.js +0 -31
- package/InputGroup/InputGroup.js.map +0 -1
- package/InputGroup/InputGroup.types.d.ts +0 -17
- package/InputGroup/index.d.ts +0 -4
- package/InputGroup/index.js +0 -7
- package/InputGroup/index.js.map +0 -1
- package/InputGroup/package.json +0 -1
- package/List/List.d.ts +0 -14
- package/List/List.js +0 -77
- package/List/List.js.map +0 -1
- package/List/List.types.d.ts +0 -28
- package/List/index.d.ts +0 -3
- package/List/index.js +0 -7
- package/List/index.js.map +0 -1
- package/List/package.json +0 -1
- package/Modal/Modal.js +0 -157
- package/Modal/Modal.js.map +0 -1
- package/Modal/index.d.ts +0 -3
- package/Modal/index.js +0 -7
- package/Modal/index.js.map +0 -1
- package/Modal/package.json +0 -1
- package/Nav/Nav.js +0 -29
- package/Nav/Nav.js.map +0 -1
- package/Nav/index.d.ts +0 -4
- package/Nav/index.js +0 -7
- package/Nav/index.js.map +0 -1
- package/Nav/package.json +0 -1
- package/NavBar/Navbar.js +0 -36
- package/NavBar/Navbar.js.map +0 -1
- package/NavBar/index.d.ts +0 -4
- package/NavBar/index.js +0 -8
- package/NavBar/index.js.map +0 -1
- package/NavBar/package.json +0 -1
- package/NavDropdown/NavDropdown.d.ts +0 -19
- package/NavDropdown/NavDropdown.js +0 -75
- package/NavDropdown/NavDropdown.js.map +0 -1
- package/NavDropdown/index.d.ts +0 -3
- package/NavDropdown/index.js +0 -7
- package/NavDropdown/index.js.map +0 -1
- package/NavDropdown/package.json +0 -1
- package/Overlay/Overlay.d.ts +0 -4
- package/Overlay/Overlay.js +0 -241
- package/Overlay/Overlay.js.map +0 -1
- package/Overlay/Overlay.types.d.ts +0 -22
- package/Overlay/index.js +0 -7
- package/Overlay/index.js.map +0 -1
- package/Overlay/package.json +0 -1
- package/Popout/Popout.js +0 -111
- package/Popout/Popout.js.map +0 -1
- package/Popout/index.d.ts +0 -3
- package/Popout/index.js +0 -7
- package/Popout/index.js.map +0 -1
- package/Popout/package.json +0 -1
- package/Spinner/Spinner.js +0 -11
- package/Spinner/Spinner.js.map +0 -1
- package/Spinner/index.d.ts +0 -3
- package/Spinner/index.js +0 -7
- package/Spinner/index.js.map +0 -1
- package/Spinner/package.json +0 -1
- package/Table/Table.js +0 -12
- package/Table/Table.js.map +0 -1
- package/Table/index.d.ts +0 -3
- package/Table/index.js +0 -7
- package/Table/index.js.map +0 -1
- package/Table/package.json +0 -1
- package/Tabs/Tabs.js +0 -162
- package/Tabs/Tabs.js.map +0 -1
- package/Tabs/index.d.ts +0 -3
- package/Tabs/index.js +0 -7
- package/Tabs/index.js.map +0 -1
- package/Tabs/package.json +0 -1
- package/ToggleButton/ToggleButton.d.ts +0 -4
- package/ToggleButton/ToggleButton.js +0 -18
- package/ToggleButton/ToggleButton.js.map +0 -1
- package/ToggleButton/ToggleButton.types.d.ts +0 -7
- package/ToggleButton/index.d.ts +0 -3
- package/ToggleButton/index.js +0 -7
- package/ToggleButton/index.js.map +0 -1
- package/ToggleButton/package.json +0 -1
- package/hooks/index.js +0 -7
- package/hooks/index.js.map +0 -1
- package/hooks/package.json +0 -1
- package/hooks/useClassname.d.ts +0 -2
- package/hooks/useClassname.js +0 -7
- package/hooks/useClassname.js.map +0 -1
- package/hooks/useDraggable.d.ts +0 -23
- package/hooks/useDraggable.js +0 -147
- package/hooks/useDraggable.js.map +0 -1
- package/hooks/useKeepElementFocused.d.ts +0 -2
- package/hooks/useKeepElementFocused.js +0 -37
- package/hooks/useKeepElementFocused.js.map +0 -1
- package/hooks/useQueryParams.d.ts +0 -2
- package/hooks/useQueryParams.js +0 -13
- package/hooks/useQueryParams.js.map +0 -1
- package/hooks/useScreenSize.d.ts +0 -5
- package/hooks/useScreenSize.js +0 -21
- package/hooks/useScreenSize.js.map +0 -1
- package/index.d.ts +0 -19
- package/index.js +0 -20
- package/index.js.map +0 -1
- package/styles/stargazerui.css +0 -6658
- package/styles/stargazerui.css.map +0 -1
- package/utils/ContrastingColor.d.ts +0 -1
- package/utils/CreateSyntheticEvent.d.ts +0 -2
- package/utils/CreateSyntheticEvent.js +0 -33
- package/utils/CreateSyntheticEvent.js.map +0 -1
- package/utils/IsInputKey.d.ts +0 -7
- package/utils/IsInputKey.js +0 -20
- package/utils/IsInputKey.js.map +0 -1
- package/utils/MergeClassnames.d.ts +0 -2
- package/utils/MergeClassnames.js +0 -7
- package/utils/MergeClassnames.js.map +0 -1
- package/utils/MergeRefs.d.ts +0 -1
- package/utils/MergeRefs.js +0 -16
- package/utils/MergeRefs.js.map +0 -1
- package/utils/createFastContext.d.ts +0 -16
- package/utils/createFastContext.js +0 -101
- package/utils/createFastContext.js.map +0 -1
- package/utils/index.d.ts +0 -4
- /package/{Button → types/components/Button}/Button.d.ts +0 -0
- /package/{CloseButton → types/components/CloseButton}/CloseButton.d.ts +0 -0
- /package/{FloatingLabel → types/components/FloatingLabel}/FloatingLabel.d.ts +0 -0
- /package/{Spinner → types/components/Spinner}/Spinner.d.ts +0 -0
- /package/{Spinner → types/components/Spinner}/Spinner.types.d.ts +0 -0
- /package/{Table → types/components/Table}/Table.d.ts +0 -0
- /package/{Tabs → types/components/Tabs}/Tabs.d.ts +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React, { forwardRef, createContext, useContext, useRef, cloneElement, ReactElement, useMemo } from "react"
|
|
2
|
+
|
|
3
|
+
import { ListType, ListSublistType, ListItemType, ListLabelType, FormContextType } from "./List.types"
|
|
4
|
+
import useDraggable, { insertPhantomElement } from "../hooks/useDraggable"
|
|
5
|
+
import useClassname from "../hooks/useClassname"
|
|
6
|
+
import mergeRefs from "../utils/MergeRefs"
|
|
7
|
+
|
|
8
|
+
export const ListContext = createContext<FormContextType | null>(null)
|
|
9
|
+
export const ListContextProvider = ({children, value} : {children: React.ReactNode, value:FormContextType}) => {
|
|
10
|
+
return (
|
|
11
|
+
<ListContext.Provider value={value}>
|
|
12
|
+
{children}
|
|
13
|
+
</ListContext.Provider>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
export const useListContext = () => {
|
|
17
|
+
const context = useContext(ListContext)
|
|
18
|
+
|
|
19
|
+
return context
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
const handlePhantomInsert = (event: React.PointerEvent, item: HTMLElement | null) => {
|
|
24
|
+
event.stopPropagation()
|
|
25
|
+
document.querySelectorAll(".phantom").forEach(phantom => phantom.remove())
|
|
26
|
+
if(item) { insertPhantomElement(item)}
|
|
27
|
+
}
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const List = forwardRef<HTMLUListElement, ListType>( ({children, className, depth, tree=false, dragdrop=false, ...restProps}, ref) => {
|
|
31
|
+
const context = useListContext()
|
|
32
|
+
const initialContext = useMemo(() => ({
|
|
33
|
+
tree: tree,
|
|
34
|
+
draggable: dragdrop
|
|
35
|
+
}), [])
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<ul ref={ref} id="test-list" data-context={context ? "true":"false" } className={useClassname("sg-list", className)} style={{"--depth":depth} as React.CSSProperties} {...restProps}>
|
|
39
|
+
{ !context ?
|
|
40
|
+
<ListContextProvider value={initialContext}>
|
|
41
|
+
{children}
|
|
42
|
+
</ListContextProvider>
|
|
43
|
+
:
|
|
44
|
+
children
|
|
45
|
+
}
|
|
46
|
+
</ul>
|
|
47
|
+
)
|
|
48
|
+
})
|
|
49
|
+
List.displayName = "List"
|
|
50
|
+
|
|
51
|
+
const Sublist = forwardRef<HTMLLIElement, ListSublistType>( ({children, className, depth, ...restProps}, ref) => {
|
|
52
|
+
const { draggable } = useListContext()!
|
|
53
|
+
const itemRef = useRef<HTMLLIElement>(null)
|
|
54
|
+
|
|
55
|
+
const { coordinates, isMouseDown} = useDraggable(itemRef, {draggable})
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<li ref={mergeRefs([ref,itemRef])} data-phantom="none" className={useClassname("sg-sublist", className)} style={{ "--depth":depth, top: coordinates.top, left: coordinates.left, width: coordinates.width } as React.CSSProperties} {...restProps}>
|
|
59
|
+
{children}
|
|
60
|
+
</li>
|
|
61
|
+
)
|
|
62
|
+
})
|
|
63
|
+
Sublist.displayName = "ListSubList"
|
|
64
|
+
|
|
65
|
+
const Item = forwardRef<HTMLLIElement, ListItemType>( ({children, className, ...restProps}, ref) => {
|
|
66
|
+
const { draggable } = useListContext()!
|
|
67
|
+
const itemRef = useRef<HTMLLIElement>(null)
|
|
68
|
+
|
|
69
|
+
const { coordinates, isMouseDown} = useDraggable(itemRef, {draggable})
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<li ref={itemRef} data-phantom="none" className={useClassname("sg-list-item", className)} style={{ top: coordinates.top, left: coordinates.left, width: coordinates.width } as React.CSSProperties} {...restProps} >
|
|
73
|
+
{children}
|
|
74
|
+
</li>
|
|
75
|
+
)
|
|
76
|
+
})
|
|
77
|
+
Item.displayName = "ListItem"
|
|
78
|
+
|
|
79
|
+
const Label = forwardRef<HTMLSpanElement, ListLabelType>( ({children, className, style, ...restProps}, ref) => {
|
|
80
|
+
const labelRef = useRef<HTMLElement>(null)
|
|
81
|
+
const computedClass = useClassname("sg-list-label", className)
|
|
82
|
+
|
|
83
|
+
//const coordinates = useDraggable(labelRef)
|
|
84
|
+
return (
|
|
85
|
+
(typeof children === "string") ?
|
|
86
|
+
<span ref={mergeRefs([ref, labelRef])} className={computedClass} style={{ ...style}} {...restProps}>
|
|
87
|
+
{children}
|
|
88
|
+
</span>
|
|
89
|
+
:
|
|
90
|
+
cloneElement(children as any,
|
|
91
|
+
{
|
|
92
|
+
ref: mergeRefs([ref, labelRef]),
|
|
93
|
+
className: computedClass,
|
|
94
|
+
style: { ...(children as ReactElement).props.style}
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
)
|
|
99
|
+
})
|
|
100
|
+
Label.displayName = "ListLabel"
|
|
101
|
+
/*
|
|
102
|
+
List.Sublist = Sublist
|
|
103
|
+
List.Item = Item
|
|
104
|
+
List.Label = Label
|
|
105
|
+
|
|
106
|
+
export default List
|
|
107
|
+
*/
|
|
108
|
+
export default Object.assign(List, {
|
|
109
|
+
Sublist: Sublist,
|
|
110
|
+
Item: Item,
|
|
111
|
+
Label: Label
|
|
112
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ReactNode } from "react"
|
|
2
|
+
|
|
3
|
+
import { BaseUListType, BaseLItemType, BaseSpanType } from "../utils/BaseTypes"
|
|
4
|
+
|
|
5
|
+
export type FormContextType = {
|
|
6
|
+
depth?: number,
|
|
7
|
+
tree?: boolean,
|
|
8
|
+
draggable?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type ListType = {
|
|
12
|
+
children: ReactNode,
|
|
13
|
+
className: string,
|
|
14
|
+
depth: number,
|
|
15
|
+
tree: boolean,
|
|
16
|
+
dragdrop: boolean
|
|
17
|
+
} & BaseUListType
|
|
18
|
+
|
|
19
|
+
export type ListSublistType = {
|
|
20
|
+
children: ReactNode,
|
|
21
|
+
className: string
|
|
22
|
+
depth: number
|
|
23
|
+
} & BaseLItemType
|
|
24
|
+
|
|
25
|
+
export type ListItemType = {
|
|
26
|
+
children: ReactNode,
|
|
27
|
+
className: string,
|
|
28
|
+
} & BaseLItemType
|
|
29
|
+
|
|
30
|
+
export type ListLabelType = {
|
|
31
|
+
children: ReactNode,
|
|
32
|
+
className: string,
|
|
33
|
+
label: string
|
|
34
|
+
} & BaseSpanType
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import React, { createContext, useContext, useEffect, useState, forwardRef, useRef } from "react"
|
|
2
|
+
import { createPortal } from "react-dom"
|
|
3
|
+
|
|
4
|
+
import { ModalBodyType, ModalContextType, ModalFooterType, ModalHeaderType, ModalTitleType, ModalType, ErrorModalType } from "./Modal.types"
|
|
5
|
+
|
|
6
|
+
import CloseButton from "../CloseButton/CloseButton"
|
|
7
|
+
import Button from "../Button/Button"
|
|
8
|
+
import mergeRefs from "../utils/MergeRefs"
|
|
9
|
+
|
|
10
|
+
const ModalContext = createContext<ModalContextType>(null)
|
|
11
|
+
const ModalContextProvider = ({children, value}:{children:React.ReactNode, value:ModalContextType}) => {
|
|
12
|
+
return (
|
|
13
|
+
<ModalContext.Provider value={value}>
|
|
14
|
+
{children}
|
|
15
|
+
</ModalContext.Provider>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
const useModalContext = () => {
|
|
19
|
+
const context = useContext(ModalContext)
|
|
20
|
+
if(!context) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
"useModalContext has to be used within ModalContextProvider!"
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
return context
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const Modal = forwardRef<HTMLDialogElement, ModalType>( ({ children, size = "md", show, backdrop = "static", fill=false, onHide, className, id, stretch, style, ...restProps
|
|
29
|
+
}, ref) => {
|
|
30
|
+
//Two "show modal" states exist to allow for the modal to not render when not used (meaning you don't have to deal with states
|
|
31
|
+
//for forms or other data that has to be renedered even though the modal is "display: none"). Also allows for an in/out-going animation
|
|
32
|
+
const [showModal, setShowModal] = useState<boolean>(show)
|
|
33
|
+
const [renderModal, setRenderModal] = useState<boolean>(show)
|
|
34
|
+
|
|
35
|
+
let typeCheck : {show: boolean, onHide: boolean} | undefined = typeof(show) === "boolean" && typeof(onHide) === "function" ? undefined : {show: typeof(show) === "boolean", onHide: typeof(onHide) === "function"}
|
|
36
|
+
if(typeCheck) {
|
|
37
|
+
console.error(
|
|
38
|
+
!typeCheck.show ? "The variable 'show' must be used and must be a boolean used to decide when to show the modal!" : null,
|
|
39
|
+
!typeCheck.onHide ? "The variable 'onHide' must be used and must be a function which is used to set 'show' as the modal gets closed!" : null
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if(show != showModal) {
|
|
44
|
+
setShowModal(show)
|
|
45
|
+
if(show) {
|
|
46
|
+
setRenderModal(true)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const modalRef = useRef<HTMLDialogElement>(null)
|
|
51
|
+
useKeepElementFocused(modalRef)
|
|
52
|
+
|
|
53
|
+
const closeModal = () => {
|
|
54
|
+
const modal = modalRef.current!
|
|
55
|
+
modal.classList.add("close")
|
|
56
|
+
modal.addEventListener('animationend', (event) => {
|
|
57
|
+
if(event.animationName === "fade-out-modal") {
|
|
58
|
+
if(onHide) {
|
|
59
|
+
onHide(false)
|
|
60
|
+
}
|
|
61
|
+
modal.close()
|
|
62
|
+
setRenderModal(false)
|
|
63
|
+
}
|
|
64
|
+
}, {once : true});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const modal = modalRef.current
|
|
69
|
+
|
|
70
|
+
if(!modal) return
|
|
71
|
+
|
|
72
|
+
if(showModal) {
|
|
73
|
+
modal.classList.remove('close')
|
|
74
|
+
modal.showModal()
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
closeModal()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
}, [showModal])
|
|
82
|
+
|
|
83
|
+
let classNameComputed: string = `sg-modal-tag`
|
|
84
|
+
if(className) {
|
|
85
|
+
classNameComputed += " "+className
|
|
86
|
+
}
|
|
87
|
+
if(backdrop === "static" || backdrop === "true") {
|
|
88
|
+
classNameComputed += " sg-modal-static"
|
|
89
|
+
}
|
|
90
|
+
if(fill) classNameComputed += " sg-modal-fill"
|
|
91
|
+
if(size && !fill) classNameComputed += ` sg-modal-${size}`
|
|
92
|
+
|
|
93
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLDialogElement>) => {
|
|
94
|
+
const key: string = event.key
|
|
95
|
+
if(key != "Escape") {return}
|
|
96
|
+
|
|
97
|
+
event.preventDefault()
|
|
98
|
+
closeModal()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
renderModal ?
|
|
103
|
+
createPortal(
|
|
104
|
+
<dialog ref={mergeRefs([ref, modalRef])} className={classNameComputed} onKeyDown={(event) => handleKeyDown(event)} {...restProps } style={{"--height":stretch ? "80%":null, ...style} as React.CSSProperties}>
|
|
105
|
+
<ModalContextProvider value={closeModal}>
|
|
106
|
+
{!typeCheck ?
|
|
107
|
+
children :
|
|
108
|
+
<ErrorModal typeCheck={typeCheck} closeModal={closeModal}/>
|
|
109
|
+
}
|
|
110
|
+
</ModalContextProvider>
|
|
111
|
+
</dialog>
|
|
112
|
+
, document.body)
|
|
113
|
+
: null
|
|
114
|
+
)
|
|
115
|
+
})
|
|
116
|
+
Modal.displayName = "Modal"
|
|
117
|
+
|
|
118
|
+
const Header = forwardRef<HTMLDivElement | HTMLSpanElement | HTMLHeadingElement, ModalHeaderType>(({children, as="", className = "", closeButton = false, onClick, ...restProps}, ref) => {
|
|
119
|
+
let validAs = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"]
|
|
120
|
+
let Component = validAs.find(valid => valid === as) ? as : "div"
|
|
121
|
+
const closeModal = useModalContext()
|
|
122
|
+
const onCloseButtonClick = (event: React.MouseEvent) => {
|
|
123
|
+
if(onClick) {
|
|
124
|
+
onClick(event)
|
|
125
|
+
}
|
|
126
|
+
closeModal()
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<Component ref={ref} className={`sg-modal-header ${className}`} {...restProps}>
|
|
131
|
+
{children}
|
|
132
|
+
{closeButton ? <CloseButton variant onClick={event => onCloseButtonClick(event)}/> : null}
|
|
133
|
+
</Component>
|
|
134
|
+
)
|
|
135
|
+
})
|
|
136
|
+
Header.displayName = "ModalHeader"
|
|
137
|
+
|
|
138
|
+
const Title = forwardRef<HTMLDivElement | HTMLSpanElement | HTMLHeadingElement, ModalTitleType>( ({children, as="h4", className, ...restProps}, ref) => {
|
|
139
|
+
let validAs = ["div", "span", "h1", "h2", "h3", "h4", "h5", "h6"]
|
|
140
|
+
let Component = validAs.find(valid => valid === as) ? as : "h4"
|
|
141
|
+
return (
|
|
142
|
+
<Component ref={ref} className={`sg-modal-title ${className}`} {...restProps}>
|
|
143
|
+
{children}
|
|
144
|
+
</Component>
|
|
145
|
+
)
|
|
146
|
+
})
|
|
147
|
+
Title.displayName = "ModalTitle"
|
|
148
|
+
|
|
149
|
+
const Body = forwardRef<HTMLDivElement, ModalBodyType>( ({children, className, ...restProps}, ref) => {
|
|
150
|
+
return (
|
|
151
|
+
<div ref={ref} className={`sg-modal-body ${className}`} {...restProps}>
|
|
152
|
+
{children}
|
|
153
|
+
</div>
|
|
154
|
+
)
|
|
155
|
+
})
|
|
156
|
+
Body.displayName = "ModalBody"
|
|
157
|
+
|
|
158
|
+
const Footer = forwardRef<HTMLDivElement, ModalBodyType>( ({children, className, ...restProps}, ref) => {
|
|
159
|
+
return (
|
|
160
|
+
<div ref={ref} className={`sg-modal-footer ${className}`} {...restProps}>
|
|
161
|
+
{children}
|
|
162
|
+
</div>
|
|
163
|
+
)
|
|
164
|
+
})
|
|
165
|
+
Footer.displayName = "ModalFooter"
|
|
166
|
+
|
|
167
|
+
export default Object.assign(Modal, {
|
|
168
|
+
Header: Header,
|
|
169
|
+
Title: Title,
|
|
170
|
+
Body: Body,
|
|
171
|
+
Footer: Footer
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
export const useKeepElementFocused = function (elementRef: React.RefObject<HTMLDialogElement>) {
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
177
|
+
const focusableElements = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
178
|
+
const modal = elementRef.current
|
|
179
|
+
if(modal) {
|
|
180
|
+
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0] as HTMLElement
|
|
181
|
+
const focusableContent = modal.querySelectorAll(focusableElements)
|
|
182
|
+
const lastFocusableElement = focusableContent[focusableContent.length - 1] as HTMLElement
|
|
183
|
+
let isTabPressed = event.key === 'Tab'
|
|
184
|
+
|
|
185
|
+
if (!isTabPressed) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (event.shiftKey) {
|
|
190
|
+
if (document.activeElement === firstFocusableElement) {
|
|
191
|
+
lastFocusableElement.focus()
|
|
192
|
+
event.preventDefault()
|
|
193
|
+
}
|
|
194
|
+
} else if (document.activeElement === lastFocusableElement) {
|
|
195
|
+
firstFocusableElement.focus();
|
|
196
|
+
event.preventDefault()
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
document.addEventListener('keydown', onKeyDown, true )
|
|
201
|
+
|
|
202
|
+
return function cleanup() {
|
|
203
|
+
document.removeEventListener('keydown', onKeyDown, true )
|
|
204
|
+
}
|
|
205
|
+
}, [elementRef])
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const ErrorModal = ({typeCheck, closeModal}:ErrorModalType) => {
|
|
209
|
+
return (
|
|
210
|
+
<>
|
|
211
|
+
<Header closeButton >
|
|
212
|
+
<Title>
|
|
213
|
+
An Error ocurred!
|
|
214
|
+
</Title>
|
|
215
|
+
</Header>
|
|
216
|
+
<Body>
|
|
217
|
+
<p>
|
|
218
|
+
{!typeCheck.show ? "The variable 'show' must be used and must be a boolean used to decide when to show the modal!" : null}
|
|
219
|
+
{!typeCheck.onHide ? "The variable 'onHide' must be used and must be a function which is used to set 'show' as the modal gets closed!" : null}
|
|
220
|
+
</p>
|
|
221
|
+
</Body>
|
|
222
|
+
<Footer>
|
|
223
|
+
<Button variant="danger" type="button" onClick={() => closeModal()}>
|
|
224
|
+
Close
|
|
225
|
+
</Button>
|
|
226
|
+
</Footer>
|
|
227
|
+
</>
|
|
228
|
+
)
|
|
229
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { BaseDialogType, BaseDivType, BaseHeadingType, BaseSpanType } from "../utils/BaseTypes"
|
|
4
|
+
|
|
5
|
+
export type ModalContextType = Function | null
|
|
6
|
+
|
|
7
|
+
export type ModalType = {
|
|
8
|
+
children:ReactNode,
|
|
9
|
+
className?: string,
|
|
10
|
+
id?: string,
|
|
11
|
+
fill?: boolean,
|
|
12
|
+
size?: string,
|
|
13
|
+
show: boolean,
|
|
14
|
+
backdrop?: string,
|
|
15
|
+
onHide: Function,
|
|
16
|
+
stretch?: boolean
|
|
17
|
+
} & BaseDialogType
|
|
18
|
+
|
|
19
|
+
export type ModalHeaderType = {
|
|
20
|
+
children: ReactNode,
|
|
21
|
+
as?: React.ElementType,
|
|
22
|
+
className?: string,
|
|
23
|
+
closeButton?: boolean
|
|
24
|
+
onClick?: (event: React.MouseEvent) => void,
|
|
25
|
+
} & (BaseDivType | BaseHeadingType | BaseSpanType)
|
|
26
|
+
|
|
27
|
+
export type ModalTitleType = {
|
|
28
|
+
children: ReactNode,
|
|
29
|
+
as?: React.ElementType,
|
|
30
|
+
className?: string
|
|
31
|
+
} & (BaseDivType | BaseHeadingType | BaseSpanType)
|
|
32
|
+
|
|
33
|
+
export type ModalBodyType = {
|
|
34
|
+
children: ReactNode,
|
|
35
|
+
className?: string,
|
|
36
|
+
} & BaseDivType
|
|
37
|
+
|
|
38
|
+
export type ModalFooterType = {
|
|
39
|
+
children: ReactNode,
|
|
40
|
+
className?: string,
|
|
41
|
+
} & BaseDivType
|
|
42
|
+
|
|
43
|
+
export type ErrorModalType = {
|
|
44
|
+
typeCheck: {
|
|
45
|
+
show: boolean,
|
|
46
|
+
onHide: boolean
|
|
47
|
+
},
|
|
48
|
+
closeModal: Function
|
|
49
|
+
}
|
package/src/Nav/Nav.tsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { NavType, NavItemType, NavLinkType } from "./Nav.types";
|
|
4
|
+
|
|
5
|
+
import { useNavbarContext } from "../NavBar/Navbar";
|
|
6
|
+
|
|
7
|
+
const Nav = forwardRef<HTMLElement, NavType>(({children, className, as="ul", ...restProps}, ref) => {
|
|
8
|
+
const Component = as
|
|
9
|
+
const navbarContext = useNavbarContext()
|
|
10
|
+
const navbarPrefix = navbarContext ? navbarContext : "sg-navbar-"
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Component ref={ref} className={`${className} ${navbarPrefix}nav`} {...restProps}>
|
|
14
|
+
{children}
|
|
15
|
+
</Component>
|
|
16
|
+
)
|
|
17
|
+
})
|
|
18
|
+
Nav.displayName = "Nav"
|
|
19
|
+
|
|
20
|
+
const Item = forwardRef<HTMLElement, NavItemType>( ({children, className, as="li", ...restProps}, ref) => {
|
|
21
|
+
const Component = as
|
|
22
|
+
return (
|
|
23
|
+
<Component role="none" ref={ref} className={`sg-nav-item${className ? " "+className:""}`} {...restProps}>
|
|
24
|
+
{children}
|
|
25
|
+
</Component>
|
|
26
|
+
)
|
|
27
|
+
})
|
|
28
|
+
Item.displayName = "NavItem"
|
|
29
|
+
|
|
30
|
+
const Link = forwardRef<HTMLElement, NavLinkType>( ({children, className, as="a", ...restProps}, ref) => {
|
|
31
|
+
const Component = as
|
|
32
|
+
return (
|
|
33
|
+
<Component role="menuitem" ref={ref} className={`sg-nav-link${className ? " "+className:""}`} {...restProps}>
|
|
34
|
+
{children}
|
|
35
|
+
</Component>
|
|
36
|
+
)
|
|
37
|
+
})
|
|
38
|
+
Link.displayName = "NavLink"
|
|
39
|
+
|
|
40
|
+
export default Object.assign(Nav, {
|
|
41
|
+
Item: Item,
|
|
42
|
+
Link: Link
|
|
43
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { BaseAnchorType, BaseElementType, BaseLItemType, BaseUListType } from "../utils/BaseTypes";
|
|
4
|
+
|
|
5
|
+
export type NavType = {
|
|
6
|
+
children: ReactNode,
|
|
7
|
+
className?: string,
|
|
8
|
+
as?: React.ElementType
|
|
9
|
+
} & (BaseUListType | BaseElementType)
|
|
10
|
+
|
|
11
|
+
export type NavItemType = {
|
|
12
|
+
children: ReactNode,
|
|
13
|
+
className?: string,
|
|
14
|
+
as?: React.ElementType
|
|
15
|
+
} & (BaseLItemType | BaseElementType)
|
|
16
|
+
|
|
17
|
+
export type NavLinkType = {
|
|
18
|
+
children: ReactNode,
|
|
19
|
+
className?: string,
|
|
20
|
+
as?: React.ElementType
|
|
21
|
+
} & (BaseAnchorType | BaseElementType)
|
package/src/Nav/index.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React, { createContext, forwardRef, useContext, useMemo } from "react";
|
|
2
|
+
|
|
3
|
+
import { NavbarBrandType, NavbarTextType, NavbarType, NavbarContextType } from "./Navbar.types";
|
|
4
|
+
|
|
5
|
+
export const NavbarContext = createContext<NavbarContextType>(null)
|
|
6
|
+
|
|
7
|
+
const NavbarContextProvider = ({children, value}:{children:React.ReactNode, value:NavbarContextType}) => {
|
|
8
|
+
return (
|
|
9
|
+
<NavbarContext.Provider value={value}>
|
|
10
|
+
{children}
|
|
11
|
+
</NavbarContext.Provider>
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
export const useNavbarContext = () => {
|
|
15
|
+
const context = useContext(NavbarContext)
|
|
16
|
+
return context
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const Navbar = forwardRef<HTMLElement, NavbarType>(({children, className, navbarPrefix= "sg-navbar-", ...restProps}, ref) => {
|
|
20
|
+
const navbarContext = useMemo(() => {
|
|
21
|
+
return navbarPrefix
|
|
22
|
+
}, [navbarPrefix])
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<nav ref={ref} className={`sg-navbar${className ? " "+className:""}`} {...restProps}>
|
|
26
|
+
<NavbarContextProvider value={navbarContext}>
|
|
27
|
+
{children}
|
|
28
|
+
</NavbarContextProvider>
|
|
29
|
+
</nav>
|
|
30
|
+
)
|
|
31
|
+
})
|
|
32
|
+
Navbar.displayName = "Navbar"
|
|
33
|
+
|
|
34
|
+
const Brand = forwardRef<HTMLAnchorElement | HTMLElement, NavbarBrandType>( ({children, className, href="#", as="a", ...restProps}, ref) => {
|
|
35
|
+
const Component = as || (href && as != "Link" ? 'a' : 'span')
|
|
36
|
+
return (
|
|
37
|
+
<Component ref={ref} href={href} className={`sg-navbar-brand${className ? " "+className:""}`} {...restProps} >
|
|
38
|
+
{children}
|
|
39
|
+
</Component>
|
|
40
|
+
)
|
|
41
|
+
})
|
|
42
|
+
Brand.displayName = "NavbarBrand"
|
|
43
|
+
|
|
44
|
+
const Text = forwardRef<HTMLElement, NavbarTextType>( ({children, className, as="span", ...restProps}, ref) => {
|
|
45
|
+
const Component = as
|
|
46
|
+
return (
|
|
47
|
+
<Component ref={ref} className={`sg-navbar-text${className ? " "+className:""}`} {...restProps}>
|
|
48
|
+
{children}
|
|
49
|
+
</Component>
|
|
50
|
+
)
|
|
51
|
+
})
|
|
52
|
+
Text.displayName = "NavbarText"
|
|
53
|
+
|
|
54
|
+
export default Object.assign(Navbar, {
|
|
55
|
+
Brand: Brand,
|
|
56
|
+
Text: Text
|
|
57
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { BaseAnchorType, BaseElementType, BaseNavType } from "../utils/BaseTypes";
|
|
4
|
+
|
|
5
|
+
export type NavbarContextType = string | null
|
|
6
|
+
|
|
7
|
+
export type NavbarType = {
|
|
8
|
+
children: ReactNode,
|
|
9
|
+
className?: string,
|
|
10
|
+
navbarPrefix?: string,
|
|
11
|
+
} & BaseNavType
|
|
12
|
+
|
|
13
|
+
export type NavbarBrandType = {
|
|
14
|
+
children: ReactNode,
|
|
15
|
+
className?: string,
|
|
16
|
+
as?: React.ElementType,
|
|
17
|
+
href?: string
|
|
18
|
+
} & (BaseAnchorType | BaseElementType)
|
|
19
|
+
|
|
20
|
+
export type NavbarTextType = {
|
|
21
|
+
children: ReactNode,
|
|
22
|
+
className?: string,
|
|
23
|
+
as?: React.ElementType
|
|
24
|
+
} & BaseElementType
|