@algolia/satellite 2.1.0 → 2.2.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 (53) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/Actions/Button/PolymorphicIconButton.d.ts +10 -2
  3. package/dist/cjs/Actions/Button/PolymorphicIconButton.js +8 -2
  4. package/dist/cjs/Actions/IconButtonWithFeedback/IconButtonWithFeedback.d.ts +68 -0
  5. package/dist/cjs/Actions/IconButtonWithFeedback/IconButtonWithFeedback.js +209 -0
  6. package/dist/cjs/Actions/SegmentedControl/SegmentedControl.d.ts +4 -4
  7. package/dist/cjs/Actions/index.d.ts +2 -0
  8. package/dist/cjs/Actions/index.js +19 -0
  9. package/dist/cjs/Fields/AutoComplete/AutoComplete.js +18 -5
  10. package/dist/cjs/Fields/AutoComplete/types.d.ts +4 -2
  11. package/dist/cjs/Fields/FilePicker/FilePicker.d.ts +10 -0
  12. package/dist/cjs/Fields/FilePicker/FilePicker.js +9 -2
  13. package/dist/cjs/Fields/Input/Input.js +1 -1
  14. package/dist/cjs/Fields/Input/Input.tailwind.js +7 -7
  15. package/dist/cjs/Fields/TextArea/TextArea.tailwind.js +7 -7
  16. package/dist/cjs/Overlay/MenuButton/MenuButton.d.ts +1 -1
  17. package/dist/cjs/Overlay/MenuButton/components/items/Item.d.ts +1 -1
  18. package/dist/cjs/Overlay/Modal/Modal.d.ts +1 -1
  19. package/dist/cjs/Overlay/Modal/Modal.js +17 -11
  20. package/dist/cjs/Overlay/Modal/Modal.tailwind.js +3 -0
  21. package/dist/cjs/Satellite/locale.d.ts +2 -0
  22. package/dist/cjs/Typography/Typography.tailwind.js +1 -1
  23. package/dist/cjs/utils/isCssPropertySupported.d.ts +1 -1
  24. package/dist/cjs/utils/prefersReducedMotion.js +1 -1
  25. package/dist/cjs/utils/useTimeoutFn.d.ts +2 -0
  26. package/dist/cjs/utils/useTimeoutFn.js +44 -0
  27. package/dist/esm/Actions/Button/PolymorphicIconButton.d.ts +10 -2
  28. package/dist/esm/Actions/Button/PolymorphicIconButton.js +8 -2
  29. package/dist/esm/Actions/IconButtonWithFeedback/IconButtonWithFeedback.d.ts +68 -0
  30. package/dist/esm/Actions/IconButtonWithFeedback/IconButtonWithFeedback.js +202 -0
  31. package/dist/esm/Actions/SegmentedControl/SegmentedControl.d.ts +4 -4
  32. package/dist/esm/Actions/index.d.ts +2 -0
  33. package/dist/esm/Actions/index.js +2 -2
  34. package/dist/esm/Fields/AutoComplete/AutoComplete.js +18 -5
  35. package/dist/esm/Fields/AutoComplete/types.d.ts +4 -2
  36. package/dist/esm/Fields/FilePicker/FilePicker.d.ts +10 -0
  37. package/dist/esm/Fields/FilePicker/FilePicker.js +9 -2
  38. package/dist/esm/Fields/Input/Input.js +1 -1
  39. package/dist/esm/Fields/Input/Input.tailwind.js +7 -9
  40. package/dist/esm/Fields/TextArea/TextArea.tailwind.js +7 -9
  41. package/dist/esm/Overlay/MenuButton/MenuButton.d.ts +1 -1
  42. package/dist/esm/Overlay/MenuButton/components/items/Item.d.ts +1 -1
  43. package/dist/esm/Overlay/Modal/Modal.d.ts +1 -1
  44. package/dist/esm/Overlay/Modal/Modal.js +17 -11
  45. package/dist/esm/Overlay/Modal/Modal.tailwind.js +3 -0
  46. package/dist/esm/Satellite/locale.d.ts +2 -0
  47. package/dist/esm/Typography/Typography.tailwind.js +1 -1
  48. package/dist/esm/utils/isCssPropertySupported.d.ts +1 -1
  49. package/dist/esm/utils/prefersReducedMotion.js +1 -1
  50. package/dist/esm/utils/useTimeoutFn.d.ts +2 -0
  51. package/dist/esm/utils/useTimeoutFn.js +38 -0
  52. package/dist/satellite.min.css +1 -1
  53. package/package.json +2 -1
