@nulogy/components 8.15.3 → 8.17.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.
package/dist/main.js CHANGED
@@ -18838,7 +18838,8 @@
18838
18838
  cacheOptions = _a$cacheOptions === void 0 ? false : _a$cacheOptions,
18839
18839
  defaultOptions = _a.defaultOptions,
18840
18840
  loadOptions = _a.loadOptions,
18841
- props = __rest(_a, ["autocomplete", "labelText", "required", "requirementText", "helpText", "noOptionsMessage", "disabled", "errorMessage", "errorList", "error", "id", "initialIsOpen", "maxHeight", "menuPosition", "multiselect", "name", "onChange", "placeholder", "value", "defaultValue", "className", "classNamePrefix", "onBlur", "menuIsOpen", "onMenuOpen", "onMenuClose", "onInputChange", "components", "aria-label", "cacheOptions", "defaultOptions", "loadOptions"]);
18841
+ isClearable = _a.isClearable,
18842
+ props = __rest(_a, ["autocomplete", "labelText", "required", "requirementText", "helpText", "noOptionsMessage", "disabled", "errorMessage", "errorList", "error", "id", "initialIsOpen", "maxHeight", "menuPosition", "multiselect", "name", "onChange", "placeholder", "value", "defaultValue", "className", "classNamePrefix", "onBlur", "menuIsOpen", "onMenuOpen", "onMenuClose", "onInputChange", "components", "aria-label", "cacheOptions", "defaultOptions", "loadOptions", "isClearable"]);
18842
18843
 
18843
18844
  var _useTranslation = useTranslation(),
18844
18845
  t = _useTranslation.t;
@@ -18895,7 +18896,8 @@
18895
18896
  "aria-label": ariaLabel,
18896
18897
  cacheOptions: cacheOptions,
18897
18898
  defaultOptions: defaultOptions,
18898
- loadOptions: loadOptions
18899
+ loadOptions: loadOptions,
18900
+ isClearable: isClearable
18899
18901
  }), /*#__PURE__*/React__default["default"].createElement(InlineValidation, {
18900
18902
  mt: "x1",
18901
18903
  errorMessage: errorMessage,
@@ -41989,6 +41991,14 @@
41989
41991
  }, children));
41990
41992
  };
41991
41993
 
41994
+ var sidebarWidths = {
41995
+ xs: "400px",
41996
+ s: "520px",
41997
+ m: "640px",
41998
+ l: "768px",
41999
+ xl: "1024px"
42000
+ };
42001
+
41992
42002
  var focusFirstElement = function focusFirstElement() {
41993
42003
  var FOCUSABLE_EL_SELECTOR = "button, a[href], select, textarea, input, [tabindex]:not([tabindex='-1'])";
41994
42004
  var focusable = document.querySelectorAll(FOCUSABLE_EL_SELECTOR);
@@ -42030,11 +42040,13 @@
42030
42040
  });
42031
42041
  };
42032
42042
 
