@algolia/satellite 1.10.2 → 1.11.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.
Files changed (140) hide show
  1. package/dist/cjs/Actions/Accordion/Accordion.d.ts +27 -18
  2. package/dist/cjs/Actions/Button/Button.tailwind.js +27 -42
  3. package/dist/cjs/Actions/Button/PolymorphicIconButton.d.ts +34 -5
  4. package/dist/cjs/Actions/Button/types.d.ts +30 -9
  5. package/dist/cjs/Actions/Button/types.js +2 -0
  6. package/dist/cjs/Actions/ButtonGroup/ButtonGroup.d.ts +6 -1
  7. package/dist/cjs/Actions/Switch/Switch.d.ts +21 -1
  8. package/dist/cjs/Actions/Switch/SwitchOption.d.ts +9 -0
  9. package/dist/cjs/Actions/Switch/types.d.ts +2 -1
  10. package/dist/cjs/Actions/Switch/types.js +3 -1
  11. package/dist/cjs/Actions/ToggleButton/ToggleButton.d.ts +9 -0
  12. package/dist/cjs/Actions/ToggleButton/ToggleButtonBase.d.ts +33 -2
  13. package/dist/cjs/Actions/ToggleButton/ToggleButtonBase.js +1 -1
  14. package/dist/cjs/Actions/ToggleGroup/ToggleGroup.d.ts +18 -6
  15. package/dist/cjs/Avatars/ApplicationAvatar/ApplicationAvatar.d.ts +10 -3
  16. package/dist/cjs/Avatars/UserAvatar/UserAvatar.d.ts +13 -5
  17. package/dist/cjs/Avatars/types.d.ts +23 -1
  18. package/dist/cjs/Avatars/types.js +3 -1
  19. package/dist/cjs/Fields/AutoComplete/components/AutoCompleteEmptyState.d.ts +6 -2
  20. package/dist/cjs/Fields/AutoComplete/types.d.ts +144 -5
  21. package/dist/cjs/Fields/Checkbox/Checkbox.d.ts +5 -2
  22. package/dist/cjs/Fields/DateInput/DateInput.d.ts +47 -0
  23. package/dist/cjs/Fields/DateInput/DateInput.js +169 -0
  24. package/dist/cjs/Fields/DateInput/index.d.ts +1 -0
  25. package/dist/cjs/Fields/DateInput/index.js +16 -0
  26. package/dist/cjs/Fields/DatePicker/DatePicker/DatePicker.d.ts +42 -0
  27. package/dist/cjs/Fields/DatePicker/DatePicker/DatePicker.js +1 -0
  28. package/dist/cjs/Fields/DatePicker/DateRangePicker/DateRangePicker.d.ts +36 -0
  29. package/dist/cjs/Fields/DatePicker/DateRangePicker/DateRangePicker.js +1 -0
  30. package/dist/cjs/Fields/DatePicker/components/Popover.d.ts +1 -0
  31. package/dist/cjs/Fields/DatePicker/components/Popover.js +5 -1
  32. package/dist/cjs/Fields/DatePicker/types.d.ts +21 -0
  33. package/dist/cjs/Fields/Dropzone/Dropzone.d.ts +85 -6
  34. package/dist/cjs/Fields/Field/Field.d.ts +32 -9
  35. package/dist/cjs/Fields/Form/stories/Complex.js +22 -12
  36. package/dist/cjs/Fields/Input/Input.d.ts +18 -1
  37. package/dist/cjs/Fields/Input/Input.js +5 -3
  38. package/dist/cjs/Fields/RadioGroup/RadioButton.d.ts +68 -2
  39. package/dist/cjs/Fields/RadioGroup/RadioGroup.d.ts +27 -10
  40. package/dist/cjs/Fields/RadioGroup/RadioGroup.js +20 -77
  41. package/dist/cjs/Fields/RadioGroup/RadioGroupItem.d.ts +20 -0
  42. package/dist/cjs/Fields/RadioGroup/RadioGroupItem.js +71 -0
  43. package/dist/cjs/Fields/RadioGroup/index.d.ts +1 -0
  44. package/dist/cjs/Fields/RadioGroup/index.js +11 -0
  45. package/dist/cjs/Fields/RangeSlider/RangeSlider.d.ts +48 -3
  46. package/dist/cjs/Fields/Select/Select.d.ts +3 -0
  47. package/dist/cjs/Fields/TextArea/TextArea.d.ts +16 -0
  48. package/dist/cjs/Fields/Toggle/Toggle.d.ts +51 -3
  49. package/dist/cjs/Fields/index.d.ts +1 -0
  50. package/dist/cjs/Fields/index.js +11 -0
  51. package/dist/cjs/Helpers/ClickAwayContainer/ClickAwayContainer.d.ts +6 -4
  52. package/dist/cjs/Helpers/HelpUnderline/HelpUnderline.d.ts +9 -1
  53. package/dist/cjs/Helpers/Medallion/Medallion.d.ts +14 -1
  54. package/dist/cjs/Helpers/Medallion/Medallion.js +11 -10
  55. package/dist/cjs/Helpers/Medallion/Medallion.tailwind.js +1 -1
  56. package/dist/cjs/Helpers/Medallion/types.d.ts +1 -1
  57. package/dist/cjs/Helpers/Separator/Separator.d.ts +10 -0
  58. package/dist/cjs/Helpers/TextWrap/TextWrap.d.ts +8 -2
  59. package/dist/cjs/Helpers/TextWrap/TextWrap.js +1 -1
  60. package/dist/cjs/Helpers/UserContent/UserContent.d.ts +10 -1
  61. package/dist/cjs/Icons/index.d.ts +1 -1
  62. package/dist/cjs/Icons/index.js +6 -0
  63. package/dist/cjs/Indicators/Badge/Badge.d.ts +6 -2
  64. package/dist/cjs/Indicators/Tag/Tag.tailwind.js +13 -4
  65. package/dist/cjs/Navigation/Stepper/Step.js +28 -25
  66. package/dist/cjs/Overlay/MenuButton/components/CustomTrigger.d.ts +1 -1
  67. package/dist/cjs/Overlay/MenuButton/components/CustomTrigger.js +12 -4
  68. package/dist/cjs/Overlay/Tooltip/types.d.ts +3 -0
  69. package/dist/cjs/Satellite/locale.d.ts +2 -1
  70. package/dist/esm/Actions/Accordion/Accordion.d.ts +27 -18
  71. package/dist/esm/Actions/Button/Button.tailwind.js +27 -44
  72. package/dist/esm/Actions/Button/PolymorphicIconButton.d.ts +34 -5
  73. package/dist/esm/Actions/Button/types.d.ts +30 -9
  74. package/dist/esm/Actions/Button/types.js +1 -0
  75. package/dist/esm/Actions/ButtonGroup/ButtonGroup.d.ts +6 -1
  76. package/dist/esm/Actions/Switch/Switch.d.ts +21 -1
  77. package/dist/esm/Actions/Switch/SwitchOption.d.ts +9 -0
  78. package/dist/esm/Actions/Switch/types.d.ts +2 -1
  79. package/dist/esm/Actions/Switch/types.js +1 -1
  80. package/dist/esm/Actions/ToggleButton/ToggleButton.d.ts +9 -0
  81. package/dist/esm/Actions/ToggleButton/ToggleButtonBase.d.ts +33 -2
  82. package/dist/esm/Actions/ToggleButton/ToggleButtonBase.js +1 -1
  83. package/dist/esm/Actions/ToggleGroup/ToggleGroup.d.ts +18 -6
  84. package/dist/esm/Avatars/ApplicationAvatar/ApplicationAvatar.d.ts +10 -3
  85. package/dist/esm/Avatars/UserAvatar/UserAvatar.d.ts +13 -5
  86. package/dist/esm/Avatars/types.d.ts +23 -1
  87. package/dist/esm/Avatars/types.js +1 -1
  88. package/dist/esm/Fields/AutoComplete/components/AutoCompleteEmptyState.d.ts +6 -2
  89. package/dist/esm/Fields/AutoComplete/types.d.ts +144 -5
  90. package/dist/esm/Fields/Checkbox/Checkbox.d.ts +5 -2
  91. package/dist/esm/Fields/DateInput/DateInput.d.ts +47 -0
  92. package/dist/esm/Fields/DateInput/DateInput.js +162 -0
  93. package/dist/esm/Fields/DateInput/index.d.ts +1 -0
  94. package/dist/esm/Fields/DateInput/index.js +1 -0
  95. package/dist/esm/Fields/DatePicker/DatePicker/DatePicker.d.ts +42 -0
  96. package/dist/esm/Fields/DatePicker/DatePicker/DatePicker.js +1 -0
  97. package/dist/esm/Fields/DatePicker/DateRangePicker/DateRangePicker.d.ts +36 -0
  98. package/dist/esm/Fields/DatePicker/DateRangePicker/DateRangePicker.js +1 -0
  99. package/dist/esm/Fields/DatePicker/components/Popover.d.ts +1 -0
  100. package/dist/esm/Fields/DatePicker/components/Popover.js +5 -1
  101. package/dist/esm/Fields/DatePicker/types.d.ts +21 -0
  102. package/dist/esm/Fields/Dropzone/Dropzone.d.ts +85 -6
  103. package/dist/esm/Fields/Field/Field.d.ts +32 -9
  104. package/dist/esm/Fields/Form/stories/Complex.js +23 -13
  105. package/dist/esm/Fields/Input/Input.d.ts +18 -1
  106. package/dist/esm/Fields/Input/Input.js +5 -3
  107. package/dist/esm/Fields/RadioGroup/RadioButton.d.ts +68 -2
  108. package/dist/esm/Fields/RadioGroup/RadioGroup.d.ts +27 -10
  109. package/dist/esm/Fields/RadioGroup/RadioGroup.js +20 -77
  110. package/dist/esm/Fields/RadioGroup/RadioGroupItem.d.ts +20 -0
  111. package/dist/esm/Fields/RadioGroup/RadioGroupItem.js +64 -0
  112. package/dist/esm/Fields/RadioGroup/index.d.ts +1 -0
  113. package/dist/esm/Fields/RadioGroup/index.js +2 -1
  114. package/dist/esm/Fields/RangeSlider/RangeSlider.d.ts +48 -3
  115. package/dist/esm/Fields/Select/Select.d.ts +3 -0
  116. package/dist/esm/Fields/TextArea/TextArea.d.ts +16 -0
  117. package/dist/esm/Fields/Toggle/Toggle.d.ts +51 -3
  118. package/dist/esm/Fields/index.d.ts +1 -0
  119. package/dist/esm/Fields/index.js +1 -0
  120. package/dist/esm/Helpers/ClickAwayContainer/ClickAwayContainer.d.ts +6 -4
  121. package/dist/esm/Helpers/HelpUnderline/HelpUnderline.d.ts +9 -1
  122. package/dist/esm/Helpers/Medallion/Medallion.d.ts +14 -1
  123. package/dist/esm/Helpers/Medallion/Medallion.js +11 -10
  124. package/dist/esm/Helpers/Medallion/Medallion.tailwind.js +1 -1
  125. package/dist/esm/Helpers/Medallion/types.d.ts +1 -1
  126. package/dist/esm/Helpers/Separator/Separator.d.ts +10 -0
  127. package/dist/esm/Helpers/TextWrap/TextWrap.d.ts +8 -2
  128. package/dist/esm/Helpers/TextWrap/TextWrap.js +1 -1
  129. package/dist/esm/Helpers/UserContent/UserContent.d.ts +10 -1
  130. package/dist/esm/Icons/index.d.ts +1 -1
  131. package/dist/esm/Icons/index.js +1 -1
  132. package/dist/esm/Indicators/Badge/Badge.d.ts +6 -2
  133. package/dist/esm/Indicators/Tag/Tag.tailwind.js +13 -4
  134. package/dist/esm/Navigation/Stepper/Step.js +28 -25
  135. package/dist/esm/Overlay/MenuButton/components/CustomTrigger.d.ts +1 -1
  136. package/dist/esm/Overlay/MenuButton/components/CustomTrigger.js +12 -4
  137. package/dist/esm/Overlay/Tooltip/types.d.ts +3 -0
  138. package/dist/esm/Satellite/locale.d.ts +2 -1
  139. package/dist/satellite.min.css +1 -1
  140. package/package.json +2 -2
