@dnb/eufemia 10.70.1 → 10.71.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/CHANGELOG.md +18 -0
- package/cjs/components/date-picker/DatePickerContext.d.ts +0 -1
- package/cjs/components/date-picker/DatePickerContext.js.map +1 -1
- package/cjs/components/date-picker/DatePickerInput.js +7 -59
- package/cjs/components/date-picker/DatePickerInput.js.map +1 -1
- package/cjs/components/date-picker/DatePickerProvider.js +0 -2
- package/cjs/components/date-picker/DatePickerProvider.js.map +1 -1
- package/cjs/components/date-picker/hooks/useDates.d.ts +0 -2
- package/cjs/components/date-picker/hooks/useDates.js +5 -5
- package/cjs/components/date-picker/hooks/useDates.js.map +1 -1
- package/cjs/components/input-masked/InputMaskedHooks.js +11 -7
- package/cjs/components/input-masked/InputMaskedHooks.js.map +1 -1
- package/cjs/components/input-masked/InputMaskedUtils.d.ts +1 -1
- package/cjs/components/input-masked/InputMaskedUtils.js +2 -1
- package/cjs/components/input-masked/InputMaskedUtils.js.map +1 -1
- package/cjs/components/modal/ModalDocs.d.ts +2 -0
- package/cjs/components/modal/ModalDocs.js +11 -1
- package/cjs/components/modal/ModalDocs.js.map +1 -1
- package/cjs/components/upload/Upload.js +6 -3
- package/cjs/components/upload/Upload.js.map +1 -1
- package/cjs/components/upload/UploadDocs.d.ts +1 -0
- package/cjs/components/upload/UploadDocs.js +43 -1
- package/cjs/components/upload/UploadDocs.js.map +1 -1
- package/cjs/components/upload/UploadFileListCell.js +32 -12
- package/cjs/components/upload/UploadFileListCell.js.map +1 -1
- package/cjs/components/upload/types.d.ts +7 -0
- package/cjs/components/upload/types.js.map +1 -1
- package/cjs/extensions/forms/DataContext/Provider/ProviderDocs.js +1 -1
- package/cjs/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/cjs/extensions/forms/Field/Number/Number.js +3 -6
- package/cjs/extensions/forms/Field/Number/Number.js.map +1 -1
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumber.d.ts +6 -4
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumber.js +33 -25
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumber.js.map +1 -1
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.d.ts +2 -2
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js +8 -3
- package/cjs/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js.map +1 -1
- package/cjs/extensions/forms/Field/Provider/useFieldProvider.d.ts +3 -3
- package/cjs/extensions/forms/Field/Upload/Upload.d.ts +1 -1
- package/cjs/extensions/forms/Field/Upload/Upload.js +3 -1
- package/cjs/extensions/forms/Field/Upload/Upload.js.map +1 -1
- package/cjs/extensions/forms/FieldBlock/FieldBlock.js +11 -4
- package/cjs/extensions/forms/FieldBlock/FieldBlock.js.map +1 -1
- package/cjs/extensions/forms/FieldBlock/FieldBlockContext.d.ts +1 -1
- package/cjs/extensions/forms/FieldBlock/FieldBlockContext.js.map +1 -1
- package/cjs/extensions/forms/hooks/DataValueWritePropsDocs.js +1 -1
- package/cjs/extensions/forms/hooks/DataValueWritePropsDocs.js.map +1 -1
- package/cjs/extensions/forms/hooks/useFieldProps.js +50 -17
- package/cjs/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/cjs/extensions/forms/types.d.ts +8 -5
- package/cjs/extensions/forms/types.js.map +1 -1
- package/cjs/extensions/forms/utils/FormError.d.ts +20 -16
- package/cjs/extensions/forms/utils/FormError.js.map +1 -1
- package/cjs/shared/Eufemia.d.ts +1 -1
- package/cjs/shared/Eufemia.js +2 -2
- package/cjs/shared/Eufemia.js.map +1 -1
- package/cjs/style/core/scopes.scss +1 -1
- package/cjs/style/dnb-ui-basis.css +1 -1
- package/cjs/style/dnb-ui-basis.min.css +1 -1
- package/cjs/style/dnb-ui-body.css +1 -1
- package/cjs/style/dnb-ui-body.min.css +1 -1
- package/cjs/style/dnb-ui-core.css +1 -1
- package/cjs/style/dnb-ui-core.min.css +1 -1
- package/components/date-picker/DatePickerContext.d.ts +0 -1
- package/components/date-picker/DatePickerContext.js.map +1 -1
- package/components/date-picker/DatePickerInput.js +7 -59
- package/components/date-picker/DatePickerInput.js.map +1 -1
- package/components/date-picker/DatePickerProvider.js +0 -2
- package/components/date-picker/DatePickerProvider.js.map +1 -1
- package/components/date-picker/hooks/useDates.d.ts +0 -2
- package/components/date-picker/hooks/useDates.js +3 -5
- package/components/date-picker/hooks/useDates.js.map +1 -1
- package/components/input-masked/InputMaskedHooks.js +11 -7
- package/components/input-masked/InputMaskedHooks.js.map +1 -1
- package/components/input-masked/InputMaskedUtils.d.ts +1 -1
- package/components/input-masked/InputMaskedUtils.js +2 -1
- package/components/input-masked/InputMaskedUtils.js.map +1 -1
- package/components/modal/ModalDocs.d.ts +2 -0
- package/components/modal/ModalDocs.js +10 -0
- package/components/modal/ModalDocs.js.map +1 -1
- package/components/upload/Upload.js +6 -3
- package/components/upload/Upload.js.map +1 -1
- package/components/upload/UploadDocs.d.ts +1 -0
- package/components/upload/UploadDocs.js +42 -0
- package/components/upload/UploadDocs.js.map +1 -1
- package/components/upload/UploadFileListCell.js +32 -12
- package/components/upload/UploadFileListCell.js.map +1 -1
- package/components/upload/types.d.ts +7 -0
- package/components/upload/types.js.map +1 -1
- package/es/components/date-picker/DatePickerContext.d.ts +0 -1
- package/es/components/date-picker/DatePickerContext.js.map +1 -1
- package/es/components/date-picker/DatePickerInput.js +2 -53
- package/es/components/date-picker/DatePickerInput.js.map +1 -1
- package/es/components/date-picker/DatePickerProvider.js +0 -2
- package/es/components/date-picker/DatePickerProvider.js.map +1 -1
- package/es/components/date-picker/hooks/useDates.d.ts +0 -2
- package/es/components/date-picker/hooks/useDates.js +3 -5
- package/es/components/date-picker/hooks/useDates.js.map +1 -1
- package/es/components/input-masked/InputMaskedHooks.js +11 -7
- package/es/components/input-masked/InputMaskedHooks.js.map +1 -1
- package/es/components/input-masked/InputMaskedUtils.d.ts +1 -1
- package/es/components/input-masked/InputMaskedUtils.js +2 -1
- package/es/components/input-masked/InputMaskedUtils.js.map +1 -1
- package/es/components/modal/ModalDocs.d.ts +2 -0
- package/es/components/modal/ModalDocs.js +6 -0
- package/es/components/modal/ModalDocs.js.map +1 -1
- package/es/components/upload/Upload.js +6 -3
- package/es/components/upload/Upload.js.map +1 -1
- package/es/components/upload/UploadDocs.d.ts +1 -0
- package/es/components/upload/UploadDocs.js +42 -0
- package/es/components/upload/UploadDocs.js.map +1 -1
- package/es/components/upload/UploadFileListCell.js +32 -12
- package/es/components/upload/UploadFileListCell.js.map +1 -1
- package/es/components/upload/types.d.ts +7 -0
- package/es/components/upload/types.js.map +1 -1
- package/es/extensions/forms/DataContext/Provider/ProviderDocs.js +1 -1
- package/es/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/es/extensions/forms/Field/Number/Number.js +3 -6
- package/es/extensions/forms/Field/Number/Number.js.map +1 -1
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumber.d.ts +6 -4
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumber.js +24 -16
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumber.js.map +1 -1
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.d.ts +2 -2
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js +7 -2
- package/es/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js.map +1 -1
- package/es/extensions/forms/Field/Provider/useFieldProvider.d.ts +3 -3
- package/es/extensions/forms/Field/Upload/Upload.d.ts +1 -1
- package/es/extensions/forms/Field/Upload/Upload.js +3 -1
- package/es/extensions/forms/Field/Upload/Upload.js.map +1 -1
- package/es/extensions/forms/FieldBlock/FieldBlock.js +11 -4
- package/es/extensions/forms/FieldBlock/FieldBlock.js.map +1 -1
- package/es/extensions/forms/FieldBlock/FieldBlockContext.d.ts +1 -1
- package/es/extensions/forms/FieldBlock/FieldBlockContext.js.map +1 -1
- package/es/extensions/forms/hooks/DataValueWritePropsDocs.js +1 -1
- package/es/extensions/forms/hooks/DataValueWritePropsDocs.js.map +1 -1
- package/es/extensions/forms/hooks/useFieldProps.js +51 -18
- package/es/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/es/extensions/forms/types.d.ts +8 -5
- package/es/extensions/forms/types.js.map +1 -1
- package/es/extensions/forms/utils/FormError.d.ts +20 -16
- package/es/extensions/forms/utils/FormError.js +1 -0
- package/es/extensions/forms/utils/FormError.js.map +1 -1
- package/es/shared/Eufemia.d.ts +1 -1
- package/es/shared/Eufemia.js +2 -2
- package/es/shared/Eufemia.js.map +1 -1
- package/es/style/core/scopes.scss +1 -1
- package/es/style/dnb-ui-basis.css +1 -1
- package/es/style/dnb-ui-basis.min.css +1 -1
- package/es/style/dnb-ui-body.css +1 -1
- package/es/style/dnb-ui-body.min.css +1 -1
- package/es/style/dnb-ui-core.css +1 -1
- package/es/style/dnb-ui-core.min.css +1 -1
- package/esm/dnb-ui-basis.min.mjs +1 -1
- package/esm/dnb-ui-components.min.mjs +1 -1
- package/esm/dnb-ui-elements.min.mjs +1 -1
- package/esm/dnb-ui-extensions.min.mjs +1 -1
- package/esm/dnb-ui-lib.min.mjs +1 -1
- package/extensions/forms/DataContext/Provider/ProviderDocs.js +1 -1
- package/extensions/forms/DataContext/Provider/ProviderDocs.js.map +1 -1
- package/extensions/forms/Field/Number/Number.js +3 -6
- package/extensions/forms/Field/Number/Number.js.map +1 -1
- package/extensions/forms/Field/PhoneNumber/PhoneNumber.d.ts +6 -4
- package/extensions/forms/Field/PhoneNumber/PhoneNumber.js +33 -25
- package/extensions/forms/Field/PhoneNumber/PhoneNumber.js.map +1 -1
- package/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.d.ts +2 -2
- package/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js +7 -2
- package/extensions/forms/Field/PhoneNumber/PhoneNumberDocs.js.map +1 -1
- package/extensions/forms/Field/Provider/useFieldProvider.d.ts +3 -3
- package/extensions/forms/Field/Upload/Upload.d.ts +1 -1
- package/extensions/forms/Field/Upload/Upload.js +3 -1
- package/extensions/forms/Field/Upload/Upload.js.map +1 -1
- package/extensions/forms/FieldBlock/FieldBlock.js +11 -4
- package/extensions/forms/FieldBlock/FieldBlock.js.map +1 -1
- package/extensions/forms/FieldBlock/FieldBlockContext.d.ts +1 -1
- package/extensions/forms/FieldBlock/FieldBlockContext.js.map +1 -1
- package/extensions/forms/hooks/DataValueWritePropsDocs.js +1 -1
- package/extensions/forms/hooks/DataValueWritePropsDocs.js.map +1 -1
- package/extensions/forms/hooks/useFieldProps.js +51 -18
- package/extensions/forms/hooks/useFieldProps.js.map +1 -1
- package/extensions/forms/types.d.ts +8 -5
- package/extensions/forms/types.js.map +1 -1
- package/extensions/forms/utils/FormError.d.ts +20 -16
- package/extensions/forms/utils/FormError.js.map +1 -1
- package/package.json +1 -1
- package/shared/Eufemia.d.ts +1 -1
- package/shared/Eufemia.js +2 -2
- package/shared/Eufemia.js.map +1 -1
- package/style/core/scopes.scss +1 -1
- package/style/dnb-ui-basis.css +1 -1
- package/style/dnb-ui-basis.min.css +1 -1
- package/style/dnb-ui-body.css +1 -1
- package/style/dnb-ui-body.min.css +1 -1
- package/style/dnb-ui-core.css +1 -1
- package/style/dnb-ui-core.min.css +1 -1
- package/umd/dnb-ui-basis.min.js +1 -1
- package/umd/dnb-ui-components.min.js +1 -1
- package/umd/dnb-ui-elements.min.js +1 -1
- package/umd/dnb-ui-extensions.min.js +1 -1
- package/umd/dnb-ui-lib.min.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Upload.js","names":["React","useCallback","useEffect","useMemo","useRef","classnames","FieldBlock","useFieldProps","useTranslation","useFormsTranslation","Upload","useUpload","pickSpacingProps","HelpButtonInline","HelpButtonInlineContent","useSharedTranslation","FormError","validateRequired","value","_ref","required","isChanged","error","hasError","some","file","errorMessage","hasFiles","length","undefined","UploadComponent","props","sharedTr","formsTr","errorMessages","errorRequired","fromInput","forEach","item","index","_item$file","name","preparedProps","_objectSpread","toInput","transformFiles","_useFieldProps","executeOnChangeRegardlessOfError","id","className","width","widthProp","label","labelDescription","help","htmlAttributes","handleChange","handleFocus","handleBlur","fileHandler","rest","_objectWithoutProperties","_excluded","title","text","acceptedFileTypes","filesAmountLimit","fileMaxSize","skeleton","onFileDelete","onFileClick","download","allowDuplicates","files","setFiles","filesRef","current","handleChangeAsync","_filesRef$current","existingFileIds","map","newFiles","filter","includes","newValidFiles","newFilesLoading","isLoading","incomingFiles","incomingFileObj","foundIndex","findIndex","newFile","push","indexOfFirstNewFile","_ref2","updatedFiles","slice","changeHandler","_ref3","fieldBlockProps","forId","labelSrOnly","createElement","_extends","onChange","Fragment","contentId","left","roundedCorner","_supportsSpacingProps","Array","isArray","File","_lastModified","_item$file2","_type","_item$file3","lastModified","type"],"sources":["../../../../../../src/extensions/forms/Field/Upload/Upload.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport classnames from 'classnames'\nimport FieldBlock, {\n Props as FieldBlockProps,\n FieldBlockWidth,\n} from '../../FieldBlock'\nimport {\n useFieldProps,\n useTranslation as useFormsTranslation,\n} from '../../hooks'\nimport { FieldProps } from '../../types'\nimport Upload, {\n UploadFile,\n UploadFileNative,\n UploadProps,\n} from '../../../../components/Upload'\nimport useUpload from '../../../../components/upload/useUpload'\nimport { pickSpacingProps } from '../../../../components/flex/utils'\nimport HelpButtonInline, {\n HelpButtonInlineContent,\n} from '../../../../components/help-button/HelpButtonInline'\nimport { useTranslation as useSharedTranslation } from '../../../../shared'\nimport { SpacingProps } from '../../../../shared/types'\nimport { FormError } from '../../utils'\n\nexport type { UploadFile, UploadFileNative }\nexport type UploadValue = Array<UploadFile | UploadFileNative>\nexport type Props = Omit<\n FieldProps<UploadValue, UploadValue | undefined>,\n 'name'\n> &\n SpacingProps & {\n width?: Omit<FieldBlockWidth, 'medium' | 'small'>\n } & Pick<\n Partial<UploadProps>,\n | 'title'\n | 'text'\n | 'acceptedFileTypes'\n | 'filesAmountLimit'\n | 'fileMaxSize'\n | 'onFileDelete'\n | 'onFileClick'\n | 'skeleton'\n | 'download'\n | 'allowDuplicates'\n > & {\n fileHandler?: (\n newFiles: UploadValue\n ) => UploadValue | Promise<UploadValue>\n }\n\nconst validateRequired = (\n value: UploadValue,\n { required, isChanged, error }\n) => {\n const hasError = value?.some((file) => file.errorMessage)\n if (hasError) {\n return new FormError('Upload.errorInvalidFiles')\n }\n\n const hasFiles = value?.length > 0\n if (required && ((!isChanged && !hasFiles) || !hasFiles)) {\n return error\n }\n\n return undefined\n}\n\nfunction UploadComponent(props: Props) {\n const sharedTr = useSharedTranslation().Upload\n const formsTr = useFormsTranslation().Upload\n\n const errorMessages = useMemo(\n () => ({\n 'Field.errorRequired': formsTr.errorRequired,\n }),\n [formsTr.errorRequired]\n )\n\n const fromInput = useCallback((value: UploadValue) => {\n value.forEach((item, index) => {\n value[index] = item\n\n // Store the name in the value, to support session storage (serialization)\n value[index]['name'] = item['name'] || item.file?.name\n })\n\n return value\n }, [])\n\n const preparedProps = {\n errorMessages,\n validateRequired,\n fromInput,\n toInput: transformFiles,\n ...props,\n }\n\n const {\n id,\n className,\n width: widthProp = 'stretch',\n value,\n label,\n labelDescription,\n help,\n htmlAttributes,\n handleChange,\n handleFocus,\n handleBlur,\n fileHandler,\n ...rest\n } = useFieldProps(preparedProps, {\n executeOnChangeRegardlessOfError: true,\n })\n\n // Upload props\n const {\n title = sharedTr.title,\n text = sharedTr.text,\n acceptedFileTypes = ['pdf', 'png', 'jpg', 'jpeg'],\n filesAmountLimit = 100,\n fileMaxSize = 5,\n skeleton,\n onFileDelete,\n onFileClick,\n download,\n allowDuplicates,\n } = rest\n\n const { files, setFiles } = useUpload(id)\n\n const filesRef = useRef<Array<UploadFile>>()\n\n useEffect(() => {\n filesRef.current = files\n }, [files])\n\n useEffect(() => {\n setFiles(value)\n }, [setFiles, value])\n\n const handleChangeAsync = useCallback(\n async (files: UploadValue) => {\n // Filter out existing files\n const existingFileIds =\n filesRef.current?.map((file) => file.id) || []\n const newFiles = files.filter(\n (file) => !existingFileIds.includes(file.id)\n )\n const newValidFiles = newFiles.filter((file) => !file.errorMessage)\n\n if (newValidFiles.length > 0) {\n // Set loading\n const newFilesLoading = newFiles.map((file) => ({\n ...file,\n isLoading: !file.errorMessage,\n }))\n setFiles([...filesRef.current, ...newFilesLoading])\n\n const incomingFiles = await fileHandler(newValidFiles)\n // merge incoming files into existing order of newFiles.\n incomingFiles.forEach((file) => {\n const incomingFileObj = {\n ...file,\n isLoading: false,\n }\n const foundIndex = newFilesLoading.findIndex(\n (newFile) => newFile.isLoading\n )\n if (foundIndex >= 0) {\n newFilesLoading[foundIndex] = incomingFileObj\n } else {\n // if there's more files incoming than there's files loading (edge case), add them to end of array.\n newFilesLoading.push(incomingFileObj)\n }\n })\n\n const indexOfFirstNewFile = filesRef.current.findIndex(\n ({ id }) => id === newFiles[0].id\n )\n\n const updatedFiles = [\n ...filesRef.current.slice(0, indexOfFirstNewFile),\n ...newFilesLoading,\n ...filesRef.current.slice(\n indexOfFirstNewFile + newFilesLoading.length\n ),\n ]\n\n // Set error, if any\n handleChange(updatedFiles)\n } else {\n handleChange(files)\n }\n },\n [setFiles, fileHandler, handleChange]\n )\n\n const changeHandler = useCallback(\n ({ files }: { files: UploadValue }) => {\n // Prevents the form-status from showing up\n handleBlur()\n handleFocus()\n\n if (fileHandler) {\n handleChangeAsync(files)\n } else {\n handleChange(files)\n }\n },\n [handleBlur, handleFocus, fileHandler, handleChangeAsync, handleChange]\n )\n\n const width = widthProp as FieldBlockWidth\n const fieldBlockProps: FieldBlockProps = {\n id,\n forId: `${id}-input`,\n labelSrOnly: true,\n className: classnames('dnb-forms-field-upload', className),\n width,\n help: undefined,\n ...pickSpacingProps(props),\n }\n\n return (\n <FieldBlock {...fieldBlockProps}>\n <Upload\n id={id}\n acceptedFileTypes={acceptedFileTypes}\n filesAmountLimit={filesAmountLimit}\n download={download}\n allowDuplicates={allowDuplicates}\n fileMaxSize={fileMaxSize}\n skeleton={skeleton}\n onChange={changeHandler}\n onFileDelete={onFileDelete}\n onFileClick={onFileClick}\n title={label ?? title}\n text={\n help ? (\n <>\n {labelDescription ?? text}\n <HelpButtonInline\n contentId={`${id}-help`}\n left={text ? 'x-small' : false}\n help={help}\n />\n </>\n ) : (\n labelDescription ?? text\n )\n }\n {...htmlAttributes}\n >\n {help && (\n <HelpButtonInlineContent\n contentId={`${id}-help`}\n help={help}\n roundedCorner={false}\n />\n )}\n </Upload>\n </FieldBlock>\n )\n}\n\nexport default UploadComponent\n\nUploadComponent._supportsSpacingProps = true\n\nexport function transformFiles(value: UploadValue) {\n if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined\n }\n\n value.map((item) => {\n if (item?.file && !(item.file instanceof File)) {\n // To support session storage, we recreated the file blob.\n item['file'] = new File([], item['name'] || item?.file['name'], {\n lastModified: (item.file as File)?.lastModified ?? 0,\n type: (item.file as File)?.type ?? '',\n })\n }\n return item\n })\n }\n\n return value\n}\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACtE,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,UAAU,MAGV,kBAAkB;AACzB,SACEC,aAAa,EACbC,cAAc,IAAIC,mBAAmB,QAChC,aAAa;AAEpB,OAAOC,MAAM,MAIN,+BAA+B;AACtC,OAAOC,SAAS,MAAM,yCAAyC;AAC/D,SAASC,gBAAgB,QAAQ,mCAAmC;AACpE,OAAOC,gBAAgB,IACrBC,uBAAuB,QAClB,qDAAqD;AAC5D,SAASN,cAAc,IAAIO,oBAAoB,QAAQ,oBAAoB;AAE3E,SAASC,SAAS,QAAQ,aAAa;AA4BvC,MAAMC,gBAAgB,GAAGA,CACvBC,KAAkB,EAAAC,IAAA,KAEf;EAAA,IADH;IAAEC,QAAQ;IAAEC,SAAS;IAAEC;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AClB,IAAIA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEb,IAAI,IAAI,EAAEa,IAAI,CAACb,IAAI,YAAYuF,IAAI,CAAC,EAAE;QAAA,IAAAC,aAAA,EAAAC,WAAA,EAAAC,KAAA,EAAAC,WAAA;QAE9C9E,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI0E,IAAI,CAAC,EAAE,EAAE1E,IAAI,CAAC,MAAM,CAAC,KAAIA,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEb,IAAI,CAAC,MAAM,CAAC,GAAE;UAC9D4F,YAAY,GAAAJ,aAAA,IAAAC,WAAA,GAAG5E,IAAI,CAACb,IAAI,cAAAyF,WAAA,uBAAVA,WAAA,CAAqBG,YAAY,cAAAJ,aAAA,cAAAA,aAAA,GAAI,CAAC;UACpDK,IAAI,GAAAH,KAAA,IAAAC,WAAA,GAAG9E,IAAI,CAACb,IAAI,cAAA2F,WAAA,uBAAVA,WAAA,CAAqBE,IAAI,cAAAH,KAAA,cAAAA,KAAA,GAAI;QACrC,CAAC,CAAC;MACJ;MACA,OAAO7E,IAAI;IACb,CAAC,CAAC;EACJ;EAEA,OAAOpB,KAAK;AACd","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Upload.js","names":["React","useCallback","useEffect","useMemo","useRef","classnames","FieldBlock","useFieldProps","useTranslation","useFormsTranslation","Upload","useUpload","pickSpacingProps","HelpButtonInline","HelpButtonInlineContent","useSharedTranslation","FormError","validateRequired","value","_ref","required","isChanged","error","hasError","some","file","errorMessage","hasFiles","length","undefined","UploadComponent","props","sharedTr","formsTr","errorMessages","errorRequired","fromInput","forEach","item","index","_item$file","name","preparedProps","_objectSpread","toInput","transformFiles","_useFieldProps","executeOnChangeRegardlessOfError","id","className","width","widthProp","label","labelDescription","help","htmlAttributes","handleChange","handleFocus","handleBlur","fileHandler","rest","_objectWithoutProperties","_excluded","title","text","acceptedFileTypes","filesAmountLimit","fileMaxSize","skeleton","onFileDelete","onFileClick","download","allowDuplicates","disableDragAndDrop","files","setFiles","filesRef","current","handleChangeAsync","_filesRef$current","existingFileIds","map","newFiles","filter","includes","newValidFiles","newFilesLoading","isLoading","incomingFiles","incomingFileObj","foundIndex","findIndex","newFile","push","indexOfFirstNewFile","_ref2","updatedFiles","slice","changeHandler","_ref3","fieldBlockProps","forId","labelSrOnly","createElement","_extends","onChange","Fragment","contentId","left","roundedCorner","_supportsSpacingProps","Array","isArray","File","_lastModified","_item$file2","_type","_item$file3","lastModified","type"],"sources":["../../../../../../src/extensions/forms/Field/Upload/Upload.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport classnames from 'classnames'\nimport FieldBlock, {\n Props as FieldBlockProps,\n FieldBlockWidth,\n} from '../../FieldBlock'\nimport {\n useFieldProps,\n useTranslation as useFormsTranslation,\n} from '../../hooks'\nimport { FieldProps } from '../../types'\nimport Upload, {\n UploadFile,\n UploadFileNative,\n UploadProps,\n} from '../../../../components/Upload'\nimport useUpload from '../../../../components/upload/useUpload'\nimport { pickSpacingProps } from '../../../../components/flex/utils'\nimport HelpButtonInline, {\n HelpButtonInlineContent,\n} from '../../../../components/help-button/HelpButtonInline'\nimport { useTranslation as useSharedTranslation } from '../../../../shared'\nimport { SpacingProps } from '../../../../shared/types'\nimport { FormError } from '../../utils'\n\nexport type { UploadFile, UploadFileNative }\nexport type UploadValue = Array<UploadFile | UploadFileNative>\nexport type Props = Omit<\n FieldProps<UploadValue, UploadValue | undefined>,\n 'name'\n> &\n SpacingProps & {\n width?: Omit<FieldBlockWidth, 'medium' | 'small'>\n } & Pick<\n Partial<UploadProps>,\n | 'title'\n | 'text'\n | 'acceptedFileTypes'\n | 'filesAmountLimit'\n | 'fileMaxSize'\n | 'onFileDelete'\n | 'onFileClick'\n | 'skeleton'\n | 'download'\n | 'allowDuplicates'\n | 'disableDragAndDrop'\n > & {\n fileHandler?: (\n newFiles: UploadValue\n ) => UploadValue | Promise<UploadValue>\n }\n\nconst validateRequired = (\n value: UploadValue,\n { required, isChanged, error }\n) => {\n const hasError = value?.some((file) => file.errorMessage)\n if (hasError) {\n return new FormError('Upload.errorInvalidFiles')\n }\n\n const hasFiles = value?.length > 0\n if (required && ((!isChanged && !hasFiles) || !hasFiles)) {\n return error\n }\n\n return undefined\n}\n\nfunction UploadComponent(props: Props) {\n const sharedTr = useSharedTranslation().Upload\n const formsTr = useFormsTranslation().Upload\n\n const errorMessages = useMemo(\n () => ({\n 'Field.errorRequired': formsTr.errorRequired,\n }),\n [formsTr.errorRequired]\n )\n\n const fromInput = useCallback((value: UploadValue) => {\n value.forEach((item, index) => {\n value[index] = item\n\n // Store the name in the value, to support session storage (serialization)\n value[index]['name'] = item['name'] || item.file?.name\n })\n\n return value\n }, [])\n\n const preparedProps = {\n errorMessages,\n validateRequired,\n fromInput,\n toInput: transformFiles,\n ...props,\n }\n\n const {\n id,\n className,\n width: widthProp = 'stretch',\n value,\n label,\n labelDescription,\n help,\n htmlAttributes,\n handleChange,\n handleFocus,\n handleBlur,\n fileHandler,\n ...rest\n } = useFieldProps(preparedProps, {\n executeOnChangeRegardlessOfError: true,\n })\n\n // Upload props\n const {\n title = sharedTr.title,\n text = sharedTr.text,\n acceptedFileTypes = ['pdf', 'png', 'jpg', 'jpeg'],\n filesAmountLimit = 100,\n fileMaxSize = 5,\n skeleton,\n onFileDelete,\n onFileClick,\n download,\n allowDuplicates,\n disableDragAndDrop,\n } = rest\n\n const { files, setFiles } = useUpload(id)\n\n const filesRef = useRef<Array<UploadFile>>()\n\n useEffect(() => {\n filesRef.current = files\n }, [files])\n\n useEffect(() => {\n setFiles(value)\n }, [setFiles, value])\n\n const handleChangeAsync = useCallback(\n async (files: UploadValue) => {\n // Filter out existing files\n const existingFileIds =\n filesRef.current?.map((file) => file.id) || []\n const newFiles = files.filter(\n (file) => !existingFileIds.includes(file.id)\n )\n const newValidFiles = newFiles.filter((file) => !file.errorMessage)\n\n if (newValidFiles.length > 0) {\n // Set loading\n const newFilesLoading = newFiles.map((file) => ({\n ...file,\n isLoading: !file.errorMessage,\n }))\n setFiles([...filesRef.current, ...newFilesLoading])\n\n const incomingFiles = await fileHandler(newValidFiles)\n // merge incoming files into existing order of newFiles.\n incomingFiles.forEach((file) => {\n const incomingFileObj = {\n ...file,\n isLoading: false,\n }\n const foundIndex = newFilesLoading.findIndex(\n (newFile) => newFile.isLoading\n )\n if (foundIndex >= 0) {\n newFilesLoading[foundIndex] = incomingFileObj\n } else {\n // if there's more files incoming than there's files loading (edge case), add them to end of array.\n newFilesLoading.push(incomingFileObj)\n }\n })\n\n const indexOfFirstNewFile = filesRef.current.findIndex(\n ({ id }) => id === newFiles[0].id\n )\n\n const updatedFiles = [\n ...filesRef.current.slice(0, indexOfFirstNewFile),\n ...newFilesLoading,\n ...filesRef.current.slice(\n indexOfFirstNewFile + newFilesLoading.length\n ),\n ]\n\n // Set error, if any\n handleChange(updatedFiles)\n } else {\n handleChange(files)\n }\n },\n [setFiles, fileHandler, handleChange]\n )\n\n const changeHandler = useCallback(\n ({ files }: { files: UploadValue }) => {\n // Prevents the form-status from showing up\n handleBlur()\n handleFocus()\n\n if (fileHandler) {\n handleChangeAsync(files)\n } else {\n handleChange(files)\n }\n },\n [handleBlur, handleFocus, fileHandler, handleChangeAsync, handleChange]\n )\n\n const width = widthProp as FieldBlockWidth\n const fieldBlockProps: FieldBlockProps = {\n id,\n forId: `${id}-input`,\n labelSrOnly: true,\n className: classnames('dnb-forms-field-upload', className),\n width,\n help: undefined,\n ...pickSpacingProps(props),\n }\n\n return (\n <FieldBlock {...fieldBlockProps}>\n <Upload\n id={id}\n acceptedFileTypes={acceptedFileTypes}\n filesAmountLimit={filesAmountLimit}\n download={download}\n allowDuplicates={allowDuplicates}\n disableDragAndDrop={disableDragAndDrop}\n fileMaxSize={fileMaxSize}\n skeleton={skeleton}\n onChange={changeHandler}\n onFileDelete={onFileDelete}\n onFileClick={onFileClick}\n title={label ?? title}\n text={\n help ? (\n <>\n {labelDescription ?? text}\n <HelpButtonInline\n contentId={`${id}-help`}\n left={text ? 'x-small' : false}\n help={help}\n />\n </>\n ) : (\n labelDescription ?? text\n )\n }\n {...htmlAttributes}\n >\n {help && (\n <HelpButtonInlineContent\n contentId={`${id}-help`}\n help={help}\n roundedCorner={false}\n />\n )}\n </Upload>\n </FieldBlock>\n )\n}\n\nexport default UploadComponent\n\nUploadComponent._supportsSpacingProps = true\n\nexport function transformFiles(value: UploadValue) {\n if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined\n }\n\n value.map((item) => {\n if (item?.file && !(item.file instanceof File)) {\n // To support session storage, we recreated the file blob.\n item['file'] = new File([], item['name'] || item?.file['name'], {\n lastModified: (item.file as File)?.lastModified ?? 0,\n type: (item.file as File)?.type ?? '',\n })\n }\n return item\n })\n }\n\n return value\n}\n"],"mappings":";;;;;;;;;AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACtE,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,UAAU,MAGV,kBAAkB;AACzB,SACEC,aAAa,EACbC,cAAc,IAAIC,mBAAmB,QAChC,aAAa;AAEpB,OAAOC,MAAM,MAIN,+BAA+B;AACtC,OAAOC,SAAS,MAAM,yCAAyC;AAC/D,SAASC,gBAAgB,QAAQ,mCAAmC;AACpE,OAAOC,gBAAgB,IACrBC,uBAAuB,QAClB,qDAAqD;AAC5D,SAASN,cAAc,IAAIO,oBAAoB,QAAQ,oBAAoB;AAE3E,SAASC,SAAS,QAAQ,aAAa;AA6BvC,MAAMC,gBAAgB,GAAGA,CACvBC,KAAkB,EAAAC,IAAA,KAEf;EAAA,IADH;IAAEC,QAAQ;IAAEC,SAAS;IAAEC;EAAM,CAAC,GAAAH,IAAA;EAE9B,MAAMI,QAAQ,GAAGL,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEM,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAACC,YAAY,CAAC;EACzD,IAAI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C,EAAE;QAAA,IAAAC,aAAA,EAAAC,WAAA,EAAAC,KAAA,EAAAC,WAAA;QAE9C/E,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI2E,IAAI,CAAC,EAAE,EAAE3E,IAAI,CAAC,MAAM,CAAC,KAAIA,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEb,IAAI,CAAC,MAAM,CAAC,GAAE;UAC9D6F,YAAY,GAAAJ,aAAA,IAAAC,WAAA,GAAG7E,IAAI,CAACb,IAAI,cAAA0F,WAAA,uBAAVA,WAAA,CAAqBG,YAAY,cAAAJ,aAAA,cAAAA,aAAA,GAAI,CAAC;UACpDK,IAAI,GAAAH,KAAA,IAAAC,WAAA,GAAG/E,IAAI,CAACb,IAAI,cAAA4F,WAAA,uBAAVA,WAAA,CAAqBE,IAAI,cAAAH,KAAA,cAAAA,KAAA,GAAI;QACrC,CAAC,CAAC;MACJ;MACA,OAAO9E,IAAI;IACb,CAAC,CAAC;EACJ;EAEA,OAAOpB,KAAK;AACd","ignoreList":[]}
|
|
@@ -373,22 +373,29 @@ function CombineMessages(_ref4) {
|
|
|
373
373
|
}, message);
|
|
374
374
|
})));
|
|
375
375
|
}
|
|
376
|
+
function getMessage(error) {
|
|
377
|
+
if (error instanceof FormError) {
|
|
378
|
+
var _error$formattedMessa;
|
|
379
|
+
return (_error$formattedMessa = error.formattedMessage) !== null && _error$formattedMessa !== void 0 ? _error$formattedMessa : error.message;
|
|
380
|
+
}
|
|
381
|
+
return error.message;
|
|
382
|
+
}
|
|
376
383
|
export function getMessagesFromError(item) {
|
|
377
384
|
const {
|
|
378
385
|
content
|
|
379
386
|
} = item;
|
|
380
387
|
if (content instanceof FormError && Array.isArray(content.errors)) {
|
|
381
|
-
return content.errors.map(
|
|
382
|
-
return
|
|
388
|
+
return content.errors.map(content => {
|
|
389
|
+
return getMessage(content);
|
|
383
390
|
});
|
|
384
391
|
}
|
|
385
392
|
if (Array.isArray(content)) {
|
|
386
393
|
return content.map(content => {
|
|
387
|
-
return content instanceof FormError || content instanceof Error ? content
|
|
394
|
+
return content instanceof FormError || content instanceof Error ? getMessage(content) : content;
|
|
388
395
|
});
|
|
389
396
|
}
|
|
390
397
|
if (content instanceof FormError || content instanceof Error) {
|
|
391
|
-
return [content
|
|
398
|
+
return [getMessage(content)];
|
|
392
399
|
}
|
|
393
400
|
return [(React.isValidElement(content) ? content : content === null || content === void 0 ? void 0 : content.toString()) || content];
|
|
394
401
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldBlock.js","names":["React","useMemo","useContext","useCallback","useRef","useReducer","useEffect","classnames","FieldBlockContext","DataContext","Space","FormLabel","FormStatus","Ul","Li","convertJsxToString","findElementInChildren","useId","HelpButtonInline","HelpButtonInlineContent","SubmitIndicator","createSharedState","useTranslation","FormError","useIterateItemNo","states","FieldBlock","props","_props$id","dataContext","fieldBlockContext","nestedFieldBlockContext","disableStatusSummary","id","forId","sharedData","_Object$assign","Object","assign","data","className","layout","layoutOptions","composition","label","labelProp","labelDescription","labelDescriptionInline","labelSuffix","labelSrOnly","help","asFieldset","required","info","warning","error","fieldState","disabled","width","contentWidth","labelHeight","align","labelSize","contentClassName","children","rest","_objectWithoutProperties","_excluded","hasCustomWidth","test","String","hasCustomContentWidth","infoRef","warningRef","errorRef","blockId","salt","forceUpdate","mountedFieldsRef","Map","fieldStateRef","stateRecordRef","fieldStateIdsRef","contentsRef","hasInitiallyErrorPropRef","Boolean","setInternalRecord","stateId","identifier","type","current","existingIndex","findIndex","item","_objectSpread","push","setBlockRecordNested","setBlockRecord","setFieldState","showFieldError","show","map","showInitially","statusContent","content","statesWithMessages","entries","flatMap","_ref","reduce","acc","cur","existing","find","messages","getMessagesFromError","message","undefined","state","width_element","no_animation","process","env","NODE_ENV","globalThis","IS_TEST","found","msg","filter","_ref2","i","arr","length","createElement","CombineMessages","mainClasses","gridClasses","enableFieldset","useEnableFieldset","labelProps","element","srOnly","space","size","mainStyle","_lO$minWidth","_lO$maxWidth","style","lO","min","getFieldWidth","minWidth","max","maxWidth","prerenderFieldProps","hasLabelDescription","isFragment","fragmentHasChildren","fragmentHasOnlyUndefinedChildren","hasHelp","title","Provider","value","hasErrorProp","_extends","contentId","_br","breakout","outset","parseFloat","ref","_ref3","result","count","child","_child$props","_child$type","_ref4","translations","Field","Fragment","errorSummary","stateSummary","_ref5","key","Array","isArray","errors","Error","isValidElement","toString","fragment","Children","isUndefined","toArray","every","_supportsSpacingProps"],"sources":["../../../../../src/extensions/forms/FieldBlock/FieldBlock.tsx"],"sourcesContent":["import React, {\n useMemo,\n useContext,\n useCallback,\n useRef,\n useReducer,\n useEffect,\n} from 'react'\nimport classnames from 'classnames'\nimport FieldBlockContext, {\n StateWithMessage,\n StatesWithMessages,\n FieldErrorIdsRef,\n MountedFieldsRef,\n StateRecord,\n StateMessage,\n StateTypes,\n StatusContent,\n FieldBlockContextProps,\n StateBasis,\n} from './FieldBlockContext'\nimport DataContext from '../DataContext/Context'\nimport { Space, FormLabel, FormStatus } from '../../../components'\nimport { Ul, Li } from '../../../elements'\nimport {\n convertJsxToString,\n findElementInChildren,\n} from '../../../shared/component-helper'\nimport useId from '../../../shared/helpers/useId'\nimport {\n ComponentProps,\n FieldProps,\n SubmitState,\n Identifier,\n UseFieldProps,\n} from '../types'\nimport type { FormLabelAllProps } from '../../../components/FormLabel'\nimport HelpButtonInline, {\n HelpButtonInlineContent,\n HelpProps,\n} from '../../../components/help-button/HelpButtonInline'\nimport SubmitIndicator from '../Form/SubmitIndicator/SubmitIndicator'\nimport { createSharedState } from '../../../shared/helpers/useSharedState'\nimport useTranslation from '../hooks/useTranslation'\nimport { FormError } from '../utils'\nimport { useIterateItemNo } from '../Iterate/ItemNo/useIItemNo'\n\nexport const states: Array<StateTypes> = ['error', 'info', 'warning']\n\n/**\n * The width of a field block\n */\nexport type CustomWidth = `${number}rem`\nexport type FieldBlockWidth =\n | false\n | 'small'\n | 'medium'\n | 'large'\n | 'stretch'\n | CustomWidth\nexport type FieldBlockHorizontalLabelWidth =\n | 'small'\n | 'medium'\n | 'large'\n | CustomWidth\nexport type FieldBlockHorizontalLabelHeight =\n | 'default'\n | 'small'\n | 'medium'\n | 'large'\n\nexport type SharedFieldBlockProps = {\n /**\n * The layout of the field block\n */\n layout?: 'vertical' | 'horizontal'\n /** Use this to set additional options for the layout */\n layoutOptions?: {\n width?: FieldBlockHorizontalLabelWidth\n minWidth?: FieldBlockHorizontalLabelWidth\n maxWidth?: FieldBlockHorizontalLabelWidth\n }\n /**\n * Main label text for the field\n */\n label?: React.ReactNode\n /**\n * Will append an additional text to the label, like \"(optional)\" or \"(recommended)\"\n */\n labelSuffix?: React.ReactNode\n /**\n * A more discreet text displayed beside the label\n */\n labelDescription?: React.ReactNode\n /**\n * If true, the labelDescription will be displayed on the same line as the label.\n */\n labelDescriptionInline?: boolean\n /**\n * Width of outer block element\n */\n width?: FieldBlockWidth\n /**\n * Width of contents block, while label etc can be wider if space is available\n */\n contentWidth?: FieldBlockWidth\n /**\n * Provide help content for the field.\n */\n help?: HelpProps\n}\n\nexport type Props<Value = unknown> = SharedFieldBlockProps &\n Pick<\n FieldProps<Value>,\n keyof ComponentProps | 'info' | 'warning' | 'error' | 'disabled'\n > & {\n /** The id to link a element with */\n forId?: string\n /** Use true if you have more than one form element */\n asFieldset?: boolean\n /** use `true` to make the label only readable by screen readers. */\n labelSrOnly?: boolean\n /** Defines the layout of nested fields */\n composition?: FieldBlockContextProps['composition']\n /** For composition only: Align the contents vertically */\n align?: 'center' | 'bottom'\n /** Class name for the contents block */\n contentClassName?: string\n /** To show the SubmitIndicator during async validation */\n fieldState?: SubmitState\n /** Typography size */\n labelSize?: 'medium' | 'large'\n /** Defines the height of an component (size prop), so the label can be aligned correctly */\n labelHeight?: FieldBlockHorizontalLabelHeight\n /** Disable the error summary for this field block */\n disableStatusSummary?: boolean\n /** For internal use only */\n required?: boolean\n children?: React.ReactNode\n } & React.HTMLAttributes<HTMLDivElement>\n\nfunction FieldBlock<Value = unknown>(props: Props<Value>) {\n const dataContext = useContext(DataContext)\n const fieldBlockContext = useContext(FieldBlockContext)\n const nestedFieldBlockContext = !fieldBlockContext?.disableStatusSummary\n ? fieldBlockContext\n : null\n\n const id = useId(props.id ?? props.forId)\n const sharedData = createSharedState<Props>('field-block-props-' + id)\n const {\n className,\n forId,\n layout = 'vertical',\n layoutOptions,\n composition,\n label: labelProp,\n labelDescription,\n labelDescriptionInline,\n labelSuffix,\n labelSrOnly,\n help,\n asFieldset,\n required,\n info,\n warning,\n error,\n disableStatusSummary,\n fieldState,\n disabled,\n width,\n contentWidth,\n labelHeight,\n align,\n labelSize,\n contentClassName,\n children,\n ...rest\n } = Object.assign({}, sharedData.data, props)\n const hasCustomWidth = /\\d(rem)$/.test(String(width))\n const hasCustomContentWidth = /\\d(rem)$/.test(String(contentWidth))\n\n const infoRef = useRef<UseFieldProps['info']>()\n const warningRef = useRef<UseFieldProps['warning']>()\n const errorRef = useRef<UseFieldProps['error']>()\n\n const blockId = useId(props.id)\n const [salt, forceUpdate] = useReducer(() => ({}), {})\n const mountedFieldsRef = useRef<MountedFieldsRef>(new Map())\n const fieldStateRef = useRef<SubmitState>(null)\n const stateRecordRef = useRef<StateRecord>({})\n const fieldStateIdsRef = useRef<FieldErrorIdsRef>(null)\n const contentsRef = useRef<HTMLDivElement>(null)\n const hasInitiallyErrorPropRef = useRef(Boolean(error))\n\n const label = useIterateItemNo({\n label: labelProp,\n labelSuffix,\n required,\n })\n\n const setInternalRecord = useCallback((props: StateBasis) => {\n const { stateId, identifier, type } = props\n\n if (!stateRecordRef.current[identifier]) {\n stateRecordRef.current[identifier] = []\n }\n\n fieldStateIdsRef.current = { error: null, warning: null, info: null }\n\n const existingIndex = stateRecordRef.current[identifier].findIndex(\n (item) => {\n return item.stateId === stateId && item.type === type\n }\n )\n\n if (existingIndex > -1) {\n stateRecordRef.current[identifier][existingIndex] = {\n ...stateRecordRef.current[identifier][existingIndex],\n ...props,\n }\n } else {\n stateRecordRef.current[identifier].push(props)\n }\n }, [])\n\n const setBlockRecordNested = nestedFieldBlockContext?.setBlockRecord\n const setBlockRecord = useCallback(\n (props: StateBasis) => {\n if (setBlockRecordNested) {\n // If this FieldBlock is inside another one, forward the call to the outer one\n setBlockRecordNested(props)\n return\n }\n\n setInternalRecord(props)\n\n forceUpdate()\n },\n [setBlockRecordNested, setInternalRecord]\n )\n\n const setFieldState = useCallback(\n (identifier: Identifier, fieldState: SubmitState) => {\n if (fieldState !== fieldStateRef.current) {\n fieldStateRef.current = fieldState\n\n forceUpdate()\n }\n },\n []\n )\n\n const showFieldError = useCallback(\n (identifier: Identifier, show: boolean) => {\n if (nestedFieldBlockContext) {\n // If this FieldBlock is inside another one, forward the call to the outer one\n nestedFieldBlockContext.showFieldError(identifier, show)\n return\n }\n\n if (stateRecordRef.current[identifier]) {\n stateRecordRef.current[identifier] = stateRecordRef.current[\n identifier\n ].map((item) => {\n if (item.showInitially) {\n return item\n }\n\n return {\n ...item,\n show,\n }\n })\n\n forceUpdate()\n }\n },\n [nestedFieldBlockContext]\n )\n\n const statusContent = useMemo(() => {\n if (typeof error !== 'undefined' || (errorRef.current && !error)) {\n errorRef.current = error\n setInternalRecord({\n identifier: blockId,\n showInitially: hasInitiallyErrorPropRef.current,\n type: 'error',\n content: error,\n })\n }\n\n if (typeof warning !== 'undefined' || warningRef.current !== warning) {\n warningRef.current = warning\n setInternalRecord({\n identifier: blockId,\n showInitially: true,\n type: 'warning',\n content: warning,\n })\n }\n\n if (typeof info !== 'undefined' || infoRef.current !== info) {\n infoRef.current = info\n setInternalRecord({\n identifier: blockId,\n showInitially: true,\n type: 'info',\n content: info,\n })\n }\n\n const statesWithMessages: Array<StatesWithMessages> =\n // 1. Prepare the states for later use\n Object.entries(stateRecordRef.current)\n .flatMap(([identifier, states]) =>\n states.map((props) => {\n return {\n identifier,\n ...props,\n }\n })\n )\n\n // 2. Take states and group the same type together\n .reduce((acc, cur) => {\n const existing = acc.find((item) => {\n return item.type === cur.type\n })\n\n const messages = getMessagesFromError(cur).map((message) => {\n return {\n ...cur,\n message,\n }\n })\n\n if (existing) {\n existing.messages.push(...messages)\n } else {\n acc.push({\n ...cur,\n content: undefined,\n messages,\n })\n }\n\n return acc\n }, [] as Array<StatesWithMessages>)\n\n // 3. Return the grouped states/messages\n return states.reduce((acc, type) => {\n const id = `${props.id || forId || blockId}-form-status--${type}`\n acc[type] = {\n id,\n label,\n state: type === 'warning' ? 'warn' : type,\n width_element: contentsRef,\n\n // Enable animation only in the browser and not in tests\n no_animation:\n process.env.NODE_ENV === 'test'\n ? true\n : typeof globalThis !== 'undefined'\n ? globalThis.IS_TEST === true\n : false,\n }\n\n const found = statesWithMessages.find((item) => {\n return item.type === type\n })\n\n if (found?.messages) {\n // Hide/remove messages that should be hidden and are not marked as to be shown initially\n const messages = found.messages\n .map((msg) => {\n if (msg.type === 'error') {\n if (!msg.showInitially && !msg.show) {\n msg.message = null\n }\n }\n\n return msg\n })\n .filter(({ message }) => message)\n .reduce((acc, msg, i, arr) => {\n const existingIndex = arr.findIndex((item) => {\n return (\n convertJsxToString(item.message) ===\n convertJsxToString(msg.message)\n )\n })\n\n // Remove duplicates, use the first found message\n if (existingIndex === i) {\n acc.push(msg)\n }\n\n return acc\n }, [])\n\n // Combine the messages and put them in an ul/li list\n if (messages.length > 0) {\n acc[type] = {\n ...acc[type],\n children: <CombineMessages type={type} messages={messages} />,\n }\n\n fieldStateIdsRef.current[type] = id\n } else {\n fieldStateIdsRef.current[type] = undefined\n }\n }\n\n return acc\n }, salt) as StatusContent\n }, [\n error,\n warning,\n info,\n salt,\n setInternalRecord,\n blockId,\n props.id,\n forId,\n label,\n ])\n\n // Handle the error prop from outside\n useEffect(() => {\n if (!nestedFieldBlockContext) {\n showFieldError(blockId, Boolean(error))\n }\n }, [error, blockId, showFieldError, nestedFieldBlockContext])\n\n useEffect(\n () => () => {\n mountedFieldsRef.current = new Map()\n stateRecordRef.current = {}\n },\n []\n )\n\n const mainClasses = classnames(\n 'dnb-forms-field-block',\n width &&\n `dnb-forms-field-block--width-${hasCustomWidth ? 'custom' : width}`,\n contentWidth &&\n `dnb-forms-field-block--content-width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`,\n labelHeight && `dnb-forms-field-block--label-height-${labelHeight}`,\n composition && 'dnb-forms-field-block__composition',\n composition &&\n `dnb-forms-field-block__composition--${\n composition === true ? 'horizontal' : composition\n }`,\n className\n )\n const gridClasses = classnames(\n 'dnb-forms-field-block__grid',\n `dnb-forms-field-block--layout-${layout}`\n )\n\n // A child component with a label was found, use fieldset/legend instead of div/label\n const enableFieldset = useEnableFieldset({\n label,\n asFieldset,\n children,\n nestedFieldBlockContext,\n })\n\n const labelProps: FormLabelAllProps = {\n id: `${id}-label`,\n className: 'dnb-forms-field-block__label',\n element: enableFieldset ? 'legend' : 'label',\n forId: enableFieldset ? undefined : forId,\n srOnly: labelSrOnly,\n space: 0, // Use CSS for spacing, but we need to reset space for doing so\n size: labelSize,\n disabled,\n }\n\n const mainStyle = useMemo(() => {\n const style: React.CSSProperties = {}\n\n if (hasCustomWidth) {\n style['--dnb-forms-field-block-width'] = width\n }\n\n if (hasCustomContentWidth) {\n style['--dnb-forms-field-block-content-width'] = contentWidth\n }\n\n const lO = layoutOptions || {}\n const min = getFieldWidth(lO.minWidth ?? lO.width)\n const max = getFieldWidth(lO.maxWidth ?? lO.width)\n\n if (typeof min === 'string') {\n style['--dnb-forms-field-block-layout-width-min'] = min\n }\n if (typeof max === 'string') {\n style['--dnb-forms-field-block-layout-width-max'] = max\n }\n\n return style\n }, [\n contentWidth,\n hasCustomContentWidth,\n hasCustomWidth,\n layoutOptions,\n width,\n ])\n\n if (dataContext?.prerenderFieldProps) {\n return null\n }\n\n const hasLabelDescription = isFragment(labelDescription)\n ? fragmentHasChildren(labelDescription) &&\n !fragmentHasOnlyUndefinedChildren(labelDescription)\n : labelDescription\n const hasHelp = help?.title || help?.content\n\n return (\n <FieldBlockContext.Provider\n value={{\n setBlockRecord,\n setFieldState,\n showFieldError,\n hasErrorProp: Boolean(error),\n fieldStateIdsRef,\n mountedFieldsRef,\n composition,\n disableStatusSummary,\n }}\n >\n <Space\n element={enableFieldset ? 'fieldset' : 'div'} // use fieldset and legend to enhance a11y\n style={mainStyle}\n className={mainClasses}\n {...rest}\n >\n <div className={gridClasses}>\n {(label || labelDescription || hasHelp) && (\n <FormLabel {...labelProps}>\n <span>\n {label && (\n <span className=\"dnb-forms-field-block__label__content\">\n {label}\n </span>\n )}\n\n {hasHelp && (\n <HelpButtonInline contentId={`${id}-help`} help={help} />\n )}\n\n {hasLabelDescription && !labelDescriptionInline && <br />}\n {hasLabelDescription && (\n <span className=\"dnb-forms-field-block__label__description\">\n {labelDescription}\n </span>\n )}\n </span>\n </FormLabel>\n )}\n\n {hasHelp && (\n <HelpButtonInlineContent\n contentId={`${id}-help`}\n className=\"dnb-forms-field-block__help\"\n help={help}\n breakout={\n layout === 'vertical' &&\n !nestedFieldBlockContext?.composition\n }\n outset={layout !== 'horizontal'}\n />\n )}\n\n <div\n className={classnames(\n 'dnb-forms-field-block__status',\n\n // Handle the width of the status messages\n contentWidth &&\n contentWidth !== 'small' &&\n contentWidth !== 'medium' &&\n !(parseFloat(contentWidth) <= 11) &&\n `dnb-forms-field-block__contents--width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`\n )}\n >\n <FormStatus {...statusContent?.error} />\n <FormStatus {...statusContent?.warning} />\n <FormStatus {...statusContent?.info} />\n </div>\n\n <div\n className={classnames(\n 'dnb-forms-field-block__contents',\n contentWidth &&\n `dnb-forms-field-block__contents--width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`,\n align && `dnb-forms-field-block__contents--align-${align}`,\n contentClassName\n )}\n ref={contentsRef}\n >\n {children}\n </div>\n\n <SubmitIndicator\n state={fieldState ?? fieldStateRef.current}\n className=\"dnb-forms-field-block__indicator dnb-forms-submit-indicator--inline-wrap\"\n />\n </div>\n </Space>\n </FieldBlockContext.Provider>\n )\n}\n\nfunction useEnableFieldset({\n label,\n asFieldset,\n children,\n nestedFieldBlockContext,\n}) {\n return useMemo(() => {\n if (asFieldset === false) {\n return false\n }\n\n let result = asFieldset\n\n if (label && !result && !nestedFieldBlockContext) {\n let count = 0\n\n findElementInChildren(children, (child: React.ReactElement) => {\n if (\n child?.props?.label ||\n child?.type?.['_formElement'] === true\n ) {\n count++\n }\n if (count > 1) {\n return (result = true)\n }\n })\n }\n\n return Boolean(result)\n }, [asFieldset, children, label, nestedFieldBlockContext])\n}\n\nfunction CombineMessages({\n type,\n messages,\n}: {\n type: StateTypes\n messages: Array<StateWithMessage>\n}) {\n const translations = useTranslation().Field\n\n if (messages.length === 1) {\n return <>{messages[0].message}</>\n }\n\n return (\n <>\n {type === 'error'\n ? translations.errorSummary\n : translations.stateSummary}\n <Ul>\n {messages.map(({ message }, i) => {\n return <Li key={i}>{message}</Li>\n })}\n </Ul>\n </>\n )\n}\n\nexport function getMessagesFromError(\n item: Partial<StateWithMessage>\n): Array<StateMessage> {\n const { content } = item\n\n if (content instanceof FormError && Array.isArray(content.errors)) {\n return content.errors.map((error) => {\n return error.message\n })\n }\n\n if (Array.isArray(content)) {\n return content.map((content) => {\n return content instanceof FormError || content instanceof Error\n ? content.message\n : content\n })\n }\n\n if (content instanceof FormError || content instanceof Error) {\n return [content.message as StateMessage]\n }\n\n return [\n ((React.isValidElement(content) ? content : content?.toString()) ||\n content) as StateMessage,\n ]\n}\n\nfunction isFragment(fragment: React.ReactNode) {\n return React.isValidElement(fragment) && fragment.type === React.Fragment\n}\n\nfunction fragmentHasChildren(fragment: React.ReactNode) {\n return (\n React.isValidElement(fragment) &&\n React.Children.count(fragment.props.children) > 0\n )\n}\n\nfunction fragmentHasOnlyUndefinedChildren(fragment: React.ReactNode) {\n const isUndefined = (child) => child === undefined\n\n return (\n React.isValidElement(fragment) &&\n React.Children.toArray(fragment.props.children).every(isUndefined)\n )\n}\n\nFieldBlock._supportsSpacingProps = true\n\nexport default FieldBlock\n\nfunction getFieldWidth(width: FieldBlockHorizontalLabelWidth) {\n switch (width) {\n case 'small':\n return 'var(--forms-field-width--small)'\n case 'medium':\n return 'var(--forms-field-width--medium)'\n case 'large':\n return 'var(--forms-field-width--large)'\n }\n\n return width\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,IACVC,OAAO,EACPC,UAAU,EACVC,WAAW,EACXC,MAAM,EACNC,UAAU,EACVC,SAAS,QACJ,OAAO;AACd,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,iBAAiB,MAWjB,qBAAqB;AAC5B,OAAOC,WAAW,MAAM,wBAAwB;AAChD,SAASC,KAAK,EAAEC,SAAS,EAAEC,UAAU,QAAQ,qBAAqB;AAClE,SAASC,EAAE,EAAEC,EAAE,QAAQ,mBAAmB;AAC1C,SACEC,kBAAkB,EAClBC,qBAAqB,QAChB,kCAAkC;AACzC,OAAOC,KAAK,MAAM,+BAA+B;AASjD,OAAOC,gBAAgB,IACrBC,uBAAuB,QAElB,kDAAkD;AACzD,OAAOC,eAAe,MAAM,yCAAyC;AACrE,SAASC,iBAAiB,QAAQ,wCAAwC;AAC1E,OAAOC,cAAc,MAAM,yBAAyB;AACpD,SAASC,SAAS,QAAQ,UAAU;AACpC,SAASC,gBAAgB,QAAQ,8BAA8B;AAE/D,OAAO,MAAMC,MAAyB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC;AA+FrE,SAASC,UAAUA,CAAkBC,KAAmB,EAAE;EAAA,IAAAC,SAAA;EACxD,MAAMC,WAAW,GAAG3B,UAAU,CAACO,WAAW,CAAC;EAC3C,MAAMqB,iBAAiB,GAAG5B,UAAU,CAACM,iBAAiB,CAAC;EACvD,MAAMuB,uBAAuB,GAAG,EAACD,iBAAiB,aAAjBA,iBAAiB,eAAjBA,iBAAiB,CAAEE,oBAAoB,IACpEF,iBAAiB,GACjB,IAAI;EAER,MAAMG,EAAE,GAAGhB,KAAK,EAAAW,SAAA,GAACD,KAAK,CA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{"version":3,"file":"FieldBlock.js","names":["React","useMemo","useContext","useCallback","useRef","useReducer","useEffect","classnames","FieldBlockContext","DataContext","Space","FormLabel","FormStatus","Ul","Li","convertJsxToString","findElementInChildren","useId","HelpButtonInline","HelpButtonInlineContent","SubmitIndicator","createSharedState","useTranslation","FormError","useIterateItemNo","states","FieldBlock","props","_props$id","dataContext","fieldBlockContext","nestedFieldBlockContext","disableStatusSummary","id","forId","sharedData","_Object$assign","Object","assign","data","className","layout","layoutOptions","composition","label","labelProp","labelDescription","labelDescriptionInline","labelSuffix","labelSrOnly","help","asFieldset","required","info","warning","error","fieldState","disabled","width","contentWidth","labelHeight","align","labelSize","contentClassName","children","rest","_objectWithoutProperties","_excluded","hasCustomWidth","test","String","hasCustomContentWidth","infoRef","warningRef","errorRef","blockId","salt","forceUpdate","mountedFieldsRef","Map","fieldStateRef","stateRecordRef","fieldStateIdsRef","contentsRef","hasInitiallyErrorPropRef","Boolean","setInternalRecord","stateId","identifier","type","current","existingIndex","findIndex","item","_objectSpread","push","setBlockRecordNested","setBlockRecord","setFieldState","showFieldError","show","map","showInitially","statusContent","content","statesWithMessages","entries","flatMap","_ref","reduce","acc","cur","existing","find","messages","getMessagesFromError","message","undefined","state","width_element","no_animation","process","env","NODE_ENV","globalThis","IS_TEST","found","msg","filter","_ref2","i","arr","length","createElement","CombineMessages","mainClasses","gridClasses","enableFieldset","useEnableFieldset","labelProps","element","srOnly","space","size","mainStyle","_lO$minWidth","_lO$maxWidth","style","lO","min","getFieldWidth","minWidth","max","maxWidth","prerenderFieldProps","hasLabelDescription","isFragment","fragmentHasChildren","fragmentHasOnlyUndefinedChildren","hasHelp","title","Provider","value","hasErrorProp","_extends","contentId","_br","breakout","outset","parseFloat","ref","_ref3","result","count","child","_child$props","_child$type","_ref4","translations","Field","Fragment","errorSummary","stateSummary","_ref5","key","getMessage","_error$formattedMessa","formattedMessage","Array","isArray","errors","Error","isValidElement","toString","fragment","Children","isUndefined","toArray","every","_supportsSpacingProps"],"sources":["../../../../../src/extensions/forms/FieldBlock/FieldBlock.tsx"],"sourcesContent":["import React, {\n useMemo,\n useContext,\n useCallback,\n useRef,\n useReducer,\n useEffect,\n} from 'react'\nimport classnames from 'classnames'\nimport FieldBlockContext, {\n StateWithMessage,\n StatesWithMessages,\n FieldErrorIdsRef,\n MountedFieldsRef,\n StateRecord,\n StateMessage,\n StateTypes,\n StatusContent,\n FieldBlockContextProps,\n StateBasis,\n} from './FieldBlockContext'\nimport DataContext from '../DataContext/Context'\nimport { Space, FormLabel, FormStatus } from '../../../components'\nimport { Ul, Li } from '../../../elements'\nimport {\n convertJsxToString,\n findElementInChildren,\n} from '../../../shared/component-helper'\nimport useId from '../../../shared/helpers/useId'\nimport {\n ComponentProps,\n FieldProps,\n SubmitState,\n Identifier,\n UseFieldProps,\n} from '../types'\nimport type { FormLabelAllProps } from '../../../components/FormLabel'\nimport HelpButtonInline, {\n HelpButtonInlineContent,\n HelpProps,\n} from '../../../components/help-button/HelpButtonInline'\nimport SubmitIndicator from '../Form/SubmitIndicator/SubmitIndicator'\nimport { createSharedState } from '../../../shared/helpers/useSharedState'\nimport useTranslation from '../hooks/useTranslation'\nimport { FormError } from '../utils'\nimport { useIterateItemNo } from '../Iterate/ItemNo/useIItemNo'\n\nexport const states: Array<StateTypes> = ['error', 'info', 'warning']\n\n/**\n * The width of a field block\n */\nexport type CustomWidth = `${number}rem`\nexport type FieldBlockWidth =\n | false\n | 'small'\n | 'medium'\n | 'large'\n | 'stretch'\n | CustomWidth\nexport type FieldBlockHorizontalLabelWidth =\n | 'small'\n | 'medium'\n | 'large'\n | CustomWidth\nexport type FieldBlockHorizontalLabelHeight =\n | 'default'\n | 'small'\n | 'medium'\n | 'large'\n\nexport type SharedFieldBlockProps = {\n /**\n * The layout of the field block\n */\n layout?: 'vertical' | 'horizontal'\n /** Use this to set additional options for the layout */\n layoutOptions?: {\n width?: FieldBlockHorizontalLabelWidth\n minWidth?: FieldBlockHorizontalLabelWidth\n maxWidth?: FieldBlockHorizontalLabelWidth\n }\n /**\n * Main label text for the field\n */\n label?: React.ReactNode\n /**\n * Will append an additional text to the label, like \"(optional)\" or \"(recommended)\"\n */\n labelSuffix?: React.ReactNode\n /**\n * A more discreet text displayed beside the label\n */\n labelDescription?: React.ReactNode\n /**\n * If true, the labelDescription will be displayed on the same line as the label.\n */\n labelDescriptionInline?: boolean\n /**\n * Width of outer block element\n */\n width?: FieldBlockWidth\n /**\n * Width of contents block, while label etc can be wider if space is available\n */\n contentWidth?: FieldBlockWidth\n /**\n * Provide help content for the field.\n */\n help?: HelpProps\n}\n\nexport type Props<Value = unknown> = SharedFieldBlockProps &\n Pick<\n FieldProps<Value>,\n keyof ComponentProps | 'info' | 'warning' | 'error' | 'disabled'\n > & {\n /** The id to link a element with */\n forId?: string\n /** Use true if you have more than one form element */\n asFieldset?: boolean\n /** use `true` to make the label only readable by screen readers. */\n labelSrOnly?: boolean\n /** Defines the layout of nested fields */\n composition?: FieldBlockContextProps['composition']\n /** For composition only: Align the contents vertically */\n align?: 'center' | 'bottom'\n /** Class name for the contents block */\n contentClassName?: string\n /** To show the SubmitIndicator during async validation */\n fieldState?: SubmitState\n /** Typography size */\n labelSize?: 'medium' | 'large'\n /** Defines the height of an component (size prop), so the label can be aligned correctly */\n labelHeight?: FieldBlockHorizontalLabelHeight\n /** Disable the error summary for this field block */\n disableStatusSummary?: boolean\n /** For internal use only */\n required?: boolean\n children?: React.ReactNode\n } & React.HTMLAttributes<HTMLDivElement>\n\nfunction FieldBlock<Value = unknown>(props: Props<Value>) {\n const dataContext = useContext(DataContext)\n const fieldBlockContext = useContext(FieldBlockContext)\n const nestedFieldBlockContext = !fieldBlockContext?.disableStatusSummary\n ? fieldBlockContext\n : null\n\n const id = useId(props.id ?? props.forId)\n const sharedData = createSharedState<Props>('field-block-props-' + id)\n const {\n className,\n forId,\n layout = 'vertical',\n layoutOptions,\n composition,\n label: labelProp,\n labelDescription,\n labelDescriptionInline,\n labelSuffix,\n labelSrOnly,\n help,\n asFieldset,\n required,\n info,\n warning,\n error,\n disableStatusSummary,\n fieldState,\n disabled,\n width,\n contentWidth,\n labelHeight,\n align,\n labelSize,\n contentClassName,\n children,\n ...rest\n } = Object.assign({}, sharedData.data, props)\n const hasCustomWidth = /\\d(rem)$/.test(String(width))\n const hasCustomContentWidth = /\\d(rem)$/.test(String(contentWidth))\n\n const infoRef = useRef<UseFieldProps['info']>()\n const warningRef = useRef<UseFieldProps['warning']>()\n const errorRef = useRef<UseFieldProps['error']>()\n\n const blockId = useId(props.id)\n const [salt, forceUpdate] = useReducer(() => ({}), {})\n const mountedFieldsRef = useRef<MountedFieldsRef>(new Map())\n const fieldStateRef = useRef<SubmitState>(null)\n const stateRecordRef = useRef<StateRecord>({})\n const fieldStateIdsRef = useRef<FieldErrorIdsRef>(null)\n const contentsRef = useRef<HTMLDivElement>(null)\n const hasInitiallyErrorPropRef = useRef(Boolean(error))\n\n const label = useIterateItemNo({\n label: labelProp,\n labelSuffix,\n required,\n })\n\n const setInternalRecord = useCallback((props: StateBasis) => {\n const { stateId, identifier, type } = props\n\n if (!stateRecordRef.current[identifier]) {\n stateRecordRef.current[identifier] = []\n }\n\n fieldStateIdsRef.current = { error: null, warning: null, info: null }\n\n const existingIndex = stateRecordRef.current[identifier].findIndex(\n (item) => {\n return item.stateId === stateId && item.type === type\n }\n )\n\n if (existingIndex > -1) {\n stateRecordRef.current[identifier][existingIndex] = {\n ...stateRecordRef.current[identifier][existingIndex],\n ...props,\n }\n } else {\n stateRecordRef.current[identifier].push(props)\n }\n }, [])\n\n const setBlockRecordNested = nestedFieldBlockContext?.setBlockRecord\n const setBlockRecord = useCallback(\n (props: StateBasis) => {\n if (setBlockRecordNested) {\n // If this FieldBlock is inside another one, forward the call to the outer one\n setBlockRecordNested(props)\n return\n }\n\n setInternalRecord(props)\n\n forceUpdate()\n },\n [setBlockRecordNested, setInternalRecord]\n )\n\n const setFieldState = useCallback(\n (identifier: Identifier, fieldState: SubmitState) => {\n if (fieldState !== fieldStateRef.current) {\n fieldStateRef.current = fieldState\n\n forceUpdate()\n }\n },\n []\n )\n\n const showFieldError = useCallback(\n (identifier: Identifier, show: boolean) => {\n if (nestedFieldBlockContext) {\n // If this FieldBlock is inside another one, forward the call to the outer one\n nestedFieldBlockContext.showFieldError(identifier, show)\n return\n }\n\n if (stateRecordRef.current[identifier]) {\n stateRecordRef.current[identifier] = stateRecordRef.current[\n identifier\n ].map((item) => {\n if (item.showInitially) {\n return item\n }\n\n return {\n ...item,\n show,\n }\n })\n\n forceUpdate()\n }\n },\n [nestedFieldBlockContext]\n )\n\n const statusContent = useMemo(() => {\n if (typeof error !== 'undefined' || (errorRef.current && !error)) {\n errorRef.current = error\n setInternalRecord({\n identifier: blockId,\n showInitially: hasInitiallyErrorPropRef.current,\n type: 'error',\n content: error,\n })\n }\n\n if (typeof warning !== 'undefined' || warningRef.current !== warning) {\n warningRef.current = warning\n setInternalRecord({\n identifier: blockId,\n showInitially: true,\n type: 'warning',\n content: warning,\n })\n }\n\n if (typeof info !== 'undefined' || infoRef.current !== info) {\n infoRef.current = info\n setInternalRecord({\n identifier: blockId,\n showInitially: true,\n type: 'info',\n content: info,\n })\n }\n\n const statesWithMessages: Array<StatesWithMessages> =\n // 1. Prepare the states for later use\n Object.entries(stateRecordRef.current)\n .flatMap(([identifier, states]) =>\n states.map((props) => {\n return {\n identifier,\n ...props,\n }\n })\n )\n\n // 2. Take states and group the same type together\n .reduce((acc, cur) => {\n const existing = acc.find((item) => {\n return item.type === cur.type\n })\n\n const messages = getMessagesFromError(cur).map((message) => {\n return {\n ...cur,\n message,\n }\n })\n\n if (existing) {\n existing.messages.push(...messages)\n } else {\n acc.push({\n ...cur,\n content: undefined,\n messages,\n })\n }\n\n return acc\n }, [] as Array<StatesWithMessages>)\n\n // 3. Return the grouped states/messages\n return states.reduce((acc, type) => {\n const id = `${props.id || forId || blockId}-form-status--${type}`\n acc[type] = {\n id,\n label,\n state: type === 'warning' ? 'warn' : type,\n width_element: contentsRef,\n\n // Enable animation only in the browser and not in tests\n no_animation:\n process.env.NODE_ENV === 'test'\n ? true\n : typeof globalThis !== 'undefined'\n ? globalThis.IS_TEST === true\n : false,\n }\n\n const found = statesWithMessages.find((item) => {\n return item.type === type\n })\n\n if (found?.messages) {\n // Hide/remove messages that should be hidden and are not marked as to be shown initially\n const messages = found.messages\n .map((msg) => {\n if (msg.type === 'error') {\n if (!msg.showInitially && !msg.show) {\n msg.message = null\n }\n }\n\n return msg\n })\n .filter(({ message }) => message)\n .reduce((acc, msg, i, arr) => {\n const existingIndex = arr.findIndex((item) => {\n return (\n convertJsxToString(item.message) ===\n convertJsxToString(msg.message)\n )\n })\n\n // Remove duplicates, use the first found message\n if (existingIndex === i) {\n acc.push(msg)\n }\n\n return acc\n }, [])\n\n // Combine the messages and put them in an ul/li list\n if (messages.length > 0) {\n acc[type] = {\n ...acc[type],\n children: <CombineMessages type={type} messages={messages} />,\n }\n\n fieldStateIdsRef.current[type] = id\n } else {\n fieldStateIdsRef.current[type] = undefined\n }\n }\n\n return acc\n }, salt) as StatusContent\n }, [\n error,\n warning,\n info,\n salt,\n setInternalRecord,\n blockId,\n props.id,\n forId,\n label,\n ])\n\n // Handle the error prop from outside\n useEffect(() => {\n if (!nestedFieldBlockContext) {\n showFieldError(blockId, Boolean(error))\n }\n }, [error, blockId, showFieldError, nestedFieldBlockContext])\n\n useEffect(\n () => () => {\n mountedFieldsRef.current = new Map()\n stateRecordRef.current = {}\n },\n []\n )\n\n const mainClasses = classnames(\n 'dnb-forms-field-block',\n width &&\n `dnb-forms-field-block--width-${hasCustomWidth ? 'custom' : width}`,\n contentWidth &&\n `dnb-forms-field-block--content-width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`,\n labelHeight && `dnb-forms-field-block--label-height-${labelHeight}`,\n composition && 'dnb-forms-field-block__composition',\n composition &&\n `dnb-forms-field-block__composition--${\n composition === true ? 'horizontal' : composition\n }`,\n className\n )\n const gridClasses = classnames(\n 'dnb-forms-field-block__grid',\n `dnb-forms-field-block--layout-${layout}`\n )\n\n // A child component with a label was found, use fieldset/legend instead of div/label\n const enableFieldset = useEnableFieldset({\n label,\n asFieldset,\n children,\n nestedFieldBlockContext,\n })\n\n const labelProps: FormLabelAllProps = {\n id: `${id}-label`,\n className: 'dnb-forms-field-block__label',\n element: enableFieldset ? 'legend' : 'label',\n forId: enableFieldset ? undefined : forId,\n srOnly: labelSrOnly,\n space: 0, // Use CSS for spacing, but we need to reset space for doing so\n size: labelSize,\n disabled,\n }\n\n const mainStyle = useMemo(() => {\n const style: React.CSSProperties = {}\n\n if (hasCustomWidth) {\n style['--dnb-forms-field-block-width'] = width\n }\n\n if (hasCustomContentWidth) {\n style['--dnb-forms-field-block-content-width'] = contentWidth\n }\n\n const lO = layoutOptions || {}\n const min = getFieldWidth(lO.minWidth ?? lO.width)\n const max = getFieldWidth(lO.maxWidth ?? lO.width)\n\n if (typeof min === 'string') {\n style['--dnb-forms-field-block-layout-width-min'] = min\n }\n if (typeof max === 'string') {\n style['--dnb-forms-field-block-layout-width-max'] = max\n }\n\n return style\n }, [\n contentWidth,\n hasCustomContentWidth,\n hasCustomWidth,\n layoutOptions,\n width,\n ])\n\n if (dataContext?.prerenderFieldProps) {\n return null\n }\n\n const hasLabelDescription = isFragment(labelDescription)\n ? fragmentHasChildren(labelDescription) &&\n !fragmentHasOnlyUndefinedChildren(labelDescription)\n : labelDescription\n const hasHelp = help?.title || help?.content\n\n return (\n <FieldBlockContext.Provider\n value={{\n setBlockRecord,\n setFieldState,\n showFieldError,\n hasErrorProp: Boolean(error),\n fieldStateIdsRef,\n mountedFieldsRef,\n composition,\n disableStatusSummary,\n }}\n >\n <Space\n element={enableFieldset ? 'fieldset' : 'div'} // use fieldset and legend to enhance a11y\n style={mainStyle}\n className={mainClasses}\n {...rest}\n >\n <div className={gridClasses}>\n {(label || labelDescription || hasHelp) && (\n <FormLabel {...labelProps}>\n <span>\n {label && (\n <span className=\"dnb-forms-field-block__label__content\">\n {label}\n </span>\n )}\n\n {hasHelp && (\n <HelpButtonInline contentId={`${id}-help`} help={help} />\n )}\n\n {hasLabelDescription && !labelDescriptionInline && <br />}\n {hasLabelDescription && (\n <span className=\"dnb-forms-field-block__label__description\">\n {labelDescription}\n </span>\n )}\n </span>\n </FormLabel>\n )}\n\n {hasHelp && (\n <HelpButtonInlineContent\n contentId={`${id}-help`}\n className=\"dnb-forms-field-block__help\"\n help={help}\n breakout={\n layout === 'vertical' &&\n !nestedFieldBlockContext?.composition\n }\n outset={layout !== 'horizontal'}\n />\n )}\n\n <div\n className={classnames(\n 'dnb-forms-field-block__status',\n\n // Handle the width of the status messages\n contentWidth &&\n contentWidth !== 'small' &&\n contentWidth !== 'medium' &&\n !(parseFloat(contentWidth) <= 11) &&\n `dnb-forms-field-block__contents--width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`\n )}\n >\n <FormStatus {...statusContent?.error} />\n <FormStatus {...statusContent?.warning} />\n <FormStatus {...statusContent?.info} />\n </div>\n\n <div\n className={classnames(\n 'dnb-forms-field-block__contents',\n contentWidth &&\n `dnb-forms-field-block__contents--width-${\n hasCustomContentWidth ? 'custom' : contentWidth\n }`,\n align && `dnb-forms-field-block__contents--align-${align}`,\n contentClassName\n )}\n ref={contentsRef}\n >\n {children}\n </div>\n\n <SubmitIndicator\n state={fieldState ?? fieldStateRef.current}\n className=\"dnb-forms-field-block__indicator dnb-forms-submit-indicator--inline-wrap\"\n />\n </div>\n </Space>\n </FieldBlockContext.Provider>\n )\n}\n\nfunction useEnableFieldset({\n label,\n asFieldset,\n children,\n nestedFieldBlockContext,\n}) {\n return useMemo(() => {\n if (asFieldset === false) {\n return false\n }\n\n let result = asFieldset\n\n if (label && !result && !nestedFieldBlockContext) {\n let count = 0\n\n findElementInChildren(children, (child: React.ReactElement) => {\n if (\n child?.props?.label ||\n child?.type?.['_formElement'] === true\n ) {\n count++\n }\n if (count > 1) {\n return (result = true)\n }\n })\n }\n\n return Boolean(result)\n }, [asFieldset, children, label, nestedFieldBlockContext])\n}\n\nfunction CombineMessages({\n type,\n messages,\n}: {\n type: StateTypes\n messages: Array<StateWithMessage>\n}) {\n const translations = useTranslation().Field\n\n if (messages.length === 1) {\n return <>{messages[0].message}</>\n }\n\n return (\n <>\n {type === 'error'\n ? translations.errorSummary\n : translations.stateSummary}\n <Ul>\n {messages.map(({ message }, i) => {\n return <Li key={i}>{message}</Li>\n })}\n </Ul>\n </>\n )\n}\n\nfunction getMessage(error: FormError | Error) {\n if (error instanceof FormError) {\n return error.formattedMessage ?? error.message\n }\n\n return error.message\n}\n\nexport function getMessagesFromError(\n item: Partial<StateWithMessage>\n): Array<StateMessage> {\n const { content } = item\n\n if (content instanceof FormError && Array.isArray(content.errors)) {\n return content.errors.map((content) => {\n return getMessage(content)\n })\n }\n\n if (Array.isArray(content)) {\n return content.map((content) => {\n return content instanceof FormError || content instanceof Error\n ? getMessage(content)\n : content\n })\n }\n\n if (content instanceof FormError || content instanceof Error) {\n return [getMessage(content)]\n }\n\n return [\n ((React.isValidElement(content) ? content : content?.toString()) ||\n content) as StateMessage,\n ]\n}\n\nfunction isFragment(fragment: React.ReactNode) {\n return React.isValidElement(fragment) && fragment.type === React.Fragment\n}\n\nfunction fragmentHasChildren(fragment: React.ReactNode) {\n return (\n React.isValidElement(fragment) &&\n React.Children.count(fragment.props.children) > 0\n )\n}\n\nfunction fragmentHasOnlyUndefinedChildren(fragment: React.ReactNode) {\n const isUndefined = (child) => child === undefined\n\n return (\n React.isValidElement(fragment) &&\n React.Children.toArray(fragment.props.children).every(isUndefined)\n )\n}\n\nFieldBlock._supportsSpacingProps = true\n\nexport default FieldBlock\n\nfunction getFieldWidth(width: FieldBlockHorizontalLabelWidth) {\n switch (width) {\n case 'small':\n return 'var(--forms-field-width--small)'\n case 'medium':\n return 'var(--forms-field-width--medium)'\n case 'large':\n return 'var(--forms-field-width--large)'\n }\n\n return width\n}\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,IACVC,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iCAAiC;EAC5C;EAEA,OAAOA,KAAK;AACd","ignoreList":[]}
|
|
@@ -13,7 +13,7 @@ export type StateBasis = {
|
|
|
13
13
|
show?: boolean;
|
|
14
14
|
};
|
|
15
15
|
export type StateRecord = Record<Identifier, Array<Omit<StateBasis, 'identifier'>>>;
|
|
16
|
-
export type StateMessage =
|
|
16
|
+
export type StateMessage = React.ReactNode;
|
|
17
17
|
export type StateWithMessage = StateBasis & {
|
|
18
18
|
message: StateMessage;
|
|
19
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldBlockContext.js","names":["React","FieldBlockContext","createContext","undefined"],"sources":["../../../../../src/extensions/forms/FieldBlock/FieldBlockContext.ts"],"sourcesContent":["import React from 'react'\nimport type { FieldProps, Identifier, SubmitState } from '../types'\n\nexport type FieldErrorIdsRef = Record<StateTypes, string>\nexport type MountedFieldsRef = Map<Identifier, boolean>\nexport type StateTypes = 'error' | 'warning' | 'info'\nexport type StateContent =\n | FieldProps<unknown>['error']\n | FieldProps<unknown>['warning']\n | FieldProps<unknown>['info']\nexport type StateBasis = {\n identifier: Identifier\n type: StateTypes\n content: StateContent\n stateId?: string\n showInitially?: boolean\n show?: boolean\n}\nexport type StateRecord = Record<\n Identifier,\n Array<Omit<StateBasis, 'identifier'>>\n>\nexport type StateMessage =
|
|
1
|
+
{"version":3,"file":"FieldBlockContext.js","names":["React","FieldBlockContext","createContext","undefined"],"sources":["../../../../../src/extensions/forms/FieldBlock/FieldBlockContext.ts"],"sourcesContent":["import React from 'react'\nimport type { FieldProps, Identifier, SubmitState } from '../types'\n\nexport type FieldErrorIdsRef = Record<StateTypes, string>\nexport type MountedFieldsRef = Map<Identifier, boolean>\nexport type StateTypes = 'error' | 'warning' | 'info'\nexport type StateContent =\n | FieldProps<unknown>['error']\n | FieldProps<unknown>['warning']\n | FieldProps<unknown>['info']\nexport type StateBasis = {\n identifier: Identifier\n type: StateTypes\n content: StateContent\n stateId?: string\n showInitially?: boolean\n show?: boolean\n}\nexport type StateRecord = Record<\n Identifier,\n Array<Omit<StateBasis, 'identifier'>>\n>\nexport type StateMessage = React.ReactNode\nexport type StateWithMessage = StateBasis & {\n message: StateMessage\n}\nexport type StatesWithMessages = StateBasis & {\n messages: Array<StateWithMessage>\n}\nexport type StatusContentState = { id: string; text: React.ReactNode }\nexport type StatusContent = {\n error: StatusContentState\n warning: StatusContentState\n info: StatusContentState\n}\n\nexport type FieldBlockContextProps = {\n setBlockRecord?: ({\n identifier,\n type,\n stateId,\n content,\n showInitially,\n show,\n }: StateBasis) => void\n setFieldState?: (identifier: Identifier, fieldState: SubmitState) => void\n showFieldError?: (identifier: Identifier, showError: boolean) => void\n hasErrorProp?: boolean\n composition?: true\n disableStatusSummary?: boolean\n fieldStateIdsRef?: React.MutableRefObject<FieldErrorIdsRef>\n mountedFieldsRef?: React.MutableRefObject<MountedFieldsRef>\n}\n\nconst FieldBlockContext = React.createContext<\n FieldBlockContextProps | undefined\n>(undefined)\n\nexport default FieldBlockContext\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAsDzB,MAAMC,iBAAiB,GAAGD,KAAK,CAACE,aAAa,CAE3CC,SAAS,CAAC;AAEZ,eAAeF,iBAAiB","ignoreList":[]}
|
|
@@ -70,7 +70,7 @@ export const DataValueWritePropsProperties = {
|
|
|
70
70
|
status: 'optional'
|
|
71
71
|
},
|
|
72
72
|
errorMessages: {
|
|
73
|
-
doc: 'Custom error messages for each type of error, overriding default messages.',
|
|
73
|
+
doc: 'Custom error messages for each type of error, overriding default messages. The messages can be a React.ReactNode or a string.',
|
|
74
74
|
type: 'object',
|
|
75
75
|
status: 'optional'
|
|
76
76
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataValueWritePropsDocs.js","names":["DataValueWritePropsProperties","value","doc","type","status","defaultValue","path","info","warning","error","disabled","emptyValue","required","labelSuffix","schema","validateInitially","validateUnchanged","validateContinuously","errorMessages","onChangeValidator","onBlurValidator","transformIn","transformOut","DataValueWritePropsEvents","onChange","onFocus","onBlur"],"sources":["../../../../../src/extensions/forms/hooks/DataValueWritePropsDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../shared/types'\n\nexport const DataValueWritePropsProperties: PropertiesTableProps = {\n value: {\n doc: 'Source data value for the field. Will take precedence over the path value given in the data context.',\n type: '{valueType}',\n status: 'optional',\n },\n defaultValue: {\n doc: 'Default source data value for the field. Will not take precedence over the path value given in the data context.',\n type: '{valueType}',\n status: 'optional',\n },\n path: {\n doc: 'JSON Pointer for where the data for the field is located in the source dataset (when using Form.Handler or DataContext). The `path` will also be set as the `name` attribute for the [string](/uilib/extensions/forms/base-fields/String/)-field.',\n type: 'string',\n status: 'optional',\n },\n info: {\n doc: \"Info message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['React.Node', 'Array<React.Node>', 'function'],\n status: 'optional',\n },\n warning: {\n doc: \"Warning message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['React.Node', 'Array<React.Node>', 'function'],\n status: 'optional',\n },\n error: {\n doc: \"Error message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['Error', 'FormError', 'Array<Error | FormError>', 'function'],\n status: 'optional',\n },\n disabled: {\n doc: 'Set `true` to show the field but without the possibility of changing the value.',\n type: 'boolean',\n status: 'optional',\n },\n emptyValue: {\n doc: 'The value to use (in `onChange` events etc) when emptying the field. Makes it possible for instance to provide `undefined` instead of an empty string when clearing the content of a text input.',\n type: ['{valueType}', 'undefined'],\n status: 'optional',\n },\n required: {\n doc: 'When set to `true`, the field will give an error if the value fails the required validation. When set to `false`, the field will not be required, but will add a \"(optional)\" suffix to the label.',\n type: 'boolean',\n status: 'optional',\n },\n labelSuffix: {\n doc: 'Will append an additional text to the label, like \"(optional)\". When using `inheritLabel`, the suffix will not be inherited. NB: The visual appearance of the `labelSuffix` may change in the future.',\n type: 'React.Node',\n status: 'optional',\n },\n schema: {\n doc: 'Custom JSON Schema for validating the value.',\n type: 'object',\n status: 'optional',\n },\n validateInitially: {\n doc: 'Set to `true` to show validation based errors initially (from given value-prop or source data) before the user interacts with the field.',\n type: 'boolean',\n status: 'optional',\n },\n validateUnchanged: {\n doc: 'Set to `true` to show validation based errors when the field is touched (like focusing a field and blurring) without having changed the value. Since the user did not introduce a new error, this will apply when the value was initially invalid based on validation.',\n type: 'boolean',\n status: 'optional',\n },\n validateContinuously: {\n doc: 'Set to `true` to show validation based errors continuously while writing, not just when blurring the field.',\n type: 'boolean',\n status: 'optional',\n },\n errorMessages: {\n doc: 'Custom error messages for each type of error, overriding default messages.',\n type: 'object',\n status: 'optional',\n },\n onChangeValidator: {\n doc: 'Custom validator function where you can return `undefined`, `Error`, `FormError` or an Array with either several other validators or several `Error` or `FormError`. It is triggered on every change done by the user. The function can be either asynchronous or synchronous. The first parameter is the value, and the second parameter returns an object containing { errorMessages, connectWithPath, validators }.',\n type: 'function',\n status: 'optional',\n },\n onBlurValidator: {\n doc: 'Custom validator function where you can return `undefined`, `Error`, `FormError` or an Array with either several other validators or several `Error` or `FormError`. It is triggered when the user leaves a field (e.g., blurring a text input or closing a dropdown). The function can be either asynchronous or synchronous. The first parameter is the value, and the second parameter returns an object containing { errorMessages, connectWithPath, validators }.',\n type: 'function',\n status: 'optional',\n },\n transformIn: {\n doc: 'Transforms the `value` before its displayed in the field (e.g. input).',\n type: 'function',\n status: 'optional',\n },\n transformOut: {\n doc: 'Transforms the value before it gets forwarded to the form data object (context) or returned as the `onChange` value parameter. The first parameter is the internal value. Some fields to support a second parameter, like the SelectCountry, where the country object is given.',\n type: 'function',\n status: 'optional',\n },\n}\n\nexport const DataValueWritePropsEvents: PropertiesTableProps = {\n onChange: {\n doc: \"Will be called on value changes made by the user, with the new value as argument. When an `async` function is used, the corresponding [FieldBlock](/uilib/extensions/forms/create-component/FieldBlock/) will show an indicator on the field label. You can return `{ success: 'saved' } as const` to show a success symbol, or an error or an object with these keys `{ info: 'Info message', warning: 'Warning message', error: Error('My error') } as const`. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).\",\n type: '(value) => void',\n status: 'optional',\n },\n onFocus: {\n doc: 'Will be called when the component gets into focus. Like clicking inside a text input or opening a dropdown. Called with active value as argument. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).',\n type: '(value) => void',\n status: 'optional',\n },\n onBlur: {\n doc: 'Will be called when the component stop being in focus. Like when going to next field, or closing a dropdown. Called with active value as argument. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).',\n type: '(value) => void',\n status: 'optional',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,6BAAmD,GAAG;EACjEC,KAAK,EAAE;IACLC,GAAG,EAAE,sGAAsG;IAC3GC,IAAI,EAAE,aAAa;IACnBC,MAAM,EAAE;EACV,CAAC;EACDC,YAAY,EAAE;IACZH,GAAG,EAAE,kHAAkH;IACvHC,IAAI,EAAE,aAAa;IACnBC,MAAM,EAAE;EACV,CAAC;EACDE,IAAI,EAAE;IACJJ,GAAG,EAAE,mPAAmP;IACxPC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDG,IAAI,EAAE;IACJL,GAAG,EAAE,gcAAgc;IACrcC,IAAI,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,UAAU,CAAC;IACrDC,MAAM,EAAE;EACV,CAAC;EACDI,OAAO,EAAE;IACPN,GAAG,EAAE,mcAAmc;IACxcC,IAAI,EA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AAE,UAAU;IAChBC,MAAM,EAAE;EACV,CAAC;EACDgB,eAAe,EAAE;IACflB,GAAG,EAAE,wcAAwc;IAC7cC,IAAI,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV,CAAC;EACDiB,WAAW,EAAE;IACXnB,GAAG,EAAE,wEAAwE;IAC7EC,IAAI,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV,CAAC;EACDkB,YAAY,EAAE;IACZpB,GAAG,EAAE,iRAAiR;IACtRC,IAAI,EAAE,UAAU;IAChBC,MAAM,EAAE;EACV;AACF,CAAC;AAED,OAAO,MAAMmB,yBAA+C,GAAG;EAC7DC,QAAQ,EAAE;IACRtB,GAAG,EAAE,iiBAAiiB;IACtiBC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACDqB,OAAO,EAAE;IACPvB,GAAG,EAAE,kPAAkP;IACvPC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACDsB,MAAM,EAAE;IACNxB,GAAG,EAAE,mPAAmP;IACxPC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"DataValueWritePropsDocs.js","names":["DataValueWritePropsProperties","value","doc","type","status","defaultValue","path","info","warning","error","disabled","emptyValue","required","labelSuffix","schema","validateInitially","validateUnchanged","validateContinuously","errorMessages","onChangeValidator","onBlurValidator","transformIn","transformOut","DataValueWritePropsEvents","onChange","onFocus","onBlur"],"sources":["../../../../../src/extensions/forms/hooks/DataValueWritePropsDocs.ts"],"sourcesContent":["import { PropertiesTableProps } from '../../../shared/types'\n\nexport const DataValueWritePropsProperties: PropertiesTableProps = {\n value: {\n doc: 'Source data value for the field. Will take precedence over the path value given in the data context.',\n type: '{valueType}',\n status: 'optional',\n },\n defaultValue: {\n doc: 'Default source data value for the field. Will not take precedence over the path value given in the data context.',\n type: '{valueType}',\n status: 'optional',\n },\n path: {\n doc: 'JSON Pointer for where the data for the field is located in the source dataset (when using Form.Handler or DataContext). The `path` will also be set as the `name` attribute for the [string](/uilib/extensions/forms/base-fields/String/)-field.',\n type: 'string',\n status: 'optional',\n },\n info: {\n doc: \"Info message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['React.Node', 'Array<React.Node>', 'function'],\n status: 'optional',\n },\n warning: {\n doc: \"Warning message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['React.Node', 'Array<React.Node>', 'function'],\n status: 'optional',\n },\n error: {\n doc: \"Error message shown below / after the field. When provided as a function, the function will be called with the current value as argument. The second parameter is an object with `{ conditionally, getValueByPath, getFieldByPath }`. To show the message first after the user has interacted with the field, you can call and return `conditionally` function with a callback and with options: `conditionally(() => 'Your message', { showInitially: true })`\",\n type: ['Error', 'FormError', 'Array<Error | FormError>', 'function'],\n status: 'optional',\n },\n disabled: {\n doc: 'Set `true` to show the field but without the possibility of changing the value.',\n type: 'boolean',\n status: 'optional',\n },\n emptyValue: {\n doc: 'The value to use (in `onChange` events etc) when emptying the field. Makes it possible for instance to provide `undefined` instead of an empty string when clearing the content of a text input.',\n type: ['{valueType}', 'undefined'],\n status: 'optional',\n },\n required: {\n doc: 'When set to `true`, the field will give an error if the value fails the required validation. When set to `false`, the field will not be required, but will add a \"(optional)\" suffix to the label.',\n type: 'boolean',\n status: 'optional',\n },\n labelSuffix: {\n doc: 'Will append an additional text to the label, like \"(optional)\". When using `inheritLabel`, the suffix will not be inherited. NB: The visual appearance of the `labelSuffix` may change in the future.',\n type: 'React.Node',\n status: 'optional',\n },\n schema: {\n doc: 'Custom JSON Schema for validating the value.',\n type: 'object',\n status: 'optional',\n },\n validateInitially: {\n doc: 'Set to `true` to show validation based errors initially (from given value-prop or source data) before the user interacts with the field.',\n type: 'boolean',\n status: 'optional',\n },\n validateUnchanged: {\n doc: 'Set to `true` to show validation based errors when the field is touched (like focusing a field and blurring) without having changed the value. Since the user did not introduce a new error, this will apply when the value was initially invalid based on validation.',\n type: 'boolean',\n status: 'optional',\n },\n validateContinuously: {\n doc: 'Set to `true` to show validation based errors continuously while writing, not just when blurring the field.',\n type: 'boolean',\n status: 'optional',\n },\n errorMessages: {\n doc: 'Custom error messages for each type of error, overriding default messages. The messages can be a React.ReactNode or a string.',\n type: 'object',\n status: 'optional',\n },\n onChangeValidator: {\n doc: 'Custom validator function where you can return `undefined`, `Error`, `FormError` or an Array with either several other validators or several `Error` or `FormError`. It is triggered on every change done by the user. The function can be either asynchronous or synchronous. The first parameter is the value, and the second parameter returns an object containing { errorMessages, connectWithPath, validators }.',\n type: 'function',\n status: 'optional',\n },\n onBlurValidator: {\n doc: 'Custom validator function where you can return `undefined`, `Error`, `FormError` or an Array with either several other validators or several `Error` or `FormError`. It is triggered when the user leaves a field (e.g., blurring a text input or closing a dropdown). The function can be either asynchronous or synchronous. The first parameter is the value, and the second parameter returns an object containing { errorMessages, connectWithPath, validators }.',\n type: 'function',\n status: 'optional',\n },\n transformIn: {\n doc: 'Transforms the `value` before its displayed in the field (e.g. input).',\n type: 'function',\n status: 'optional',\n },\n transformOut: {\n doc: 'Transforms the value before it gets forwarded to the form data object (context) or returned as the `onChange` value parameter. The first parameter is the internal value. Some fields to support a second parameter, like the SelectCountry, where the country object is given.',\n type: 'function',\n status: 'optional',\n },\n}\n\nexport const DataValueWritePropsEvents: PropertiesTableProps = {\n onChange: {\n doc: \"Will be called on value changes made by the user, with the new value as argument. When an `async` function is used, the corresponding [FieldBlock](/uilib/extensions/forms/create-component/FieldBlock/) will show an indicator on the field label. You can return `{ success: 'saved' } as const` to show a success symbol, or an error or an object with these keys `{ info: 'Info message', warning: 'Warning message', error: Error('My error') } as const`. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).\",\n type: '(value) => void',\n status: 'optional',\n },\n onFocus: {\n doc: 'Will be called when the component gets into focus. Like clicking inside a text input or opening a dropdown. Called with active value as argument. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).',\n type: '(value) => void',\n status: 'optional',\n },\n onBlur: {\n doc: 'Will be called when the component stop being in focus. Like when going to next field, or closing a dropdown. Called with active value as argument. The second parameter is an object that e.g. contains `props` (all given `Field.*` properties).',\n type: '(value) => void',\n status: 'optional',\n },\n}\n"],"mappings":"AAEA,OAAO,MAAMA,6BAAmD,GAAG;EACjEC,KAAK,EAAE;IACLC,GAAG,EAAE,sGAAsG;IAC3GC,IAAI,EAAE,aAAa;IACnBC,MAAM,EAAE;EACV,CAAC;EACDC,YAAY,EAAE;IACZH,GAAG,EAAE,kHAAkH;IACvHC,IAAI,EAAE,aAAa;IACnBC,MAAM,EAAE;EACV,CAAC;EACDE,IAAI,EAAE;IACJJ,GAAG,EAAE,mPAAmP;IACxPC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE;EACV,CAAC;EACDG,IAAI,EAAE;IACJL,GAAG,EAAE,gcAAgc;IACrcC,IAAI,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,UAAU,CAAC;IACrDC,MAAM,EAAE;EACV,CAAC;EACDI,OAAO,EAAE;IACPN,GAAG,EAAE,mcAAmc;IACxcC,IAAI,EAAE,CAAC,YAAY,EAAE,mBAAmB,EAAE,UAAU,CAAC;IACrDC,MAAM,EAAE;EACV,CAAC;EACDK,KAAK,EAAE;IACLP,GAAG,EAAE,icAAic;IACtcC,IAAI,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,UAAU,CAAC;IACpEC,MAAM,EAAE;EACV,CAAC;EACDM,QAAQ,EAAE;IACRR,GAAG,EAAE,iFAAiF;IACtFC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV,C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ChBC,MAAM,EAAE;EACV;AACF,CAAC;AAED,OAAO,MAAMmB,yBAA+C,GAAG;EAC7DC,QAAQ,EAAE;IACRtB,GAAG,EAAE,iiBAAiiB;IACtiBC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACDqB,OAAO,EAAE;IACPvB,GAAG,EAAE,kPAAkP;IACvPC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV,CAAC;EACDsB,MAAM,EAAE;IACNxB,GAAG,EAAE,mPAAmP;IACxPC,IAAI,EAAE,iBAAiB;IACvBC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
|
|
@@ -11,7 +11,7 @@ import { ajvErrorsToOneFormError, errorChanged, overwriteErrorMessagesWithGivenA
|
|
|
11
11
|
import { Context as DataContext } from '../DataContext';
|
|
12
12
|
import { clearedData } from '../DataContext/Provider/Provider';
|
|
13
13
|
import FieldProviderContext from '../Field/Provider/FieldProviderContext';
|
|
14
|
-
import { combineDescribedBy, warn } from '../../../shared/component-helper';
|
|
14
|
+
import { combineDescribedBy, convertJsxToString, warn } from '../../../shared/component-helper';
|
|
15
15
|
import useId from '../../../shared/helpers/useId';
|
|
16
16
|
import useUpdateEffect from '../../../shared/helpers/useUpdateEffect';
|
|
17
17
|
import FieldBlockContext from '../FieldBlock/FieldBlockContext';
|
|
@@ -256,6 +256,28 @@ export default function useFieldProps(localProps) {
|
|
|
256
256
|
id: undefined
|
|
257
257
|
};
|
|
258
258
|
}, [fieldInternalsRef]);
|
|
259
|
+
const errorMessageCacheRef = useRef(new Map());
|
|
260
|
+
const ensureErrorMessageObject = useCallback(error => {
|
|
261
|
+
let key = null;
|
|
262
|
+
let returnValue = error;
|
|
263
|
+
if (typeof error === 'string') {
|
|
264
|
+
key = error;
|
|
265
|
+
returnValue = new Error(error);
|
|
266
|
+
} else if (error && React.isValidElement(error)) {
|
|
267
|
+
key = error.key || convertJsxToString(error);
|
|
268
|
+
returnValue = new FormError('Error', {
|
|
269
|
+
formattedMessage: error
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
if (key) {
|
|
273
|
+
if (errorMessageCacheRef.current.has(key)) {
|
|
274
|
+
return errorMessageCacheRef.current.get(key);
|
|
275
|
+
} else {
|
|
276
|
+
errorMessageCacheRef.current.set(key, returnValue);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return returnValue;
|
|
280
|
+
}, []);
|
|
259
281
|
const messageCacheRef = useRef({
|
|
260
282
|
isSet: false,
|
|
261
283
|
message: undefined
|
|
@@ -271,7 +293,7 @@ export default function useFieldProps(localProps) {
|
|
|
271
293
|
if (options !== null && options !== void 0 && options.showInitially) {
|
|
272
294
|
currentMode |= INITIALLY;
|
|
273
295
|
}
|
|
274
|
-
return callback();
|
|
296
|
+
return executeMessage(callback());
|
|
275
297
|
},
|
|
276
298
|
getValueByPath,
|
|
277
299
|
getFieldByPath
|
|
@@ -301,8 +323,8 @@ export default function useFieldProps(localProps) {
|
|
|
301
323
|
return undefined;
|
|
302
324
|
}
|
|
303
325
|
}
|
|
304
|
-
return message;
|
|
305
|
-
}, [getFieldByPath, getValueByPath]);
|
|
326
|
+
return ensureErrorMessageObject(message);
|
|
327
|
+
}, [getFieldByPath, getValueByPath, ensureErrorMessageObject]);
|
|
306
328
|
const errorProp = initialErrorProp === 'initial' ? undefined : initialErrorProp;
|
|
307
329
|
const error = executeMessage(errorProp);
|
|
308
330
|
const warning = executeMessage(warningProp);
|
|
@@ -330,7 +352,7 @@ export default function useFieldProps(localProps) {
|
|
|
330
352
|
const asyncBehaviorIsEnabled = useMemo(() => {
|
|
331
353
|
return isAsync(onChange) || isAsync(onChangeContext);
|
|
332
354
|
}, [onChangeContext, onChange]);
|
|
333
|
-
const
|
|
355
|
+
const validatedValueRef = useRef();
|
|
334
356
|
const changeEventResultRef = useRef(null);
|
|
335
357
|
const asyncProcessRef = useRef(null);
|
|
336
358
|
const defineAsyncProcess = useCallback(name => {
|
|
@@ -432,8 +454,8 @@ export default function useFieldProps(localProps) {
|
|
|
432
454
|
return extendedErrorMessages;
|
|
433
455
|
}, [contextErrorMessages, errorMessages, identifier]);
|
|
434
456
|
const prepareError = useCallback(error => {
|
|
435
|
-
|
|
436
|
-
|
|
457
|
+
const prepare = error => {
|
|
458
|
+
if (error instanceof FormError) {
|
|
437
459
|
let message = error.message;
|
|
438
460
|
const {
|
|
439
461
|
ajvKeyword
|
|
@@ -464,9 +486,20 @@ export default function useFieldProps(localProps) {
|
|
|
464
486
|
} else if (message.includes('.')) {
|
|
465
487
|
message = formatMessage(message, error.messageValues);
|
|
466
488
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
489
|
+
if (React.isValidElement(message)) {
|
|
490
|
+
error.formattedMessage = message;
|
|
491
|
+
} else {
|
|
492
|
+
error.message = message;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return ensureErrorMessageObject(error);
|
|
496
|
+
};
|
|
497
|
+
if (Array.isArray(error)) {
|
|
498
|
+
return new FormError('Error', {
|
|
499
|
+
errors: error.map(prepare)
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
if (error instanceof FormError) {
|
|
470
503
|
if (Array.isArray(error.errors)) {
|
|
471
504
|
error.errors = error.errors.map(prepare);
|
|
472
505
|
return error;
|
|
@@ -474,7 +507,7 @@ export default function useFieldProps(localProps) {
|
|
|
474
507
|
return prepare(error);
|
|
475
508
|
}
|
|
476
509
|
return error;
|
|
477
|
-
}, [combinedErrorMessages, formatMessage]);
|
|
510
|
+
}, [combinedErrorMessages, ensureErrorMessageObject, formatMessage]);
|
|
478
511
|
contextErrorRef.current = useMemo(() => {
|
|
479
512
|
const dataContextError = dataContextErrors === null || dataContextErrors === void 0 ? void 0 : dataContextErrors[path];
|
|
480
513
|
if (!dataContextError) {
|
|
@@ -570,9 +603,9 @@ export default function useFieldProps(localProps) {
|
|
|
570
603
|
}
|
|
571
604
|
callStackRef.current = [];
|
|
572
605
|
} else {
|
|
573
|
-
return result;
|
|
606
|
+
return ensureErrorMessageObject(result);
|
|
574
607
|
}
|
|
575
|
-
}, [additionalArgs, hasBeenCalledRef]);
|
|
608
|
+
}, [additionalArgs, hasBeenCalledRef, ensureErrorMessageObject]);
|
|
576
609
|
const callValidatorFnSync = useCallback(function (validator) {
|
|
577
610
|
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : valueRef.current;
|
|
578
611
|
if (typeof validator !== 'function') {
|
|
@@ -607,9 +640,9 @@ export default function useFieldProps(localProps) {
|
|
|
607
640
|
}
|
|
608
641
|
callStackRef.current = [];
|
|
609
642
|
} else {
|
|
610
|
-
return result;
|
|
643
|
+
return ensureErrorMessageObject(result);
|
|
611
644
|
}
|
|
612
|
-
}, [additionalArgs, callValidatorFnAsync, hasBeenCalledRef]);
|
|
645
|
+
}, [additionalArgs, callValidatorFnAsync, hasBeenCalledRef, ensureErrorMessageObject]);
|
|
613
646
|
const stateId = useId();
|
|
614
647
|
const persistErrorState = useCallback(function (method, initiator) {
|
|
615
648
|
var _errorMethodRef$curre, _errorMethodRef$curre2;
|
|
@@ -833,7 +866,7 @@ export default function useFieldProps(localProps) {
|
|
|
833
866
|
}
|
|
834
867
|
const value = valueRef.current;
|
|
835
868
|
changeEventResultRef.current = null;
|
|
836
|
-
|
|
869
|
+
validatedValueRef.current = null;
|
|
837
870
|
let initiator = null;
|
|
838
871
|
try {
|
|
839
872
|
const requiredError = transformers.current.validateRequired(value, {
|
|
@@ -878,7 +911,7 @@ export default function useFieldProps(localProps) {
|
|
|
878
911
|
if (isProcessActive()) {
|
|
879
912
|
clearErrorState();
|
|
880
913
|
}
|
|
881
|
-
|
|
914
|
+
validatedValueRef.current = value;
|
|
882
915
|
} catch (error) {
|
|
883
916
|
if (isProcessActive()) {
|
|
884
917
|
persistErrorState('weak', initiator, error);
|
|
@@ -955,7 +988,7 @@ export default function useFieldProps(localProps) {
|
|
|
955
988
|
withStates,
|
|
956
989
|
hasValue
|
|
957
990
|
} = _ref9;
|
|
958
|
-
const hasMatchingValue = hasValue ===
|
|
991
|
+
const hasMatchingValue = hasValue === validatedValueRef.current;
|
|
959
992
|
const result = (typeof hasValue === 'undefined' ? false : !hasMatchingValue) || (processName ? processName === asyncProcessRef.current : true) && (withStates === null || withStates === void 0 ? void 0 : withStates.some(state => {
|
|
960
993
|
return state === fieldStateRef.current;
|
|
961
994
|
}));
|