@@ -0,0 +1,202 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
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 _excluded = ["icon", "successIcon", "errorIcon", "message", "tooltipDelay", "tooltipHideDelay", "tooltipSuccessMessageDuration", "tooltipErrorMessageDuration", "onClick", "onError", "locale"];
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
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 { useEffect, useState } from "react";
10
+ import useMountedState from "react-use/lib/useMountedState";
11
+ import { useSpinDelay } from "spin-delay";
12
+ import { IconButton } from "./../IconButton/IconButton";
13
+ import { AlertTriangleIcon, CheckIcon } from "./../../Icons";
14
+ import { useLocale } from "./../../Satellite";
15
+ import { useTimeoutFn } from "./../../utils/useTimeoutFn";
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ var DEFAULT_TOOLTIP_SHOW_DELAY = 250;
18
+ var DEFAULT_TOOLTIP_HIDE_DELAY = 500;
19
+ var DEFAULT_TOOLTIP_SUCCESS_MESSAGE_DURATION = 1000;
20
+ var DEFAULT_TOOLTIP_ERROR_MESSAGE_DURATION = 2000;
21
+
22
+ // Used in the tests but not re-exported externally.
23
+ export var RESET_STATUS_DELAY = 100;
24
+ var DEFAULT_ICON_WITH_BUTTON_FEEDBACK_LOCALE = {
25
+ success: "Success",
26
+ error: "Something went wrong",
27
+ loading: "Loading..."
28
+ };
29
+ /**
30
+ * A compact, icon-only button that displays contextual tooltips on hover and click, enhancing user understanding and confirmation.
31
+ *
32
+ * See the [IconButtonWithFeedback documentation page](https://zeroheight.com/8261d6576/p/70da74-icon-button-with-feedback) for more information.
33
+ */
34
+ export var IconButtonWithFeedback = function IconButtonWithFeedback(_ref) {
35
+ var iconProp = _ref.icon,
36
+ _ref$successIcon = _ref.successIcon,
37
+ successIcon = _ref$successIcon === void 0 ? CheckIcon : _ref$successIcon,
38
+ _ref$errorIcon = _ref.errorIcon,
39
+ errorIcon = _ref$errorIcon === void 0 ? AlertTriangleIcon : _ref$errorIcon,
40
+ message = _ref.message,
41
+ _ref$tooltipDelay = _ref.tooltipDelay,
42
+ tooltipDelay = _ref$tooltipDelay === void 0 ? DEFAULT_TOOLTIP_SHOW_DELAY : _ref$tooltipDelay,
43
+ _ref$tooltipHideDelay = _ref.tooltipHideDelay,
44
+ tooltipHideDelay = _ref$tooltipHideDelay === void 0 ? DEFAULT_TOOLTIP_HIDE_DELAY : _ref$tooltipHideDelay,
45
+ _ref$tooltipSuccessMe = _ref.tooltipSuccessMessageDuration,
46
+ tooltipSuccessMessageDuration = _ref$tooltipSuccessMe === void 0 ? DEFAULT_TOOLTIP_SUCCESS_MESSAGE_DURATION : _ref$tooltipSuccessMe,
47
+ _ref$tooltipErrorMess = _ref.tooltipErrorMessageDuration,
48
+ tooltipErrorMessageDuration = _ref$tooltipErrorMess === void 0 ? DEFAULT_TOOLTIP_ERROR_MESSAGE_DURATION : _ref$tooltipErrorMess,
49
+ onClick = _ref.onClick,
50
+ onError = _ref.onError,
51
+ propsLocale = _ref.locale,
52
+ props = _objectWithoutProperties(_ref, _excluded);
53
+ var contextLocale = useLocale("iconButtonWithFeedback");
54
+ var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_ICON_WITH_BUTTON_FEEDBACK_LOCALE), contextLocale), propsLocale);
55
+ var _useState = useState("idle"),
56
+ _useState2 = _slicedToArray(_useState, 2),
57
+ status = _useState2[0],
58
+ setStatus = _useState2[1];
59
+ var _useState3 = useState(false),
60
+ _useState4 = _slicedToArray(_useState3, 2),
61
+ showTooltip = _useState4[0],
62
+ setShowTooltip = _useState4[1];
63
+ var mounted = useMountedState();
64
+
65
+ // Use a delayed loading state to prevent flickering of the loading spinner.
66
+ var isLoading = useSpinDelay(status === "loading", {
67
+ delay: 200,
68
+ minDuration: 600
69
+ });
70
+
71
+ // Show the tooltip after a delay when the button is hovered/focused.
72
+ var _useTimeoutFn = useTimeoutFn(function () {
73
+ if (mounted()) setShowTooltip(true);
74
+ }, tooltipDelay, false),
75
+ _useTimeoutFn2 = _slicedToArray(_useTimeoutFn, 3),
76
+ cancelShowTooltip = _useTimeoutFn2[1],
77
+ scheduleShowTooltip = _useTimeoutFn2[2];
78
+
79
+ // Hide the tooltip after a delay when the button is unhovered/unfocused.
80
+ var _useTimeoutFn3 = useTimeoutFn(function () {
81
+ if (mounted()) setShowTooltip(false);
82
+ }, status === "error" ? tooltipErrorMessageDuration : tooltipSuccessMessageDuration, false),
83
+ _useTimeoutFn4 = _slicedToArray(_useTimeoutFn3, 3),
84
+ scheduleHideTooltip = _useTimeoutFn4[2];
85
+
86
+ // Reset the tooltip status after a delay when the tooltip is hidden.
87
+ var _useTimeoutFn5 = useTimeoutFn(function () {
88
+ if (mounted()) setStatus("idle");
89
+ }, tooltipHideDelay + RESET_STATUS_DELAY, false),
90
+ _useTimeoutFn6 = _slicedToArray(_useTimeoutFn5, 3),
91
+ scheduleResetStatus = _useTimeoutFn6[2];
92
+
93
+ // Auto-hide tooltip while showing success/error messages.
94
+ useEffect(function () {
95
+ if (status === "idle" || isLoading) return;
96
+ scheduleHideTooltip();
97
+ }, [status, isLoading, scheduleHideTooltip]);
98
+
99
+ // After tooltip fully fades out, go back to idle.
100
+ useEffect(function () {
101
+ if (showTooltip || status !== "success" && status !== "error") return;
102
+ scheduleResetStatus();
103
+ }, [showTooltip, status, scheduleResetStatus]);
104
+ var getTitle = function getTitle() {
105
+ if (isLoading) return locale.loading;
106
+ switch (status) {
107
+ case "success":
108
+ return locale.success;
109
+ case "error":
110
+ return locale.error;
111
+ default:
112
+ return message;
113
+ }
114
+ };
115
+ var getIcon = function getIcon() {
116
+ if (status === "error" && errorIcon) return errorIcon;
117
+ if (status === "success" && successIcon) return successIcon;
118
+ return iconProp;
119
+ };
120
+ var title = getTitle();
121
+ var icon = getIcon();
122
+ var handleClick = /*#__PURE__*/function () {
123
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(evt) {
124
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
125
+ while (1) switch (_context.prev = _context.next) {
126
+ case 0:
127
+ if (!evt.defaultPrevented) {
128
+ _context.next = 2;
129
+ break;
130
+ }
131
+ return _context.abrupt("return");
132
+ case 2:
133
+ cancelShowTooltip();
134
+ setStatus("loading");
135
+ setShowTooltip(true);
136
+ _context.prev = 5;
137
+ _context.next = 8;
138
+ return onClick === null || onClick === void 0 ? void 0 : onClick(evt);
139
+ case 8:
140
+ if (mounted()) {
141
+ _context.next = 10;
142
+ break;
143
+ }
144
+ return _context.abrupt("return");
145
+ case 10:
146
+ setStatus("success");
147
+ _context.next = 19;
148
+ break;
149
+ case 13:
150
+ _context.prev = 13;
151
+ _context.t0 = _context["catch"](5);
152
+ if (mounted()) {
153
+ _context.next = 17;
154
+ break;
155
+ }
156
+ return _context.abrupt("return");
157
+ case 17:
158
+ setStatus("error");
159
+ onError === null || onError === void 0 || onError(_context.t0);
160
+ case 19:
161
+ case "end":
162
+ return _context.stop();
163
+ }
164
+ }, _callee, null, [[5, 13]]);
165
+ }));
166
+ return function handleClick(_x) {
167
+ return _ref2.apply(this, arguments);
168
+ };
169
+ }();
170
+
171
+ // Common handler for pointer enter/focus
172
+ var handleShowTooltip = function handleShowTooltip(e) {
173
+ var _props$onPointerEnter, _props$onFocus;
174
+ // Call the original handler if provided
175
+ if (e.type === "pointerenter") (_props$onPointerEnter = props.onPointerEnter) === null || _props$onPointerEnter === void 0 || _props$onPointerEnter.call(props, e);
176
+ if (e.type === "focus") (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 || _props$onFocus.call(props, e);
177
+ if (isLoading || status !== "idle") return;
178
+ scheduleShowTooltip();
179
+ };
180
+
181
+ // Common handler for pointer leave/blur
182
+ var handleHideTooltip = function handleHideTooltip(e) {
183
+ var _props$onPointerLeave, _props$onBlur;
184
+ if (e.type === "pointerleave") (_props$onPointerLeave = props.onPointerLeave) === null || _props$onPointerLeave === void 0 || _props$onPointerLeave.call(props, e);
185
+ if (e.type === "blur") (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, e);
186
+ if (isLoading || status !== "idle") return;
187
+ cancelShowTooltip();
188
+ setShowTooltip(false);
189
+ };
190
+ return /*#__PURE__*/_jsx(IconButton, _objectSpread(_objectSpread({}, props), {}, {
191
+ title: title,
192
+ showTooltip: showTooltip,
193
+ tooltipHideDelay: tooltipHideDelay,
194
+ icon: icon,
195
+ loading: isLoading,
196
+ onClick: handleClick,
197
+ onPointerEnter: handleShowTooltip,
198
+ onPointerLeave: handleHideTooltip,
199
+ onFocus: handleShowTooltip,
200
+ onBlur: handleHideTooltip
201
+ }));
202
+ };
@@ -2,7 +2,7 @@ import type { ReactNode } from "react";
2
2
  import type { SegmentedControlSize } from "./types";
