@mond-design-system/react 4.12.0 → 5.0.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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties, HTMLAttributes, JSX, ReactElement, Ref, ReactNode, ButtonHTMLAttributes, ElementType, ComponentPropsWithRef, MouseEventHandler, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, RefObject, KeyboardEvent } from 'react';
2
+ import { CSSProperties, HTMLAttributes, JSX, ReactElement, Ref, ReactNode, ButtonHTMLAttributes, ElementType, ComponentPropsWithRef, MouseEventHandler, InputHTMLAttributes, HTMLInputTypeAttribute, TextareaHTMLAttributes, SelectHTMLAttributes, RefObject, KeyboardEvent } from 'react';
3
3
 
4
4
  /**
5
5
  * Join class names, dropping anything falsy.
@@ -612,7 +612,18 @@ interface FieldProps {
612
612
  declare function Field({ label, children, hint, error, required, className }: FieldProps): ReactElement;
613
613
 
614
614
  type InputSize = "sm" | "md" | "lg";
615
- interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
615
+ interface InputBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
616
+ /** The native input type, passed straight through — the system adds no types
617
+ of its own, so `email`, `tel`, `url` and `number` behave as the platform
618
+ defines them, keyboard and validation included. Default "text".
619
+
620
+ One type the component answers to: with `type="search"`, `onClear` takes
621
+ over the browser's own clear cross, so the field shows one clear
622
+ affordance rather than two. Without `onClear` the native cross is left
623
+ alone — there it is the only way to empty the field. */
624
+ type?: HTMLInputTypeAttribute;
625
+ /** Control height and type size. The icon slots, the gutter and the clear
626
+ button all step with it. Default "md". */
616
627
  size?: InputSize;
617
628
  /** Marks the value as failing validation — sets aria-invalid and the danger
618
629
  border. Inside a Field the field's error state does this already. */
@@ -624,20 +635,50 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size">
624
635
  iconRight?: ReactNode;
625
636
  ref?: Ref<HTMLInputElement>;
626
637
  }
638
+ type ClearEnforcement = {
639
+ /** Raises a clear button in the trailing slot whenever the field holds
640
+ text, and runs when it is pressed. An uncontrolled field is emptied
641
+ for you; a controlled one is yours to empty here. Rules out
642
+ iconRight — they are the same slot. */
643
+ onClear: () => void;
644
+ /** Names that button, e.g. "Clear search". Required: the cross says
645
+ nothing to a screen reader, and the words are the app's — "Clear
646
+ search" and "Clear filter" are not interchangeable. */
647
+ clearLabel: string;
648
+ iconRight?: undefined;
649
+ } | {
650
+ onClear?: undefined;
651
+ clearLabel?: undefined;
652
+ };
653
+ type InputProps = InputBaseProps & ClearEnforcement;
627
654
  /**
628
655
  * Single-line text input. Inside a Field it inherits id/description/invalid.
629
656
  *
657
+ * Sizes are `sm` / `md` / `lg`; the icon slots and the clear button step with
658
+ * them. `onClear` folds in what SearchField used to be — pair it with
659
+ * `type="search"` and it replaces the browser's own clear cross.
660
+ *
630
661
  * ```tsx
631
662
  * <Field label="Name">
632
663
  * <Input value={name} onChange={(e) => setName(e.target.value)} />
633
664
  * </Field>
634
665
  *
635
666
  * <Input aria-label="Search" iconLeft={<Icon name="search" />} />
667
+ *
668
+ * <Input
669
+ * type="search"
670
+ * aria-label="Search sessions"
671
+ * iconLeft={<Icon name="search" />}
672
+ * value={query}
673
+ * onChange={(e) => setQuery(e.target.value)}
674
+ * clearLabel="Clear search"
675
+ * onClear={() => setQuery("")}
676
+ * />
636
677
  * ```
637
678
  */
638
- declare function Input({ size, invalid, iconLeft, iconRight, className, ...rest }: InputProps): ReactElement;
679
+ declare function Input({ size, invalid, iconLeft, iconRight, onClear, clearLabel, className, ref, ...rest }: InputProps): ReactElement;
639
680
 
