@mmb-digital/ds-lilly 0.7.1 → 0.7.4

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/ds-lilly.js CHANGED
@@ -87067,7 +87067,7 @@ var Button_rest = (undefined && undefined.__rest) || function (s, e) {
87067
87067
 
87068
87068
  var Button = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["forwardRef"])(function (_a, ref) {
87069
87069
  var _b;
87070
- var _c = _a.allowEventPropagation, allowEventPropagation = _c === void 0 ? false : _c, ariaLabel = _a.ariaLabel, children = _a.children, color = _a.color, disabledTooltip = _a.disabledTooltip, disabledTooltipType = _a.disabledTooltipType, _d = _a.elementType, elementType = _d === void 0 ? 'button' : _d, isBlock = _a.isBlock, isDisabled = _a.isDisabled, isLoading = _a.isLoading, isRounded = _a.isRounded, isSmall = _a.isSmall, linkDownloadTitle = _a.linkDownloadTitle, linkUrl = _a.linkUrl, onClick = _a.onClick, onlyIconName = _a.onlyIconName, _e = _a.testId, testId = _e === void 0 ? 'Button' : _e, theme = _a.theme, title = _a.title, _f = _a.type, type = _f === void 0 ? 'filled' : _f, rest = Button_rest(_a, ["allowEventPropagation", "ariaLabel", "children", "color", "disabledTooltip", "disabledTooltipType", "elementType", "isBlock", "isDisabled", "isLoading", "isRounded", "isSmall", "linkDownloadTitle", "linkUrl", "onClick", "onlyIconName", "testId", "theme", "title", "type"]);
87070
+ var _c = _a.allowEventPropagation, allowEventPropagation = _c === void 0 ? false : _c, ariaLabel = _a.ariaLabel, children = _a.children, color = _a.color, disabledTooltip = _a.disabledTooltip, disabledTooltipType = _a.disabledTooltipType, _d = _a.elementType, elementType = _d === void 0 ? 'button' : _d, isBlock = _a.isBlock, isDisabled = _a.isDisabled, isLoading = _a.isLoading, isRounded = _a.isRounded, isSmall = _a.isSmall, linkDownloadTitle = _a.linkDownloadTitle, linkUrl = _a.linkUrl, onClick = _a.onClick, onKeyDown = _a.onKeyDown, onlyIconName = _a.onlyIconName, _e = _a.testId, testId = _e === void 0 ? 'Button' : _e, theme = _a.theme, title = _a.title, _f = _a.type, type = _f === void 0 ? 'filled' : _f, rest = Button_rest(_a, ["allowEventPropagation", "ariaLabel", "children", "color", "disabledTooltip", "disabledTooltipType", "elementType", "isBlock", "isDisabled", "isLoading", "isRounded", "isSmall", "linkDownloadTitle", "linkUrl", "onClick", "onKeyDown", "onlyIconName", "testId", "theme", "title", "type"]);
87071
87071
  var handleOnClick = function (event) {
87072
87072
  if (isDisabled || isLoading) {
87073
87073
  event.preventDefault();
@@ -87096,7 +87096,7 @@ var Button = Object(external_root_React_commonjs2_react_commonjs_react_amd_react
87096
87096
  _b["c-btn--" + type] = type !== 'filled',
87097
87097
  _b["c-btn--" + color] = color,
87098
87098
  _b['c-btn--onlyIcon'] = onlyIconName,
87099
- _b), theme), "data-testid": testId, disabled: (isDisabled || isLoading) && !disabledTooltip, download: linkDownloadTitle, href: linkUrl, title: title, type: linkUrl ? undefined : elementType, onClick: handleOnClick }, rest),
87099
+ _b), theme), "data-testid": testId, disabled: (isDisabled || isLoading) && !disabledTooltip, download: linkDownloadTitle, href: linkUrl, title: title, type: linkUrl ? undefined : elementType, onClick: handleOnClick, onKeyDown: onKeyDown }, rest),
87100
87100
  isLoading && external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "loading" }),