3
3
  export interface SegmentedControlProps {
4
4
  /**
5
- * The class name of the `Switch`.
5
+ * The class name of the `SegmentedControl`.
6
6
  */
7
7
  className?: string;
8
8
  /**
@@ -10,7 +10,7 @@ export interface SegmentedControlProps {
10
10
  */
11
11
  value: string;
12
12
  /**
13
- * Whether the `Switch` is disabled.
13
+ * Whether the `SegmentedControl` is disabled.
14
14
  */
15
15
  disabled?: boolean;
16
16
  /**
@@ -18,11 +18,11 @@ export interface SegmentedControlProps {
18
18
  */
19
19
  onChange: (value: string) => void;
20
20
  /**
21
- * The content of the `Switch`.
21
+ * The content of the `SegmentedControl`.
22
22
  */
23
23
  children: ReactNode;
24
24
  /**
25
- * The size of the `Switch`.
25
+ * The size of the `SegmentedControl`.
26
26
  */
27
27
  size?: SegmentedControlSize;
28
28
  /**
@@ -2,6 +2,8 @@ export * from "./Accordion/Accordion";
2
2
  export * from "./Button/Button";
3
3
  export * from "./ButtonGroup/ButtonGroup";
4
4
  export * from "./ButtonLink/ButtonLink";
5
+ export type { IconButtonWithFeedbackLocale, IconButtonWithFeedbackProps, } from "./IconButtonWithFeedback/IconButtonWithFeedback";
6
+ export { IconButtonWithFeedback } from "./IconButtonWithFeedback/IconButtonWithFeedback";
5
7
  export * from "./IconButton/IconButton";
6
8
  export * from "./IconButtonLink/IconButtonLink";
7
9
  export * from "./SegmentedControl";
@@ -2,9 +2,9 @@ export * from "./Accordion/Accordion";
2
2
  export * from "./Button/Button";
3
3
  export * from "./ButtonGroup/ButtonGroup";
4
4
  export * from "./ButtonLink/ButtonLink";
5
+ export { IconButtonWithFeedback } from "./IconButtonWithFeedback/IconButtonWithFeedback";
5
6
  export * from "./IconButton/IconButton";
6
7
  export * from "./IconButtonLink/IconButtonLink";
7
8
  export * from "./SegmentedControl";
8
9
  export * from "./ToggleButton/ToggleButton";
9
- export * from "./ToggleGroup/ToggleGroup";
10
- export {};
10
+ export * from "./ToggleGroup/ToggleGroup";
@@ -172,14 +172,14 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
172
172
  selectedItems: selectedItems,
173
173
  onSelectedItemsChange: function onSelectedItemsChange(changes) {
174
174
  if (typeof changes.selectedItems === "undefined") {
175
- onChange(null);
175
+ onChange(null, changes.type);
176
176
  } else if (multiple) {
177
177
  onChange(uniqBy(changes.selectedItems, function (i) {
178
178
  return i.value;
179
- }));
179
+ }), changes.type);
180
180
  } else {
181
181
  var _changes$selectedItem;
182
- onChange((_changes$selectedItem = changes.selectedItems[0]) !== null && _changes$selectedItem !== void 0 ? _changes$selectedItem : null);
182
+ onChange((_changes$selectedItem = changes.selectedItems[0]) !== null && _changes$selectedItem !== void 0 ? _changes$selectedItem : null, changes.type);
183
183
  }
184
184
  }
185
185
  });
@@ -195,6 +195,7 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
195
195
  });
196
196
  },
197
197
  defaultHighlightedIndex: 0,
198
+ isOpen: inputValue ? items.length > 0 ? undefined : true : undefined,
198
199
  getA11yStatusMessage: function getA11yStatusMessage(_ref2) {
199
200
  var isOpen = _ref2.isOpen,
200
201
  resultCount = _ref2.resultCount,
@@ -281,7 +282,13 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
281
282
  setInputFocused(true);
282
283
  },
283
284
  onBlur: function onBlur(evt) {
285
+ var _evt$relatedTarget;
284
286
  _onBlur === null || _onBlur === void 0 || _onBlur(evt);
287
+
288
+ // Do not update inputFocused if the blur is caused by the clear button
289
+ if (evt.relatedTarget instanceof Element && ((_evt$relatedTarget = evt.relatedTarget) === null || _evt$relatedTarget === void 0 ? void 0 : _evt$relatedTarget.getAttribute("aria-label")) === locale.clearInputButton) {
290
+ return;
291
+ }
285
292
  setInputFocused(false);
286
293
  },
287
294
  onKeyDown: function onKeyDown(evt) {
@@ -340,7 +347,8 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
340
347
  className: cx(stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["autocomplete-container"]))), inputFocused && stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["focusable-show"]))), variant === "large" && stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["autocomplete-large py-1"]))), disabled && stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["autocomplete-disabled"]))), isInvalid && stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["autocomplete-invalid"]))), noWrap && stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["autocomplete-nowrap"])))),
341
348
  onClick: function onClick() {
342
349
  var _inputRef$current;
343
- return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
350
+ (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.focus();
351
+ combobox.openMenu();
344
352
  },
345
353
  children: [Icon && /*#__PURE__*/_jsx(Icon, {
346
354
  className: cx(stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["mr-4 shrink-0"]))), stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["", ""])), disabled ? "text-grey-200" : inputFocused ? "text-accent-600" : "text-grey-500")),
