@algolia/satellite 1.0.0-beta.157 → 1.0.0-beta.159

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 (69) hide show
  1. package/cjs/Badge/Badge.d.ts +2 -2
  2. package/cjs/Badge/Badge.js +7 -6
  3. package/cjs/Banners/Alert/Alert.js +1 -1
  4. package/cjs/Button/Button.d.ts +3 -5
  5. package/cjs/Button/Button.js +8 -51
  6. package/cjs/Button/IconButton.d.ts +3 -18
  7. package/cjs/Button/IconButton.js +8 -64
  8. package/cjs/Button/PolymorphicButton.d.ts +11 -0
  9. package/cjs/Button/PolymorphicButton.js +76 -0
  10. package/cjs/Button/PolymorphicIconButton.d.ts +24 -0
  11. package/cjs/Button/PolymorphicIconButton.js +84 -0
  12. package/cjs/Button/index.d.ts +1 -1
  13. package/cjs/Button/index.js +16 -12
  14. package/cjs/Button/types.d.ts +11 -6
  15. package/cjs/Button/types.js +3 -1
  16. package/cjs/Dropdown/DropdownButton.d.ts +3 -3
  17. package/cjs/Dropdown/DropdownButton.js +5 -2
  18. package/cjs/Link/ButtonLink.d.ts +5 -3
  19. package/cjs/Link/ButtonLink.js +9 -6
  20. package/cjs/Link/IconButtonLink.d.ts +5 -4
  21. package/cjs/Link/IconButtonLink.js +8 -5
  22. package/cjs/Medallion/Medallion.js +1 -1
  23. package/cjs/Modal/Modal.d.ts +35 -11
  24. package/cjs/Modal/Modal.js +101 -109
  25. package/cjs/Modal/Modal.tailwind.js +54 -18
  26. package/cjs/Satellite/Satellite.d.ts +2 -1
  27. package/cjs/Satellite/Satellite.js +26 -2
  28. package/cjs/Tag/Tag.d.ts +26 -6
  29. package/cjs/Tag/Tag.js +51 -19
  30. package/cjs/Tag/Tag.tailwind.js +17 -1
  31. package/cjs/styles/colors.d.ts +18 -0
  32. package/cjs/styles/colors.js +33 -15
  33. package/cjs/types.d.ts +9 -0
  34. package/esm/Badge/Badge.d.ts +2 -2
  35. package/esm/Badge/Badge.js +7 -6
  36. package/esm/Banners/Alert/Alert.js +1 -1
  37. package/esm/Button/Button.d.ts +3 -5
  38. package/esm/Button/Button.js +8 -52
  39. package/esm/Button/IconButton.d.ts +3 -18
  40. package/esm/Button/IconButton.js +8 -66
  41. package/esm/Button/PolymorphicButton.d.ts +11 -0
  42. package/esm/Button/PolymorphicButton.js +66 -0
  43. package/esm/Button/PolymorphicIconButton.d.ts +24 -0
  44. package/esm/Button/PolymorphicIconButton.js +78 -0
  45. package/esm/Button/index.d.ts +1 -1
  46. package/esm/Button/index.js +1 -1
  47. package/esm/Button/types.d.ts +11 -6
  48. package/esm/Button/types.js +3 -1
  49. package/esm/Dropdown/DropdownButton.d.ts +3 -3
  50. package/esm/Dropdown/DropdownButton.js +5 -2
  51. package/esm/Link/ButtonLink.d.ts +5 -3
  52. package/esm/Link/ButtonLink.js +9 -6
  53. package/esm/Link/IconButtonLink.d.ts +5 -4
  54. package/esm/Link/IconButtonLink.js +8 -5
  55. package/esm/Medallion/Medallion.js +1 -1
  56. package/esm/Modal/Modal.d.ts +35 -11
  57. package/esm/Modal/Modal.js +99 -111
  58. package/esm/Modal/Modal.tailwind.js +53 -18
  59. package/esm/Satellite/Satellite.d.ts +2 -1
  60. package/esm/Satellite/Satellite.js +24 -1
  61. package/esm/Tag/Tag.d.ts +26 -6
  62. package/esm/Tag/Tag.js +52 -20
  63. package/esm/Tag/Tag.tailwind.js +17 -1
  64. package/esm/styles/colors.d.ts +18 -0
  65. package/esm/styles/colors.js +33 -15
  66. package/esm/types.d.ts +9 -0
  67. package/package.json +7 -4
  68. package/satellite.min.css +1 -1
  69. package/scss/colors.scss +27 -10