87101
87101
  onlyIconName ? (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["Fragment"], null,
87102
87102
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: onlyIconName }),
@@ -96384,13 +96384,17 @@ var Dropdown = function (_a) {
96384
96384
  // CONCATENATED MODULE: ./src/components/Components/Dropdown/_elements_/DropdownMenu.tsx
96385
96385
 
96386
96386
 
96387
- var DropdownMenu = function (_a) {
96387
+ var DropdownMenu = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["forwardRef"])(function (_a, ref) {
96388
96388
  var _b;
96389
96389
  var activeDescendant = _a.activeDescendant, _c = _a.ariaHidden, ariaHidden = _c === void 0 ? false : _c, children = _a.children, id = _a.id, labelledBy = _a.labelledBy, onBlur = _a.onBlur, onKeyDown = _a.onKeyDown, role = _a.role, tabIndex = _a.tabIndex, testId = _a.testId, theme = _a.theme, title = _a.title;
96390
96390
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["Fragment"], null,
96391
96391
  title && external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: classBinder_cx('c-dropdown__title') }, title),
96392
- external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("ul", { "aria-activedescendant": activeDescendant, "aria-hidden": ariaHidden, "aria-labelledby": labelledBy, className: classBinder_cx('c-dropdown__menu', (_b = {}, _b["c-dropdown__menu--categorised"] = title, _b), theme), "data-testid": testId, id: id, role: role, tabIndex: tabIndex, onBlur: onBlur, onKeyDown: onKeyDown }, children)));
96393
- };
96392
+ external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("ul", {
96393
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
96394
+ // @ts-ignore
96395
+ ref: ref, "aria-activedescendant": activeDescendant, "aria-hidden": ariaHidden, "aria-labelledby": labelledBy, className: classBinder_cx('c-dropdown__menu', (_b = {}, _b["c-dropdown__menu--categorised"] = title, _b), theme), "data-testid": testId, id: id, role: role, tabIndex: tabIndex, onBlur: onBlur, onKeyDown: onKeyDown }, children)));
96396
+ });
96397
+ DropdownMenu.displayName = 'forwardRef(DropdownMenu)';
96394
96398
 
96395
96399
  // CONCATENATED MODULE: ./src/components/Components/Dropdown/_elements_/DropdownItem.tsx
96396
96400
 
@@ -96425,8 +96429,6 @@ var DropdownItem = function (_a) {
96425
96429
  };
96426
96430
 
96427
96431
  // CONCATENATED MODULE: ./src/components/Components/CompactButtons/CompactButtons.tsx
96428
- // TODO: enable eslint react-hooks/exhaustive-deps
96429
- /* eslint-disable react-hooks/exhaustive-deps */
96430
96432
  var CompactButtons_assign = (undefined && undefined.__assign) || function () {
96431
96433
  CompactButtons_assign = Object.assign || function(t) {
96432
96434
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -96456,10 +96458,32 @@ var CompactButtons = function (_a) {
96456
96458
  var background = _a.background, buttons = _a.buttons, isSmall = _a.isSmall, _b = _a.maxVisibleButtons, maxVisibleButtons = _b === void 0 ? buttons.length : _b, theme = _a.theme, _c = _a.type, type = _c === void 0 ? 'filled' : _c;
96457
96459
  var container = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useRef"])(null);
96458
96460
  var refs = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useRef"])([]);
96461
+ var dropdownRef = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useRef"])();
96459
96462
  var width = useContainerDimensions(container).width;
96460
96463
  var _d = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(false), isDropdownVisible = _d[0], setIsDropdownVisible = _d[1];
96464
+ var _e = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useState"])(-1), focusedItemIndex = _e[0], setFocusedItemIndex = _e[1];
96461
96465
  var openerWidth = type === 'border' ? 40 : 56;
96462
- var toggleDropdownVisibility = function () { return setIsDropdownVisible(function (prev) { return !prev; }); };
96466
+ var focusOpener = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function () {
96467
+ var _a, _b;
96468
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
96469
+ // @ts-ignore
96470
+ (_b = (_a = container.current) === null || _a === void 0 ? void 0 : _a.getElementsByClassName('c-compact-buttons__opener')[0]) === null || _b === void 0 ? void 0 : _b.focus();
96471
+ }, [container]);
96472
+ var focusDropdown = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function () {
96473
+ var _a;
96474
+ (_a = dropdownRef === null || dropdownRef === void 0 ? void 0 : dropdownRef.current) === null || _a === void 0 ? void 0 : _a.focus();
96475
+ }, [dropdownRef]);
96476
+ var toggleDropdownVisibility = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function () {
96477
+ if (!isDropdownVisible) {
96478
+ setTimeout(function () {
96479
+ focusDropdown();
96480
+ });
96481
+ }
96482
+ else {
96483
+ setFocusedItemIndex(-1);
96484
+ }
96485
+ setIsDropdownVisible(function (prev) { return !prev; });
96486
+ }, [isDropdownVisible, focusDropdown, setFocusedItemIndex, setIsDropdownVisible]);
96463
96487
  var ends = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useMemo"])(function () {
