@hashicorp/react-components 0.0.0-nightly.91abcef → 0.0.0-nightly.928c674

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 (140) hide show
  1. package/.eslintrc.js +1 -2
  2. package/.stylelintrc.js +1 -1
  3. package/README.md +1 -1
  4. package/package.json +3 -8
  5. package/postcss.config.js +1 -1
  6. package/src/components/nav-panel/components/flight-icon/index.tsx +51 -0
  7. package/src/components/nav-panel/components/flight-icon/style.module.css +3 -0
  8. package/src/components/nav-panel/components/link/index.tsx +127 -0
  9. package/src/components/nav-panel/components/link/style.module.css +64 -0
  10. package/src/components/nav-panel/components/link-list/index.tsx +7 -64
  11. package/src/components/nav-panel/components/link-list/style.module.css +1 -50
  12. package/src/components/nav-panel/components/panel/column/style.module.css +2 -2
  13. package/src/components/nav-panel/components/panel/root/style.module.css +5 -5
  14. package/src/components/nav-panel/components/promo/index.tsx +26 -9
  15. package/src/components/nav-panel/components/promo/style.module.css +33 -19
  16. package/src/components/nav-panel/components/text/index.tsx +34 -0
  17. package/src/components/nav-panel/product-panel/index.tsx +46 -14
  18. package/src/components/nav-panel/product-panel/style.module.css +133 -53
  19. package/src/components/nav-panel/standard-panel/style.module.css +2 -2
  20. package/src/lib/get-localized-link-props/index.ts +2 -3
  21. package/src/lib/parse-url/index.ts +2 -9
  22. package/src/lib/send-posthog-event/index.ts +22 -0
  23. package/src/lib/supported-locales/index.ts +10 -1
  24. package/src/lib/track-nav-click-event/index.ts +4 -4
  25. package/src/components/actions/index.tsx +0 -107
  26. package/src/components/actions/style.module.css +0 -28
  27. package/src/components/actions/types.ts +0 -73
  28. package/src/components/call-to-action/index.tsx +0 -205
  29. package/src/components/call-to-action/styles/variant-centered.module.css +0 -93
  30. package/src/components/call-to-action/styles/variant-compact-grid.module.css +0 -88
  31. package/src/components/call-to-action/styles/variant-compact.module.css +0 -91
  32. package/src/components/call-to-action/styles/variant-links.module.css +0 -85
  33. package/src/components/card/README.md +0 -11
  34. package/src/components/card/card.tsx +0 -45
  35. package/src/components/card/index.test.tsx +0 -69
  36. package/src/components/card/index.tsx +0 -14
  37. package/src/components/card/newsroom-card/index.test.tsx +0 -39
  38. package/src/components/card/newsroom-card/index.tsx +0 -37
  39. package/src/components/card/newsroom-card/style.module.css +0 -12
  40. package/src/components/card/partner-card/index.test.tsx +0 -57
  41. package/src/components/card/partner-card/index.tsx +0 -69
  42. package/src/components/card/partner-card/style.module.css +0 -24
  43. package/src/components/card/person-card/index.test.tsx +0 -71
  44. package/src/components/card/person-card/index.tsx +0 -93
  45. package/src/components/card/person-card/style.module.css +0 -33
  46. package/src/components/card/primitives.tsx +0 -177
  47. package/src/components/card/promo-card/index.tsx +0 -51
  48. package/src/components/card/resource-card/index.test.tsx +0 -48
  49. package/src/components/card/resource-card/index.tsx +0 -40
  50. package/src/components/card/style.module.css +0 -145
  51. package/src/components/card/types.ts +0 -66
  52. package/src/components/card/unified-card/index.spec.tsx +0 -40
  53. package/src/components/card/unified-card/index.tsx +0 -58
  54. package/src/components/intro/index.tsx +0 -82
  55. package/src/components/intro/style.module.css +0 -67
  56. package/src/components/intro/types.ts +0 -44
  57. package/src/components/marketo-form/CHANGELOG.md +0 -122
  58. package/src/components/marketo-form/README.md +0 -1
  59. package/src/components/marketo-form/contexts/FormMetadata.ts +0 -13
  60. package/src/components/marketo-form/docs.mdx +0 -197
  61. package/src/components/marketo-form/fixtures/index.ts +0 -185
  62. package/src/components/marketo-form/form/index.tsx +0 -371
  63. package/src/components/marketo-form/index.test.tsx +0 -320
  64. package/src/components/marketo-form/index.ts +0 -11
  65. package/src/components/marketo-form/package.original.json +0 -30
  66. package/src/components/marketo-form/partials/error-message/index.tsx +0 -12
  67. package/src/components/marketo-form/partials/error-message/style.module.css +0 -13
  68. package/src/components/marketo-form/partials/field/index.tsx +0 -90
  69. package/src/components/marketo-form/partials/field-wrapper/index.tsx +0 -26
  70. package/src/components/marketo-form/partials/fields/checkbox-field/index.tsx +0 -32
  71. package/src/components/marketo-form/partials/fields/email-field/index.tsx +0 -35
  72. package/src/components/marketo-form/partials/fields/form-page-url-field/index.tsx +0 -32
  73. package/src/components/marketo-form/partials/fields/hidden-field/index.tsx +0 -38
  74. package/src/components/marketo-form/partials/fields/htmltext-field/index.tsx +0 -21
  75. package/src/components/marketo-form/partials/fields/htmltext-field/style.module.css +0 -18
  76. package/src/components/marketo-form/partials/fields/name-field/index.tsx +0 -19
  77. package/src/components/marketo-form/partials/fields/name-field/style.module.css +0 -13
  78. package/src/components/marketo-form/partials/fields/radio-buttons-field/index.tsx +0 -48
  79. package/src/components/marketo-form/partials/fields/select-field/index.tsx +0 -39
  80. package/src/components/marketo-form/partials/fields/select-field/style.module.css +0 -5
  81. package/src/components/marketo-form/partials/fields/telephone-field/index.tsx +0 -30
  82. package/src/components/marketo-form/partials/fields/text-field/index.tsx +0 -30
  83. package/src/components/marketo-form/partials/fields/textarea-field/index.tsx +0 -29
  84. package/src/components/marketo-form/partials/label/index.tsx +0 -24
  85. package/src/components/marketo-form/partials/label/style.module.css +0 -12
  86. package/src/components/marketo-form/partials/visibility-rule/index.tsx +0 -84
  87. package/src/components/marketo-form/props.js +0 -66
  88. package/src/components/marketo-form/server/api-routes.ts +0 -109
  89. package/src/components/marketo-form/server/client.ts +0 -98
  90. package/src/components/marketo-form/server/index.ts +0 -8
  91. package/src/components/marketo-form/types.ts +0 -262
  92. package/src/components/marketo-form/utils.test.tsx +0 -103
  93. package/src/components/marketo-form/utils.ts +0 -449
  94. package/src/components/next-steps/index.tsx +0 -138
  95. package/src/components/next-steps/style.module.css +0 -270
  96. package/src/components/next-steps/types.ts +0 -63
  97. package/src/components/product-badge/index.test.tsx +0 -11
  98. package/src/components/product-badge/index.tsx +0 -42
  99. package/src/components/product-badge/style.module.css +0 -76
  100. package/src/components/products-used/index.tsx +0 -84
  101. package/src/components/products-used/style.module.css +0 -87
  102. package/src/components/products-used/types.ts +0 -31
  103. package/src/components/related-content/index.test.tsx +0 -74
  104. package/src/components/related-content/index.tsx +0 -56
  105. package/src/components/related-content/style.module.css +0 -89
  106. package/src/components/related-content/types.ts +0 -21
  107. package/src/components/subnav/helpers/areBasePathsMatching.ts +0 -13
  108. package/src/components/subnav/helpers/traverse/index.ts +0 -42
  109. package/src/components/subnav/helpers/useHeightRef.ts +0 -42
  110. package/src/components/subnav/helpers/useNavRef.ts +0 -30
  111. package/src/components/subnav/helpers/useOverflowRef.ts +0 -85
  112. package/src/components/subnav/helpers/useStuckRef.ts +0 -51
  113. package/src/components/subnav/index.tsx +0 -209
  114. package/src/components/subnav/partials/CtaLinks/github-stars-link/formatStarCount/index.test.ts +0 -26
  115. package/src/components/subnav/partials/CtaLinks/github-stars-link/formatStarCount/index.ts +0 -22
  116. package/src/components/subnav/partials/CtaLinks/github-stars-link/index.tsx +0 -87
  117. package/src/components/subnav/partials/CtaLinks/github-stars-link/parseGithubUrl/index.test.ts +0 -29
  118. package/src/components/subnav/partials/CtaLinks/github-stars-link/parseGithubUrl/index.ts +0 -32
  119. package/src/components/subnav/partials/CtaLinks/github-stars-link/style.module.css +0 -81
  120. package/src/components/subnav/partials/CtaLinks/icons/github-logo.js +0 -20
  121. package/src/components/subnav/partials/CtaLinks/icons/github.svg.js +0 -7
  122. package/src/components/subnav/partials/CtaLinks/icons/star.js +0 -20
  123. package/src/components/subnav/partials/CtaLinks/index.tsx +0 -131
  124. package/src/components/subnav/partials/CtaLinks/style.module.css +0 -45
  125. package/src/components/subnav/partials/DropdownTrigger/index.tsx +0 -35
  126. package/src/components/subnav/partials/DropdownTrigger/style.module.css +0 -39
  127. package/src/components/subnav/partials/MenuItemsDefault/index.tsx +0 -173
  128. package/src/components/subnav/partials/MenuItemsDefault/style.module.css +0 -104
  129. package/src/components/subnav/partials/MenuItemsOverflow/index.tsx +0 -155
  130. package/src/components/subnav/partials/MenuItemsOverflow/style.module.css +0 -88
  131. package/src/components/subnav/partials/TitleLink/index.tsx +0 -115
  132. package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-dark.ts +0 -10
  133. package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-light.ts +0 -10
  134. package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-dark.ts +0 -23
  135. package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-light.ts +0 -23
  136. package/src/components/subnav/partials/TitleLink/style.module.css +0 -43
  137. package/src/components/subnav/partials/nav-item-text/index.tsx +0 -37
  138. package/src/components/subnav/partials/nav-item-text/style.module.css +0 -13
  139. package/src/components/subnav/style.module.css +0 -66
  140. package/src/components/subnav/subnav-consts.ts +0 -1