@@ -1,72 +1,14 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
- var _excluded = ["as", "className", "variant", "size", "icon", "title", "showTooltip", "tooltipPlacement", "loading"];
5
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
6
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
- import cx from "clsx";
9
- import ProgressSpinner from "../ProgressSpinner";
10
- import stl from "../styles/helpers/satellitePrefixer";
11
- import { TooltipWrapper } from "../Tooltip";
12
- import { BUTTON_LOADER_ICON_SIZES, BUTTON_VARIANT_CLASSNAMES } from "./styles";
13
- import { isButtonType } from "./types";
4
+ import { forwardRef } from "react";
5
+ import { PolymorphicIconButton } from "./PolymorphicIconButton";
14
6
  import { jsx as _jsx } from "react/jsx-runtime";
15
- import { Fragment as _Fragment } from "react/jsx-runtime";
16
- import { jsxs as _jsxs } from "react/jsx-runtime";
17
- var BASE_CLASSNAMES = stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["btn inline-flex items-center justify-center"])));
18
- var SIZE_CLASSNAMES = {
19
- small: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["h-6 w-6 text-mobile md:text-sm"]))),
20
- medium: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["h-8 w-8 text-md"]))),
21
- large: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["h-10 w-10 text-lg"])))
22
- };
23
- var VARIANT_CLASSNAMES = _objectSpread(_objectSpread({}, BUTTON_VARIANT_CLASSNAMES), {}, {
24
- neutral: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["btn-neutral text-grey-600"])))
7
+ export var IconButton = /*#__PURE__*/forwardRef(function (props, ref) {
8
+ return /*#__PURE__*/_jsx(PolymorphicIconButton, _objectSpread(_objectSpread({}, props), {}, {
9
+ as: "button",
10
+ ref: ref
11
+ }));
25
12
  });
26
- export var IconButton = function IconButton(props) {
27
- var _props$as = props.as,
28
- Tag = _props$as === void 0 ? "button" : _props$as,
29
- className = props.className,
30
- _props$variant = props.variant,
31
- variant = _props$variant === void 0 ? "neutral" : _props$variant,
32
- _props$size = props.size,
33
- size = _props$size === void 0 ? "medium" : _props$size,
34
- Icon = props.icon,
35
- title = props.title,
36
- showTooltip = props.showTooltip,
37
- _props$tooltipPlaceme = props.tooltipPlacement,
38
- tooltipPlacement = _props$tooltipPlaceme === void 0 ? "top" : _props$tooltipPlaceme,
39
- _props$loading = props.loading,
40
- loading = _props$loading === void 0 ? false : _props$loading,
41
- cleanedProps = _objectWithoutProperties(props, _excluded);
42
- if (loading) {
43
- cleanedProps.disabled = true;
44
- }
45
- var iconButtonClassName = cx(BASE_CLASSNAMES, SIZE_CLASSNAMES[size], VARIANT_CLASSNAMES[variant], cleanedProps.disabled && stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["btn-disabled"]))), className);
46
- var loaderClassNames = stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["absolute ", ""])), (variant === "destructive" || variant === "primary") && "text-white");
47
- if (isButtonType(props) && !Object.prototype.hasOwnProperty.call(cleanedProps, "type")) {
48
- // @ts-ignore
49
- cleanedProps.type = "button";
50
- }
51
- return /*#__PURE__*/_jsx(TooltipWrapper, {
52
- delay: 500,
53
- show: showTooltip,
54
- placement: tooltipPlacement,
55
- content: title,
56
- children: /*#__PURE__*/_jsx(Tag, _objectSpread(_objectSpread({}, cleanedProps), {}, {
57
- className: iconButtonClassName,
58
- "aria-label": title,
59
- children: /*#__PURE__*/_jsxs(_Fragment, {
60
- children: [loading && /*#__PURE__*/_jsx(ProgressSpinner, {
61
- className: loaderClassNames,
62
- size: BUTTON_LOADER_ICON_SIZES[size],
63
- thickness: 1
64
- }), /*#__PURE__*/_jsx(Icon, {
65
- className: cx(loading && stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["invisible"])))),
66
- size: "1em"
67
- })]
68
- })
69
- }))
70
- });
71
- };
13
+ IconButton.displayName = "IconButton";
72
14
  export default IconButton;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import { ButtonBaseProps, PolymorphicComponentPropWithRef } from "./types";
