@algolia/satellite 1.10.1 → 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 (142) 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/Popover/types.d.ts +4 -0
  69. package/dist/cjs/Overlay/Tooltip/types.d.ts +3 -0
  70. package/dist/cjs/Satellite/locale.d.ts +2 -1
  71. package/dist/esm/Actions/Accordion/Accordion.d.ts +27 -18
  72. package/dist/esm/Actions/Button/Button.tailwind.js +27 -44
  73. package/dist/esm/Actions/Button/PolymorphicIconButton.d.ts +34 -5
  74. package/dist/esm/Actions/Button/types.d.ts +30 -9
  75. package/dist/esm/Actions/Button/types.js +1 -0
  76. package/dist/esm/Actions/ButtonGroup/ButtonGroup.d.ts +6 -1
  77. package/dist/esm/Actions/Switch/Switch.d.ts +21 -1
  78. package/dist/esm/Actions/Switch/SwitchOption.d.ts +9 -0
  79. package/dist/esm/Actions/Switch/types.d.ts +2 -1
  80. package/dist/esm/Actions/Switch/types.js +1 -1
  81. package/dist/esm/Actions/ToggleButton/ToggleButton.d.ts +9 -0
  82. package/dist/esm/Actions/ToggleButton/ToggleButtonBase.d.ts +33 -2
  83. package/dist/esm/Actions/ToggleButton/ToggleButtonBase.js +1 -1
  84. package/dist/esm/Actions/ToggleGroup/ToggleGroup.d.ts +18 -6
  85. package/dist/esm/Avatars/ApplicationAvatar/ApplicationAvatar.d.ts +10 -3
  86. package/dist/esm/Avatars/UserAvatar/UserAvatar.d.ts +13 -5
  87. package/dist/esm/Avatars/types.d.ts +23 -1
  88. package/dist/esm/Avatars/types.js +1 -1
  89. package/dist/esm/Fields/AutoComplete/components/AutoCompleteEmptyState.d.ts +6 -2
  90. package/dist/esm/Fields/AutoComplete/types.d.ts +144 -5
  91. package/dist/esm/Fields/Checkbox/Checkbox.d.ts +5 -2
  92. package/dist/esm/Fields/DateInput/DateInput.d.ts +47 -0
  93. package/dist/esm/Fields/DateInput/DateInput.js +162 -0
  94. package/dist/esm/Fields/DateInput/index.d.ts +1 -0
  95. package/dist/esm/Fields/DateInput/index.js +1 -0
  96. package/dist/esm/Fields/DatePicker/DatePicker/DatePicker.d.ts +42 -0
  97. package/dist/esm/Fields/DatePicker/DatePicker/DatePicker.js +1 -0
  98. package/dist/esm/Fields/DatePicker/DateRangePicker/DateRangePicker.d.ts +36 -0
  99. package/dist/esm/Fields/DatePicker/DateRangePicker/DateRangePicker.js +1 -0
  100. package/dist/esm/Fields/DatePicker/components/Popover.d.ts +1 -0
  101. package/dist/esm/Fields/DatePicker/components/Popover.js +5 -1
  102. package/dist/esm/Fields/DatePicker/types.d.ts +21 -0
  103. package/dist/esm/Fields/Dropzone/Dropzone.d.ts +85 -6
  104. package/dist/esm/Fields/Field/Field.d.ts +32 -9
  105. package/dist/esm/Fields/Form/stories/Complex.js +23 -13
  106. package/dist/esm/Fields/Input/Input.d.ts +18 -1
  107. package/dist/esm/Fields/Input/Input.js +5 -3
  108. package/dist/esm/Fields/RadioGroup/RadioButton.d.ts +68 -2
  109. package/dist/esm/Fields/RadioGroup/RadioGroup.d.ts +27 -10
  110. package/dist/esm/Fields/RadioGroup/RadioGroup.js +20 -77
  111. package/dist/esm/Fields/RadioGroup/RadioGroupItem.d.ts +20 -0
  112. package/dist/esm/Fields/RadioGroup/RadioGroupItem.js +64 -0
  113. package/dist/esm/Fields/RadioGroup/index.d.ts +1 -0
  114. package/dist/esm/Fields/RadioGroup/index.js +2 -1
  115. package/dist/esm/Fields/RangeSlider/RangeSlider.d.ts +48 -3
  116. package/dist/esm/Fields/Select/Select.d.ts +3 -0
  117. package/dist/esm/Fields/TextArea/TextArea.d.ts +16 -0
  118. package/dist/esm/Fields/Toggle/Toggle.d.ts +51 -3
  119. package/dist/esm/Fields/index.d.ts +1 -0
  120. package/dist/esm/Fields/index.js +1 -0
  121. package/dist/esm/Helpers/ClickAwayContainer/ClickAwayContainer.d.ts +6 -4
  122. package/dist/esm/Helpers/HelpUnderline/HelpUnderline.d.ts +9 -1
  123. package/dist/esm/Helpers/Medallion/Medallion.d.ts +14 -1
  124. package/dist/esm/Helpers/Medallion/Medallion.js +11 -10
  125. package/dist/esm/Helpers/Medallion/Medallion.tailwind.js +1 -1
  126. package/dist/esm/Helpers/Medallion/types.d.ts +1 -1
  127. package/dist/esm/Helpers/Separator/Separator.d.ts +10 -0
  128. package/dist/esm/Helpers/TextWrap/TextWrap.d.ts +8 -2
  129. package/dist/esm/Helpers/TextWrap/TextWrap.js +1 -1
  130. package/dist/esm/Helpers/UserContent/UserContent.d.ts +10 -1
  131. package/dist/esm/Icons/index.d.ts +1 -1
  132. package/dist/esm/Icons/index.js +1 -1
  133. package/dist/esm/Indicators/Badge/Badge.d.ts +6 -2
  134. package/dist/esm/Indicators/Tag/Tag.tailwind.js +13 -4
  135. package/dist/esm/Navigation/Stepper/Step.js +28 -25
  136. package/dist/esm/Overlay/MenuButton/components/CustomTrigger.d.ts +1 -1
  137. package/dist/esm/Overlay/MenuButton/components/CustomTrigger.js +12 -4
  138. package/dist/esm/Overlay/Popover/types.d.ts +4 -0
  139. package/dist/esm/Overlay/Tooltip/types.d.ts +3 -0
  140. package/dist/esm/Satellite/locale.d.ts +2 -1
  141. package/dist/satellite.min.css +1 -1
  142. package/package.json +3 -3