42033
- var Sidebar = function Sidebar(_a) {
42043
+ function Sidebar(_a) {
42044
+ var _b;
42045
+
42034
42046
  var _a$p = _a.p,
42035
- p = _a$p === void 0 ? "x3" : _a$p,
42047
+ p = _a$p === void 0 ? "x2" : _a$p,
42036
42048
  _a$width = _a.width,
42037
- width = _a$width === void 0 ? "400px" : _a$width,
42049
+ width = _a$width === void 0 ? "xs" : _a$width,
42038
42050
  children = _a.children,
42039
42051
  onClose = _a.onClose,
42040
42052
  title = _a.title,
@@ -42058,8 +42070,11 @@
42058
42070
  disableScroll = _a$disableScroll === void 0 ? true : _a$disableScroll,
42059
42071
  _a$hideCloseButton = _a.hideCloseButton,
42060
42072
  hideCloseButton = _a$hideCloseButton === void 0 ? false : _a$hideCloseButton,
42061
- zIndex = _a.zIndex,
42062
- props = __rest(_a, ["p", "width", "children", "onClose", "title", "isOpen", "footer", "closeButtonTestId", "closeButtonAriaLabel", "offset", "triggerRef", "duration", "top", "closeOnOutsideClick", "overlay", "disableScroll", "hideCloseButton", "zIndex"]);
42073
+ _a$zIndex = _a.zIndex,
42074
+ zIndex = _a$zIndex === void 0 ? "sidebar" : _a$zIndex,
42075
+ helpText = _a.helpText,
42076
+ renderHelpText = _a.renderHelpText,
42077
+ props = __rest(_a, ["p", "width", "children", "onClose", "title", "isOpen", "footer", "closeButtonTestId", "closeButtonAriaLabel", "offset", "triggerRef", "duration", "top", "closeOnOutsideClick", "overlay", "disableScroll", "hideCloseButton", "zIndex", "helpText", "renderHelpText"]);
42063
42078
 
42064
42079
  var closeButton = React.useRef(null);
42065
42080
 
@@ -42072,7 +42087,10 @@
42072
42087
 
42073
42088
  var sideBarRef = React.useRef(null);
42074
42089
  var contentRef = React.useRef(null);
42090
+ var selectedWidth = (_b = sidebarWidths[width]) !== null && _b !== void 0 ? _b : width;
42075
42091
  React.useEffect(function () {
42092
+ var _a;
42093
+
42076
42094
  if (closeButton.current && isOpen) {
42077
42095
  if (closeButton && closeButton.current) {
42078
42096
  closeButton.current.focus();
@@ -42081,7 +42099,7 @@
42081
42099
  }
42082
42100
  } else if (shouldUpdateFocus) {
42083
42101
  if (triggerRef) {
42084
- triggerRef.current.focus();
42102
+ (_a = triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
42085
42103
  } else {
42086
42104
  focusFirstElement();
42087
42105
  }
@@ -42141,11 +42159,11 @@
42141
42159
  position: "fixed",
42142
42160
  top: top,
42143
42161
  right: offset,
42144
- width: typeof width === "string" ? {
42162
+ width: typeof selectedWidth === "string" ? {
42145
42163
  default: "100%",
42146
- small: width
42147
- } : width,
42148
- zIndex: zIndex || "sidebar",
42164
+ small: selectedWidth
42165
+ } : selectedWidth,
42166
+ zIndex: zIndex,
42149
42167
  ref: sideBarRef
42150
42168
  }, props), /*#__PURE__*/React__default["default"].createElement(Flex, {
42151
42169
  p: p,
@@ -42157,9 +42175,14 @@
42157
42175
  overflowBehaviour: "contain"
42158
42176
  }
42159
42177
  }, /*#__PURE__*/React__default["default"].createElement(Flex, {
42160
- justifyContent: "space-between",
42161
- alignItems: "flex-start",
42178
+ flexDirection: "column",
42162
42179
  pb: "x3"
42180
+ }, /*#__PURE__*/React__default["default"].createElement(Flex, {
42181
+ flexDirection: "column",
42182
+ pb: "x2"
42183
+ }, /*#__PURE__*/React__default["default"].createElement(Flex, {
42184
+ justifyContent: "space-between",
42185
+ alignItems: "flex-start"
42163
42186
  }, title && /*#__PURE__*/React__default["default"].createElement(Flex, {
42164
42187
  alignItems: "center",
42165
42188
  height: "100%"
@@ -42174,7 +42197,13 @@
42174
42197
  onClick: onClose,
42175
42198
  "data-testid": closeButtonTestId,
42176
42199
  "aria-label": closeButtonAriaLabel || t("close")
42177
- }))), /*#__PURE__*/React__default["default"].createElement(AnimatedBox, {
42200
+ }))), renderHelpText ? renderHelpText() : helpText && /*#__PURE__*/React__default["default"].createElement(Text, {
42201
+ pt: "x1",
42202
+ color: "midGrey"
42203
+ }, helpText)), /*#__PURE__*/React__default["default"].createElement(Divider$1, {
42204
+ m: "0 -8px",
42205
+ width: "calc(100% + 16px)"
42206
+ })), /*#__PURE__*/React__default["default"].createElement(AnimatedBox, {
42178
42207
  variants: childVariants,
42179
42208
  animate: isOpen ? "open" : "closed",
42180
42209
  flexGrow: 1,
@@ -42192,7 +42221,7 @@
42192
42221
  }, footer), overlay && disableScroll && isOpen && /*#__PURE__*/React__default["default"].createElement(PreventBodyElementScrolling, {
42193
42222
  scrollRef: sideBarRef
42194
42223
  })));
42195
- };
42224
+ }
42196
42225
 