3
+ export declare type PolymorphicButtonProps<C extends React.ElementType> = PolymorphicComponentPropWithRef<C, ButtonBaseProps>;
4
+ declare type PolymorphicButtonComponent = (<C extends React.ElementType = "button">(props: PolymorphicButtonProps<C>) => React.ReactElement | null) & {
5
+ displayName?: string;
6
+ };
7
+ /**
8
+ * `PolymorphicButton` is intended for internal use
9
+ */
10
+ export declare const PolymorphicButton: PolymorphicButtonComponent;
11
+ export {};
@@ -0,0 +1,66 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
+ var _excluded = ["as", "className", "variant", "size", "startIcon", "endIcon", "loading", "children"];
5
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
+ import cx from "clsx";
9
+ import React, { forwardRef } from "react";
10
+ import ProgressSpinner from "../ProgressSpinner";
11
+ import stl from "../styles/helpers/satellitePrefixer";
12
+ import { BUTTON_LOADER_ICON_SIZES, BUTTON_SIZE_CLASSNAMES, BUTTON_VARIANT_CLASSNAMES, getIconColorClassName } from "./styles";
13
+ import { isButtonType } from "./types";
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ import { jsxs as _jsxs } from "react/jsx-runtime";
16
+ var BASE_CLASSNAMES = stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["btn inline-flex justify-center items-center px-3 typo-display-body"])));
17
+ var ICON_SIZE = 16;
18
+ /**
19
+ * `PolymorphicButton` is intended for internal use
20
+ */
21
+ export var PolymorphicButton = /*#__PURE__*/forwardRef(function (props, ref) {
22
+ var _props$as = props.as,
23
+ Component = _props$as === void 0 ? "button" : _props$as,
24
+ className = props.className,
25
+ _props$variant = props.variant,
26
+ variant = _props$variant === void 0 ? "neutral" : _props$variant,
27
+ _props$size = props.size,
28
+ size = _props$size === void 0 ? "medium" : _props$size,
29
+ StartIcon = props.startIcon,
30
+ EndIcon = props.endIcon,
31
+ _props$loading = props.loading,
32
+ loading = _props$loading === void 0 ? false : _props$loading,
33
+ children = props.children,
34
+ cleanedProps = _objectWithoutProperties(props, _excluded);
35
+ if (loading) {
36
+ // @ts-expect-error
37
+ cleanedProps.disabled = true;
38
+ }
39
+ var buttonClassName = cx(BASE_CLASSNAMES, BUTTON_SIZE_CLASSNAMES[size], BUTTON_VARIANT_CLASSNAMES[variant], cleanedProps.disabled && stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["btn-disabled"]))), className);
40
+ var loaderClassNames = stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["absolute ", ""])), (variant === "destructive" || variant === "primary") && "text-white");
41
+ var iconClassNames = cx(getIconColorClassName(props), loading && stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["invisible"]))));
42
+ var textClassNames = cx(loading && stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["invisible"]))));
43
+ if (isButtonType(props) && !Object.prototype.hasOwnProperty.call(cleanedProps, "type")) {
44
+ // @ts-expect-error
45
+ cleanedProps.type = "button";
46
+ }
47
+ return /*#__PURE__*/_jsxs(Component, _objectSpread(_objectSpread({}, cleanedProps), {}, {
48
+ className: buttonClassName,
49
+ ref: ref,
50
+ children: [loading && /*#__PURE__*/_jsx(ProgressSpinner, {
51
+ className: loaderClassNames,
52
+ size: BUTTON_LOADER_ICON_SIZES[size],
53
+ thickness: 1
54
+ }), StartIcon && /*#__PURE__*/_jsx(StartIcon, {
55
+ size: ICON_SIZE,
56
+ className: cx(stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["shrink-0"]))), iconClassNames)
57
+ }), /*#__PURE__*/_jsx("span", {
58
+ className: cx(stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["truncate text-center px-1"]))), textClassNames),
59
+ children: children
60
+ }), EndIcon && /*#__PURE__*/_jsx(EndIcon, {
61
+ size: ICON_SIZE,
62
+ className: cx(stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["shrink-0"]))), iconClassNames)
63
+ })]
64
+ }));
65
+ });
66
+ PolymorphicButton.displayName = "PolymorphicButton";
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ import type { TooltipWrapperBaseProps } from "../Tooltip/types";
3
+ import type { IconComponentType } from "../types";
4
+ import { ButtonSize, ButtonVariant, PolymorphicComponentPropWithRef } from "./types";
5
+ export interface IconButtonBaseProps {
6
+ variant?: ButtonVariant;
7
+ size?: ButtonSize;
8
+ disabled?: boolean;
9
+ icon: IconComponentType;
10
+ title: string;
11
+ showTooltip?: boolean;
12
+ /** @default "top" */
13
+ tooltipPlacement?: TooltipWrapperBaseProps["placement"];
14
+ loading?: boolean;
15
+ }
16
+ export declare type PolymorphicIconButtonProps<C extends React.ElementType> = PolymorphicComponentPropWithRef<C, IconButtonBaseProps>;
17
+ declare type PolymorphicIconButtonComponent = (<C extends React.ElementType = "button">(props: PolymorphicIconButtonProps<C>) => React.ReactElement | null) & {
18
+ displayName?: string;
19
+ };
20
+ /**
21
+ * `PolymorphicIconButton` is intended for internal use
22
+ */
23
+ export declare const PolymorphicIconButton: PolymorphicIconButtonComponent;
24
+ export {};
@@ -0,0 +1,78 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
4
+ var _excluded = ["as", "className", "variant", "size", "icon", "title", "showTooltip", "tooltipPlacement", "loading"];
5
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
+ import cx from "clsx";
9
+ import { forwardRef } from "react";
10
+ import ProgressSpinner from "../ProgressSpinner";
11
+ import stl from "../styles/helpers/satellitePrefixer";
12
+ import { TooltipWrapper } from "../Tooltip";
13
+ import { BUTTON_LOADER_ICON_SIZES, BUTTON_VARIANT_CLASSNAMES } from "./styles";
14
+ import { isButtonType } from "./types";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { Fragment as _Fragment } from "react/jsx-runtime";
17
+ import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ var BASE_CLASSNAMES = stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["btn inline-flex items-center justify-center"])));
19
+ var SIZE_CLASSNAMES = {
20
+ small: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["h-6 w-6 text-mobile md:text-sm"]))),
21
+ medium: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["h-8 w-8 text-md"]))),
22
+ large: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["h-10 w-10 text-lg"])))
23
+ };
24
+ var VARIANT_CLASSNAMES = _objectSpread(_objectSpread({}, BUTTON_VARIANT_CLASSNAMES), {}, {
25
+ neutral: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["btn-neutral text-grey-600"])))
26
+ });
27
+ /**
28
+ * `PolymorphicIconButton` is intended for internal use
29
+ */
30
+ export var PolymorphicIconButton = /*#__PURE__*/forwardRef(function (props, ref) {
31
+ var _props$as = props.as,
32
+ Tag = _props$as === void 0 ? "button" : _props$as,
33
+ className = props.className,
34
+ _props$variant = props.variant,
35
+ variant = _props$variant === void 0 ? "neutral" : _props$variant,
36
+ _props$size = props.size,
37
+ size = _props$size === void 0 ? "medium" : _props$size,
38
+ Icon = props.icon,
39
+ title = props.title,
40
+ showTooltip = props.showTooltip,
41
+ _props$tooltipPlaceme = props.tooltipPlacement,
42
+ tooltipPlacement = _props$tooltipPlaceme === void 0 ? "top" : _props$tooltipPlaceme,
43
+ _props$loading = props.loading,
44
+ loading = _props$loading === void 0 ? false : _props$loading,
45
+ cleanedProps = _objectWithoutProperties(props, _excluded);
46
+ if (loading) {
47
+ // @ts-expect-error
48
+ cleanedProps.disabled = true;
49
+ }
50
+ var iconButtonClassName = cx(BASE_CLASSNAMES, SIZE_CLASSNAMES[size], VARIANT_CLASSNAMES[variant], cleanedProps.disabled && stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["btn-disabled"]))), className);
51
+ var loaderClassNames = stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["absolute ", ""])), (variant === "destructive" || variant === "primary") && "text-white");
52
+ if (isButtonType(props) && !Object.prototype.hasOwnProperty.call(cleanedProps, "type")) {
53
+ // @ts-ignore
54
+ cleanedProps.type = "button";
55
+ }
56
+ return /*#__PURE__*/_jsx(TooltipWrapper, {
57
+ delay: 500,
58
+ show: showTooltip,
59
+ placement: tooltipPlacement,
60
+ content: title,
61
+ children: /*#__PURE__*/_jsx(Tag, _objectSpread(_objectSpread({}, cleanedProps), {}, {
62
+ className: iconButtonClassName,
63
+ "aria-label": title,
64
+ ref: ref,
65
+ children: /*#__PURE__*/_jsxs(_Fragment, {
66
+ children: [loading && /*#__PURE__*/_jsx(ProgressSpinner, {
67
+ className: loaderClassNames,
68
+ size: BUTTON_LOADER_ICON_SIZES[size],
69
+ thickness: 1
70
+ }), /*#__PURE__*/_jsx(Icon, {
71
+ className: cx(loading && stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["invisible"])))),
72
+ size: "1em"
73
+ })]
74
+ })
75
+ }))
76
+ });
77
+ });
78
+ PolymorphicIconButton.displayName = "PolymorphicIconButton";
@@ -1,5 +1,5 @@
1
1
  export * from "./Button";
