@algolia/satellite 2.3.0-rc.4 → 2.3.0-rc.6
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/dist/cjs/Actions/ButtonLink/ButtonLink.d.ts +2 -0
- package/dist/cjs/Actions/ButtonLink/ButtonLink.js +4 -2
- package/dist/cjs/Actions/ToggleGroup/ToggleGroup.d.ts +13 -14
- package/dist/cjs/Fields/AutoComplete/AutoComplete.js +5 -7
- package/dist/cjs/Fields/AutoComplete/types.d.ts +0 -8
- package/dist/cjs/Fields/AutoComplete/utils.d.ts +1 -1
- package/dist/cjs/Fields/AutoComplete/utils.js +2 -3
- package/dist/cjs/Fields/Checkbox/Checkbox.d.ts +2 -2
- package/dist/cjs/Fields/Checkbox/Checkbox.js +2 -2
- package/dist/cjs/Fields/Dropzone/Dropzone.js +1 -1
- package/dist/cjs/Fields/Form/stories/Complex.js +123 -50
- package/dist/cjs/Fields/RadioGroup/RadioButton.js +9 -2
- package/dist/cjs/Fields/RadioGroup/RadioButton.tailwind.js +1 -1
- package/dist/cjs/Fields/RadioGroup/RadioGroupItem.js +1 -1
- package/dist/cjs/Fields/Select/Select.tailwind.js +4 -3
- package/dist/cjs/Fields/SelectableCard/SelectableCard.d.ts +35 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCard.js +105 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCardContext.d.ts +13 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCardContext.js +15 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCardGroup.d.ts +13 -0
- package/dist/cjs/Fields/SelectableCard/SelectableCardGroup.js +55 -0
- package/dist/cjs/Fields/SelectableCard/index.d.ts +2 -0
- package/dist/cjs/Fields/SelectableCard/index.js +27 -0
- package/dist/cjs/Fields/Switch/Switch.js +1 -1
- package/dist/cjs/Fields/index.d.ts +1 -0
- package/dist/cjs/Fields/index.js +11 -0
- package/dist/cjs/Helpers/utilities/focusable.tailwind.js +1 -1
- package/dist/cjs/Navigation/Link/Link.d.ts +10 -0
- package/dist/cjs/Navigation/Link/Link.js +4 -2
- package/dist/esm/Actions/ButtonLink/ButtonLink.d.ts +2 -0
- package/dist/esm/Actions/ButtonLink/ButtonLink.js +4 -2
- package/dist/esm/Actions/ToggleGroup/ToggleGroup.d.ts +13 -14
- package/dist/esm/Fields/AutoComplete/AutoComplete.js +5 -7
- package/dist/esm/Fields/AutoComplete/types.d.ts +0 -8
- package/dist/esm/Fields/AutoComplete/utils.d.ts +1 -1
- package/dist/esm/Fields/AutoComplete/utils.js +2 -3
- package/dist/esm/Fields/Checkbox/Checkbox.d.ts +2 -2
- package/dist/esm/Fields/Checkbox/Checkbox.js +2 -2
- package/dist/esm/Fields/Dropzone/Dropzone.js +1 -1
- package/dist/esm/Fields/Form/stories/Complex.js +123 -50
- package/dist/esm/Fields/RadioGroup/RadioButton.js +10 -3
- package/dist/esm/Fields/RadioGroup/RadioButton.tailwind.js +1 -1
- package/dist/esm/Fields/RadioGroup/RadioGroupItem.js +1 -1
- package/dist/esm/Fields/Select/Select.tailwind.js +4 -3
- package/dist/esm/Fields/SelectableCard/SelectableCard.d.ts +35 -0
- package/dist/esm/Fields/SelectableCard/SelectableCard.js +100 -0
- package/dist/esm/Fields/SelectableCard/SelectableCardContext.d.ts +13 -0
- package/dist/esm/Fields/SelectableCard/SelectableCardContext.js +9 -0
- package/dist/esm/Fields/SelectableCard/SelectableCardGroup.d.ts +13 -0
- package/dist/esm/Fields/SelectableCard/SelectableCardGroup.js +48 -0
- package/dist/esm/Fields/SelectableCard/index.d.ts +2 -0
- package/dist/esm/Fields/SelectableCard/index.js +2 -0
- package/dist/esm/Fields/Switch/Switch.js +1 -1
- package/dist/esm/Fields/index.d.ts +1 -0
- package/dist/esm/Fields/index.js +1 -0
- package/dist/esm/Helpers/utilities/focusable.tailwind.js +1 -1
- package/dist/esm/Navigation/Link/Link.d.ts +10 -0
- package/dist/esm/Navigation/Link/Link.js +4 -2
- package/dist/satellite.min.css +1 -1
- package/package.json +2 -2
@@ -0,0 +1,100 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
5
|
+
var _excluded = ["value", "selectedColor", "children", "id", "className"];
|
6
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18;
|
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 cx from "clsx";
|
10
|
+
import { forwardRef } from "react";
|
11
|
+
import { Checkbox, RadioButton, useField } from "..";
|
12
|
+
import { Card } from "../../Layout";
|
13
|
+
import stl from "../../styles/helpers/satellitePrefixer";
|
14
|
+
import { useSelectableCardContext } from "./SelectableCardContext";
|
15
|
+
|
16
|
+
// We need to omit the `elevation` prop because we handle it ourselves.
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
18
|
+
var SELECTED_COLOR_CLASSNAMES = {
|
19
|
+
grey: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["border-grey-600"]))),
|
20
|
+
pink: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["border-pink-600"]))),
|
21
|
+
accent: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["border-accent-600"]))),
|
22
|
+
blue: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["border-blue-600"]))),
|
23
|
+
green: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["border-green-600"]))),
|
24
|
+
orange: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["border-orange-600"]))),
|
25
|
+
red: stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["border-red-600"]))),
|
26
|
+
xenon: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["border-xenon-600"])))
|
27
|
+
};
|
28
|
+
export var SelectableCard = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
29
|
+
var value = _ref.value,
|
30
|
+
_ref$selectedColor = _ref.selectedColor,
|
31
|
+
selectedColor = _ref$selectedColor === void 0 ? "xenon" : _ref$selectedColor,
|
32
|
+
children = _ref.children,
|
33
|
+
id = _ref.id,
|
34
|
+
className = _ref.className,
|
35
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
36
|
+
var _useSelectableCardCon = useSelectableCardContext(),
|
37
|
+
name = _useSelectableCardCon.name,
|
38
|
+
isControlled = _useSelectableCardCon.isControlled,
|
39
|
+
setValue = _useSelectableCardCon.setValue,
|
40
|
+
onValueChange = _useSelectableCardCon.onValueChange,
|
41
|
+
type = _useSelectableCardCon.type,
|
42
|
+
valueContext = _useSelectableCardCon.value,
|
43
|
+
disabledContext = _useSelectableCardCon.disabled;
|
44
|
+
var disabled = props.disabled || disabledContext;
|
45
|
+
var selected = valueContext === null || valueContext === void 0 ? void 0 : valueContext.includes(value);
|
46
|
+
var _useField = useField(),
|
47
|
+
status = _useField.state.status;
|
48
|
+
var isInvalid = status === "invalid";
|
49
|
+
var handleCheckboxChange = function handleCheckboxChange(evt) {
|
50
|
+
var _valueContext$filter;
|
51
|
+
var newValue = selected ? (_valueContext$filter = valueContext === null || valueContext === void 0 ? void 0 : valueContext.filter(function (v) {
|
52
|
+
return v !== value;
|
53
|
+
})) !== null && _valueContext$filter !== void 0 ? _valueContext$filter : [] : [].concat(_toConsumableArray(valueContext !== null && valueContext !== void 0 ? valueContext : []), [value]);
|
54
|
+
if (!isControlled && !evt.isDefaultPrevented()) {
|
55
|
+
setValue(newValue);
|
56
|
+
}
|
57
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(newValue);
|
58
|
+
};
|
59
|
+
var handleRadioButtonChange = function handleRadioButtonChange(evt) {
|
60
|
+
var newValue = [evt.target.value];
|
61
|
+
if (!isControlled && !evt.isDefaultPrevented()) {
|
62
|
+
setValue(newValue);
|
63
|
+
}
|
64
|
+
onValueChange === null || onValueChange === void 0 || onValueChange(newValue);
|
65
|
+
};
|
66
|
+
return /*#__PURE__*/_jsxs(Card, _objectSpread(_objectSpread({
|
67
|
+
ref: ref,
|
68
|
+
fullBleed: true,
|
69
|
+
className: cx(stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["relative border transition-[shadow,border]"]))), !disabled && !selected && !isInvalid && stl(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["border-transparent"]))),
|
70
|
+
// Disabled
|
71
|
+
disabled && stl(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["bg-grey-100 border-grey-200 text-grey-300 shadow-none cursor-not-allowed [&>*]:text-grey-300"]))),
|
72
|
+
// Selected
|
73
|
+
selected && stl(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["card-z200"]))), !disabled && selected && !isInvalid && SELECTED_COLOR_CLASSNAMES[selectedColor],
|
74
|
+
// Hovered
|
75
|
+
!disabled && !selected && !isInvalid && stl(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["hover:border-grey-200"]))), // Focused
|
76
|
+
stl(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["focusable-visible-within"]))), !selected && stl(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["focus-within:border-grey-200"]))),
|
77
|
+
// Invalid
|
78
|
+
isInvalid && stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["border-red-700 shadow-none"]))),
|
79
|
+
// Custom
|
80
|
+
className)
|
81
|
+
}, props), {}, {
|
82
|
+
children: [type === "multiple" ? /*#__PURE__*/_jsx(Checkbox, {
|
83
|
+
id: id,
|
84
|
+
disabled: disabled,
|
85
|
+
checked: selected,
|
86
|
+
className: cx(stl(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["absolute right-4 top-4 z-10"])))),
|
87
|
+
onChange: handleCheckboxChange,
|
88
|
+
name: name
|
89
|
+
}) : /*#__PURE__*/_jsx(RadioButton, {
|
90
|
+
id: id,
|
91
|
+
disabled: disabled,
|
92
|
+
checked: selected,
|
93
|
+
className: cx(stl(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["absolute right-4 top-4 z-10"])))),
|
94
|
+
onChange: handleRadioButtonChange,
|
95
|
+
value: value,
|
96
|
+
name: name
|
97
|
+
}), children]
|
98
|
+
}));
|
99
|
+
});
|
100
|
+
SelectableCard.displayName = "SelectableCard";
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { type Dispatch, type SetStateAction } from "react";
|
2
|
+
import type { SelectionTypes } from "./SelectableCardGroup";
|
3
|
+
export interface SelectableCardContextInterface {
|
4
|
+
value?: string[];
|
5
|
+
name?: string;
|
6
|
+
type: SelectionTypes;
|
7
|
+
isControlled: boolean;
|
8
|
+
setValue: Dispatch<SetStateAction<string[]>>;
|
9
|
+
onValueChange?: (value: string[]) => void;
|
10
|
+
disabled?: boolean;
|
11
|
+
}
|
12
|
+
export declare const SelectableCardContext: import("react").Context<SelectableCardContextInterface | null>;
|
13
|
+
export declare const useSelectableCardContext: () => SelectableCardContextInterface;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { createContext, useContext } from "react";
|
2
|
+
export var SelectableCardContext = /*#__PURE__*/createContext(null);
|
3
|
+
export var useSelectableCardContext = function useSelectableCardContext() {
|
4
|
+
var context = useContext(SelectableCardContext);
|
5
|
+
if (!context) {
|
6
|
+
throw new Error("useSelectableCardContext used outside SelectableCardContext");
|
7
|
+
}
|
8
|
+
return context;
|
9
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { type FC, type PropsWithChildren } from "react";
|
2
|
+
export declare type SelectionTypes = "multiple" | "single";
|
3
|
+
export declare type SelectableCardGroupProps = {
|
4
|
+
disabled?: boolean;
|
5
|
+
name?: string;
|
6
|
+
value?: string[];
|
7
|
+
defaultValue?: string[];
|
8
|
+
type: SelectionTypes;
|
9
|
+
onValueChange?: (value: string[]) => void;
|
10
|
+
className?: string;
|
11
|
+
required?: boolean;
|
12
|
+
};
|
13
|
+
export declare const SelectableCardGroup: FC<PropsWithChildren<SelectableCardGroupProps>>;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
+
import { useState } from "react";
|
3
|
+
import { useField } from "..";
|
4
|
+
import { SelectableCardContext } from "./SelectableCardContext";
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
6
|
+
export var SelectableCardGroup = function SelectableCardGroup(_ref) {
|
7
|
+
var _ref2;
|
8
|
+
var children = _ref.children,
|
9
|
+
disabled = _ref.disabled,
|
10
|
+
name = _ref.name,
|
11
|
+
controlledValue = _ref.value,
|
12
|
+
defaultValue = _ref.defaultValue,
|
13
|
+
type = _ref.type,
|
14
|
+
onValueChange = _ref.onValueChange,
|
15
|
+
className = _ref.className,
|
16
|
+
required = _ref.required;
|
17
|
+
var isControlled = controlledValue !== undefined;
|
18
|
+
var _useState = useState((_ref2 = controlledValue !== null && controlledValue !== void 0 ? controlledValue : defaultValue) !== null && _ref2 !== void 0 ? _ref2 : []),
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
20
|
+
internalValue = _useState2[0],
|
21
|
+
setInternalValue = _useState2[1];
|
22
|
+
var value = isControlled ? controlledValue : internalValue;
|
23
|
+
var _useField = useField({
|
24
|
+
required: required
|
25
|
+
}),
|
26
|
+
status = _useField.state.status,
|
27
|
+
labelId = _useField.labelId,
|
28
|
+
descriptionId = _useField.descriptionId;
|
29
|
+
return /*#__PURE__*/_jsx(SelectableCardContext.Provider, {
|
30
|
+
value: {
|
31
|
+
value: value,
|
32
|
+
setValue: setInternalValue,
|
33
|
+
isControlled: isControlled,
|
34
|
+
name: name,
|
35
|
+
disabled: disabled,
|
36
|
+
onValueChange: onValueChange,
|
37
|
+
type: type
|
38
|
+
},
|
39
|
+
children: /*#__PURE__*/_jsx("div", {
|
40
|
+
role: type === "single" ? "radiogroup" : "group",
|
41
|
+
"aria-invalid": status === "invalid",
|
42
|
+
"aria-labelledby": labelId,
|
43
|
+
"aria-describedby": descriptionId,
|
44
|
+
className: className,
|
45
|
+
children: children
|
46
|
+
})
|
47
|
+
});
|
48
|
+
};
|
@@ -76,7 +76,7 @@ export var Switch = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
76
76
|
role: "switch",
|
77
77
|
ref: ref
|
78
78
|
})), /*#__PURE__*/_jsx("div", {
|
79
|
-
className: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["switch focusable-sibling"])))
|
79
|
+
className: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["switch focusable-visible-sibling"])))
|
80
80
|
})]
|
81
81
|
});
|
82
82
|
});
|
package/dist/esm/Fields/index.js
CHANGED
@@ -5,7 +5,7 @@ var plugin = _plugin;
|
|
5
5
|
export default plugin(function (_ref) {
|
6
6
|
var addComponents = _ref.addComponents,
|
7
7
|
theme = _ref.theme;
|
8
|
-
addComponents(_defineProperty({}, ".focusable:focus,\n .focusable-within:focus-within,\n .focusable-visible:focus-visible,\n .focusable-visible-within:has(:focus-visible),\n input:focus ~ .focusable-sibling,\n .focusable-visible-group:focus-visible .focusable-visible-group-item,\n .focusable-show", {
|
8
|
+
addComponents(_defineProperty({}, ".focusable:focus,\n .focusable-within:focus-within,\n .focusable-visible:focus-visible,\n .focusable-visible-within:has(:focus-visible),\n input:focus ~ .focusable-sibling,\n input:focus-visible ~ .focusable-visible-sibling,\n .focusable-visible-group:focus-visible .focusable-visible-group-item,\n .focusable-show", {
|
9
9
|
outline: "2px solid ".concat(theme("colors.accent.600")),
|
10
10
|
outlineOffset: "1px"
|
11
11
|
}));
|
@@ -13,6 +13,11 @@ export declare type LinkProps = {
|
|
13
13
|
* The icon to display at the end of the link.
|
14
14
|
*/
|
15
15
|
endIcon?: IconComponentType;
|
16
|
+
/**
|
17
|
+
* To determine if the `ExternalLink` icon should be displayed.
|
18
|
+
* @default true
|
19
|
+
*/
|
20
|
+
withExternalLinkIcon?: boolean;
|
16
21
|
} & AnchorHTMLAttributes<HTMLAnchorElement>;
|
17
22
|
/**
|
18
23
|
* The `Link` component is used to display a link.
|
@@ -32,4 +37,9 @@ export declare const Link: import("react").ForwardRefExoticComponent<{
|
|
32
37
|
* The icon to display at the end of the link.
|
33
38
|
*/
|
34
39
|
endIcon?: IconComponentType | undefined;
|
40
|
+
/**
|
41
|
+
* To determine if the `ExternalLink` icon should be displayed.
|
42
|
+
* @default true
|
43
|
+
*/
|
44
|
+
withExternalLinkIcon?: boolean | undefined;
|
35
45
|
} & AnchorHTMLAttributes<HTMLAnchorElement> & import("react").RefAttributes<HTMLAnchorElement>>;
|
@@ -2,7 +2,7 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
4
|
var _templateObject, _templateObject2, _templateObject3;
|
5
|
-
var _excluded = ["className", "children", "startIcon", "endIcon", "href", "onClick"];
|
5
|
+
var _excluded = ["className", "children", "startIcon", "endIcon", "withExternalLinkIcon", "href", "onClick"];
|
6
6
|
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
7
|
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; }
|
8
8
|
import cx from "clsx";
|
@@ -21,6 +21,8 @@ export var Link = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
21
21
|
children = _ref.children,
|
22
22
|
StartIcon = _ref.startIcon,
|
23
23
|
EndIcon = _ref.endIcon,
|
24
|
+
_ref$withExternalLink = _ref.withExternalLinkIcon,
|
25
|
+
withExternalLinkIcon = _ref$withExternalLink === void 0 ? true : _ref$withExternalLink,
|
24
26
|
href = _ref.href,
|
25
27
|
onClick = _ref.onClick,
|
26
28
|
anchorProps = _objectWithoutProperties(_ref, _excluded);
|
@@ -29,7 +31,7 @@ export var Link = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
29
31
|
onClick: onClick
|
30
32
|
}));
|
31
33
|
var isExternalLink = linkProps.target === "_blank" && EndIcon === undefined;
|
32
|
-
if (isExternalLink) {
|
34
|
+
if (isExternalLink && withExternalLinkIcon) {
|
33
35
|
EndIcon = ExternalLinkIcon;
|
34
36
|
}
|
35
37
|
return /*#__PURE__*/_jsxs("a", _objectSpread(_objectSpread(_objectSpread({}, anchorProps), linkProps), {}, {
|