goobs-frontend 0.7.69 → 0.7.71
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/README.md +186 -10
- package/package.json +5 -5
- package/src/components/Dropdown/index.tsx +97 -13
- package/src/components/Grid/index.tsx +7 -8
- package/src/components/Nav/VerticalVariant/index.tsx +216 -230
- package/src/components/PricingTable/defaultconfig.tsx +23 -10
- package/src/components/PricingTable/index.tsx +45 -56
- package/src/components/TransferList/index.tsx +11 -58
- package/src/index.ts +31 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { Box, Paper } from '@mui/material'
|
|
2
|
+
import React, { useState, useCallback, useMemo } from 'react'
|
|
3
|
+
import { Box, Paper, SelectChangeEvent } from '@mui/material'
|
|
4
4
|
import InfoIcon from '@mui/icons-material/Info'
|
|
5
5
|
import CheckCircleIcon from '@mui/icons-material/CheckCircle'
|
|
6
6
|
import { Typography } from '../Typography'
|
|
@@ -20,13 +20,10 @@ import {
|
|
|
20
20
|
} from '../../styles/palette'
|
|
21
21
|
|
|
22
22
|
type TiedToPackage = {
|
|
23
|
-
tiedtopackages?: string
|
|
23
|
+
tiedtopackages?: string[]
|
|
24
24
|
columnconfig?: Omit<columnconfig, 'component'>
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* Interface for sub-features in the pricing table
|
|
29
|
-
*/
|
|
30
27
|
interface SubFeature {
|
|
31
28
|
title: string
|
|
32
29
|
titlelink?: string
|
|
@@ -35,9 +32,6 @@ interface SubFeature {
|
|
|
35
32
|
tiedtopackage?: TiedToPackage
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
/**
|
|
39
|
-
* Interface for main features in the pricing table
|
|
40
|
-
*/
|
|
41
35
|
interface Feature {
|
|
42
36
|
title: string
|
|
43
37
|
infopopuptext?: string
|
|
@@ -47,9 +41,6 @@ interface Feature {
|
|
|
47
41
|
tiedtopackage?: TiedToPackage
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
/**
|
|
51
|
-
* Interface for the props of the PricingTable component
|
|
52
|
-
*/
|
|
53
44
|
export interface PricingProps {
|
|
54
45
|
headerGridConfig?: gridconfig
|
|
55
46
|
tabletitle?: {
|
|
@@ -58,46 +49,49 @@ export interface PricingProps {
|
|
|
58
49
|
}
|
|
59
50
|
packagecolumns?: {
|
|
60
51
|
columnheaders?: string
|
|
61
|
-
packagenames?: string
|
|
52
|
+
packagenames?: string[]
|
|
62
53
|
columnconfig?: columnconfig
|
|
63
54
|
}
|
|
64
55
|
monthlyprice?: {
|
|
65
|
-
prices?: string
|
|
56
|
+
prices?: string[]
|
|
66
57
|
columnconfig?: columnconfig
|
|
67
58
|
}
|
|
68
59
|
annualprice?: {
|
|
69
|
-
annualprices?: string
|
|
60
|
+
annualprices?: string[]
|
|
70
61
|
columnconfig?: columnconfig
|
|
71
62
|
}
|
|
72
63
|
featureGridConfig?: gridconfig
|
|
73
64
|
features?: Feature[]
|
|
74
65
|
buttoncolumns?: {
|
|
75
|
-
buttontexts?: string
|
|
76
|
-
buttonlinks?: string
|
|
66
|
+
buttontexts?: string[]
|
|
67
|
+
buttonlinks?: string[]
|
|
77
68
|
columnconfig?: columnconfig
|
|
78
69
|
}
|
|
79
70
|
}
|
|
80
71
|
|
|
81
|
-
/**
|
|
82
|
-
* PricingTable component for rendering a customizable pricing table
|
|
83
|
-
* @param {PricingProps} props - The props for the component
|
|
84
|
-
* @returns {JSX.Element} The rendered PricingTable component
|
|
85
|
-
*/
|
|
86
72
|
const PricingTable: React.FC<PricingProps> = props => {
|
|
87
|
-
// Merge default config with provided props
|
|
88
|
-
const config: PricingProps = { ...defaultConfig, ...props }
|
|
89
|
-
|
|
90
73
|
const router = useRouter()
|
|
74
|
+
const [selectedPackageIndex, setSelectedPackageIndex] = useState(0)
|
|
75
|
+
|
|
76
|
+
const config = useMemo(() => {
|
|
77
|
+
return { ...defaultConfig, ...props }
|
|
78
|
+
}, [props])
|
|
91
79
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
const handlePackageChange = useCallback(
|
|
81
|
+
(event: SelectChangeEvent<unknown>) => {
|
|
82
|
+
const newValue = event.target.value as string
|
|
83
|
+
const newIndex =
|
|
84
|
+
config.packagecolumns?.packagenames?.indexOf(newValue) ?? 0
|
|
85
|
+
setSelectedPackageIndex(newIndex)
|
|
86
|
+
console.log('Package selection changed to:', newValue)
|
|
87
|
+
},
|
|
88
|
+
[config.packagecolumns?.packagenames]
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
const renderColumnConfigs = useCallback(() => {
|
|
97
92
|
const headerColumnConfigs: columnconfig[] = []
|
|
98
93
|
const featureColumnConfigs: columnconfig[] = []
|
|
99
94
|
|
|
100
|
-
// Render table title
|
|
101
95
|
if (config.tabletitle && config.tabletitle.columnconfig) {
|
|
102
96
|
headerColumnConfigs.push({
|
|
103
97
|
...config.tabletitle.columnconfig,
|
|
@@ -112,34 +106,33 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
112
106
|
})
|
|
113
107
|
}
|
|
114
108
|
|
|
115
|
-
// Render package dropdown
|
|
116
109
|
if (config.packagecolumns && config.packagecolumns.columnconfig) {
|
|
117
110
|
headerColumnConfigs.push({
|
|
118
111
|
...config.packagecolumns.columnconfig,
|
|
119
112
|
component: (
|
|
120
113
|
<Dropdown
|
|
121
114
|
label="Packages"
|
|
122
|
-
options={
|
|
123
|
-
|
|
115
|
+
options={(config.packagecolumns.packagenames || []).map(name => ({
|
|
116
|
+
value: name,
|
|
117
|
+
label: name,
|
|
118
|
+
}))}
|
|
119
|
+
defaultValue={config.packagecolumns.packagenames?.[0] || ''}
|
|
124
120
|
backgroundcolor={semiTransparentBlack.main}
|
|
125
121
|
outlinecolor={black.main}
|
|
126
122
|
fontcolor={black.main}
|
|
127
123
|
shrunkfontcolor={black.main}
|
|
128
|
-
onChange={
|
|
129
|
-
console.log('Package selection changed')
|
|
130
|
-
}}
|
|
124
|
+
onChange={handlePackageChange}
|
|
131
125
|
/>
|
|
132
126
|
),
|
|
133
127
|
})
|
|
134
128
|
}
|
|
135
129
|
|
|
136
|
-
// Render monthly price
|
|
137
130
|
if (config.monthlyprice && config.monthlyprice.columnconfig) {
|
|
138
131
|
headerColumnConfigs.push({
|
|
139
132
|
...config.monthlyprice.columnconfig,
|
|
140
133
|
component: (
|
|
141
134
|
<Typography
|
|
142
|
-
text={config.monthlyprice.prices}
|
|
135
|
+
text={config.monthlyprice.prices?.[selectedPackageIndex] || ''}
|
|
143
136
|
fontcolor={black.main}
|
|
144
137
|
fontvariant="merrih5"
|
|
145
138
|
/>
|
|
@@ -147,13 +140,12 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
147
140
|
})
|
|
148
141
|
}
|
|
149
142
|
|
|
150
|
-
// Render annual price
|
|
151
143
|
if (config.annualprice && config.annualprice.columnconfig) {
|
|
152
144
|
headerColumnConfigs.push({
|
|
153
145
|
...config.annualprice.columnconfig,
|
|
154
146
|
component: (
|
|
155
147
|
<Typography
|
|
156
|
-
text={config.annualprice.annualprices}
|
|
148
|
+
text={config.annualprice.annualprices?.[selectedPackageIndex] || ''}
|
|
157
149
|
fontcolor={black.main}
|
|
158
150
|
fontvariant="merrih5"
|
|
159
151
|
/>
|
|
@@ -161,12 +153,7 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
161
153
|
})
|
|
162
154
|
}
|
|
163
155
|
|
|
164
|
-
/**
|
|
165
|
-
* Renders a feature and its subfeatures
|
|
166
|
-
* @param {Feature} feature - The feature to render
|
|
167
|
-
*/
|
|
168
156
|
const renderFeature = (feature: Feature) => {
|
|
169
|
-
// Render main feature
|
|
170
157
|
if (feature.columnconfig) {
|
|
171
158
|
featureColumnConfigs.push({
|
|
172
159
|
...feature.columnconfig,
|
|
@@ -197,14 +184,15 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
197
184
|
} as columnconfig)
|
|
198
185
|
}
|
|
199
186
|
|
|
200
|
-
// Render feature checkbox
|
|
201
187
|
if (feature.tiedtopackage && feature.tiedtopackage.columnconfig) {
|
|
202
188
|
const tiedConfig: columnconfig = {
|
|
203
189
|
...feature.tiedtopackage.columnconfig,
|
|
204
190
|
cellconfig: {
|
|
205
191
|
minHeight: '40px',
|
|
206
192
|
},
|
|
207
|
-
component: feature.tiedtopackage.tiedtopackages
|
|
193
|
+
component: feature.tiedtopackage.tiedtopackages?.[
|
|
194
|
+
selectedPackageIndex
|
|
195
|
+
] ? (
|
|
208
196
|
<CheckCircleIcon />
|
|
209
197
|
) : (
|
|
210
198
|
<Box sx={{ width: '24px', height: '24px' }} />
|
|
@@ -213,7 +201,6 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
213
201
|
featureColumnConfigs.push(tiedConfig)
|
|
214
202
|
}
|
|
215
203
|
|
|
216
|
-
// Render subfeatures
|
|
217
204
|
feature.subfeatures.forEach(subFeature => {
|
|
218
205
|
if (subFeature.columnconfig) {
|
|
219
206
|
featureColumnConfigs.push({
|
|
@@ -245,14 +232,15 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
245
232
|
} as columnconfig)
|
|
246
233
|
}
|
|
247
234
|
|
|
248
|
-
// Render subfeature checkbox
|
|
249
235
|
if (subFeature.tiedtopackage && subFeature.tiedtopackage.columnconfig) {
|
|
250
236
|
const tiedConfig: columnconfig = {
|
|
251
237
|
...subFeature.tiedtopackage.columnconfig,
|
|
252
238
|
cellconfig: {
|
|
253
239
|
minHeight: '40px',
|
|
254
240
|
},
|
|
255
|
-
component: subFeature.tiedtopackage.tiedtopackages
|
|
241
|
+
component: subFeature.tiedtopackage.tiedtopackages?.[
|
|
242
|
+
selectedPackageIndex
|
|
243
|
+
] ? (
|
|
256
244
|
<CheckCircleIcon />
|
|
257
245
|
) : (
|
|
258
246
|
<Box sx={{ width: '24px', height: '24px' }} />
|
|
@@ -263,12 +251,11 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
263
251
|
})
|
|
264
252
|
}
|
|
265
253
|
|
|
266
|
-
// Render all features
|
|
267
254
|
config.features?.forEach(renderFeature)
|
|
268
255
|
|
|
269
|
-
// Render button columns
|
|
270
256
|
if (config.buttoncolumns && config.buttoncolumns.columnconfig) {
|
|
271
|
-
const buttonLink =
|
|
257
|
+
const buttonLink =
|
|
258
|
+
config.buttoncolumns.buttonlinks?.[selectedPackageIndex] || '#'
|
|
272
259
|
|
|
273
260
|
featureColumnConfigs.push({
|
|
274
261
|
...config.buttoncolumns.columnconfig,
|
|
@@ -280,14 +267,16 @@ const PricingTable: React.FC<PricingProps> = props => {
|
|
|
280
267
|
href={buttonLink}
|
|
281
268
|
width="100%"
|
|
282
269
|
onClick={() => router.push(buttonLink)}
|
|
283
|
-
text={
|
|
270
|
+
text={
|
|
271
|
+
config.buttoncolumns.buttontexts?.[selectedPackageIndex] || ''
|
|
272
|
+
}
|
|
284
273
|
/>
|
|
285
274
|
),
|
|
286
275
|
})
|
|
287
276
|
}
|
|
288
277
|
|
|
289
278
|
return { headerColumnConfigs, featureColumnConfigs }
|
|
290
|
-
}
|
|
279
|
+
}, [config, selectedPackageIndex, router, handlePackageChange])
|
|
291
280
|
|
|
292
281
|
const { headerColumnConfigs, featureColumnConfigs } = renderColumnConfigs()
|
|
293
282
|
|
|
@@ -10,40 +10,20 @@ import Checkbox from '@mui/material/Checkbox'
|
|
|
10
10
|
import Button from '@mui/material/Button'
|
|
11
11
|
import Paper from '@mui/material/Paper'
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Returns the elements in array 'a' that are not in array 'b'
|
|
15
|
-
* @param {readonly string[]} a - The first array
|
|
16
|
-
* @param {readonly string[]} b - The second array
|
|
17
|
-
* @returns {string[]} The elements in 'a' that are not in 'b'
|
|
18
|
-
*/
|
|
19
13
|
function not(a: readonly string[], b: readonly string[]) {
|
|
20
14
|
return a.filter(value => b.indexOf(value) === -1)
|
|
21
15
|
}
|
|
22
16
|
|
|
23
|
-
/**
|
|
24
|
-
* Returns the common elements between arrays 'a' and 'b'
|
|
25
|
-
* @param {readonly string[]} a - The first array
|
|
26
|
-
* @param {readonly string[]} b - The second array
|
|
27
|
-
* @returns {string[]} The common elements between 'a' and 'b'
|
|
28
|
-
*/
|
|
29
17
|
function intersection(a: readonly string[], b: readonly string[]) {
|
|
30
18
|
return a.filter(value => b.indexOf(value) !== -1)
|
|
31
19
|
}
|
|
32
20
|
|
|
33
|
-
/**
|
|
34
|
-
* Props interface for the TransferList component
|
|
35
|
-
*/
|
|
36
21
|
export interface TransferListProps {
|
|
37
22
|
leftItems: readonly string[]
|
|
38
23
|
rightItems: readonly string[]
|
|
39
|
-
onChange?: (
|
|
24
|
+
onChange?: () => void
|
|
40
25
|
}
|
|
41
26
|
|
|
42
|
-
/**
|
|
43
|
-
* TransferList component that allows moving items between two lists
|
|
44
|
-
* @param {TransferListProps} props - The props for the TransferList component
|
|
45
|
-
* @returns {JSX.Element} The rendered TransferList component
|
|
46
|
-
*/
|
|
47
27
|
const TransferList: React.FC<TransferListProps> = ({
|
|
48
28
|
leftItems,
|
|
49
29
|
rightItems,
|
|
@@ -56,10 +36,6 @@ const TransferList: React.FC<TransferListProps> = ({
|
|
|
56
36
|
const leftChecked = intersection(checked, left)
|
|
57
37
|
const rightChecked = intersection(checked, right)
|
|
58
38
|
|
|
59
|
-
/**
|
|
60
|
-
* Toggles the checked state of an item
|
|
61
|
-
* @param {string} value - The value to toggle
|
|
62
|
-
*/
|
|
63
39
|
const handleToggle = (value: string) => () => {
|
|
64
40
|
const currentIndex = checked.indexOf(value)
|
|
65
41
|
const newChecked = [...checked]
|
|
@@ -73,63 +49,40 @@ const TransferList: React.FC<TransferListProps> = ({
|
|
|
73
49
|
setChecked(newChecked)
|
|
74
50
|
}
|
|
75
51
|
|
|
76
|
-
/**
|
|
77
|
-
* Moves all items from left to right
|
|
78
|
-
*/
|
|
79
52
|
const handleAllRight = () => {
|
|
80
|
-
|
|
81
|
-
setRight(newRight)
|
|
53
|
+
setRight(right.concat(left))
|
|
82
54
|
setLeft([])
|
|
83
55
|
if (onChange) {
|
|
84
|
-
onChange(
|
|
56
|
+
onChange()
|
|
85
57
|
}
|
|
86
58
|
}
|
|
87
59
|
|
|
88
|
-
/**
|
|
89
|
-
* Moves checked items from left to right
|
|
90
|
-
*/
|
|
91
60
|
const handleCheckedRight = () => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
setRight(newRight)
|
|
95
|
-
setLeft(newLeft)
|
|
61
|
+
setRight(right.concat(leftChecked))
|
|
62
|
+
setLeft(not(left, leftChecked))
|
|
96
63
|
setChecked(not(checked, leftChecked))
|
|
97
64
|
if (onChange) {
|
|
98
|
-
onChange(
|
|
65
|
+
onChange()
|
|
99
66
|
}
|
|
100
67
|
}
|
|
101
68
|
|
|
102
|
-
/**
|
|
103
|
-
* Moves checked items from right to left
|
|
104
|
-
*/
|
|
105
69
|
const handleCheckedLeft = () => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
setLeft(newLeft)
|
|
109
|
-
setRight(newRight)
|
|
70
|
+
setLeft(left.concat(rightChecked))
|
|
71
|
+
setRight(not(right, rightChecked))
|
|
110
72
|
setChecked(not(checked, rightChecked))
|
|
111
73
|
if (onChange) {
|
|
112
|
-
onChange(
|
|
74
|
+
onChange()
|
|
113
75
|
}
|
|
114
76
|
}
|
|
115
77
|
|
|
116
|
-
/**
|
|
117
|
-
* Moves all items from right to left
|
|
118
|
-
*/
|
|
119
78
|
const handleAllLeft = () => {
|
|
120
|
-
|
|
121
|
-
setLeft(newLeft)
|
|
79
|
+
setLeft(left.concat(right))
|
|
122
80
|
setRight([])
|
|
123
81
|
if (onChange) {
|
|
124
|
-
onChange(
|
|
82
|
+
onChange()
|
|
125
83
|
}
|
|
126
84
|
}
|
|
127
85
|
|
|
128
|
-
/**
|
|
129
|
-
* Renders a custom list of items
|
|
130
|
-
* @param {readonly string[]} items - The items to render in the list
|
|
131
|
-
* @returns {JSX.Element} The rendered list
|
|
132
|
-
*/
|
|
133
86
|
const customList = (items: readonly string[]) => (
|
|
134
87
|
<Paper sx={{ width: 200, height: 230, overflow: 'auto' }}>
|
|
135
88
|
<List dense component="div" role="list">
|
package/src/index.ts
CHANGED
|
@@ -55,6 +55,21 @@ import { Animation } from './components/Content/Structure/animations'
|
|
|
55
55
|
import { ExtendedButtonProps } from './components/Content/Structure/button/useButton'
|
|
56
56
|
import { ExtendedTypographyProps } from './components/Content/Structure/typography/useGridTypography'
|
|
57
57
|
import { ExtendedTextFieldProps } from './components/Content/Structure/textfield/useTextField'
|
|
58
|
+
import { ExtendedQRCodeProps } from './components/Content/Structure/qrcode/useQRCode'
|
|
59
|
+
import { ExtendedDropdownProps } from './components/Content/Structure/dropdown/useDropdown'
|
|
60
|
+
import { ExtendedDateFieldProps } from './components/Content/Structure/datefield/useDateField'
|
|
61
|
+
import { ExtendedNumberFieldProps } from './components/Content/Structure/numberField/useNumberField'
|
|
62
|
+
import { ExtendedIncrementNumberFieldProps } from './components/Content/Structure/incremementNumberField/useIncremementNumberField'
|
|
63
|
+
import { ExtendedPasswordFieldProps } from './components/Content/Structure/passwordField/usePasswordField'
|
|
64
|
+
import { ExtendedSearchbarProps } from './components/Content/Structure/searchbar/useSearchbar'
|
|
65
|
+
import { ExtendedCodeCopyProps } from './components/Content/Structure/codecopy/useCodeCopy'
|
|
66
|
+
import { ExtendedCardProps } from './components/Content/Structure/card/useCard'
|
|
67
|
+
import { ExtendedTransferListProps } from './components/Content/Structure/transferlist/useTransferList'
|
|
68
|
+
import { ExtendedStepperProps } from './components/Content/Structure/stepper/useStepper'
|
|
69
|
+
import { ExtendedPricingProps } from './components/Content/Structure/pricing/usePricing'
|
|
70
|
+
import { ExtendedImageProps } from './components/Content/Structure/image/useImage'
|
|
71
|
+
import { ExtendedConfirmationCodeInputsProps } from './components/Content/Structure/confirmationinput/useConfirmationInput'
|
|
72
|
+
import { ExtendedRadioGroupProps } from './components/Content/Structure/radiogroup/useRadioGroup'
|
|
58
73
|
|
|
59
74
|
// Colors
|
|
60
75
|
import {
|
|
@@ -201,6 +216,19 @@ export { TextField }
|
|
|
201
216
|
export type { ExtendedButtonProps }
|
|
202
217
|
export type { ExtendedTypographyProps }
|
|
203
218
|
export type { ExtendedTextFieldProps }
|
|
219
|
+
export type { ExtendedNumberFieldProps }
|
|
220
|
+
export type { ExtendedIncrementNumberFieldProps }
|
|
221
|
+
export type { ExtendedPasswordFieldProps }
|
|
222
|
+
export type { ExtendedSearchbarProps }
|
|
223
|
+
export type { ExtendedCodeCopyProps }
|
|
224
|
+
export type { ExtendedCardProps }
|
|
225
|
+
export type { ExtendedTransferListProps }
|
|
226
|
+
export type { ExtendedStepperProps }
|
|
227
|
+
export type { ExtendedPricingProps }
|
|
228
|
+
export type { ExtendedImageProps }
|
|
229
|
+
export type { ExtendedConfirmationCodeInputsProps }
|
|
230
|
+
export type { ExtendedRadioGroupProps }
|
|
231
|
+
|
|
204
232
|
// Type exports
|
|
205
233
|
export type { CustomButtonProps }
|
|
206
234
|
export type { CustomGridProps }
|
|
@@ -219,6 +247,9 @@ export type { ToolbarProps }
|
|
|
219
247
|
export type { TransferListProps }
|
|
220
248
|
export type { CustomTooltipProps }
|
|
221
249
|
export type { QRCodeProps }
|
|
250
|
+
export type { ExtendedQRCodeProps }
|
|
251
|
+
export type { ExtendedDropdownProps }
|
|
252
|
+
export type { ExtendedDateFieldProps }
|
|
222
253
|
|
|
223
254
|
// Additional type exports for the newly declared types
|
|
224
255
|
export type { TypographyComponentProps }
|