2
2
  export * from "./IconButton";
3
3
  export * from "./ButtonGroup";
4
- export * from "./types";
4
+ export { ButtonSize, ButtonVariant } from "./types";
5
5
  export { default } from "./Button";
@@ -1,5 +1,5 @@
1
1
  export * from "./Button";
2
2
  export * from "./IconButton";
3
3
  export * from "./ButtonGroup";
4
- export * from "./types";
4
+ export { ButtonSize, ButtonVariant } from "./types";
5
5
  export { default } from "./Button";
@@ -1,12 +1,7 @@
1
- import type { ComponentType, ReactNode } from "react";
1
+ import type { ReactNode } from "react";
2
2
  import type { IconComponentType } from "../types";
3
3
  export declare type ButtonVariant = "subtle" | "neutral" | "primary" | "destructive";
4
4
  export declare type ButtonSize = "small" | "medium" | "large";
5
- export declare type MinimalButtonProps = {
6
- className?: string;
7
- };
8
- export declare type AcceptableButtonType = "a" | "button" | ComponentType<MinimalButtonProps>;
9
- export declare type ExtractProps<T> = T extends "a" | "button" ? JSX.IntrinsicElements[T] : T extends ComponentType<infer P> ? P : never;
10
5
  export interface ButtonBaseProps {
11
6
  /** @default "neutral" */
12
7
  variant?: ButtonVariant;
@@ -25,3 +20,13 @@ export interface ButtonBaseProps {
25
20
  className?: string;
26
21
  }
27
22
  export declare function isButtonType(props: any): props is JSX.IntrinsicElements["button"];
23
+ declare type AsProp<C extends React.ElementType> = {
24
+ as?: C;
25
+ };
26
+ declare type PropsToOmit<C extends React.ElementType, P> = keyof (AsProp<C> & P);
27
+ declare type PolymorphicComponentProp<C extends React.ElementType, Props = {}> = React.PropsWithChildren<Props & AsProp<C>> & Omit<React.ComponentPropsWithoutRef<C>, PropsToOmit<C, Props>>;
28
+ export declare type PolymorphicComponentPropWithRef<C extends React.ElementType, Props = {}> = PolymorphicComponentProp<C, Props> & {
29
+ ref?: PolymorphicRef<C>;
30
+ };
31
+ export declare type PolymorphicRef<C extends React.ElementType> = React.ComponentPropsWithRef<C>["ref"];
32
+ export {};
@@ -1,3 +1,5 @@
1
1
  export function isButtonType(props) {
2
2
  return props && (!props.as || props.as === "button");
3
- }
3
+ }
4
+
5
+ // Polymorphic Helpers lifted from https://blog.logrocket.com/build-strongly-typed-polymorphic-components-react-typescript/
@@ -1,11 +1,11 @@
1
- import type { FunctionComponent, ReactNode } from "react";
1
+ import { ReactNode } from "react";
2
2
  import { ButtonProps } from "../Button";
