@sprinklrjs/spaceweb 14.14.1 → 14.14.3

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.
Files changed (42) hide show
  1. package/asyncSelect/hooks/useAsyncSelect.d.ts +3 -3
  2. package/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +3 -3
  3. package/baseui/layer/tether.js +6 -3
  4. package/baseui/layer/types.d.ts +5 -0
  5. package/baseui/layer/utils.d.ts +25 -0
  6. package/baseui/layer/utils.js +74 -1
  7. package/baseui/popover/popover.js +61 -13
  8. package/baseui/popover/stateful-container.js +2 -1
  9. package/baseui/popover/styled-components.js +5 -0
  10. package/baseui/popover/types.d.ts +7 -0
  11. package/color-picker/CustomColorSelector.js +25 -15
  12. package/color-picker/constants.d.ts +3 -0
  13. package/color-picker/constants.js +3 -1
  14. package/date-picker/StatelessDatePicker.js +10 -8
  15. package/esm/asyncSelect/hooks/useAsyncSelect.d.ts +3 -3
  16. package/esm/asyncSelect/hooks/useGroupedAsyncSelect.d.ts +3 -3
  17. package/esm/baseui/layer/tether.js +7 -4
  18. package/esm/baseui/layer/types.d.ts +5 -0
  19. package/esm/baseui/layer/utils.d.ts +25 -0
  20. package/esm/baseui/layer/utils.js +71 -0
  21. package/esm/baseui/popover/popover.js +61 -13
  22. package/esm/baseui/popover/stateful-container.js +2 -1
  23. package/esm/baseui/popover/styled-components.js +5 -0
  24. package/esm/baseui/popover/types.d.ts +7 -0
  25. package/esm/color-picker/CustomColorSelector.js +26 -16
  26. package/esm/color-picker/constants.d.ts +3 -0
  27. package/esm/color-picker/constants.js +2 -0
  28. package/esm/date-picker/StatelessDatePicker.js +10 -8
  29. package/esm/helpers/colors.d.ts +1 -0
  30. package/esm/helpers/colors.js +14 -2
  31. package/esm/popover/popover.js +2 -2
  32. package/esm/tooltip/disabled-tooltip-container.d.ts +1 -0
  33. package/esm/tooltip/stateful-tooltip-container.d.ts +1 -0
  34. package/esm/tooltip/stateful-tooltip.d.ts +1 -0
  35. package/helpers/colors.d.ts +1 -0
  36. package/helpers/colors.js +16 -3
  37. package/package.json +2 -2
  38. package/popover/popover.js +2 -2
  39. package/tooltip/disabled-tooltip-container.d.ts +1 -0
  40. package/tooltip/stateful-tooltip-container.d.ts +1 -0
  41. package/tooltip/stateful-tooltip.d.ts +1 -0
  42. package/tsconfig.build.tsbuildinfo +1 -1
@@ -5,8 +5,9 @@ import { CustomPicker } from 'react-color';
5
5
  import { Alpha, EditableInput, Hue, Saturation } from 'react-color/lib/components/common';
6
6
  import { Stack } from '../stack';
7
7
  import { Box } from '../box';
8
- import { hexToRgb, isValidHex, normalizeHexWithAlpha } from '../helpers/colors';
8
+ import { hexToRgb, isValidHex, normalizeHexWithAlpha, normalizeHex } from '../helpers/colors';
9
9
  import TransparentBackground from '../icon/components/transparentBackground';
