goobs-frontend 0.7.53

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/package.json +122 -0
  4. package/src/app/_app.tsx +8 -0
  5. package/src/atoms/helperfooter.ts +21 -0
  6. package/src/components/Button/index.tsx +241 -0
  7. package/src/components/ConfirmationCodeInput/index.tsx +108 -0
  8. package/src/components/ConfirmationCodeInput/utils/useCodeConfirmation.tsx +129 -0
  9. package/src/components/Content/Structure/animations.tsx +106 -0
  10. package/src/components/Content/Structure/button/useButton.tsx +80 -0
  11. package/src/components/Content/Structure/confirmationinput/useConfirmationInput.tsx +56 -0
  12. package/src/components/Content/Structure/image/useImage.tsx +62 -0
  13. package/src/components/Content/Structure/link/useLink.tsx +60 -0
  14. package/src/components/Content/Structure/radiogroup/useGridRadioGroup.tsx +62 -0
  15. package/src/components/Content/Structure/styledcomponent/useStyledComponent.tsx +96 -0
  16. package/src/components/Content/Structure/typography/useGridTypography.tsx +53 -0
  17. package/src/components/Content/index.tsx +147 -0
  18. package/src/components/Form/Popup/index.tsx +121 -0
  19. package/src/components/Grid/defaultconfig.tsx +131 -0
  20. package/src/components/Grid/index.tsx +265 -0
  21. package/src/components/Icons/Calendar.tsx +21 -0
  22. package/src/components/Icons/DownArrowFilled.tsx +9 -0
  23. package/src/components/Icons/Drag.tsx +9 -0
  24. package/src/components/Icons/FavoriteIcon.tsx +24 -0
  25. package/src/components/Icons/Info.tsx +12 -0
  26. package/src/components/Icons/Search.tsx +29 -0
  27. package/src/components/Icons/ShowHideEye.tsx +16 -0
  28. package/src/components/RadioGroup/index.tsx +96 -0
  29. package/src/components/StyledComponent/adornments.tsx +118 -0
  30. package/src/components/StyledComponent/helperfooter/useHelperFooter.tsx +411 -0
  31. package/src/components/StyledComponent/hooks/useDropdown.tsx +144 -0
  32. package/src/components/StyledComponent/hooks/usePassword.tsx +23 -0
  33. package/src/components/StyledComponent/hooks/usePhoneNumber.tsx +75 -0
  34. package/src/components/StyledComponent/hooks/useSearchbar.tsx +44 -0
  35. package/src/components/StyledComponent/hooks/useSplitButton.tsx +66 -0
  36. package/src/components/StyledComponent/index.tsx +404 -0
  37. package/src/components/Typography/index.tsx +268 -0
  38. package/src/index.ts +210 -0
  39. package/src/main.tsx +7 -0
  40. package/src/styles/Form/index.ts +7 -0
  41. package/src/styles/StyledComponent/Label/index.ts +76 -0
  42. package/src/styles/palette.ts +143 -0
  43. package/src/styles/typography.ts +184 -0
  44. package/src/types/async-lock.d.ts +35 -0
