@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
@@ -1,17 +1,39 @@
1
- export declare type ApplicationAvatarSize = "small" | "medium";
1
+ export declare const applicationAvatarSizes: readonly ["small", "medium"];
2
+ export declare type ApplicationAvatarSize = (typeof applicationAvatarSizes)[number];
2
3
  export declare type MinimalApplication = {
4
+ /**
5
+ * The application ID.
6
+ */
3
7
  applicationId: string;
8
+ /**
9
+ * The name of the application.
10
+ */
4
11
  name?: string;
5
12
  };
6
13
  declare type UserAvatarWithName = {
14
+ /**
15
+ * The name of the user.
16
+ */
7
17
  name: string;
18
+ /**
19
+ * The email of the user.
20
+ */
8
21
  email?: string;
9
22
  };
10
23
  declare type UserAvatarWithEmail = {
24
+ /**
25
+ * The email of the user.
26
+ */
11
27
  email: string;
28
+ /**
29
+ * The name of the user.
30
+ */
12
31
  name?: string;
13
32
  };
14
33
  export declare type MinimalUser = (UserAvatarWithName | UserAvatarWithEmail) & {
34
+ /**
35
+ * The avatar of the user.
36
+ */
15
37
  avatar?: string;
16
38
  };
17
39
  export {};
@@ -2,4 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+ exports.applicationAvatarSizes = void 0;
7
+ var applicationAvatarSizes = exports.applicationAvatarSizes = ["small", "medium"];
@@ -4,9 +4,13 @@ import { type IconComponentType } from "../../../Icons";
4
4
  export interface AutoCompleteEmptyStateProps {
5
5
  icon?: IconComponentType;
6
6
  variant?: MedallionVariant;
7
- /** Descriptive title for state */
7
+ /**
8
+ * Descriptive title for state
9
+ */
8
10
  title: ReactNode;
9
- /** Optional description to explain why the screen is empty or define next steps */
11
+ /**
12
+ * Optional description to explain why the screen is empty or define next steps
13
+ */
10
14
  description?: ReactNode;
11
15
  }
12
16
  export declare const AutoCompleteEmptyState: VFC<AutoCompleteEmptyStateProps>;
@@ -10,70 +10,209 @@ export declare type AutoCompleteLocale = {
10
10
  optionItemPrefix?: (multiple: boolean) => string;
11
11
  };