96464
96488
  var offset = 0;
96465
96489
  return refs.current.map(function (ref) {
@@ -96468,11 +96492,92 @@ var CompactButtons = function (_a) {
96468
96492
  offset += buttonWidth;
96469
96493
  return end;
96470
96494
  });
96495
+ // eslint-disable-next-line react-hooks/exhaustive-deps
96471
96496
  }, [refs.current.length, width]);
96472
- var isButtonVisible = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (position) { return ends[position] + openerWidth <= width && position < maxVisibleButtons; }, [ends, width, maxVisibleButtons]);
96497
+ var isButtonVisible = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (position) { return ends[position] + openerWidth <= width && position < maxVisibleButtons; }, [ends, width, maxVisibleButtons, openerWidth]);
96473
96498
  var registerButtonRef = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (pos) { return function (ref) {
96474
96499
  refs.current[pos] = ref;
96475
96500
  }; }, []);
96501
+ var selectableItems = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useMemo"])(function () { return buttons.map(function (_a, i) {
96502
+ var isDisabled = _a.isDisabled;
96503
+ return (!isDisabled && !isButtonVisible(i) ? i : null);
96504
+ }).filter(function (i) { return i !== null; }); }, [buttons, isButtonVisible]);
96505
+ Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useEffect"])(function () {
96506
+ var _a;
96507
+ if (focusedItemIndex > -1) {
96508
+ var item = (_a = dropdownRef.current) === null || _a === void 0 ? void 0 : _a.getElementsByClassName('c-compact-buttons__dropdown-item')[focusedItemIndex];
96509
+ item === null || item === void 0 ? void 0 : item.focus();
96510
+ }
96511
+ }, [focusedItemIndex]);
96512
+ var handleOptionKeyPress = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (event) {
96513
+ var key = event.key;
96514
+ switch (key) {
96515
+ case KEYS.ArrowDown:
96516
+ event.preventDefault();
96517
+ if (focusedItemIndex === -1) {
96518
+ setFocusedItemIndex(0);
96519
+ }
96520
+ else if (selectableItems[focusedItemIndex + 1] !== undefined) {
96521
+ setFocusedItemIndex(focusedItemIndex + 1);
96522
+ }
96523
+ else {
96524
+ setFocusedItemIndex(-1);
96525
+ focusOpener();
96526
+ }
96527
+ break;
96528
+ case KEYS.Tab:
96529
+ setFocusedItemIndex(-1);
96530
+ setIsDropdownVisible(false);
96531
+ break;
96532
+ case KEYS.ArrowUp:
96533
+ event.preventDefault();
96534
+ if (focusedItemIndex === -1) {
96535
+ setFocusedItemIndex(selectableItems.length - 1);
96536
+ }
96537
+ else if (selectableItems[focusedItemIndex - 1] !== undefined) {
96538
+ setFocusedItemIndex(focusedItemIndex - 1);
96539
+ }
96540
+ else {
96541
+ setFocusedItemIndex(-1);
96542
+ focusOpener();
96543
+ }
96544
+ break;
96545
+ case KEYS.Home:
96546
+ event.preventDefault();
96547
+ setFocusedItemIndex(0);
96548
+ break;
96549
+ case KEYS.End:
96550
+ event.preventDefault();
96551
+ setFocusedItemIndex(selectableItems.length - 1);
96552
+ break;
96553
+ }
96554
+ }, [setFocusedItemIndex, focusOpener, focusedItemIndex, selectableItems]);
96555
+ var handleOpenerKeyPress = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (event) {
96556
+ var key = event.key;
96557
+ switch (key) {
96558
+ case KEYS.ArrowDown:
96559
+ event.preventDefault();
96560
+ focusDropdown();
96561
+ setFocusedItemIndex(0);
96562
+ break;
96563
+ case KEYS.ArrowUp:
96564
+ event.preventDefault();
96565
+ focusDropdown();
96566
+ setFocusedItemIndex(selectableItems.length - 1);
96567
+ break;
96568
+ case KEYS.Tab:
96569
+ setFocusedItemIndex(-1);
96570
+ setIsDropdownVisible(false);
96571
+ break;
96572
+ }
96573
+ }, [focusDropdown, setFocusedItemIndex, setIsDropdownVisible, selectableItems]);
96574
+ var handleDropdownItemKeyPress = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (onClick) { return function (event) {
96575
+ var key = event.key;
96576
+ if (key === KEYS.Enter || key === KEYS.Space) {
96577
+ event.preventDefault();
96578
+ onClick && onClick(event);
96579
+ }
96580
+ }; }, []);
96476
96581
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { ref: container, className: "c-compact-buttons" },
96477
96582
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: classBinder_cx('c-compact-buttons__wrapper', "c-compact-buttons__wrapper--" + type, "c-compact-buttons__wrapper--" + background, theme) },
96478
96583
  buttons.map(function (_a, i) {
@@ -96485,16 +96590,16 @@ var CompactButtons = function (_a) {
96485
96590
  label),
96486
96591
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("i", { className: "c-compact-buttons__button_separator" })));
96487
96592
  }),
