market/src/components/@shared/FormInput/index.tsx

155 lines
4.0 KiB
TypeScript
Raw Normal View History

import React, {
ChangeEvent,
FormEvent,
KeyboardEvent,
ReactElement,
ReactNode,
useEffect,
useState
} from 'react'
import InputElement from './InputElement'
import Label from './Label'
import styles from './index.module.css'
2021-11-01 15:57:00 +01:00
import { ErrorMessage, FieldInputProps } from 'formik'
import classNames from 'classnames/bind'
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
import Disclaimer from './Disclaimer'
2021-10-21 20:58:55 +02:00
import Tooltip from '@shared/atoms/Tooltip'
import Markdown from '@shared/Markdown'
import FormHelp from './Help'
const cx = classNames.bind(styles)
export interface InputProps {
name: string
2020-09-21 14:23:04 +02:00
label?: string | ReactNode
placeholder?: string
required?: boolean
help?: string
prominentHelp?: boolean
tag?: string
type?: string
options?: string[]
Swap tokens (#204) * swap Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * validation and calculation Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove unused effect Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix interval Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * increase refresh timer, remove optional params Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * make inputs show up without wallet * style fixes * restyling * styling * more styling * fix refresh price Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove test effect * fixes, get data as early as possible from DDO and initial state * refactor * refactor * refactor * label tweaks * copy * typo * prototype output * remove price header * ouput swap fee * fix * spacing * copy * refactor pool transaction titles * copy * update math Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * use messaging tweaks * tab tweaks, output refactor * fix dark mode selection style * prototype output * method tweaks * slippage to 1%, added warnig banner Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * form tweaks * error fix * empty inputs by default * longer intervals * maxOcean validation fix * slippage tolerance UI * modified slippage UI * refactor, refresh ocean user balance * move typings/models around * typing fix * fixed output values Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * bump oceanlib Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.log * remove placeholder * tweak * non-web3 browser tweak Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2020-11-16 16:21:15 +01:00
sortOptions?: boolean
additionalComponent?: ReactElement
value?: string | number
onChange?(
e:
| FormEvent<HTMLInputElement>
| ChangeEvent<HTMLInputElement>
| ChangeEvent<HTMLSelectElement>
| ChangeEvent<HTMLTextAreaElement>
): void
onKeyPress?(
e:
| KeyboardEvent<HTMLInputElement>
| KeyboardEvent<HTMLInputElement>
| KeyboardEvent<HTMLSelectElement>
| KeyboardEvent<HTMLTextAreaElement>
): void
rows?: number
multiple?: boolean
pattern?: string
min?: string
2020-09-16 11:57:02 +02:00
max?: string
disabled?: boolean
readOnly?: boolean
2020-10-16 09:36:21 +02:00
field?: FieldInputProps<any>
2020-07-17 15:06:28 +02:00
form?: any
2020-10-06 23:16:08 +02:00
prefix?: string | ReactElement
postfix?: string | ReactElement
step?: string
2020-09-10 12:20:40 +02:00
defaultChecked?: boolean
Swap tokens (#204) * swap Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * validation and calculation Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * refactor Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove unused effect Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix interval Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * increase refresh timer, remove optional params Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * make inputs show up without wallet * style fixes * restyling * styling * more styling * fix refresh price Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove test effect * fixes, get data as early as possible from DDO and initial state * refactor * refactor * refactor * label tweaks * copy * typo * prototype output * remove price header * ouput swap fee * fix * spacing * copy * refactor pool transaction titles * copy * update math Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * use messaging tweaks * tab tweaks, output refactor * fix dark mode selection style * prototype output * method tweaks * slippage to 1%, added warnig banner Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * form tweaks * error fix * empty inputs by default * longer intervals * maxOcean validation fix * slippage tolerance UI * modified slippage UI * refactor, refresh ocean user balance * move typings/models around * typing fix * fixed output values Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * bump oceanlib Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove console.log * remove placeholder * tweak * non-web3 browser tweak Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2020-11-16 16:21:15 +01:00
size?: 'mini' | 'small' | 'large' | 'default'
Edit compute dataset (#417) * WIP * created form for editing compute privacy * used editComputePrivacy method * select and update trusted algorithm * display and select multiple trusted algorithms * fixed update when trusted algorithm list not changed * code refactoring * moved separator inside condition * moved functions and interface from EditComputeDataset component * moved algorithmOptions to parent component * used AssetSelection to display algorithms * use AssetSelection to select trusted algorithms * getAlgorithmsOptions function review * review fixes * removed unused imports * merge fixes * AssetSelection style & usability tweaks * use custom radio & checkbox styles * add simple search for name & DID * spacing adjustments * copy updates, remove raw algo input, hardcode allowRawAlgorithm * copy * AssetSelection usability tweaks * make rows clickable * tweak layout, style and markup * use formik set function to update values * sorted algorithm list, added checked field * sort assetSelection list on user select * fix getAlgorithmsForAssetSelection breaking on empty responses * form debug output * another empty publisherTrustedAlgorithms fix * created separate algorithms state for the form, sort list on edit * refactor * use Formik functionality wherever possible * unify transforming form data to final data * fix form debug transformation * fix form submit, fix defaultChecked * refactor * use Formik functionality wherever possible * unify transforming form data to final data * fix form debug transformation * fix form submit, fix defaultChecked * disable assetSelection when allowAllAlgorithms is true * added loader to AssetSelection * changed allowAllAlgorithms to allowAllPublishedAlgorithms * fixed lint error * updated transformComputeFormToServiceComputePrivacy * lint fix * modify publish defaults Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-03-25 08:34:07 +01:00
className?: string
checked?: boolean
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
disclaimer?: string
disclaimerValues?: string[]
}
function checkError(
form: any,
parsedFieldName: string[],
field: FieldInputProps<any>
) {
if (form?.errors && Object.entries(form?.errors).length === 0) {
return false
} else if (
(form?.touched?.[parsedFieldName[0]]?.[parsedFieldName[1]] &&
form?.errors?.[parsedFieldName[0]]?.[parsedFieldName[1]]) ||
(form?.touched[field.name] &&
form?.errors[field.name] &&
field.name !== 'links')
) {
return true
}
}
export default function Input(props: Partial<InputProps>): ReactElement {
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
const {
label,
help,
prominentHelp,
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
additionalComponent,
size,
2021-10-28 17:34:46 +02:00
form,
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
field,
disclaimer,
disclaimerValues
} = props
2021-10-28 17:34:46 +02:00
const isFormikField = typeof field !== 'undefined'
const isNestedField = field?.name?.includes('.')
// TODO: this feels hacky as it assumes nested `values` store. But we can't use the
// `useField()` hook in here to get `meta.error` so we have to match against form?.errors?
// handling flat and nested data at same time.
const parsedFieldName =
isFormikField && (isNestedField ? field?.name.split('.') : [field?.name])
const hasFormikError = checkError(form, parsedFieldName, field)
const styleClasses = cx({
field: true,
2021-10-28 17:34:46 +02:00
hasError: hasFormikError
})
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
const [disclaimerVisible, setDisclaimerVisible] = useState(true)
useEffect(() => {
2021-10-28 17:34:46 +02:00
if (!isFormikField) return
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
if (disclaimer && disclaimerValues) {
setDisclaimerVisible(
2021-10-28 17:34:46 +02:00
disclaimerValues.includes(
props.form?.values[parsedFieldName[0]]?.[parsedFieldName[1]]
)
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
)
}
2021-10-28 17:34:46 +02:00
}, [isFormikField, props.form?.values])
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
return (
2021-10-28 17:34:46 +02:00
<div className={styleClasses}>
2021-11-01 15:57:00 +01:00
<Label htmlFor={props.name}>
{label}
{props.required && (
<span title="Required" className={styles.required}>
*
</span>
)}
{help && !prominentHelp && (
<Tooltip content={<Markdown text={help} />} />
)}
</Label>
2020-10-31 00:55:00 +01:00
<InputElement size={size} {...field} {...props} />
{help && prominentHelp && <FormHelp>{help}</FormHelp>}
2021-10-28 17:34:46 +02:00
{isFormikField && hasFormikError && (
2020-07-13 14:24:41 +02:00
<div className={styles.error}>
<ErrorMessage name={field.name} />
</div>
)}
GDPR Compliance (#796) * add cookie utils * add gdpr metadata for ppc * add graphql typeDefs for GDPR metadata * add ppc variable to app config * add ppc user preference * add switch component * add ppc components * add cookie consent provider * add consent provider to wrapRootElement * add ppc to app component * add cookie button to footer component * add ppc to site metadata query * add styles for buttons in footer * add switch component unit tests * renewed siteMetadata json for testing * add gdpr metadata for testing * add cookie module unit test * add cookie module tests * add customizable format to time component * add english privacy policy * add privacy policy slugs to user preferences and appConfig * add privacy policy components * add autolink for policy md navigation * only show language select for multiple policies * add gatsby policy page creation * use new privacy slug user preference * add to top button styling for markdown pages * add policies for de, es & fr * add pointer events to toTop buttons css * add privacy policy basic unit test * outsource scroll button component * import cleanup * add customizable delay for debounce * add scroll button unit tests * add disclaimer component * add disclaimer fields as optional fields in PublishJsonData * add acces type disclaimer * adjusted help for desc and author fields * add disclaimer unit tests * minor adjustment to test * add print button to history page * naming changes for better readability * add cookies hash to policies * ppc disabled per default * fix react unknown prop for disclaimer * minor adjustments to cookie utils * add gdpr example file * change exposed gdpr metadata scope by useConsent * update README * readme fixes * emoji fix * added imprint * adjustments to gdpr.json structure and related graphql type * add default values for ppc * Update app.config.js Fixed typo. * change variable name for consistency, remove console logs * readability * adjust css selector order to be consistent * Update fr.md updated policy * Update es.md updated policy * Update en.md updated policy * Update de.md * fix type issue * replace language select input with links * remove scroll button from codebase * change privacy policy route to /privacy * remove Do Not Track detection * add size to checkbox / radio inputs * replace switch component with checkbox inputs * fix plain text links * remove console log * refactor privacy policy pages to use PageMarkdown template * setup useUserPreferences mock for unit tests * unit tests forprivacy policy components * setup discalimer to use alert component * Apply .env suggestions from code review Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * move gdpr example to gdpr.json * adjustments to address .env approach for appConfig.privacyPreferenceCenter * update readme * add small styling option to ppc * update README * add ppc unit tests * update comments * Update README.md Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com> * Merge print into profile history * add inifiniteApproval to UserPreference fixture * changed default styling of PPC to small Co-authored-by: Frederic Schwill <41265505+fr-3deric@users.noreply.github.com> Co-authored-by: MeikeMolitor <88214332+MeikeMolitor@users.noreply.github.com> Co-authored-by: Jamie Hewitt <jamie.hewitt15@gmail.com>
2021-10-12 10:00:57 +02:00
{disclaimer && (
<Disclaimer visible={disclaimerVisible}>{disclaimer}</Disclaimer>
)}
{additionalComponent && additionalComponent}
</div>
)
}