12
12
  export interface AutoCompleteBaseProps<T extends Option = Option> {
13
+ /**
14
+ * The id of the `AutoComplete`.
15
+ */
13
16
  id?: string;
17
+ /**
18
+ * The aria-label of the `AutoComplete`.
19
+ */
14
20
  "aria-label"?: string;
21
+ /**
22
+ * The label id of the `AutoComplete`.
23
+ */
15
24
  labelId?: string;
25
+ /**
26
+ * The icon of the `AutoComplete`.
27
+ */
16
28
  icon?: IconComponentType;
29
+ /**
30
+ * The name of the `AutoComplete`.
31
+ */
17
32
  name?: string;
33
+ /**
34
+ * Whether the `AutoComplete` is required.
35
+ * @default false
36
+ */
18
37
  required?: boolean;
38
+ /**
39
+ * The class name of the `AutoComplete`.
40
+ */
19
41
  className?: string;
42
+ /**
43
+ * The class name of the `AutoComplete` values.
44
+ */
20
45
  valuesClassName?: string;
46
+ /**
47
+ * The class name of the `AutoComplete` menu.
48
+ */
21
49
  menuClassName?: string;
50
+ /**
51
+ * The variant of the `AutoComplete`.
52
+ * @default "medium"
53
+ */
22
54
  variant?: AutoCompleteVariant;
55
+ /**
56
+ * The placeholder of the `AutoComplete`.
57
+ */
23
58
  placeholder?: string;
59
+ /**
60
+ * Whether the `AutoComplete` is disabled.
61
+ * @default false
62
+ */
24
63
  disabled?: boolean;
64
+ /**
65
+ * Whether the `AutoComplete` should be focused.
66
+ */
25
67
  autoFocus?: boolean;
68
+ /**
69
+ * The options of the `AutoComplete`.
70
+ */
26
71
  options?: T[];
72
+ /**
73
+ * The current value of the `AutoComplete`.
74
+ */
27
75
  inputValue?: string;
76
+ /**
77
+ * The callback function that is called when the text of the `AutoComplete` changes.
78
+ */
28
79
  onTextChange?: (text: string) => any;
80
+ /**
81
+ * The callback function that is called when the `AutoComplete` gains focus.
82
+ */
29
83
  onFocus?: FocusEventHandler<HTMLInputElement>;
84
+ /**
85
+ * The callback function that is called when the `AutoComplete` loses focus.
86
+ */
30
87
  onBlur?: FocusEventHandler<HTMLInputElement>;
88
+ /**
89
+ * Whether the `AutoComplete` is creatable.
90
+ */
31
91
  creatable?: boolean;
92
+ /**
93
+ * Whether the `AutoComplete` should clear the input value.
94
+ */
32
95
  clearable?: boolean;
96
+ /**
97
+ * Whether the `AutoComplete` should select the option on blur.
98
+ */
33
99
  selectOnBlur?: boolean;
100
+ /**
101
+ * The maximum number of results to display in the `AutoComplete` menu.
102
+ * @default 7
103
+ */
34
104
  maxResults?: number;
105
+ /**
106
+ * The function used to create options from the input value.
107
+ */
35
108
  createFromInputValue?: CreateFromInputValue<T>;
109
+ /**
110
+ * The keys used to split the input value into multiple options.
111
+ */
36
112
  separatorKeys?: string[];
113
+ /**
114
+ * The template used to render the value of the `AutoComplete`.
115
+ */
37
116
  renderValueTemplate?: (args: RenderValueTemplateArgs<T>) => JSX.Element;
117
+ /**
118
+ * The empty state of the `AutoComplete`.
119
+ */
38
120
  emptyState?: ReactNode;
121
+ /**
122
+ * The footer of the `AutoComplete` menu.
123
+ */
39
124
  menuFooter?: ReactNode;
125
+ /**
126
+ * The component used to render the option items.
127
+ */
40
128
  optionItemComponent?: OptionItemComponentType<T>;
41
- /** Keep the input on a single line */
129
+ /**
130
+ * Whether the input should be kept on a single line.
131
+ */
42
132
  noWrap?: boolean;
133
+ /**
134
+ * The end item of the `AutoComplete`.
135
+ */
43
136
  endItem?: ReactNode;
44
137
  /**
45
- * `medium` will display about 5 results in the dropdown; use `large` variant to display more
138
+ * The size of the `AutoComplete` menu.
139
+ * `medium` will display about 5 results in the dropdown; use `large` variant to display more.
46
140
  * @default "medium"
47
141
  */
48
142
  menuSize?: "medium" | "large";
143
+ /**
144
+ * The locale of the `AutoComplete`.
145
+ */
49
146
  locale?: AutoCompleteLocale;
50
- /** @deprecated Use of this props is discouraged and is only there for backwards compatibility */
147
+ /**
148
+ * @deprecated Use of this props is discouraged and is only there for backwards compatibility.
149
+ */
51
150
  internalsRef?: ForwardedRef<AutoCompleteInternals>;
52
151
  }
53
152
  export interface AutoCompleteInternals {
54
- /** Current internal inputValue */
153
+ /**
154
+ * Current internal inputValue
155
+ */
55
156
  inputValue: string;
56
- /** RefObject containing the underlying combobox input element */
157
+ /**
158
+ * RefObject containing the underlying combobox input element
159
+ */
57
160
  inputRef: RefObject<HTMLInputElement>;
58
161
  }
59
162
  export interface AutoCompleteSingleProps<T extends Option = Option> extends AutoCompleteBaseProps<T> {
163
+ /**
164
+ * Whether the `AutoComplete` is a multiple selection.
165
+ */
60
166
  multiple?: false;
167
+ /**
168
+ * The value of the `AutoComplete`.
169
+ */
61
170
  value?: T;
171
+ /**
172
+ * The callback function that is called when the value of the `AutoComplete` changes.
173
+ */
62
174
  onChange: (option: T | null) => void;
63
175
  }
