@algolia/satellite 1.0.0-beta.165 → 1.0.0-beta.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/AutoComplete/AutoComplete.d.ts +1 -1
- package/cjs/AutoComplete/AutoComplete.js +28 -6
- package/cjs/AutoComplete/index.d.ts +1 -0
- package/cjs/AutoComplete/index.js +10 -1
- package/cjs/AutoComplete/types.d.ts +11 -1
- package/cjs/Badge/Badge.js +2 -1
- package/cjs/Banners/Alert/Alert.js +2 -1
- package/cjs/Button/PolymorphicButton.js +4 -2
- package/cjs/Button/PolymorphicIconButton.js +2 -1
- package/cjs/Checkbox/Checkbox.js +4 -2
- package/cjs/Dropdown/components/DropdownButtonItem.js +2 -1
- package/cjs/Dropdown/components/DropdownLinkItem.js +2 -1
- package/cjs/Dropdown/components/DropdownToggleItem.js +2 -1
- package/cjs/Dropzone/Dropzone.js +4 -2
- package/cjs/Field/Field.d.ts +3 -2
- package/cjs/Field/Field.js +18 -8
- package/cjs/Field/FieldContext.d.ts +16 -0
- package/cjs/Field/FieldContext.js +14 -0
- package/cjs/Field/index.d.ts +3 -2
- package/cjs/Field/index.js +14 -17
- package/cjs/Field/useField.d.ts +2 -0
- package/cjs/Field/useField.js +11 -0
- package/cjs/Input/Input.js +9 -5
- package/cjs/Link/Link.d.ts +2 -2
- package/cjs/Link/Link.js +4 -2
- package/cjs/ProgressBar/ProgressBar.d.ts +7 -4
- package/cjs/ProgressBar/ProgressBar.js +24 -16
- package/cjs/Sidebar/SidebarLinksGroup/SidebarLinksGroup.js +2 -1
- package/cjs/types.d.ts +3 -3
- package/cjs/utils/clamp.d.ts +1 -0
- package/cjs/utils/clamp.js +9 -0
- package/cjs/utils/prefersReducedMotion.js +2 -1
- package/esm/AutoComplete/AutoComplete.d.ts +1 -1
- package/esm/AutoComplete/AutoComplete.js +29 -7
- package/esm/AutoComplete/index.d.ts +1 -0
- package/esm/AutoComplete/index.js +1 -0
- package/esm/AutoComplete/types.d.ts +11 -1
- package/esm/Badge/Badge.js +2 -1
- package/esm/Banners/Alert/Alert.js +2 -1
- package/esm/Button/PolymorphicButton.js +4 -2
- package/esm/Button/PolymorphicIconButton.js +2 -1
- package/esm/Checkbox/Checkbox.js +5 -3
- package/esm/Dropdown/components/DropdownButtonItem.js +2 -1
- package/esm/Dropdown/components/DropdownLinkItem.js +2 -1
- package/esm/Dropdown/components/DropdownToggleItem.js +2 -1
- package/esm/Dropzone/Dropzone.js +5 -3
- package/esm/Field/Field.d.ts +3 -2
- package/esm/Field/Field.js +18 -5
- package/esm/Field/FieldContext.d.ts +16 -0
- package/esm/Field/FieldContext.js +8 -0
- package/esm/Field/index.d.ts +3 -2
- package/esm/Field/index.js +2 -2
- package/esm/Field/useField.d.ts +2 -0
- package/esm/Field/useField.js +5 -0
- package/esm/Input/Input.js +9 -5
- package/esm/Link/Link.d.ts +2 -2
- package/esm/Link/Link.js +4 -2
- package/esm/ProgressBar/ProgressBar.d.ts +7 -4
- package/esm/ProgressBar/ProgressBar.js +21 -16
- package/esm/Sidebar/SidebarLinksGroup/SidebarLinksGroup.js +2 -1
- package/esm/types.d.ts +3 -3
- package/esm/utils/clamp.d.ts +1 -0
- package/esm/utils/clamp.js +3 -0
- package/esm/utils/prefersReducedMotion.js +2 -1
- package/package.json +2 -1
- package/satellite.min.css +1 -1
- package/cjs/Field/FieldStateContext.d.ts +0 -12
- package/cjs/Field/FieldStateContext.js +0 -12
- package/cjs/Field/useFieldState.d.ts +0 -2
- package/cjs/Field/useFieldState.js +0 -15
- package/esm/Field/FieldStateContext.d.ts +0 -12
- package/esm/Field/FieldStateContext.js +0 -6
- package/esm/Field/useFieldState.d.ts +0 -2
- package/esm/Field/useFieldState.js +0 -6
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
5
6
|
value: true
|
6
7
|
});
|
@@ -8,39 +9,46 @@ exports["default"] = exports.ProgressBar = void 0;
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
9
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
10
11
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
12
|
+
var Progress = _interopRequireWildcard(require("@radix-ui/react-progress"));
|
11
13
|
var _clsx = _interopRequireDefault(require("clsx"));
|
12
14
|
var _react = require("react");
|
13
15
|
var _satellitePrefixer = _interopRequireDefault(require("../styles/helpers/satellitePrefixer"));
|
16
|
+
var _clamp = require("../utils/clamp");
|
14
17
|
var _prefersReducedMotion = require("../utils/prefersReducedMotion");
|
15
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
16
|
-
var _templateObject, _templateObject2;
|
17
|
-
var _excluded = ["value", "className", "barClassName"];
|
19
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
20
|
+
var _excluded = ["value", "max", "className", "barClassName"];
|
21
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
18
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; }
|
19
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; }
|
20
25
|
/**
|
21
|
-
*
|
26
|
+
* A progress bar visually indicates the completion status of a task, updating in real-time to guide users.
|
22
27
|
*
|
23
|
-
*
|
24
|
-
* - You should indicate either a percentage or other numeric values (such as - 234/4092 queries processed)
|
28
|
+
* See the [Progress Bar documentation page](https://satellite.algolia.com/components/feedback/progress-bar) for more information.
|
25
29
|
*/
|
26
30
|
var ProgressBar = exports.ProgressBar = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
27
31
|
var value = _ref.value,
|
32
|
+
_ref$max = _ref.max,
|
33
|
+
max = _ref$max === void 0 ? 100 : _ref$max,
|
28
34
|
className = _ref.className,
|
29
35
|
barClassName = _ref.barClassName,
|
30
36
|
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
if (value < 0 || value > max) {
|
38
|
+
if (process.env.NODE_ENV !== "production") {
|
39
|
+
console.warn("ProgressBar: Invalid `value` of ".concat(value, ". The `value` prop must be between 0 and ").concat(max, " (`max` prop). The `value` has been clamped to the range of 0 to ").concat(max, "."));
|
40
|
+
}
|
41
|
+
value = (0, _clamp.clamp)(value, 0, max);
|
42
|
+
}
|
43
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Progress.Root, _objectSpread(_objectSpread({}, props), {}, {
|
44
|
+
ref: ref,
|
45
|
+
value: value,
|
46
|
+
max: max,
|
34
47
|
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["progress-bar"]))), className),
|
35
|
-
|
36
|
-
|
37
|
-
"aria-valuemin": 0,
|
38
|
-
"aria-valuemax": 100,
|
39
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
40
|
-
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["progress-bar-progress"]))), barClassName),
|
48
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Progress.Indicator, {
|
49
|
+
className: (0, _clsx["default"])((0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["progress-bar-progress transition-transform ease-in-out origin-left"]))), _prefersReducedMotion.prefersReducedMotion ? (0, _satellitePrefixer["default"])(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["duration-150"]))) : (0, _satellitePrefixer["default"])(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["duration-500"]))), barClassName),
|
41
50
|
style: {
|
42
|
-
|
43
|
-
transition: _prefersReducedMotion.prefersReducedMotion ? "width 150ms ease-in-out" : "width 500ms ease-in-out"
|
51
|
+
transform: "scaleX(".concat(value / max, ")")
|
44
52
|
}
|
45
53
|
})
|
46
54
|
}));
|
@@ -65,7 +65,8 @@ var SidebarLinksGroup = exports.SidebarLinksGroup = function SidebarLinksGroup(p
|
|
65
65
|
"aria-controls": contentId,
|
66
66
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(props.icon, {
|
67
67
|
className: (0, _satellitePrefixer["default"])(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["shrink-0 text-grey-500 mr-3"]))),
|
68
|
-
|
68
|
+
width: "1rem",
|
69
|
+
height: "1rem"
|
69
70
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
70
71
|
className: (0, _satellitePrefixer["default"])(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["truncate display-subheading uppercase text-grey-800 group-focus:text-accent-500 group-hover:text-accent-500 mr-2"]))),
|
71
72
|
children: props.title
|
package/cjs/types.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import type {
|
2
|
-
export declare type IconProps =
|
3
|
-
export declare type IconComponentType =
|
1
|
+
import type { ComponentClass, SVGAttributes, VoidFunctionComponent } from "react";
|
2
|
+
export declare type IconProps = SVGAttributes<SVGElement>;
|
3
|
+
export declare type IconComponentType = VoidFunctionComponent<IconProps> | ComponentClass<IconProps>;
|
4
4
|
export declare type ColorVariant = "accent" | "grey" | "green" | "blue" | "orange" | "red";
|
5
5
|
/**
|
6
6
|
* Ensures at least one type is required
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function clamp(val: number, min: number, max: number): number;
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.prefersReducedMotion = void 0;
|
7
|
+
var _window$matchMedia, _window;
|
7
8
|
/**
|
8
9
|
* Checks if the user has `prefers-reduced-motion` enabled
|
9
10
|
*
|
10
11
|
* @returns {boolean}
|
11
12
|
*/
|
12
|
-
var prefersReducedMotion = exports.prefersReducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches === true;
|
13
|
+
var prefersReducedMotion = exports.prefersReducedMotion = typeof window !== "undefined" && ((_window$matchMedia = (_window = window).matchMedia) === null || _window$matchMedia === void 0 ? void 0 : _window$matchMedia.call(_window, "(prefers-reduced-motion: reduce)").matches) === true;
|
@@ -16,5 +16,5 @@ import type { AutoCompleteProps, Option } from "./types";
|
|
16
16
|
* - Provide matching results quickly
|
17
17
|
* - Style different data
|
18
18
|
*/
|
19
|
-
export declare const AutoComplete: <O extends Option = Option>({ locale: localeProp, id, name, placeholder, autoFocus, inputValue: inputValueProp, onTextChange, onFocus, onBlur, disabled, clearable, renderValueTemplate, noWrap, separatorKeys, multiple, value, selectOnBlur, onChange, options, optionItemComponent, creatable, createFromInputValue, emptyState, maxResults: maxItems, menuFooter, menuSize, variant, icon: Icon, endItem, className, menuClassName, valuesClassName, }: AutoCompleteProps<O>) => JSX.Element;
|
19
|
+
export declare const AutoComplete: <O extends Option = Option>({ locale: localeProp, id, labelId, "aria-label": ariaLabel, name, placeholder, autoFocus, inputValue: inputValueProp, onTextChange, onFocus, onBlur, disabled, clearable, renderValueTemplate, noWrap, separatorKeys, multiple, value, selectOnBlur, onChange, options, optionItemComponent, creatable, createFromInputValue, emptyState, maxResults: maxItems, menuFooter, menuSize, variant, icon: Icon, endItem, className, menuClassName, valuesClassName, internalsRef, }: AutoCompleteProps<O>) => JSX.Element;
|
20
20
|
export default AutoComplete;
|
@@ -13,7 +13,7 @@ import { usePopper } from "react-popper";
|
|
13
13
|
import useMeasure from "react-use/lib/useMeasure";
|
14
14
|
import { Card } from "../Card";
|
15
15
|
import { ClickAwayContainer } from "../ClickAwayContainer";
|
16
|
-
import {
|
16
|
+
import { useField } from "../Field";
|
17
17
|
import { useCreatePortal, useLocale } from "../Satellite";
|
18
18
|
import ScrollIndicator from "../ScrollIndicator";
|
19
19
|
import stl from "../styles/helpers/satellitePrefixer";
|
@@ -36,6 +36,13 @@ var MENU_POPPER_OPTIONS = {
|
|
36
36
|
}]
|
37
37
|
};
|
38
38
|
var SHOW_ALL_ITEMS_ID = "__stl_extra_results_option__";
|
39
|
+
var updateRef = function updateRef(ref, value) {
|
40
|
+
if (typeof ref === "function") {
|
41
|
+
ref(value);
|
42
|
+
} else if (ref) {
|
43
|
+
ref.current = value;
|
44
|
+
}
|
45
|
+
};
|
39
46
|
|
40
47
|
/**
|
41
48
|
* Autocomplete is a search-as-you-type function that matches what a person types, usually the beginning of a word, or a prefix, with a word list. Not to be confused with auto-suggestion that predicts the end of a query.
|
@@ -56,6 +63,8 @@ var SHOW_ALL_ITEMS_ID = "__stl_extra_results_option__";
|
|
56
63
|
export var AutoComplete = function AutoComplete(_ref) {
|
57
64
|
var localeProp = _ref.locale,
|
58
65
|
id = _ref.id,
|
66
|
+
labelId = _ref.labelId,
|
67
|
+
ariaLabel = _ref["aria-label"],
|
59
68
|
name = _ref.name,
|
60
69
|
placeholder = _ref.placeholder,
|
61
70
|
autoFocus = _ref.autoFocus,
|
@@ -87,10 +96,12 @@ export var AutoComplete = function AutoComplete(_ref) {
|
|
87
96
|
endItem = _ref.endItem,
|
88
97
|
className = _ref.className,
|
89
98
|
menuClassName = _ref.menuClassName,
|
90
|
-
valuesClassName = _ref.valuesClassName
|
99
|
+
valuesClassName = _ref.valuesClassName,
|
100
|
+
internalsRef = _ref.internalsRef;
|
91
101
|
var createPortal = useCreatePortal();
|
92
|
-
var
|
93
|
-
status =
|
102
|
+
var _useField = useField(),
|
103
|
+
status = _useField.state.status,
|
104
|
+
fieldLabelId = _useField.labelId;
|
94
105
|
var localeContext = useLocale("autoComplete");
|
95
106
|
var locale = useMemo(function () {
|
96
107
|
return _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_AUTOCOMPLETE_LOCALE), localeContext), localeProp);
|
@@ -158,6 +169,8 @@ export var AutoComplete = function AutoComplete(_ref) {
|
|
158
169
|
}
|
159
170
|
});
|
160
171
|
var combobox = useCombobox({
|
172
|
+
inputId: id,
|
173
|
+
labelId: labelId !== null && labelId !== void 0 ? labelId : fieldLabelId,
|
161
174
|
items: items,
|
162
175
|
itemToString: optionToString,
|
163
176
|
scrollIntoView: function scrollIntoView(node) {
|
@@ -238,7 +251,9 @@ export var AutoComplete = function AutoComplete(_ref) {
|
|
238
251
|
return Boolean(item.disabled);
|
239
252
|
}
|
240
253
|
});
|
241
|
-
var inputProps = combobox.getInputProps(
|
254
|
+
var inputProps = combobox.getInputProps(_objectSpread({
|
255
|
+
"aria-label": ariaLabel
|
256
|
+
}, multipleSelection.getDropdownProps({
|
242
257
|
ref: inputRef,
|
243
258
|
autoFocus: autoFocus,
|
244
259
|
disabled: disabled,
|
@@ -270,7 +285,7 @@ export var AutoComplete = function AutoComplete(_ref) {
|
|
270
285
|
}
|
271
286
|
}
|
272
287
|
}
|
273
|
-
}));
|
288
|
+
})));
|
274
289
|
useEffect(function () {
|
275
290
|
if (!combobox.isOpen) return;
|
276
291
|
if (items.length === 0 && combobox.highlightedIndex >= 0) {
|
@@ -290,6 +305,12 @@ export var AutoComplete = function AutoComplete(_ref) {
|
|
290
305
|
}));
|
291
306
|
};
|
292
307
|
}, [optionItemComponent, locale]);
|
308
|
+
useEffect(function () {
|
309
|
+
updateRef(internalsRef, {
|
310
|
+
inputRef: inputRef,
|
311
|
+
inputValue: inputValue
|
312
|
+
});
|
313
|
+
}, [inputRef, internalsRef, inputValue]);
|
293
314
|
return /*#__PURE__*/_jsx(AutocompleteProvider, {
|
294
315
|
children: /*#__PURE__*/_jsxs("div", {
|
295
316
|
className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["flex"]))), className),
|
@@ -306,7 +327,8 @@ export var AutoComplete = function AutoComplete(_ref) {
|
|
306
327
|
},
|
307
328
|
children: [Icon && /*#__PURE__*/_jsx(Icon, {
|
308
329
|
className: cx(stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["mr-4 shrink-0"]))), stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["", ""])), disabled ? "text-grey-200" : inputFocused ? "text-accent-600" : "text-grey-500")),
|
309
|
-
|
330
|
+
width: "1rem",
|
331
|
+
height: "1rem"
|
310
332
|
}), /*#__PURE__*/_jsxs("div", {
|
311
333
|
className: cx(stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["flex items-center flex-1 max-h-full"]))), !noWrap && stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["flex-wrap overflow-y-scroll no-scrollbar"]))), multiple && stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["-ml-1"]))), valuesClassName),
|
312
334
|
children: [multiple && selectedItems.map(function (option, index) {
|
@@ -3,4 +3,5 @@ export * from "./components/DefaultOptionItem";
|
|
3
3
|
export * from "./components/AutoCompleteEmptyState";
|
4
4
|
export * from "./components/AutocompleteContext";
|
5
5
|
export * from "./types";
|
6
|
+
export { defaultCreateFromInputValue } from "./utils";
|
6
7
|
export { default } from "./AutoComplete";
|
@@ -3,4 +3,5 @@ export * from "./components/DefaultOptionItem";
|
|
3
3
|
export * from "./components/AutoCompleteEmptyState";
|
4
4
|
export * from "./components/AutocompleteContext";
|
5
5
|
export * from "./types";
|
6
|
+
export { defaultCreateFromInputValue } from "./utils";
|
6
7
|
export { default } from "./AutoComplete";
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ComponentType, FocusEventHandler, ReactNode } from "react";
|
1
|
+
import type { ComponentType, FocusEventHandler, ForwardedRef, ReactNode, RefObject } from "react";
|
2
2
|
import type { IconComponentType } from "../types";
|
3
3
|
export declare type AutoCompleteVariant = "medium" | "large";
|
4
4
|
export declare type AutoCompleteLocale = {
|
@@ -11,6 +11,8 @@ export declare type AutoCompleteLocale = {
|
|
11
11
|
};
|
12
12
|
export interface AutoCompleteBaseProps<T extends Option = Option> {
|
13
13
|
id?: string;
|
14
|
+
"aria-label"?: string;
|
15
|
+
labelId?: string;
|
14
16
|
icon?: IconComponentType;
|
15
17
|
name?: string;
|
16
18
|
className?: string;
|
@@ -44,6 +46,14 @@ export interface AutoCompleteBaseProps<T extends Option = Option> {
|
|
44
46
|
*/
|
45
47
|
menuSize?: "medium" | "large";
|
46
48
|
locale?: AutoCompleteLocale;
|
49
|
+
/** @deprecated Use of this props is discouraged and is only there for backwards compatibility */
|
50
|
+
internalsRef?: ForwardedRef<AutoCompleteInternals>;
|
51
|
+
}
|
52
|
+
export interface AutoCompleteInternals {
|
53
|
+
/** Current internal inputValue */
|
54
|
+
inputValue: string;
|
55
|
+
/** RefObject containing the underlying combobox input element */
|
56
|
+
inputRef: RefObject<HTMLInputElement>;
|
47
57
|
}
|
48
58
|
export interface AutoCompleteSingleProps<T extends Option = Option> extends AutoCompleteBaseProps<T> {
|
49
59
|
multiple?: false;
|
package/esm/Badge/Badge.js
CHANGED
@@ -58,7 +58,8 @@ export var Badge = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
58
58
|
className: badgeClassName,
|
59
59
|
children: [Icon && /*#__PURE__*/_jsx("span", {
|
60
60
|
children: /*#__PURE__*/_jsx(Icon, {
|
61
|
-
|
61
|
+
width: ".8em",
|
62
|
+
height: ".8em"
|
62
63
|
})
|
63
64
|
}), isRenderedChild(children) && /*#__PURE__*/_jsx("span", {
|
64
65
|
className: stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["truncate"]))),
|
@@ -105,7 +105,8 @@ export var Alert = function Alert(_ref) {
|
|
105
105
|
style: style,
|
106
106
|
children: [/*#__PURE__*/_jsx(Icon, {
|
107
107
|
className: cx(stl(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["\n shrink-0 mr-2\n ", "\n "])), title ? "mt-0.5" : "mt-2px"), ICON_CLASSNAME_VARIANTS[variant]),
|
108
|
-
|
108
|
+
width: "1rem",
|
109
|
+
height: "1rem"
|
109
110
|
}), /*#__PURE__*/_jsxs("div", {
|
110
111
|
className: stl(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["flex flex-1 flex-col ", ""])), onDismiss && "mr-6"),
|
111
112
|
children: [!!title && /*#__PURE__*/_jsx("h4", {
|
@@ -53,13 +53,15 @@ export var PolymorphicButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
53
53
|
size: BUTTON_LOADER_ICON_SIZES[size],
|
54
54
|
thickness: 1
|
55
55
|
}), StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
56
|
-
|
56
|
+
width: ICON_SIZE,
|
57
|
+
height: ICON_SIZE,
|
57
58
|
className: cx(stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["shrink-0"]))), iconClassNames)
|
58
59
|
}), /*#__PURE__*/_jsx("span", {
|
59
60
|
className: cx(stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["truncate text-center px-1"]))), textClassNames),
|
60
61
|
children: children
|
61
62
|
}), EndIcon && /*#__PURE__*/_jsx(EndIcon, {
|
62
|
-
|
63
|
+
width: ICON_SIZE,
|
64
|
+
height: ICON_SIZE,
|
63
65
|
className: cx(stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["shrink-0"]))), iconClassNames)
|
64
66
|
})]
|
65
67
|
}));
|
@@ -71,7 +71,8 @@ export var PolymorphicIconButton = /*#__PURE__*/forwardRef(function (props, ref)
|
|
71
71
|
thickness: 1
|
72
72
|
}), /*#__PURE__*/_jsx(Icon, {
|
73
73
|
className: cx(loading && stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["invisible"])))),
|
74
|
-
|
74
|
+
width: "1em",
|
75
|
+
height: "1em"
|
75
76
|
})]
|
76
77
|
})
|
77
78
|
}))
|
package/esm/Checkbox/Checkbox.js
CHANGED
@@ -9,7 +9,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
9
9
|
import cx from "clsx";
|
10
10
|
import { forwardRef, useMemo, useState } from "react";
|
11
11
|
import { Check, Minus } from "react-feather";
|
12
|
-
import {
|
12
|
+
import { useField } from "../Field";
|
13
13
|
import stl from "../styles/helpers/satellitePrefixer";
|
14
14
|
import isRenderedChild from "../utils/isRenderedChild";
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
@@ -43,8 +43,9 @@ export var Checkbox = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
43
43
|
var id = useMemo(function () {
|
44
44
|
return checkboxProps.id || generateFieldId();
|
45
45
|
}, [checkboxProps.id]);
|
46
|
-
var
|
47
|
-
status =
|
46
|
+
var _useField = useField(),
|
47
|
+
status = _useField.state.status,
|
48
|
+
labelId = _useField.labelId;
|
48
49
|
var isControlled = typeof checked === "boolean";
|
49
50
|
var _useState = useState(Boolean(isControlled ? checked : defaultChecked)),
|
50
51
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -72,6 +73,7 @@ export var Checkbox = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
72
73
|
}), /*#__PURE__*/_jsx("input", _objectSpread(_objectSpread({}, checkboxProps), {}, {
|
73
74
|
"aria-checked": indeterminate ? "mixed" : isChecked,
|
74
75
|
id: id,
|
76
|
+
"aria-labelledby": labelId,
|
75
77
|
className: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n opacity-0 absolute inset-0\n ", "\n "])), disabled ? "cursor-not-allowed" : "cursor-pointer"),
|
76
78
|
type: "checkbox",
|
77
79
|
ref: ref,
|
@@ -24,7 +24,8 @@ export var DropdownButtonItem = function DropdownButtonItem(props) {
|
|
24
24
|
className: cx(mergedProps.className, stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["w-full"])))),
|
25
25
|
children: [StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
26
26
|
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mr-2 shrink-0 ", ""])), showDestructiveVariant ? "text-red-700" : "text-grey-500"),
|
27
|
-
|
27
|
+
width: "1rem",
|
28
|
+
height: "1rem"
|
28
29
|
}), /*#__PURE__*/_jsx("span", {
|
29
30
|
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["w-full truncate ", ""])), showDestructiveVariant && "text-red-700"),
|
30
31
|
children: children
|
@@ -29,7 +29,8 @@ export var DropdownLinkItem = function DropdownLinkItem(props) {
|
|
29
29
|
}, mergedProps), {}, {
|
30
30
|
children: [StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
31
31
|
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mr-2 shrink-0 text-grey-500"]))),
|
32
|
-
|
32
|
+
width: "1rem",
|
33
|
+
height: "1rem"
|
33
34
|
}), /*#__PURE__*/_jsx("span", {
|
34
35
|
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["w-full truncate"]))),
|
35
36
|
children: children
|
@@ -24,7 +24,8 @@ export var DropdownToggleItem = function DropdownToggleItem(props) {
|
|
24
24
|
className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["flex items-center"]))), className),
|
25
25
|
children: [StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
26
26
|
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mr-2 shrink-0 text-grey-500"]))),
|
27
|
-
|
27
|
+
width: "1rem",
|
28
|
+
height: "1rem"
|
28
29
|
}), /*#__PURE__*/_jsx("span", {
|
29
30
|
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["flex-1 truncate mr-4"]))),
|
30
31
|
children: children
|
package/esm/Dropzone/Dropzone.js
CHANGED
@@ -12,7 +12,7 @@ import { Fragment, useCallback, useMemo, useState } from "react";
|
|
12
12
|
import { useDropzone } from "react-dropzone";
|
13
13
|
import { Check, UploadCloud, X } from "react-feather";
|
14
14
|
import { IconButton } from "../Button";
|
15
|
-
import {
|
15
|
+
import { useField } from "../Field";
|
16
16
|
import { useLocale } from "../Satellite";
|
17
17
|
import stl from "../styles/helpers/satellitePrefixer";
|
18
18
|
import { formatHumanSize } from "../utils/formatters";
|
@@ -64,8 +64,9 @@ export var Dropzone = function Dropzone(_ref2) {
|
|
64
64
|
_useState4 = _slicedToArray(_useState3, 2),
|
65
65
|
focused = _useState4[0],
|
66
66
|
setFocused = _useState4[1];
|
67
|
-
var
|
68
|
-
status =
|
67
|
+
var _useField = useField(),
|
68
|
+
status = _useField.state.status,
|
69
|
+
labelId = _useField.labelId;
|
69
70
|
var onDrop = useCallback(function (acceptedFiles, fileRejections) {
|
70
71
|
var updatedFiles = multiple ? [].concat(_toConsumableArray(files), _toConsumableArray(acceptedFiles)) : acceptedFiles;
|
71
72
|
setFiles(updatedFiles);
|
@@ -104,6 +105,7 @@ export var Dropzone = function Dropzone(_ref2) {
|
|
104
105
|
})), {}, {
|
105
106
|
children: [/*#__PURE__*/_jsx("input", _objectSpread({}, getInputProps({
|
106
107
|
id: dropzoneId,
|
108
|
+
"aria-labelledby": labelId,
|
107
109
|
onFocus: function onFocus() {
|
108
110
|
return setFocused(true);
|
109
111
|
},
|
package/esm/Field/Field.d.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
import type
|
2
|
-
import type { FieldState } from "./
|
1
|
+
import { type ReactChild, type ReactNode, type VFC } from "react";
|
2
|
+
import type { FieldState } from "./FieldContext";
|
3
3
|
export interface FieldProps {
|
4
4
|
/** @ignore */
|
5
5
|
className?: string;
|
6
6
|
/** Label to display above the nested input */
|
7
7
|
label?: ReactChild;
|
8
|
+
labelId?: string;
|
8
9
|
labelFor?: string;
|
9
10
|
/** Helpful description to show below the `Field` */
|
10
11
|
description?: ReactNode;
|
package/esm/Field/Field.js
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
2
2
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
3
3
|
import cx from "clsx";
|
4
|
+
import { useMemo } from "react";
|
4
5
|
import { AlertCircle } from "react-feather";
|
5
6
|
import stl from "../styles/helpers/satellitePrefixer";
|
6
|
-
import
|
7
|
+
import { uniqueId } from "../utils";
|
8
|
+
import { DEFAULT_FIELD_STATE, FieldContext } from "./FieldContext";
|
7
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
8
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
11
|
/**
|
@@ -44,20 +46,31 @@ export var Field = function Field(_ref) {
|
|
44
46
|
var className = _ref.className,
|
45
47
|
label = _ref.label,
|
46
48
|
labelFor = _ref.labelFor,
|
49
|
+
labelIdProp = _ref.labelId,
|
47
50
|
description = _ref.description,
|
48
51
|
_ref$state = _ref.state,
|
49
|
-
state = _ref$state === void 0 ?
|
52
|
+
state = _ref$state === void 0 ? DEFAULT_FIELD_STATE : _ref$state,
|
50
53
|
_ref$inline = _ref.inline,
|
51
54
|
inline = _ref$inline === void 0 ? false : _ref$inline,
|
52
55
|
children = _ref.children;
|
53
|
-
|
54
|
-
|
56
|
+
var hasLabel = !!label;
|
57
|
+
var labelId = useMemo(
|
58
|
+
// eslint-disable-next-line @algolia/satellite/prefer-stl-helper
|
59
|
+
function () {
|
60
|
+
return hasLabel ? labelIdProp !== null && labelIdProp !== void 0 ? labelIdProp : uniqueId("stl-field-label-") : undefined;
|
61
|
+
}, [labelIdProp, hasLabel]);
|
62
|
+
return /*#__PURE__*/_jsx(FieldContext.Provider, {
|
63
|
+
value: {
|
64
|
+
state: state,
|
65
|
+
labelId: labelId
|
66
|
+
},
|
55
67
|
children: /*#__PURE__*/_jsxs("div", {
|
56
68
|
className: className,
|
57
69
|
children: [/*#__PURE__*/_jsxs("label", {
|
58
70
|
className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["cursor-pointer flex ", ""])), !inline && "flex-col"),
|
59
71
|
htmlFor: labelFor,
|
60
|
-
children: [
|
72
|
+
children: [hasLabel && /*#__PURE__*/_jsx("div", {
|
73
|
+
id: labelId,
|
61
74
|
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["truncate ", ""])), inline ? "mr-2" : "mb-1"),
|
62
75
|
children: label
|
63
76
|
}), /*#__PURE__*/_jsx("div", {
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
export declare type FieldState = {
|
3
|
+
status: "default";
|
4
|
+
} | {
|
5
|
+
status: "validated";
|
6
|
+
} | {
|
7
|
+
status: "invalid";
|
8
|
+
errors: string[];
|
9
|
+
};
|
10
|
+
export declare type FieldContextValue = {
|
11
|
+
state: FieldState;
|
12
|
+
labelId?: string;
|
13
|
+
};
|
14
|
+
export declare const DEFAULT_FIELD_STATE: FieldState;
|
15
|
+
export declare const DEFAULT_CONTEXT_VALUE: FieldContextValue;
|
16
|
+
export declare const FieldContext: import("react").Context<FieldContextValue>;
|
package/esm/Field/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from "./Field";
|
2
|
-
export
|
3
|
-
export
|
2
|
+
export type { FieldState, FieldContextValue } from "./FieldContext";
|
3
|
+
export { FieldContext } from "./FieldContext";
|
4
|
+
export * from "./useField";
|
4
5
|
export { default } from "./Field";
|
package/esm/Field/index.js
CHANGED
package/esm/Input/Input.js
CHANGED
@@ -10,7 +10,7 @@ import cx from "clsx";
|
|
10
10
|
import { forwardRef, Fragment, useEffect, useState } from "react";
|
11
11
|
import { Check, ChevronDown, ChevronUp, Search, X } from "react-feather";
|
12
12
|
import { IconButton } from "../Button";
|
13
|
-
import
|
13
|
+
import { useField } from "../Field";
|
14
14
|
import { useLocale } from "../Satellite";
|
15
15
|
import stl from "../styles/helpers/satellitePrefixer";
|
16
16
|
import isNil from "../utils/isNil";
|
@@ -82,8 +82,9 @@ export var Input = /*#__PURE__*/forwardRef(function (_ref, externalRef) {
|
|
82
82
|
inputRefCallback = _useForwardedRef2[0],
|
83
83
|
inputRef = _useForwardedRef2[1];
|
84
84
|
var triggerInputChange = useTriggerInputChange(inputRef);
|
85
|
-
var
|
86
|
-
status =
|
85
|
+
var _useField = useField(),
|
86
|
+
status = _useField.state.status,
|
87
|
+
labelId = _useField.labelId;
|
87
88
|
var isControlled = ("value" in inputProps);
|
88
89
|
var _useState3 = useState(function () {
|
89
90
|
return isControlled ? inputProps.value : inputProps.defaultValue;
|
@@ -98,6 +99,7 @@ export var Input = /*#__PURE__*/forwardRef(function (_ref, externalRef) {
|
|
98
99
|
}
|
99
100
|
}, [inputProps.value, isControlled]);
|
100
101
|
var Icon = startIcon ? startIcon : type === "search" ? SearchIcon : undefined;
|
102
|
+
var iconSize = variant === "small" ? "1rem" : "1.5rem";
|
101
103
|
var StatusIcon = status === "invalid" ? InvalidIcon : status === "validated" ? ValidatedIcon : Fragment;
|
102
104
|
var clearable = typeof clearableProp === "boolean" ? clearableProp : type === "search";
|
103
105
|
return /*#__PURE__*/_jsxs("div", {
|
@@ -109,11 +111,13 @@ export var Input = /*#__PURE__*/forwardRef(function (_ref, externalRef) {
|
|
109
111
|
},
|
110
112
|
children: [Icon && /*#__PURE__*/_jsx(Icon, {
|
111
113
|
className: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["ml-4 shrink-0 ", ""])), disabled ? "text-grey-200" : focused ? "text-accent-600" : "text-grey-500"),
|
112
|
-
|
114
|
+
width: iconSize,
|
115
|
+
height: iconSize
|
113
116
|
}), /*#__PURE__*/_jsx("input", _objectSpread(_objectSpread({
|
114
117
|
className: stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["mx-4 no-search-input-decoration"]))),
|
115
118
|
ref: inputRefCallback,
|
116
|
-
type: type
|
119
|
+
type: type,
|
120
|
+
"aria-labelledby": labelId
|
117
121
|
}, inputProps), {}, {
|
118
122
|
readOnly: readOnly,
|
119
123
|
disabled: disabled,
|
package/esm/Link/Link.d.ts
CHANGED
@@ -7,7 +7,7 @@ export declare type LinkProps = {
|
|
7
7
|
} & AnchorHTMLAttributes<HTMLAnchorElement>;
|
8
8
|
export declare const Link: import("react").ForwardRefExoticComponent<{
|
9
9
|
href: string;
|
10
|
-
startIcon?:
|
11
|
-
endIcon?:
|
10
|
+
startIcon?: IconComponentType | undefined;
|
11
|
+
endIcon?: IconComponentType | undefined;
|
12
12
|
} & AnchorHTMLAttributes<HTMLAnchorElement> & import("react").RefAttributes<HTMLAnchorElement>>;
|
13
13
|
export default Link;
|
package/esm/Link/Link.js
CHANGED
@@ -33,10 +33,12 @@ export var Link = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
33
33
|
className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["typo-link inline-flex items-center"]))), className),
|
34
34
|
children: [StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
35
35
|
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mr-1 shrink-0"]))),
|
36
|
-
|
36
|
+
width: "1em",
|
37
|
+
height: "1em"
|
37
38
|
}), children, EndIcon && /*#__PURE__*/_jsx(EndIcon, {
|
38
39
|
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["ml-1 shrink-0"]))),
|
39
|
-
|
40
|
+
width: "1em",
|
41
|
+
height: "1em"
|
40
42
|
})]
|
41
43
|
}));
|
42
44
|
});
|