3
3
  import { RenderTargetParams } from "./Dropdown";
4
- export interface DropdownButtonProps extends Omit<ButtonProps<"button">, "title" | "endIcon"> {
4
+ export interface DropdownButtonProps extends Omit<ButtonProps, "title" | "endIcon"> {
5
5
  /** Descriptive title for `Dropdown` */
6
6
  title: ReactNode;
7
7
  renderFooter?: (args: RenderTargetParams) => ReactNode;
8
8
  children: ReactNode;
9
9
  }
10
- export declare const DropdownButton: FunctionComponent<DropdownButtonProps>;
10
+ export declare const DropdownButton: import("react").ForwardRefExoticComponent<DropdownButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
11
11
  export default DropdownButton;
@@ -3,11 +3,12 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  var _excluded = ["children", "title", "renderFooter"];
4
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ import { forwardRef } from "react";
6
7
  import { ChevronDown } from "react-feather";
7
8
  import Button from "../Button";
8
9
  import Dropdown from "./Dropdown";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
- export var DropdownButton = function DropdownButton(_ref) {
11
+ export var DropdownButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
11
12
  var children = _ref.children,
12
13
  title = _ref.title,
13
14
  renderFooter = _ref.renderFooter,
@@ -25,6 +26,7 @@ export var DropdownButton = function DropdownButton(_ref) {
25
26
  return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({}, buttonProps), {}, {
26
27
  onClick: handleClick,
27
28
  endIcon: ChevronDown,
29
+ ref: ref,
28
30
  children: title
29
31
  }));
30
32
  };