@@ -0,0 +1,96 @@
1
+ import React from 'react'
2
+ import StyledComponent, {
3
+ StyledComponentProps,
4
+ } from '../../../../components/StyledComponent'
5
+ import { columnconfig, cellconfig } from '../../../Grid'
6
+
7
+ export interface ExtendedStyledComponentProps extends StyledComponentProps {
8
+ columnconfig?: columnconfig
9
+ cellconfig?: cellconfig
10
+ }
11
+
12
+ const useStyledComponent = (grid: {
13
+ styledcomponent?:
14
+ | ExtendedStyledComponentProps
15
+ | ExtendedStyledComponentProps[]
16
+ }) => {
17
+ if (!grid.styledcomponent) return null
18
+
19
+ const renderStyledComponent = (
20
+ component: ExtendedStyledComponentProps,
21
+ index: number
22
+ ): columnconfig => {
23
+ const {
24
+ name,
25
+ outlinecolor,
26
+ iconcolor,
27
+ backgroundcolor,
28
+ combinedfontcolor,
29
+ unshrunkfontcolor,
30
+ shrunkfontcolor,
31
+ autoComplete,
32
+ componentvariant,
33
+ options,
34
+ helperfooter,
35
+ placeholder,
36
+ minRows,
37
+ label,
38
+ shrunklabellocation,
39
+ value,
40
+ onChange,
41
+ defaultValue,
42
+ inputRef,
43
+ columnconfig,
44
+ serverActionValidation,
45
+ valuestatus,
46
+ cellconfig,
47
+ required,
48
+ ...restProps
49
+ } = component
50
+
51
+ // Merge the cellconfig with the columnconfig
52
+ const mergedConfig: columnconfig = {
53
+ ...columnconfig,
54
+ cellconfig: {
55
+ ...cellconfig,
56
+ },
57
+ component: (
58
+ <StyledComponent
59
+ key={`styledcomponent-${index}`}
60
+ name={name}
61
+ outlinecolor={outlinecolor}
62
+ iconcolor={iconcolor}
63
+ backgroundcolor={backgroundcolor}
64
+ combinedfontcolor={combinedfontcolor}
65
+ unshrunkfontcolor={unshrunkfontcolor}
66
+ shrunkfontcolor={shrunkfontcolor}
67
+ autoComplete={autoComplete}
68
+ componentvariant={componentvariant}
69
+ options={options}
70
+ helperfooter={helperfooter}
71
+ placeholder={placeholder}
72
+ minRows={minRows}
73
+ label={label}
74
+ shrunklabellocation={shrunklabellocation}
75
+ value={value}
76
+ onChange={onChange}
77
+ defaultValue={defaultValue}
78
+ inputRef={inputRef}
79
+ serverActionValidation={serverActionValidation}
80
+ valuestatus={valuestatus}
81
+ required={required}
82
+ {...restProps}
83
+ />
84
+ ),
85
+ }
86
+ return mergedConfig
87
+ }
88
+
89
+ if (Array.isArray(grid.styledcomponent)) {
90
+ return grid.styledcomponent.map(renderStyledComponent)
91
+ } else {
92
+ return [renderStyledComponent(grid.styledcomponent, 0)]
93
+ }
94
+ }
95
+
96
+ export default useStyledComponent
@@ -0,0 +1,53 @@
1
+ import React from 'react'
2
+ import { Typography, TypographyProps } from '../../../Typography'
3
+ import { columnconfig, cellconfig } from '../../../Grid'
4
+
5
+ export interface ExtendedTypographyProps extends TypographyProps {
6
+ columnconfig?: columnconfig
7
+ cellconfig?: cellconfig
8
+ }
9
+
10
+ const useGridTypography = (grid: {
11
+ typography?: ExtendedTypographyProps | ExtendedTypographyProps[]
12
+ }) => {
13
+ if (!grid.typography) return null
14
+
15
+ const renderTypography = (
16
+ typographyItem: ExtendedTypographyProps,
17
+ index: number
18
+ ): columnconfig => {
19
+ const {
20
+ text,
21
+ fontcolor,
22
+ fontvariant,
23
+ columnconfig: itemColumnConfig,
24
+ cellconfig,
25
+ ...restProps
26
+ } = typographyItem
27
+
28
+ return {
29
+ ...itemColumnConfig,
30
+ cellconfig: {
31
+ ...cellconfig,
32
+ border: 'none',
33
+ },
34
+ component: (
35
+ <Typography
36
+ key={`typography-${index}`}
37
+ text={text}
38
+ fontvariant={fontvariant}
39
+ fontcolor={fontcolor}
40
+ {...restProps}
41
+ />
42
+ ),
43
+ }
44
+ }
45
+
46
+ if (Array.isArray(grid.typography)) {
47
+ return grid.typography.map(renderTypography)
48
+ } else {
49
+ return renderTypography(grid.typography, 0)
50
+ }
51
+ }
52
+
53
+ export default useGridTypography
@@ -0,0 +1,147 @@
1
+ 'use client'
2
+ import React from 'react'
3
+ import CustomGrid, { columnconfig, gridconfig } from '../../components/Grid'
4
+ import useGridTypography, {
5
+ ExtendedTypographyProps as TypographyProps,
6
+ } from './Structure/typography/useGridTypography'
7
+ import useStyledComponent, {
8
+ ExtendedStyledComponentProps,
9
+ } from '../../components/Content/Structure/styledcomponent/useStyledComponent'
10
+ import useGridRadioGroup, {
11
+ ExtendedRadioGroupProps,
12
+ } from '../../components/Content/Structure/radiogroup/useGridRadioGroup'
13
+ import useConfirmationInput, {
14
+ ExtendedConfirmationCodeInputsProps,
15
+ } from '../../components/Content/Structure/confirmationinput/useConfirmationInput'
16
+ import useLink, {
17
+ ExtendedTypographyProps as LinkProps,
18
+ } from '../../components/Content/Structure/link/useLink'
19
+ import useImage, {
20
+ ExtendedImageProps,
21
+ } from '../../components/Content/Structure/image/useImage'
22
+ import useButton, {
23
+ ExtendedButtonProps,
24
+ } from '../../components/Content/Structure/button/useButton'
25
+
26
+ export interface ContentSectionProps {
27
+ gridconfig?: gridconfig
28
+ confirmationcodeinput?:
29
+ | ExtendedConfirmationCodeInputsProps
30
+ | ExtendedConfirmationCodeInputsProps[]
31
+ typography?: TypographyProps | TypographyProps[]
32
+ styledcomponent?:
33
+ | ExtendedStyledComponentProps
34
+ | ExtendedStyledComponentProps[]
35
+ radiogroup?: ExtendedRadioGroupProps | ExtendedRadioGroupProps[]
36
+ link?: LinkProps | LinkProps[]
37
+ button?: ExtendedButtonProps | ExtendedButtonProps[]
38
+ image?: ExtendedImageProps | ExtendedImageProps[]
39
+ }
40
+
41
+ /**
42
+ * RenderContent component renders the content of a section based on the provided props.
43
+ * It uses various custom hooks to generate column configurations for different content types.
44
+ * @param props The props for the RenderContent component.
45
+ * @returns The rendered content section.
46
+ */
47
+ const RenderContent: React.FC<ContentSectionProps> = ({
48
+ gridconfig,
49
+ ...props
50
+ }) => {
51
+ let columnConfigs: columnconfig[] = []
52
+
53
+ /**
54
+ * Generate column configurations for typography content.
55
+ */
56
+ const paragraph = useGridTypography(props)
57
+ if (paragraph) {
58
+ if (Array.isArray(paragraph)) {
59
+ columnConfigs = columnConfigs.concat(paragraph)
60
+ } else {
61
+ columnConfigs.push(paragraph)
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Generate column configurations for styled component content.
67
+ */
68
+ const styledComponent = useStyledComponent(props)
69
+ if (styledComponent) {
70
+ columnConfigs = columnConfigs.concat(styledComponent)
71
+ }
72
+
73
+ /**
74
+ * Generate column configurations for radio group content.
75
+ */
76
+ const radioGroup = useGridRadioGroup(props)
77
+ if (radioGroup) {
78
+ columnConfigs = columnConfigs.concat(radioGroup)
79
+ }
80
+
81
+ /**
82
+ * Generate column configurations for confirmation input content.
83
+ */
84
+ const confirmationInput = useConfirmationInput({
85
+ confirmationcodeinput: props.confirmationcodeinput,
86
+ })
87
+ if (confirmationInput) {
88
+ if (Array.isArray(confirmationInput)) {
89
+ columnConfigs = columnConfigs.concat(confirmationInput)
90
+ } else {
91
+ columnConfigs.push(confirmationInput)
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Generate column configurations for link content.
97
+ */
98
+ const links = useLink(props)
99
+ if (links) {
100
+ columnConfigs = columnConfigs.concat(links)
101
+ }
102
+
103
+ /**
104
+ * Generate column configurations for button content.
105
+ */
106
+ const button = useButton(props)
107
+ if (button) {
108
+ if (Array.isArray(button)) {
109
+ button.forEach(btn => {
110
+ if (btn) {
111
+ columnConfigs.push(btn)
112
+ }
113
+ })
114
+ } else {
115
+ columnConfigs.push(button)
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Generate column configurations for image content.
121
+ */
122
+ const image = useImage(props)
123
+ if (image) {
124
+ columnConfigs = columnConfigs.concat(image)
125
+ }
126
+
127
+ return <CustomGrid gridconfig={gridconfig} columnconfig={columnConfigs} />
128
+ }
129
+
130
+ /**
131
+ * ContentSection component renders a list of content sections based on the provided grids prop.
132
+ * @param props The props for the ContentSection component.
133
+ * @returns The rendered content sections.
134
+ */
135
+ export default function ContentSection({
136
+ grids,
137
+ }: {
138
+ grids: ContentSectionProps[]
139
+ }) {
140
+ return (
141
+ <>
142
+ {grids.map((grid, index) => (
143
+ <RenderContent key={index} {...grid} />
144
+ ))}
145
+ </>
146
+ )
147
+ }
@@ -0,0 +1,121 @@
1
+ 'use client'
2
+ import { Close } from '@mui/icons-material'
3
+ import { Dialog, IconButton, Box } from '@mui/material'
4
+ import ContentSection, { ContentSectionProps } from '../../Content'
5
+ import { formContainerStyle } from './../../../styles/Form'
6
+ import { TypographyProps } from './../../../components/Typography'
7
+ import React from 'react'
8
+
9
+ export interface PopupFormProps {
10
+ title?: string
11
+ description?: string
12
+ open: boolean
13
+ onClose: () => void
14
+ onSubmit?: (formData: FormData) => void
15
+ grids: ContentSectionProps[]
16
+ }
17
+
18
+ /**
19
+ * PopupForm component renders a popup form with a title, description, and content sections.
20
+ * It uses the ContentSection component to render the form content.
21
+ * @param props The props for the PopupForm component.
22
+ * @returns The rendered popup form.
23
+ */
24
+ function PopupForm({
25
+ title,
26
+ description,
27
+ open,
28
+ onClose,
29
+ grids,
30
+ onSubmit,
31
+ }: PopupFormProps) {
32
+ /**
33
+ * handleSubmit function is called when the form is submitted.
34
+ * It prevents the default form submission behavior and creates a FormData object from the form data.
35
+ * If an onSubmit callback is provided, it is called with the FormData object.
36
+ * @param event The form submission event.
37
+ */
38
+ const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
39
+ event.preventDefault()
40
+ const formData = new FormData(event.currentTarget)
41
+ if (onSubmit) {
42
+ onSubmit(formData)
43
+ }
44
+ }
45
+
46
+ /**
47
+ * headerGrid array contains the grid configuration for the form header.
48
+ * It includes the title and description typography props.
49
+ */
50
+ const headerGrid = [
51
+ {
52
+ gridconfig: {
53
+ gridname: 'formHeader',
54
+ margintop: 0,
55
+ marginbottom: 1,
56
+ marginleft: 0,
57
+ marginright: 0,
58
+ gridwidth: '100%',
59
+ },
60
+ subtitle: {
61
+ text: title,
62
+ columnconfig: {
63
+ row: 1,
64
+ column: 1,
65
+ gridname: 'formHeader',
66
+ columnwidth: '100%',
67
+ alignment: 'left',
68
+ marginbottom: 0.5,
69
+ },
70
+ cellconfig: {
71
+ border: 'none',
72
+ },
73
+ } as TypographyProps,
74
+ paragraph: {
75
+ text: description,
76
+ columnconfig: {
77
+ row: 2,
78
+ column: 1,
79
+ gridname: 'formHeader',
80
+ columnwidth: '100%',
81
+ marginbottom: 0,
82
+ },
83
+ cellconfig: {
84
+ border: 'none',
85
+ },
86
+ } as TypographyProps,
87
+ },
88
+ ]
89
+
90
+ /**
91
+ * contentSectionGrids array combines the headerGrid and the provided grids prop.
92
+ */
93
+ const contentSectionGrids = [...headerGrid, ...grids]
94
+
95
+ return (
96
+ <Dialog open={open} onClose={onClose} fullWidth maxWidth="sm">
97
+ <IconButton
98
+ size="small"
99
+ onClick={onClose}
100
+ sx={{
101
+ position: 'absolute',
102
+ right: 8,
103
+ top: 8,
104
+ color: theme => theme.palette.grey[500],
105
+ }}
106
+ >
107
+ <Close />
108
+ </IconButton>
109
+ <Box
110
+ // @ts-ignore
111
+ sx={formContainerStyle}
112
+ >
113
+ <form onSubmit={handleSubmit}>
114
+ <ContentSection grids={contentSectionGrids} />
115
+ </form>
116
+ </Box>
117
+ </Dialog>
118
+ )
119
+ }
120
+
121
+ export default PopupForm
@@ -0,0 +1,131 @@
1
+ import { gridconfig, columnconfig, cellconfig } from './index'
2
+ import { Typography } from '../../components/Typography'
3
+ import React from 'react'
4
+
5
+ export const defaultGridConfig: gridconfig = {
6
+ gridname: 'testgrid',
7
+ alignment: 'center',
8
+ margintop: 10,
9
+ marginbottom: 2,
10
+ marginright: 2,
11
+ marginleft: 10,
12
+ gridwidth: '100%',
13
+ }
14
+
15
+ export const defaultColumnConfig: columnconfig[] = [
16
+ {
17
+ row: 1,
18
+ column: 1,
19
+ gridname: 'testgrid',
20
+ alignment: 'left',
21
+ columnwidth: '33.33%',
22
+ margintop: 1,
23
+ marginbottom: 1,
24
+ marginright: 0,
25
+ marginleft: 0,
26
+ component: <Typography variant="h4" text="Column 1" />,
27
+ cellconfig: {
28
+ border: 'none',
29
+ mobilewidth: '100%',
30
+ tabletwidth: '33.33%',
31
+ computerwidth: '33.33%',
32
+ },
33
+ },
34
+ {
35
+ row: 1,
36
+ column: 2,
37
+ gridname: 'testgrid',
38
+ alignment: 'left',
39
+ columnwidth: '33.33%',
40
+ margintop: 1,
41
+ marginbottom: 1,
42
+ marginright: 0,
43
+ marginleft: 0,
44
+ component: <Typography variant="h4" text="Column 2" />,
45
+ cellconfig: {
46
+ border: 'none',
47
+ mobilewidth: '100%',
48
+ tabletwidth: '33.33%',
49
+ computerwidth: '33.33%',
50
+ },
51
+ },
52
+ {
53
+ row: 1,
54
+ column: 3,
55
+ gridname: 'testgrid',
56
+ alignment: 'left',
57
+ columnwidth: '33.33%',
58
+ margintop: 1,
59
+ marginbottom: 1,
60
+ marginright: 0,
61
+ marginleft: 0,
62
+ component: <Typography variant="h4" text="Column 3" />,
63
+ cellconfig: {
64
+ border: 'none',
65
+ mobilewidth: '100%',
66
+ tabletwidth: '33.33%',
67
+ computerwidth: '33.33%',
68
+ },
69
+ },
70
+ {
71
+ row: 2,
72
+ column: 1,
73
+ gridname: 'testgrid',
74
+ alignment: 'center',
75
+ columnwidth: '33.33%',
76
+ margintop: 1,
77
+ marginbottom: 1,
78
+ marginright: 2,
79
+ marginleft: 2,
80
+ component: <Typography variant="h4" text="Column 4" />,
81
+ cellconfig: {
82
+ border: 'none',
83
+ mobilewidth: '100%',
84
+ tabletwidth: '33.33%',
85
+ computerwidth: '33.33%',
86
+ },
87
+ },
88
+ {
89
+ row: 2,
90
+ column: 2,
91
+ gridname: 'testgrid',
92
+ alignment: 'center',
93
+ columnwidth: '33.33%',
94
+ margintop: 1,
95
+ marginbottom: 1,
96
+ marginright: 2,
97
+ marginleft: 2,
98
+ component: <Typography variant="h4" text="Column 5" />,
99
+ cellconfig: {
100
+ border: 'none',
101
+ mobilewidth: '100%',
102
+ tabletwidth: '33.33%',
103
+ computerwidth: '33.33%',
104
+ },
105
+ },
106
+ {
107
+ row: 2,
108
+ column: 3,
109
+ gridname: 'testgrid',
110
+ alignment: 'center',
111
+ columnwidth: '33.33%',
112
+ margintop: 1,
113
+ marginbottom: 1,
114
+ marginright: 0,
115
+ marginleft: 0,
116
+ component: <Typography variant="h4" text="Column 6" />,
117
+ cellconfig: {
118
+ border: 'none',
119
+ mobilewidth: '100%',
120
+ tabletwidth: '33.33%',
121
+ computerwidth: '33.33%',
122
+ },
123
+ },
124
+ ]
125
+
126
+ export const defaultCellConfig: cellconfig = {
127
+ border: 'none',
128
+ mobilewidth: '100%',
129
+ tabletwidth: '100%',
130
+ computerwidth: '100%',
131
+ }