10
+ import { TRANSPARENT_HEX, TRANSPARENT_RGBA } from './constants';
10
11
  var CustomPointer = function () { return (_jsx(Box, { style: function (_a) {
11
12
  var rtlCompatible = _a.rtlCompatible;
12
13
  return rtlCompatible({ transform: 'translate(-50%, -2px)' });
@@ -60,6 +61,11 @@ var CustomEditableInput = function (_a) {
60
61
  // @ts-ignore -- @types/react-color doesn't properly include types for input
61
62
  var input = editableInput.input;
62
63
  var fireChange = function () {
64
+ var inputValue = input.value;
65
+ if (inputValue === String(value))
66
+ return;
67
+ if (label === 'Hex' && normalizeHex(inputValue) === normalizeHex(String(value)))
68
+ return;
63
69
  onChange(typedValue.current);
64
70
  };
65
71
  var keydownHandler = function (event) {
@@ -72,16 +78,15 @@ var CustomEditableInput = function (_a) {
72
78
  input.removeEventListener('blur', fireChange);
73
79
  input.removeEventListener('keydown', keydownHandler);
74
80
  };
75
- }, [editableInput, label, onChange]);
81
+ }, [editableInput, label, onChange, value]);
76
82
  return (_jsx(EditableInput, { style: EDITABLE_INPUT_STYLES, label: label, value: value, onChange: handleChange, ref: setInput }));
77
83
  };
78
84
  function getNumberWithFallback(input, fallback) {
79
- var _fallback = fallback !== null && fallback !== void 0 ? fallback : 0;
80
- if (!input)
81
- return _fallback;
82
- if (Number.isNaN(+input))
83
- return _fallback;
84
- return parseInt(input);
85
+ if (fallback === void 0) { fallback = 0; }
86
+ var trimmedInput = input === null || input === void 0 ? void 0 : input.trim();
87
+ if (!trimmedInput || Number.isNaN(+trimmedInput))
88
+ return fallback;
89
+ return parseInt(trimmedInput);
85
90
  }
86
91
  var ColorPickerComponent = function (_props) {
87
92
  // react-color intercepts the onChange function, wraps the data, and forwards it accordingly
@@ -95,8 +100,9 @@ var ColorPickerComponent = function (_props) {
95
100
  // color which cause a flickering issue
96
101
  //https://github.com/casesandberg/react-color/blob/bc9a0e1dc5d11b06c511a8e02a95bd85c7129f4b/src/components/sketch/SketchFields.js#L51
97
102
  var _a = rgb !== null && rgb !== void 0 ? rgb : {}, r = _a.r, g = _a.g, b = _a.b, a = _a.a;
103
+ var hexInput = (_hex === null || _hex === void 0 ? void 0 : _hex.toLowerCase()) === 'transparent' ? '#000000' : _hex;
98
104
  // react-color doesn't support alpha hexes, so we need to insert it ourselves
99
- var hex = normalizeHexWithAlpha(_hex, a);
105
+ var hex = normalizeHexWithAlpha(hexInput, a);
100
106
  var handleHueChange = useCallback(function (data) {
101
107
  // If alpha was zero and the saturation/lightness is changed, reset alpha to full
102
108
  if ('a' in data && data.a === 0) {
@@ -109,15 +115,19 @@ var ColorPickerComponent = function (_props) {
109
115
  // react-color emitted data is very dynamic and uses properties from labels
110
116
  if ('Hex' in data) {
111
117
  var newHex = data.Hex;
112
- var parsedRgba = hexToRgb(data.Hex);
118
+ if (newHex.toLowerCase() === 'transparent' && hex !== TRANSPARENT_HEX) {
119
+ onChange(TRANSPARENT_RGBA);
120
+ onChangeComplete({ rgb: TRANSPARENT_RGBA });
121
+ return;
122
+ }
123
+ if (!isValidHex(newHex))
124
+ return;
125
+ var parsedRgba = hexToRgb(newHex);
113
126
  var newRgba = enableAlphaSelector ? parsedRgba : __assign(__assign({}, parsedRgba), { a: 1 }); // No alpha values when enableAlphaSelector is disabled
114
127
  onChange(newRgba);
115
- // No need to invoke onChange based on isValidHex as onChange is standard handler for react-color
116
- // CustomPicker HOC takes care that onChange is invoked with correct values in case of invalid value of rgba.
117
- if (isValidHex(newHex))
118
- onChangeComplete({ rgb: newRgba });
128
+ onChangeComplete({ rgb: newRgba });
119
129
  }
120
- else if (data.R || data.G || data.B || data.A) {
130
+ else if ('R' in data || 'G' in data || 'B' in data || 'A' in data) {
121
131
  var _a = __read(Object.keys(data), 1), changedKey = _a[0];
122
132
  // Reset alpha IF:
123
133
  // Changed value is R/G/B AND current alpha is 0 AND new value is different from old value
@@ -131,7 +141,7 @@ var ColorPickerComponent = function (_props) {
131
141
  onChange(newRgba);
132
142
  onChangeComplete({ rgb: newRgba });
133
143
  }
134
- }, [onChange, onChangeComplete, enableAlphaSelector, r, g, b, a]);
144
+ }, [onChange, onChangeComplete, enableAlphaSelector, r, g, b, a, hex]);
135
145
  return (_jsxs(Stack, __assign({ direction: "vertical", gap: 4 }, { children: [renderColorSuggestionPanel ? renderColorSuggestionPanel(hex) : null, _jsx(Box, __assign({ className: "relative w-full h-32 rounded-16 overflow-hidden", style: { height: '150px' } }, { children: _jsx(Saturation, __assign({}, props, { onChange: handleHueChange })) })), _jsxs(Stack, __assign({ direction: "vertical", gap: 2 }, { children: [_jsx(Box, __assign({ className: "flex gap-2 justify-between ml-2" }, { children: _jsxs(Box, __assign({ className: "flex flex-col items-start gap-2" }, { children: [_jsxs(Box, __assign({ className: "flex items-center gap-2" }, { children: [_jsx(Box, __assign({ className: "relative h-3", style: { width: enableAlphaSelector ? '261px' : '228px' } }, { children: _jsx(Hue, __assign({ pointer: CustomPointer, radius: "24px" }, props, { onChange: handleHueChange })) })), _jsx(ColorPreview, { color: rgb })] })), enableAlphaSelector ? (_jsx(Box, __assign({ className: "relative h-3", style: { width: '261px' } }, { children: _jsx(Alpha, __assign({ pointer: CustomPointer, radius: "24px", style: { container: { margin: 0 } } }, props)) }))) : null] })) })), _jsxs(Box, __assign({ className: "grid w-full gap-2",
136
146
  // 5 columns with alpha, 4 columns without
137
147
  style: {
@@ -1,3 +1,4 @@
1
+ import type { RGBColor } from 'react-color';
1
2
  export declare const GRADIENT_TYPE: {
2
3
  LINEAR: string;
3
4
  RADIAL: string;
@@ -12,3 +13,5 @@ export declare const COLOR_TYPE: {
12
13
  readonly GRADIENT: "gradient";
13
14
  };
14
15
  export declare const SWATCHES_PER_ROW = 10;
16
+ export declare const TRANSPARENT_HEX = "#00000000";
17
+ export declare const TRANSPARENT_RGBA: RGBColor;
@@ -8,3 +8,5 @@ export var COLOR_TYPE = {
8
8
  GRADIENT: 'gradient',
9
9
  };
10
10
  export var SWATCHES_PER_ROW = 10;
11
+ export var TRANSPARENT_HEX = '#00000000';
12
+ export var TRANSPARENT_RGBA = { r: 0, g: 0, b: 0, a: 0 };
@@ -24,9 +24,9 @@ import { getDefaultSize } from '../helpers/themeHelpers';
24
24
  import { useStyle } from '../style';
25
25
  // eslint-disable-next-line max-statements -- required for function component
26
26
  export var StatelessDatePicker = function (_props) {
27
- var _a, _b, _c;
27
+ var _a, _b, _c, _d;
28
28
  var theme = useStyle().theme;
29
- var _d = useContextualFormProps(_props), onChange = _d.onChange, onBlur = _d.onBlur, _e = _d.adapter, adapter = _e === void 0 ? dateFnsAdapter : _e, _f = _d.size, size = _f === void 0 ? getDefaultSize(theme) : _f, _g = _d.formatString, formatString = _g === void 0 ? DEFAULT_FORMAT_STRING : _g, _h = _d.isOpen, isOpen = _h === void 0 ? false : _h, onFocus = _d.onFocus, clearable = _d.clearable, _displayValueAtRangeIndex = _d.displayValueAtRangeIndex, _j = _d.variant, variant = _j === void 0 ? 'default' : _j, overrides = _d.overrides, intent = _d.intent, _value = _d.value, formatDisplayValue = _d.formatDisplayValue, _k = _d.autoSizeInput, autoSizeInput = _k === void 0 ? false : _k, weekStartsOn = _d.weekStartsOn, _l = _d.timezone, timezone = _l === void 0 ? getSystemTzName() : _l, _m = _d.showTimezone, showTimezone = _m === void 0 ? false : _m, timezoneOptions = _d.timezoneOptions, props = __rest(_d, ["onChange", "onBlur", "adapter", "size", "formatString", "isOpen", "onFocus", "clearable", "displayValueAtRangeIndex", "variant", "overrides", "intent", "value", "formatDisplayValue", "autoSizeInput", "weekStartsOn", "timezone", "showTimezone", "timezoneOptions"]);
29
+ var _e = useContextualFormProps(_props), onChange = _e.onChange, onBlur = _e.onBlur, _f = _e.adapter, adapter = _f === void 0 ? dateFnsAdapter : _f, _g = _e.size, size = _g === void 0 ? getDefaultSize(theme) : _g, _h = _e.formatString, formatString = _h === void 0 ? DEFAULT_FORMAT_STRING : _h, _j = _e.isOpen, isOpen = _j === void 0 ? false : _j, onFocus = _e.onFocus, clearable = _e.clearable, _displayValueAtRangeIndex = _e.displayValueAtRangeIndex, _k = _e.variant, variant = _k === void 0 ? 'default' : _k, overrides = _e.overrides, intent = _e.intent, _value = _e.value, formatDisplayValue = _e.formatDisplayValue, _l = _e.autoSizeInput, autoSizeInput = _l === void 0 ? false : _l, weekStartsOn = _e.weekStartsOn, _m = _e.timezone, timezone = _m === void 0 ? getSystemTzName() : _m, _o = _e.showTimezone, showTimezone = _o === void 0 ? false : _o, timezoneOptions = _e.timezoneOptions, props = __rest(_e, ["onChange", "onBlur", "adapter", "size", "formatString", "isOpen", "onFocus", "clearable", "displayValueAtRangeIndex", "variant", "overrides", "intent", "value", "formatDisplayValue", "autoSizeInput", "weekStartsOn", "timezone", "showTimezone", "timezoneOptions"]);
30
30
  var locale = useLocale();
31
31
  var dateHelpers = React.useMemo(function () { return new DateHelpers(adapter); }, [adapter]);
32
32
  var dateFnsLocale = React.useMemo(function () { return prepareLocale(props.locale, { weekStartsOn: weekStartsOn }); }, [weekStartsOn, props.locale]);
@@ -41,8 +41,8 @@ export var StatelessDatePicker = function (_props) {
41
41
  }, [_value, timezone, timezoneOptions]);
42
42
  // this state is required for a11y of calendar, this will be set to true when user first press down arrow key on opened calendar
43
43
  // and we will set this to false when calendar will be closed.
44
- var _o = __read(React.useState(false), 2), autoFocusCalendar = _o[0], setAutoFocusCalendar = _o[1];
45
- var _p = __read(React.useState(false), 2), error = _p[0], setError = _p[1];
44
+ var _p = __read(React.useState(false), 2), autoFocusCalendar = _p[0], setAutoFocusCalendar = _p[1];
45
+ var _q = __read(React.useState(false), 2), error = _q[0], setError = _q[1];
46
46
  React.useEffect(function () {
47
47
  var _a = getMinMaxDateInTimezone({
48
48
  maxDate: props.maxDate,
@@ -58,7 +58,9 @@ export var StatelessDatePicker = function (_props) {
58
58
  }
59
59
  }, [value, props.minDate, props.maxDate, dateHelpers, timezone, timezoneOptions]);
60
60
  var screenReaderMsgId = useUniqueId();
61
- var _q = props["aria-describedby"], ariaDescribedBy = _q === void 0 ? "datepicker--screenreader--message--input-".concat(screenReaderMsgId) : _q;
61
+ var screenReaderMsgDescribedById = "datepicker--screenreader--message--input-".concat(screenReaderMsgId);
62
+ var baseAriaDescribedBy = (_a = props['aria-describedby']) !== null && _a !== void 0 ? _a : '';
63
+ var ariaDescribedBy = "".concat(screenReaderMsgDescribedById, " ").concat(baseAriaDescribedBy).trim();
62
64
  var defaultFormatDisplayValue = React.useCallback(function (date) {
63
65
  var normalizedFormatString = normalizeDashes(formatString);
64
66
  if (formatDisplayValue) {
@@ -137,10 +139,10 @@ export var StatelessDatePicker = function (_props) {
137
139
  var _r = __read(useOverrides(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.Input, DatePickerInput), 2), InputComponent = _r[0], inputProps = _r[1];
138
140
  var _s = __read(useOverrides(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.Popover, Popover), 2), PopoverComponent = _s[0], popoverProps = _s[1];
139
141
  var _t = __read(useOverrides(mergedOverrides === null || mergedOverrides === void 0 ? void 0 : mergedOverrides.InputWrapper, StyledInputWrapper), 2), InputWrapper = _t[0], inputWrapperProps = _t[1];
140
- var placeholder = (_a = props.placeholder) !== null && _a !== void 0 ? _a : formatString.toLowerCase();
142
+ var placeholder = (_b = props.placeholder) !== null && _b !== void 0 ? _b : formatString.toLowerCase();
141
143
  // if calendar is close, open it on click otherwise close the calendar
142
144
  var popoverHandleClick = isOpen ? onBlur : onFocus;
143
- return (_jsxs(_Fragment, { children: [_jsx(PopoverComponent, __assign({ accessibilityType: "none", focusLock: true, returnFocus: true, mountNode: props.mountNode, placement: PLACEMENT.auto, isOpen: isOpen, onClickOutside: onClose, onEsc: onClose, showArrow: false, triggerType: "click", onClick: props.disabled ? _noop : popoverHandleClick, content: _jsx(DatePickerContent, __assign({}, props, { value: value, onChange: handleDateChange, overrides: mergedOverrides, autoFocusCalendar: autoFocusCalendar, onClose: onClose, formatString: formatString, adapter: adapter, locale: dateFnsLocale, showTimezone: showTimezone, timezone: timezone, timezoneOptions: timezoneOptions, formatDisplayValue: defaultFormatDisplayValue })) }, popoverProps, { children: _jsx(InputWrapper, __assign({}, inputWrapperProps, { children: _jsx(InputComponent, __assign({ id: props.id, "aria-disabled": props.disabled, "aria-label": (_b = props['aria-label']) !== null && _b !== void 0 ? _b : locale.timeRangePicker.ariaLabel, "aria-describedby": ariaDescribedBy, "aria-labelledby": props['aria-labelledby'], "aria-invalid": props['aria-invalid'], "aria-errormessage": props['aria-errormessage'], "aria-required": (_c = props.required) !== null && _c !== void 0 ? _c : props['aria-required'], disabled: props.disabled, size: size, variant: variant, intent: error ? 'error' : intent, value: displayValue,
145
+ return (_jsxs(_Fragment, { children: [_jsx(PopoverComponent, __assign({ accessibilityType: "none", focusLock: true, returnFocus: true, mountNode: props.mountNode, placement: PLACEMENT.auto, isOpen: isOpen, onClickOutside: onClose, onEsc: onClose, showArrow: false, triggerType: "click", onClick: props.disabled ? _noop : popoverHandleClick, content: _jsx(DatePickerContent, __assign({}, props, { value: value, onChange: handleDateChange, overrides: mergedOverrides, autoFocusCalendar: autoFocusCalendar, onClose: onClose, formatString: formatString, adapter: adapter, locale: dateFnsLocale, showTimezone: showTimezone, timezone: timezone, timezoneOptions: timezoneOptions, formatDisplayValue: defaultFormatDisplayValue })) }, popoverProps, { children: _jsx(InputWrapper, __assign({}, inputWrapperProps, { children: _jsx(InputComponent, __assign({ id: props.id, "aria-disabled": props.disabled, "aria-label": (_c = props['aria-label']) !== null && _c !== void 0 ? _c : locale.timeRangePicker.ariaLabel, "aria-describedby": ariaDescribedBy, "aria-labelledby": props['aria-labelledby'], "aria-invalid": props['aria-invalid'], "aria-errormessage": props['aria-errormessage'], "aria-required": (_d = props.required) !== null && _d !== void 0 ? _d : props['aria-required'], disabled: props.disabled, size: size, variant: variant, intent: error ? 'error' : intent, value: displayValue,
144
146
  // onFocus={onFocus}
145
- onKeyDown: handleKeyDown, onChange: handleInputChange, placeholder: placeholder, required: props.required, clearable: clearable, isOpen: isOpen, autoSizeInput: autoSizeInput }, inputProps)) })) })), _jsxs(Box, __assign({ className: "relative" }, { children: [_jsx(Typography, __assign({ id: ariaDescribedBy, className: "sr-only" }, { children: locale.timeRangePicker.screenReaderMessageInput })), _jsx(Typography, __assign({ "aria-live": "assertive", className: "sr-only" }, { children: dateAriaLabel }))] }))] }));
147
+ onKeyDown: handleKeyDown, onChange: handleInputChange, placeholder: placeholder, required: props.required, clearable: clearable, isOpen: isOpen, autoSizeInput: autoSizeInput }, inputProps)) })) })), _jsxs(Box, __assign({ className: "relative" }, { children: [_jsx(Typography, __assign({ id: screenReaderMsgDescribedById, className: "sr-only" }, { children: locale.timeRangePicker.screenReaderMessageInput })), _jsx(Typography, __assign({ "aria-live": "assertive", className: "sr-only" }, { children: dateAriaLabel }))] }))] }));
146
148
  };
@@ -7,6 +7,7 @@ export declare const isValidHex: (hex: unknown) => string | undefined;
7
7
  */
8
8
  export declare function hexToRgb(_hex: string): RGBColor;
9
9
  export declare function RgbToHex({ r, g, b, a }: RGBColor): string;
10
+ export declare function normalizeHex(hex: string): string | undefined;
10
11
  /**
11
12
  * https://medium.muz.li/the-science-of-color-contrast-an-expert-designers-guide-33e84c41d156
12
13
  * https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum#dfn-contrast-ratio
@@ -7,7 +7,7 @@ export var isValidHex = function (hex) {
7
7
  if (![3, 4, 6, 8].includes(hexVal.length))
8
8
  return undefined;
9
9
  if (/^[0-9a-f]+$/i.test(hexVal))
10
- return hexVal;
10
+ return hexVal.toUpperCase();
11
11
  return undefined;
12
12
  };
13
13
  /**
@@ -30,6 +30,18 @@ export function RgbToHex(_a) {
30
30
  return "#".concat(__spreadArray([r, g, b], __read((a < 1 ? [Math.round(a * 255)] : [])), false).map(function (n) { return (Number.isNaN(n) ? 10 : Math.round(Math.min(Math.max(n, 0), 255))).toString(16).padStart(2, '0'); })
31
31
  .join(''));
32
32
  }
33
+ export function normalizeHex(hex) {
34
+ if (!isValidHex(hex))
35
+ return undefined;
36
+ var _a = hexToRgb(hex), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
37
+ return "#".concat([r, g, b, Math.round((a !== null && a !== void 0 ? a : 1) * 255)]
38
+ .map(function (n) {
39
+ return Math.round(Math.min(Math.max(n, 0), 255))
40
+ .toString(16)
41
+ .padStart(2, '0');
42
+ })
43
+ .join(''));
44
+ }
33
45
  /**
34
46
  * https://medium.muz.li/the-science-of-color-contrast-an-expert-designers-guide-33e84c41d156
35
47
  * https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum#dfn-contrast-ratio
@@ -86,7 +98,7 @@ export function noAlphaHex(inputHex) {
86
98
  return inputHex;
87
99
  }
88
100
  export function normalizeHexWithAlpha(hex, alpha) {
89
- if (typeof alpha !== 'number' || alpha === 1 || !hex)
101
+ if (typeof alpha !== 'number' || alpha === 1 || !hex || !isValidHex(hex))
90
102
  return hex;
91
103
  return (hex +
92
104
  Math.floor(alpha * 255)
@@ -17,7 +17,7 @@ import { getPopperOptions } from './utils';
17
17
  // @ts-ignore -- displayName is not typed in BasePopover
18
18
  BasePopover.displayName = 'BaseUIPopover';
19
19
  var Popover = React.forwardRef(function (_a, ref) {
20
- var overrides = _a.overrides, children = _a.children, _b = _a.placement, placement = _b === void 0 ? 'auto' : _b, accessibilityType = _a.accessibilityType, _c = _a.triggerType, triggerType = _c === void 0 ? 'click' : _c, _d = _a.showArrow, showArrow = _d === void 0 ? false : _d, targetElement = _a.targetElement, isOpen = _a.isOpen, _e = _a.focusLock, focusLock = _e === void 0 ? false : _e, _f = _a.returnFocus, returnFocus = _f === void 0 ? triggerType === 'click' : _f, popperOptions = _a.popperOptions, ignoreBoundary = _a.ignoreBoundary, _g = _a.viewportAsBoundary, viewportAsBoundary = _g === void 0 ? true : _g, restProps = __rest(_a, ["overrides", "children", "placement", "accessibilityType", "triggerType", "showArrow", "targetElement", "isOpen", "focusLock", "returnFocus", "popperOptions", "ignoreBoundary", "viewportAsBoundary"]);
20
+ var overrides = _a.overrides, children = _a.children, _b = _a.placement, placement = _b === void 0 ? 'auto' : _b, accessibilityType = _a.accessibilityType, _c = _a.triggerType, triggerType = _c === void 0 ? 'click' : _c, _d = _a.showArrow, showArrow = _d === void 0 ? false : _d, targetElement = _a.targetElement, isOpen = _a.isOpen, _e = _a.focusLock, focusLock = _e === void 0 ? false : _e, _f = _a.returnFocus, returnFocus = _f === void 0 ? triggerType === 'click' : _f, popperOptions = _a.popperOptions, ignoreBoundary = _a.ignoreBoundary, _g = _a.viewportAsBoundary, viewportAsBoundary = _g === void 0 ? true : _g, hideWhenTargetClipped = _a.hideWhenTargetClipped, restProps = __rest(_a, ["overrides", "children", "placement", "accessibilityType", "triggerType", "showArrow", "targetElement", "isOpen", "focusLock", "returnFocus", "popperOptions", "ignoreBoundary", "viewportAsBoundary", "hideWhenTargetClipped"]);
21
21
  var _h = useStyle(), isRTL = _h.isRTL, theme = _h.theme;
22
22
  var focusLockProps = useFocusLock({ returnFocus: returnFocus, focusLock: focusLock });
23
23
  var _j = __read(useOverrides(overrides === null || overrides === void 0 ? void 0 : overrides.ArrowTriangle, StyledArrowTriangle), 2), ArrowTriangle = _j[0], arrowTriangleProps = _j[1];
@@ -57,7 +57,7 @@ var Popover = React.forwardRef(function (_a, ref) {
57
57
  }
58
58
  var id = useUniqueId();
59
59
  var mergedPopperOptions = useMemo(function () { return (__assign(__assign({}, getPopperOptions({ ignoreBoundary: ignoreBoundary, viewportAsBoundary: viewportAsBoundary })), popperOptions)); }, [popperOptions, ignoreBoundary, viewportAsBoundary]);
60
- return (_jsx(Layer, __assign({ zIndex: Z_INDEX.POPOVER }, layerProps, { children: _jsx(BasePopover, __assign({ id: id }, restProps, mappedProps, { showArrow: showArrow, isOpen: isOpen, overrides: _overrides, innerRef: combinedRef }, focusLockProps, { popperOptions: mergedPopperOptions }, { children: _jsx(PopoverChildEnhancer, __assign({ targetElement: targetElement }, { children: childNode }), "CheckCompliance<Popover>") })) })));
60
+ return (_jsx(Layer, __assign({ zIndex: Z_INDEX.POPOVER }, layerProps, { children: _jsx(BasePopover, __assign({ id: id }, restProps, mappedProps, { showArrow: showArrow, isOpen: isOpen, overrides: _overrides, innerRef: combinedRef }, focusLockProps, { hideWhenTargetClipped: hideWhenTargetClipped, popperOptions: mergedPopperOptions }, { children: _jsx(PopoverChildEnhancer, __assign({ targetElement: targetElement }, { children: childNode }), "CheckCompliance<Popover>") })) })));
61
61
  });
62
62
  Popover.displayName = 'Popover';
63
63
  Popover.__standard = 'Component<Popover>';
@@ -16,6 +16,7 @@ declare const DisabledTooltipContainer: {
16
16
  popperOptions?: any;
17
17
  repositionOnResize?: boolean | undefined;
18
18
  positionFixed?: boolean | undefined;
19
+ hideWhenTargetClipped?: boolean | undefined;
19
20
  accessibilityType?: "none" | "menu" | "tooltip" | undefined;
20
21
  animateOutTime?: number | undefined;
21
22
  'data-baseweb'?: string | undefined;
@@ -16,6 +16,7 @@ declare const StatefulContainer: {
16
16
  popperOptions?: any;
17
17
  repositionOnResize?: boolean | undefined;
18
18
  positionFixed?: boolean | undefined;
19
+ hideWhenTargetClipped?: boolean | undefined;
19
20
  accessibilityType?: "none" | "menu" | "tooltip" | undefined;
20
21
  animateOutTime?: number | undefined;
21
22
  'data-baseweb'?: string | undefined;
@@ -19,6 +19,7 @@ declare const StatefulTooltip: {
19
19
  popperOptions?: any;
20
20
  repositionOnResize?: boolean | undefined;
21
21
  positionFixed?: boolean | undefined;
22
+ hideWhenTargetClipped?: boolean | undefined;
22
23
  accessibilityType?: "none" | "menu" | "tooltip" | undefined;
23
24
  animateOutTime?: number | undefined;
24
25
  'data-baseweb'?: string | undefined;
@@ -7,6 +7,7 @@ export declare const isValidHex: (hex: unknown) => string | undefined;
7
7
  */
8
8
  export declare function hexToRgb(_hex: string): RGBColor;
9
9
  export declare function RgbToHex({ r, g, b, a }: RGBColor): string;
10
+ export declare function normalizeHex(hex: string): string | undefined;
10
11
  /**
11
12
  * https://medium.muz.li/the-science-of-color-contrast-an-expert-designers-guide-33e84c41d156
12
13
  * https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum#dfn-contrast-ratio
package/helpers/colors.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeHexWithAlpha = exports.noAlphaHex = exports.HslToRgb = exports.RgbToHsl = exports.getContrastRatio = exports.getRelativeLuminance = exports.RgbToHex = exports.hexToRgb = exports.isValidHex = void 0;
3
+ exports.normalizeHexWithAlpha = exports.noAlphaHex = exports.HslToRgb = exports.RgbToHsl = exports.getContrastRatio = exports.getRelativeLuminance = exports.normalizeHex = exports.RgbToHex = exports.hexToRgb = exports.isValidHex = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var memoize_1 = tslib_1.__importDefault(require("lodash/memoize"));
6
6
  var isValidHex = function (hex) {
@@ -10,7 +10,7 @@ var isValidHex = function (hex) {
10
10
  if (![3, 4, 6, 8].includes(hexVal.length))
11
11
  return undefined;
12
12
  if (/^[0-9a-f]+$/i.test(hexVal))
13
- return hexVal;
13
+ return hexVal.toUpperCase();
14
14
  return undefined;
15
15
  };
16
16
  exports.isValidHex = isValidHex;
@@ -36,6 +36,19 @@ function RgbToHex(_a) {
36
36
  .join(''));
37
37
  }
38
38
  exports.RgbToHex = RgbToHex;
39
+ function normalizeHex(hex) {
40
+ if (!(0, exports.isValidHex)(hex))
41
+ return undefined;
42
+ var _a = hexToRgb(hex), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
43
+ return "#".concat([r, g, b, Math.round((a !== null && a !== void 0 ? a : 1) * 255)]
44
+ .map(function (n) {
45
+ return Math.round(Math.min(Math.max(n, 0), 255))
46
+ .toString(16)
47
+ .padStart(2, '0');
48
+ })
49
+ .join(''));
50
+ }
51
+ exports.normalizeHex = normalizeHex;
39
52
  /**
40
53
  * https://medium.muz.li/the-science-of-color-contrast-an-expert-designers-guide-33e84c41d156
41
54
  * https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum#dfn-contrast-ratio
@@ -96,7 +109,7 @@ function noAlphaHex(inputHex) {
96
109
  }
97
110
  exports.noAlphaHex = noAlphaHex;
98
111
  function normalizeHexWithAlpha(hex, alpha) {
99
- if (typeof alpha !== 'number' || alpha === 1 || !hex)
112
+ if (typeof alpha !== 'number' || alpha === 1 || !hex || !(0, exports.isValidHex)(hex))
100
113
  return hex;
101
114
  return (hex +
102
115
  Math.floor(alpha * 255)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprinklrjs/spaceweb",
3
- "version": "14.14.1",
3
+ "version": "14.14.3",
4
4
  "description": "Components for SpaceWeb",
5
5
  "main": "index.js",
6
6
  "module": "./esm/index.js",
@@ -101,7 +101,7 @@
101
101
  "ts-node": "^10.4.0"
102
102
  },
103
103
  "peerDependencies": {
104
- "@sprinklrjs/spaceweb-themes": "14.14.1",
104
+ "@sprinklrjs/spaceweb-themes": "14.14.3",
105
105
  "react": ">=17.0.2 <19.0.0",
106
106
  "react-dom": ">=17.0.2 <19.0.0"
107
107
  }
@@ -19,7 +19,7 @@ var utils_1 = require("./utils");
19
19
  // @ts-ignore -- displayName is not typed in BasePopover
20
20
  popover_1.Popover.displayName = 'BaseUIPopover';
21
21
  var Popover = React.forwardRef(function (_a, ref) {
22
- var overrides = _a.overrides, children = _a.children, _b = _a.placement, placement = _b === void 0 ? 'auto' : _b, accessibilityType = _a.accessibilityType, _c = _a.triggerType, triggerType = _c === void 0 ? 'click' : _c, _d = _a.showArrow, showArrow = _d === void 0 ? false : _d, targetElement = _a.targetElement, isOpen = _a.isOpen, _e = _a.focusLock, focusLock = _e === void 0 ? false : _e, _f = _a.returnFocus, returnFocus = _f === void 0 ? triggerType === 'click' : _f, popperOptions = _a.popperOptions, ignoreBoundary = _a.ignoreBoundary, _g = _a.viewportAsBoundary, viewportAsBoundary = _g === void 0 ? true : _g, restProps = tslib_1.__rest(_a, ["overrides", "children", "placement", "accessibilityType", "triggerType", "showArrow", "targetElement", "isOpen", "focusLock", "returnFocus", "popperOptions", "ignoreBoundary", "viewportAsBoundary"]);
22
+ var overrides = _a.overrides, children = _a.children, _b = _a.placement, placement = _b === void 0 ? 'auto' : _b, accessibilityType = _a.accessibilityType, _c = _a.triggerType, triggerType = _c === void 0 ? 'click' : _c, _d = _a.showArrow, showArrow = _d === void 0 ? false : _d, targetElement = _a.targetElement, isOpen = _a.isOpen, _e = _a.focusLock, focusLock = _e === void 0 ? false : _e, _f = _a.returnFocus, returnFocus = _f === void 0 ? triggerType === 'click' : _f, popperOptions = _a.popperOptions, ignoreBoundary = _a.ignoreBoundary, _g = _a.viewportAsBoundary, viewportAsBoundary = _g === void 0 ? true : _g, hideWhenTargetClipped = _a.hideWhenTargetClipped, restProps = tslib_1.__rest(_a, ["overrides", "children", "placement", "accessibilityType", "triggerType", "showArrow", "targetElement", "isOpen", "focusLock", "returnFocus", "popperOptions", "ignoreBoundary", "viewportAsBoundary", "hideWhenTargetClipped"]);
23
23
  var _h = (0, style_1.useStyle)(), isRTL = _h.isRTL, theme = _h.theme;
24
24
  var focusLockProps = (0, hooks_1.useFocusLock)({ returnFocus: returnFocus, focusLock: focusLock });
25
25
  var _j = tslib_1.__read((0, overrides_1.useOverrides)(overrides === null || overrides === void 0 ? void 0 : overrides.ArrowTriangle, styled_components_1.StyledArrowTriangle), 2), ArrowTriangle = _j[0], arrowTriangleProps = _j[1];
@@ -59,7 +59,7 @@ var Popover = React.forwardRef(function (_a, ref) {
59
59
  }
60
60
  var id = (0, useUniqueId_1.default)();
61
61
  var mergedPopperOptions = (0, react_1.useMemo)(function () { return (tslib_1.__assign(tslib_1.__assign({}, (0, utils_1.getPopperOptions)({ ignoreBoundary: ignoreBoundary, viewportAsBoundary: viewportAsBoundary })), popperOptions)); }, [popperOptions, ignoreBoundary, viewportAsBoundary]);
62
- return ((0, jsx_runtime_1.jsx)(Layer, tslib_1.__assign({ zIndex: layer_1.Z_INDEX.POPOVER }, layerProps, { children: (0, jsx_runtime_1.jsx)(popover_1.Popover, tslib_1.__assign({ id: id }, restProps, mappedProps, { showArrow: showArrow, isOpen: isOpen, overrides: _overrides, innerRef: combinedRef }, focusLockProps, { popperOptions: mergedPopperOptions }, { children: (0, jsx_runtime_1.jsx)(PopoverEnhancer_1.PopoverChildEnhancer, tslib_1.__assign({ targetElement: targetElement }, { children: childNode }), "CheckCompliance<Popover>") })) })));
62
+ return ((0, jsx_runtime_1.jsx)(Layer, tslib_1.__assign({ zIndex: layer_1.Z_INDEX.POPOVER }, layerProps, { children: (0, jsx_runtime_1.jsx)(popover_1.Popover, tslib_1.__assign({ id: id }, restProps, mappedProps, { showArrow: showArrow, isOpen: isOpen, overrides: _overrides, innerRef: combinedRef }, focusLockProps, { hideWhenTargetClipped: hideWhenTargetClipped, popperOptions: mergedPopperOptions }, { children: (0, jsx_runtime_1.jsx)(PopoverEnhancer_1.PopoverChildEnhancer, tslib_1.__assign({ targetElement: targetElement }, { children: childNode }), "CheckCompliance<Popover>") })) })));
63
63
  });
64
64
  Popover.displayName = 'Popover';
65
65
  Popover.__standard = 'Component<Popover>';
@@ -16,6 +16,7 @@ declare const DisabledTooltipContainer: {
16
16
  popperOptions?: any;
17
17
  repositionOnResize?: boolean | undefined;
18
18
  positionFixed?: boolean | undefined;
19
+ hideWhenTargetClipped?: boolean | undefined;
19
20
  accessibilityType?: "none" | "menu" | "tooltip" | undefined;
20
21
  animateOutTime?: number | undefined;
21
22
  'data-baseweb'?: string | undefined;
@@ -16,6 +16,7 @@ declare const StatefulContainer: {
16
16
  popperOptions?: any;
17
17
  repositionOnResize?: boolean | undefined;
18
18
  positionFixed?: boolean | undefined;
19
+ hideWhenTargetClipped?: boolean | undefined;
19
20
  accessibilityType?: "none" | "menu" | "tooltip" | undefined;
20
21
  animateOutTime?: number | undefined;
21
22
  'data-baseweb'?: string | undefined;
@@ -19,6 +19,7 @@ declare const StatefulTooltip: {
19
19
  popperOptions?: any;
20
20
  repositionOnResize?: boolean | undefined;
21
21
  positionFixed?: boolean | undefined;
22
+ hideWhenTargetClipped?: boolean | undefined;
22
23
  accessibilityType?: "none" | "menu" | "tooltip" | undefined;
23
24
  animateOutTime?: number | undefined;
24
25
  'data-baseweb'?: string | undefined;