@@ -390,7 +398,12 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
390
398
  }), showClearButton && /*#__PURE__*/_jsx("button", {
391
399
  type: "button",
392
400
  className: stl(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["w-6 h-6 flex items-center justify-center text-grey-500"]))),
393
- onClick: function onClick() {
401
+ onClick: function onClick(evt) {
402
+ var _inputRef$current2;
403
+ // We stop propagation to avoid calling the onClick handler of the container
404
+ // which would open the combobox
405
+ evt.stopPropagation();
406
+ (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.focus();
394
407
  setInternalInputValue("");
395
408
  multipleSelection.setSelectedItems([]);
396
409
  },
@@ -1,3 +1,4 @@
1
+ import type { UseMultipleSelectionStateChangeTypes } from "downshift";
1
2
  import type { ComponentType, FocusEventHandler, ForwardedRef, PropsWithChildren, ReactNode, RefObject } from "react";
2
3
  import type { IconComponentType } from "../../Icons";
3
4
  export declare type AutoCompleteVariant = "medium" | "large";
@@ -171,8 +172,9 @@ export interface AutoCompleteSingleProps<T extends Option = Option> extends Auto
171
172
  /**
172
173
  * The callback function that is called when the value of the `AutoComplete` changes.
173
174
  */
174
- onChange: (option: T | null) => void;
175
+ onChange: (option: T | null, changeType: AutoCompleteChangeTypes) => void;
175
176
  }
177
+ export declare type AutoCompleteChangeTypes = UseMultipleSelectionStateChangeTypes;
176
178
  export interface AutoCompleteMultiProps<T extends Option = Option> extends AutoCompleteBaseProps<T> {
177
179
  /**
178
180
  * Whether the `AutoComplete` is a multiple selection.
@@ -185,7 +187,7 @@ export interface AutoCompleteMultiProps<T extends Option = Option> extends AutoC
185
187
  /**
186
188
  * The callback function that is called when the value of the `AutoComplete` changes.
187
189
  */
188
- onChange: (option: T[] | null) => void;
190
+ onChange: (option: T[] | null, changeType: AutoCompleteChangeTypes) => void;
189
191
  }
190
192
  export declare type AutoCompleteProps<T extends Option = Option> = AutoCompleteMultiProps<T> | AutoCompleteSingleProps<T>;
191
193
  declare type OptionsValue = string | number | boolean;
@@ -5,6 +5,11 @@ export declare type FilePickerLocale = {
5
5
  };
6
6
  export declare type FilePickerProps = DropzoneProps & {
7
7
  locale?: FilePickerLocale;
8
+ /**
9
+ * Whether the picked files can be cleared.
10
+ * @default true
11
+ */
12
+ clearable?: boolean;
8
13
  };
9
14
  /**
10
15
  * The `FilePicker` component allows users to select multiple files for attachment, supporting both drag-and-drop and browse options.
@@ -13,4 +18,9 @@ export declare type FilePickerProps = DropzoneProps & {
13
18
  */
14
19
  export declare const FilePicker: import("react").ForwardRefExoticComponent<import("../../Fields/Dropzone").DropzoneBaseProps & Omit<import("react-dropzone").DropzoneProps, "multiple" | "onDropAccepted" | "onDropRejected"> & {
15
20
  locale?: FilePickerLocale | undefined;
21
+ /**
22
+ * Whether the picked files can be cleared.
23
+ * @default true
24
+ */
25
+ clearable?: boolean | undefined;
16
26
  } & import("react").RefAttributes<HTMLElement>>;
@@ -1,7 +1,9 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
5
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
6
+ var _excluded = ["clearable"];
5
7
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
6
8
  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; }