42197
42226
  var LoadingAnimation = function LoadingAnimation(_ref) {
42198
42227
  var inactive = _ref.inactive;
@@ -18815,7 +18815,8 @@ var AsyncSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
18815
18815
  cacheOptions = _a$cacheOptions === void 0 ? false : _a$cacheOptions,
18816
18816
  defaultOptions = _a.defaultOptions,
18817
18817
  loadOptions = _a.loadOptions,
18818
- props = __rest(_a, ["autocomplete", "labelText", "required", "requirementText", "helpText", "noOptionsMessage", "disabled", "errorMessage", "errorList", "error", "id", "initialIsOpen", "maxHeight", "menuPosition", "multiselect", "name", "onChange", "placeholder", "value", "defaultValue", "className", "classNamePrefix", "onBlur", "menuIsOpen", "onMenuOpen", "onMenuClose", "onInputChange", "components", "aria-label", "cacheOptions", "defaultOptions", "loadOptions"]);
18818
+ isClearable = _a.isClearable,
18819
+ props = __rest(_a, ["autocomplete", "labelText", "required", "requirementText", "helpText", "noOptionsMessage", "disabled", "errorMessage", "errorList", "error", "id", "initialIsOpen", "maxHeight", "menuPosition", "multiselect", "name", "onChange", "placeholder", "value", "defaultValue", "className", "classNamePrefix", "onBlur", "menuIsOpen", "onMenuOpen", "onMenuClose", "onInputChange", "components", "aria-label", "cacheOptions", "defaultOptions", "loadOptions", "isClearable"]);
18819
18820
 
18820
18821
  var _useTranslation = useTranslation(),
18821
18822
  t = _useTranslation.t;
@@ -18872,7 +18873,8 @@ var AsyncSelect = /*#__PURE__*/forwardRef(function (_a, ref) {
18872
18873
  "aria-label": ariaLabel,
18873
18874
  cacheOptions: cacheOptions,
18874
18875
  defaultOptions: defaultOptions,
18875
- loadOptions: loadOptions
18876
+ loadOptions: loadOptions,
18877
+ isClearable: isClearable
18876
18878
  }), /*#__PURE__*/React__default.createElement(InlineValidation, {
18877
18879
  mt: "x1",
18878
18880
  errorMessage: errorMessage,
@@ -41966,6 +41968,14 @@ var Page = function Page(_a) {
41966
41968
  }, children));
41967
41969
  };
41968
41970
 
41971
+ var sidebarWidths = {
41972
+ xs: "400px",
41973
+ s: "520px",
41974
+ m: "640px",
41975
+ l: "768px",
41976
+ xl: "1024px"
41977
+ };
41978
+
41969
41979
  var focusFirstElement = function focusFirstElement() {
41970
41980
  var FOCUSABLE_EL_SELECTOR = "button, a[href], select, textarea, input, [tabindex]:not([tabindex='-1'])";
41971
41981
  var focusable = document.querySelectorAll(FOCUSABLE_EL_SELECTOR);
@@ -42007,11 +42017,13 @@ var SidebarOverlay = function SidebarOverlay(_ref) {
42007
42017
  });
42008
42018
  };
42009
42019
 
