@canonical/react-components 0.36.0 → 0.37.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 (72) hide show
  1. package/dist/components/Accordion/Accordion.js +1 -1
  2. package/dist/components/ActionButton/ActionButton.js +1 -1
  3. package/dist/components/ArticlePagination/ArticlePagination.js +1 -1
  4. package/dist/components/Button/Button.d.ts +1 -0
  5. package/dist/components/Button/Button.js +2 -1
  6. package/dist/components/Card/Card.js +1 -1
  7. package/dist/components/CheckableInput/CheckableInput.js +1 -1
  8. package/dist/components/CheckboxInput/CheckboxInput.js +1 -1
  9. package/dist/components/Chip/Chip.js +1 -1
  10. package/dist/components/Code/Code.js +1 -1
  11. package/dist/components/CodeSnippet/CodeSnippet.js +1 -1
  12. package/dist/components/CodeSnippet/CodeSnippetBlock.js +1 -1
  13. package/dist/components/CodeSnippet/CodeSnippetDropdown.js +1 -1
  14. package/dist/components/Col/Col.js +1 -1
  15. package/dist/components/ContextualMenu/ContextualMenu.js +1 -2
  16. package/dist/components/ContextualMenu/ContextualMenuDropdown/ContextualMenuDropdown.js +1 -1
  17. package/dist/components/Form/Form.js +1 -1
  18. package/dist/components/Icon/Icon.js +1 -1
  19. package/dist/components/Input/Input.js +1 -1
  20. package/dist/components/Label/Label.js +1 -1
  21. package/dist/components/Link/Link.js +1 -1
  22. package/dist/components/List/List.js +28 -17
  23. package/dist/components/MainTable/MainTable.js +2 -2
  24. package/dist/components/Modal/Modal.js +1 -1
  25. package/dist/components/ModularTable/ModularTable.js +1 -1
  26. package/dist/components/Navigation/Navigation.d.ts +57 -0
  27. package/dist/components/Navigation/Navigation.js +266 -0
  28. package/dist/components/Navigation/NavigationLink/NavigationLink.d.ts +11 -0
  29. package/dist/components/Navigation/NavigationLink/NavigationLink.js +57 -0
  30. package/dist/components/Navigation/NavigationLink/index.d.ts +1 -0
  31. package/dist/components/Navigation/NavigationLink/index.js +15 -0
  32. package/dist/components/Navigation/NavigationMenu/NavigationMenu.d.ts +11 -0
  33. package/dist/components/Navigation/NavigationMenu/NavigationMenu.js +97 -0
  34. package/dist/components/Navigation/NavigationMenu/index.d.ts +1 -0
  35. package/dist/components/Navigation/NavigationMenu/index.js +15 -0
  36. package/dist/components/Navigation/index.d.ts +3 -0
  37. package/dist/components/Navigation/index.js +15 -0
  38. package/dist/components/Navigation/types.d.ts +57 -0
  39. package/dist/components/Navigation/types.js +5 -0
  40. package/dist/components/Notification/Notification.js +1 -1
  41. package/dist/components/PasswordToggle/PasswordToggle.js +1 -1
  42. package/dist/components/RadioInput/RadioInput.js +1 -1
  43. package/dist/components/Row/Row.js +1 -1
  44. package/dist/components/SearchAndFilter/SearchAndFilter.js +12 -16
  45. package/dist/components/SearchBox/SearchBox.d.ts +6 -5
  46. package/dist/components/SearchBox/SearchBox.js +22 -8
  47. package/dist/components/Select/Select.js +1 -1
  48. package/dist/components/Slider/Slider.js +1 -1
  49. package/dist/components/Spinner/Spinner.js +1 -1
  50. package/dist/components/StatusLabel/StatusLabel.d.ts +31 -0
  51. package/dist/components/StatusLabel/StatusLabel.js +51 -0
  52. package/dist/components/StatusLabel/index.d.ts +2 -0
  53. package/dist/components/StatusLabel/index.js +25 -0
  54. package/dist/components/Strip/Strip.js +1 -1
  55. package/dist/components/Switch/Switch.js +1 -1
  56. package/dist/components/Table/Table.js +1 -1
  57. package/dist/components/TableCell/TableCell.js +1 -1
  58. package/dist/components/TableHeader/TableHeader.js +1 -1
  59. package/dist/components/TableRow/TableRow.js +1 -1
  60. package/dist/components/Tabs/Tabs.js +1 -1
  61. package/dist/components/Textarea/Textarea.js +1 -1
  62. package/dist/hooks/index.d.ts +4 -2
  63. package/dist/hooks/index.js +19 -3
  64. package/dist/hooks/useClickOutside.d.ts +7 -0
  65. package/dist/hooks/useClickOutside.js +41 -0
  66. package/dist/hooks/useOnEscapePressed.d.ts +4 -0
  67. package/dist/hooks/useOnEscapePressed.js +27 -0
  68. package/dist/index.d.ts +6 -2
  69. package/dist/index.js +34 -0
  70. package/dist/types/index.d.ts +13 -0
  71. package/dist/types/index.js +49 -1
  72. package/package.json +42 -40