@@ -0,0 +1,162 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
+ var _templateObject, _templateObject2;
6
+ var _excluded = ["id", "defaultValue", "value", "onChange", "valueFormat", "placeholder", "separator", "locale", "datePickerProps"];
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ import { format, isEqual, isValid, parse, startOfDay } from "date-fns";
10
+ import { forwardRef, useEffect, useRef, useState } from "react";
11
+ import { IconButton } from "../../Actions";
12
+ import { CalendarIcon } from "../../Icons";
13
+ import { useLocale } from "../../Satellite";
14
+ import stl from "../../styles/helpers/satellitePrefixer";
15
+ import { DatePicker } from "../DatePicker";
16
+ import { Input } from "../Input";
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ var DEFAULT_DATE_INPUT_LOCALE = {
19
+ tooltip: function tooltip(open) {
20
+ return "".concat(open ? "Close" : "Open", " date picker");
21
+ }
22
+ };
23
+ var NOW = new Date();
24
+ /**
25
+ * Parses and validates a date string
26
+ * @param {string} value - The date string to parse
27
+ * @param {string} format - The expected format of the date string
28
+ * @param {Date} referenceDate - A reference date to use for parsing
29
+ * @returns {Date | null} The parsed Date object if valid, null otherwise
30
+ */
31
+ var parseAndValidateDate = function parseAndValidateDate(value, format, referenceDate) {
32
+ var date = parse(value, format, referenceDate);
33
+ // See https://github.com/date-fns/date-fns/issues/942#issuecomment-516808982
34
+ if (isValid(date) && value.length === format.length) {
35
+ return date;
36
+ }
37
+ return null;
38
+ };
39
+
40
+ /**
41
+ * The `DateInput` component provides a date input field with an integrated date picker.
42
+ * It allows users to either type a date manually or select one from a calendar interface.
43
+ *
44
+ * See the [DateInput documentation page](https://satellite.algolia.com/components/forms/date-input) for more information.
45
+ */
46
+ export var DateInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
47
+ var _ref2;
48
+ var id = _ref.id,
49
+ defaultValue = _ref.defaultValue,
50
+ controlledValue = _ref.value,
51
+ onChange = _ref.onChange,
52
+ _valueFormat = _ref.valueFormat,
53
+ _placeholder = _ref.placeholder,
54
+ _ref$separator = _ref.separator,
55
+ separator = _ref$separator === void 0 ? "/" : _ref$separator,
56
+ propsLocale = _ref.locale,
57
+ datePickerProps = _ref.datePickerProps,
58
+ inputProps = _objectWithoutProperties(_ref, _excluded);
59
+ // Get localization from context and merge with props and defaults
60
+ var contextLocale = useLocale("dateInput");
61
+ var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_DATE_INPUT_LOCALE), contextLocale), propsLocale);
62
+
63
+ // Defaults
64
+ var valueFormat = _valueFormat || "MM".concat(separator, "dd").concat(separator, "yyyy");
65
+ var placeholder = _placeholder || "mm".concat(separator, "dd").concat(separator, "yyyy");
66
+
67
+ // State for input value and internal date value
68
+ var _useState = useState(defaultValue ? format(defaultValue, valueFormat) : ""),
69
+ _useState2 = _slicedToArray(_useState, 2),
70
+ inputValue = _useState2[0],
71
+ setInputValue = _useState2[1];
72
+ var _useState3 = useState((_ref2 = controlledValue !== null && controlledValue !== void 0 ? controlledValue : defaultValue) !== null && _ref2 !== void 0 ? _ref2 : null),
73
+ _useState4 = _slicedToArray(_useState3, 2),
74
+ internalValue = _useState4[0],
75
+ setInternalValue = _useState4[1];
76
+ var isControlled = controlledValue !== undefined;
77
+ var rawValue = isControlled ? controlledValue : internalValue;
78
+ var value = rawValue ? startOfDay(rawValue) : null;
79
+ var oldValue = useRef(value);
80
+
81
+ /**
82
+ * Handles changes to the `DateInput` input field
83
+ */
84
+ var handleInputChange = function handleInputChange(e) {
85
+ var value = e.currentTarget.value;
86
+ setInputValue(value);
87
+ var date = parseAndValidateDate(value, valueFormat, NOW);
88
+ setInternalValue(date);
89
+ onChange === null || onChange === void 0 || onChange(date);
90
+ };
91
+
92
+ /**
93
+ * Handles changes from the `DateInput` date picker
94
+ */
95
+ var handleDatePickerChange = function handleDatePickerChange(date) {
96
+ // We do this because the DatePicker call this callback twice
97
+ if (oldValue.current && date && isEqual(oldValue.current, date)) {
98
+ return;
99
+ }
100
+ oldValue.current = date;
101
+ if (!isControlled && date) {
102
+ setInternalValue(date);
103
+ setInputValue(format(date, valueFormat));
104
+ }
105
+ onChange === null || onChange === void 0 || onChange(date);
106
+ };
107
+
108
+ /**
109
+ * Handles the `DateInput` value key up event
110
+ */
111
+ var handleInputKeyUp = function handleInputKeyUp(e) {
112
+ if (e.key === "Backspace" || e.key === "Delete") {
113
+ return;
114
+ }
115
+ var value = e.currentTarget.value;
116
+ var valueLength = value.length;
117
+ if (valueLength === 2 || valueLength === 5) {
118
+ setInputValue(function (v) {
119
+ return v + separator;
120
+ });
121
+ }
122
+ };
123
+
124
+ // Update input value when controlled value changes
125
+ useEffect(function () {
126
+ if (isControlled && value) {
127
+ setInputValue(format(value, valueFormat));
128
+ }
129
+ }, [isControlled, value, valueFormat]);
130
+ return /*#__PURE__*/_jsx(Input, _objectSpread(_objectSpread({
131
+ value: inputValue,
132
+ onChange: handleInputChange
133
+ }, inputProps), {}, {
134
+ type: "text",
135
+ onKeyUp: handleInputKeyUp,
136
+ ref: ref,
137
+ id: id,
138
+ placeholder: placeholder,
139
+ endItem: /*#__PURE__*/_jsx(DatePicker, _objectSpread(_objectSpread({}, datePickerProps), {}, {
140
+ renderTarget: function renderTarget(_ref3) {
141
+ var isOpen = _ref3.isOpen,
142
+ toggle = _ref3.toggle;
143
+ return /*#__PURE__*/_jsx(IconButton, {
144
+ disabled: inputProps.disabled,
145
+ showTooltip: inputProps.disabled ? false : undefined,
146
+ variant: "subtle",
147
+ title: locale.tooltip(isOpen),
148
+ icon: CalendarIcon,
149
+ className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["-mr-2"]))),
150
+ onClick: toggle
151
+ });
152
+ },
153
+ modalPlacement: (datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.modalPlacement) || "bottom-end",
154
+ popoverAnchor: /*#__PURE__*/_jsx("div", {
155
+ className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["absolute inset-0 pointer-events-none"])))
156
+ }),
157
+ value: value,
158
+ onChange: handleDatePickerChange
159
+ }))
160
+ }));
161
+ });
162
+ DateInput.displayName = "DateInput";
@@ -0,0 +1 @@
1
+ export * from "./DateInput";
@@ -0,0 +1 @@
1
+ export * from "./DateInput";
@@ -17,19 +17,61 @@ interface RenderTargetParams {
17
17
  isOpen: boolean;
18
18
  }
