@aurora-ds/components 0.24.6 → 0.24.8

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.
@@ -1,9 +1,13 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import { CSSProperties, FocusEvent, ReactNode } from 'react';
2
2
  export type InputProps = {
3
3
  /** The value of the input */
4
4
  value: string;
5
5
  /** Callback fired when the value changes */
6
6
  onChange: (value: string) => void;
7
+ /** Callback fired when the input receives focus */
8
+ onFocus?: (event: FocusEvent<HTMLInputElement>) => void;
9
+ /** Callback fired when the input loses focus */
10
+ onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
7
11
  /** Label displayed above the input */
8
12
  label?: string;
9
13
  /** Whether the field is mandatory (displays an asterisk next to the label) */
@@ -1,9 +1,13 @@
1
- import { CSSProperties } from 'react';
1
+ import { CSSProperties, FocusEvent } from 'react';
2
2
  export type TextAreaProps = {
3
3
  /** The value of the textarea */
4
4
  value: string;
5
5
  /** Callback fired when the value changes */
6
6
  onChange: (value: string) => void;
7
+ /** Callback fired when the textarea receives focus */
8
+ onFocus?: (event: FocusEvent<HTMLTextAreaElement>) => void;
9
+ /** Callback fired when the textarea loses focus */
10
+ onBlur?: (event: FocusEvent<HTMLTextAreaElement>) => void;
7
11
  /** Label displayed above the textarea */
8
12
  label?: string;
9
13
  /** Whether the field is mandatory (displays an asterisk next to the label) */
@@ -6,4 +6,9 @@ export type MenuProps = {
6
6
  children: ReactNode;
7
7
  anchorOrigin?: AnchorOrigin;
8
8
  width?: CSSProperties['width'];
9
+ /**
10
+ * Désactive l'animation/transition d'apparition du menu
11
+ * @default false
12
+ */
13
+ disableAnimation?: boolean;
9
14
  };
@@ -1,4 +1,13 @@
1
+ import { CSSProperties } from 'react';
1
2
  import { AnchorOrigin, AnchorPosition } from '@hooks/useAnchorPosition.types';
3
+ type MenuStyleParams = {
4
+ isFadingIn: boolean;
5
+ anchorOrigin: AnchorOrigin;
6
+ position: AnchorPosition;
7
+ width?: CSSProperties['width'];
8
+ disableAnimation?: boolean;
9
+ };
2
10
  export declare const MENU_STYLES: {
3
- root: (isFadingIn: boolean, anchorOrigin: AnchorOrigin, position: AnchorPosition, width?: import("csstype").Property.Width<string | number> | undefined) => string;
11
+ root: (args_0: MenuStyleParams) => string;
4
12
  };
13
+ export {};
package/dist/cjs/index.js CHANGED
@@ -1218,14 +1218,14 @@ const UploadIcon = () => (jsxRuntime.jsxs("svg", { xmlns: 'http://www.w3.org/200
1218
1218
  /**
1219
1219
  * Input component
1220
1220
  */
1221
- const Input = React.forwardRef(({ value, onChange, label, mandatory = false, placeholder, disabled = false, type = 'text', ariaLabel, startIcon, endIcon, width, }, ref) => {
1221
+ const Input = React.forwardRef(({ value, onChange, onFocus, onBlur, label, mandatory = false, placeholder, disabled = false, type = 'text', ariaLabel, startIcon, endIcon, width, }, ref) => {
1222
1222
  const [showPassword, setShowPassword] = React.useState(false);
1223
1223
  const handleChange = (event) => {
1224
1224
  onChange(event.target.value);
1225
1225
  };
1226
1226
  const inputType = type === 'password' ? (showPassword ? 'text' : 'password') : type;
1227
1227
  const hasPasswordToggle = type === 'password';
1228
- return (jsxRuntime.jsxs(Stack, { direction: 'column', gap: 'xs', align: 'stretch', width: width ?? '100%', children: [label && (jsxRuntime.jsxs(Stack, { direction: 'row', gap: 'xs', align: 'center', children: [jsxRuntime.jsx(Text, { variant: 'label', fontSize: 'sm', children: label }), mandatory && (jsxRuntime.jsx(Text, { variant: 'label', fontSize: 'sm', color: 'error', children: "*" }))] })), jsxRuntime.jsxs("div", { className: `${INPUT_STYLES.container({ width })} ${disabled ? 'disabled' : ''}`, children: [jsxRuntime.jsx("input", { ref: ref, type: inputType, value: value, onChange: handleChange, placeholder: placeholder, disabled: disabled, className: INPUT_STYLES.root({ disabled, hasStartIcon: !!startIcon, hasEndIcon: !!endIcon, hasPasswordToggle }), "aria-label": ariaLabel || label }), startIcon && (jsxRuntime.jsx("div", { className: INPUT_STYLES.startIcon, children: jsxRuntime.jsx(Icon, { color: 'textTertiary', children: startIcon }) })), endIcon && (jsxRuntime.jsx("div", { className: hasPasswordToggle ? INPUT_STYLES.endIconShifted : INPUT_STYLES.endIcon, children: jsxRuntime.jsx(Icon, { color: 'textTertiary', children: endIcon }) })), hasPasswordToggle && (jsxRuntime.jsx("div", { className: INPUT_STYLES.passwordToggle, children: jsxRuntime.jsx(IconButton, { icon: showPassword ? jsxRuntime.jsx(EyeOffIcon, {}) : jsxRuntime.jsx(EyeIcon, {}), onClick: () => setShowPassword(!showPassword), disabled: disabled, ariaLabel: ariaLabel || label, variant: 'text', size: 'small', textColor: 'textSecondary' }) }))] })] }));
1228
+ return (jsxRuntime.jsxs(Stack, { direction: 'column', gap: 'xs', align: 'stretch', width: width ?? '100%', children: [label && (jsxRuntime.jsxs(Stack, { direction: 'row', gap: 'xs', align: 'center', children: [jsxRuntime.jsx(Text, { variant: 'label', fontSize: 'sm', children: label }), mandatory && (jsxRuntime.jsx(Text, { variant: 'label', fontSize: 'sm', color: 'error', children: "*" }))] })), jsxRuntime.jsxs("div", { className: `${INPUT_STYLES.container({ width })} ${disabled ? 'disabled' : ''}`, children: [jsxRuntime.jsx("input", { ref: ref, type: inputType, value: value, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, placeholder: placeholder, disabled: disabled, className: INPUT_STYLES.root({ disabled, hasStartIcon: !!startIcon, hasEndIcon: !!endIcon, hasPasswordToggle }), "aria-label": ariaLabel || label }), startIcon && (jsxRuntime.jsx("div", { className: INPUT_STYLES.startIcon, children: jsxRuntime.jsx(Icon, { color: 'textTertiary', children: startIcon }) })), endIcon && (jsxRuntime.jsx("div", { className: hasPasswordToggle ? INPUT_STYLES.endIconShifted : INPUT_STYLES.endIcon, children: jsxRuntime.jsx(Icon, { color: 'textTertiary', children: endIcon }) })), hasPasswordToggle && (jsxRuntime.jsx("div", { className: INPUT_STYLES.passwordToggle, children: jsxRuntime.jsx(IconButton, { icon: showPassword ? jsxRuntime.jsx(EyeOffIcon, {}) : jsxRuntime.jsx(EyeIcon, {}), onClick: () => setShowPassword(!showPassword), disabled: disabled, ariaLabel: ariaLabel || label, variant: 'text', size: 'small', textColor: 'textSecondary' }) }))] })] }));
1229
1229
  });
1230
1230
  Input.displayName = 'Input';
1231
1231
  var Input_default = React.memo(Input);
@@ -1278,7 +1278,7 @@ const TEXTAREA_STYLES = theme.createStyles((theme) => ({
1278
1278
  /**
1279
1279
  * TextArea component with auto-expanding height based on content
1280
1280
  */
1281
- const TextArea = React.forwardRef(({ value, onChange, label, mandatory = false, placeholder, disabled = false, ariaLabel, width, minRows = 3, maxRows, }, ref) => {
1281
+ const TextArea = React.forwardRef(({ value, onChange, onFocus, onBlur, label, mandatory = false, placeholder, disabled = false, ariaLabel, width, minRows = 3, maxRows, }, ref) => {
1282
1282
  const internalRef = React.useRef(null);
1283
1283
  const textareaRef = ref || internalRef;
1284
1284
  const adjustHeight = React.useCallback(() => {
@@ -1303,7 +1303,7 @@ const TextArea = React.forwardRef(({ value, onChange, label, mandatory = false,
1303
1303
  const handleChange = (event) => {
1304
1304
  onChange(event.target.value);
1305
1305
  };
1306
- return (jsxRuntime.jsxs(Stack, { direction: 'column', gap: 'xs', align: 'stretch', width: width ?? '100%', children: [label && (jsxRuntime.jsxs(Stack, { direction: 'row', gap: 'xs', align: 'center', children: [jsxRuntime.jsx(Text, { variant: 'label', fontSize: 'sm', children: label }), mandatory && (jsxRuntime.jsx(Text, { variant: 'label', fontSize: 'sm', color: 'error', children: "*" }))] })), jsxRuntime.jsx("div", { className: `${TEXTAREA_STYLES.container({ width })} ${disabled ? 'disabled' : ''}`, children: jsxRuntime.jsx("textarea", { ref: textareaRef, value: value, onChange: handleChange, placeholder: placeholder, disabled: disabled, className: TEXTAREA_STYLES.root({ disabled }), "aria-label": ariaLabel || label, rows: minRows }) })] }));
1306
+ return (jsxRuntime.jsxs(Stack, { direction: 'column', gap: 'xs', align: 'stretch', width: width ?? '100%', children: [label && (jsxRuntime.jsxs(Stack, { direction: 'row', gap: 'xs', align: 'center', children: [jsxRuntime.jsx(Text, { variant: 'label', fontSize: 'sm', children: label }), mandatory && (jsxRuntime.jsx(Text, { variant: 'label', fontSize: 'sm', color: 'error', children: "*" }))] })), jsxRuntime.jsx("div", { className: `${TEXTAREA_STYLES.container({ width })} ${disabled ? 'disabled' : ''}`, children: jsxRuntime.jsx("textarea", { ref: textareaRef, value: value, onChange: handleChange, onFocus: onFocus, onBlur: onBlur, placeholder: placeholder, disabled: disabled, className: TEXTAREA_STYLES.root({ disabled }), "aria-label": ariaLabel || label, rows: minRows }) })] }));
1307
1307
  });
1308
1308
  TextArea.displayName = 'TextArea';
1309
1309
  var TextArea_default = React.memo(TextArea);
@@ -1405,7 +1405,7 @@ const SelectItem = ({ option, isSelected = false, onSelect }) => {
1405
1405
  SelectItem.displayName = 'SelectItem';
1406
1406
 
1407
1407
  const MENU_STYLES = theme.createStyles((theme) => ({
1408
- root: (isFadingIn, anchorOrigin, position, width) => ({
1408
+ root: ({ isFadingIn, anchorOrigin, position, width, disableAnimation = false }) => ({
1409
1409
  position: 'fixed',
1410
1410
  zIndex: theme.zIndex.popover,
1411
1411
  marginTop: theme.spacing.xs,
@@ -1417,10 +1417,10 @@ const MENU_STYLES = theme.createStyles((theme) => ({
1417
1417
  maxHeight: MENU_ITEM_SIZE * 8,
1418
1418
  overflowY: 'auto',
1419
1419
  width,
1420
- opacity: isFadingIn ? 1 : 0,
1421
- transform: isFadingIn ? 'scale(1)' : 'scale(0.95)',
1420
+ opacity: disableAnimation ? 1 : (isFadingIn ? 1 : 0),
1421
+ transform: disableAnimation ? 'scale(1)' : (isFadingIn ? 'scale(1)' : 'scale(0.95)'),
1422
1422
  transformOrigin: anchorOrigin === 'right' ? 'top right' : 'top left',
1423
- transition: `opacity ${DEFAULT_TRANSITION_DURATION_MS}ms ease-out, transform ${DEFAULT_TRANSITION_DURATION_MS}ms ease-out`,
1423
+ transition: disableAnimation ? 'none' : `opacity ${DEFAULT_TRANSITION_DURATION_MS}ms ease-out, transform ${DEFAULT_TRANSITION_DURATION_MS}ms ease-out`,
1424
1424
  top: position?.top ?? 0,
1425
1425
  left: position?.left ?? 0,
1426
1426
  visibility: position ? 'visible' : 'hidden',
@@ -1554,7 +1554,7 @@ const useTransitionRender = (isOpen, duration = DEFAULT_TRANSITION_DURATION_MS)
1554
1554
  };
1555
1555
  };
1556
1556
 
1557
- const Menu = ({ anchor, onClose, children, anchorOrigin = 'right', width }) => {
1557
+ const Menu = ({ anchor, onClose, children, anchorOrigin = 'right', width, disableAnimation = false }) => {
1558
1558
  // refs
1559
1559
  const menuRef = React.useRef(null);
1560
1560
  const anchorRef = React.useRef(null);
@@ -1579,7 +1579,7 @@ const Menu = ({ anchor, onClose, children, anchorOrigin = 'right', width }) => {
1579
1579
  if (!isVisible) {
1580
1580
  return null;
1581
1581
  }
1582
- return reactDom.createPortal(jsxRuntime.jsx("div", { ref: menuRef, className: MENU_STYLES.root(isFadingIn, anchorOrigin, position, width), children: children }), document.body);
1582
+ return reactDom.createPortal(jsxRuntime.jsx("div", { ref: menuRef, className: MENU_STYLES.root({ isFadingIn, anchorOrigin, position, width, disableAnimation }), children: children }), document.body);
1583
1583
  };
1584
1584
  Menu.displayName = 'Menu';
1585
1585