draft-components 2.2.0 → 2.3.1

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.
@@ -749,6 +749,7 @@
749
749
  transition-duration: 0.2s;
750
750
  transition-property: color, background-color;
751
751
  text-align: center;
752
+ white-space: nowrap;
752
753
  text-decoration: none;
753
754
  text-transform: none;
754
755
  border: 1px solid var(--dc-button-border-color);
@@ -2467,6 +2468,7 @@
2467
2468
  color-scheme: light;
2468
2469
  font: 14px/1 var(--dc-primary-font);
2469
2470
  display: inline-flex;
2471
+ flex-shrink: 0;
2470
2472
  margin: 0;
2471
2473
  padding: 0;
2472
2474
  list-style: none;
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { MouseEventHandler, ReactNode } from 'react';
2
2
  import { TextInputProps } from '../text-input/index.js';
3
3
  export type PasswordInputBaseProps = Omit<TextInputProps, 'type' | 'slotRight'>;
4
4
  export type PasswordInputProps = {
@@ -6,5 +6,6 @@ export type PasswordInputProps = {
6
6
  defaultVisible?: boolean;
7
7
  getTooltipText?: (visible: boolean) => ReactNode;
8
8
  renderToggleButtonIcon?: (visible: boolean) => ReactNode;
9
+ onClickToggleButton?: MouseEventHandler<HTMLButtonElement>;
9
10
  } & PasswordInputBaseProps;
10
11
  export declare const PasswordInput: import("react").ForwardRefExoticComponent<Omit<PasswordInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
@@ -12,9 +12,15 @@ const getDefaultTooltipText = (visible) => (visible
12
12
  const renderToggleButtonDefaultIcon = (visible) => (visible
13
13
  ? _jsx(EyeIcon, { width: "1.25em", height: "1.25em" })
14
14
  : _jsx(EyeSlashIcon, { width: "1.25em", height: "1.25em" }));
15
- export const PasswordInput = forwardRef(function PasswordInput({ className, loading = false, defaultVisible = false, getTooltipText = getDefaultTooltipText, renderToggleButtonIcon = renderToggleButtonDefaultIcon, ...props }, ref) {
15
+ export const PasswordInput = forwardRef(function PasswordInput({ className, loading = false, defaultVisible = false, getTooltipText = getDefaultTooltipText, renderToggleButtonIcon = renderToggleButtonDefaultIcon, onClickToggleButton, ...props }, ref) {
16
16
  const [visible, setVisible] = useState(defaultVisible);
17
- return (_jsx(TextInput, { ...props, ref: ref, className: classNames('dc-password-input', className), type: visible ? 'text' : 'password', readOnly: loading ?? props.readOnly, slotRight: () => (_jsx(Tooltip, { content: getTooltipText(visible), children: _jsx("button", { className: "dc-password-input__toggle-button", type: "button", disabled: loading, onClick: () => setVisible(!visible), children: loading
17
+ const handleClickToggleButton = (event) => {
18
+ setVisible(!visible);
19
+ if (typeof onClickToggleButton === 'function') {
20
+ onClickToggleButton(event);
21
+ }
22
+ };
23
+ return (_jsx(TextInput, { ...props, ref: ref, className: classNames('dc-password-input', className), type: visible ? 'text' : 'password', readOnly: loading ?? props.readOnly, slotRight: () => (_jsx(Tooltip, { content: getTooltipText(visible), children: _jsx("button", { className: "dc-password-input__toggle-button", type: "button", disabled: loading, onClick: handleClickToggleButton, children: loading
18
24
  ? _jsx(Spinner, { width: "1.15em" })
19
25
  : renderToggleButtonIcon(visible) }) })) }));
20
26
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "draft-components",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "The React based UI components library.",
5
5
  "type": "module",
6
6
  "exports": {