96488
- !isButtonVisible(buttons.length - 1) && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Dropdown, { forceVisibility: isDropdownVisible, placement: "bottom-end", trigger: null, triggerComponent: external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Button, { "aria-hidden": true, ariaLabel: "other", color: background, isSmall: isSmall, theme: "c-compact-buttons__button", type: type, onClick: toggleDropdownVisibility },
96593
+ !isButtonVisible(buttons.length - 1) && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Dropdown, { forceVisibility: isDropdownVisible, placement: "bottom-end", trigger: null, triggerComponent: external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Button, { "aria-hidden": true, ariaLabel: "other", color: background, isSmall: isSmall, theme: "c-compact-buttons__button c-compact-buttons__opener", type: type, onClick: toggleDropdownVisibility, onKeyDown: handleOpenerKeyPress },
96489
96594
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "other" }),
96490
96595
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("span", { className: "c-compact-buttons__dropdown__opener" })), onVisibleChange: function (state) { return setIsDropdownVisible(state); } },
96491
- external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(DropdownMenu, { ariaHidden: true }, buttons.map(function (_a, i) {
96596
+ external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(DropdownMenu, { ref: dropdownRef, tabIndex: 0, onKeyDown: handleOptionKeyPress }, buttons.map(function (_a, i) {
96492
96597
  var allowEventPropagation = _a.allowEventPropagation, icon = _a.icon, isDisabled = _a.isDisabled, isLoading = _a.isLoading, key = _a.key, label = _a.label, onClick = _a.onClick, testId = _a.testId;
96493
96598
  if (isButtonVisible(i))
96494
96599
  return;
96495
- return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(DropdownItem, { key: key, allowEventPropagation: allowEventPropagation, iconName: icon, isDisabled: isDisabled, testId: testId + "-dropdown", theme: classBinder_cx('c-compact-buttons__dropdown-item', {
96600
+ return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(DropdownItem, { key: key, allowEventPropagation: allowEventPropagation, iconName: icon, isDisabled: isDisabled, isFocused: selectableItems[focusedItemIndex] === i, tabIndex: 0, testId: testId + "-dropdown", theme: classBinder_cx('c-compact-buttons__dropdown-item', {
96496
96601
  'c-compact-buttons__dropdown-item--disabled': isDisabled || isLoading
96497
- }), onClick: onClick }, label));
96602
+ }), onClick: onClick, onKeyDown: handleDropdownItemKeyPress(onClick) }, label));
96498
96603
  })))))));
