@cerebruminc/cerebellum 16.1.1 → 16.2.0-beta.dangerous.cd6fba9
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-oEHUS8Oi.js} +43 -22
- package/lib/cjs/{FormStyles-CxgYRZOl.js.map → FormStyles-oEHUS8Oi.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-DDXxSB2z.js} +37 -4
- package/lib/cjs/{FormikContainer-CY2nLsAs.js.map → FormikContainer-DDXxSB2z.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-wlDzB1vZ.js} +44 -23
- package/lib/esm/{FormStyles-BQJPyTS0.js.map → FormStyles-wlDzB1vZ.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--y08X-6j.js} +38 -5
- package/lib/esm/{FormikContainer-SJPYfIkF.js.map → FormikContainer--y08X-6j.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-wlDzB1vZ.js';
|
|
2
|
+
export { F as Form } from './FormikContainer--y08X-6j.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-wlDzB1vZ.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":";;;;;;;;;;;;;;;;;;;;;;;"}
|