64
176
  export interface AutoCompleteMultiProps<T extends Option = Option> extends AutoCompleteBaseProps<T> {
177
+ /**
178
+ * Whether the `AutoComplete` is a multiple selection.
179
+ */
65
180
  multiple: true;
181
+ /**
182
+ * The value of the `AutoComplete`.
183
+ */
66
184
  value?: T[];
185
+ /**
186
+ * The callback function that is called when the value of the `AutoComplete` changes.
187
+ */
67
188
  onChange: (option: T[] | null) => void;
68
189
  }
69
190
  export declare type AutoCompleteProps<T extends Option = Option> = AutoCompleteMultiProps<T> | AutoCompleteSingleProps<T>;
70
191
  declare type OptionsValue = string | number | boolean;
71
192
  export interface Option {
193
+ /**
194
+ * The value of the `Option`.
195
+ */
72
196
  value: OptionsValue;
197
+ /**
198
+ * The label of the `Option`.
199
+ */
73
200
  label: string;
201
+ /**
202
+ * The metadata of the `Option`.
203
+ */
74
204
  metadata?: string[];
205
+ /**
206
+ * Whether the `Option` is new.
207
+ */
75
208
  new?: boolean;
209
+ /**
210
+ * Whether the `Option` is disabled.
211
+ */
76
212
  disabled?: boolean;
213
+ /**
214
+ * Whether the `Option` should bypass the needle match.
215
+ */
77
216
  bypassNeedleMatch?: boolean;
78
217
  }