96499
96604
  };
96500
96605
 
@@ -97732,11 +97837,12 @@ var IntegerInput = function (_a) {
97732
97837
  var hasChangedRef = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useRef"])(false);
97733
97838
  var numberMask = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useMemo"])(function () {
97734
97839
  return configureIntegerMask({
97735
- thousandSeparator: thousandSeparator,
97840
+ allowLeadingZeros: allowLeadingZeros,
97736
97841
  allowNegative: allowNegative,
97737
- integerPlaces: integerPlaces
97842
+ integerPlaces: integerPlaces,
97843
+ thousandSeparator: thousandSeparator
97738
97844
  });
97739
- }, [thousandSeparator, allowNegative, integerPlaces]);
97845
+ }, [allowLeadingZeros, allowNegative, integerPlaces, thousandSeparator]);
97740
97846
  Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useEffect"])(function () {
97741
97847
  if (Number.isNaN(value)) {
97742
97848
  return;
@@ -43,6 +43,8 @@ interface BasicButtonType extends ComponentPropsType, DisabledTooltipPropsType {
43
43
  target?: TargetType;
44
44
  /** Click event handler. */
45
45
  onClick?: (e: SyntheticEvent | KeyboardEvent) => void;
46
+ /** Key down event handler. */
47
+ onKeyDown?: (event: React.KeyboardEvent) => void;
46
48
  /** Name of icon, that should be displayed stand alone. If you need icon and text (or something else) use children property. */
47
49
  onlyIconName?: never;
48
50
  /** Title of the button element */
@@ -1,4 +1,4 @@
1
- import { ReactElement, ReactNode, SyntheticEvent } from 'react';
1
+ import React, { ReactElement, ReactNode, SyntheticEvent } from 'react';
2
2
  import { IconNameType, TargetType } from '../../..';
3
3
  import { ComponentPropsType, DisabledTooltipPropsType } from '../../../utils';
4
4
  interface CompactButtonsButtonType extends ComponentPropsType, DisabledTooltipPropsType {
@@ -28,7 +28,7 @@ interface CompactButtonsButtonType extends ComponentPropsType, DisabledTooltipPr
28
28
  /** Target for link outside app. */
29
29
  target?: TargetType;
30
30
  /** Click event handler. */
31
- onClick?: (e: SyntheticEvent | KeyboardEvent) => void;
31
+ onClick?: (e: SyntheticEvent | KeyboardEvent | React.KeyboardEvent) => void;
32
32
  /** Name of icon, that should be displayed stand alone. */
33
33
  onlyIconName?: never;
34
34
  /** Title of the button element */
@@ -15,5 +15,5 @@ export interface DropdownMenuPropsType extends ComponentPropsType {
15
15
  onKeyDown?: (event: React.KeyboardEvent<HTMLUListElement>) => void;
16
16
  onBlur?: () => void;
17
17
  }
18
- export declare const DropdownMenu: ({ activeDescendant, ariaHidden, children, id, labelledBy, onBlur, onKeyDown, role, tabIndex, testId, theme, title }: DropdownMenuPropsType) => JSX.Element;
18
+ export declare const DropdownMenu: React.ForwardRefExoticComponent<DropdownMenuPropsType & React.RefAttributes<unknown>>;
19
19
  //# sourceMappingURL=DropdownMenu.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmb-digital/ds-lilly",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "description": "MMB LILLY design system",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": false,