@@ -33,5 +35,6 @@ export var DropdownButton = function DropdownButton(_ref) {
33
35
  renderFooter: renderFooter,
34
36
  children: children
35
37
  });
36
- };
38
+ });
39
+ DropdownButton.displayName = "DropdownButton";
37
40
  export default DropdownButton;
@@ -1,7 +1,9 @@
1
1
  /// <reference types="react" />
2
- import type { ButtonBaseProps, ExtractProps } from "../Button/types";
3
- export declare type ButtonLinkProps = ButtonBaseProps & ExtractProps<"a"> & {
2
+ import { type PolymorphicButtonProps } from "../Button/PolymorphicButton";
3
+ export declare type ButtonLinkProps = Omit<PolymorphicButtonProps<"a">, "as" | "ref"> & {
4
4
  href: string;
5
5
  };
6
- export declare const ButtonLink: ({ endIcon: EndIcon, href, onClick, ...props }: ButtonLinkProps) => JSX.Element;
6
+ export declare const ButtonLink: import("react").ForwardRefExoticComponent<Omit<PolymorphicButtonProps<"a">, "ref" | "as"> & {
7
+ href: string;
8
+ } & import("react").RefAttributes<HTMLAnchorElement>>;
7
9
  export default ButtonLink;
@@ -3,11 +3,12 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  var _excluded = ["endIcon", "href", "onClick"];
4
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ import { forwardRef } from "react";
6
7
  import { ExternalLink } from "react-feather";
7
- import Button from "../Button/Button";
8
+ import { PolymorphicButton } from "../Button/PolymorphicButton";
8
9
  import useLinkProps from "../utils/useLinkProps";
9
10
  import { jsx as _jsx } from "react/jsx-runtime";
10
- export var ButtonLink = function ButtonLink(_ref) {
11
+ export var ButtonLink = /*#__PURE__*/forwardRef(function (_ref, ref) {
11
12
  var EndIcon = _ref.endIcon,
12
13
  href = _ref.href,
13
14
  onClick = _ref.onClick,
@@ -19,9 +20,11 @@ export var ButtonLink = function ButtonLink(_ref) {
19
20
  if (linkProps.target === "_blank" && EndIcon === undefined) {
20
21
  EndIcon = ExternalLink;
21
22
  }
22
- return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread(_objectSpread({}, props), linkProps), {}, {
23
- endIcon: EndIcon,
24
- as: "a"
23
+ return /*#__PURE__*/_jsx(PolymorphicButton, _objectSpread(_objectSpread(_objectSpread({}, props), linkProps), {}, {
24
+ ref: ref,
25
+ as: "a",
26
+ endIcon: EndIcon
25
27
  }));
26
- };
28
+ });
29
+ ButtonLink.displayName = "ButtonLink";
27
30
  export default ButtonLink;
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
- import { IconButtonBaseProps } from "../Button/IconButton";
3
- import type { ExtractProps } from "../Button/types";
4
- export declare type IconButtonLinkProps = IconButtonBaseProps & ExtractProps<"a"> & {
2
+ import { type PolymorphicIconButtonProps } from "../Button/PolymorphicIconButton";
3
+ export declare type IconButtonLinkProps = Omit<PolymorphicIconButtonProps<"a">, "as" | "ref"> & {
5
4
  href: string;
6
5
  };
7
- export declare const IconButtonLink: ({ href, onClick, ...props }: IconButtonLinkProps) => JSX.Element;
6
+ export declare const IconButtonLink: import("react").ForwardRefExoticComponent<Omit<PolymorphicIconButtonProps<"a">, "ref" | "as"> & {
7
+ href: string;
8
+ } & import("react").RefAttributes<HTMLAnchorElement>>;
8
9
  export default IconButtonLink;
@@ -3,10 +3,11 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  var _excluded = ["href", "onClick"];
4
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
- import IconButton from "../Button/IconButton";
6
+ import { forwardRef } from "react";
7
+ import { PolymorphicIconButton } from "../Button/PolymorphicIconButton";
7
8
  import useLinkProps from "../utils/useLinkProps";
8
9
  import { jsx as _jsx } from "react/jsx-runtime";
9
- export var IconButtonLink = function IconButtonLink(_ref) {
10
+ export var IconButtonLink = /*#__PURE__*/forwardRef(function (_ref, ref) {
10
11
  var href = _ref.href,
11
12
  onClick = _ref.onClick,
12
13
  props = _objectWithoutProperties(_ref, _excluded);
@@ -14,8 +15,10 @@ export var IconButtonLink = function IconButtonLink(_ref) {
14
15
  href: href,
15
16
  onClick: onClick
16
17
  }));
17
- return /*#__PURE__*/_jsx(IconButton, _objectSpread(_objectSpread(_objectSpread({}, props), linkProps), {}, {
18
- as: "a"
18
+ return /*#__PURE__*/_jsx(PolymorphicIconButton, _objectSpread(_objectSpread(_objectSpread({}, props), linkProps), {}, {
19
+ as: "a",
20
+ ref: ref
19
21
  }));
20
- };
22
+ });
23
+ IconButtonLink.displayName = "IconButtonLink";
21
24
  export default IconButtonLink;
@@ -8,7 +8,7 @@ var VARIANT_CLASSNAMES = {
8
8
  pink: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["medallion-pink text-pink-600"]))),
9
9
  accent: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["medallion-accent text-accent-600"]))),
