feat: add custom font sizes to fields (#1376)

Adds custom font sizes to fields

https://github.com/user-attachments/assets/1473a4d7-8dc6-4ead-acf5-dd78be7782a0
This commit is contained in:
Ephraim Duncan
2024-10-16 05:05:41 +00:00
committed by GitHub
parent 0bd2760792
commit e0c948c2ac
30 changed files with 663 additions and 186 deletions

View File

@@ -1,12 +1,5 @@
// import { numberFormatValues } from '@documenso/ui/primitives/document-flow/field-items-advanced-settings/constants';
interface NumberFieldMeta {
minValue?: number;
maxValue?: number;
readOnly?: boolean;
required?: boolean;
numberFormat?: string;
}
import type { TNumberFieldMeta as NumberFieldMeta } from '../types/field-meta';
export const validateNumberField = (
value: string,
@@ -15,7 +8,7 @@ export const validateNumberField = (
): string[] => {
const errors = [];
const { minValue, maxValue, readOnly, required, numberFormat } = fieldMeta || {};
const { minValue, maxValue, readOnly, required, numberFormat, fontSize } = fieldMeta || {};
const formatRegex: { [key: string]: RegExp } = {
'123,456,789.00': /^(?:\d{1,3}(?:,\d{3})*|\d+)(?:\.\d{1,2})?$/,
@@ -63,5 +56,9 @@ export const validateNumberField = (
errors.push('A field cannot be both read-only and required');
}
if (fontSize && (fontSize < 8 || fontSize > 96)) {
errors.push('Font size must be between 8 and 96.');
}
return errors;
};