@@ -21,6 +21,7 @@ var DatePickerPopover = exports.DatePickerPopover = function DatePickerPopover(_
21
21
  onOpenChange = _ref.onOpenChange,
22
22
  trigger = _ref.trigger,
23
23
  children = _ref.children,
24
+ anchor = _ref.anchor,
24
25
  _ref$placement = _ref.placement,
25
26
  placement = _ref$placement === void 0 ? "bottom-start" : _ref$placement,
26
27
  onOpenAutoFocus = _ref.onOpenAutoFocus,
@@ -37,7 +38,10 @@ var DatePickerPopover = exports.DatePickerPopover = function DatePickerPopover(_
37
38
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Popover.Trigger, {
38
39
  asChild: true,
39
40
  children: trigger
40
- }), createPortal( /*#__PURE__*/(0, _jsxRuntime.jsx)(Popover.Content, {
41
+ }), anchor ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Popover.Anchor, {
42
+ asChild: true,
43
+ children: anchor
44
+ }) : null, createPortal( /*#__PURE__*/(0, _jsxRuntime.jsx)(Popover.Content, {
41
45
  side: side,
42
46
  sideOffset: 16,
43
47
  align: align,
@@ -1,4 +1,5 @@
1
1
  import type { Locale as DateFnsLocale } from "date-fns";
2
+ import type { ReactNode } from "react";
2
3
  import type { DatePickerPopoverProps } from "./components";
3
4
  export declare type DatePickerLocale = {
4
5
  /** The date-fns locale object used to localize dates. Defaults to* `en-US`. */
@@ -17,11 +18,31 @@ export declare type DatePickerLocale = {
17
18
  title?: string;
18
19
  };
19
20
  export declare type SharedDatePickerProps = {
21
+ /**
22
+ * The placement of the `DatePicker`/`DateRangePicker` modal.
23
+ * @todo Rename this prop to `side`/`align` in the next major version
24
+ */
20
25
  modalPlacement?: DatePickerPopoverProps["placement"];
26
+ /**
27
+ * The anchor element for the `DatePicker`/`DateRangePicker` popover.
28
+ */
29
+ popoverAnchor?: ReactNode;
30
+ /**
31
+ * The locale of the `DatePicker`/`DateRangePicker`.
32
+ */
21
33
  locale?: DatePickerLocale;
22
34
  } & ({
35
+ /**
36
+ * Whether the year is editable.
37
+ */
23
38
  editableYear?: false;
24
39
  } | {
40
+ /**
41
+ * Whether the year is editable.
42
+ */
25
43
  editableYear: true;
44
+ /**
45
+ * The years to display in the `DatePicker`/`DateRangePicker`.
46
+ */
26
47
  years?: number[];
27
48
  });
@@ -5,23 +5,102 @@ export declare type DropzoneLocale = {
5
5
  placeholder?: (multiple: boolean) => string;
6
6
  };
7
7
  export interface DropzoneBaseProps {
8
+ /**
9
+ * The id of the `Dropzone`.
10
+ */
8
11
  id?: string;
12
+ /**
13
+ * The callback function that is called when files are added to the `Dropzone`.
14
+ */
9
15
  onChange?(acceptedFiles: File[], fileRejections: FileRejection[]): void;
16
+ /**
17
+ * The placeholder of the `Dropzone`.
18
+ */
10
19
  placeholder?: string;
11
- /** @default false */
20
+ /**
21
+ * Whether the `Dropzone` is clearable.
22
+ * @default false
23
+ */
12
24
  clearable?: boolean;
13
- /** @ignore */
25
+ /**
26
+ * The class name of the `Dropzone`.
27
+ */
14
28
  className?: string;
15
- /** @default false */
29
+ /**
30
+ * Whether the `Dropzone` allows multiple files.
31
+ * @default false
32
+ */
16
33
  multiple?: boolean;
17
- /** @default false */
34
+ /**
35
+ * Whether the `Dropzone` is required.
36
+ * @default false
37
+ */
18
38
  required?: boolean;
39
+ /**
40
+ * The locale of the `Dropzone`.
41
+ */
19
42
  locale?: DropzoneLocale;
43
+ /**
44
+ * The accepted file types of the `Dropzone`.
45
+ */
46
+ accept?: ReactDropZoneProps["accept"];
47
+ /**
48
+ * The minimum file size of the `Dropzone`.
49
+ */
50
+ minSize?: ReactDropZoneProps["minSize"];
51
+ /**
52
+ * The maximum file size of the `Dropzone`.
53
+ */
54
+ maxSize?: ReactDropZoneProps["maxSize"];
55
+ /**
56
+ * The maximum number of files of the `Dropzone`.
57
+ */
58
+ maxFiles?: ReactDropZoneProps["maxFiles"];
59
+ /**
60
+ * Whether the `Dropzone` prevents the drop event on the document.
61
+ */
62
+ preventDropOnDocument?: ReactDropZoneProps["preventDropOnDocument"];
63
+ /**
64
+ * Whether the `Dropzone` prevents the click event on the document.
65
+ */
66
+ noClick?: ReactDropZoneProps["noClick"];
67
+ /**
68
+ * Whether the `Dropzone` prevents the keyboard event on the document.
69
+ */
70
+ noKeyboard?: ReactDropZoneProps["noKeyboard"];
71
+ /**
72
+ * Whether the `Dropzone` prevents the drag event on the document.
73
+ */
74
+ noDrag?: ReactDropZoneProps["noDrag"];
75
+ /**
76
+ * Whether the `Dropzone` prevents the drag events bubbling.
77
+ */
78
+ noDragEventsBubbling?: ReactDropZoneProps["noDragEventsBubbling"];
79
+ /**
80
+ * Whether the `Dropzone` is disabled.
81
+ */
82
+ disabled?: ReactDropZoneProps["disabled"];
83
+ /**
84
+ * The callback function that is called to get the files from the event.
85
+ */
86
+ getFilesFromEvent?: ReactDropZoneProps["getFilesFromEvent"];
87
+ /**
88
+ * The callback function that is called when the file dialog is canceled.
89
+ */
90
+ onFileDialogCancel?: ReactDropZoneProps["onFileDialogCancel"];
91
+ /**
92
+ * The callback function that is called when the file dialog is opened.
93
+ */
94
+ onFileDialogOpen?: ReactDropZoneProps["onFileDialogOpen"];
95
+ /**
96
+ * The callback function that is called to validate the file.
97
+ */
98
+ validator?: ReactDropZoneProps["validator"];
20
99
  }
21
- export declare type DropzoneProps = DropzoneBaseProps & Omit<ReactDropZoneProps, "onDrop" | "onDropAccepted" | "onDropRejected" | "multiple">;
100
+ export declare type DropzoneProps = DropzoneBaseProps;
22
101
  /**
23
102
  * The `Dropzone` component is used to upload files.
24
103
  *
25
104
  * See the [Dropzone documentation page](https://satellite.algolia.com/components/forms/dropzone) for more information.
26
105
  */
27
- export declare const Dropzone: import("react").ForwardRefExoticComponent<DropzoneBaseProps & Omit<ReactDropZoneProps, "onDrop" | "multiple" | "onDropAccepted" | "onDropRejected"> & import("react").RefAttributes<HTMLInputElement>>;
106
+ export declare const Dropzone: import("react").ForwardRefExoticComponent<DropzoneBaseProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,24 +1,47 @@
1
1
  import { type ReactChild, type ReactNode, type VFC } from "react";
2
2
  import type { FieldState } from "./FieldContext";
3
3
  export interface FieldProps {
4
- /** @ignore */
4
+ /**
5
+ * The class name of the `Field`.
6
+ */
5
7
  className?: string;
6
- /** Define a label to display above the nested input. */
8
+ /**
9
+ * Define a label to display above the nested input.
10
+ */
7
11
  label?: ReactChild;
8
- /** Define the `id` of the label. */
12
+ /**
13
+ * Define the `id` of the label.
14
+ */
9
15
  labelId?: string;
10
- /** Define the `id` of the input used by the label. */
16
+ /**
17
+ * Define the `id` of the input used by the label.
18
+ */
11
19
  labelFor?: string;
12
- /** Define an helpful description to show below the `Field`. */
20
+ /**
21
+ * Define an helpful description to show below the `Field`.
22
+ */
13
23
  description?: ReactNode;
14
- /** Define the state of the `Field`. */
24
+ /**
25
+ * Define the state of the `Field`.
26
+ */
15
27
  state?: FieldState;
16
- /** Define if the `Field` should be displayed inline. */
28
+ /**
29
+ * Define if the `Field` should be displayed inline.
30
+ * @default false
31
+ */
17
32
  inline?: boolean;
18
- /** Define if the `Field` is required. */
33
+ /**
34
+ * Define if the `Field` is required.
35
+ */
19
36
  required?: boolean;
20
- /** Define the visibility of the required indicator. */
37
+ /**
38
+ * Define the visibility of the required indicator.
39
+ * @default false
40
+ */
21
41
  hideRequiredIndicator?: boolean;
42
+ /**
43
+ * The children of the `Field`.
44
+ */
22
45
  children: ReactNode;
23
46
  }
24
47
  /**
@@ -108,6 +108,10 @@ var zodSchema = _zod2.z.object({
108
108
  message: "You must specify a birthday"
109
109
  };
110
110
  }
111
+ }).refine(function (val) {
112
+ return val < now;
113
+ }, {
114
+ message: "You must specify a birthday in the past"
111
115
  }),
112
116
  age: _zod2.z.coerce.number().min(1, {
113
117
  message: "You must specify an age"
@@ -377,14 +381,16 @@ var RHFComplexComponent = exports.RHFComplexComponent = function RHFComplexCompo
377
381
  description: "Please specify your birthday",
378
382
  state: getFieldState("birthday"),
379
383
  className: (0, _satellitePrefixer["default"])(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["w-full"]))),
380
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.DatePicker, _objectSpread({
384
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.DateInput, _objectSpread({
381
385
  id: "birthday",
382
- calendarProps: {
383
- disabled: {
384
- after: now
386
+ required: true,
387
+ datePickerProps: {
388
+ calendarProps: {
389
+ disabled: {
390
+ after: now
391
+ }
385
392
  }
386
- },
387
- required: true
393
+ }
388
394
  }, field))
389
395
  });
390
396
  }
@@ -583,7 +589,9 @@ var yupSchema = yup.object({
583
589
  value: yup.string()
584
590
  })).min(1, "You must specify at least one job position"),
585
591
  employmentStatus: yup.string().oneOf(employmentStatuses).required("You must specify an employment status"),
586
- birthday: yup.date().required("You must specify a birthday"),
592
+ birthday: yup.date().required("You must specify a birthday").test("birthday", "You must specify a birthday in the past", function (value) {
593
+ return value < now;
594
+ }),
587
595
  age: yup.number().min(18, "You must be at least 18 years old").max(100, "You must be at most 100 years old").required("You must specify an age"),
588
596
  interest: yup.number().min(5, "Your level of interest must be at least 5").required(),
589
597
  idealLocation: yup.array(yup.number().min(10, "Your minimum ideal location must be 10 km").max(40, "Your maximum ideal location must be 40 km").required()).required(),
@@ -774,14 +782,16 @@ var FormikComplexComponent = exports.FormikComplexComponent = function FormikCom
774
782
  description: "Please specify your birthday",
775
783
  state: getFieldState("birthday"),
776
784
  className: (0, _satellitePrefixer["default"])(_templateObject38 || (_templateObject38 = (0, _taggedTemplateLiteral2["default"])(["w-full"]))),
777
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.DatePicker, {
785
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.DateInput, {
778
786
  id: "birthday",
779
- calendarProps: {
780
- disabled: {
781
- after: now
787
+ required: true,
788
+ datePickerProps: {
789
+ calendarProps: {
790
+ disabled: {
791
+ after: now
792
+ }
782
793
  }
783
794
  },
784
- required: true,
785
795
  onChange: function onChange(value) {
786
796
  return formik.setFieldValue("birthday", value);
787
797
  },
@@ -8,15 +8,32 @@ export declare type InputPropsLocale = {
8
8
  decrement?: string;
9
9
  };
10
10
  export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "checked" | "defaultChecked"> {
11
+ /**
12
+ * Define the type of the `Input`.
13
+ * @default "text"
14
+ */
11
15
  type?: "text" | "number" | "search" | "email" | "password";
16
+ /**
17
+ * Define the variant of the `Input`.
18
+ * @default "medium"
19
+ */
12
20
  variant?: InputVariant;
21
+ /**
22
+ * Define the start icon of the `Input`.
23
+ */
13
24
  startIcon?: IconComponentType;
25
+ /**
26
+ * Define the end item of the `Input`.
27
+ */
14
28
  endItem?: ReactNode;
15
29
  /**
16
- * Define whether or not a "clear input" x button should show on hover
30
+ * Define whether or not a "clear input" x button should show on hover.
17
31
  * @default false
18
32
  */
19
33
  clearable?: boolean;
34
+ /**
35
+ * Define the locale of the `Input`.
36
+ */
20
37
  locale?: InputPropsLocale;
21
38
  }
22
39
  /**
@@ -116,9 +116,11 @@ var Input = exports.Input = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
116
116
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
117
117
  className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n input group\n ", "\n ", "\n "])), focused && "focusable-show", disabled && "input-disabled"), VARIANT_CLASSNAMES[variant], STATUS_CLASSNAMES[status], className),
118
118
  style: style,
119
- onClick: function onClick() {
120
- var _inputRef$current;
121
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
119
+ onClick: function onClick(e) {
120
+ if (e.currentTarget.contains(e.target)) {
121
+ var _inputRef$current;
122
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
123
+ }
122
124
  },
123
125
  children: [Icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
124
126
  className: (0, _satellitePrefixer["default"])(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["ml-4 shrink-0 ", ""])), disabled ? "text-grey-200" : focused ? "text-accent-600" : "text-grey-500"),
@@ -1,3 +1,69 @@
1
1
  import type { HTMLAttributes, InputHTMLAttributes } from "react";
2
- export declare type RadioButtonProps = HTMLAttributes<HTMLInputElement> & Pick<InputHTMLAttributes<HTMLInputElement>, "value" | "name" | "checked" | "defaultChecked" | "onChange" | "required" | "autoFocus" | "disabled">;
3
- export declare const RadioButton: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLInputElement> & Pick<InputHTMLAttributes<HTMLInputElement>, "name" | "value" | "defaultChecked" | "autoFocus" | "onChange" | "disabled" | "checked" | "required"> & import("react").RefAttributes<HTMLInputElement>>;
2
+ export declare type RadioButtonProps = HTMLAttributes<HTMLInputElement> & {
3
+ /**
4
+ * The value of the `RadioButton`.
5
+ */
6
+ value?: InputHTMLAttributes<HTMLInputElement>["value"];
7
+ /**
8
+ * The name of the `RadioButton`.
9
+ */
10
+ name?: InputHTMLAttributes<HTMLInputElement>["name"];
11
+ /**
12
+ * Whether the `RadioButton` is checked.
13
+ */
14
+ checked?: InputHTMLAttributes<HTMLInputElement>["checked"];
15
+ /**
16
+ * The default checked state of the `RadioButton`.
17
+ */
18
+ defaultChecked?: InputHTMLAttributes<HTMLInputElement>["defaultChecked"];
19
+ /**
20
+ * Event handler for when the `RadioButton`'s value changes.
21
+ */
22
+ onChange?: InputHTMLAttributes<HTMLInputElement>["onChange"];
23
+ /**
24
+ * Whether the `RadioButton` is required.
25
+ */
26
+ required?: InputHTMLAttributes<HTMLInputElement>["required"];
27
+ /**
28
+ * Whether the `RadioButton` should automatically receive focus when the page loads.
29
+ */
30
+ autoFocus?: InputHTMLAttributes<HTMLInputElement>["autoFocus"];
31
+ /**
32
+ * Whether the `RadioButton` is disabled.
33
+ */
34
+ disabled?: InputHTMLAttributes<HTMLInputElement>["disabled"];
35
+ };
36
+ export declare const RadioButton: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLInputElement> & {
37
+ /**
38
+ * The value of the `RadioButton`.
39
+ */
40
+ value?: InputHTMLAttributes<HTMLInputElement>["value"];
41
+ /**
42
+ * The name of the `RadioButton`.
43
+ */
44
+ name?: InputHTMLAttributes<HTMLInputElement>["name"];
45
+ /**
46
+ * Whether the `RadioButton` is checked.
47
+ */
48
+ checked?: InputHTMLAttributes<HTMLInputElement>["checked"];
49
+ /**
50
+ * The default checked state of the `RadioButton`.
51
+ */
52
+ defaultChecked?: InputHTMLAttributes<HTMLInputElement>["defaultChecked"];
53
+ /**
54
+ * Event handler for when the `RadioButton`'s value changes.
55
+ */
56
+ onChange?: InputHTMLAttributes<HTMLInputElement>["onChange"];
57
+ /**
58
+ * Whether the `RadioButton` is required.
59
+ */
60
+ required?: InputHTMLAttributes<HTMLInputElement>["required"];
61
+ /**
62
+ * Whether the `RadioButton` should automatically receive focus when the page loads.
63
+ */
64
+ autoFocus?: InputHTMLAttributes<HTMLInputElement>["autoFocus"];
65
+ /**
66
+ * Whether the `RadioButton` is disabled.
67
+ */
68
+ disabled?: InputHTMLAttributes<HTMLInputElement>["disabled"];
69
+ } & import("react").RefAttributes<HTMLInputElement>>;
@@ -1,30 +1,47 @@
1
- import type { ForwardRefExoticComponent, ReactNode, RefAttributes, VFC } from "react";
1
+ import type { ForwardRefExoticComponent, ReactNode, RefAttributes } from "react";
2
+ import { RadioGroupItem } from "./RadioGroupItem";
2
3
  export interface RadioGroupProps {
4
+ /**
5
+ * The id of the `RadioGroup`.
6
+ */
3
7
  id?: string;
4
- /** @ignore */
8
+ /**
9
+ * The class name of the `RadioGroup`.
10
+ */
5
11
  className?: string;
12
+ /**
13
+ * The name of the `RadioGroup`.
14
+ */
6
15
  name?: string;
16
+ /**
17
+ * The value of the `RadioGroup`.
18
+ */
7
19
  value: string;
20
+ /**
21
+ * Whether the `RadioGroup` is disabled.
22
+ */
8
23
  disabled?: boolean;
24
+ /**
25
+ * Whether the `RadioGroup` is required.
26
+ */
9
27
  required?: boolean;
10
28
  /**
11
- * `RadioGroupItem` text position
29
+ * The text position of the `RadioGroupItem`.
12
30
  * @default left
13
31
  */
14
32
  textPosition?: "left" | "right";
33
+ /**
34
+ * Event handler for when the `RadioGroup`'s value changes.
35
+ */
15
36
  onChange: (newValue: string) => void;
16
- children?: ReactNode;
17
- }
18
- export interface RadioGroupItemProps {
19
- value: string;
20
- disabled?: boolean;
21
- required?: boolean;
37
+ /**
38
+ * The children of the `RadioGroup`.
39
+ */
22
40
  children?: ReactNode;
23
41
  }
24
42
  export declare type RadioGroupComponent = ForwardRefExoticComponent<RadioGroupProps & RefAttributes<HTMLFieldSetElement>> & {
25
43
  Item: typeof RadioGroupItem;
26
44
  };
27
- export declare const RadioGroupItem: VFC<RadioGroupItemProps>;
28
45
  /**
29
46
  * The `RadioGroup` component presents mutually exclusive options, allowing users to make a single selection from a list.
30
47
  *
@@ -4,83 +4,26 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.RadioGroupItem = exports.RadioGroup = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
7
+ exports.RadioGroup = void 0;
9
8
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
10
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
10
  var _clsx = _interopRequireDefault(require("clsx"));
12
11
  var _react = require("react");
13
12
  var _Layout = require("../../Layout");
14
13
  var _satellitePrefixer = _interopRequireDefault(require("../../styles/helpers/satellitePrefixer"));
15
14
  var _uniqueId = require("../../utils/uniqueId");
16
15
  var _Field = require("../Field");
17
- var _RadioButton = require("./RadioButton");
18
16
  var _RadioGroupContext = require("./RadioGroupContext");
17
+ var _RadioGroupItem = require("./RadioGroupItem");
19
18
  var _jsxRuntime = require("react/jsx-runtime");
20
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
21
- var _excluded = ["value", "disabled", "required", "children"];
22
- var RadioGroupItem = exports.RadioGroupItem = function RadioGroupItem(_ref) {
23
- var value = _ref.value,
24
- disabled = _ref.disabled,
25
- required = _ref.required,
26
- children = _ref.children,
27
- props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
28
- var _useRadioGroupContext = (0, _RadioGroupContext.useRadioGroupContext)(),
29
- id = _useRadioGroupContext.id,
30
- name = _useRadioGroupContext.name,
31
- contextDisabled = _useRadioGroupContext.disabled,
32
- contextRequired = _useRadioGroupContext.required,
33
- _onChange = _useRadioGroupContext.onChange,
34
- contextValue = _useRadioGroupContext.value,
35
- _useRadioGroupContext2 = _useRadioGroupContext.textPosition,
36
- textPosition = _useRadioGroupContext2 === void 0 ? "left" : _useRadioGroupContext2,
37
- descriptionId = _useRadioGroupContext.descriptionId,
38
- state = _useRadioGroupContext.state,
39
- ref = _useRadioGroupContext.ref;
40
- var isFirstChild = props.childIndex === 0;
41
- var isInvalid = (state === null || state === void 0 ? void 0 : state.status) === "invalid";
42
- var checked = value === contextValue;
43
- disabled = contextDisabled || disabled;
44
- required = contextRequired || required;
45
- var labelId = (0, _react.useMemo)(
46
- // eslint-disable-next-line @algolia/stl/prefer-stl-helper
47
- function () {
48
- return (0, _uniqueId.uniqueId)("stl-radio-group-label-");
49
- }, []);
50
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
51
- className: (0, _satellitePrefixer["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n flex items-center justify-between\n min-h-10 px-4 py-2\n ", "\n ", "\n ", "\n ", ""])), disabled ? "text-grey-300" : "hover:bg-grey-100", disabled ? "cursor-not-allowed" : "cursor-pointer", textPosition === "right" && "flex-row-reverse", isInvalid && "hover:bg-red-50"),
52
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
53
- id: labelId,
54
- className: (0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["flex-1 truncate ", ""])), textPosition === "right" ? "ml-2" : "mr-2"),
55
- children: children
56
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioButton.RadioButton, {
57
- id: checked || isFirstChild && !contextValue ? id : undefined,
58
- className: (0, _satellitePrefixer["default"])(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["shrink-0 self-start mt-1"]))),
59
- value: value,
60
- checked: checked,
61
- name: name,
62
- onChange: function onChange() {
63
- if (!disabled && !checked) {
64
- _onChange(value);
65
- }
66
- },
67
- disabled: disabled,
68
- required: required,
69
- "aria-invalid": isInvalid,
70
- "aria-labelledby": labelId,
71
- "aria-describedby": descriptionId,
72
- ref: isFirstChild ? ref : undefined
73
- })]
74
- });
75
- };
76
-
19
+ var _templateObject, _templateObject2, _templateObject3;
77
20
  // This function is used to clone the children of the `RadioGroup` component
78
21
  // and pass the `childIndex` prop to the `RadioGroupItem` children.
79
22
  function applyChildIndexRecursively(children) {
80
23
  return _react.Children.map(children, function (child, index) {
81
24
  var _child$props;
82
25
  if (! /*#__PURE__*/(0, _react.isValidElement)(child)) return child;
83
- if (child.type === RadioGroupItem) {
26
+ if (child.type === _RadioGroupItem.RadioGroupItem) {
84
27
  return /*#__PURE__*/(0, _react.cloneElement)(child, {
85
28
  childIndex: index
86
29
  });
@@ -99,17 +42,17 @@ function applyChildIndexRecursively(children) {
99
42
  *
100
43
  * See the [Radio Group documentation page](https://satellite.algolia.com/components/controls/radio-group) for more information.
101
44
  */
102
- var RadioGroup = exports.RadioGroup = /*#__PURE__*/(0, _react.forwardRef)(function (_ref2, ref) {
103
- var id = _ref2.id,
104
- className = _ref2.className,
105
- name = _ref2.name,
106
- value = _ref2.value,
107
- disabled = _ref2.disabled,
108
- _ref2$required = _ref2.required,
109
- required = _ref2$required === void 0 ? false : _ref2$required,
110
- textPosition = _ref2.textPosition,
111
- children = _ref2.children,
112
- onChange = _ref2.onChange;
45
+ var RadioGroup = exports.RadioGroup = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
46
+ var id = _ref.id,
47
+ className = _ref.className,
48
+ name = _ref.name,
49
+ value = _ref.value,
50
+ disabled = _ref.disabled,
51
+ _ref$required = _ref.required,
52
+ required = _ref$required === void 0 ? false : _ref$required,
53
+ textPosition = _ref.textPosition,
54
+ children = _ref.children,
55
+ onChange = _ref.onChange;
113
56
  var _useState = (0, _react.useState)(function () {
114
57
  return (0, _uniqueId.uniqueId)("RadioGroupName-");
115
58
  }),
@@ -138,13 +81,13 @@ var RadioGroup = exports.RadioGroup = /*#__PURE__*/(0, _react.forwardRef)(functi
138
81
  };
139
82
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Layout.Card, {
140
83
  fullBleed: true,
141
- className: (0, _clsx["default"])(className, (0, _satellitePrefixer["default"])(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["border ", ""])), state.status === "invalid" ? "bg-red-100 border-red-700" : "border-transparent")),
84
+ className: (0, _clsx["default"])(className, (0, _satellitePrefixer["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["border ", ""])), state.status === "invalid" ? "bg-red-100 border-red-700" : "border-transparent")),
142
85
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_RadioGroupContext.RadioGroupContext.Provider, {
143
86
  value: contextValue,
144
87
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("fieldset", {
145
- className: (0, _satellitePrefixer["default"])(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["min-w-0"]))),
88
+ className: (0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["min-w-0"]))),
146
89
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
147
- className: (0, _satellitePrefixer["default"])(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["flex flex-col py-1"]))),
90
+ className: (0, _satellitePrefixer["default"])(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["flex flex-col py-1"]))),
148
91
  children: applyChildIndexRecursively(children)
149
92
  })
150
93
  })
@@ -152,4 +95,4 @@ var RadioGroup = exports.RadioGroup = /*#__PURE__*/(0, _react.forwardRef)(functi
152
95
  });
153
96
  });
154
97
  RadioGroup.displayName = "RadioGroup";
155
- RadioGroup.Item = RadioGroupItem;
98
+ RadioGroup.Item = _RadioGroupItem.RadioGroupItem;
@@ -0,0 +1,20 @@
1
+ import type { ReactNode, VFC } from "react";
2
+ export interface RadioGroupItemProps {
3
+ /**
4
+ * The value of the `RadioGroupItem`.
5
+ */
6
+ value: string;
7
+ /**
8
+ * Whether the `RadioGroupItem` is disabled.
9
+ */
10
+ disabled?: boolean;
11
+ /**
12
+ * Whether the `RadioGroupItem` is required.
13
+ */
14
+ required?: boolean;
15
+ /**
16
+ * The children of the `RadioGroupItem`.
17
+ */
18
+ children?: ReactNode;
19
+ }
20
+ export declare const RadioGroupItem: VFC<RadioGroupItemProps>;