19
19
  export declare type DatePickerProps = {
20
+ /**
21
+ * The id of the `DatePicker`.
22
+ */
20
23
  id?: string;
24
+ /**
25
+ * The props of the `DatePicker` calendar.
26
+ */
21
27
  calendarProps?: Pick<DatePickerCalendarProps, "fromMonth" | "toMonth" | "disabled">;
28
+ /**
29
+ * The callback function that is called when the `DatePicker` is opened.
30
+ */
22
31
  onOpen?: DatePickerDisplayProps["onClick"];
32
+ /**
33
+ * The callback function that is called when the `DatePicker` is changed.
34
+ */
23
35
  onChange?: (value: Date | null) => void;
36
+ /**
37
+ * The callback function that is called when the `DatePicker` is submitted.
38
+ */
24
39
  onSubmit?: (event: MouseEvent<HTMLButtonElement>, value: Date | null) => void;
40
+ /**
41
+ * The callback function that is called when the `DatePicker` is canceled.
42
+ */
25
43
  onCancel?: DatePickerFooterActionsProps["onCancel"];
44
+ /**
45
+ * The callback function that is called to validate the `DatePicker`.
46
+ */
26
47
  validate?: (state: DatePickerReducerState) => Error[] | null;
48
+ /**
49
+ * The callback function that is called to render the left footer of the `DatePicker`.
50
+ */
27
51
  renderLeftFooter?: (args: LeftFooterComponentArgs) => ReactNode;
52
+ /**
53
+ * The callback function that is called to render the right panel of the `DatePicker`.
54
+ */
28
55
  renderRightPanel?: (args: RightSidePanelComponentArgs) => ReactNode;
56
+ /**
57
+ * The callback function that is called to render the target of the `DatePicker`.
58
+ */
29
59
  renderTarget?: (args: RenderTargetParams) => ReactNode;
60
+ /**
61
+ * The value of the `DatePicker`.
62
+ */
30
63
  value?: Date | null;
64
+ /**
65
+ * The initial value of the `DatePicker`.
66
+ */
31
67
  initialValue?: Date | null;
68
+ /**
69
+ * The size of the `DatePicker` button.
70
+ */
32
71
  buttonSize?: DatePickerDisplayProps["size"];
72
+ /**
73
+ * Whether the `DatePicker` is required.
74
+ */
33
75
  required?: boolean;
34
76
  } & SharedDatePickerProps;
