@cerebruminc/cerebellum 16.1.1-beta.dangerous.fe9f73b → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/ColorPickerInput-CBPI8IJ-.js +187 -0
- package/lib/cjs/ColorPickerInput-CBPI8IJ-.js.map +1 -0
- package/lib/cjs/ColorPickerInput.cjs +25 -0
- package/lib/cjs/ColorPickerInput.cjs.map +1 -0
- package/lib/cjs/DatePicker.cjs +1 -1
- package/lib/cjs/Form.cjs +7 -4
- package/lib/cjs/Form.cjs.map +1 -1
- package/lib/cjs/FormFieldTypeEnum.cjs +5 -0
- package/lib/cjs/FormFieldTypeEnum.cjs.map +1 -1
- package/lib/cjs/FormSeparator.cjs +3 -1
- package/lib/cjs/FormSeparator.cjs.map +1 -1
- package/lib/cjs/{FormStyles-CxgYRZOl.js → FormStyles-CM25rbhG.js} +38 -21
- package/lib/cjs/{FormStyles-CxgYRZOl.js.map → FormStyles-CM25rbhG.js.map} +1 -1
- package/lib/cjs/FormWrapper.cjs +3 -1
- package/lib/cjs/FormWrapper.cjs.map +1 -1
- package/lib/cjs/{FormikContainer-CY2nLsAs.js → FormikContainer-DVL86Jri.js} +33 -3
- package/lib/cjs/{FormikContainer-CY2nLsAs.js.map → FormikContainer-DVL86Jri.js.map} +1 -1
- package/lib/cjs/InlineColorPickerInput.cjs +25 -0
- package/lib/cjs/InlineColorPickerInput.cjs.map +1 -0
- package/lib/cjs/{InlineDatePicker-DFv_uHo9.js → InlineDatePicker-B7DTwvhv.js} +344 -176
- package/lib/cjs/InlineDatePicker-B7DTwvhv.js.map +1 -0
- package/lib/cjs/InlineDatePicker.cjs +1 -1
- package/lib/cjs/TitleGroup.cjs +3 -1
- package/lib/cjs/TitleGroup.cjs.map +1 -1
- package/lib/cjs/cerebellumTheme.cjs +5 -0
- package/lib/cjs/cerebellumTheme.cjs.map +1 -1
- package/lib/cjs/index.cjs +9 -3
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/cjs/validateColorContrast.cjs +53 -0
- package/lib/cjs/validateColorContrast.cjs.map +1 -0
- package/lib/cjs/validateColorContrastWithMessage.cjs +10 -0
- package/lib/cjs/validateColorContrastWithMessage.cjs.map +1 -0
- package/lib/esm/ColorPickerInput-S8X2gIA5.js +180 -0
- package/lib/esm/ColorPickerInput-S8X2gIA5.js.map +1 -0
- package/lib/esm/ColorPickerInput.js +18 -0
- package/lib/esm/ColorPickerInput.js.map +1 -0
- package/lib/esm/DatePicker.js +1 -1
- package/lib/esm/Form.js +7 -5
- package/lib/esm/Form.js.map +1 -1
- package/lib/esm/FormFieldTypeEnum.js +5 -1
- package/lib/esm/FormFieldTypeEnum.js.map +1 -1
- package/lib/esm/FormSeparator.js +3 -1
- package/lib/esm/FormSeparator.js.map +1 -1
- package/lib/esm/{FormStyles-BQJPyTS0.js → FormStyles-CyqyMC1o.js} +39 -22
- package/lib/esm/{FormStyles-BQJPyTS0.js.map → FormStyles-CyqyMC1o.js.map} +1 -1
- package/lib/esm/FormWrapper.js +3 -1
- package/lib/esm/FormWrapper.js.map +1 -1
- package/lib/esm/{FormikContainer-SJPYfIkF.js → FormikContainer-uI5oe1px.js} +34 -4
- package/lib/esm/{FormikContainer-SJPYfIkF.js.map → FormikContainer-uI5oe1px.js.map} +1 -1
- package/lib/esm/InlineColorPickerInput.js +18 -0
- package/lib/esm/InlineColorPickerInput.js.map +1 -0
- package/lib/esm/{InlineDatePicker-ClVBWEzW.js → InlineDatePicker-BuxjkoV0.js} +345 -177
- package/lib/esm/InlineDatePicker-BuxjkoV0.js.map +1 -0
- package/lib/esm/InlineDatePicker.js +1 -1
- package/lib/esm/TitleGroup.js +3 -1
- package/lib/esm/TitleGroup.js.map +1 -1
- package/lib/esm/cerebellumTheme.js +5 -0
- package/lib/esm/cerebellumTheme.js.map +1 -1
- package/lib/esm/index.js +6 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/validateColorContrast.js +50 -0
- package/lib/esm/validateColorContrast.js.map +1 -0
- package/lib/esm/validateColorContrastWithMessage.js +3 -0
- package/lib/esm/validateColorContrastWithMessage.js.map +1 -0
- package/lib/types/src/components/ColorPickerInput/ColorPickerInput.d.ts +3 -0
- package/lib/types/src/components/ColorPickerInput/InlineColorPickerInput.d.ts +3 -0
- package/lib/types/src/components/ColorPickerInput/index.d.ts +3 -0
- package/lib/types/src/components/ColorPickerInput/types.d.ts +48 -0
- package/lib/types/src/components/Form/fields/ColorPickerField/ColorPickerField.d.ts +4 -0
- package/lib/types/src/components/Form/fields/ColorPickerField/index.d.ts +1 -0
- package/lib/types/src/components/Form/fields/index.d.ts +2 -1
- package/lib/types/src/components/Form/index.d.ts +3 -3
- package/lib/types/src/components/Form/mocks/fields.d.ts +62 -0
- package/lib/types/src/components/Form/types.d.ts +36 -2
- package/lib/types/src/helpers/colorValidators.d.ts +19 -0
- package/lib/types/src/index.d.ts +5 -1
- package/lib/types/src/theme.d.ts +6 -0
- package/package.json +1 -1
- package/lib/cjs/InlineDatePicker-DFv_uHo9.js.map +0 -1
- package/lib/esm/InlineDatePicker-ClVBWEzW.js.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pressedEnter = require('./pressedEnter.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Validates that a color has sufficient contrast against a background color
|
|
7
|
+
* according to WCAG AA accessibility standards (4.5:1 ratio for normal text).
|
|
8
|
+
*
|
|
9
|
+
* @param color - The foreground color (hex format, e.g., "#ff0000")
|
|
10
|
+
* @param backgroundColor - The background color to check against (hex format, defaults to "#ffffff")
|
|
11
|
+
* @returns boolean - true if the contrast ratio is >= 4.5:1, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
var validateColorContrast = function (color, backgroundColor) {
|
|
14
|
+
if (backgroundColor === void 0) { backgroundColor = "#ffffff"; }
|
|
15
|
+
if (!color) {
|
|
16
|
+
return true; // Allow empty values, let required validation handle this
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
var contrastRatio = pressedEnter.contrast(color, backgroundColor);
|
|
20
|
+
// WCAG AA requires 4.5:1 for normal text, 3:1 for large text
|
|
21
|
+
// Using 4.5 as the threshold for accessibility compliance
|
|
22
|
+
return contrastRatio >= 4.5;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
// If there's an error in contrast calculation (invalid color format, etc.)
|
|
26
|
+
// return true to avoid blocking the form, let other validation handle format issues
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Validates that a color has sufficient contrast against a background color
|
|
32
|
+
* and returns an error message if validation fails.
|
|
33
|
+
*
|
|
34
|
+
* @param color - The foreground color (hex format, e.g., "#ff0000")
|
|
35
|
+
* @param backgroundColor - The background color to check against (hex format, defaults to "#ffffff")
|
|
36
|
+
* @param errorMessage - Custom error message (optional)
|
|
37
|
+
* @returns string | null - Error message if validation fails, null if valid
|
|
38
|
+
*/
|
|
39
|
+
var validateColorContrastWithMessage = function (color, backgroundColor, errorMessage) {
|
|
40
|
+
if (backgroundColor === void 0) { backgroundColor = "#ffffff"; }
|
|
41
|
+
if (!color) {
|
|
42
|
+
return null; // Allow empty values, let required validation handle this
|
|
43
|
+
}
|
|
44
|
+
var isValid = validateColorContrast(color, backgroundColor);
|
|
45
|
+
if (!isValid) {
|
|
46
|
+
return errorMessage || "This color does not have sufficient contrast for accessibility";
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.validateColorContrast = validateColorContrast;
|
|
52
|
+
exports.validateColorContrastWithMessage = validateColorContrastWithMessage;
|
|
53
|
+
//# sourceMappingURL=validateColorContrast.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateColorContrast.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('./pressedEnter.cjs');
|
|
4
|
+
var validateColorContrast = require('./validateColorContrast.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.validateColorContrast = validateColorContrast.validateColorContrast;
|
|
9
|
+
exports.validateColorContrastWithMessage = validateColorContrast.validateColorContrastWithMessage;
|
|
10
|
+
//# sourceMappingURL=validateColorContrastWithMessage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateColorContrastWithMessage.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { b as __makeTemplateObject, _ as __assign } from './_tslib-CcAXazg4.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useRef, useMemo, useEffect, useState } from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { BodyXSPrimary } from './BodyLEmphasis.js';
|
|
6
|
+
import { u as useMeasure } from './useMeasure-D89v6c_A.js';
|
|
7
|
+
import { s as showLabel } from './showLabel-D6KgNem4.js';
|
|
8
|
+
import { I as InputGroup, L as LabelBox, V as ValidationText, H as HelperText } from './Inputs-C6OWHviY.js';
|
|
9
|
+
import { contrast } from './pressedEnter.js';
|
|
10
|
+
import { validateColorContrast } from './validateColorContrast.js';
|
|
11
|
+
|
|
12
|
+
// Container that holds both the input and the text side by side
|
|
13
|
+
var ColorPickerContainer = styled.div(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n align-items: center;\n display: flex;\n flex-wrap: nowrap;\n gap: 12px;\n"], ["\n align-items: center;\n display: flex;\n flex-wrap: nowrap;\n gap: 12px;\n"])));
|
|
14
|
+
var ColorInputWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n align-items: center;\n background: ", ";\n border: solid 1px ", ";\n border-radius: ", "px;\n display: flex;\n flex-shrink: 0; /* Prevent the square from shrinking */\n height: ", "px;\n justify-content: center;\n min-width: ", "px;\n padding: ", "px;\n position: relative;\n transition: border-color 350ms ease-out 50ms, background-color 350ms ease-out 50ms;\n /* Make the wrapper square based on inputHeight, with a larger default for color pickers */\n width: ", "px;\n \n &:hover {\n border-color: ", ";\n }\n \n &:focus-within {\n border-color: ", ";\n }\n"], ["\n align-items: center;\n background: ", ";\n border: solid 1px ", ";\n border-radius: ", "px;\n display: flex;\n flex-shrink: 0; /* Prevent the square from shrinking */\n height: ", "px;\n justify-content: center;\n min-width: ", "px;\n padding: ", "px;\n position: relative;\n transition: border-color 350ms ease-out 50ms, background-color 350ms ease-out 50ms;\n /* Make the wrapper square based on inputHeight, with a larger default for color pickers */\n width: ", "px;\n \n &:hover {\n border-color: ", ";\n }\n \n &:focus-within {\n border-color: ", ";\n }\n"])), function (_a) {
|
|
15
|
+
var _b;
|
|
16
|
+
var $themeOverride = _a.$themeOverride, theme = _a.theme;
|
|
17
|
+
return ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.inputBackgroundColor) || ((_b = theme.input) === null || _b === void 0 ? void 0 : _b.inputBackgroundColor);
|
|
18
|
+
}, function (_a) {
|
|
19
|
+
var _b, _c, _d;
|
|
20
|
+
var $disabled = _a.$disabled, theme = _a.theme, $showValidationMessage = _a.$showValidationMessage, $themeOverride = _a.$themeOverride;
|
|
21
|
+
return $showValidationMessage
|
|
22
|
+
? ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.failColor) || ((_b = theme.input) === null || _b === void 0 ? void 0 : _b.failColor)
|
|
23
|
+
: $disabled
|
|
24
|
+
? ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.disabledBorderColor) || ((_c = theme.input) === null || _c === void 0 ? void 0 : _c.disabledBorderColor)
|
|
25
|
+
: ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.inactiveBorderColor) || ((_d = theme.input) === null || _d === void 0 ? void 0 : _d.inactiveBorderColor);
|
|
26
|
+
}, function (_a) {
|
|
27
|
+
var $themeOverride = _a.$themeOverride, theme = _a.theme;
|
|
28
|
+
return ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.inputBorderRadius) || theme.input.inputBorderRadius;
|
|
29
|
+
}, function (_a) {
|
|
30
|
+
var $themeOverride = _a.$themeOverride, theme = _a.theme;
|
|
31
|
+
return ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.inputHeight) || theme.input.inputHeight;
|
|
32
|
+
}, function (_a) {
|
|
33
|
+
var $themeOverride = _a.$themeOverride, theme = _a.theme;
|
|
34
|
+
return ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.inputHeight) || theme.input.inputHeight;
|
|
35
|
+
}, function (_a) {
|
|
36
|
+
var _b;
|
|
37
|
+
var $themeOverride = _a.$themeOverride, theme = _a.theme;
|
|
38
|
+
return (_b = $themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.inputPadding) !== null && _b !== void 0 ? _b : theme.colorPickerInput.padding;
|
|
39
|
+
}, function (_a) {
|
|
40
|
+
var $themeOverride = _a.$themeOverride, theme = _a.theme;
|
|
41
|
+
return ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.inputHeight) || theme.input.inputHeight;
|
|
42
|
+
}, function (_a) {
|
|
43
|
+
var _b, _c, _d;
|
|
44
|
+
var $disabled = _a.$disabled, theme = _a.theme, $showValidationMessage = _a.$showValidationMessage, $themeOverride = _a.$themeOverride;
|
|
45
|
+
return $showValidationMessage
|
|
46
|
+
? ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.failColor) || ((_b = theme.input) === null || _b === void 0 ? void 0 : _b.failColor)
|
|
47
|
+
: $disabled
|
|
48
|
+
? ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.disabledBorderColor) || ((_c = theme.input) === null || _c === void 0 ? void 0 : _c.disabledBorderColor)
|
|
49
|
+
: ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.hoverBorderColor) || ((_d = theme.input) === null || _d === void 0 ? void 0 : _d.hoverBorderColor);
|
|
50
|
+
}, function (_a) {
|
|
51
|
+
var _b, _c, _d;
|
|
52
|
+
var $disabled = _a.$disabled, theme = _a.theme, $showValidationMessage = _a.$showValidationMessage, $themeOverride = _a.$themeOverride;
|
|
53
|
+
return $showValidationMessage
|
|
54
|
+
? ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.failColor) || ((_b = theme.input) === null || _b === void 0 ? void 0 : _b.failColor)
|
|
55
|
+
: $disabled
|
|
56
|
+
? ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.disabledBorderColor) || ((_c = theme.input) === null || _c === void 0 ? void 0 : _c.disabledBorderColor)
|
|
57
|
+
: ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.activeBorderColor) || ((_d = theme.input) === null || _d === void 0 ? void 0 : _d.activeBorderColor);
|
|
58
|
+
});
|
|
59
|
+
// Custom styled color input that is 90% of the wrapper size and centered
|
|
60
|
+
var ColorInput = styled.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: none;\n border-radius: 4px;\n border: none;\n cursor: ", ";\n height: 90%;\n opacity: ", ";\n outline: none;\n width: 90%;\n \n /* Remove the default color input outline/border and ensure color is visible */\n &::-webkit-color-swatch-wrapper {\n border-radius: 4px;\n border: none;\n padding: 0;\n }\n \n &::-webkit-color-swatch {\n border: none;\n border-radius: 4px;\n outline: none;\n }\n \n &::-moz-color-swatch {\n border: none;\n border-radius: 4px;\n outline: none;\n }\n \n /* Firefox specific fixes */\n &::-moz-focus-inner {\n border: none;\n padding: 0;\n }\n \n &:focus {\n outline: none;\n }\n"], ["\n background: none;\n border-radius: 4px;\n border: none;\n cursor: ", ";\n height: 90%;\n opacity: ", ";\n outline: none;\n width: 90%;\n \n /* Remove the default color input outline/border and ensure color is visible */\n &::-webkit-color-swatch-wrapper {\n border-radius: 4px;\n border: none;\n padding: 0;\n }\n \n &::-webkit-color-swatch {\n border: none;\n border-radius: 4px;\n outline: none;\n }\n \n &::-moz-color-swatch {\n border: none;\n border-radius: 4px;\n outline: none;\n }\n \n /* Firefox specific fixes */\n &::-moz-focus-inner {\n border: none;\n padding: 0;\n }\n \n &:focus {\n outline: none;\n }\n"])), function (_a) {
|
|
61
|
+
var $disabled = _a.$disabled;
|
|
62
|
+
return ($disabled ? "not-allowed" : "pointer");
|
|
63
|
+
}, function (_a) {
|
|
64
|
+
var $disabled = _a.$disabled;
|
|
65
|
+
return ($disabled ? 0.5 : 1);
|
|
66
|
+
});
|
|
67
|
+
// Legibility text component that displays to the right, vertically centered
|
|
68
|
+
var LegibilityText = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n color: ", ";\n font-size: ", "px;\n opacity: ", ";\n white-space: nowrap;\n"], ["\n color: ", ";\n font-size: ", "px;\n opacity: ", ";\n white-space: nowrap;\n"])), function (_a) {
|
|
69
|
+
var _b, _c;
|
|
70
|
+
var $disabled = _a.$disabled, $themeOverride = _a.$themeOverride, theme = _a.theme;
|
|
71
|
+
return $disabled ? ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.disabledColor) || ((_b = theme.input) === null || _b === void 0 ? void 0 : _b.disabledColor) : (_c = theme.input) === null || _c === void 0 ? void 0 : _c.helperTextColor;
|
|
72
|
+
}, function (_a) {
|
|
73
|
+
var _b;
|
|
74
|
+
var theme = _a.theme;
|
|
75
|
+
return (((_b = theme.input) === null || _b === void 0 ? void 0 : _b.textFontSize) || 14) - 2;
|
|
76
|
+
}, function (_a) {
|
|
77
|
+
var $disabled = _a.$disabled;
|
|
78
|
+
return ($disabled ? 0.5 : 1);
|
|
79
|
+
});
|
|
80
|
+
var InlineColorPickerInput = function (_a) {
|
|
81
|
+
var _b = _a.checkLegible, checkLegible = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, focus = _a.focus, innerRef = _a.innerRef, inputLabel = _a.inputLabel, _d = _a.legibleAgainst, legibleAgainst = _d === void 0 ? "#ffffff" : _d, name = _a.name, onChange = _a.onChange, onEnter = _a.onEnter, onInputBlur = _a.onInputBlur, onInputFocus = _a.onInputFocus, onValueChange = _a.onValueChange, _e = _a.showValidationMessage, showValidationMessage = _e === void 0 ? false : _e, themeOverride = _a.themeOverride, value = _a.value;
|
|
82
|
+
var inputRef = innerRef || useRef(null);
|
|
83
|
+
// Calculate legibility and dynamic text
|
|
84
|
+
var legibilityInfo = useMemo(function () {
|
|
85
|
+
if (!checkLegible || !value) {
|
|
86
|
+
return { isLegible: true, legibilityText: undefined };
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
var isLegible = validateColorContrast(value, legibleAgainst);
|
|
90
|
+
var legibilityText = void 0;
|
|
91
|
+
if (isLegible) {
|
|
92
|
+
legibilityText = "✅ Looks good";
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// Determine if we need lighter or darker
|
|
96
|
+
// If contrast with black is greater, the color is light and needs to be darker
|
|
97
|
+
// If contrast with white is greater, the color is dark and needs to be lighter
|
|
98
|
+
var needsDarker = contrast(value, "#000000") > contrast(value, "#ffffff");
|
|
99
|
+
legibilityText = needsDarker ? "⚠️ Too light" : "⚠️ Too dark";
|
|
100
|
+
}
|
|
101
|
+
return { isLegible: isLegible, legibilityText: legibilityText };
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
// If there's an error in contrast calculation, assume it's legible
|
|
105
|
+
return { isLegible: true, legibilityText: undefined };
|
|
106
|
+
}
|
|
107
|
+
}, [checkLegible, value, legibleAgainst]);
|
|
108
|
+
useEffect(function () {
|
|
109
|
+
var _a;
|
|
110
|
+
if (focus) {
|
|
111
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
112
|
+
}
|
|
113
|
+
}, [focus]);
|
|
114
|
+
return (jsxs(ColorPickerContainer, { children: [jsx(ColorInputWrapper, { "$disabled": disabled, "$showValidationMessage": showValidationMessage || (checkLegible && !legibilityInfo.isLegible), "$themeOverride": themeOverride, children: jsx(ColorInput, __assign({ ref: inputRef, type: "color", value: value, disabled: disabled, "$disabled": disabled, "$themeOverride": themeOverride }, (name ? { name: name } : {}), { onChange: function (event) {
|
|
115
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(event.target.value);
|
|
116
|
+
onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
117
|
+
target: {
|
|
118
|
+
value: event.target.value,
|
|
119
|
+
name: name,
|
|
120
|
+
selectionStart: event.target.selectionStart || undefined,
|
|
121
|
+
selectionEnd: event.target.selectionEnd || undefined,
|
|
122
|
+
},
|
|
123
|
+
nativeEvent: event.nativeEvent,
|
|
124
|
+
});
|
|
125
|
+
}, onBlur: function (event) {
|
|
126
|
+
if (onInputBlur) {
|
|
127
|
+
onInputBlur(event);
|
|
128
|
+
}
|
|
129
|
+
}, onFocus: function (event) {
|
|
130
|
+
if (onInputFocus) {
|
|
131
|
+
onInputFocus(event);
|
|
132
|
+
}
|
|
133
|
+
}, onKeyDown: function (event) {
|
|
134
|
+
if (event.key === "Enter" && onEnter) {
|
|
135
|
+
onEnter(value);
|
|
136
|
+
}
|
|
137
|
+
}, "aria-label": typeof inputLabel === "string" ? inputLabel : undefined })) }), checkLegible && legibilityInfo.legibilityText && (jsx(LegibilityText, { "$isLegible": legibilityInfo.isLegible, "$disabled": disabled, "$themeOverride": themeOverride, children: legibilityInfo.legibilityText }))] }));
|
|
138
|
+
};
|
|
139
|
+
var templateObject_1$1, templateObject_2, templateObject_3, templateObject_4;
|
|
140
|
+
|
|
141
|
+
var InstructionalText = styled(BodyXSPrimary)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tcolor: ", ";\n\tfont-size: ", "px;\n\tmargin-bottom: ", "px;\n"], ["\n\tcolor: ", ";\n\tfont-size: ", "px;\n\tmargin-bottom: ", "px;\n"])), function (_a) {
|
|
142
|
+
var theme = _a.theme, $themeOverride = _a.$themeOverride;
|
|
143
|
+
return ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.instructionalTextColor) || theme.colorPickerInput.instructionalTextColor;
|
|
144
|
+
}, function (_a) {
|
|
145
|
+
var theme = _a.theme, $themeOverride = _a.$themeOverride;
|
|
146
|
+
return ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.instructionalTextFontSize) || theme.colorPickerInput.instructionalTextFontSize;
|
|
147
|
+
}, function (_a) {
|
|
148
|
+
var theme = _a.theme, $themeOverride = _a.$themeOverride;
|
|
149
|
+
return ($themeOverride === null || $themeOverride === void 0 ? void 0 : $themeOverride.instructionalTextFontSize) || theme.colorPickerInput.instructionalTextFontSize;
|
|
150
|
+
});
|
|
151
|
+
var ColorPickerInput = function (props) {
|
|
152
|
+
var _a = props.checkLegible, checkLegible = _a === void 0 ? false : _a, _b = props.disabled, disabled = _b === void 0 ? false : _b, helperText = props.helperText, inputLabel = props.inputLabel, inputWidth = props.inputWidth, instructionalText = props.instructionalText, _c = props.showValidationMessage, showValidationMessage = _c === void 0 ? false : _c, themeOverride = props.themeOverride, validationMessage = props.validationMessage;
|
|
153
|
+
var labelBoxRef = useRef(null);
|
|
154
|
+
var _d = useMeasure(), inputGroupRef = _d[0], inputGroupMeasure = _d[1];
|
|
155
|
+
var validationRef = useRef(null);
|
|
156
|
+
var _e = useState(false), designSwitch = _e[0], setDesignSwitch = _e[1];
|
|
157
|
+
var helperTextVisible = !showValidationMessage || !designSwitch;
|
|
158
|
+
useEffect(function () {
|
|
159
|
+
var _a, _b;
|
|
160
|
+
var validationWidth = ((_a = validationRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) || 0;
|
|
161
|
+
var labelWidth = ((_b = labelBoxRef.current) === null || _b === void 0 ? void 0 : _b.clientWidth) || 0;
|
|
162
|
+
var noRoomForTopLabel = validationWidth + labelWidth >= inputGroupMeasure.width;
|
|
163
|
+
if (noRoomForTopLabel) {
|
|
164
|
+
setDesignSwitch(true);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
setDesignSwitch(false);
|
|
168
|
+
}
|
|
169
|
+
}, [inputGroupMeasure.width, showValidationMessage, inputLabel, validationMessage]);
|
|
170
|
+
return (jsxs(InputGroup, { ref: inputGroupRef, "$inputWidth": inputWidth, "$roomForError": showValidationMessage && !inputLabel, children: [jsx(LabelBox, { ref: labelBoxRef, children: showLabel({
|
|
171
|
+
inputLabel: inputLabel,
|
|
172
|
+
disabled: disabled,
|
|
173
|
+
disabledColor: themeOverride === null || themeOverride === void 0 ? void 0 : themeOverride.disabledColor,
|
|
174
|
+
labelColor: themeOverride === null || themeOverride === void 0 ? void 0 : themeOverride.labelColor,
|
|
175
|
+
}) }), instructionalText && jsx(InstructionalText, { "$themeOverride": themeOverride, children: instructionalText }), jsx(InlineColorPickerInput, __assign({}, props, { checkLegible: checkLegible, themeOverride: themeOverride })), jsx(ValidationText, { ref: validationRef, "$showValidationMessage": showValidationMessage, "$disabled": disabled, "$failColor": themeOverride === null || themeOverride === void 0 ? void 0 : themeOverride.failColor, "$disabledColor": themeOverride === null || themeOverride === void 0 ? void 0 : themeOverride.disabledColor, "$designSwitch": designSwitch && showValidationMessage, children: validationMessage }), helperTextVisible && (jsx(HelperText, { "$disabled": disabled, "$helperTextColor": themeOverride === null || themeOverride === void 0 ? void 0 : themeOverride.helperTextColor, "$disabledColor": themeOverride === null || themeOverride === void 0 ? void 0 : themeOverride.disabledColor, "data-sentry-unmask": true, children: helperText }))] }));
|
|
176
|
+
};
|
|
177
|
+
var templateObject_1;
|
|
178
|
+
|
|
179
|
+
export { ColorPickerInput as C, InlineColorPickerInput as I };
|
|
180
|
+
//# sourceMappingURL=ColorPickerInput-S8X2gIA5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerInput-S8X2gIA5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { C as ColorPickerInput, I as InlineColorPickerInput } from './ColorPickerInput-S8X2gIA5.js';
|
|
2
|
+
import './_tslib-CcAXazg4.js';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'styled-components';
|
|
6
|
+
import './BodyLEmphasis.js';
|
|
7
|
+
import './useMeasure-D89v6c_A.js';
|
|
8
|
+
import './addOrRemoveById.js';
|
|
9
|
+
import 'dayjs';
|
|
10
|
+
import './isEmptyObject.js';
|
|
11
|
+
import './useIsomorphicLayoutEffect-Br1zBZHl.js';
|
|
12
|
+
import './showLabel-D6KgNem4.js';
|
|
13
|
+
import './Inputs-C6OWHviY.js';
|
|
14
|
+
import './colors.js';
|
|
15
|
+
import './IconComponentStyles-BwczcTS4.js';
|
|
16
|
+
import './pressedEnter.js';
|
|
17
|
+
import './validateColorContrast.js';
|
|
18
|
+
//# sourceMappingURL=ColorPickerInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorPickerInput.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
package/lib/esm/DatePicker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as __assign } from './_tslib-CcAXazg4.js';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useRef, useState, useEffect } from 'react';
|
|
4
|
-
import { D as DatePickerGroup, I as InlineDatePicker, V as ValidationText, H as HelperText } from './InlineDatePicker-
|
|
4
|
+
import { D as DatePickerGroup, I as InlineDatePicker, V as ValidationText, H as HelperText } from './InlineDatePicker-BuxjkoV0.js';
|
|
5
5
|
import { u as useMeasure } from './useMeasure-D89v6c_A.js';
|
|
6
6
|
import { s as showLabel } from './showLabel-D6KgNem4.js';
|
|
7
7
|
import { L as LabelBox, A as Asterisk } from './Inputs-C6OWHviY.js';
|
package/lib/esm/Form.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { F as FormWrapper } from './FormStyles-
|
|
2
|
-
export { F as Form } from './FormikContainer-
|
|
3
|
-
export { FormFieldTypeEnum, RemovableFieldTypeEnum, isAddress, isCheckbox, isCheckboxGroup, isConfigurableInput, isCountrySelect, isCountySelect, isCreditCard, isCurrency, isDatePicker, isDescriptiveDropdownInput, isEmail, isFormFieldType, isImagePicker, isMultiSelect, isNationalitySelect, isNumber, isPassword, isPhone, isRadioGroup, isRemovable, isSectionHeader, isSelect, isSocialSecurity, isSplitLine, isStateSelect, isTextarea, isToggle, isToggleGroup, isZipCode } from './FormFieldTypeEnum.js';
|
|
1
|
+
export { F as FormWrapper } from './FormStyles-CyqyMC1o.js';
|
|
2
|
+
export { F as Form } from './FormikContainer-uI5oe1px.js';
|
|
3
|
+
export { FormFieldTypeEnum, RemovableFieldTypeEnum, isAddress, isCheckbox, isCheckboxGroup, isColorPicker, isConfigurableInput, isCountrySelect, isCountySelect, isCreditCard, isCurrency, isDatePicker, isDescriptiveDropdownInput, isEmail, isFormFieldType, isImagePicker, isMultiSelect, isNationalitySelect, isNumber, isPassword, isPhone, isRadioGroup, isRemovable, isSectionHeader, isSelect, isSocialSecurity, isSplitLine, isStateSelect, isTextarea, isToggle, isToggleGroup, isZipCode } from './FormFieldTypeEnum.js';
|
|
4
4
|
import './_tslib-CcAXazg4.js';
|
|
5
5
|
import 'styled-components';
|
|
6
6
|
import './colors.js';
|
|
@@ -18,6 +18,8 @@ import './Switches-yNTNw1zb.js';
|
|
|
18
18
|
import './DescriptiveSwitchMenuStyles-CQ_uwipg.js';
|
|
19
19
|
import './SwitchTypeEnum.js';
|
|
20
20
|
import './addOrRemoveById.js';
|
|
21
|
+
import './validateColorContrast.js';
|
|
22
|
+
import './pressedEnter.js';
|
|
21
23
|
import './formatBytesToString.js';
|
|
22
24
|
import './northAmericanNumberingPlanRegex.js';
|
|
23
25
|
import 'yup';
|
|
@@ -26,7 +28,6 @@ import 'react';
|
|
|
26
28
|
import './ButtonColorFamilyEnum.js';
|
|
27
29
|
import './LoadingEllipsis-8qdawLXG.js';
|
|
28
30
|
import './Button.js';
|
|
29
|
-
import './pressedEnter.js';
|
|
30
31
|
import './ArrowLong.js';
|
|
31
32
|
import './colors-D-UTb8yU.js';
|
|
32
33
|
import './CaretDown.js';
|
|
@@ -60,6 +61,7 @@ import './Checkbox-BvmFgeG0.js';
|
|
|
60
61
|
import './CheckboxEmpty.js';
|
|
61
62
|
import './CheckboxFull.js';
|
|
62
63
|
import './CheckboxGroup-DLMaYrFn.js';
|
|
64
|
+
import './ColorPickerInput-S8X2gIA5.js';
|
|
63
65
|
import './ConfigurableInput-BjJTNTyz.js';
|
|
64
66
|
import './RadioGroup-ByCUWp6N.js';
|
|
65
67
|
import './RadioItem-BKCG_dY3.js';
|
|
@@ -92,7 +94,7 @@ import './cardValidationStateMachine.js';
|
|
|
92
94
|
import './CurrencyInput-CzI4uaoz.js';
|
|
93
95
|
import './InlineCurrencyInput-DPpU3QyZ.js';
|
|
94
96
|
import './DatePicker.js';
|
|
95
|
-
import './InlineDatePicker-
|
|
97
|
+
import './InlineDatePicker-BuxjkoV0.js';
|
|
96
98
|
import './Calendar.js';
|
|
97
99
|
import './ClickOutHandler-CcKVoXIs.js';
|
|
98
100
|
import './CaretLeft.js';
|
package/lib/esm/Form.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Form.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ var FormFieldTypeEnum;
|
|
|
3
3
|
FormFieldTypeEnum["Address"] = "ADDRESS";
|
|
4
4
|
FormFieldTypeEnum["Checkbox"] = "CHECKBOX";
|
|
5
5
|
FormFieldTypeEnum["CheckboxGroup"] = "CHECKBOX_GROUP";
|
|
6
|
+
FormFieldTypeEnum["ColorPicker"] = "COLOR_PICKER";
|
|
6
7
|
FormFieldTypeEnum["ConfigurableInput"] = "CONFIGURABLE_INPUT";
|
|
7
8
|
FormFieldTypeEnum["CountySelect"] = "COUNTY_SELECT";
|
|
8
9
|
FormFieldTypeEnum["CountrySelect"] = "COUNTRY_SELECT";
|
|
@@ -44,6 +45,9 @@ var isCheckbox = function (field) {
|
|
|
44
45
|
var isCheckboxGroup = function (field) {
|
|
45
46
|
return field.type === FormFieldTypeEnum.CheckboxGroup;
|
|
46
47
|
};
|
|
48
|
+
var isColorPicker = function (field) {
|
|
49
|
+
return field.type === FormFieldTypeEnum.ColorPicker;
|
|
50
|
+
};
|
|
47
51
|
var isConfigurableInput = function (field) {
|
|
48
52
|
return field.type === FormFieldTypeEnum.ConfigurableInput;
|
|
49
53
|
};
|
|
@@ -155,5 +159,5 @@ var isZipCode = function (field) {
|
|
|
155
159
|
return field.type === FormFieldTypeEnum.ZipCode;
|
|
156
160
|
};
|
|
157
161
|
|
|
158
|
-
export { FormFieldTypeEnum, RemovableFieldTypeEnum, isAddress, isArrayOfSelectOptionsType, isCheckbox, isCheckboxGroup, isConfigurableInput, isCountrySelect, isCountySelect, isCreditCard, isCurrency, isDatePicker, isDescriptiveDropdownInput, isEmail, isFormFieldType, isHidden, isImagePicker, isMultiSelect, isNationalitySelect, isNumber, isPassword, isPhone, isRadioGroup, isRemovable, isSectionHeader, isSelect, isSelectOptionType, isSocialSecurity, isSplitLine, isStateSelect, isSwitchMenuOptionsType, isText, isTextarea, isToggle, isToggleGroup, isZipCode };
|
|
162
|
+
export { FormFieldTypeEnum, RemovableFieldTypeEnum, isAddress, isArrayOfSelectOptionsType, isCheckbox, isCheckboxGroup, isColorPicker, isConfigurableInput, isCountrySelect, isCountySelect, isCreditCard, isCurrency, isDatePicker, isDescriptiveDropdownInput, isEmail, isFormFieldType, isHidden, isImagePicker, isMultiSelect, isNationalitySelect, isNumber, isPassword, isPhone, isRadioGroup, isRemovable, isSectionHeader, isSelect, isSelectOptionType, isSocialSecurity, isSplitLine, isStateSelect, isSwitchMenuOptionsType, isText, isTextarea, isToggle, isToggleGroup, isZipCode };
|
|
159
163
|
//# sourceMappingURL=FormFieldTypeEnum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldTypeEnum.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormFieldTypeEnum.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/lib/esm/FormSeparator.js
CHANGED
|
@@ -5,7 +5,7 @@ import './BodyLEmphasis.js';
|
|
|
5
5
|
import './Loading.js';
|
|
6
6
|
import './Scroller.js';
|
|
7
7
|
import './Inputs-C6OWHviY.js';
|
|
8
|
-
export { u as AddButtonBox, A as AddButtonGroup, B as ButtonGroup, w as CancelButton, C as CenterCheckbox, o as CenterToggle, s as ClearFormButtonWrap, e as FieldBox, p as FormGroup, a as FormSeparator, q as FormTitleGroup, F as FormWrapper, H as HelperTextGrid, n as InlineFieldCell, m as InlineFieldGrid, I as InputBox, f as LeftGutter, g as LeftLabel, L as LoadingBase, b as LoadingBox, d as LoadingInput, c as LoadingLabel, k as RemovableButtonBox, i as RemovableFieldBox, j as RemoveButtonWrapper, R as RightGutter, S as SubHeader, v as SubmitButton, l as Text, r as Title, T as TitleGroup, V as ValidationTextGrid } from './FormStyles-
|
|
8
|
+
export { u as AddButtonBox, A as AddButtonGroup, B as ButtonGroup, w as CancelButton, C as CenterCheckbox, o as CenterToggle, s as ClearFormButtonWrap, e as FieldBox, p as FormGroup, a as FormSeparator, q as FormTitleGroup, F as FormWrapper, H as HelperTextGrid, n as InlineFieldCell, m as InlineFieldGrid, I as InputBox, f as LeftGutter, g as LeftLabel, L as LoadingBase, b as LoadingBox, d as LoadingInput, c as LoadingLabel, k as RemovableButtonBox, i as RemovableFieldBox, j as RemoveButtonWrapper, R as RightGutter, S as SubHeader, v as SubmitButton, l as Text, r as Title, T as TitleGroup, V as ValidationTextGrid } from './FormStyles-CyqyMC1o.js';
|
|
9
9
|
import 'react/jsx-runtime';
|
|
10
10
|
import './IconComponentStyles-BwczcTS4.js';
|
|
11
11
|
import './CheckboxStyles-Cx6hCn3t.js';
|
|
@@ -16,6 +16,8 @@ import './Switches-yNTNw1zb.js';
|
|
|
16
16
|
import './DescriptiveSwitchMenuStyles-CQ_uwipg.js';
|
|
17
17
|
import './SwitchTypeEnum.js';
|
|
18
18
|
import './addOrRemoveById.js';
|
|
19
|
+
import './validateColorContrast.js';
|
|
20
|
+
import './pressedEnter.js';
|
|
19
21
|
import './formatBytesToString.js';
|
|
20
22
|
import './northAmericanNumberingPlanRegex.js';
|
|
21
23
|
import 'yup';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormSeparator.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormSeparator.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -14,10 +14,11 @@ import './Switches-yNTNw1zb.js';
|
|
|
14
14
|
import './DescriptiveSwitchMenuStyles-CQ_uwipg.js';
|
|
15
15
|
import { SwitchTypeEnum } from './SwitchTypeEnum.js';
|
|
16
16
|
import { getObjectById } from './addOrRemoveById.js';
|
|
17
|
+
import { validateColorContrast } from './validateColorContrast.js';
|
|
17
18
|
import { formatBytesToString } from './formatBytesToString.js';
|
|
18
19
|
import { northAmericanNumberingPlanRegex } from './northAmericanNumberingPlanRegex.js';
|
|
19
20
|
import * as yup from 'yup';
|
|
20
|
-
import { FormFieldTypeEnum, isSplitLine, isSectionHeader, isCheckbox, isToggle, isCheckboxGroup, isMultiSelect, isToggleGroup, isRemovable, isPassword, isAddress, isConfigurableInput, isCountySelect, isCountrySelect, isCreditCard, isCurrency, isDatePicker, isDescriptiveDropdownInput, isEmail, isImagePicker, isNumber, isPhone, isRadioGroup, isSelect, isSocialSecurity, isStateSelect, isTextarea, isZipCode } from './FormFieldTypeEnum.js';
|
|
21
|
+
import { FormFieldTypeEnum, isSplitLine, isSectionHeader, isCheckbox, isToggle, isCheckboxGroup, isMultiSelect, isToggleGroup, isRemovable, isPassword, isAddress, isColorPicker, isConfigurableInput, isCountySelect, isCountrySelect, isCreditCard, isCurrency, isDatePicker, isDescriptiveDropdownInput, isEmail, isImagePicker, isNumber, isPhone, isRadioGroup, isSelect, isSocialSecurity, isStateSelect, isTextarea, isZipCode } from './FormFieldTypeEnum.js';
|
|
21
22
|
|
|
22
23
|
var integerRegex = /^\d+$/;
|
|
23
24
|
// at least 8 chars
|
|
@@ -173,8 +174,24 @@ var formatValidationInternals = function (_a) {
|
|
|
173
174
|
validationFunction ||
|
|
174
175
|
(required && allowRequired && !disabled ? yup.array().of(yup.string()).min(1, requiredMessage) : yup.array().of(yup.string()));
|
|
175
176
|
}
|
|
177
|
+
else if (isColorPicker(field)) {
|
|
178
|
+
var _j = field.requiredMessage, requiredMessage = _j === void 0 ? "This field is required" : _j, _k = field.validationMessage, validationMessage = _k === void 0 ? "This color does not have sufficient contrast for accessibility" : _k;
|
|
179
|
+
var _l = field.options || {}, _m = _l.checkLegible, checkLegible = _m === void 0 ? false : _m, _o = _l.legibleAgainst, legibleAgainst_1 = _o === void 0 ? "#ffffff" : _o;
|
|
180
|
+
// Create base string validation
|
|
181
|
+
var colorSchema = yup.string();
|
|
182
|
+
// Add contrast validation if checkLegible is enabled
|
|
183
|
+
if (checkLegible) {
|
|
184
|
+
colorSchema = colorSchema.test("color-contrast", validationMessage, function (value) {
|
|
185
|
+
if (!value)
|
|
186
|
+
return true; // Allow empty values, let required validation handle this
|
|
187
|
+
return validateColorContrast(value, legibleAgainst_1);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
validationInternals[name_6] =
|
|
191
|
+
validationFunction || (required && allowRequired && !disabled ? colorSchema.required(requiredMessage) : colorSchema);
|
|
192
|
+
}
|
|
176
193
|
else if (isConfigurableInput(field)) {
|
|
177
|
-
var
|
|
194
|
+
var _p = field.requiredMessage, requiredMessage = _p === void 0 ? "This field is required" : _p, _q = field.validationMessage, validationMessage = _q === void 0 ? "This field must be a string" : _q, options = field.options;
|
|
178
195
|
var maskedRadios = options.maskedRadios, defaultId = options.defaultId;
|
|
179
196
|
var activeId = configurableInputFieldActiveIds[name_6] || defaultId || maskedRadios[0].value;
|
|
180
197
|
var selectedOption = getObjectById({ array: maskedRadios, id: activeId, idKey: "value" });
|
|
@@ -187,31 +204,31 @@ var formatValidationInternals = function (_a) {
|
|
|
187
204
|
: yup.string().typeError(validationMessage));
|
|
188
205
|
}
|
|
189
206
|
else if (isCountySelect(field)) {
|
|
190
|
-
var
|
|
207
|
+
var _r = field.requiredMessage, requiredMessage = _r === void 0 ? "This field is required" : _r, _s = field.validationMessage, validationMessage = _s === void 0 ? "This field must be a string" : _s;
|
|
191
208
|
validationInternals[name_6] =
|
|
192
209
|
validationFunction ||
|
|
193
210
|
(required && allowRequired && !disabled ? yup.string().required(requiredMessage) : yup.string().typeError(validationMessage));
|
|
194
211
|
}
|
|
195
212
|
else if (isCountrySelect(field)) {
|
|
196
|
-
var
|
|
213
|
+
var _t = field.requiredMessage, requiredMessage = _t === void 0 ? "This field is required" : _t, _u = field.validationMessage, validationMessage = _u === void 0 ? "This field must be a string" : _u;
|
|
197
214
|
validationInternals[name_6] =
|
|
198
215
|
validationFunction ||
|
|
199
216
|
(required && allowRequired && !disabled ? yup.string().required(requiredMessage) : yup.string().typeError(validationMessage));
|
|
200
217
|
}
|
|
201
218
|
else if (isCreditCard(field)) {
|
|
202
|
-
var
|
|
219
|
+
var _v = field.requiredMessage, requiredMessage = _v === void 0 ? "This field is required" : _v, _w = field.validationMessage, validationMessage = _w === void 0 ? "This field must be a string" : _w;
|
|
203
220
|
validationInternals[name_6] =
|
|
204
221
|
validationFunction ||
|
|
205
222
|
(required && allowRequired && !disabled ? yup.string().required(requiredMessage) : yup.string().typeError(validationMessage));
|
|
206
223
|
}
|
|
207
224
|
else if (isCurrency(field)) {
|
|
208
|
-
var
|
|
225
|
+
var _x = field.requiredMessage, requiredMessage = _x === void 0 ? "This field is required" : _x, _y = field.validationMessage, validationMessage = _y === void 0 ? "This field must be a number" : _y;
|
|
209
226
|
validationInternals[name_6] =
|
|
210
227
|
validationFunction ||
|
|
211
228
|
(required && allowRequired && !disabled ? yup.number().required(requiredMessage) : yup.number().typeError(validationMessage));
|
|
212
229
|
}
|
|
213
230
|
else if (isDatePicker(field)) {
|
|
214
|
-
var
|
|
231
|
+
var _z = field.requiredMessage, requiredMessage = _z === void 0 ? "This field is required" : _z, _0 = field.validationMessage, validationMessage = _0 === void 0 ? "Please enter a valid date" : _0;
|
|
215
232
|
var dateSchema = yup
|
|
216
233
|
.date()
|
|
217
234
|
// For some reason, "value" is always wrong. Thanks react-datepicker. Thanks a lot.
|
|
@@ -228,7 +245,7 @@ var formatValidationInternals = function (_a) {
|
|
|
228
245
|
validationFunction || (required && allowRequired && !disabled ? dateSchema.required(requiredMessage) : dateSchema);
|
|
229
246
|
}
|
|
230
247
|
else if (isDescriptiveDropdownInput(field)) {
|
|
231
|
-
var
|
|
248
|
+
var _1 = field.requiredMessage, requiredMessage = _1 === void 0 ? "Please select at least one" : _1, _2 = field.validationMessage, validationMessage = _2 === void 0 ? "This field must be a string" : _2;
|
|
232
249
|
var switchType = (_b = field.options) === null || _b === void 0 ? void 0 : _b.switchType;
|
|
233
250
|
if (!switchType || switchType === SwitchTypeEnum.Radio) {
|
|
234
251
|
validationInternals[name_6] =
|
|
@@ -242,7 +259,7 @@ var formatValidationInternals = function (_a) {
|
|
|
242
259
|
}
|
|
243
260
|
}
|
|
244
261
|
else if (isEmail(field)) {
|
|
245
|
-
var
|
|
262
|
+
var _3 = field.requiredMessage, requiredMessage = _3 === void 0 ? "Please enter your email" : _3, _4 = field.validationMessage, validationMessage = _4 === void 0 ? "Invalid email" : _4;
|
|
246
263
|
validationInternals[name_6] =
|
|
247
264
|
validationFunction ||
|
|
248
265
|
(required && allowRequired && !disabled
|
|
@@ -251,7 +268,7 @@ var formatValidationInternals = function (_a) {
|
|
|
251
268
|
}
|
|
252
269
|
else if (isImagePicker(field)) {
|
|
253
270
|
var maxFileSize_1 = ((_c = field.options) === null || _c === void 0 ? void 0 : _c.maxFileSize) || 9999999999;
|
|
254
|
-
var initialValue_1 = field.initialValue,
|
|
271
|
+
var initialValue_1 = field.initialValue, _5 = field.requiredMessage, requiredMessage = _5 === void 0 ? "Please pick an image" : _5, _6 = field.validationMessage, validationMessage = _6 === void 0 ? "File cannot exceed ".concat(formatBytesToString({ bytes: maxFileSize_1 })) : _6;
|
|
255
272
|
validationInternals[name_6] =
|
|
256
273
|
validationFunction ||
|
|
257
274
|
(required && allowRequired && !disabled
|
|
@@ -259,13 +276,13 @@ var formatValidationInternals = function (_a) {
|
|
|
259
276
|
: yup.mixed().test("fileSize", validationMessage, function (value) { return imageValidation({ value: value, maxFileSize: maxFileSize_1, initialValue: initialValue_1 }); })); // will validate if there is no file, or if the initialValue is passed
|
|
260
277
|
}
|
|
261
278
|
else if (isMultiSelect(field)) {
|
|
262
|
-
var
|
|
279
|
+
var _7 = field.requiredMessage, requiredMessage = _7 === void 0 ? "This field is required" : _7;
|
|
263
280
|
validationInternals[name_6] =
|
|
264
281
|
validationFunction ||
|
|
265
282
|
(required && allowRequired && !disabled ? yup.array().of(yup.string()).min(1, requiredMessage) : yup.array().of(yup.string()));
|
|
266
283
|
}
|
|
267
284
|
else if (isNumber(field)) {
|
|
268
|
-
var
|
|
285
|
+
var _8 = field.requiredMessage, requiredMessage = _8 === void 0 ? "This field is required" : _8, _9 = field.validationMessage, validationMessage = _9 === void 0 ? "Please enter a valid number" : _9;
|
|
269
286
|
validationInternals[name_6] =
|
|
270
287
|
validationFunction ||
|
|
271
288
|
(required && allowRequired && !disabled
|
|
@@ -282,7 +299,7 @@ var formatValidationInternals = function (_a) {
|
|
|
282
299
|
}));
|
|
283
300
|
}
|
|
284
301
|
else if (isPhone(field)) {
|
|
285
|
-
var
|
|
302
|
+
var _10 = field.requiredMessage, requiredMessage = _10 === void 0 ? "Phone number is required" : _10, _11 = field.validationMessage, validationMessage = _11 === void 0 ? "Please enter a valid phone number" : _11;
|
|
286
303
|
validationInternals[name_6] =
|
|
287
304
|
validationFunction ||
|
|
288
305
|
(required && allowRequired && !disabled
|
|
@@ -300,19 +317,19 @@ var formatValidationInternals = function (_a) {
|
|
|
300
317
|
}));
|
|
301
318
|
}
|
|
302
319
|
else if (isRadioGroup(field)) {
|
|
303
|
-
var
|
|
320
|
+
var _12 = field.requiredMessage, requiredMessage = _12 === void 0 ? "Please select one" : _12, _13 = field.validationMessage, validationMessage = _13 === void 0 ? "This field must be a string" : _13;
|
|
304
321
|
validationInternals[name_6] =
|
|
305
322
|
validationFunction ||
|
|
306
323
|
(required && allowRequired && !disabled ? yup.string().required(requiredMessage) : yup.string().typeError(validationMessage));
|
|
307
324
|
}
|
|
308
325
|
else if (isSelect(field)) {
|
|
309
|
-
var
|
|
326
|
+
var _14 = field.requiredMessage, requiredMessage = _14 === void 0 ? "This field is required" : _14, _15 = field.validationMessage, validationMessage = _15 === void 0 ? "This field must be a string" : _15;
|
|
310
327
|
validationInternals[name_6] =
|
|
311
328
|
validationFunction ||
|
|
312
329
|
(required && allowRequired && !disabled ? yup.string().required(requiredMessage) : yup.string().typeError(validationMessage));
|
|
313
330
|
}
|
|
314
331
|
else if (isSocialSecurity(field)) {
|
|
315
|
-
var
|
|
332
|
+
var _16 = field.requiredMessage, requiredMessage = _16 === void 0 ? "Please enter an SSN" : _16, _17 = field.validationMessage, validationMessage = _17 === void 0 ? "Please enter a valid SSN" : _17;
|
|
316
333
|
validationInternals[name_6] =
|
|
317
334
|
validationFunction ||
|
|
318
335
|
(required && allowRequired && !disabled
|
|
@@ -329,25 +346,25 @@ var formatValidationInternals = function (_a) {
|
|
|
329
346
|
}));
|
|
330
347
|
}
|
|
331
348
|
else if (isStateSelect(field)) {
|
|
332
|
-
var
|
|
349
|
+
var _18 = field.requiredMessage, requiredMessage = _18 === void 0 ? "This field is required" : _18, _19 = field.validationMessage, validationMessage = _19 === void 0 ? "This field must be a string" : _19;
|
|
333
350
|
validationInternals[name_6] =
|
|
334
351
|
validationFunction ||
|
|
335
352
|
(required && allowRequired && !disabled ? yup.string().required(requiredMessage) : yup.string().typeError(validationMessage));
|
|
336
353
|
}
|
|
337
354
|
else if (isTextarea(field)) {
|
|
338
|
-
var
|
|
355
|
+
var _20 = field.requiredMessage, requiredMessage = _20 === void 0 ? "This field is required" : _20, _21 = field.validationMessage, validationMessage = _21 === void 0 ? "This field must be a string" : _21;
|
|
339
356
|
validationInternals[name_6] =
|
|
340
357
|
validationFunction ||
|
|
341
358
|
(required && allowRequired && !disabled ? yup.string().required(requiredMessage) : yup.string().typeError(validationMessage));
|
|
342
359
|
}
|
|
343
360
|
else if (isToggleGroup(field)) {
|
|
344
|
-
var
|
|
361
|
+
var _22 = field.requiredMessage, requiredMessage = _22 === void 0 ? "Please select at least one" : _22;
|
|
345
362
|
validationInternals[name_6] =
|
|
346
363
|
validationFunction ||
|
|
347
364
|
(required && allowRequired && !disabled ? yup.array().of(yup.string()).min(1, requiredMessage) : yup.array().of(yup.string()));
|
|
348
365
|
}
|
|
349
366
|
else if (isZipCode(field)) {
|
|
350
|
-
var
|
|
367
|
+
var _23 = field.requiredMessage, requiredMessage = _23 === void 0 ? "Please enter a zip code" : _23, _24 = field.validationMessage, validationMessage = _24 === void 0 ? "Please enter a valid zip code" : _24;
|
|
351
368
|
validationInternals[name_6] =
|
|
352
369
|
validationFunction ||
|
|
353
370
|
(required && allowRequired && !disabled
|
|
@@ -364,7 +381,7 @@ var formatValidationInternals = function (_a) {
|
|
|
364
381
|
}));
|
|
365
382
|
}
|
|
366
383
|
else {
|
|
367
|
-
var
|
|
384
|
+
var _25 = field.requiredMessage, requiredMessage = _25 === void 0 ? "This field is required" : _25, _26 = field.validationMessage, validationMessage = _26 === void 0 ? "This field must be a string" : _26;
|
|
368
385
|
validationInternals[name_6] =
|
|
369
386
|
validationFunction ||
|
|
370
387
|
(required && allowRequired && !disabled
|
|
@@ -697,4 +714,4 @@ var LoadingInput = styled.div(templateObject_32 || (templateObject_32 = __makeTe
|
|
|
697
714
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27, templateObject_28, templateObject_29, templateObject_30, templateObject_31, templateObject_32;
|
|
698
715
|
|
|
699
716
|
export { AddButtonGroup as A, ButtonGroup as B, CenterCheckbox as C, DefaultPixelWidth as D, FormWrapper as F, HelperTextGrid as H, InputBox as I, LoadingBase as L, RightGutter as R, SubHeader as S, TitleGroup as T, ValidationTextGrid as V, FormSeparator as a, LoadingBox as b, LoadingLabel as c, LoadingInput as d, FieldBox as e, LeftGutter as f, LeftLabel as g, formHasValues as h, RemovableFieldBox as i, RemoveButtonWrapper as j, RemovableButtonBox as k, Text as l, InlineFieldGrid as m, InlineFieldCell as n, CenterToggle as o, FormGroup as p, FormTitleGroup as q, Title as r, ClearFormButtonWrap as s, shouldFade as t, AddButtonBox as u, SubmitButton as v, CancelButton as w, formatValidation as x, formatInitialValues as y };
|
|
700
|
-
//# sourceMappingURL=FormStyles-
|
|
717
|
+
//# sourceMappingURL=FormStyles-CyqyMC1o.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormStyles-
|
|
1
|
+
{"version":3,"file":"FormStyles-CyqyMC1o.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|