goobs-frontend 0.7.54 → 0.7.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goobs-frontend",
3
- "version": "0.7.54",
3
+ "version": "0.7.56",
4
4
  "description": "A comprehensive React-based UI library built on Material-UI, offering a wide range of customizable components including grids, typography, buttons, cards, forms, navigation, pricing tables, steppers, tooltips, accordions, and more. Designed for building responsive and consistent user interfaces with advanced features like form validation, theming, and code syntax highlighting.",
5
5
  "license": "MIT",
6
6
  "main": "./src/index.ts",
@@ -28,7 +28,6 @@
28
28
  "@mui/icons-material": "^5.15.20",
29
29
  "@mui/material": "^5.15.20",
30
30
  "@types/lodash": "^4.17.5",
31
- "async-lock": "^1.4.1",
32
31
  "goobs-cache": "^1.2.1",
33
32
  "highlight.js": "^11.9.0",
34
33
  "lodash": "^4.17.21",
@@ -36,7 +35,6 @@
36
35
  },
37
36
  "devDependencies": {
38
37
  "@next/eslint-plugin-next": "^14.2.4",
39
- "@types/async-lock": "^1.4.2",
40
38
  "@types/node": "^20.14.9",
41
39
  "@types/react": "18.3.0",
42
40
  "@types/react-dom": "^18.3.0",
@@ -5,7 +5,7 @@ import { columnconfig, cellconfig } from '../../../Grid'
5
5
  import { TypographyPropsVariantOverrides } from '@mui/material'
6
6
 
7
7
  export interface ExtendedButtonProps extends CustomButtonProps {
8
- columnconfig?: columnconfig
8
+ columnconfig?: Partial<columnconfig>
9
9
  cellconfig?: cellconfig
10
10
  }
11
11
 
@@ -39,8 +39,19 @@ const useButton = (grid: {
39
39
  ...restProps
40
40
  } = buttonItem
41
41
 
42
+ if (
43
+ !itemColumnConfig ||
44
+ typeof itemColumnConfig !== 'object' ||
45
+ typeof itemColumnConfig.row !== 'number' ||
46
+ typeof itemColumnConfig.column !== 'number'
47
+ ) {
48
+ throw new Error(
49
+ 'columnconfig must be an object with row and column as numbers'
50
+ )
51
+ }
52
+
42
53
  const mergedConfig: columnconfig = {
43
- ...itemColumnConfig,
54
+ ...(itemColumnConfig as columnconfig),
44
55
  cellconfig: {
45
56
  ...cellconfig,
46
57
  },
@@ -3,8 +3,12 @@ import React from 'react'
3
3
  import { columnconfig, cellconfig } from '../../../Grid'
4
4
  import Card, { CardProps } from './../../../../components/Card'
5
5
 
6
- export interface ExtendedCardProps extends CardProps {
7
- columnconfig?: columnconfig
6
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
7
+ component?: columnconfig['component']
8
+ }
9
+
10
+ export interface ExtendedCardProps extends Omit<CardProps, 'columnconfig'> {
11
+ columnconfig?: ExtendedColumnConfig
8
12
  cellconfig?: cellconfig
9
13
  }
10
14
 
@@ -23,6 +27,17 @@ const useCard = (grid: {
23
27
  ...restProps
24
28
  } = cardProps
25
29
 
30
+ if (
31
+ !itemColumnConfig ||
32
+ typeof itemColumnConfig !== 'object' ||
33
+ typeof itemColumnConfig.row !== 'number' ||
34
+ typeof itemColumnConfig.column !== 'number'
35
+ ) {
36
+ throw new Error(
37
+ 'columnconfig must be an object with row and column as numbers'
38
+ )
39
+ }
40
+
26
41
  // Merge the existing columnconfig with the new props
27
42
  const mergedConfig: columnconfig = {
28
43
  ...itemColumnConfig,
@@ -3,8 +3,13 @@ import React from 'react'
3
3
  import CodeCopy, { CodeCopyProps } from './../../../../components/CodeCopy'
4
4
  import { columnconfig, cellconfig } from '../../../Grid'
5
5
 
6
- export interface ExtendedCodeCopyProps extends CodeCopyProps {
7
- columnconfig?: columnconfig
6
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
7
+ component?: columnconfig['component']
8
+ }
9
+
10
+ export interface ExtendedCodeCopyProps
11
+ extends Omit<CodeCopyProps, 'columnconfig'> {
12
+ columnconfig?: ExtendedColumnConfig
8
13
  cellconfig?: cellconfig
9
14
  }
10
15
 
@@ -25,6 +30,17 @@ const useCodeCopy = (grid: {
25
30
  ...restProps
26
31
  } = codeCopyProps
27
32
 
33
+ if (
34
+ !itemColumnConfig ||
35
+ typeof itemColumnConfig !== 'object' ||
36
+ typeof itemColumnConfig.row !== 'number' ||
37
+ typeof itemColumnConfig.column !== 'number'
38
+ ) {
39
+ throw new Error(
40
+ 'columnconfig must be an object with row and column as numbers'
41
+ )
42
+ }
43
+
28
44
  // Merge the existing columnconfig with the new props
29
45
  const mergedConfig: columnconfig = {
30
46
  ...itemColumnConfig,
@@ -5,9 +5,13 @@ import ConfirmationCodeInputs, {
5
5
  } from '../../../ConfirmationCodeInput'
6
6
  import { columnconfig, cellconfig } from '../../../Grid'
7
7
 
8
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
9
+ component?: columnconfig['component']
10
+ }
11
+
8
12
  export interface ExtendedConfirmationCodeInputsProps
9
- extends ConfirmationCodeInputsProps {
10
- columnconfig?: columnconfig
13
+ extends Omit<ConfirmationCodeInputsProps, 'columnconfig'> {
14
+ columnconfig?: ExtendedColumnConfig
11
15
  cellconfig?: cellconfig
12
16
  }
13
17
 
@@ -30,6 +34,17 @@ const useConfirmationInput = (grid: {
30
34
  ...restProps
31
35
  } = confirmationCodeInputProps
32
36
 
37
+ if (
38
+ !itemColumnConfig ||
39
+ typeof itemColumnConfig !== 'object' ||
40
+ typeof itemColumnConfig.row !== 'number' ||
41
+ typeof itemColumnConfig.column !== 'number'
42
+ ) {
43
+ throw new Error(
44
+ 'columnconfig must be an object with row and column as numbers'
45
+ )
46
+ }
47
+
33
48
  return {
34
49
  ...itemColumnConfig,
35
50
  cellconfig: {
@@ -3,6 +3,10 @@ import React from 'react'
3
3
  import Image from 'next/image'
4
4
  import { columnconfig, cellconfig } from '../../../Grid'
5
5
 
6
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
7
+ component?: columnconfig['component']
8
+ }
9
+
6
10
  type ImageProps = {
7
11
  url: string
8
12
  alt?: string
@@ -11,13 +15,13 @@ type ImageProps = {
11
15
  }
12
16
 
13
17
  export interface ExtendedImageProps extends Omit<ImageProps, 'columnconfig'> {
14
- columnconfig?: columnconfig
18
+ columnconfig?: ExtendedColumnConfig
15
19
  cellconfig?: cellconfig
16
20
  }
17
21
 
18
22
  const useImage = (grid: {
19
23
  image?: ExtendedImageProps | ExtendedImageProps[]
20
- }) => {
24
+ }): columnconfig | columnconfig[] | null => {
21
25
  if (!grid.image) return null
22
26
 
23
27
  const renderImage = (
@@ -32,7 +36,20 @@ const useImage = (grid: {
32
36
  ...restProps
33
37
  } = imageItem
34
38
 
35
- if (!url) return itemColumnConfig || {}
39
+ if (!url) {
40
+ throw new Error('URL is required for image')
41
+ }
42
+
43
+ if (
44
+ !itemColumnConfig ||
45
+ typeof itemColumnConfig !== 'object' ||
46
+ typeof itemColumnConfig.row !== 'number' ||
47
+ typeof itemColumnConfig.column !== 'number'
48
+ ) {
49
+ throw new Error(
50
+ 'columnconfig must be an object with row and column as numbers'
51
+ )
52
+ }
36
53
 
37
54
  return {
38
55
  ...itemColumnConfig,
@@ -55,7 +72,7 @@ const useImage = (grid: {
55
72
  if (Array.isArray(grid.image)) {
56
73
  return grid.image.map(renderImage)
57
74
  } else {
58
- return [renderImage(grid.image, 0)]
75
+ return renderImage(grid.image, 0)
59
76
  }
60
77
  }
61
78
 
@@ -4,15 +4,20 @@ import Link from 'next/link'
4
4
  import { Typography, TypographyProps } from '../../../Typography'
5
5
  import { columnconfig, cellconfig } from '../../../Grid'
6
6
 
7
- export interface ExtendedTypographyProps extends TypographyProps {
8
- columnconfig?: columnconfig
7
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
8
+ component?: columnconfig['component']
9
+ }
10
+
11
+ export interface ExtendedTypographyProps
12
+ extends Omit<TypographyProps, 'columnconfig'> {
13
+ columnconfig?: ExtendedColumnConfig
9
14
  cellconfig?: cellconfig
10
- link?: string
15
+ link: string
11
16
  }
12
17
 
13
18
  const useLink = (grid: {
14
19
  link?: ExtendedTypographyProps | ExtendedTypographyProps[]
15
- }) => {
20
+ }): columnconfig | columnconfig[] | null => {
16
21
  if (!grid.link) return null
17
22
 
18
23
  const renderLink = (
@@ -33,6 +38,17 @@ const useLink = (grid: {
33
38
  throw new Error('Link property is required in ExtendedTypographyProps')
34
39
  }
35
40
 
41
+ if (
42
+ !itemColumnConfig ||
43
+ typeof itemColumnConfig !== 'object' ||
44
+ typeof itemColumnConfig.row !== 'number' ||
45
+ typeof itemColumnConfig.column !== 'number'
46
+ ) {
47
+ throw new Error(
48
+ 'columnconfig must be an object with row and column as numbers'
49
+ )
50
+ }
51
+
36
52
  return {
37
53
  ...itemColumnConfig,
38
54
  cellconfig: {
@@ -53,7 +69,7 @@ const useLink = (grid: {
53
69
  if (Array.isArray(grid.link)) {
54
70
  return grid.link.map(renderLink)
55
71
  } else {
56
- return [renderLink(grid.link, 0)]
72
+ return renderLink(grid.link, 0)
57
73
  }
58
74
  }
59
75
 
@@ -4,8 +4,13 @@ import PricingTable from './../../../../components/PricingTable'
4
4
  import { columnconfig, cellconfig } from '../../../Grid'
5
5
  import { PricingProps } from './../../../../components/PricingTable'
6
6
 
7
- export interface ExtendedPricingProps extends PricingProps {
8
- columnconfig?: columnconfig
7
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
8
+ component?: columnconfig['component']
9
+ }
10
+
11
+ export interface ExtendedPricingProps
12
+ extends Omit<PricingProps, 'columnconfig'> {
13
+ columnconfig?: ExtendedColumnConfig
9
14
  cellconfig?: cellconfig
10
15
  }
11
16
 
@@ -22,6 +27,17 @@ const usePricing = (pricing?: ExtendedPricingProps): columnconfig | null => {
22
27
  ...restProps
23
28
  } = pricingItem
24
29
 
30
+ if (
31
+ !itemColumnConfig ||
32
+ typeof itemColumnConfig !== 'object' ||
33
+ typeof itemColumnConfig.row !== 'number' ||
34
+ typeof itemColumnConfig.column !== 'number'
35
+ ) {
36
+ throw new Error(
37
+ 'columnconfig must be an object with row and column as numbers'
38
+ )
39
+ }
40
+
25
41
  // Merge the existing columnconfig with the new props
26
42
  const mergedConfig: columnconfig = {
27
43
  ...itemColumnConfig,
@@ -3,15 +3,19 @@ import RadioGroup from '../../../RadioGroup'
3
3
  import { columnconfig, cellconfig } from '../../../Grid'
4
4
  import { RadioGroupProps as BaseRadioGroupProps } from '../../../../components/RadioGroup'
5
5
 
6
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
7
+ component?: columnconfig['component']
8
+ }
9
+
6
10
  export interface ExtendedRadioGroupProps
7
11
  extends Omit<BaseRadioGroupProps, 'columnconfig'> {
8
- columnconfig?: columnconfig
12
+ columnconfig?: ExtendedColumnConfig
9
13
  cellconfig?: cellconfig
10
14
  }
11
15
 
12
16
  const useGridRadioGroup = (grid: {
13
17
  radiogroup?: ExtendedRadioGroupProps | ExtendedRadioGroupProps[]
14
- }) => {
18
+ }): columnconfig | columnconfig[] | null => {
15
19
  if (!grid.radiogroup) return null
16
20
 
17
21
  const renderRadioGroup = (
@@ -31,6 +35,17 @@ const useGridRadioGroup = (grid: {
31
35
  ...restProps
32
36
  } = radiogroup
33
37
 
38
+ if (
39
+ !itemColumnConfig ||
40
+ typeof itemColumnConfig !== 'object' ||
41
+ typeof itemColumnConfig.row !== 'number' ||
42
+ typeof itemColumnConfig.column !== 'number'
43
+ ) {
44
+ throw new Error(
45
+ 'columnconfig must be an object with row and column as numbers'
46
+ )
47
+ }
48
+
34
49
  return {
35
50
  ...itemColumnConfig,
36
51
  cellconfig: {
@@ -55,7 +70,7 @@ const useGridRadioGroup = (grid: {
55
70
  if (Array.isArray(grid.radiogroup)) {
56
71
  return grid.radiogroup.map(renderRadioGroup)
57
72
  } else {
58
- return [renderRadioGroup(grid.radiogroup, 0)]
73
+ return renderRadioGroup(grid.radiogroup, 0)
59
74
  }
60
75
  }
61
76
 
@@ -7,25 +7,50 @@ import {
7
7
  import { columnconfig, cellconfig } from '../../../Grid'
8
8
  import { CustomStepperProps as BaseCustomStepperProps } from './../../../../components/Stepper'
9
9
 
10
- export interface ExtendedStepperProps extends BaseCustomStepperProps {
10
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
11
+ component?: columnconfig['component']
12
+ }
13
+
14
+ export interface ExtendedStepperProps
15
+ extends Omit<BaseCustomStepperProps, 'columnconfig'> {
11
16
  cellconfig?: cellconfig
12
- columnconfig?: columnconfig
17
+ columnconfig?: ExtendedColumnConfig
13
18
  }
14
19
 
15
20
  const useStepper = (grid: {
16
21
  stepper?: ExtendedStepperProps | ExtendedStepperProps[]
17
- }) => {
22
+ }): columnconfig | columnconfig[] | null => {
18
23
  if (!grid.stepper) return null
19
24
 
20
- const renderStepper = (stepperProps: ExtendedStepperProps): columnconfig => {
21
- const { steps, columnconfig, cellconfig, ...restProps } = stepperProps
22
- const mergedConfig = {
23
- ...columnconfig,
25
+ const renderStepper = (
26
+ stepperProps: ExtendedStepperProps,
27
+ index: number
28
+ ): columnconfig => {
29
+ const {
30
+ steps,
31
+ columnconfig: itemColumnConfig,
32
+ cellconfig,
33
+ ...restProps
34
+ } = stepperProps
35
+
36
+ if (
37
+ !itemColumnConfig ||
38
+ typeof itemColumnConfig !== 'object' ||
39
+ typeof itemColumnConfig.row !== 'number' ||
40
+ typeof itemColumnConfig.column !== 'number'
41
+ ) {
42
+ throw new Error(
43
+ 'columnconfig must be an object with row and column as numbers'
44
+ )
45
+ }
46
+
47
+ const mergedConfig: columnconfig = {
48
+ ...itemColumnConfig,
24
49
  cellconfig: {
25
50
  ...cellconfig,
26
51
  },
27
52
  component: (
28
- <CustomStepper steps={steps} {...restProps}>
53
+ <CustomStepper key={`stepper-${index}`} steps={steps} {...restProps}>
29
54
  {steps.map(step => (
30
55
  <Step key={step.label}>
31
56
  <StepLabel>{step.label}</StepLabel>
@@ -38,9 +63,9 @@ const useStepper = (grid: {
38
63
  }
39
64
 
40
65
  if (Array.isArray(grid.stepper)) {
41
- return grid.stepper.map(renderStepper)
66
+ return grid.stepper.map((stepper, index) => renderStepper(stepper, index))
42
67
  } else {
43
- return renderStepper(grid.stepper)
68
+ return renderStepper(grid.stepper, 0)
44
69
  }
45
70
  }
46
71
 
@@ -4,8 +4,13 @@ import StyledComponent, {
4
4
  } from '../../../../components/StyledComponent'
5
5
  import { columnconfig, cellconfig } from '../../../Grid'
6
6
 
7
- export interface ExtendedStyledComponentProps extends StyledComponentProps {
8
- columnconfig?: columnconfig
7
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
8
+ component?: columnconfig['component']
9
+ }
10
+
11
+ export interface ExtendedStyledComponentProps
12
+ extends Omit<StyledComponentProps, 'columnconfig'> {
13
+ columnconfig?: ExtendedColumnConfig
9
14
  cellconfig?: cellconfig
10
15
  }
11
16
 
@@ -13,7 +18,7 @@ const useStyledComponent = (grid: {
13
18
  styledcomponent?:
14
19
  | ExtendedStyledComponentProps
15
20
  | ExtendedStyledComponentProps[]
16
- }) => {
21
+ }): columnconfig | columnconfig[] | null => {
17
22
  if (!grid.styledcomponent) return null
18
23
 
19
24
  const renderStyledComponent = (
@@ -40,16 +45,27 @@ const useStyledComponent = (grid: {
40
45
  onChange,
41
46
  defaultValue,
42
47
  inputRef,
43
- columnconfig,
48
+ columnconfig: itemColumnConfig,
44
49
  valuestatus,
45
50
  cellconfig,
46
51
  required,
47
52
  ...restProps
48
53
  } = component
49
54
 
55
+ if (
56
+ !itemColumnConfig ||
57
+ typeof itemColumnConfig !== 'object' ||
58
+ typeof itemColumnConfig.row !== 'number' ||
59
+ typeof itemColumnConfig.column !== 'number'
60
+ ) {
61
+ throw new Error(
62
+ 'columnconfig must be an object with row and column as numbers'
63
+ )
64
+ }
65
+
50
66
  // Merge the cellconfig with the columnconfig
51
67
  const mergedConfig: columnconfig = {
52
- ...columnconfig,
68
+ ...itemColumnConfig,
53
69
  cellconfig: {
54
70
  ...cellconfig,
55
71
  },
@@ -87,7 +103,7 @@ const useStyledComponent = (grid: {
87
103
  if (Array.isArray(grid.styledcomponent)) {
88
104
  return grid.styledcomponent.map(renderStyledComponent)
89
105
  } else {
90
- return [renderStyledComponent(grid.styledcomponent, 0)]
106
+ return renderStyledComponent(grid.styledcomponent, 0)
91
107
  }
92
108
  }
93
109
 
@@ -2,35 +2,53 @@ import React from 'react'
2
2
  import TransferList, { TransferListProps } from '../../../TransferList'
3
3
  import { columnconfig, cellconfig } from '../../../Grid'
4
4
 
5
- export interface ExtendedTransferListProps extends TransferListProps {
6
- columnconfig?: columnconfig
5
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
6
+ component?: columnconfig['component']
7
+ }
8
+
9
+ export interface ExtendedTransferListProps
10
+ extends Omit<TransferListProps, 'columnconfig'> {
11
+ columnconfig?: ExtendedColumnConfig
7
12
  cellconfig?: cellconfig
8
13
  }
9
14
 
10
15
  const useTransferList = (grid: {
11
16
  transferlist?: ExtendedTransferListProps | ExtendedTransferListProps[]
12
- }) => {
17
+ }): columnconfig | columnconfig[] | null => {
13
18
  if (!grid.transferlist) return null
14
19
 
15
20
  const renderTransferList = (
16
- transferListItem: ExtendedTransferListProps
21
+ transferListItem: ExtendedTransferListProps,
22
+ index: number
17
23
  ): columnconfig => {
18
24
  const {
19
25
  leftItems,
20
26
  rightItems,
21
27
  onChange,
22
- columnconfig,
28
+ columnconfig: itemColumnConfig,
23
29
  cellconfig,
24
30
  ...restProps
25
31
  } = transferListItem
26
32
 
33
+ if (
34
+ !itemColumnConfig ||
35
+ typeof itemColumnConfig !== 'object' ||
36
+ typeof itemColumnConfig.row !== 'number' ||
37
+ typeof itemColumnConfig.column !== 'number'
38
+ ) {
39
+ throw new Error(
40
+ 'columnconfig must be an object with row and column as numbers'
41
+ )
42
+ }
43
+
27
44
  const mergedConfig: columnconfig = {
28
- ...columnconfig,
45
+ ...itemColumnConfig,
29
46
  cellconfig: {
30
47
  ...cellconfig,
31
48
  },
32
49
  component: (
33
50
  <TransferList
51
+ key={`transferlist-${index}`}
34
52
  leftItems={leftItems}
35
53
  rightItems={rightItems}
36
54
  onChange={onChange}
@@ -38,14 +56,15 @@ const useTransferList = (grid: {
38
56
  />
39
57
  ),
40
58
  }
41
-
42
59
  return mergedConfig
43
60
  }
44
61
 
45
62
  if (Array.isArray(grid.transferlist)) {
46
- return grid.transferlist.map(renderTransferList)
63
+ return grid.transferlist.map((item, index) =>
64
+ renderTransferList(item, index)
65
+ )
47
66
  } else {
48
- return renderTransferList(grid.transferlist)
67
+ return renderTransferList(grid.transferlist, 0)
49
68
  }
50
69
  }
51
70
 
@@ -2,14 +2,19 @@ import React from 'react'
2
2
  import { Typography, TypographyProps } from '../../../Typography'
3
3
  import { columnconfig, cellconfig } from '../../../Grid'
4
4
 
5
- export interface ExtendedTypographyProps extends TypographyProps {
6
- columnconfig?: columnconfig
5
+ type ExtendedColumnConfig = Omit<columnconfig, 'component'> & {
6
+ component?: columnconfig['component']
7
+ }
8
+
9
+ export interface ExtendedTypographyProps
10
+ extends Omit<TypographyProps, 'columnconfig'> {
11
+ columnconfig?: ExtendedColumnConfig
7
12
  cellconfig?: cellconfig
8
13
  }
9
14
 
10
15
  const useGridTypography = (grid: {
11
16
  typography?: ExtendedTypographyProps | ExtendedTypographyProps[]
12
- }) => {
17
+ }): columnconfig | columnconfig[] | null => {
13
18
  if (!grid.typography) return null
14
19
 
15
20
  const renderTypography = (
@@ -25,6 +30,17 @@ const useGridTypography = (grid: {
25
30
  ...restProps
26
31
  } = typographyItem
27
32
 
33
+ if (
34
+ !itemColumnConfig ||
35
+ typeof itemColumnConfig !== 'object' ||
36
+ typeof itemColumnConfig.row !== 'number' ||
37
+ typeof itemColumnConfig.column !== 'number'
38
+ ) {
39
+ throw new Error(
40
+ 'columnconfig must be an object with row and column as numbers'
41
+ )
42
+ }
43
+
28
44
  return {
29
45
  ...itemColumnConfig,
30
46
  cellconfig: {
@@ -10,7 +10,7 @@ import useStyledComponent, {
10
10
  } from '../../components/Content/Structure/styledcomponent/useStyledComponent'
11
11
  import useGridRadioGroup, {
12
12
  ExtendedRadioGroupProps,
13
- } from '../../components/Content/Structure/radiogroup/useGridRadioGroup'
13
+ } from './Structure/radiogroup/useRadioGroup'
14
14
  import useConfirmationInput, {
15
15
  ExtendedConfirmationCodeInputsProps,
16
16
  } from '../../components/Content/Structure/confirmationinput/useConfirmationInput'
@@ -44,44 +44,35 @@ import useCodeCopy, {
44
44
  * Includes configuration for various content elements.
45
45
  */
46
46
  export interface ContentSectionProps {
47
- /** Grid configuration */
48
- gridconfig?: gridconfig
49
- /** Configuration for confirmation code input */
50
- confirmationcodeinput?:
51
- | ExtendedConfirmationCodeInputsProps
52
- | ExtendedConfirmationCodeInputsProps[]
53
- /** Typography configuration */
54
- typography?: TypographyProps | TypographyProps[]
55
- /** Styled component configuration */
56
- styledcomponent?:
57
- | ExtendedStyledComponentProps
58
- | ExtendedStyledComponentProps[]
59
- /** Radio group configuration */
60
- radiogroup?: ExtendedRadioGroupProps | ExtendedRadioGroupProps[]
61
- /** Link configuration */
62
- link?: LinkProps | LinkProps[]
63
- /** Button configuration */
64
- button?: ExtendedButtonProps | ExtendedButtonProps[]
65
- /** Image configuration */
66
- image?: ExtendedImageProps | ExtendedImageProps[]
67
- /** Pricing configuration */
68
- pricing?: ExtendedPricingProps
69
- /** Stepper configuration */
70
- stepper?: ExtendedStepperProps | ExtendedStepperProps[]
71
- /** Transfer list configuration */
72
- transferlist?: ExtendedTransferListProps | ExtendedTransferListProps[]
73
- /** Card configuration */
74
- card?: ExtendedCardProps | ExtendedCardProps[]
75
- /** Code copy configuration */
76
- codecopy?: ExtendedCodeCopyProps | ExtendedCodeCopyProps[]
47
+ grids: Array<{
48
+ grid: {
49
+ gridconfig?: gridconfig
50
+ }
51
+ confirmationcodeinput?:
52
+ | ExtendedConfirmationCodeInputsProps
53
+ | ExtendedConfirmationCodeInputsProps[]
54
+ typography?: TypographyProps | TypographyProps[]
55
+ styledcomponent?:
56
+ | ExtendedStyledComponentProps
57
+ | ExtendedStyledComponentProps[]
58
+ radiogroup?: ExtendedRadioGroupProps | ExtendedRadioGroupProps[]
59
+ link?: LinkProps | LinkProps[]
60
+ button?: ExtendedButtonProps | ExtendedButtonProps[]
61
+ image?: ExtendedImageProps | ExtendedImageProps[]
62
+ pricing?: ExtendedPricingProps
63
+ stepper?: ExtendedStepperProps | ExtendedStepperProps[]
64
+ transferlist?: ExtendedTransferListProps | ExtendedTransferListProps[]
65
+ card?: ExtendedCardProps | ExtendedCardProps[]
66
+ codecopy?: ExtendedCodeCopyProps | ExtendedCodeCopyProps[]
67
+ }>
77
68
  }
78
69
 
79
70
  /**
80
71
  * RenderContent component handles the rendering of various content elements
81
72
  * based on the provided configuration.
82
73
  */
83
- const RenderContent: React.FC<ContentSectionProps> = ({
84
- gridconfig,
74
+ const RenderContent: React.FC<ContentSectionProps['grids'][0]> = ({
75
+ grid,
85
76
  ...props
86
77
  }) => {
87
78
  let columnConfigs: columnconfig[] = []
@@ -113,22 +104,20 @@ const RenderContent: React.FC<ContentSectionProps> = ({
113
104
  addToColumnConfigs(useCard(props))
114
105
  addToColumnConfigs(useCodeCopy(props))
115
106
 
116
- return <CustomGrid gridconfig={gridconfig} columnconfig={columnConfigs} />
107
+ return (
108
+ <CustomGrid gridconfig={grid.gridconfig} columnconfig={columnConfigs} />
109
+ )
117
110
  }
118
111
 
119
112
  /**
120
113
  * ContentSection component renders multiple grids based on the provided configuration.
121
114
  * @param grids An array of ContentSectionProps, each representing a grid to be rendered.
122
115
  */
123
- export default function ContentSection({
124
- grids,
125
- }: {
126
- grids: ContentSectionProps[]
127
- }) {
116
+ export default function ContentSection({ grids }: ContentSectionProps) {
128
117
  return (
129
118
  <>
130
- {grids.map((grid, index) => (
131
- <RenderContent key={index} {...grid} />
119
+ {grids.map((gridProps, index) => (
120
+ <RenderContent key={index} {...gridProps} />
132
121
  ))}
133
122
  </>
134
123
  )
@@ -1,11 +1,11 @@
1
1
  'use client'
2
-
3
- import React from 'react'
2
+ import React, { forwardRef, useImperativeHandle, useRef } from 'react'
4
3
  import { Close } from '@mui/icons-material'
5
4
  import { Dialog, IconButton, Box } from '@mui/material'
6
5
  import ContentSection, { ContentSectionProps } from '../../Content'
7
6
  import { formContainerStyle } from './../../../styles/Form'
8
7
  import { ExtendedTypographyProps } from '../../Content/Structure/typography/useGridTypography'
8
+ import Typography from '../../Typography'
9
9
 
10
10
  /**
11
11
  * Props for the PopupForm component.
@@ -19,103 +19,137 @@ export interface PopupFormProps {
19
19
  open: boolean
20
20
  /** Function to call when closing the dialog */
21
21
  onClose: () => void
22
- /** Array of ContentSectionProps to render the form content */
23
- grids: ContentSectionProps[]
22
+ /** ContentSectionProps to render the form content */
23
+ grids: ContentSectionProps['grids']
24
+ /** Optional function to handle form submission */
25
+ onSubmit?: () => void
24
26
  }
25
27
 
26
28
  /**
27
29
  * PopupForm component renders a popup form with a title, description, and content sections.
28
30
  * It uses the ContentSection component to render the form content within a Material-UI Dialog.
31
+ * Handles form submission and displays submitted data internally.
29
32
  *
30
33
  * @param props The props for the PopupForm component.
34
+ * @param ref Ref forwarded to the form element.
31
35
  * @returns The rendered popup form.
32
36
  */
33
- function PopupForm({
34
- title,
35
- description,
36
- open,
37
- onClose,
38
- grids,
39
- }: PopupFormProps) {
40
- /**
41
- * headerGrid contains the grid configuration for the form header.
42
- * It includes the title and description as typography items.
43
- */
44
- const headerGrid: ContentSectionProps = {
45
- gridconfig: {
46
- gridname: 'formHeader',
47
- margintop: 0,
48
- marginbottom: 1,
49
- marginleft: 0,
50
- marginright: 0,
51
- gridwidth: '100%',
52
- },
53
- typography: [
54
- {
55
- text: title,
56
- fontvariant: 'merrih5',
57
- fontcolor: 'black',
58
- columnconfig: {
59
- row: 1,
60
- column: 1,
37
+ const PopupForm = forwardRef<HTMLFormElement, PopupFormProps>(
38
+ ({ title, description, open, onClose, grids, onSubmit }, ref) => {
39
+ const [submittedData, setSubmittedData] = React.useState<
40
+ Record<string, string>
41
+ >({})
42
+ const internalFormRef = useRef<HTMLFormElement>(null)
43
+
44
+ useImperativeHandle(ref, () => internalFormRef.current as HTMLFormElement)
45
+
46
+ /**
47
+ * headerGrid contains the grid configuration for the form header.
48
+ * It includes the title and description as typography items.
49
+ */
50
+ const headerGrid: ContentSectionProps['grids'][0] = {
51
+ grid: {
52
+ gridconfig: {
61
53
  gridname: 'formHeader',
62
- columnwidth: '100%',
63
- alignment: 'left',
64
- marginbottom: 0.5,
65
- },
66
- cellconfig: {
67
- border: 'none',
54
+ marginbottom: 1,
55
+ gridwidth: '100%',
68
56
  },
69
57
  },
70
- {
71
- text: description,
72
- fontvariant: 'merriparagraph',
73
- fontcolor: 'black',
74
- columnconfig: {
75
- row: 2,
76
- column: 1,
77
- gridname: 'formHeader',
78
- columnwidth: '100%',
79
- marginbottom: 0,
58
+ typography: [
59
+ {
60
+ text: title,
61
+ fontvariant: 'merrih5',
62
+ fontcolor: 'black',
63
+ columnconfig: {
64
+ column: 1,
65
+ gridname: 'formHeader',
66
+ columnwidth: '100%',
67
+ alignment: 'left',
68
+ marginbottom: 0.5,
69
+ },
80
70
  },
81
- cellconfig: {
82
- border: 'none',
71
+ {
72
+ text: description,
73
+ fontvariant: 'merriparagraph',
74
+ fontcolor: 'black',
75
+ columnconfig: {
76
+ column: 1,
77
+ gridname: 'formHeader',
78
+ columnwidth: '100%',
79
+ },
83
80
  },
84
- },
85
- ] as ExtendedTypographyProps[],
86
- }
81
+ ] as ExtendedTypographyProps[],
82
+ }
87
83
 
88
- /** Combine the header grid with the provided content grids */
89
- const contentSectionGrids: ContentSectionProps[] = [headerGrid, ...grids]
84
+ /** Combine the header grid with the provided content grids */
85
+ const contentSectionGrids: ContentSectionProps['grids'] = [
86
+ headerGrid,
87
+ ...grids,
88
+ ]
90
89
 
91
- return (
92
- <Dialog open={open} onClose={onClose} fullWidth maxWidth="sm">
93
- {/* Close button */}
94
- <IconButton
95
- size="small"
96
- onClick={onClose}
97
- sx={{
98
- position: 'absolute',
99
- right: 8,
100
- top: 8,
101
- color: theme => theme.palette.grey[500],
102
- }}
103
- >
104
- <Close />
105
- </IconButton>
90
+ /**
91
+ * Handles form submission and processes form data internally.
92
+ * @param event - The form submission event
93
+ */
94
+ const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
95
+ event.preventDefault()
96
+ const formData = new FormData(event.currentTarget)
97
+ const data: Record<string, string> = {}
106
98
 
107
- {/* Form container */}
108
- <Box
109
- // @ts-ignore
110
- sx={formContainerStyle}
111
- >
112
- <form>
113
- {/* Render the form content using ContentSection */}
114
- <ContentSection grids={contentSectionGrids} />
115
- </form>
116
- </Box>
117
- </Dialog>
118
- )
119
- }
99
+ formData.forEach((value, key) => {
100
+ data[key] = value.toString()
101
+ })
102
+
103
+ setSubmittedData(data)
104
+
105
+ if (onSubmit) {
106
+ onSubmit()
107
+ }
108
+ }
109
+
110
+ return (
111
+ <Dialog open={open} onClose={onClose} fullWidth maxWidth="sm">
112
+ {/* Close button */}
113
+ <IconButton
114
+ size="small"
115
+ onClick={onClose}
116
+ sx={{
117
+ position: 'absolute',
118
+ right: 8,
119
+ top: 8,
120
+ color: theme => theme.palette.grey[500],
121
+ }}
122
+ >
123
+ <Close />
124
+ </IconButton>
125
+ {/* Form container */}
126
+ <Box
127
+ // @ts-ignore
128
+ sx={formContainerStyle}
129
+ >
130
+ <form onSubmit={handleSubmit} ref={internalFormRef}>
131
+ {/* Render the form content using ContentSection */}
132
+ <ContentSection grids={contentSectionGrids} />
133
+ </form>
134
+ {/* Display submitted data */}
135
+ {Object.keys(submittedData).length > 0 && (
136
+ <Box mt={2}>
137
+ <Typography fontvariant="merrih6" text="Submitted Data:" />
138
+ {Object.entries(submittedData).map(([key, value]) => (
139
+ <Typography
140
+ key={key}
141
+ fontvariant="merriparagraph"
142
+ text={`${key}: ${value}`}
143
+ />
144
+ ))}
145
+ </Box>
146
+ )}
147
+ </Box>
148
+ </Dialog>
149
+ )
150
+ }
151
+ )
152
+
153
+ PopupForm.displayName = 'PopupForm'
120
154
 
121
155
  export default PopupForm
@@ -13,8 +13,8 @@ export type BorderProp = 'none' | 'solid'
13
13
  * Configuration for individual columns within the grid
14
14
  */
15
15
  export interface columnconfig {
16
- row?: number
17
- column?: number
16
+ row: number
17
+ column: number
18
18
  gridname?: string
19
19
  alignment?: Alignment
20
20
  margintop?: number
@@ -116,12 +116,20 @@ const defaultConfig: PricingProps = {
116
116
  },
117
117
  },
118
118
  tiedtopackage: {
119
- row: 1,
120
- column: 2,
121
119
  tiedtopackages: 'true',
122
- mobilewidth: '20%',
123
- tabletwidth: '50%',
124
- computerwidth: '50%',
120
+ columnconfig: {
121
+ row: 1,
122
+ column: 2,
123
+ mobilewidth: '20%',
124
+ tabletwidth: '50%',
125
+ computerwidth: '50%',
126
+ gridname: 'pricingtablefeatures',
127
+ alignment: 'center' as Alignment,
128
+ cellconfig: {
129
+ border: 'solid',
130
+ minHeight: '40px',
131
+ },
132
+ },
125
133
  },
126
134
  subfeatures: [
127
135
  {
@@ -143,12 +151,20 @@ const defaultConfig: PricingProps = {
143
151
  },
144
152
  },
145
153
  tiedtopackage: {
146
- row: 2,
147
- column: 2,
148
154
  tiedtopackages: 'true',
149
- mobilewidth: '20%',
150
- tabletwidth: '50%',
151
- computerwidth: '50%',
155
+ columnconfig: {
156
+ row: 2,
157
+ column: 2,
158
+ mobilewidth: '20%',
159
+ tabletwidth: '50%',
160
+ computerwidth: '50%',
161
+ gridname: 'pricingtablefeatures',
162
+ alignment: 'center' as Alignment,
163
+ cellconfig: {
164
+ border: 'solid',
165
+ minHeight: '40px',
166
+ },
167
+ },
152
168
  },
153
169
  },
154
170
  {
@@ -170,12 +186,20 @@ const defaultConfig: PricingProps = {
170
186
  },
171
187
  },
172
188
  tiedtopackage: {
173
- row: 3,
174
- column: 2,
175
189
  tiedtopackages: 'true',
176
- mobilewidth: '20%',
177
- tabletwidth: '50%',
178
- computerwidth: '50%',
190
+ columnconfig: {
191
+ row: 3,
192
+ column: 2,
193
+ mobilewidth: '20%',
194
+ tabletwidth: '50%',
195
+ computerwidth: '50%',
196
+ gridname: 'pricingtablefeatures',
197
+ alignment: 'center' as Alignment,
198
+ cellconfig: {
199
+ border: 'solid',
200
+ minHeight: '40px',
201
+ },
202
+ },
179
203
  },
180
204
  },
181
205
  ],
@@ -198,12 +222,20 @@ const defaultConfig: PricingProps = {
198
222
  },
199
223
  },
200
224
  tiedtopackage: {
201
- row: 4,
202
- column: 2,
203
225
  tiedtopackages: 'true',
204
- mobilewidth: '20%',
205
- tabletwidth: '50%',
206
- computerwidth: '50%',
226
+ columnconfig: {
227
+ row: 4,
228
+ column: 2,
229
+ mobilewidth: '20%',
230
+ tabletwidth: '50%',
231
+ computerwidth: '50%',
232
+ gridname: 'pricingtablefeatures',
233
+ alignment: 'center' as Alignment,
234
+ cellconfig: {
235
+ border: 'solid',
236
+ minHeight: '40px',
237
+ },
238
+ },
207
239
  },
208
240
  subfeatures: [
209
241
  {
@@ -225,12 +257,20 @@ const defaultConfig: PricingProps = {
225
257
  },
226
258
  },
227
259
  tiedtopackage: {
228
- row: 5,
229
- column: 2,
230
260
  tiedtopackages: 'true',
231
- mobilewidth: '20%',
232
- tabletwidth: '50%',
233
- computerwidth: '50%',
261
+ columnconfig: {
262
+ row: 5,
263
+ column: 2,
264
+ mobilewidth: '20%',
265
+ tabletwidth: '50%',
266
+ computerwidth: '50%',
267
+ gridname: 'pricingtablefeatures',
268
+ alignment: 'center' as Alignment,
269
+ cellconfig: {
270
+ border: 'solid',
271
+ minHeight: '40px',
272
+ },
273
+ },
234
274
  },
235
275
  },
236
276
  {
@@ -252,12 +292,20 @@ const defaultConfig: PricingProps = {
252
292
  },
253
293
  },
254
294
  tiedtopackage: {
255
- row: 6,
256
- column: 2,
257
295
  tiedtopackages: 'true',
258
- mobilewidth: '20%',
259
- tabletwidth: '50%',
260
- computerwidth: '50%',
296
+ columnconfig: {
297
+ row: 6,
298
+ column: 2,
299
+ mobilewidth: '20%',
300
+ tabletwidth: '50%',
301
+ computerwidth: '50%',
302
+ gridname: 'pricingtablefeatures',
303
+ alignment: 'center' as Alignment,
304
+ cellconfig: {
305
+ border: 'solid',
306
+ minHeight: '40px',
307
+ },
308
+ },
261
309
  },
262
310
  },
263
311
  ],
@@ -7,8 +7,8 @@ import { Typography } from '../Typography'
7
7
  import StyledTooltip from '../Tooltip'
8
8
  import CustomButton from '../Button'
9
9
  import StyledComponent from '../StyledComponent'
10
- import CustomGrid from '@/components/Grid'
11
- import { columnconfig, gridconfig } from '@/components/Grid/'
10
+ import CustomGrid from './../../components/Grid'
11
+ import { columnconfig, gridconfig } from './../../components/Grid/'
12
12
  import defaultConfig from './defaultconfig'
13
13
  import { useRouter } from 'next/navigation'
14
14
  import {
@@ -19,6 +19,11 @@ import {
19
19
  aqua,
20
20
  } from '../../styles/palette'
21
21
 
22
+ type TiedToPackage = {
23
+ tiedtopackages?: string
24
+ columnconfig?: Omit<columnconfig, 'component'>
25
+ }
26
+
22
27
  /**
23
28
  * Interface for sub-features in the pricing table
24
29
  */
@@ -26,15 +31,8 @@ interface SubFeature {
26
31
  title: string
27
32
  titlelink?: string
28
33
  infopopuptext?: string
29
- columnconfig?: columnconfig
30
- tiedtopackage?: {
31
- row?: number
32
- column?: number
33
- tiedtopackages?: string
34
- mobilewidth?: string
35
- tabletwidth?: string
36
- computerwidth?: string
37
- }
34
+ columnconfig?: Omit<columnconfig, 'component'>
35
+ tiedtopackage?: TiedToPackage
38
36
  }
39
37
 
40
38
  /**
@@ -45,15 +43,8 @@ interface Feature {
45
43
  infopopuptext?: string
46
44
  titlelink?: string
47
45
  subfeatures: SubFeature[]
48
- columnconfig?: columnconfig
49
- tiedtopackage?: {
50
- row?: number
51
- column?: number
52
- tiedtopackages?: string
53
- mobilewidth?: string
54
- tabletwidth?: string
55
- computerwidth?: string
56
- }
46
+ columnconfig?: Omit<columnconfig, 'component'>
47
+ tiedtopackage?: TiedToPackage
57
48
  }
58
49
 
59
50
  /**
@@ -184,11 +175,7 @@ const PricingTable: React.FC<PricingProps> = props => {
184
175
  featureColumnConfigs.push({
185
176
  ...feature.columnconfig,
186
177
  component: (
187
- <Box
188
- // @ts-ignore
189
- display="flex"
190
- alignItems="center"
191
- >
178
+ <Box display="flex" alignItems="center">
192
179
  <Typography
193
180
  text={feature.title}
194
181
  fontcolor={black.main}
@@ -211,13 +198,13 @@ const PricingTable: React.FC<PricingProps> = props => {
211
198
  )}
212
199
  </Box>
213
200
  ),
214
- })
201
+ } as columnconfig)
215
202
  }
216
203
 
217
204
  // Render feature checkbox
218
- if (feature.tiedtopackage) {
219
- featureColumnConfigs.push({
220
- ...feature.tiedtopackage,
205
+ if (feature.tiedtopackage && feature.tiedtopackage.columnconfig) {
206
+ const tiedConfig: columnconfig = {
207
+ ...feature.tiedtopackage.columnconfig,
221
208
  cellconfig: {
222
209
  border: 'solid',
223
210
  minHeight: '40px',
@@ -225,12 +212,10 @@ const PricingTable: React.FC<PricingProps> = props => {
225
212
  component: feature.tiedtopackage.tiedtopackages ? (
226
213
  <CheckCircleIcon />
227
214
  ) : (
228
- <Box
229
- // @ts-ignore
230
- sx={{ width: '24px', height: '24px' }}
231
- />
215
+ <Box sx={{ width: '24px', height: '24px' }} />
232
216
  ),
233
- })
217
+ }
218
+ featureColumnConfigs.push(tiedConfig)
234
219
  }
235
220
 
236
221
  // Render subfeatures
@@ -262,13 +247,13 @@ const PricingTable: React.FC<PricingProps> = props => {
262
247
  )}
263
248
  </Box>
264
249
  ),
265
- })
250
+ } as columnconfig)
266
251
  }
267
252
 
268
253
  // Render subfeature checkbox
269
- if (subFeature.tiedtopackage) {
270
- featureColumnConfigs.push({
271
- ...subFeature.tiedtopackage,
254
+ if (subFeature.tiedtopackage && subFeature.tiedtopackage.columnconfig) {
255
+ const tiedConfig: columnconfig = {
256
+ ...subFeature.tiedtopackage.columnconfig,
272
257
  cellconfig: {
273
258
  border: 'solid',
274
259
  minHeight: '40px',
@@ -278,7 +263,8 @@ const PricingTable: React.FC<PricingProps> = props => {
278
263
  ) : (
279
264
  <Box sx={{ width: '24px', height: '24px' }} />
280
265
  ),
281
- })
266
+ }
267
+ featureColumnConfigs.push(tiedConfig)
282
268
  }
283
269
  })
284
270
  }
package/src/index.ts CHANGED
@@ -38,6 +38,7 @@ import PricingTable, { PricingProps } from './components/PricingTable'
38
38
  import { CustomStepper, CustomStepperProps } from './components/Stepper'
39
39
  import CustomToolbar, { ToolbarProps } from './components/Toolbar'
40
40
  import TransferList, { TransferListProps } from './components/TransferList'
41
+ import StyledTooltip, { CustomTooltipProps } from './components/Tooltip'
41
42
  import React from 'react'
42
43
 
43
44
  // Animations
@@ -139,6 +140,9 @@ declare type CustomToolbarComponentProps = React.ComponentProps<
139
140
  declare type TransferListComponentProps = React.ComponentProps<
140
141
  typeof TransferList
141
142
  >
143
+ declare type StyledTooltipComponentProps = React.ComponentProps<
144
+ typeof StyledTooltip
145
+ >
142
146
 
143
147
  // Named exports
144
148
  export { CustomButton }
@@ -157,6 +161,7 @@ export { PricingTable }
157
161
  export { CustomStepper }
158
162
  export { CustomToolbar }
159
163
  export { TransferList }
164
+ export { StyledTooltip }
160
165
  export { formContainerStyle }
161
166
 
162
167
  // Exporting ExtendedButtonProps
@@ -185,6 +190,7 @@ export type { PricingProps }
185
190
  export type { CustomStepperProps }
186
191
  export type { ToolbarProps }
187
192
  export type { TransferListProps }
193
+ export type { CustomTooltipProps }
188
194
 
189
195
  // Additional type exports for the newly declared types
190
196
  export type { TypographyComponentProps }
@@ -200,6 +206,7 @@ export type { PricingTableComponentProps }
200
206
  export type { CustomStepperComponentProps }
201
207
  export type { CustomToolbarComponentProps }
202
208
  export type { TransferListComponentProps }
209
+ export type { StyledTooltipComponentProps }
203
210
 
204
211
  // Animation type export
205
212
  export type { Animation }