35
77
  /**
@@ -107,6 +107,7 @@ export var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
107
107
  evt.preventDefault();
108
108
  (_cancelElementRef$cur = cancelElementRef.current) === null || _cancelElementRef$cur === void 0 || _cancelElementRef$cur.focus();
109
109
  },
110
+ anchor: props.popoverAnchor,
110
111
  trigger: props.renderTarget ? props.renderTarget({
111
112
  toggle: state.show ? handleClose : handleOpen,
112
113
  isOpen: state.show
@@ -18,17 +18,53 @@ interface RenderTargetParams {
18
18
  isOpen: boolean;
19
19
  }
20
20
  export declare type DateRangePickerProps = {
21
+ /**
22
+ * The id of the `DateRangePicker`.
23
+ */
21
24
  id?: string;
25
+ /**
26
+ * The range of the `DateRangePicker`.
27
+ */
22
28
  range: DateRangePickerTimeRange | null;
29
+ /**
30
+ * The ranges to only display in the `DateRangePicker`.
31
+ */
23
32
  displayOnlyRanges?: DateRangePickerTimeRange[];
33
+ /**
34
+ * The props of the `DateRangePicker` calendar.
35
+ */
24
36
  calendarProps?: Pick<DatePickerCalendarProps, "fromMonth" | "toMonth" | "disabled" | "numberOfMonths">;