7
9
  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; }
@@ -17,6 +19,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
19
  var FileCard = function FileCard(_ref) {
18
20
  var file = _ref.file,
19
21
  errors = _ref.errors,
22
+ clearable = _ref.clearable,
20
23
  removeFileTooltip = _ref.removeFileTooltip,
21
24
  onDelete = _ref.onDelete;
22
25
  var FileIcon = errors ? AlertTriangleIcon : FileTextIcon;
@@ -40,7 +43,7 @@ var FileCard = function FileCard(_ref) {
40
43
  children: formatHumanSize(file.size)
41
44
  })]
42
45
  })]
43
- }), /*#__PURE__*/_jsx(IconButton, {
46
+ }), clearable && /*#__PURE__*/_jsx(IconButton, {
44
47
  icon: TrashIcon,
45
48
  title: removeFileTooltip,
46
49
  size: "medium",
@@ -60,6 +63,9 @@ var DEFAULT_FILE_PICKER_LOCALE = {
60
63
  export var FilePicker = /*#__PURE__*/forwardRef(function (props, ref) {
61
64
  var contextLocale = useLocale("filePicker");
62
65
  var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_FILE_PICKER_LOCALE), contextLocale), props.locale);
66
+ var _props$clearable = props.clearable,
67
+ clearable = _props$clearable === void 0 ? true : _props$clearable,
68
+ dropzoneProps = _objectWithoutProperties(props, _excluded);
63
69
  var _useState = useState([]),
64
70
  _useState2 = _slicedToArray(_useState, 2),
65
71
  files = _useState2[0],
@@ -110,7 +116,7 @@ export var FilePicker = /*#__PURE__*/forwardRef(function (props, ref) {
110
116
  };
111
117
  return /*#__PURE__*/_jsxs("div", {
112
118
  className: stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["flex flex-col gap-4"]))),
113
- children: [/*#__PURE__*/_jsx(Dropzone, _objectSpread(_objectSpread({}, props), {}, {
119
+ children: [/*#__PURE__*/_jsx(Dropzone, _objectSpread(_objectSpread({}, dropzoneProps), {}, {
114
120
  ref: ref,
115
121
  onDrop: onDrop,
116
122
  hideFiles: true
@@ -121,6 +127,7 @@ export var FilePicker = /*#__PURE__*/forwardRef(function (props, ref) {
121
127
  errors = _ref5.errors;
122
128
  return /*#__PURE__*/_jsx(FileCard, {
123
129
  file: file,
130
+ clearable: clearable,
124
131
  errors: errors,
125
132
  removeFileTooltip: locale.removeFile,
126
133
  onDelete: function onDelete() {
@@ -116,7 +116,7 @@ export var Input = /*#__PURE__*/forwardRef(function (_ref, externalRef) {
116
116
  }
117
117
  },
118
118
  children: [Icon && /*#__PURE__*/_jsx(Icon, {
119
- className: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["ml-4 shrink-0 ", ""])), disabled ? "text-grey-200" : focused ? "text-accent-600" : "text-grey-500"),
119
+ className: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["ml-4 shrink-0 ", ""])), disabled ? "text-grey-300" : focused ? "text-accent-600" : "text-grey-500"),
120
120
  width: iconSize,
121
121
  height: iconSize
122
122
  }), /*#__PURE__*/_jsx("input", _objectSpread(_objectSpread({
@@ -1,10 +1,6 @@
1
- import _rgba from "../../styles/rgba";
2
- import _disabledColor from "../../styles/disabledColor";
3
1
  import _plugin from "tailwindcss/plugin";
4
2
  // @ts-check
5
3
  var plugin = _plugin;
6
- var disabledColor = _disabledColor;
7
- var rgba = _rgba;
8
4
  var inputPlugin = plugin(function (_ref) {
9
5
  var addComponents = _ref.addComponents,
10
6
  theme = _ref.theme;
@@ -19,7 +15,6 @@ var inputPlugin = plugin(function (_ref) {
19
15
  backgroundColor: theme("colors.white"),
20
16
  border: "1px solid ".concat(theme("colors.grey.500")),
21
17
  borderRadius: theme("borderRadius.DEFAULT"),
22
- boxShadow: "inset 0px 1px 4px 0px ".concat(rgba(theme("colors.grey.500"), 0.3)),
23
18
  overflow: "hidden",
24
19
  transition: "all 100ms ease-in-out",
25
20
  "&:not(.input-disabled, .focusable-show):hover": {
@@ -47,15 +42,18 @@ var inputPlugin = plugin(function (_ref) {
47
42
  "&::placeholder": {
48
43
  color: theme("colors.grey.600")
49
44
  }
45
+ },
46
+ "&:has(input:read-only:not(input:disabled))": {
47
+ backgroundColor: theme("colors.grey.100"),
48
+ borderColor: "transparent"
50
49
  }
51
50
  },
52
51
  ".input-disabled": {
53
52
  cursor: "not-allowed",
54
- background: "linear-gradient(-180deg, ".concat(theme("colors.white"), " 0%, ").concat(theme("colors.grey.100"), " 100%)"),
55
- borderColor: disabledColor(theme("colors.grey.200")),
56
- boxShadow: "none",
53
+ background: theme("colors.grey.100"),
54
+ borderColor: theme("colors.grey.200"),
57
55
  "input, input::placeholder": {
58
- color: theme("colors.grey.300"),
56
+ color: theme("colors.grey.600"),
59
57
  pointerEvents: "none"
60
58
  }
61
59
  },
@@ -1,10 +1,6 @@
1
- import _rgba from "../../styles/rgba";
2
- import _disabledColor from "../../styles/disabledColor";
3
1
  import _plugin from "tailwindcss/plugin";
4
2
  // @ts-check
5
3
  var plugin = _plugin;
6
- var disabledColor = _disabledColor;
7
- var rgba = _rgba;
8
4
  var textAreaPlugin = plugin(function (_ref) {
9
5
  var addComponents = _ref.addComponents,
10
6
  theme = _ref.theme;
@@ -15,7 +11,6 @@ var textAreaPlugin = plugin(function (_ref) {
15
11
  backgroundColor: theme("colors.white"),
16
12
  border: "1px solid ".concat(theme("colors.grey.500")),
17
13
  borderRadius: theme("borderRadius.DEFAULT"),
18
- boxShadow: "inset 0px 1px 4px 0px ".concat(rgba(theme("colors.grey.500"), 0.3)),
19
14
  transition: "all 100ms ease-in-out",
20
15
  fontSize: theme("fontSize.base"),
21
16
  lineHeight: theme("lineHeight.base"),
@@ -26,8 +21,11 @@ var textAreaPlugin = plugin(function (_ref) {
26
21
  borderColor: theme("colors.grey.600")
27
22
  },
28
23
  "&:has(textarea:disabled)": {
29
- borderColor: disabledColor(theme("colors.grey.200")),
30
- boxShadow: "none"
24
+ borderColor: theme("colors.grey.200")
25
+ },
26
+ "&:has(textarea:read-only:not(textarea:disabled))": {
27
+ backgroundColor: theme("colors.grey.100"),
28
+ borderColor: "transparent"
31
29
  }
32
30
  },
33
31
  ".text-area-invalid": {
@@ -56,8 +54,8 @@ var textAreaPlugin = plugin(function (_ref) {
56
54
  },
57
55
  "&:disabled": {
58
56
  cursor: "not-allowed",
59
- color: theme("colors.grey.300"),
60
- background: "linear-gradient(-180deg, ".concat(theme("colors.white"), " 0%, ").concat(theme("colors.grey.100"), " 100%)")
57
+ color: theme("colors.grey.600"),
58
+ background: theme("colors.grey.100")
61
59
  }
62
60
  },
63
61
  ".text-area-invalid:not(.text-area:disabled)": {
@@ -19,7 +19,7 @@ export declare const MenuButton: {
19
19
  Divider: import("react").ForwardRefExoticComponent<import("react").RefAttributes<HTMLDivElement>>;
20
20
  Item: import("react").ForwardRefExoticComponent<import("./useMenuItemProps").BaseItemProps<HTMLDivElement> & DropdownMenu.DropdownMenuItemProps & {
21
21
  startIcon?: import("../..").IconComponentType | undefined;
22
- variant?: "default" | "destructive" | undefined;
22
+ variant?: "destructive" | "default" | undefined;
23
23
  } & {
24
24
  children?: import("react").ReactNode;
25
25
  } & import("react").RefAttributes<HTMLDivElement>>;
@@ -19,7 +19,7 @@ export declare const Item: import("react").ForwardRefExoticComponent<BaseItemPro
19
19
  * Variant of the item
20
20
  * @default "default"
21
21
  */
22
- variant?: "default" | "destructive" | undefined;
22
+ variant?: "destructive" | "default" | undefined;
23
23
  } & {
24
24
  children?: import("react").ReactNode;
25
25
  } & import("react").RefAttributes<HTMLDivElement>>;
@@ -2,7 +2,7 @@ import type { FC, ReactNode } from "react";
2
2
  import { ModalFooter } from "./components/ModalFooter";
3
3
  import { ModalSection } from "./components/ModalSection";
4
4
  import type { XOR } from "../../types";
5
- export declare type ModalSizeVariant = "medium" | "large";
5
+ export declare type ModalSizeVariant = "small" | "medium" | "large";
6
6
  export declare type ModalLocale = {
7
7
  dismissText?: string;
8
8
  modalTitle?: string;
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
3
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15;
3
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
4
4
  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; }
5
5
  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; }
6
6
  import * as Dialog from "@radix-ui/react-dialog";
@@ -21,8 +21,14 @@ var DEFAULT_MODAL_LOCALE = {
21
21
  modalTitle: "Modal"
22
22
  };
23
23
  var SIZE_CLASSNAMES = {
24
- medium: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["modal-dialog-medium"]))),
25
- large: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["modal-dialog-large"])))
24
+ small: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["modal-dialog-small"]))),
25
+ medium: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["modal-dialog-medium"]))),
26
+ large: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["modal-dialog-large"])))
27
+ };
28
+ var SIZE_PADDING_CLASSNAMES = {
29
+ small: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["p-6"]))),
30
+ medium: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["p-8"]))),
31
+ large: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["p-10"])))
26
32
  };