@@ -17,6 +17,8 @@ var _Chip = _interopRequireDefault(require("../Chip"));
17
17
 
18
18
  var _utils = require("./utils");
19
19
 
20
+ var _hooks = require("../../hooks");
21
+
20
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
23
 
22
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -108,14 +110,18 @@ var SearchAndFilter = function SearchAndFilter(_ref) {
108
110
  return function () {
109
111
  document.removeEventListener("click", searchContainerClickCheck);
110
112
  };
111
- }, [searchContainerActive]); // This useEffect sets up listeners so the panel will close if user clicks
113
+ }, [searchContainerActive]);
114
+
115
+ var closePanel = function closePanel() {
116
+ setFilterPanelHidden(true);
117
+ };
118
+
119
+ (0, _hooks.useOnEscapePressed)(function () {
120
+ return closePanel();
121
+ }); // This useEffect sets up listeners so the panel will close if user clicks
112
122
  // anywhere else on the page or hits the escape key
113
123
 
114
124
  (0, _react.useEffect)(function () {
115
- var closePanel = function closePanel() {
116
- setFilterPanelHidden(true);
117
- };
118
-
119
125
  var mouseDown = function mouseDown(e) {
120
126
  var _searchAndFilterRef$c;
121
127
 
@@ -124,23 +130,13 @@ var SearchAndFilter = function SearchAndFilter(_ref) {
124
130
  // If so, close the panel
125
131
  closePanel();
126
132
  }
127
- };
128
-
129
- var keyDown = function keyDown(e) {
130
- if (e.code === "Escape") {
131
- // Close panel if Esc keydown detected
132
- closePanel();
133
- }
134
133
  }; // Add listener on document to capture click events
135
134
 
136
135
 
137
- document.addEventListener("mousedown", mouseDown); // Add listener on document to capture keydown events
138
-
139
- document.addEventListener("keydown", keyDown); // return function to be called when unmounted
136
+ document.addEventListener("mousedown", mouseDown); // return function to be called when unmounted
140
137
 
141
138
  return function () {
142
139
  document.removeEventListener("mousedown", mouseDown);
143
- document.removeEventListener("keydown", keyDown);
144
140
  };
145
141
  }, []); // Add passed chip to the searchData array
146
142
 
@@ -1,4 +1,4 @@
1
- import { HTMLProps } from "react";
1
+ import React, { HTMLProps } from "react";
2
2
  import type { ClassName, PropsWithSpread } from "../../types";
3
3
  export declare type Props = PropsWithSpread<{
4
4
  /**
@@ -29,13 +29,14 @@ export declare type Props = PropsWithSpread<{
29
29
  * A search input placeholder message.
30
30
  */
31
31
  placeholder?: string;
32
+ /**
33
+ * A ref that is passed to the input element.
34
+ */
35
+ ref?: string;
32
36
  /**
33
37
  * The value of the search input when the state is externally controlled.
34
38
  */
35
39
  value?: string;
36
40
  }, HTMLProps<HTMLInputElement>>;