10
10
  blue: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["medallion-blue text-blue-600"]))),
11
- green: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["medallion-green text-green-700"]))),
11
+ green: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["medallion-green text-green-600"]))),
12
12
  orange: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["medallion-orange text-orange-600"]))),
13
13
  red: stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["medallion-red text-red-600"]))),
14
14
  // eslint-disable-next-line @algolia/satellite/prefer-accent -- here we're definitely refering to the color itself
@@ -1,30 +1,54 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { XOR } from "../types";
2
3
  export declare type ModalSizeVariant = "medium" | "large";
3
4
  export declare type ModalLocale = {
4
5
  dismissText?: string;
6
+ modalTitle?: string;
5
7
  };
6
- export interface ModalProps {
7
- open?: boolean;
8
- /** Descriptive title for `Modal` */
8
+ interface ModalControlledProps {
9
+ /** Define whether the modal is open or closed. */
10
+ open: boolean;
11
+ /** The element that should receive focus once the `Modal` is closed. */
12
+ autoFocusOnCloseElement?: HTMLElement | null;
13
+ }
14
+ interface ModalUncontrolledProps {
15
+ /** Button which should trigger the modal */
16
+ triggerButton: ReactNode;
17
+ }
18
+ export declare type ModalProps = XOR<ModalControlledProps, ModalUncontrolledProps> & {
19
+ /** Descriptive title for `Modal`. */
9
20
  title?: ReactNode;
10
21
  /** @ignore */
11
22
  className?: string;
12
- /** Should the content take up full full width of the `Modal`. */
23
+ /** Define whether the content should take up the full width of the `Modal`. */
13
24
  fullBleed?: boolean;
14
- /** Define whether or not the modal should animate on show and hide */
25
+ /** Define whether or not the modal should animate on show and hide. */
15
26
  animate?: boolean;
27
+ /** Define the size of the `Modal`. */
16
28
  size?: ModalSizeVariant;
17
- /** Define whether or not the dismiss button should be hidden */
29
+ /** Define whether or not the dismiss button should be hidden. */
18
30
  hideCloseIcon?: boolean;
19
- /** Define whether or not the modal should be vertically aligned */
31
+ /** Define whether or not the modal should be vertically aligned. */
20
32
  centerY?: boolean;
21
- /** Function triggered when the dismiss button is clicked */
33
+ /**
34
+ * Function triggered when the modal is dismissed.
35
+ * This function is called when the user clicks the close button,
36
+ * clicks outside the modal or presses the escape key.
37
+ */
22
38
  onDismiss?: () => void;
23
- children: ReactNode;
39
+ /** The locale for the `Modal`. */
24
40
  locale?: ModalLocale;
25
- }
41
+ /**
42
+ * The element that should receive focus once the `Modal` is opened.
43
+ * If `undefined` or `null` is passed, the first focusable element will be focused.
44
+ * If `false`, no element will be focused.
45
+ */
46
+ autoFocusOnOpenElement?: HTMLElement | null | false;
47
+ children: ReactNode;
48
+ };
26
49
  export declare const Modal: {
27
- ({ title, className, children, open, fullBleed, onDismiss, animate, hideCloseIcon, size, centerY, locale: propsLocale, }: ModalProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
50
+ ({ title, className, children, open, onDismiss, fullBleed, animate, hideCloseIcon, size, centerY, autoFocusOnOpenElement, autoFocusOnCloseElement, triggerButton, locale: propsLocale, }: ModalProps): JSX.Element;
28
51
  Footer: import("react").FunctionComponent<import("./components/ModalFooter").ModalFooterProps>;
52
+ Section: ({ children, className, fullBleed }: import("./components/ModalSection").ModalSectionProps) => JSX.Element;
29
53
  };
30
54
  export default Modal;