27
33
 
28
34
  /**
@@ -70,10 +76,10 @@ export var Modal = function Modal(_ref) {
70
76
  asChild: true,
71
77
  children: triggerButton
72
78
  }), createPortal( /*#__PURE__*/_jsx(Dialog.Overlay, {
73
- className: cx(animate && !prefersReducedMotion && stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["modal-animated"]))), stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["modal-overlay bg-grey-900/30 z-modalOverlay inset-0 fixed w-full h-full flex items-start justify-center overflow-x-hidden overflow-y-auto px-4 py-10"])))),
79
+ className: cx(animate && !prefersReducedMotion && stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["modal-animated"]))), stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["modal-overlay bg-grey-900/30 z-modalOverlay inset-0 fixed w-full h-full flex items-start justify-center overflow-x-hidden overflow-y-auto px-4 py-10"])))),
74
80
  children: /*#__PURE__*/_jsx(Dialog.Content, {
75
81
  ref: dialogContentRef,
76
- className: cx(stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["modal-content"]))), SIZE_CLASSNAMES[size], centerY && stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["flex m-auto"])))),
82
+ className: cx(stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["modal-content"]))), SIZE_CLASSNAMES[size], centerY && stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["flex m-auto"])))),
77
83
  "aria-describedby": undefined,