37
- declare const SearchBox: {
38
- ({ autocomplete, className, disabled, externallyControlled, onChange, onSearch, placeholder, value, ...props }: Props): JSX.Element;
39
- displayName: string;
40
- };
41
+ declare const SearchBox: React.ForwardRefExoticComponent<Pick<Props, "content" | "title" | "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "pattern" | "children" | "className" | "key" | "list" | "role" | "id" | "onClick" | "type" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "as" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "dateTime" | "default" | "defer" | "disabled" | "download" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "height" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "name" | "nonce" | "noValidate" | "open" | "optimum" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "size" | "sizes" | "src" | "srcDoc" | "srcLang" | "srcSet" | "start" | "step" | "target" | "useMap" | "value" | "width" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "externallyControlled" | "autocomplete" | "onSearch"> & React.RefAttributes<HTMLInputElement>>;
41
42
  export default SearchBox;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -7,21 +9,25 @@ exports.default = void 0;
7
9
 
8
10
  var _classnames = _interopRequireDefault(require("classnames"));
9
11
 
10
- var _react = _interopRequireDefault(require("react"));
12
+ var _react = _interopRequireWildcard(require("react"));
11
13
 
12
14
  var _Icon = _interopRequireDefault(require("../Icon"));
13
15
 
14
16
  var _excluded = ["autocomplete", "className", "disabled", "externallyControlled", "onChange", "onSearch", "placeholder", "value"];
15
17
 
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
16
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
23
 
18
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
24
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
25
 
20
26
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
21
27
 
22
28
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
23
29
 
24
- var SearchBox = function SearchBox(_ref) {
30
+ var SearchBox = /*#__PURE__*/_react.default.forwardRef(function (_ref, forwardedRef) {
25
31
  var _ref$autocomplete = _ref.autocomplete,
26
32
  autocomplete = _ref$autocomplete === void 0 ? "on" : _ref$autocomplete,
27
33
  className = _ref.className,
@@ -34,13 +40,13 @@ var SearchBox = function SearchBox(_ref) {
34
40
  value = _ref.value,
35
41
  props = _objectWithoutProperties(_ref, _excluded);
36
42
 
37
- var input = /*#__PURE__*/_react.default.createRef();
43
+ var internalRef = (0, _react.useRef)();
38
44
 
39
45
  var resetInput = function resetInput() {
40
46
  _onChange && _onChange("");
41
47
 
42
- if (input.current) {
43
- input.current.value = "";
48
+ if (internalRef.current) {
49
+ internalRef.current.value = "";
44
50
  }
45
51
  };
46
52
 
@@ -63,7 +69,15 @@ var SearchBox = function SearchBox(_ref) {
63
69
  return _onChange(evt.target.value);
64
70
  },
65
71
  placeholder: placeholder,
66
- ref: input,
72
+ ref: function ref(input) {
73
+ internalRef.current = input; // Handle both function and object refs.
74
+
75
+ if (typeof forwardedRef === "function") {
76
+ forwardedRef(input);
77
+ } else if (forwardedRef) {
78
+ forwardedRef.current = input;
79
+ }
80
+ },
67
81
  type: "search",
68
82
  defaultValue: externallyControlled ? undefined : value,
69
83
  value: externallyControlled ? value : undefined
@@ -81,7 +95,7 @@ var SearchBox = function SearchBox(_ref) {
81
95
  }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
82
96
  name: "search"
83
97
  }, "Search")));
84
- };
98
+ });
85
99
 
86
100
  SearchBox.displayName = "SearchBox";
87
101
  var _default = SearchBox;
@@ -24,7 +24,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
24
24
 
25
25
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
26
 
27
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
27
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
28
28
 
29
29
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
30
30
 