42010
- var Sidebar = function Sidebar(_a) {
42020
+ function Sidebar(_a) {
42021
+ var _b;
42022
+
42011
42023
  var _a$p = _a.p,
42012
- p = _a$p === void 0 ? "x3" : _a$p,
42024
+ p = _a$p === void 0 ? "x2" : _a$p,
42013
42025
  _a$width = _a.width,
42014
- width = _a$width === void 0 ? "400px" : _a$width,
42026
+ width = _a$width === void 0 ? "xs" : _a$width,
42015
42027
  children = _a.children,
42016
42028
  onClose = _a.onClose,
42017
42029
  title = _a.title,
@@ -42035,8 +42047,11 @@ var Sidebar = function Sidebar(_a) {
42035
42047
  disableScroll = _a$disableScroll === void 0 ? true : _a$disableScroll,
42036
42048
  _a$hideCloseButton = _a.hideCloseButton,
42037
42049
  hideCloseButton = _a$hideCloseButton === void 0 ? false : _a$hideCloseButton,
42038
- zIndex = _a.zIndex,
42039
- props = __rest(_a, ["p", "width", "children", "onClose", "title", "isOpen", "footer", "closeButtonTestId", "closeButtonAriaLabel", "offset", "triggerRef", "duration", "top", "closeOnOutsideClick", "overlay", "disableScroll", "hideCloseButton", "zIndex"]);
42050
+ _a$zIndex = _a.zIndex,
42051
+ zIndex = _a$zIndex === void 0 ? "sidebar" : _a$zIndex,
42052
+ helpText = _a.helpText,
42053
+ renderHelpText = _a.renderHelpText,
42054
+ props = __rest(_a, ["p", "width", "children", "onClose", "title", "isOpen", "footer", "closeButtonTestId", "closeButtonAriaLabel", "offset", "triggerRef", "duration", "top", "closeOnOutsideClick", "overlay", "disableScroll", "hideCloseButton", "zIndex", "helpText", "renderHelpText"]);
42040
42055
 
42041
42056
  var closeButton = useRef(null);
42042
42057
 
@@ -42049,7 +42064,10 @@ var Sidebar = function Sidebar(_a) {
42049
42064
 
42050
42065
  var sideBarRef = useRef(null);
42051
42066
  var contentRef = useRef(null);
42067
+ var selectedWidth = (_b = sidebarWidths[width]) !== null && _b !== void 0 ? _b : width;
42052
42068
  useEffect(function () {
42069
+ var _a;
42070
+
42053
42071
  if (closeButton.current && isOpen) {
42054
42072
  if (closeButton && closeButton.current) {
42055
42073
  closeButton.current.focus();
@@ -42058,7 +42076,7 @@ var Sidebar = function Sidebar(_a) {
42058
42076
  }
42059
42077
  } else if (shouldUpdateFocus) {
42060
42078
  if (triggerRef) {
42061
- triggerRef.current.focus();
42079
+ (_a = triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
42062
42080
  } else {
42063
42081
  focusFirstElement();
42064
42082
  }
@@ -42118,11 +42136,11 @@ var Sidebar = function Sidebar(_a) {
42118
42136
  position: "fixed",
42119
42137
  top: top,
42120
42138
  right: offset,
42121
- width: typeof width === "string" ? {
42139
+ width: typeof selectedWidth === "string" ? {
42122
42140
  default: "100%",
42123
- small: width
42124
- } : width,
42125
- zIndex: zIndex || "sidebar",
42141
+ small: selectedWidth
42142
+ } : selectedWidth,
42143
+ zIndex: zIndex,
42126
42144
  ref: sideBarRef
42127
42145
  }, props), /*#__PURE__*/React__default.createElement(Flex, {
42128
42146
  p: p,
@@ -42134,9 +42152,14 @@ var Sidebar = function Sidebar(_a) {
42134
42152
  overflowBehaviour: "contain"
42135
42153
  }
42136
42154
  }, /*#__PURE__*/React__default.createElement(Flex, {
42137
- justifyContent: "space-between",
42138
- alignItems: "flex-start",
42155
+ flexDirection: "column",
42139
42156
  pb: "x3"
42157
+ }, /*#__PURE__*/React__default.createElement(Flex, {
42158
+ flexDirection: "column",
42159
+ pb: "x2"
42160
+ }, /*#__PURE__*/React__default.createElement(Flex, {
42161
+ justifyContent: "space-between",
42162
+ alignItems: "flex-start"
42140
42163
  }, title && /*#__PURE__*/React__default.createElement(Flex, {
42141
42164
  alignItems: "center",
42142
42165
  height: "100%"
@@ -42151,7 +42174,13 @@ var Sidebar = function Sidebar(_a) {
42151
42174
  onClick: onClose,
42152
42175
  "data-testid": closeButtonTestId,
42153
42176
  "aria-label": closeButtonAriaLabel || t("close")
42154
- }))), /*#__PURE__*/React__default.createElement(AnimatedBox, {
42177
+ }))), renderHelpText ? renderHelpText() : helpText && /*#__PURE__*/React__default.createElement(Text, {
42178
+ pt: "x1",
42179
+ color: "midGrey"
42180
+ }, helpText)), /*#__PURE__*/React__default.createElement(Divider$1, {
42181
+ m: "0 -8px",
42182
+ width: "calc(100% + 16px)"
42183
+ })), /*#__PURE__*/React__default.createElement(AnimatedBox, {
42155
42184
  variants: childVariants,
42156
42185
  animate: isOpen ? "open" : "closed",
42157
42186
  flexGrow: 1,
@@ -42169,7 +42198,7 @@ var Sidebar = function Sidebar(_a) {
42169
42198
  }, footer), overlay && disableScroll && isOpen && /*#__PURE__*/React__default.createElement(PreventBodyElementScrolling, {
42170
42199
  scrollRef: sideBarRef
42171
42200
  })));
42172
- };
42201
+ }
42173
42202
 
42174
42203
  var LoadingAnimation = function LoadingAnimation(_ref) {
42175
42204
  var inactive = _ref.inactive;
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  type AsyncSelectProps = {
3
3
  windowThreshold?: number;
4
+ isClearable?: boolean;
4
5
  filterOption?: (...args: any[]) => any;
5
6
  autocomplete?: boolean;
6
7
  disabled?: boolean;
@@ -21,12 +21,8 @@ export declare const WithADefaultValue: {
21
21
  name: string;
22
22
  };
23
23
  };
24
- export declare const Multiselect: {
25
- (): React.JSX.Element;
26
- story: {
27
- name: string;
28
- };
29
- };
24
+ export declare const Multiselect: () => React.JSX.Element;
25
+ export declare const WithAClearButton: () => React.JSX.Element;
30
26
  export declare const UsingRefToControlFocus: {
31
27
  (): React.JSX.Element;
32
28
  story: {
@@ -1,20 +1,25 @@
1
1
  import React, { RefObject } from "react";
2
2
  import { AnimatedBoxProps } from "../Box/Box";
3
- type SidebarProps = AnimatedBoxProps & {
3
+ type PredefinedSidebarWidth = "xs" | "s" | "m" | "l" | "xl";
4
+ type SidebarWidth = PredefinedSidebarWidth | (string & {});
5
+ type SidebarProps = Omit<AnimatedBoxProps, "width"> & {
4
6
  children?: React.ReactNode;
5
- onClose?: (arg: any) => any;
7
+ onClose?: () => void;
6
8
  title?: string;
7
9
  isOpen?: boolean;
8
10
  footer?: React.ReactNode;
9
11
  closeButtonTestId?: string;
10
12
  closeButtonAriaLabel?: string;
11
13
  offset?: string;
12
- triggerRef?: RefObject<any>;
14
+ triggerRef?: RefObject<HTMLInputElement | HTMLButtonElement>;
13
15
  duration?: number;
14
16
  closeOnOutsideClick?: boolean;
15
17
  overlay?: boolean;
16
18
  disableScroll?: boolean;
17
19
  hideCloseButton?: boolean;
20
+ width?: SidebarWidth;
21
+ helpText?: React.ReactNode;
22
+ renderHelpText?: () => React.ReactNode;
18
23
  };
19
- declare const Sidebar: React.FC<SidebarProps>;
24
+ declare function Sidebar({ p, width, children, onClose, title, isOpen, footer, closeButtonTestId, closeButtonAriaLabel, offset, triggerRef, duration, top, closeOnOutsideClick, overlay, disableScroll, hideCloseButton, zIndex, helpText, renderHelpText, ...props }: SidebarProps): React.JSX.Element;
20
25
  export default Sidebar;
@@ -16,3 +16,7 @@ export declare const WithCustomOffset: () => React.JSX.Element;
16
16
  export declare const DontCloseOnOutsideClick: () => React.JSX.Element;
17
17
  export declare const WithoutCloseButton: () => React.JSX.Element;
18
18
  export declare const WithALongTitle: () => React.JSX.Element;
19
+ export declare const WithDifferentWidths: () => React.JSX.Element;
20
+ export declare const WithHelpText: () => React.JSX.Element;
21
+ export declare const WithOtherElementsInHelpText: () => React.JSX.Element;
22
+ export declare const WithARenderedHelpText: () => React.JSX.Element;
@@ -36,6 +36,7 @@ export type SelectProps = {
36
36
  closeMenuOnSelect?: boolean;
37
37
  "aria-label"?: string;
38
38
  size?: ComponentSize;
39
+ isClearable?: boolean;
39
40
  [key: string]: any;
40
41
  };
41
42
  export declare const SelectDefaultProps: {
@@ -47,6 +47,7 @@ export declare const Required: {
47
47
  name: string;
48
48
  };
49
49
  };
50
+ export declare const WithAClearButton: () => React.JSX.Element;
50
51
  export declare const WithHelpText: {
51
52
  (): React.JSX.Element;
52
53
  story: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nulogy/components",
3
- "version": "8.15.3",
3
+ "version": "8.17.0",
4
4
  "description": "Component library for the Nulogy Design System - http://nulogy.design",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -132,7 +132,7 @@
132
132
  "semantic-release": "^17.2.1",
133
133
  "source-map-loader": "^1.0.1",
134
134
  "storybook-addon-performance": "^0.17.1",
135
- "styled-components": "^5.1.0",
135
+ "styled-components": "^5.3.11",
136
136
  "svg-sprite-loader": "^6.0.11",
137
137
  "ts-jest": "^26.1.1",
138
138
  "typescript": "4.9.5",