78
84
  onOpenAutoFocus: function onOpenAutoFocus(e) {
79
85
  var _closeButtonRef$curre;
@@ -91,28 +97,28 @@ export var Modal = function Modal(_ref) {
91
97
  }
92
98
  },
93
99
  children: /*#__PURE__*/_jsx("div", {
94
- className: stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["modal-container"]))),
100
+ className: stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["modal-container"]))),
95
101
  children: /*#__PURE__*/_jsxs(Card, {
96
102
  as: "div",
97
103
  elevation: "500",
98
- className: cx(stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["relative"]))), className),
104
+ className: cx(stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["relative"]))), className),
99
105
  fullBleed: true,
100
106
  children: [/*#__PURE__*/_jsx("header", {
101
- className: cx(stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["min-h-14 flex items-center justify-between space-x-2"]))), title ? stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["border-b border-grey-100 pl-8 pr-16"]))) : stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["justify-end px-8"]))), !title && hideCloseIcon && stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["hidden"])))),
107
+ className: cx(stl(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["min-h-14 flex items-center justify-between space-x-2"]))), title ? stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["border-b border-grey-100 pl-8 pr-16"]))) : stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["justify-end px-8"]))), !title && hideCloseIcon && stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["hidden"])))),
102
108
  children: /*#__PURE__*/_jsx(Dialog.Title, {
103
109
  asChild: true,
104
110
  children: title ? /*#__PURE__*/_jsx("div", {
105
- className: stl(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["flex-1 display-heading truncate"]))),
111
+ className: stl(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["flex-1 display-heading truncate"]))),
106
112
  children: title
107
113
  }) : /*#__PURE__*/_jsx(VisuallyHidden, {
108
114
  children: locale.modalTitle
109
115
  })
110
116
  })
111
117
  }), /*#__PURE__*/_jsx("div", {
112
- className: cx(!fullBleed && stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["p-10"])))),
118
+ className: cx(!fullBleed && SIZE_PADDING_CLASSNAMES[size]),
113
119
  children: children
114
120
  }), !hideCloseIcon && /*#__PURE__*/_jsx("div", {
115
- className: stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["-mr-2 absolute top-3 right-8"]))),
121
+ className: stl(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["-mr-2 absolute top-3 right-8"]))),
116
122
  children: /*#__PURE__*/_jsx(Dialog.Close, {
117
123
  ref: closeButtonRef,
118
124
  asChild: true,
@@ -18,6 +18,9 @@ var modalPlugin = plugin(function (_ref) {
18
18
  }
19
19
  },
20
20
  // Sizes
21
+ ".modal-dialog-small": {
22
+ maxWidth: "480px"
23
+ },
21
24
  ".modal-dialog-medium": {
22
25
  maxWidth: "640px"
23
26
  },