37
+ /**
38
+ * The reducer of the `DateRangePicker`.
39
+ */
25
40
  stateReducer?: (state: DateRangePickerReducerState, action: DateRangePickerReducerAction, defaultReducer: typeof dateRangePickerReducer) => DateRangePickerReducerState;
41
+ /**
42
+ * The initial state of the `DateRangePicker`.
43
+ */
26
44
  initialState?: Partial<DateRangePickerReducerState>;
45
+ /**
46
+ * The callback function that is called when the `DateRangePicker` is changed.
47
+ */
27
48
  onAction?: (action: DateRangePickerReducerAction, state: DateRangePickerReducerState) => void;
49
+ /**
50
+ * The callback function that is called to validate the `DateRangePicker`.
51
+ */
28
52
  validate?: (state: DateRangePickerReducerState) => Error[] | null;
53
+ /**
54
+ * The callback function that is called to render the target of the `DateRangePicker`.
55
+ */
29
56
  renderTarget?: (args: RenderTargetParams) => ReactNode;
57
+ /**
58
+ * The callback function that is called to render the left footer of the `DateRangePicker`.
59
+ */
30
60
  renderLeftFooter?: (args: LeftFooterComponentArgs) => ReactNode;
61
+ /**
62
+ * The callback function that is called to render the right panel of the `DateRangePicker`.
63
+ */
31
64
  renderRightPanel?: (args: RightSidePanelComponentArgs) => ReactNode;
65
+ /**
66
+ * The size of the `DateRangePicker` button.
67
+ */
32
68
  buttonSize?: DateRangePickerDisplayProps["buttonSize"];
33
69
  } & SharedDatePickerProps;