79
218
  export interface OptionItemProps<T extends Option = Option> {
@@ -1,13 +1,16 @@
1
1
  import type { HTMLAttributes, InputHTMLAttributes } from "react";
2
2
  declare type CheckboxCustomProps = {
3
3
  /**
4
- * `Checkbox` text position
4
+ * The text position of the `Checkbox`.
5
5
  * @default right
6
6
  */
7
7
  textPosition?: "left" | "right";
8
+ /**
9
+ * Whether the `Checkbox` is indeterminate.
10
+ */
8
11
  indeterminate?: boolean;
9
12
  /**
10
- * Color of the `Checkbox`
13
+ * The color of the `Checkbox` when it is checked.
11
14
  * @default accent.600
12
15
  */
13
16
  checkedColor?: string;
@@ -0,0 +1,47 @@
1
+ /// <reference types="react" />
2
+ import type { DatePickerProps } from "../DatePicker";
3
+ import type { InputProps } from "../Input";
4
+ declare type DateValue = Date | null;
5
+ export declare type DateInputLocale = {
6
+ tooltip?: (open: boolean) => string;
7
+ };
8
+ export interface DateInputProps extends Omit<InputProps, "type" | "defaultValue" | "value" | "onChange" | "locale" | "endItem"> {
9
+ /**
10
+ * Defines the default value of the `DateInput`.
11
+ */
12
+ defaultValue?: DateValue;
13
+ /**
14
+ * Defines the value of the `DateInput`.
15
+ */
16
+ value?: DateValue;
17
+ /**
18
+ * Defines the function to call when the `DateInput` value changes.
19
+ */
20
+ onChange?: (value: DateValue) => void;
21
+ /**
22
+ * Defines the format of the `DateInput` value.
23
+ * @default "MM/dd/yyyy"
24
+ */
25
+ valueFormat?: string;
26
+ /**
27
+ * Defines the separator of the `DateInput` value.
28
+ * @default "/"
29
+ */
30
+ separator?: string;
31
+ /**
32
+ * Defines the locale of the `DateInput`.
33
+ */
34
+ locale?: DateInputLocale;
35
+ /**
36
+ * Defines the props to pass to the `DatePicker`.
37
+ */
38
+ datePickerProps?: Omit<DatePickerProps, "value" | "onChange" | "renderTarget">;
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 declare const DateInput: import("react").ForwardRefExoticComponent<DateInputProps & import("react").RefAttributes<HTMLInputElement>>;
47
+ export {};
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DateInput = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
+ var _dateFns = require("date-fns");
13
+ var _react = require("react");
14
+ var _Actions = require("../../Actions");
15
+ var _Icons = require("../../Icons");
16
+ var _Satellite = require("../../Satellite");
17
+ var _satellitePrefixer = _interopRequireDefault(require("../../styles/helpers/satellitePrefixer"));
18
+ var _DatePicker = require("../DatePicker");
19
+ var _Input = require("../Input");
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+ var _templateObject, _templateObject2;
22
+ var _excluded = ["id", "defaultValue", "value", "onChange", "valueFormat", "placeholder", "separator", "locale", "datePickerProps"];
23
+ 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; }
24
+ 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) { (0, _defineProperty2["default"])(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; }
25
+ var DEFAULT_DATE_INPUT_LOCALE = {
26
+ tooltip: function tooltip(open) {
27
+ return "".concat(open ? "Close" : "Open", " date picker");
28
+ }
29
+ };
30
+ var NOW = new Date();
31
+ /**
32
+ * Parses and validates a date string
33
+ * @param {string} value - The date string to parse
34
+ * @param {string} format - The expected format of the date string
35
+ * @param {Date} referenceDate - A reference date to use for parsing
36
+ * @returns {Date | null} The parsed Date object if valid, null otherwise
37
+ */
38
+ var parseAndValidateDate = function parseAndValidateDate(value, format, referenceDate) {
39
+ var date = (0, _dateFns.parse)(value, format, referenceDate);
40
+ // See https://github.com/date-fns/date-fns/issues/942#issuecomment-516808982
41
+ if ((0, _dateFns.isValid)(date) && value.length === format.length) {
42
+ return date;
43
+ }
44
+ return null;
45
+ };
46
+
47
+ /**
48
+ * The `DateInput` component provides a date input field with an integrated date picker.
49
+ * It allows users to either type a date manually or select one from a calendar interface.
50
+ *
51
+ * See the [DateInput documentation page](https://satellite.algolia.com/components/forms/date-input) for more information.
52
+ */
53
+ var DateInput = exports.DateInput = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
54
+ var _ref2;
55
+ var id = _ref.id,
56
+ defaultValue = _ref.defaultValue,
57
+ controlledValue = _ref.value,
58
+ onChange = _ref.onChange,
59
+ _valueFormat = _ref.valueFormat,
60
+ _placeholder = _ref.placeholder,
61
+ _ref$separator = _ref.separator,
62
+ separator = _ref$separator === void 0 ? "/" : _ref$separator,
63
+ propsLocale = _ref.locale,
64
+ datePickerProps = _ref.datePickerProps,
65
+ inputProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
66
+ // Get localization from context and merge with props and defaults
67
+ var contextLocale = (0, _Satellite.useLocale)("dateInput");
68
+ var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_DATE_INPUT_LOCALE), contextLocale), propsLocale);
69
+
70
+ // Defaults
71
+ var valueFormat = _valueFormat || "MM".concat(separator, "dd").concat(separator, "yyyy");
72
+ var placeholder = _placeholder || "mm".concat(separator, "dd").concat(separator, "yyyy");
73
+
74
+ // State for input value and internal date value
75
+ var _useState = (0, _react.useState)(defaultValue ? (0, _dateFns.format)(defaultValue, valueFormat) : ""),
76
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
77
+ inputValue = _useState2[0],
78
+ setInputValue = _useState2[1];
79
+ var _useState3 = (0, _react.useState)((_ref2 = controlledValue !== null && controlledValue !== void 0 ? controlledValue : defaultValue) !== null && _ref2 !== void 0 ? _ref2 : null),
80
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
81
+ internalValue = _useState4[0],
82
+ setInternalValue = _useState4[1];
83
+ var isControlled = controlledValue !== undefined;
84
+ var rawValue = isControlled ? controlledValue : internalValue;
85
+ var value = rawValue ? (0, _dateFns.startOfDay)(rawValue) : null;
86
+ var oldValue = (0, _react.useRef)(value);
87
+
88
+ /**
89
+ * Handles changes to the `DateInput` input field
90
+ */
91
+ var handleInputChange = function handleInputChange(e) {
92
+ var value = e.currentTarget.value;
93
+ setInputValue(value);
94
+ var date = parseAndValidateDate(value, valueFormat, NOW);
95
+ setInternalValue(date);
96
+ onChange === null || onChange === void 0 || onChange(date);
97
+ };
98
+
99
+ /**
100
+ * Handles changes from the `DateInput` date picker
101
+ */
102
+ var handleDatePickerChange = function handleDatePickerChange(date) {
103
+ // We do this because the DatePicker call this callback twice
104
+ if (oldValue.current && date && (0, _dateFns.isEqual)(oldValue.current, date)) {
105
+ return;
106
+ }
107
+ oldValue.current = date;
108
+ if (!isControlled && date) {
109
+ setInternalValue(date);
110
+ setInputValue((0, _dateFns.format)(date, valueFormat));
111
+ }
112
+ onChange === null || onChange === void 0 || onChange(date);
113
+ };
114
+
115
+ /**
116
+ * Handles the `DateInput` value key up event
117
+ */
118
+ var handleInputKeyUp = function handleInputKeyUp(e) {
119
+ if (e.key === "Backspace" || e.key === "Delete") {
120
+ return;
121
+ }
122
+ var value = e.currentTarget.value;
123
+ var valueLength = value.length;
124
+ if (valueLength === 2 || valueLength === 5) {
125
+ setInputValue(function (v) {
126
+ return v + separator;
127
+ });
128
+ }
129
+ };
130
+
131
+ // Update input value when controlled value changes
132
+ (0, _react.useEffect)(function () {
133
+ if (isControlled && value) {
134
+ setInputValue((0, _dateFns.format)(value, valueFormat));
135
+ }
136
+ }, [isControlled, value, valueFormat]);
137
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.Input, _objectSpread(_objectSpread({
138
+ value: inputValue,
139
+ onChange: handleInputChange
140
+ }, inputProps), {}, {
141
+ type: "text",
142
+ onKeyUp: handleInputKeyUp,
143
+ ref: ref,
144
+ id: id,
145
+ placeholder: placeholder,
146
+ endItem: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker.DatePicker, _objectSpread(_objectSpread({}, datePickerProps), {}, {
147
+ renderTarget: function renderTarget(_ref3) {
148
+ var isOpen = _ref3.isOpen,
149
+ toggle = _ref3.toggle;
150
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Actions.IconButton, {
151
+ disabled: inputProps.disabled,
152
+ showTooltip: inputProps.disabled ? false : undefined,
153
+ variant: "subtle",
154
+ title: locale.tooltip(isOpen),
155
+ icon: _Icons.CalendarIcon,
156
+ className: (0, _satellitePrefixer["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["-mr-2"]))),
157
+ onClick: toggle
158
+ });
159
+ },
160
+ modalPlacement: (datePickerProps === null || datePickerProps === void 0 ? void 0 : datePickerProps.modalPlacement) || "bottom-end",
161
+ popoverAnchor: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
162
+ className: (0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["absolute inset-0 pointer-events-none"])))
163
+ }),
164
+ value: value,
165
+ onChange: handleDatePickerChange
166
+ }))
167
+ }));
168
+ });
169
+ DateInput.displayName = "DateInput";
@@ -0,0 +1 @@
1
+ export * from "./DateInput";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _DateInput = require("./DateInput");
7
+ Object.keys(_DateInput).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _DateInput[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _DateInput[key];
14
+ }
15
+ });
16
+ });
@@ -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
  /**
@@ -114,6 +114,7 @@ var DatePicker = exports.DatePicker = /*#__PURE__*/(0, _react.forwardRef)(functi
114
114
  evt.preventDefault();
115
115
  (_cancelElementRef$cur = cancelElementRef.current) === null || _cancelElementRef$cur === void 0 || _cancelElementRef$cur.focus();
116
116
  },
117
+ anchor: props.popoverAnchor,
117
118
  trigger: props.renderTarget ? props.renderTarget({
118
119
  toggle: state.show ? handleClose : handleOpen,
119
120
  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
  /**
@@ -195,6 +195,7 @@ var DateRangePicker = exports.DateRangePicker = function DateRangePicker(_ref2)
195
195
  evt.preventDefault();
196
196
  (_cancelElementRef$cur = cancelElementRef.current) === null || _cancelElementRef$cur === void 0 || _cancelElementRef$cur.focus();
197
197
  },
198
+ anchor: props.popoverAnchor,
198
199
  trigger: renderTarget ? renderTarget({
199
200
  toggle: state.show ? handleClose : handleOpen,
200
201
  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;