@vectara/vectara-ui 15.6.2 → 15.7.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.
@@ -5,4 +5,5 @@ export declare const VuiNumberInput: import("react").ForwardRefExoticComponent<O
5
5
  max?: number | undefined;
6
6
  min?: number | undefined;
7
7
  step?: number | undefined;
8
+ allowUndefined?: boolean | undefined;
8
9
  } & import("react").RefAttributes<HTMLInputElement | null>>;
@@ -13,7 +13,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { forwardRef, useEffect, useState } from "react";
14
14
  import { VuiBasicInput } from "./BasicInput";
15
15
  export const VuiNumberInput = forwardRef((_a, ref) => {
16
- var { value, onChange, max, min, step } = _a, rest = __rest(_a, ["value", "onChange", "max", "min", "step"]);
16
+ var { value, onChange, max, min, step, allowUndefined } = _a, rest = __rest(_a, ["value", "onChange", "max", "min", "step", "allowUndefined"]);
17
17
  const [localValue, setLocalValue] = useState(value);
18
18
  // This is a hacky solution to the number input misbehaving on Firefox.
19
19
  // If we were to apply the value and onChange values directly to the
@@ -26,17 +26,21 @@ export const VuiNumberInput = forwardRef((_a, ref) => {
26
26
  // For some reason, using a useState hook to store the value doesn't have
27
27
  // this problem.
28
28
  useEffect(() => {
29
- // Reflect the upstream value when it changes. Ignore 0
30
- // because that indicates the user has entered a decimal point.
31
- if (value !== 0) {
29
+ // Reflect the upstream value when it changes. Ignore 0 because that
30
+ // indicates the user has entered a decimal point (Firefox workaround).
31
+ // When allowUndefined is on, also ignore undefined — otherwise the
32
+ // parent reflecting undefined back would clear the input mid-typing.
33
+ const isUndefined = !(allowUndefined && value === undefined);
34
+ if (value !== 0 && isUndefined) {
32
35
  setLocalValue(value);
33
36
  }
34
37
  }, [value]);
35
- // Part of the hacky solution above.
38
+ // Propagate localValue changes upstream. Without allowUndefined, an
39
+ // undefined localValue (empty input) is coerced to 0 so existing
40
+ // consumers always receive a number. With allowUndefined, undefined
41
+ // passes through so consumers can treat empty as "no value."
36
42
  useEffect(() => {
37
- // Set value locally so an undefined value doesn't reset it to 0.
38
- // Pass the value upstream, e.g. so it can be persisted.
39
- onChange(localValue !== null && localValue !== void 0 ? localValue : 0);
43
+ onChange(allowUndefined ? localValue : localValue !== null && localValue !== void 0 ? localValue : 0);
40
44
  }, [localValue]);
41
45
  const onChangeValue = (e) => {
42
46
  // Enable resetting the value to undefined.
@@ -45,10 +45,10 @@ export const VuiModal = (_a) => {
45
45
  }, 0);
46
46
  };
47
47
  const classes = classNames("vuiModal", `vuiModal--${color}`, `vuiModal--${size}`, className);
48
- return (_jsx(VuiPortal, { children: isOpen && (_jsx(VuiScreenBlock, { children: _jsx(FocusOn, Object.assign({ onEscapeKey: onCloseDelayed, onClickOutside: canClickOutsideToClose ? onCloseDelayed : undefined,
48
+ return (_jsx(VuiPortal, { children: isOpen && (_jsx(VuiScreenBlock, Object.assign({ type: "modal" }, { children: _jsx(FocusOn, Object.assign({ onEscapeKey: onCloseDelayed, onClickOutside: canClickOutsideToClose ? onCloseDelayed : undefined,
49
49
  // Enable manual focus return to work.
50
50
  returnFocus: false,
51
51
  // Enable focus on contents when it's open,
52
52
  // but enable manual focus return to work when it's closed.
53
- autoFocus: isOpen }, { children: _jsx("div", Object.assign({ className: "vuiModalContainer" }, getOverlayProps("modalTitle"), { children: _jsxs("div", Object.assign({ className: classes }, rest, { children: [_jsx("div", Object.assign({ className: "vuiModalHeader" }, { children: _jsxs(VuiFlexContainer, Object.assign({ justifyContent: "spaceBetween", alignItems: "center" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xs" }, { children: [icon && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "l" }, { children: icon })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx("div", Object.assign({ className: "vuiModalHeader__title" }, { children: _jsx(DrawerTitle, Object.assign({ id: "modalTitle" }, { children: title })) })) }))] })) })), onClose && (_jsx(VuiFlexItem, { children: _jsx(VuiIconButton, { "aria-label": "Close", "data-testid": "modalCloseButton", onClick: onCloseDelayed, color: "neutral", icon: _jsx(VuiIcon, Object.assign({ size: "m", color: "neutral" }, { children: _jsx(BiX, {}) })) }) }))] })) })), _jsx("div", Object.assign({ className: "vuiModalContent" }, { children: _jsx("div", Object.assign({ className: "vuiModalContent__inner" }, { children: children })) }))] })) })) })) }, key)) }));
53
+ autoFocus: isOpen }, { children: _jsx("div", Object.assign({ className: "vuiModalContainer" }, getOverlayProps("modalTitle"), { children: _jsxs("div", Object.assign({ className: classes }, rest, { children: [_jsx("div", Object.assign({ className: "vuiModalHeader" }, { children: _jsxs(VuiFlexContainer, Object.assign({ justifyContent: "spaceBetween", alignItems: "center" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xs" }, { children: [icon && (_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: false }, { children: _jsx(VuiIcon, Object.assign({ size: "l" }, { children: icon })) }))), _jsx(VuiFlexItem, Object.assign({ grow: false }, { children: _jsx("div", Object.assign({ className: "vuiModalHeader__title" }, { children: _jsx(DrawerTitle, Object.assign({ id: "modalTitle" }, { children: title })) })) }))] })) })), onClose && (_jsx(VuiFlexItem, { children: _jsx(VuiIconButton, { "aria-label": "Close", "data-testid": "modalCloseButton", onClick: onCloseDelayed, color: "neutral", icon: _jsx(VuiIcon, Object.assign({ size: "m", color: "neutral" }, { children: _jsx(BiX, {}) })) }) }))] })) })), _jsx("div", Object.assign({ className: "vuiModalContent" }, { children: _jsx("div", Object.assign({ className: "vuiModalContent__inner" }, { children: children })) }))] })) })) })) }), key)) }));
54
54
  };
@@ -2,6 +2,7 @@ type Props = {
2
2
  onClick?: () => void;
3
3
  children: React.ReactNode;
4
4
  color?: "neutral" | "primary" | "danger" | "success";
5
+ type?: "default" | "modal";
5
6
  };
6
- export declare const VuiScreenBlock: ({ onClick, children, color }: Props) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const VuiScreenBlock: ({ onClick, children, color, type }: Props) => import("react/jsx-runtime").JSX.Element;
7
8
  export {};
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import classNames from "classnames";
3
- export const VuiScreenBlock = ({ onClick, children, color = "neutral" }) => {
4
- const classes = classNames("vuiScreenBlock", `vuiScreenBlock--${color}`);
3
+ export const VuiScreenBlock = ({ onClick, children, color = "neutral", type = "default" }) => {
4
+ const classes = classNames("vuiScreenBlock", `vuiScreenBlock--${color}`, `vuiScreenBlock--${type}`);
5
5
  return (_jsxs("div", Object.assign({ className: classes }, { children: [children, _jsx("div", { className: "vuiScreenBlock__mask", onClick: onClick })] })));
6
6
  };
@@ -4,12 +4,19 @@
4
4
  left: 0;
5
5
  right: 0;
6
6
  bottom: 0;
7
- z-index: $screenBlockZIndex;
8
7
  display: flex;
9
8
  align-items: center;
10
9
  justify-content: center;
11
10
  }
12
11
 
12
+ .vuiScreenBlock--default {
13
+ z-index: $screenBlockZIndex;
14
+ }
15
+
16
+ .vuiScreenBlock--modal {
17
+ z-index: $modalZIndex;
18
+ }
19
+
13
20
  .vuiScreenBlock__mask {
14
21
  width: 100%;
15
22
  height: 100%;
@@ -4493,12 +4493,19 @@ h2.react-datepicker__current-month {
4493
4493
  left: 0;
4494
4494
  right: 0;
4495
4495
  bottom: 0;
4496
- z-index: 10;
4497
4496
  display: flex;
4498
4497
  align-items: center;
4499
4498
  justify-content: center;
4500
4499
  }
4501
4500
 
4501
+ .vuiScreenBlock--default {
4502
+ z-index: 10;
4503
+ }
4504
+
4505
+ .vuiScreenBlock--modal {
4506
+ z-index: 12;
4507
+ }
4508
+
4502
4509
  .vuiScreenBlock__mask {
4503
4510
  width: 100%;
4504
4511
  height: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectara/vectara-ui",
3
- "version": "15.6.2",
3
+ "version": "15.7.0",
4
4
  "homepage": "./",
5
5
  "description": "Vectara's design system, codified as a React and Sass component library",
6
6
  "author": "Vectara",