640
- interface PasswordInputProps extends Omit<InputProps, "type"> {
681
+ interface PasswordInputProps extends Omit<InputProps, "type" | "onClear" | "clearLabel" | "iconRight"> {
641
682
  /** Names the reveal button while the password is hidden, e.g. "Show password".
642
683
  Required: the button carries no visible text, so this is the only thing a
643
684
  screen reader has, and it is the app's language rather than the system's. */
@@ -820,26 +861,6 @@ interface SegmentedControlProps<T extends string = string> {
820
861
  */
821
862
  declare function SegmentedControl<T extends string = string>({ label, options, value, onChange, disabled, fullWidth, size, bare, repick, className, }: SegmentedControlProps<T>): ReactElement;
822
863
 
823
- interface SearchFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size" | "value" | "onChange"> {
824
- /** Accessible name. */
825
- label: string;
826
- /** Names the clear button, e.g. "Clear search". Required: the button is a
827
- glyph, so this is all a screen reader has, and the words are the app's. */
828
- clearLabel: string;
829
- value: string;
830
- /** Receives the new text — "" when cleared. */
831
- onChange: (value: string) => void;
832
- ref?: Ref<HTMLInputElement>;
833
- }
834
- /**
835
- * Controlled search input with a clear affordance once there is text.
836
- *
837
- * ```tsx
838
- * <SearchField label="Search sessions" clearLabel="Clear search" value={query} onChange={setQuery} />
839
- * ```
840
- */
841
- declare function SearchField({ label, clearLabel, value, onChange, className, ...rest }: SearchFieldProps): ReactElement;
842
-
843
864
  interface ScrollerLabels {
844
865
  previous: string;
845
866
  next: string;
@@ -1958,4 +1979,4 @@ interface RovingGroupOptions {
1958
1979
  */
1959
1980
  declare function useRovingGroup(ref: RefObject<HTMLElement | null>, { selector, orientation }: RovingGroupOptions): (event: KeyboardEvent<HTMLElement>) => void;
1960
1981
 
1961
- export { AppBar, type AppBarProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeTone, Breadcrumb, type BreadcrumbProps, Button, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant, type CSSVars, Card, CardBody, type CardBodyProps, CardFooter, CardHeader, type CardProps, type CardSectionProps, type CardVariant, type CarouselPager, type CarouselSlide, Checkbox, type CheckboxProps, Chip, ChipBar, type ChipBarGap, type ChipBarProps, ChipGroup, type ChipGroupGap, type ChipGroupProps, type ChipProps, type ChipVariant, ConfirmDialog, type ConfirmDialogProps, type ConfirmDialogTone, Container, type ContainerProps, type ContainerWidth, CountButton, type CountButtonProps, type CountButtonTone, type Crumb, type DataColumn, DataTable, type DataTableProps, type DataTableSelectionLabels, DateTimePicker, type DateTimePickerLabels, type DateTimePickerProps, Divider, type DividerProps, EmptyState, type EmptyStateProps, Field, type FieldContextValue, type FieldProps, FileDrop, type FileDropProps, Heading, type HeadingLevel, type HeadingProps, type HeadingTone, Icon, type IconProps, IconProvider, type IconProviderProps, type IconRender, type IconRenderProps, type IconSize, ImageCarousel, type ImageCarouselLabels, type ImageCarouselProps, Inline, type InlineAlign, type InlineGap, type InlineJustify, type InlineProps, Input, type InputProps, type InputSize, Lightbox, type LightboxLabels, type LightboxProps, Link, type LinkProps, type LinkVariant, ListGroup, type ListGroupProps, ListItem, type ListItemProps, MediaPlaceholder, type MediaPlaceholderProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, type OverlayHistory, OverlayHistoryContext, PasswordInput, type PasswordInputProps, type Presence, ProgressBar, type ProgressBarProps, Radio, type RadioProps, type RovingGroupOptions, Screen, ScreenContent, type ScreenContentProps, Scroller, type ScrollerLabels, type ScrollerProps, SearchField, type SearchFieldProps, type SegmentOption, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, Select, type SelectProps, type SelectSize, Sheet, SheetBody, SheetFooter, SheetHeader, type SheetProps, SideNav, SideNavGroup, type SideNavGroupProps, SideNavItem, type SideNavItemProps, type SideNavProps, Skeleton, type SkeletonProps, type SkeletonVariant, Spinner, type SpinnerProps, Stack, type StackAlign, type StackGap, type StackProps, Switch, type SwitchProps, Tab, TabBar, TabBarAction, type TabBarActionProps, TabBarItem, type TabBarItemProps, type TabBarProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Tag, type TagProps, type TagTone, Text, type TextProps, type TextTone, type TextVariant, Textarea, type TextareaProps, type ToastAction, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, UploadProgress, type UploadProgressLabels, type UploadProgressProps, type UploadStatus, type UseOverlayOptions, type VideoCaptions, type VideoChapter, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, VisuallyHidden, type VisuallyHiddenProps, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
1982
+ export { AppBar, type AppBarProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeTone, Breadcrumb, type BreadcrumbProps, Button, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant, type CSSVars, Card, CardBody, type CardBodyProps, CardFooter, CardHeader, type CardProps, type CardSectionProps, type CardVariant, type CarouselPager, type CarouselSlide, Checkbox, type CheckboxProps, Chip, ChipBar, type ChipBarGap, type ChipBarProps, ChipGroup, type ChipGroupGap, type ChipGroupProps, type ChipProps, type ChipVariant, ConfirmDialog, type ConfirmDialogProps, type ConfirmDialogTone, Container, type ContainerProps, type ContainerWidth, CountButton, type CountButtonProps, type CountButtonTone, type Crumb, type DataColumn, DataTable, type DataTableProps, type DataTableSelectionLabels, DateTimePicker, type DateTimePickerLabels, type DateTimePickerProps, Divider, type DividerProps, EmptyState, type EmptyStateProps, Field, type FieldContextValue, type FieldProps, FileDrop, type FileDropProps, Heading, type HeadingLevel, type HeadingProps, type HeadingTone, Icon, type IconProps, IconProvider, type IconProviderProps, type IconRender, type IconRenderProps, type IconSize, ImageCarousel, type ImageCarouselLabels, type ImageCarouselProps, Inline, type InlineAlign, type InlineGap, type InlineJustify, type InlineProps, Input, type InputProps, type InputSize, Lightbox, type LightboxLabels, type LightboxProps, Link, type LinkProps, type LinkVariant, ListGroup, type ListGroupProps, ListItem, type ListItemProps, MediaPlaceholder, type MediaPlaceholderProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, type OverlayHistory, OverlayHistoryContext, PasswordInput, type PasswordInputProps, type Presence, ProgressBar, type ProgressBarProps, Radio, type RadioProps, type RovingGroupOptions, Screen, ScreenContent, type ScreenContentProps, Scroller, type ScrollerLabels, type ScrollerProps, type SegmentOption, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, Select, type SelectProps, type SelectSize, Sheet, SheetBody, SheetFooter, SheetHeader, type SheetProps, SideNav, SideNavGroup, type SideNavGroupProps, SideNavItem, type SideNavItemProps, type SideNavProps, Skeleton, type SkeletonProps, type SkeletonVariant, Spinner, type SpinnerProps, Stack, type StackAlign, type StackGap, type StackProps, Switch, type SwitchProps, Tab, TabBar, TabBarAction, type TabBarActionProps, TabBarItem, type TabBarItemProps, type TabBarProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Tag, type TagProps, type TagTone, Text, type TextProps, type TextTone, type TextVariant, Textarea, type TextareaProps, type ToastAction, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, UploadProgress, type UploadProgressLabels, type UploadProgressProps, type UploadStatus, type UseOverlayOptions, type VideoCaptions, type VideoChapter, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, VisuallyHidden, type VisuallyHiddenProps, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties, HTMLAttributes, JSX, ReactElement, Ref, ReactNode, ButtonHTMLAttributes, ElementType, ComponentPropsWithRef, MouseEventHandler, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, RefObject, KeyboardEvent } from 'react';
2
+ import { CSSProperties, HTMLAttributes, JSX, ReactElement, Ref, ReactNode, ButtonHTMLAttributes, ElementType, ComponentPropsWithRef, MouseEventHandler, InputHTMLAttributes, HTMLInputTypeAttribute, TextareaHTMLAttributes, SelectHTMLAttributes, RefObject, KeyboardEvent } from 'react';
3
3
 
4
4
  /**
5
5
  * Join class names, dropping anything falsy.
@@ -612,7 +612,18 @@ interface FieldProps {
612
612
  declare function Field({ label, children, hint, error, required, className }: FieldProps): ReactElement;
613
613
 
614
614
  type InputSize = "sm" | "md" | "lg";
615
- interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
615
+ interface InputBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
616
+ /** The native input type, passed straight through — the system adds no types
617
+ of its own, so `email`, `tel`, `url` and `number` behave as the platform
618
+ defines them, keyboard and validation included. Default "text".
619
+
620
+ One type the component answers to: with `type="search"`, `onClear` takes
621
+ over the browser's own clear cross, so the field shows one clear
622
+ affordance rather than two. Without `onClear` the native cross is left
623
+ alone — there it is the only way to empty the field. */
624
+ type?: HTMLInputTypeAttribute;
625
+ /** Control height and type size. The icon slots, the gutter and the clear
626
+ button all step with it. Default "md". */
616
627
  size?: InputSize;
617
628
  /** Marks the value as failing validation — sets aria-invalid and the danger
618
629
  border. Inside a Field the field's error state does this already. */
@@ -624,20 +635,50 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size">
624
635
  iconRight?: ReactNode;
625
636
  ref?: Ref<HTMLInputElement>;
626
637
  }
638
+ type ClearEnforcement = {
639
+ /** Raises a clear button in the trailing slot whenever the field holds
640
+ text, and runs when it is pressed. An uncontrolled field is emptied
641
+ for you; a controlled one is yours to empty here. Rules out
642
+ iconRight — they are the same slot. */
643
+ onClear: () => void;
644
+ /** Names that button, e.g. "Clear search". Required: the cross says
645
+ nothing to a screen reader, and the words are the app's — "Clear
646
+ search" and "Clear filter" are not interchangeable. */
647
+ clearLabel: string;
648
+ iconRight?: undefined;
649
+ } | {
650
+ onClear?: undefined;
651
+ clearLabel?: undefined;
652
+ };
653
+ type InputProps = InputBaseProps & ClearEnforcement;
627
654
  /**
628
655
  * Single-line text input. Inside a Field it inherits id/description/invalid.
629
656
  *
657
+ * Sizes are `sm` / `md` / `lg`; the icon slots and the clear button step with
658
+ * them. `onClear` folds in what SearchField used to be — pair it with
659
+ * `type="search"` and it replaces the browser's own clear cross.
660
+ *
630
661
  * ```tsx
631
662
  * <Field label="Name">
632
663
  * <Input value={name} onChange={(e) => setName(e.target.value)} />
633
664
  * </Field>
634
665
  *
635
666
  * <Input aria-label="Search" iconLeft={<Icon name="search" />} />
667
+ *
668
+ * <Input
669
+ * type="search"
670
+ * aria-label="Search sessions"
671
+ * iconLeft={<Icon name="search" />}
672
+ * value={query}
673
+ * onChange={(e) => setQuery(e.target.value)}
674
+ * clearLabel="Clear search"
675
+ * onClear={() => setQuery("")}
676
+ * />
636
677
  * ```
637
678
  */
638
- declare function Input({ size, invalid, iconLeft, iconRight, className, ...rest }: InputProps): ReactElement;
679
+ declare function Input({ size, invalid, iconLeft, iconRight, onClear, clearLabel, className, ref, ...rest }: InputProps): ReactElement;
639
680
 
640
- interface PasswordInputProps extends Omit<InputProps, "type"> {
681
+ interface PasswordInputProps extends Omit<InputProps, "type" | "onClear" | "clearLabel" | "iconRight"> {
641
682
  /** Names the reveal button while the password is hidden, e.g. "Show password".
642
683
  Required: the button carries no visible text, so this is the only thing a
643
684
  screen reader has, and it is the app's language rather than the system's. */
@@ -820,26 +861,6 @@ interface SegmentedControlProps<T extends string = string> {
820
861
  */
821
862
  declare function SegmentedControl<T extends string = string>({ label, options, value, onChange, disabled, fullWidth, size, bare, repick, className, }: SegmentedControlProps<T>): ReactElement;
822
863
 
823
- interface SearchFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size" | "value" | "onChange"> {
824
- /** Accessible name. */
825
- label: string;
826
- /** Names the clear button, e.g. "Clear search". Required: the button is a
827
- glyph, so this is all a screen reader has, and the words are the app's. */
828
- clearLabel: string;
829
- value: string;
830
- /** Receives the new text — "" when cleared. */
831
- onChange: (value: string) => void;
832
- ref?: Ref<HTMLInputElement>;
833
- }
834
- /**
835
- * Controlled search input with a clear affordance once there is text.
836
- *
837
- * ```tsx
838
- * <SearchField label="Search sessions" clearLabel="Clear search" value={query} onChange={setQuery} />
839
- * ```
840
- */
841
- declare function SearchField({ label, clearLabel, value, onChange, className, ...rest }: SearchFieldProps): ReactElement;
842
-
843
864
  interface ScrollerLabels {
844
865
  previous: string;
845
866
  next: string;
@@ -1958,4 +1979,4 @@ interface RovingGroupOptions {
1958
1979
  */
1959
1980
  declare function useRovingGroup(ref: RefObject<HTMLElement | null>, { selector, orientation }: RovingGroupOptions): (event: KeyboardEvent<HTMLElement>) => void;
1960
1981
 
1961
- export { AppBar, type AppBarProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeTone, Breadcrumb, type BreadcrumbProps, Button, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant, type CSSVars, Card, CardBody, type CardBodyProps, CardFooter, CardHeader, type CardProps, type CardSectionProps, type CardVariant, type CarouselPager, type CarouselSlide, Checkbox, type CheckboxProps, Chip, ChipBar, type ChipBarGap, type ChipBarProps, ChipGroup, type ChipGroupGap, type ChipGroupProps, type ChipProps, type ChipVariant, ConfirmDialog, type ConfirmDialogProps, type ConfirmDialogTone, Container, type ContainerProps, type ContainerWidth, CountButton, type CountButtonProps, type CountButtonTone, type Crumb, type DataColumn, DataTable, type DataTableProps, type DataTableSelectionLabels, DateTimePicker, type DateTimePickerLabels, type DateTimePickerProps, Divider, type DividerProps, EmptyState, type EmptyStateProps, Field, type FieldContextValue, type FieldProps, FileDrop, type FileDropProps, Heading, type HeadingLevel, type HeadingProps, type HeadingTone, Icon, type IconProps, IconProvider, type IconProviderProps, type IconRender, type IconRenderProps, type IconSize, ImageCarousel, type ImageCarouselLabels, type ImageCarouselProps, Inline, type InlineAlign, type InlineGap, type InlineJustify, type InlineProps, Input, type InputProps, type InputSize, Lightbox, type LightboxLabels, type LightboxProps, Link, type LinkProps, type LinkVariant, ListGroup, type ListGroupProps, ListItem, type ListItemProps, MediaPlaceholder, type MediaPlaceholderProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, type OverlayHistory, OverlayHistoryContext, PasswordInput, type PasswordInputProps, type Presence, ProgressBar, type ProgressBarProps, Radio, type RadioProps, type RovingGroupOptions, Screen, ScreenContent, type ScreenContentProps, Scroller, type ScrollerLabels, type ScrollerProps, SearchField, type SearchFieldProps, type SegmentOption, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, Select, type SelectProps, type SelectSize, Sheet, SheetBody, SheetFooter, SheetHeader, type SheetProps, SideNav, SideNavGroup, type SideNavGroupProps, SideNavItem, type SideNavItemProps, type SideNavProps, Skeleton, type SkeletonProps, type SkeletonVariant, Spinner, type SpinnerProps, Stack, type StackAlign, type StackGap, type StackProps, Switch, type SwitchProps, Tab, TabBar, TabBarAction, type TabBarActionProps, TabBarItem, type TabBarItemProps, type TabBarProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Tag, type TagProps, type TagTone, Text, type TextProps, type TextTone, type TextVariant, Textarea, type TextareaProps, type ToastAction, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, UploadProgress, type UploadProgressLabels, type UploadProgressProps, type UploadStatus, type UseOverlayOptions, type VideoCaptions, type VideoChapter, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, VisuallyHidden, type VisuallyHiddenProps, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
1982
+ export { AppBar, type AppBarProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeTone, Breadcrumb, type BreadcrumbProps, Button, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonVariant, type CSSVars, Card, CardBody, type CardBodyProps, CardFooter, CardHeader, type CardProps, type CardSectionProps, type CardVariant, type CarouselPager, type CarouselSlide, Checkbox, type CheckboxProps, Chip, ChipBar, type ChipBarGap, type ChipBarProps, ChipGroup, type ChipGroupGap, type ChipGroupProps, type ChipProps, type ChipVariant, ConfirmDialog, type ConfirmDialogProps, type ConfirmDialogTone, Container, type ContainerProps, type ContainerWidth, CountButton, type CountButtonProps, type CountButtonTone, type Crumb, type DataColumn, DataTable, type DataTableProps, type DataTableSelectionLabels, DateTimePicker, type DateTimePickerLabels, type DateTimePickerProps, Divider, type DividerProps, EmptyState, type EmptyStateProps, Field, type FieldContextValue, type FieldProps, FileDrop, type FileDropProps, Heading, type HeadingLevel, type HeadingProps, type HeadingTone, Icon, type IconProps, IconProvider, type IconProviderProps, type IconRender, type IconRenderProps, type IconSize, ImageCarousel, type ImageCarouselLabels, type ImageCarouselProps, Inline, type InlineAlign, type InlineGap, type InlineJustify, type InlineProps, Input, type InputProps, type InputSize, Lightbox, type LightboxLabels, type LightboxProps, Link, type LinkProps, type LinkVariant, ListGroup, type ListGroupProps, ListItem, type ListItemProps, MediaPlaceholder, type MediaPlaceholderProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, type OverlayHistory, OverlayHistoryContext, PasswordInput, type PasswordInputProps, type Presence, ProgressBar, type ProgressBarProps, Radio, type RadioProps, type RovingGroupOptions, Screen, ScreenContent, type ScreenContentProps, Scroller, type ScrollerLabels, type ScrollerProps, type SegmentOption, SegmentedControl, type SegmentedControlProps, type SegmentedControlSize, Select, type SelectProps, type SelectSize, Sheet, SheetBody, SheetFooter, SheetHeader, type SheetProps, SideNav, SideNavGroup, type SideNavGroupProps, SideNavItem, type SideNavItemProps, type SideNavProps, Skeleton, type SkeletonProps, type SkeletonVariant, Spinner, type SpinnerProps, Stack, type StackAlign, type StackGap, type StackProps, Switch, type SwitchProps, Tab, TabBar, TabBarAction, type TabBarActionProps, TabBarItem, type TabBarItemProps, type TabBarProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Tag, type TagProps, type TagTone, Text, type TextProps, type TextTone, type TextVariant, Textarea, type TextareaProps, type ToastAction, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, UploadProgress, type UploadProgressLabels, type UploadProgressProps, type UploadStatus, type UseOverlayOptions, type VideoCaptions, type VideoChapter, VideoPlayer, type VideoPlayerLabels, type VideoPlayerProps, VisuallyHidden, type VisuallyHiddenProps, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
package/dist/index.js CHANGED
@@ -1092,20 +1092,47 @@ function ProgressBar({
1092
1092
  );
1093
1093
  }
1094
1094
 
1095
+ // src/internal/forkRef.ts
1096
+ function forkRef(own, given) {
1097
+ return (node) => {
1098
+ own.current = node;
1099
+ if (typeof given === "function") given(node);
1100
+ else if (given != null) given.current = node;
1101
+ };
1102
+ }
1103
+
1095
1104
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Input/Input.module.css?mds-scoped
1096
- var Input_module_default = { "input": "mds-Input__input", "size-sm": "mds-Input__size-sm", "size-md": "mds-Input__size-md", "size-lg": "mds-Input__size-lg", "iconWrap": "mds-Input__iconWrap", "icon": "mds-Input__icon", "iconLeft": "mds-Input__iconLeft", "iconRight": "mds-Input__iconRight", "with-icon-left": "mds-Input__with-icon-left", "with-icon-right": "mds-Input__with-icon-right" };
1105
+ var Input_module_default = { "input": "mds-Input__input", "own-clear": "mds-Input__own-clear", "size-sm": "mds-Input__size-sm", "size-md": "mds-Input__size-md", "size-lg": "mds-Input__size-lg", "iconWrap": "mds-Input__iconWrap", "icon": "mds-Input__icon", "slot-sm": "mds-Input__slot-sm", "slot-md": "mds-Input__slot-md", "slot-lg": "mds-Input__slot-lg", "iconLeft": "mds-Input__iconLeft", "iconRight": "mds-Input__iconRight", "with-icon-left": "mds-Input__with-icon-left", "with-icon-right": "mds-Input__with-icon-right", "clear": "mds-Input__clear mds-hit-area__hitArea", "clearGlyph": "mds-Input__clearGlyph" };
1097
1106
  function Input({
1098
1107
  size = "md",
1099
1108
  invalid,
1100
1109
  iconLeft,
1101
1110
  iconRight,
1111
+ onClear,
1112
+ clearLabel,
1102
1113
  className,
1114
+ ref,
1103
1115
  ...rest
1104
1116
  }) {
1105
1117
  const field = useFieldContext();
1118
+ const own = useRef(null);
1119
+ const [typedInto, setTypedInto] = useState(() => String(rest.defaultValue ?? "") !== "");
1120
+ const hasText = rest.value !== void 0 ? String(rest.value) !== "" : typedInto;
1121
+ const showClear = onClear != null && hasText;
1122
+ const handleChange = (event) => {
1123
+ if (onClear != null) setTypedInto(event.target.value !== "");
1124
+ rest.onChange?.(event);
1125
+ };
1126
+ const clear = () => {
1127
+ if (rest.value === void 0 && own.current != null) own.current.value = "";
1128
+ setTypedInto(false);
1129
+ own.current?.focus();
1130
+ onClear?.();
1131
+ };
1106
1132
  const input = /* @__PURE__ */ jsx(
1107
1133
  "input",
1108
1134
  {
1135
+ ref: forkRef(own, ref),
1109
1136
  id: rest.id ?? field?.id,
1110
1137
  "aria-describedby": rest["aria-describedby"] ?? field?.describedBy,
1111
1138
  "aria-invalid": rest["aria-invalid"] ?? ((invalid ?? field?.invalid) || void 0),
@@ -1113,17 +1140,20 @@ function Input({
1113
1140
  Input_module_default.input,
1114
1141
  Input_module_default[`size-${size}`],
1115
1142
  iconLeft != null && Input_module_default["with-icon-left"],
1116
- iconRight != null && Input_module_default["with-icon-right"],
1143
+ (iconRight != null || showClear) && Input_module_default["with-icon-right"],
1144
+ onClear != null && Input_module_default["own-clear"],
1117
1145
  className
1118
1146
  ),
1119
- ...rest
1147
+ ...rest,
1148
+ onChange: handleChange
1120
1149
  }
1121
1150
  );
1122
- if (iconLeft == null && iconRight == null) return input;
1123
- return /* @__PURE__ */ jsxs("span", { className: Input_module_default.iconWrap, children: [
1151
+ if (iconLeft == null && iconRight == null && onClear == null) return input;
1152
+ return /* @__PURE__ */ jsxs("span", { className: cx(Input_module_default.iconWrap, Input_module_default[`slot-${size}`]), children: [
1124
1153
  input,
1125
1154
  iconLeft != null && /* @__PURE__ */ jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconLeft), "aria-hidden": "true", children: iconLeft }),
1126
- iconRight != null && /* @__PURE__ */ jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconRight), "aria-hidden": "true", children: iconRight })
1155
+ iconRight != null && /* @__PURE__ */ jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconRight), "aria-hidden": "true", children: iconRight }),
1156
+ showClear && /* @__PURE__ */ jsx("button", { type: "button", "aria-label": clearLabel, className: Input_module_default.clear, onClick: clear, children: /* @__PURE__ */ jsx(CloseGlyph, { className: Input_module_default.clearGlyph }) })
1127
1157
  ] });
1128
1158
  }
1129
1159
 
@@ -1195,15 +1225,6 @@ function Textarea({ rows = 3, showCount = false, className, ...rest }) {
1195
1225
  ] });
1196
1226
  }
1197
1227
 
1198
- // src/internal/forkRef.ts
1199
- function forkRef(own, given) {
1200
- return (node) => {
1201
- own.current = node;
1202
- if (typeof given === "function") given(node);
1203
- else if (given != null) given.current = node;
1204
- };
1205
- }
1206
-
1207
1228
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Checkbox/Checkbox.module.css?mds-scoped
1208
1229
  var Checkbox_module_default = { "root": "mds-Checkbox__root", "box": "mds-Checkbox__box mds-hit-area__hitArea", "bare": "mds-Checkbox__bare", "label": "mds-Checkbox__label" };
1209
1230
  function Checkbox({
@@ -1316,51 +1337,6 @@ function SegmentedControl({
1316
1337
  );
1317
1338
  }
1318
1339
 
1319
- // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/SearchField/SearchField.module.css?mds-scoped
1320
- var SearchField_module_default = { "wrap": "mds-SearchField__wrap", "glass": "mds-SearchField__glass", "input": "mds-SearchField__input", "clear": "mds-SearchField__clear mds-hit-area__hitArea", "clearGlyph": "mds-SearchField__clearGlyph" };
1321
- function SearchField({
1322
- label,
1323
- clearLabel,
1324
- value,
1325
- onChange,
1326
- className,
1327
- ...rest
1328
- }) {
1329
- return /* @__PURE__ */ jsxs("span", { className: cx(SearchField_module_default.wrap, className), children: [
1330
- /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className: SearchField_module_default.glass, children: /* @__PURE__ */ jsx(
1331
- "path",
1332
- {
1333
- d: "M7 12a5 5 0 1 1 0-10 5 5 0 0 1 0 10Zm7 2-3.5-3.5",
1334
- fill: "none",
1335
- stroke: "currentColor",
1336
- strokeWidth: "1.5",
1337
- strokeLinecap: "round"
1338
- }
1339
- ) }),
1340
- /* @__PURE__ */ jsx(
1341
- "input",
1342
- {
1343
- type: "search",
1344
- "aria-label": label,
1345
- value,
1346
- onChange: (event) => onChange(event.target.value),
1347
- className: SearchField_module_default.input,
1348
- ...rest
1349
- }
1350
- ),
1351
- value !== "" && /* @__PURE__ */ jsx(
1352
- "button",
1353
- {
1354
- type: "button",
1355
- "aria-label": clearLabel,
1356
- className: SearchField_module_default.clear,
1357
- onClick: () => onChange(""),
1358
- children: /* @__PURE__ */ jsx(CloseGlyph, { className: SearchField_module_default.clearGlyph })
1359
- }
1360
- )
1361
- ] });
1362
- }
1363
-
1364
1340
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Scroller/Scroller.module.css?mds-scoped
1365
1341
  var Scroller_module_default = { "scroller": "mds-Scroller__scroller", "header": "mds-Scroller__header", "trailing": "mds-Scroller__trailing", "track": "mds-Scroller__track", "arrows": "mds-Scroller__arrows" };
1366
1342
  var STEP = 0.8;
@@ -2830,6 +2806,6 @@ function useRovingGroup(ref, { selector, orientation = "horizontal" }) {
2830
2806
  );
2831
2807
  }
2832
2808
 
2833
- export { AppBar, Avatar, AvatarGroup, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Checkbox, Chip, ChipBar, ChipGroup, ConfirmDialog, Container, CountButton, DataTable, DateTimePicker, Divider, EmptyState, Field, FileDrop, Heading, Icon, IconProvider, ImageCarousel, Inline, Input, Lightbox, Link, ListGroup, ListItem, MediaPlaceholder, Modal, ModalBody, ModalFooter, ModalHeader, OverlayHistoryContext, PasswordInput, ProgressBar, Radio, Screen, ScreenContent, Scroller, SearchField, SegmentedControl, Select, Sheet, SheetBody, SheetFooter, SheetHeader, SideNav, SideNavGroup, SideNavItem, Skeleton, Spinner, Stack, Switch, Tab, TabBar, TabBarAction, TabBarItem, TabList, TabPanel, Tabs, Tag, Text, Textarea, ToastProvider, UploadProgress, VideoPlayer, VisuallyHidden, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
2809
+ export { AppBar, Avatar, AvatarGroup, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Checkbox, Chip, ChipBar, ChipGroup, ConfirmDialog, Container, CountButton, DataTable, DateTimePicker, Divider, EmptyState, Field, FileDrop, Heading, Icon, IconProvider, ImageCarousel, Inline, Input, Lightbox, Link, ListGroup, ListItem, MediaPlaceholder, Modal, ModalBody, ModalFooter, ModalHeader, OverlayHistoryContext, PasswordInput, ProgressBar, Radio, Screen, ScreenContent, Scroller, SegmentedControl, Select, Sheet, SheetBody, SheetFooter, SheetHeader, SideNav, SideNavGroup, SideNavItem, Skeleton, Spinner, Stack, Switch, Tab, TabBar, TabBarAction, TabBarItem, TabList, TabPanel, Tabs, Tag, Text, Textarea, ToastProvider, UploadProgress, VideoPlayer, VisuallyHidden, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
2834
2810
  //# sourceMappingURL=index.js.map
2835
2811
  //# sourceMappingURL=index.js.map