34
70
  /**
@@ -188,6 +188,7 @@ export var DateRangePicker = function DateRangePicker(_ref2) {
188
188
  evt.preventDefault();
189
189
  (_cancelElementRef$cur = cancelElementRef.current) === null || _cancelElementRef$cur === void 0 || _cancelElementRef$cur.focus();
190
190
  },
191
+ anchor: props.popoverAnchor,
191
192
  trigger: renderTarget ? renderTarget({
192
193
  toggle: state.show ? handleClose : handleOpen,
193
194
  isOpen: state.show
@@ -5,6 +5,7 @@ export interface DatePickerPopoverProps {
5
5
  onOpenChange: (open: boolean) => void;
6
6
  trigger: ReactNode;
7
7
  children: ReactNode;
8
+ anchor?: ReactNode;
8
9
  placement?: Popover.PopoverContentProps["side"] | `${Popover.PopoverContentProps["side"] & string}-${Popover.PopoverContentProps["align"] & string}`;
9
10
  onOpenAutoFocus?: (event: Event) => void;
10
11
  title?: string;
@@ -11,6 +11,7 @@ export var DatePickerPopover = function DatePickerPopover(_ref) {
11
11
  onOpenChange = _ref.onOpenChange,
12
12
  trigger = _ref.trigger,
13
13
  children = _ref.children,
14
+ anchor = _ref.anchor,
14
15
  _ref$placement = _ref.placement,
15
16
  placement = _ref$placement === void 0 ? "bottom-start" : _ref$placement,
16
17
  onOpenAutoFocus = _ref.onOpenAutoFocus,
@@ -27,7 +28,10 @@ export var DatePickerPopover = function DatePickerPopover(_ref) {
27
28
  children: [/*#__PURE__*/_jsx(Popover.Trigger, {
28
29
  asChild: true,
29
30
  children: trigger
30
- }), createPortal( /*#__PURE__*/_jsx(Popover.Content, {
31
+ }), anchor ? /*#__PURE__*/_jsx(Popover.Anchor, {
32
+ asChild: true,
33
+ children: anchor
34
+ }) : null, createPortal( /*#__PURE__*/_jsx(Popover.Content, {
31
35
  side: side,
32
36
  sideOffset: 16,
33
37
  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
  /**
@@ -13,7 +13,7 @@ import * as yup from "yup";
13
13
  import { z } from "zod";
14
14
  import stl from "../../../styles/helpers/satellitePrefixer";
15
15
  import { Field } from "../../Field";
16
- import { AutoComplete, Checkbox, DatePicker, Dropzone } from "../../index";
16
+ import { AutoComplete, Checkbox, DateInput, Dropzone } from "../../index";
17
17
  import { Input } from "../../Input";
18
18
  import { RadioButton, RadioGroup } from "../../RadioGroup";
19
19
  import { RangeSlider } from "../../RangeSlider";
@@ -98,6 +98,10 @@ var zodSchema = z.object({
98
98
  message: "You must specify a birthday"
99
99
  };
100
100
  }
101
+ }).refine(function (val) {
102
+ return val < now;
103
+ }, {
104
+ message: "You must specify a birthday in the past"
101
105
  }),
102
106
  age: z.coerce.number().min(1, {
103
107
  message: "You must specify an age"
@@ -367,14 +371,16 @@ export var RHFComplexComponent = function RHFComplexComponent() {
367
371
  description: "Please specify your birthday",
368
372
  state: getFieldState("birthday"),
369
373
  className: stl(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["w-full"]))),
370
- children: /*#__PURE__*/_jsx(DatePicker, _objectSpread({
374
+ children: /*#__PURE__*/_jsx(DateInput, _objectSpread({
371
375
  id: "birthday",
372
- calendarProps: {
373
- disabled: {
374
- after: now
376
+ required: true,
377
+ datePickerProps: {
378
+ calendarProps: {
379
+ disabled: {
380
+ after: now
381
+ }
375
382
  }
376
- },
377
- required: true
383
+ }
378
384
  }, field))
379
385
  });
380
386
  }
@@ -573,7 +579,9 @@ var yupSchema = yup.object({
573
579
  value: yup.string()
574
580
  })).min(1, "You must specify at least one job position"),
575
581
  employmentStatus: yup.string().oneOf(employmentStatuses).required("You must specify an employment status"),
576
- birthday: yup.date().required("You must specify a birthday"),
582
+ birthday: yup.date().required("You must specify a birthday").test("birthday", "You must specify a birthday in the past", function (value) {
583
+ return value < now;
584
+ }),
577
585
  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"),
578
586
  interest: yup.number().min(5, "Your level of interest must be at least 5").required(),
579
587
  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(),
@@ -764,14 +772,16 @@ export var FormikComplexComponent = function FormikComplexComponent() {
764
772
  description: "Please specify your birthday",
765
773
  state: getFieldState("birthday"),
766
774
  className: stl(_templateObject38 || (_templateObject38 = _taggedTemplateLiteral(["w-full"]))),
767
- children: /*#__PURE__*/_jsx(DatePicker, {
775
+ children: /*#__PURE__*/_jsx(DateInput, {
768
776
  id: "birthday",
769
- calendarProps: {
770
- disabled: {
771
- after: now
777
+ required: true,
778
+ datePickerProps: {
779
+ calendarProps: {
780
+ disabled: {
781
+ after: now
782
+ }
772
783
  }
773
784
  },
774
- required: true,
775
785
  onChange: function onChange(value) {
776
786
  return formik.setFieldValue("birthday", value);
777
787
  },
@@ -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
  /**
@@ -109,9 +109,11 @@ export var Input = /*#__PURE__*/forwardRef(function (_ref, externalRef) {
109
109
  return /*#__PURE__*/_jsxs("div", {
110
110
  className: cx(stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n input group\n ", "\n ", "\n "])), focused && "focusable-show", disabled && "input-disabled"), VARIANT_CLASSNAMES[variant], STATUS_CLASSNAMES[status], className),
111
111
  style: style,
112
- onClick: function onClick() {
113
- var _inputRef$current;
114
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
112
+ onClick: function onClick(e) {
113
+ if (e.currentTarget.contains(e.target)) {
114
+ var _inputRef$current;
115
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
116
+ }
115
117
  },
116
118
  children: [Icon && /*#__PURE__*/_jsx(Icon, {
117
119
  className: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["ml-4 shrink-0 ", ""])), disabled ? "text-grey-200" : focused ? "text-accent-600" : "text-grey-500"),