@hashicorp/react-components 1.1.10 → 1.2.0
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 +1 -1
- package/package.json +8 -13
- package/postcss.config.js +1 -1
- package/src/components/nav-panel/components/flight-icon/index.tsx +53 -0
- package/src/components/nav-panel/components/flight-icon/style.module.css +3 -0
- package/src/components/nav-panel/components/link/cloud-fill.svg +3 -0
- package/src/components/nav-panel/components/link/index.tsx +139 -0
- package/src/components/nav-panel/components/link/layers-fill.svg +5 -0
- package/src/components/nav-panel/components/link/shield-alert-fill.svg +3 -0
- package/src/components/nav-panel/components/link/style.module.css +64 -0
- package/src/components/nav-panel/components/link/zap-fill.svg +3 -0
- package/src/components/nav-panel/components/link-list/index.tsx +12 -64
- package/src/components/nav-panel/components/link-list/style.module.css +1 -50
- package/src/components/nav-panel/components/panel/column/style.module.css +2 -2
- package/src/components/nav-panel/components/panel/root/style.module.css +5 -5
- package/src/components/nav-panel/components/promo/index.tsx +35 -15
- package/src/components/nav-panel/components/promo/style.module.css +32 -28
- package/src/components/nav-panel/components/text/index.tsx +34 -0
- package/src/components/nav-panel/product-panel/index.tsx +71 -20
- package/src/components/nav-panel/product-panel/style.module.css +111 -53
- package/src/components/nav-panel/standard-panel/index.tsx +3 -0
- package/src/components/nav-panel/standard-panel/style.module.css +2 -2
- package/src/lib/get-localized-link-props/index.test.ts +30 -0
- package/src/lib/get-localized-link-props/index.ts +45 -0
- package/src/lib/parse-url/index.test.ts +57 -2
- package/src/lib/parse-url/index.ts +97 -13
- package/src/lib/send-posthog-event/index.ts +22 -0
- package/src/lib/supported-locales/index.ts +10 -0
- package/src/lib/track-nav-click-event/index.ts +5 -5
- package/src/lib/v/index.ts +9 -4
- package/tsconfig.json +1 -2
- package/.eslintrc.js +0 -4
- package/.stylelintrc.js +0 -3
- package/src/components/actions/index.tsx +0 -107
- package/src/components/actions/style.module.css +0 -28
- package/src/components/actions/types.ts +0 -73
- package/src/components/call-to-action/index.tsx +0 -205
- package/src/components/call-to-action/styles/variant-centered.module.css +0 -93
- package/src/components/call-to-action/styles/variant-compact-grid.module.css +0 -88
- package/src/components/call-to-action/styles/variant-compact.module.css +0 -91
- package/src/components/call-to-action/styles/variant-links.module.css +0 -85
- package/src/components/card/README.md +0 -11
- package/src/components/card/card.tsx +0 -45
- package/src/components/card/index.test.tsx +0 -69
- package/src/components/card/index.tsx +0 -14
- package/src/components/card/newsroom-card/index.test.tsx +0 -39
- package/src/components/card/newsroom-card/index.tsx +0 -37
- package/src/components/card/newsroom-card/style.module.css +0 -12
- package/src/components/card/partner-card/index.test.tsx +0 -57
- package/src/components/card/partner-card/index.tsx +0 -69
- package/src/components/card/partner-card/style.module.css +0 -24
- package/src/components/card/person-card/index.test.tsx +0 -71
- package/src/components/card/person-card/index.tsx +0 -93
- package/src/components/card/person-card/style.module.css +0 -33
- package/src/components/card/primitives.tsx +0 -176
- package/src/components/card/promo-card/index.tsx +0 -51
- package/src/components/card/resource-card/index.test.tsx +0 -48
- package/src/components/card/resource-card/index.tsx +0 -37
- package/src/components/card/style.module.css +0 -145
- package/src/components/card/types.ts +0 -66
- package/src/components/card/unified-card/index.tsx +0 -64
- package/src/components/consent-manager/README.md +0 -73
- package/src/components/consent-manager/components/banner/banner.module.css +0 -23
- package/src/components/consent-manager/components/banner/banner.test.tsx +0 -31
- package/src/components/consent-manager/components/banner/banner.tsx +0 -73
- package/src/components/consent-manager/components/dialog/dialog.module.css +0 -145
- package/src/components/consent-manager/components/dialog/dialog.test.tsx +0 -194
- package/src/components/consent-manager/components/dialog/dialog.tsx +0 -339
- package/src/components/consent-manager/img/icn_close.tsx +0 -19
- package/src/components/consent-manager/index.test.tsx +0 -334
- package/src/components/consent-manager/index.tsx +0 -186
- package/src/components/consent-manager/loader/README.md +0 -29
- package/src/components/consent-manager/loader/categories.ts +0 -22
- package/src/components/consent-manager/loader/index.tsx +0 -94
- package/src/components/consent-manager/loader/presets/enterprise.ts +0 -12
- package/src/components/consent-manager/loader/presets/oss.ts +0 -10
- package/src/components/consent-manager/loader/services.ts +0 -45
- package/src/components/consent-manager/scripts/custom.tsx +0 -59
- package/src/components/consent-manager/scripts/segment.tsx +0 -87
- package/src/components/consent-manager/style.module.css +0 -9
- package/src/components/consent-manager/types.ts +0 -55
- package/src/components/consent-manager/util/cookies.test.ts +0 -75
- package/src/components/consent-manager/util/cookies.ts +0 -70
- package/src/components/consent-manager/util/integrations.test.ts +0 -115
- package/src/components/consent-manager/util/integrations.ts +0 -110
- package/src/components/intro/index.tsx +0 -82
- package/src/components/intro/style.module.css +0 -67
- package/src/components/intro/types.ts +0 -44
- package/src/components/marketo-form/CHANGELOG.md +0 -122
- package/src/components/marketo-form/README.md +0 -1
- package/src/components/marketo-form/contexts/FormMetadata.ts +0 -11
- package/src/components/marketo-form/docs.mdx +0 -197
- package/src/components/marketo-form/fixtures/index.ts +0 -185
- package/src/components/marketo-form/form/index.tsx +0 -369
- package/src/components/marketo-form/index.test.tsx +0 -320
- package/src/components/marketo-form/index.ts +0 -11
- package/src/components/marketo-form/package.original.json +0 -30
- package/src/components/marketo-form/partials/error-message/index.tsx +0 -12
- package/src/components/marketo-form/partials/error-message/style.module.css +0 -13
- package/src/components/marketo-form/partials/field/index.tsx +0 -90
- package/src/components/marketo-form/partials/field-wrapper/index.tsx +0 -26
- package/src/components/marketo-form/partials/fields/checkbox-field/index.tsx +0 -32
- package/src/components/marketo-form/partials/fields/email-field/index.tsx +0 -35
- package/src/components/marketo-form/partials/fields/form-page-url-field/index.tsx +0 -21
- package/src/components/marketo-form/partials/fields/hidden-field/index.tsx +0 -37
- package/src/components/marketo-form/partials/fields/htmltext-field/index.tsx +0 -21
- package/src/components/marketo-form/partials/fields/htmltext-field/style.module.css +0 -18
- package/src/components/marketo-form/partials/fields/name-field/index.tsx +0 -19
- package/src/components/marketo-form/partials/fields/name-field/style.module.css +0 -13
- package/src/components/marketo-form/partials/fields/radio-buttons-field/index.tsx +0 -48
- package/src/components/marketo-form/partials/fields/select-field/index.tsx +0 -39
- package/src/components/marketo-form/partials/fields/select-field/style.module.css +0 -5
- package/src/components/marketo-form/partials/fields/telephone-field/index.tsx +0 -30
- package/src/components/marketo-form/partials/fields/text-field/index.tsx +0 -30
- package/src/components/marketo-form/partials/fields/textarea-field/index.tsx +0 -29
- package/src/components/marketo-form/partials/label/index.tsx +0 -24
- package/src/components/marketo-form/partials/label/style.module.css +0 -12
- package/src/components/marketo-form/partials/visibility-rule/index.tsx +0 -84
- package/src/components/marketo-form/props.js +0 -66
- package/src/components/marketo-form/server/api-routes.ts +0 -109
- package/src/components/marketo-form/server/client.ts +0 -98
- package/src/components/marketo-form/server/index.ts +0 -8
- package/src/components/marketo-form/types.ts +0 -268
- package/src/components/marketo-form/utils.test.tsx +0 -103
- package/src/components/marketo-form/utils.ts +0 -449
- package/src/components/next-steps/index.tsx +0 -137
- package/src/components/next-steps/style.module.css +0 -270
- package/src/components/next-steps/types.ts +0 -63
- package/src/components/product-badge/index.test.tsx +0 -11
- package/src/components/product-badge/index.tsx +0 -42
- package/src/components/product-badge/style.module.css +0 -76
- package/src/components/products-used/index.tsx +0 -84
- package/src/components/products-used/style.module.css +0 -87
- package/src/components/products-used/types.ts +0 -31
- package/src/components/related-content/index.test.tsx +0 -74
- package/src/components/related-content/index.tsx +0 -56
- package/src/components/related-content/style.module.css +0 -89
- package/src/components/related-content/types.ts +0 -21
- package/src/components/subnav/helpers/areBasePathsMatching.ts +0 -13
- package/src/components/subnav/helpers/traverse/index.ts +0 -42
- package/src/components/subnav/helpers/useHeightRef.ts +0 -42
- package/src/components/subnav/helpers/useNavRef.ts +0 -30
- package/src/components/subnav/helpers/useOverflowRef.ts +0 -85
- package/src/components/subnav/helpers/useStuckRef.ts +0 -51
- package/src/components/subnav/index.tsx +0 -199
- package/src/components/subnav/partials/CtaLinks/github-stars-link/formatStarCount/index.test.ts +0 -26
- package/src/components/subnav/partials/CtaLinks/github-stars-link/formatStarCount/index.ts +0 -22
- package/src/components/subnav/partials/CtaLinks/github-stars-link/index.tsx +0 -87
- package/src/components/subnav/partials/CtaLinks/github-stars-link/parseGithubUrl/index.test.ts +0 -29
- package/src/components/subnav/partials/CtaLinks/github-stars-link/parseGithubUrl/index.ts +0 -32
- package/src/components/subnav/partials/CtaLinks/github-stars-link/style.module.css +0 -85
- package/src/components/subnav/partials/CtaLinks/icons/github-logo.js +0 -20
- package/src/components/subnav/partials/CtaLinks/icons/github.svg.js +0 -7
- package/src/components/subnav/partials/CtaLinks/icons/star.js +0 -20
- package/src/components/subnav/partials/CtaLinks/index.tsx +0 -130
- package/src/components/subnav/partials/CtaLinks/style.module.css +0 -45
- package/src/components/subnav/partials/DropdownTrigger/index.tsx +0 -35
- package/src/components/subnav/partials/DropdownTrigger/style.module.css +0 -36
- package/src/components/subnav/partials/MenuItemsDefault/index.tsx +0 -151
- package/src/components/subnav/partials/MenuItemsDefault/style.module.css +0 -91
- package/src/components/subnav/partials/MenuItemsOverflow/index.tsx +0 -139
- package/src/components/subnav/partials/MenuItemsOverflow/style.module.css +0 -82
- package/src/components/subnav/partials/TitleLink/index.tsx +0 -113
- package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-dark.ts +0 -9
- package/src/components/subnav/partials/TitleLink/mktg-logos/all-community-product-logos_on-light.ts +0 -9
- package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-dark.ts +0 -23
- package/src/components/subnav/partials/TitleLink/mktg-logos/all-primary-logos_on-light.ts +0 -23
- package/src/components/subnav/partials/TitleLink/style.module.css +0 -43
- package/src/components/subnav/partials/nav-item-text/index.tsx +0 -37
- package/src/components/subnav/partials/nav-item-text/style.module.css +0 -15
- package/src/components/subnav/style.module.css +0 -68
- package/src/components/subnav/subnav-consts.ts +0 -1
- package/src/components/subnav/theme.module.css +0 -50
|
@@ -1,268 +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
|
-
|
|
19
|
-
export interface Autofill {
|
|
20
|
-
value: string
|
|
21
|
-
valueFrom: string
|
|
22
|
-
parameterName: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface VisibilityRule {
|
|
26
|
-
subjectField: string
|
|
27
|
-
operator: 'is' | 'isNot' | 'isEmpty'
|
|
28
|
-
values: string[]
|
|
29
|
-
altLabel: string
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface VisibilityRules {
|
|
33
|
-
rules?: VisibilityRule[]
|
|
34
|
-
ruleType: 'alwaysShow' | 'show' | 'hide'
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface MarketoBaseFormField {
|
|
38
|
-
id: string
|
|
39
|
-
dataType: MarketoFormDatatype
|
|
40
|
-
rowNumber: number
|
|
41
|
-
columnNumber: number
|
|
42
|
-
defaultValue?: string
|
|
43
|
-
label?: string
|
|
44
|
-
required: boolean
|
|
45
|
-
validationMessage?: string
|
|
46
|
-
autoFill?: Autofill
|
|
47
|
-
visibilityRules?: VisibilityRules
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface MarketoFormTextField extends MarketoBaseFormField {
|
|
51
|
-
dataType: 'text'
|
|
52
|
-
hintText?: string
|
|
53
|
-
maxLength?: number
|
|
54
|
-
formPrefill?: boolean
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface MarketoFormEmailField extends MarketoBaseFormField {
|
|
58
|
-
dataType: 'email'
|
|
59
|
-
hintText?: string
|
|
60
|
-
formPrefill: boolean
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface MarketoFormTelephoneField extends MarketoBaseFormField {
|
|
64
|
-
dataType: 'telephone'
|
|
65
|
-
hintText?: string
|
|
66
|
-
formPrefill: boolean
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface MarketoFormTextAreaField extends MarketoBaseFormField {
|
|
70
|
-
dataType: 'textArea'
|
|
71
|
-
hintText?: string
|
|
72
|
-
formPrefill: boolean
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export interface SelectValue {
|
|
76
|
-
label: string
|
|
77
|
-
value: string
|
|
78
|
-
selected?: boolean
|
|
79
|
-
isDefault?: boolean
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface SelectFieldMetaData {
|
|
83
|
-
values?: SelectValue[]
|
|
84
|
-
visibleLines?: number
|
|
85
|
-
multiSelect?: boolean
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface MarketoFormSelectField extends MarketoBaseFormField {
|
|
89
|
-
dataType: 'select'
|
|
90
|
-
fieldMetaData: SelectFieldMetaData
|
|
91
|
-
formPrefill: boolean
|
|
92
|
-
labelWidth?: number
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface CheckboxFieldMetaData {
|
|
96
|
-
initiallyChecked: boolean
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface MarketoFormCheckboxField extends MarketoBaseFormField {
|
|
100
|
-
dataType: 'checkbox'
|
|
101
|
-
fieldMetaData: CheckboxFieldMetaData
|
|
102
|
-
formPrefill: boolean
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export interface MarketoFormHiddenField extends MarketoBaseFormField {
|
|
106
|
-
dataType: 'hidden'
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface MarketoFormHtmltextField {
|
|
110
|
-
id: string
|
|
111
|
-
labelWidth: number
|
|
112
|
-
dataType: 'htmltext'
|
|
113
|
-
rowNumber: number
|
|
114
|
-
columnNumber: number
|
|
115
|
-
visibilityRules?: VisibilityRules
|
|
116
|
-
text: string
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export interface MarketoFormRadioButtonsField extends MarketoBaseFormField {
|
|
120
|
-
dataType: 'radioButtons'
|
|
121
|
-
fieldWidth?: number
|
|
122
|
-
formPrefill?: boolean
|
|
123
|
-
fieldMetaData: {
|
|
124
|
-
values: Array<{ label: string; value: string }>
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export interface MarketoFormFieldset {
|
|
129
|
-
id: string
|
|
130
|
-
label?: string
|
|
131
|
-
dataType: 'fieldset'
|
|
132
|
-
rowNumber: number
|
|
133
|
-
columnNumber: number
|
|
134
|
-
visibilityRules?: VisibilityRules
|
|
135
|
-
fields: Array<string>
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export type MarketoFormField =
|
|
139
|
-
| MarketoFormTextField
|
|
140
|
-
| MarketoFormEmailField
|
|
141
|
-
| MarketoFormTelephoneField
|
|
142
|
-
| MarketoFormTextAreaField
|
|
143
|
-
| MarketoFormSelectField
|
|
144
|
-
| MarketoFormCheckboxField
|
|
145
|
-
| MarketoFormHiddenField
|
|
146
|
-
| MarketoFormHtmltextField
|
|
147
|
-
| MarketoFormRadioButtonsField
|
|
148
|
-
| MarketoFormFieldset
|
|
149
|
-
|
|
150
|
-
export interface MarketoFormMetadata {
|
|
151
|
-
id: number
|
|
152
|
-
name: string
|
|
153
|
-
description: string
|
|
154
|
-
createdAt: string
|
|
155
|
-
updatedAt: string
|
|
156
|
-
url: string
|
|
157
|
-
status: string
|
|
158
|
-
theme: string
|
|
159
|
-
language: string
|
|
160
|
-
locale: string
|
|
161
|
-
progressiveProfiling: boolean
|
|
162
|
-
labelPosition: string
|
|
163
|
-
fontFamily: string
|
|
164
|
-
fontSize: string
|
|
165
|
-
folder?: {
|
|
166
|
-
type: string
|
|
167
|
-
value: number
|
|
168
|
-
folderName: string
|
|
169
|
-
}
|
|
170
|
-
knownVisitor?: {
|
|
171
|
-
type: string
|
|
172
|
-
template: unknown
|
|
173
|
-
}
|
|
174
|
-
thankYouList?: {
|
|
175
|
-
followupType: string
|
|
176
|
-
followupValue: string | null
|
|
177
|
-
default: boolean
|
|
178
|
-
}[]
|
|
179
|
-
buttonLocation: number
|
|
180
|
-
buttonLabel: string
|
|
181
|
-
waitingLabel: string
|
|
182
|
-
workSpaceId: number
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* The Marketo API response containing form fields.
|
|
187
|
-
*/
|
|
188
|
-
export interface MarketoFormResponse<T> {
|
|
189
|
-
success: boolean
|
|
190
|
-
errors: { code: string; message: string }[]
|
|
191
|
-
warnings?: string[]
|
|
192
|
-
requestId?: string
|
|
193
|
-
result: T[]
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export type MarketoFormFieldsResponse = MarketoFormResponse<MarketoFormField>
|
|
197
|
-
export type MarketoFormMetadataResponse =
|
|
198
|
-
MarketoFormResponse<MarketoFormMetadata>
|
|
199
|
-
export interface MarketoFormAPIResponse {
|
|
200
|
-
fields: MarketoFormFieldsResponse
|
|
201
|
-
metadata: MarketoFormMetadataResponse
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Custom components to be used in lieu of the default built-in components.
|
|
206
|
-
*/
|
|
207
|
-
export interface MarketoFormComponents {
|
|
208
|
-
text?: (props: { field: MarketoFormTextField }) => JSX.Element
|
|
209
|
-
email?: (props: { field: MarketoFormEmailField }) => JSX.Element
|
|
210
|
-
telephone?: (props: { field: MarketoFormTelephoneField }) => JSX.Element
|
|
211
|
-
textArea?: (props: { field: MarketoFormTextAreaField }) => JSX.Element
|
|
212
|
-
select?: (props: { field: MarketoFormSelectField }) => JSX.Element
|
|
213
|
-
checkbox?: (props: { field: MarketoFormCheckboxField }) => JSX.Element
|
|
214
|
-
hidden?: (props: { field: MarketoFormHiddenField }) => JSX.Element
|
|
215
|
-
htmltext?: (props: { field: MarketoFormHtmltextField }) => JSX.Element
|
|
216
|
-
radioButtons?: (props: { field: MarketoFormRadioButtonsField }) => JSX.Element
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Configuration on which fields to render with a single component. Can be used
|
|
221
|
-
* to render multiple default components on one row (such as First Name and
|
|
222
|
-
* Last Name) or to render a particular set of fields with a single component.
|
|
223
|
-
*/
|
|
224
|
-
export type MarketoFormGroups = Record<
|
|
225
|
-
string,
|
|
226
|
-
{
|
|
227
|
-
fields: string[]
|
|
228
|
-
component: (props: { fields: MarketoFormField[] }) => JSX.Element
|
|
229
|
-
}
|
|
230
|
-
>
|
|
231
|
-
|
|
232
|
-
export type SubmissionFilter = (req: NextApiRequest) => Promise<boolean>
|
|
233
|
-
|
|
234
|
-
export interface MarketoSubmissionResponse {
|
|
235
|
-
success: boolean
|
|
236
|
-
result: { status: 'created' | 'updated' | 'skipped' }[]
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export type OnSubmitData = Record<string, unknown>
|
|
240
|
-
|
|
241
|
-
export interface OnSubmitProps {
|
|
242
|
-
/**
|
|
243
|
-
* Whether to reset the form after a successful submission.
|
|
244
|
-
* Default: false
|
|
245
|
-
*/
|
|
246
|
-
resetOnSubmission?: boolean
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Callback called when form has started submission process.
|
|
250
|
-
* Form will submit with the transformed data returned.
|
|
251
|
-
*/
|
|
252
|
-
transformData?: (data: OnSubmitData) => OnSubmitData
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Callback called when form has started submission process.
|
|
256
|
-
*/
|
|
257
|
-
onSubmitStart?: () => void
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Callback called when form has been successfully submitted.
|
|
261
|
-
*/
|
|
262
|
-
onSubmitSuccess?: (data?: OnSubmitData) => void
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Callback called when form submission results in an error.
|
|
266
|
-
*/
|
|
267
|
-
onSubmitError?: () => void
|
|
268
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
calculateDefaultValues,
|
|
3
|
-
formattedLabel,
|
|
4
|
-
groupFields,
|
|
5
|
-
includesSkippedRecords,
|
|
6
|
-
} from './utils'
|
|
7
|
-
import { UTM_FORM_PROPS, VISIBILITY_RULE_FORM_PROPS } from './fixtures'
|
|
8
|
-
|
|
9
|
-
describe('formattedLabel', () => {
|
|
10
|
-
it('does not append asterisk for non-required fields', () => {
|
|
11
|
-
expect(
|
|
12
|
-
formattedLabel({
|
|
13
|
-
id: 'FirstName',
|
|
14
|
-
label: 'First Name',
|
|
15
|
-
dataType: 'text',
|
|
16
|
-
validationMessage: 'This field is required.',
|
|
17
|
-
rowNumber: 3,
|
|
18
|
-
columnNumber: 0,
|
|
19
|
-
required: false,
|
|
20
|
-
visibilityRules: {
|
|
21
|
-
ruleType: 'alwaysShow',
|
|
22
|
-
},
|
|
23
|
-
})
|
|
24
|
-
).toBe('First Name')
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
describe('groupFields', () => {
|
|
29
|
-
it('groups fields', () => {
|
|
30
|
-
const groups = groupFields(UTM_FORM_PROPS.fields.result, {
|
|
31
|
-
name: {
|
|
32
|
-
fields: ['FirstName', 'LastName'],
|
|
33
|
-
component: () => <span>Not used</span>,
|
|
34
|
-
},
|
|
35
|
-
})
|
|
36
|
-
expect(groups).toEqual({
|
|
37
|
-
name: [UTM_FORM_PROPS.fields.result[0], UTM_FORM_PROPS.fields.result[1]],
|
|
38
|
-
utm_medium__c: [UTM_FORM_PROPS.fields.result[2]],
|
|
39
|
-
form_page_url__c: [UTM_FORM_PROPS.fields.result[3]],
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
describe('calculateDefaultValues', () => {
|
|
45
|
-
it('calculates default values', () => {
|
|
46
|
-
expect(
|
|
47
|
-
calculateDefaultValues(VISIBILITY_RULE_FORM_PROPS.fields.result)
|
|
48
|
-
).toEqual({
|
|
49
|
-
FirstName: '',
|
|
50
|
-
LastName: '',
|
|
51
|
-
Phone: '',
|
|
52
|
-
fastTracktoSales: false,
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('accounts for passed in values', () => {
|
|
57
|
-
expect(
|
|
58
|
-
calculateDefaultValues(UTM_FORM_PROPS.fields.result, {
|
|
59
|
-
form_page_url__c: 'http',
|
|
60
|
-
})
|
|
61
|
-
).toEqual({
|
|
62
|
-
FirstName: '',
|
|
63
|
-
LastName: '',
|
|
64
|
-
utm_medium__c: '',
|
|
65
|
-
form_page_url__c: 'http',
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
describe('includesSkippedRecords', () => {
|
|
71
|
-
it('returns true when containing skipped records', () => {
|
|
72
|
-
const response = {
|
|
73
|
-
requestId: 'f8a8#185cc1e96b9',
|
|
74
|
-
result: [
|
|
75
|
-
{
|
|
76
|
-
status: 'skipped' as const,
|
|
77
|
-
reasons: [
|
|
78
|
-
{
|
|
79
|
-
code: '1003',
|
|
80
|
-
message:
|
|
81
|
-
"Invalid value for field 'email' and value 'dylan.staley@hashicorp.co.k'",
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
success: true,
|
|
87
|
-
}
|
|
88
|
-
expect(includesSkippedRecords(response)).toBe(true)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('returns false when not containing skipped records', () => {
|
|
92
|
-
const response = {
|
|
93
|
-
requestId: 'f8a8#185cc1e96b9',
|
|
94
|
-
result: [
|
|
95
|
-
{
|
|
96
|
-
status: 'created' as const,
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
success: true,
|
|
100
|
-
}
|
|
101
|
-
expect(includesSkippedRecords(response)).toBe(false)
|
|
102
|
-
})
|
|
103
|
-
})
|