@@ -1,84 +0,0 @@
1
- /**
2
- * Copyright (c) HashiCorp, Inc.
3
- * SPDX-License-Identifier: MPL-2.0
4
- */
5
-
6
- import { useMemo } from 'react'
7
- import { useFormContext } from 'react-hook-form'
8
- import Field from '../field'
9
- import type {
10
- MarketoFormField,
11
- MarketoFormComponents,
12
- VisibilityRule as VisibilityRuleType,
13
- } from '../../types'
14
-
15
- function ruleApplies(rule: VisibilityRuleType, value: any): boolean {
16
- switch (rule.operator) {
17
- case 'is':
18
- return (
19
- rule.values.includes(value) ||
20
- (value === false && rule.values.includes('no')) ||
21
- (value === true && rule.values.includes('yes'))
22
- )
23
- case 'isNot':
24
- return !rule.values.includes(value)
25
- case 'isEmpty':
26
- return value === null || typeof value === 'undefined' || value === ''
27
- default:
28
- return false
29
- }
30
- }
31
-
32
- const FieldWithVisibilityRule = ({
33
- field,
34
- components,
35
- }: {
36
- field: MarketoFormField
37
- components?: MarketoFormComponents
38
- }) => {
39
- const { watch } = useFormContext()
40
-
41
- // Currently we only support the first defined rule.
42
- const value = watch(field.visibilityRules!.rules![0].subjectField)
43
-
44
- const hasMatchingRule = useMemo(() => {
45
- return field.visibilityRules!.rules!.some((rule) =>
46
- ruleApplies(rule, value)
47
- )
48
- }, [field, value])
49
-
50
- if (
51
- hasMatchingRule &&
52
- (field.visibilityRules!.ruleType === 'show' ||
53
- field.visibilityRules!.ruleType === 'hide')
54
- ) {
55
- return field.visibilityRules!.ruleType === 'show' ? (
56
- <Field field={field} components={components} />
57
- ) : null
58
- }
59
-
60
- // If the ruleType is show, that means the field is hidden by default.
61
- return field.visibilityRules!.ruleType === 'show' ? null : (
62
- <Field field={field} components={components} />
63
- )
64
- }
65
-
66
- const VisibilityRule = ({
67
- field,
68
- components,
69
- }: {
70
- field: MarketoFormField
71
- components?: MarketoFormComponents
72
- }) => {
73
- if (
74
- field.visibilityRules &&
75
- (field.visibilityRules.ruleType === 'show' ||
76
- field.visibilityRules.ruleType === 'hide')
77
- ) {
78
- return <FieldWithVisibilityRule field={field} components={components} />
79
- }
80
-
81
- return <Field field={field} components={components} />
82
- }
83
-
84
- export default VisibilityRule
@@ -1,66 +0,0 @@
1
- /**
2
- * Copyright (c) HashiCorp, Inc.
3
- * SPDX-License-Identifier: MPL-2.0
4
- */
5
-
6
- module.exports = {
7
- formId: {
8
- type: 'number',
9
- required: true,
10
- description:
11
- 'The numeric ID of the Marketo form that this component is rendering.',
12
- },
13
- marketoForm: {
14
- type: 'object',
15
- required: true,
16
- description:
17
- 'The API response containing the fields of the form this component should render.',
18
- },
19
- groups: {
20
- type: 'object',
21
- description:
22
- 'Mapping of fields that should be rendered with a single component.',
23
- },
24
- components: {
25
- type: 'object',
26
- description: 'Custom components to use instead of the built-in components',
27
- properties: {
28
- text: {
29
- type: 'React.ComponentType',
30
- description: 'Component to use for text fields',
31
- },
32
- email: {
33
- type: 'React.ComponentType',
34
- description: 'Component to use for email fields',
35
- },
36
- select: {
37
- type: 'React.ComponentType',
38
- description: 'Component to use for select fields',
39
- },
40
- checkbox: {
41
- type: 'React.ComponentType',
42
- description: 'Component to use for checkbox fields',
43
- },
44
- hidden: {
45
- type: 'React.ComponentType',
46
- description: 'Component to use for hidden fields',
47
- },
48
- },
49
- },
50
- submitTitle: {
51
- type: 'string',
52
- description: 'Title to use for the submit button',
53
- },
54
- className: {
55
- type: 'string',
56
- description: 'Additional classNames passed to the form element.',
57
- },
58
- onSubmitSuccess: {
59
- type: 'function',
60
- description: 'Callback function invoked on submission success',
61
- },
62
- onSubmitFailure: {
63
- type: 'function',
64
- description: 'Callback function invoked on submission failure',
65
- },
66
- }
@@ -1,109 +0,0 @@
1
- /**
2
- * Copyright (c) HashiCorp, Inc.
3
- * SPDX-License-Identifier: MPL-2.0
4
- */
5
-
6
- import * as client from './client'
7
- import { includesSkippedRecords } from '../utils'
8
- import type { SubmissionFilter, MarketoSubmissionResponse } from '../types'
9
- import type { NextApiRequest, NextApiResponse } from 'next'
10
-
11
- async function notifyError(body: unknown, err: unknown) {
12
- if (process.env.MARKETO_ERROR_ZAPIER_WEBHOOK) {
13
- try {
14
- await fetch(process.env.MARKETO_ERROR_ZAPIER_WEBHOOK, {
15
- method: 'POST',
16
- headers: {
17
- 'Content-Type': 'application/json',
18
- },
19
- body: JSON.stringify({ body, err }, null, 2),
20
- })
21
- } catch (err) {
22
- console.error({ body, err })
23
- }
24
- }
25
-
26
- return Promise.resolve()
27
- }
28
-
29
- function isE2ETest(req: NextApiRequest): boolean {
30
- // running e2e tests locally
31
- if (process.env.E2E_TESTS === 'true') {
32
- return true
33
- }
34
-
35
- // running e2e tests against a Vercel preview
36
- if (
37
- 'input' in req.body &&
38
- req.body.input.length > 0 &&
39
- req.body.input[0].leadFormFields.email === 'daniela.rod@example.com'
40
- ) {
41
- return true
42
- }
43
-
44
- return false
45
- }
46
-
47
- async function submitForm(
48
- req: NextApiRequest,
49
- res: NextApiResponse,
50
- {
51
- submissionFilter,
52
- }: {
53
- submissionFilter?: SubmissionFilter
54
- }
55
- ) {
56
- // Don't submit forms to the Marketo API when using E2E tests.
57
- if (isE2ETest(req)) {
58
- res.status(200).json({
59
- requestId: '7d85#181a7ae5e56',
60
- result: [
61
- {
62
- id: 25325329,
63
- status: 'updated',
64
- },
65
- ],
66
- success: true,
67
- })
68
- return
69
- }
70
-
71
- try {
72
- const passesSubmissionFilter = submissionFilter
73
- ? await submissionFilter(req)
74
- : true
75
- if (!passesSubmissionFilter) {
76
- // trick spammers into thinking their form submitted successfully
77
- res.status(200).json({ success: true })
78
- return
79
- }
80
- const marketoRes = await client.submitForm(req.body)
81
- const form = (await marketoRes.json()) as MarketoSubmissionResponse
82
- if (!form.success || includesSkippedRecords(form)) {
83
- await notifyError(req.body, form)
84
- }
85
- res.status(marketoRes.status).json(form)
86
- } catch (err) {
87
- await notifyError(req.body, err)
88
- res.status(500).json({ error: 'internal server error' })
89
- throw err
90
- }
91
- }
92
-
93
- export function buildApiRoutes({
94
- submissionFilter,
95
- }: {
96
- submissionFilter?: SubmissionFilter
97
- } = {}) {
98
- return async function apiRoutes(req: NextApiRequest, res: NextApiResponse) {
99
- const route = Array.isArray(req.query.marketo)
100
- ? req.query.marketo[0]
101
- : req.query.marketo
102
- switch (route) {
103
- case 'submit':
104
- return submitForm(req, res, { submissionFilter })
105
- default:
106
- return res.status(404).json({ error: 'not found' })
107
- }
108
- }
109
- }
@@ -1,98 +0,0 @@
1
- /**
2
- * Copyright (c) HashiCorp, Inc.
3
- * SPDX-License-Identifier: MPL-2.0
4
- */
5
-
6
- import moize from 'moize'
7
- import type {
8
- MarketoFormFieldsResponse,
9
- MarketoFormMetadataResponse,
10
- MarketoFormAPIResponse,
11
- } from '../types'
12
-
13
- interface MarketoTokenResponse {
14
- access_token: string
15
- }
16
-
17
- export async function getToken(): Promise<MarketoTokenResponse> {
18
- const url = new URL(`${process.env.MARKETO_IDENTITY}/oauth/token`)
19
- url.searchParams.append('grant_type', 'client_credentials')
20
- url.searchParams.append('client_id', process.env.MARKETO_CLIENT_ID!)
21
- url.searchParams.append('client_secret', process.env.MARKETO_CLIENT_SECRET!)
22
- const res = await fetch(url.toString())
23
- return await res.json()
24
- }
25
-
26
- export async function getForm(formId: number) {
27
- return await fetch(`https://content.hashicorp.com/api/marketo?id=${formId}`)
28
- }
29
-
30
- export async function getDraftFormProps(formId: number) {
31
- const { access_token } = await getToken()
32
-
33
- const fieldsResponse = await fetch(
34
- `${process.env.MARKETO_ENDPOINT}/asset/v1/form/${formId}/fields.json?status=draft`,
35
- {
36
- headers: {
37
- 'Content-Type': 'application/json',
38
- Authorization: `Bearer ${access_token}`,
39
- },
40
- }
41
- )
42
-
43
- const metadataResponse = await fetch(
44
- `${process.env.MARKETO_ENDPOINT}/asset/v1/form/${formId}.json?status=draft`,
45
- {
46
- headers: {
47
- 'Content-Type': 'application/json',
48
- Authorization: `Bearer ${access_token}`,
49
- },
50
- }
51
- )
52
-
53
- const [fields, metadata] = await Promise.all([
54
- fieldsResponse.json(),
55
- metadataResponse.json(),
56
- ])
57
-
58
- return { fields, metadata }
59
- }
60
-
61
- export async function getFormProps(
62
- id: number
63
- ): Promise<MarketoFormAPIResponse> {
64
- const res = await getForm(id)
65
- if (res.status !== 200) {
66
- throw new Error(
67
- `[marketo-form] non-200 status code when requesting form ${id}: ${res.status}`
68
- )
69
- }
70
-
71
- const form = (await res.json()) as {
72
- result: {
73
- fields: MarketoFormFieldsResponse
74
- metadata: MarketoFormMetadataResponse
75
- }
76
- }
77
-
78
- return form.result
79
- }
80
- export const memoizedGetFormProps = moize(getFormProps, {
81
- isPromise: true,
82
- maxAge: 60 * 1000, // 60 seconds
83
- })
84
-
85
- export async function submitForm(body: unknown) {
86
- const { access_token } = await getToken()
87
- return await fetch(
88
- `${process.env.MARKETO_ENDPOINT}/v1/leads/submitForm.json`,
89
- {
90
- method: 'POST',
91
- headers: {
92
- 'Content-Type': 'application/json',
93
- Authorization: `Bearer ${access_token}`,
94
- },
95
- body: JSON.stringify(body),
96
- }
97
- )
98
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Copyright (c) HashiCorp, Inc.
3
- * SPDX-License-Identifier: MPL-2.0
4
- */
5
-
6
- import { buildApiRoutes } from './api-routes'
7
-
8
- export { buildApiRoutes }
@@ -1,262 +0,0 @@
1
- /**
2
- * Copyright (c) HashiCorp, Inc.
3
- * SPDX-License-Identifier: MPL-2.0
4
- */
5
-
6
- import type { NextApiRequest } from 'next'
7
-
8
- export type MarketoFormDatatype =
9
- | 'text'
10
- | 'email'
11
- | 'telephone'
12
- | 'textArea'
13
- | 'select'
14
- | 'checkbox'
15
- | 'hidden'
16
- | 'htmltext'
17
- | 'radioButtons'
18
- | 'fieldset'
19
-
20
- export interface Autofill {
21
- value: string
22
- valueFrom: string
23
- parameterName: string
24
- }
25
-
26
- export interface VisibilityRule {
27
- subjectField: string
28
- operator: 'is' | 'isNot' | 'isEmpty'
29
- values: string[]
30
- altLabel: string
31
- }
32
-
33
- export interface VisibilityRules {
34
- rules?: VisibilityRule[]
35
- ruleType: 'alwaysShow' | 'show' | 'hide'
36
- }
37
-
38
- export interface MarketoBaseFormField {
39
- id: string
40
- dataType: MarketoFormDatatype
41
- rowNumber: number
42
- columnNumber: number
43
- defaultValue?: string
44
- label?: string
45
- required?: boolean
46
- validationMessage?: string
47
- autoFill?: Autofill
48
- visibilityRules?: VisibilityRules
49
- }
50
-
51
- export interface MarketoFormTextField extends MarketoBaseFormField {
52
- dataType: 'text'
53
- hintText?: string
54
- maxLength?: number
55
- formPrefill?: boolean
56
- }
57
-
58
- export interface MarketoFormEmailField extends MarketoBaseFormField {
59
- dataType: 'email'
60
- hintText?: string
61
- formPrefill: boolean
62
- }
63
-
64
- export interface MarketoFormTelephoneField extends MarketoBaseFormField {
65
- dataType: 'telephone'
66
- hintText?: string
67
- formPrefill: boolean
68
- }
69
-
70
- export interface MarketoFormTextAreaField extends MarketoBaseFormField {
71
- dataType: 'textArea'
72
- hintText?: string
73
- formPrefill: boolean
74
- }
75
-
76
- export interface SelectValue {
77
- label: string
78
- value: string
79
- selected?: boolean
80
- isDefault?: boolean
81
- }
82
-
83
- export interface SelectFieldMetaData {
84
- values?: SelectValue[]
85
- visibleLines?: number
86
- multiSelect?: boolean
87
- }
88
-
89
- export interface MarketoFormSelectField extends MarketoBaseFormField {
90
- dataType: 'select'
91
- fieldMetaData: SelectFieldMetaData
92
- formPrefill: boolean
93
- labelWidth?: number
94
- }
95
-
96
- export interface CheckboxFieldMetaData {
97
- initiallyChecked: boolean
98
- }
99
-
100
- export interface MarketoFormCheckboxField extends MarketoBaseFormField {
101
- dataType: 'checkbox'
102
- fieldMetaData: CheckboxFieldMetaData
103
- formPrefill: boolean
104
- }
105
-
106
- export interface MarketoFormHiddenField extends MarketoBaseFormField {
107
- dataType: 'hidden'
108
- }
109
-
110
- export interface MarketoFormHtmltextField extends MarketoBaseFormField {
111
- dataType: 'htmltext'
112
- labelWidth: number
113
- visibilityRules?: VisibilityRules
114
- text: string
115
- }
116
-
117
- export interface MarketoFormRadioButtonsField extends MarketoBaseFormField {
118
- dataType: 'radioButtons'
119
- fieldWidth?: number
120
- formPrefill?: boolean
121
- fieldMetaData: {
122
- values: Array<{ label: string; value: string }>
123
- }
124
- }
125
-
126
- export interface MarketoFormFieldset extends MarketoBaseFormField {
127
- dataType: 'fieldset'
128
- visibilityRules?: VisibilityRules
129
- fields: Array<string>
130
- }
131
-
132
- export type MarketoFormField =
133
- | MarketoFormTextField
134
- | MarketoFormEmailField
135
- | MarketoFormTelephoneField
136
- | MarketoFormTextAreaField
137
- | MarketoFormSelectField
138
- | MarketoFormCheckboxField
139
- | MarketoFormHiddenField
140
- | MarketoFormHtmltextField
141
- | MarketoFormRadioButtonsField
142
- | MarketoFormFieldset
143
-
144
- export interface MarketoFormMetadata {
145
- id: number
146
- name: string
147
- description: string
148
- createdAt: string
149
- updatedAt: string
150
- url: string
151
- status: string
152
- theme: string
153
- language: string
154
- locale: string
155
- progressiveProfiling: boolean
156
- labelPosition: string
157
- fontFamily: string
158
- fontSize: string
159
- folder?: {
160
- type: string
161
- value: number
162
- folderName: string
163
- }
164
- knownVisitor?: {
165
- type: string
166
- template: unknown
167
- }
168
- thankYouList?: {
169
- followupType: string
170
- followupValue: string | null
171
- default: boolean
172
- }[]
173
- buttonLocation: number
174
- buttonLabel: string
175
- waitingLabel: string
176
- workSpaceId: number
177
- }
178
-
179
- /**
180
- * The Marketo API response containing form fields.
181
- */
182
- export interface MarketoFormResponse<T> {
183
- success: boolean
184
- errors: { code: string; message: string }[]
185
- warnings?: string[]
186
- requestId?: string
187
- result: T[]
188
- }
189
-
190
- export type MarketoFormFieldsResponse = MarketoFormResponse<MarketoFormField>
191
- export type MarketoFormMetadataResponse =
192
- MarketoFormResponse<MarketoFormMetadata>
193
- export interface MarketoFormAPIResponse {
194
- fields: MarketoFormFieldsResponse
195
- metadata: MarketoFormMetadataResponse
196
- }
197
-
198
- /**
199
- * Custom components to be used in lieu of the default built-in components.
200
- */
201
- export interface MarketoFormComponents {
202
- text?: (props: { field: MarketoFormTextField }) => JSX.Element
203
- email?: (props: { field: MarketoFormEmailField }) => JSX.Element
204
- telephone?: (props: { field: MarketoFormTelephoneField }) => JSX.Element
205
- textArea?: (props: { field: MarketoFormTextAreaField }) => JSX.Element
206
- select?: (props: { field: MarketoFormSelectField }) => JSX.Element
207
- checkbox?: (props: { field: MarketoFormCheckboxField }) => JSX.Element
208
- hidden?: (props: { field: MarketoFormHiddenField }) => JSX.Element
209
- htmltext?: (props: { field: MarketoFormHtmltextField }) => JSX.Element
210
- radioButtons?: (props: { field: MarketoFormRadioButtonsField }) => JSX.Element
211
- }
212
-
213
- /**
214
- * Configuration on which fields to render with a single component. Can be used
215
- * to render multiple default components on one row (such as First Name and
216
- * Last Name) or to render a particular set of fields with a single component.
217
- */
218
- export type MarketoFormGroups = Record<
219
- string,
220
- {
221
- fields: string[]
222
- component: (props: { fields: MarketoFormField[] }) => JSX.Element
223
- }
224
- >
225
-
226
- export type SubmissionFilter = (req: NextApiRequest) => Promise<boolean>
227
-
228
- export interface MarketoSubmissionResponse {
229
- success: boolean
230
- result: { status: 'created' | 'updated' | 'skipped' }[]
231
- }
232
-
233
- export type OnSubmitData = Record<string, unknown>
234
-
235
- export interface OnSubmitProps {
236
- /**
237
- * Whether to reset the form after a successful submission.
238
- * Default: false
239
- */
240
- resetOnSubmission?: boolean
241
-
242
- /**
243
- * Callback called when form has started submission process.
244
- * Form will submit with the transformed data returned.
245
- */
246
- transformData?: (data: OnSubmitData) => OnSubmitData
247
-
248
- /**
249
- * Callback called when form has started submission process.
250
- */
251
- onSubmitStart?: () => void
252
-
253
- /**
254
- * Callback called when form has been successfully submitted.
255
- */
256
- onSubmitSuccess?: (data?: OnSubmitData) => void
257
-
258
- /**
259
- * Callback called when form submission results in an error.
260
- */
261
- onSubmitError?: () => void
262
- }