@@ -15,7 +15,7 @@ var _excluded = ["caution", "disabled", "error", "help", "id", "inputDisabled",
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
18
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
19
 
20
20
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
21
21
 
@@ -15,7 +15,7 @@ var _excluded = ["className", "text", "isLight", "ariaLive", "role"];
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
18
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
19
19
 
20
20
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
21
21
 
@@ -0,0 +1,31 @@
1
+ import type { HTMLProps, ReactNode } from "react";
2
+ import { ClassName, PropsWithSpread, ValueOf } from "../../types";
3
+ export declare const StatusLabelAppearance: {
4
+ readonly CAUTION: "caution";
5
+ readonly DEFAULT: "";
6
+ readonly INFORMATION: "information";
7
+ readonly NEGATIVE: "negative";
8
+ readonly POSITIVE: "positive";
9
+ };
10
+ /**
11
+ * The type of the StatusLabel props.
12
+ */
13
+ export declare type Props = PropsWithSpread<{
14
+ /**
15
+ * The appearance of the label.
16
+ */
17
+ appearance?: ValueOf<typeof StatusLabelAppearance> | string;
18
+ /**
19
+ * The content of the label.
20
+ */
21
+ children?: ReactNode;
22
+ /**
23
+ * Optional class(es) to pass to the wrapping element.
24
+ */
25
+ className?: ClassName;
26
+ }, HTMLProps<HTMLDivElement>>;
27
+ /**
28
+ * A component for the Vanilla Label.
29
+ */
30
+ declare const StatusLabel: ({ appearance, children, className, ...labelProps }: Props) => JSX.Element;
31
+ export default StatusLabel;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.StatusLabelAppearance = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+
12
+ var _excluded = ["appearance", "children", "className"];
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
+
18
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
+
20
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
21
+
22
+ var StatusLabelAppearance = {
23
+ CAUTION: "caution",
24
+ DEFAULT: "",
25
+ INFORMATION: "information",
26
+ NEGATIVE: "negative",
27
+ POSITIVE: "positive"
28
+ };
29
+ /**
30
+ * The type of the StatusLabel props.
31
+ */
32
+
33
+ exports.StatusLabelAppearance = StatusLabelAppearance;
34
+
35
+ /**
36
+ * A component for the Vanilla Label.
37
+ */
38
+ var StatusLabel = function StatusLabel(_ref) {
39
+ var appearance = _ref.appearance,
40
+ children = _ref.children,
41
+ className = _ref.className,
42
+ labelProps = _objectWithoutProperties(_ref, _excluded);
43
+
44
+ var classes = (0, _classnames.default)(appearance ? "p-status-label--".concat(appearance) : "p-status-label", className);
45
+ return /*#__PURE__*/_react.default.createElement("div", _extends({}, labelProps, {
46
+ className: classes
47
+ }), children);
48
+ };
49
+
50
+ var _default = StatusLabel;
51
+ exports.default = _default;
@@ -0,0 +1,2 @@
1
+ export { default, StatusLabelAppearance } from "./StatusLabel";
2
+ export type { Props as StatusLabelProps } from "./StatusLabel";
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "StatusLabelAppearance", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _StatusLabel.StatusLabelAppearance;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "default", {
15
+ enumerable: true,
16
+ get: function get() {
17
+ return _StatusLabel.default;
18
+ }
19
+ });
20
+
21
+ var _StatusLabel = _interopRequireWildcard(require("./StatusLabel"));
22
+
23
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
+
25
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -17,7 +17,7 @@ var _excluded = ["background", "bordered", "children", "className", "colSize", "
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
20
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
21
21
 
22
22
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
23
 
@@ -11,7 +11,7 @@ var _excluded = ["label", "disabled"];
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
15
 
16
16
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
17
 
@@ -13,7 +13,7 @@ var _excluded = ["children", "className", "expanding", "responsive"];
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
16
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
17
 
18
18
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
19
 
@@ -13,7 +13,7 @@ var _excluded = ["children", "className", "hasOverflow", "expanding", "hidden",
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
16
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
17
 
18
18
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
19
 
@@ -11,7 +11,7 @@ var _excluded = ["children", "sort"];
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
15
 
16
16
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
17
 
@@ -11,7 +11,7 @@ var _excluded = ["children"];
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
15
 
16
16
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
17
17
 
@@ -13,7 +13,7 @@ var _excluded = ["active", "className", "component", "label", "listItemClassName
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
16
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
17
 
18
18
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
19
 
@@ -23,7 +23,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
26
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
26
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
27
27
 
28
28
  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; }
29
29
 
@@ -1,7 +1,9 @@
1
- export { useWindowFitment } from "./useWindowFitment";
1
+ export { useClickOutside } from "./useClickOutside";
2
+ export { useId } from "./useId";
2
3
  export { useListener } from "./useListener";
4
+ export { useOnEscapePressed } from "./useOnEscapePressed";
3
5
  export { usePrevious } from "./usePrevious";
4
6
  export { useThrottle } from "./useThrottle";
5
- export { useId } from "./useId";
6
7
  export { usePagination } from "./usePagination";
8
+ export { useWindowFitment } from "./useWindowFitment";
7
9
  export type { WindowFitment } from "./useWindowFitment";
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "useClickOutside", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _useClickOutside.useClickOutside;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "useId", {
7
13
  enumerable: true,
8
14
  get: function get() {
@@ -15,6 +21,12 @@ Object.defineProperty(exports, "useListener", {
15
21
  return _useListener.useListener;
16
22
  }
17
23
  });
24
+ Object.defineProperty(exports, "useOnEscapePressed", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _useOnEscapePressed.useOnEscapePressed;
28
+ }
29
+ });
18
30
  Object.defineProperty(exports, "usePagination", {
19
31
  enumerable: true,
20
32
  get: function get() {
@@ -40,14 +52,18 @@ Object.defineProperty(exports, "useWindowFitment", {
40
52
  }
41
53
  });
42
54
 
43
- var _useWindowFitment = require("./useWindowFitment");
55
+ var _useClickOutside = require("./useClickOutside");
56
+
57
+ var _useId = require("./useId");
44
58
 
45
59
  var _useListener = require("./useListener");
46
60
 
61
+ var _useOnEscapePressed = require("./useOnEscapePressed");
62
+
47
63
  var _usePrevious = require("./usePrevious");
48
64
 
49
65
  var _useThrottle = require("./useThrottle");
50
66
 
51
- var _useId = require("./useId");
67
+ var _usePagination = require("./usePagination");
52
68
 
53
- var _usePagination = require("./usePagination");
69
+ var _useWindowFitment = require("./useWindowFitment");
@@ -0,0 +1,7 @@
1
+ import { MutableRefObject } from "react";
2
+ /**
3
+ * Handle clicks outside an element.
4
+ * @returns An id and ref to pass to the element to handle clicks
5
+ * outside of.
6
+ */
7
+ export declare const useClickOutside: <E extends HTMLElement>(onClickOutside: () => void) => [MutableRefObject<E>, string];
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useClickOutside = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _useId = require("./useId");
11
+
12
+ /**
13
+ * Handle clicks outside an element.
14
+ * @returns An id and ref to pass to the element to handle clicks
15
+ * outside of.
16
+ */
17
+ var useClickOutside = function useClickOutside(onClickOutside) {
18
+ var wrapperRef = (0, _react.useRef)(null);
19
+ var id = (0, _useId.useId)();
20
+ var handleClickOutside = (0, _react.useCallback)(function (evt) {
21
+ var _evt$target, _wrapperRef$current;
22
+
23
+ var target = evt.target; // The target might be something like an SVG node which doesn't provide
24
+ // the class name as a string.
25
+
26
+ var isValidTarget = typeof (evt === null || evt === void 0 ? void 0 : (_evt$target = evt.target) === null || _evt$target === void 0 ? void 0 : _evt$target.className) === "string";
27
+
28
+ if (!isValidTarget || wrapperRef.current && !((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(target)) && target.id !== id) {
29
+ onClickOutside();
30
+ }
31
+ }, [id, onClickOutside]);
32
+ (0, _react.useEffect)(function () {
33
+ document.addEventListener("click", handleClickOutside, false);
34
+ return function () {
35
+ return document.removeEventListener("click", handleClickOutside, false);
36
+ };
37
+ }, [handleClickOutside]);
38
+ return [wrapperRef, id];
39
+ };
40
+
41
+ exports.useClickOutside = useClickOutside;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Handle the escape key pressed.
3
+ */
4
+ export declare const useOnEscapePressed: (onEscape: () => void) => void;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useOnEscapePressed = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ /**
11
+ * Handle the escape key pressed.
12
+ */
13
+ var useOnEscapePressed = function useOnEscapePressed(onEscape) {
14
+ var keyDown = (0, _react.useCallback)(function (evt) {
15
+ if (evt.code === "Escape") {
16
+ onEscape();
17
+ }
18
+ }, [onEscape]);
19
+ (0, _react.useEffect)(function () {
20
+ document.addEventListener("keydown", keyDown);
21
+ return function () {
22
+ document.removeEventListener("keydown", keyDown);
23
+ };
24
+ }, [keyDown]);
25
+ };
26
+
27
+ exports.useOnEscapePressed = useOnEscapePressed;
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export { default as List } from "./components/List";
19
19
  export { default as Loader } from "./components/Loader";
20
20
  export { default as MainTable } from "./components/MainTable";
21
21
  export { default as ModularTable } from "./components/ModularTable";
22
+ export { default as Navigation } from "./components/Navigation";
22
23
  export { default as Modal } from "./components/Modal";
23
24
  export { default as Notification, NotificationSeverity, } from "./components/Notification";
24
25
  export { default as Pagination } from "./components/Pagination";
@@ -31,6 +32,7 @@ export { default as Select } from "./components/Select";
31
32
  export { default as Slider } from "./components/Slider";
32
33
  export { default as Switch } from "./components/Switch";
33
34
  export { default as Spinner } from "./components/Spinner";
35
+ export { default as StatusLabel, StatusLabelAppearance, } from "./components/StatusLabel";
34
36
  export { default as Strip } from "./components/Strip";
35
37
  export { default as SummaryButton } from "./components/SummaryButton";
36
38
  export { default as Table } from "./components/Table";
@@ -63,6 +65,7 @@ export type { ListProps } from "./components/List";
63
65
  export type { MainTableProps } from "./components/MainTable";
64
66
  export type { ModularTableProps } from "./components/ModularTable";
65
67
  export type { ModalProps } from "./components/Modal";
68
+ export type { GenerateLink, LogoProps, NavigationProps, NavItem, NavLink, } from "./components/Navigation";
66
69
  export type { NotificationProps } from "./components/Notification";
67
70
  export type { PaginationProps } from "./components/Pagination";
68
71
  export type { RadioInputProps } from "./components/RadioInput";
@@ -72,6 +75,7 @@ export type { SearchBoxProps } from "./components/SearchBox";
72
75
  export type { SelectProps } from "./components/Select";
73
76
  export type { SliderProps } from "./components/Slider";
74
77
  export type { SpinnerProps } from "./components/Spinner";
78
+ export type { StatusLabelProps } from "./components/StatusLabel";
75
79
  export type { StripProps } from "./components/Strip";
76
80
  export type { SummaryButtonProps } from "./components/SummaryButton";
77
81
  export type { TableProps } from "./components/Table";
@@ -81,6 +85,6 @@ export type { TableRowProps } from "./components/TableRow";
81
85
  export type { TabsProps } from "./components/Tabs";
82
86
  export type { TextareaProps } from "./components/Textarea";
83
87
  export type { TooltipProps } from "./components/Tooltip";
84
- export { useWindowFitment, useListener, usePrevious, useThrottle, useId, } from "./hooks";
88
+ export { useClickOutside, useId, useListener, useOnEscapePressed, usePrevious, useThrottle, useWindowFitment, } from "./hooks";
85
89
  export type { WindowFitment } from "./hooks";
86
- export type { ClassName, Headings, PropsWithSpread, SortDirection, SubComponentProps, TSFixMe, ValueOf, } from "./types";
90
+ export type { ClassName, Headings, PropsWithSpread, SortDirection, SubComponentProps, Theme, TSFixMe, ValueOf, } from "./types";