@mmb-digital/ds-lilly 0.10.6 → 0.10.8

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
@@ -97840,7 +97840,7 @@ var Dropdown_assign = (undefined && undefined.__assign) || function () {
97840
97840
 
97841
97841
  var SCROLL_DEVIATION = 16;
97842
97842
  var Dropdown = function (_a) {
97843
- var children = _a.children, closeOnOutsideClick = _a.closeOnOutsideClick, closeOnTriggerHidden = _a.closeOnTriggerHidden, _b = _a.delayHide, delayHide = _b === void 0 ? 200 : _b, delayShow = _a.delayShow, dropdownId = _a.dropdownId, forceVisibility = _a.forceVisibility, _c = _a.hasSameWidthAsTrigger, hasSameWidthAsTrigger = _c === void 0 ? false : _c, interactive = _a.interactive, _d = _a.isOpenByDefault, isOpenByDefault = _d === void 0 ? false : _d, onOutsideClick = _a.onOutsideClick, onScrollToEnd = _a.onScrollToEnd, onVisibleChange = _a.onVisibleChange, _e = _a.placement, placement = _e === void 0 ? 'auto' : _e, testId = _a.testId, theme = _a.theme, _f = _a.trigger, trigger = _f === void 0 ? 'focus' : _f, triggerComponent = _a.triggerComponent;
97843
+ var children = _a.children, closeOnOutsideClick = _a.closeOnOutsideClick, closeOnTriggerHidden = _a.closeOnTriggerHidden, _b = _a.delayHide, delayHide = _b === void 0 ? 200 : _b, delayShow = _a.delayShow, dropdownId = _a.dropdownId, forceVisibility = _a.forceVisibility, _c = _a.hasSameWidthAsTrigger, hasSameWidthAsTrigger = _c === void 0 ? false : _c, interactive = _a.interactive, _d = _a.isOpenByDefault, isOpenByDefault = _d === void 0 ? false : _d, onBlur = _a.onBlur, onOutsideClick = _a.onOutsideClick, onScrollToEnd = _a.onScrollToEnd, onVisibleChange = _a.onVisibleChange, _e = _a.placement, placement = _e === void 0 ? 'auto' : _e, tabIndex = _a.tabIndex, testId = _a.testId, theme = _a.theme, _f = _a.trigger, trigger = _f === void 0 ? 'focus' : _f, triggerComponent = _a.triggerComponent;
97844
97844
  var tooltipRef = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useRef"])();
97845
97845
  var _g = usePopperTooltip({
97846
97846
  closeOnOutsideClick: closeOnOutsideClick,
@@ -97870,9 +97870,9 @@ var Dropdown = function (_a) {
97870
97870
  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,
97871
97871
  Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["cloneElement"])(triggerComponent, { ref: setTriggerRef }),
97872
97872
  visible && (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,
97873
- external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", Dropdown_assign({ ref: setRef, "data-testid": testId }, getTooltipProps({
97873
+ external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", Dropdown_assign({ ref: setRef, "aria-expanded": "true", "data-testid": testId }, getTooltipProps({
97874
97874
  className: classBinder_cx('c-dropdown', { 'c-dropdown--fullWidth': hasSameWidthAsTrigger }, theme)
97875
- }), { id: dropdownId, onScroll: handleScroll }), children),
97875
+ }), { id: dropdownId, tabIndex: tabIndex, onBlur: onBlur, onScroll: handleScroll }), children),
97876
97876
  onOutsideClick && external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "c-dropdown__outside", onClick: onOutsideClick })))));
97877
97877
  };
97878
97878
 
@@ -99600,7 +99600,7 @@ var Label2 = function (_a) {
99600
99600
 
99601
99601
 
99602
99602
  var FormGroup2 = function (_a) {
99603
- var charCounter = _a.charCounter, children = _a.children, disabledTooltip = _a.disabledTooltip, _b = _a.disabledTooltipOffset, disabledTooltipOffset = _b === void 0 ? 6 : _b, disabledTooltipType = _a.disabledTooltipType, error = _a.error, _c = _a.hasError, hasError = _c === void 0 ? false : _c, _d = _a.hasWarning, hasWarning = _d === void 0 ? false : _d, help = _a.help, isDisabled = _a.isDisabled, label = _a.label, labelTooltip = _a.labelTooltip, name = _a.name, theme = _a.theme, warning = _a.warning;
99603
+ var charCounter = _a.charCounter, children = _a.children, disabledTooltip = _a.disabledTooltip, _b = _a.disabledTooltipOffset, disabledTooltipOffset = _b === void 0 ? 6 : _b, disabledTooltipType = _a.disabledTooltipType, error = _a.error, _c = _a.hasError, hasError = _c === void 0 ? false : _c, _d = _a.hasWarning, hasWarning = _d === void 0 ? false : _d, help = _a.help, isDisabled = _a.isDisabled, label = _a.label, labelFor = _a.labelFor, labelTooltip = _a.labelTooltip, name = _a.name, theme = _a.theme, warning = _a.warning;
99604
99604
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: classBinder_cx('f-group2', { 'f-group2--disabled': isDisabled, 'f-group2--error': hasError, 'f-group2--warning': hasWarning }, theme) },
99605
99605
  withDisabledTooltip({
99606
99606
  isDisabled: isDisabled,
@@ -99608,7 +99608,7 @@ var FormGroup2 = function (_a) {
99608
99608
  disabledTooltipOffset: disabledTooltipOffset,
99609
99609
  disabledTooltipType: disabledTooltipType
99610
99610
  })(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("span", { className: "disabled-tooltip-wrapper" },
99611
- label && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Label2, { htmlFor: name, identifier: name + "_label", labelTooltip: labelTooltip }, label)),
99611
+ label && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Label2, { htmlFor: labelFor || name, identifier: name + "_label", labelTooltip: labelTooltip }, label)),
99612
99612
  children)),
99613
99613
  charCounter && charCounter.max > 0 && (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: classBinder_cx('f-controlCounter', { 'f-controlCounter--error': charCounter.length > charCounter.max }) }, (charCounter.length || 0) + " / " + charCounter.max)),
99614
99614
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { "aria-live": "assertive", className: "f-validationMsg f-validationMsg--invalid", id: name + "_errorMessage" }, error || warning),
@@ -100429,7 +100429,6 @@ var Autocomplete2 = function (_a) {
100429
100429
  var handleCreateNewOption = function () {
100430
100430
  setButtonValue({ label: fulltextValue, value: fulltextValue });
100431
100431
  onCreateNewItem && onCreateNewItem(fulltextValue);
100432
- setTypingMode(false);
100433
100432
  };
100434
100433
  var handleBlur = function (item) {
100435
100434
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -100437,10 +100436,14 @@ var Autocomplete2 = function (_a) {
100437
100436
  onBlur && onBlur((item === null || item === void 0 ? void 0 : item.value) || undefined);
100438
100437
  };
100439
100438
  var handleOptionKeyPress = function (event) {
100440
- var ctrlKey = event.ctrlKey, key = event.key, metaKey = event.metaKey, target = event.target;
100439
+ var ctrlKey = event.ctrlKey, key = event.key, metaKey = event.metaKey, shiftKey = event.shiftKey, target = event.target;
100441
100440
  switch (key) {
100442
100441
  case KEYS.Enter:
100443
100442
  case KEYS.Tab:
100443
+ if (shiftKey) {
100444
+ handleComboBoxClick();
100445
+ return;
100446
+ }
100444
100447
  if (target.id === name + "_list-createNew") {
100445
100448
  handleCreateNewOption();
100446
100449
  }
@@ -100516,7 +100519,7 @@ var Autocomplete2 = function (_a) {
100516
100519
  event.preventDefault();
100517
100520
  break;
100518
100521
  default:
100519
- if (!(ctrlKey || metaKey)) {
100522
+ if (!(ctrlKey || metaKey) && key !== KEYS.Shift) {
100520
100523
  setFulltextValue(function (prev) { return "" + prev + key; });
100521
100524
  }
100522
100525
  break;
@@ -100723,6 +100726,7 @@ var Autocomplete2 = function (_a) {
100723
100726
  help: help,
100724
100727
  isDisabled: isDisabled,
100725
100728
  label: label,
100729
+ labelFor: name + "_button",
100726
100730
  labelTooltip: labelTooltip,
100727
100731
  name: name,
100728
100732
  warning: warning
@@ -100735,7 +100739,7 @@ var Autocomplete2 = function (_a) {
100735
100739
  'f-control2--large': displayDetails,
100736
100740
  'f-autocomplete__trigger--loading': isLoading,
100737
100741
  'u-hide': typingMode
100738
- }), disabled: isDisabled, id: name + "_button", name: name, type: "button", onClick: handleComboBoxClick, onFocus: handleFocus },
100742
+ }), disabled: isDisabled, id: name + "_button", name: name, tabIndex: isDropdownVisible ? -1 : 0, type: "button", onClick: handleComboBoxClick, onFocus: handleFocus },
100739
100743
  isLoading && external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "loading" }),
100740
100744
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("span", { className: classBinder_cx("f-control2__" + (buttonValue ? 'value' : 'placeholder')) }, buttonValue ? external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(SelectedOption, Autocomplete2_assign({ displayDetails: displayDetails }, buttonValue)) : placeholder),
100741
100745
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "arrowDown", size: "small", theme: "f-control2__selectIcon" })),
@@ -100743,7 +100747,7 @@ var Autocomplete2 = function (_a) {
100743
100747
  ? isCategorised(items)
100744
100748
  ? name + "_option-" + focusedCategoryIndex + "-" + focusedItemIndex
100745
100749
  : name + "_option-" + focusedItemIndex
100746
- : undefined, "aria-autocomplete": "list", "aria-controls": name + "_list", "aria-labelledby": name + "_label", autoComplete: "off", className: classBinder_cx('f-autocomplete__input'), disabled: isDisabled, id: name + "_input", name: name, placeholder: placeholder, type: "text", value: fulltextValue, onChange: handleFulltextChange, onKeyDown: handleFulltextKeyPress }),
100750
+ : undefined, "aria-autocomplete": "list", "aria-controls": name + "_list", "aria-labelledby": name + "_label", autoComplete: "off", className: classBinder_cx('f-autocomplete__input', { 'u-hide': !isDropdownVisible }), disabled: isDisabled, id: name + "_input", name: name, placeholder: placeholder, tabIndex: isDropdownVisible ? 0 : -1, type: "text", value: fulltextValue, onChange: handleFulltextChange, onKeyDown: handleFulltextKeyPress }),
100747
100751
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("button", { "aria-invalid": !!error, className: classBinder_cx('f-autocomplete__button'), disabled: isDisabled, id: name + "_toggle_button", name: name, tabIndex: -1, type: "button", onClick: toggleDropdown },
100748
100752
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "arrowDown", size: "small", theme: "f-control2__selectIcon" })))), onScrollToEnd: handleScrollToEnd, onVisibleChange: handleDropdownVisibilityChange }, renderDropdownContent()))));
100749
100753
  };
@@ -109046,9 +109050,9 @@ var Select2 = function (_a) {
109046
109050
  var _a;
109047
109051
  var listElementId;
109048
109052
  if (currentItemPosition > -1) {
109049
- var _b = itemsIndex[currentItemPosition], category = _b.category, item = _b.item;
109050
- scrollToItem(item, category, true);
109051
- listElementId = isCategorised ? name + "_list-" + category : name + "_list";
109053
+ var _b = itemsIndex[currentItemPosition], category_1 = _b.category, item_1 = _b.item;
109054
+ scrollToItem(item_1, category_1, true);
109055
+ listElementId = isCategorised ? name + "_list-" + category_1 : name + "_list";
109052
109056
  }
109053
109057
  else {
109054
109058
  listElementId = isCategorised ? name + "_list-0" : name + "_list";
@@ -109116,8 +109120,13 @@ var Select2 = function (_a) {
109116
109120
  }
109117
109121
  };
109118
109122
  var handleOptionKeyPress = function (event) {
109119
- var key = event.key;
109123
+ var key = event.key, shiftKey = event.shiftKey;
109120
109124
  switch (key) {
109125
+ case KEYS.Tab:
109126
+ if (shiftKey) {
109127
+ handleComboBoxClick();
109128
+ }
109129
+ break;
109121
109130
  case KEYS.Enter:
109122
109131
  selectFocusedItem();
109123
109132
  handleComboBoxClick();
@@ -109125,18 +109134,18 @@ var Select2 = function (_a) {
109125
109134
  break;
109126
109135
  case KEYS.ArrowDown:
109127
109136
  {
109128
- var itemIndex = itemsIndex[currentItemPosition + 1];
109129
- if (itemIndex) {
109130
- handleFocusedItem(itemIndex.item, itemIndex.category);
109137
+ var itemIndex_1 = itemsIndex[currentItemPosition + 1];
109138
+ if (itemIndex_1) {
109139
+ handleFocusedItem(itemIndex_1.item, itemIndex_1.category);
109131
109140
  }
109132
109141
  event.preventDefault();
109133
109142
  }
109134
109143
  break;
109135
109144
  case KEYS.ArrowUp:
109136
109145
  {
109137
- var itemIndex = itemsIndex[currentItemPosition - 1];
109138
- if (itemIndex) {
109139
- handleFocusedItem(itemIndex.item, itemIndex.category);
109146
+ var itemIndex_2 = itemsIndex[currentItemPosition - 1];
109147
+ if (itemIndex_2) {
109148
+ handleFocusedItem(itemIndex_2.item, itemIndex_2.category);
109140
109149
  }
109141
109150
  event.preventDefault();
109142
109151
  }
@@ -109148,18 +109157,18 @@ var Select2 = function (_a) {
109148
109157
  break;
109149
109158
  case KEYS.Home:
109150
109159
  {
109151
- var itemIndex = itemsIndex[0];
109152
- if (itemIndex) {
109153
- handleFocusedItem(itemIndex.item, itemIndex.category);
109160
+ var itemIndex_3 = itemsIndex[0];
109161
+ if (itemIndex_3) {
109162
+ handleFocusedItem(itemIndex_3.item, itemIndex_3.category);
109154
109163
  }
109155
109164
  event.preventDefault();
109156
109165
  }
109157
109166
  break;
109158
109167
  case KEYS.End:
109159
109168
  {
109160
- var itemIndex = itemsIndex[itemsIndex.length - 1];
109161
- if (itemIndex) {
109162
- handleFocusedItem(itemIndex.item, itemIndex.category);
109169
+ var itemIndex_4 = itemsIndex[itemsIndex.length - 1];
109170
+ if (itemIndex_4) {
109171
+ handleFocusedItem(itemIndex_4.item, itemIndex_4.category);
109163
109172
  }
109164
109173
  event.preventDefault();
109165
109174
  }
@@ -109206,14 +109215,23 @@ var Select2 = function (_a) {
109206
109215
  help: help,
109207
109216
  isDisabled: isDisabled,
109208
109217
  label: label,
109218
+ labelFor: name + "_button",
109209
109219
  labelTooltip: labelTooltip,
109210
109220
  name: name,
109211
109221
  warning: warning
109212
109222
  };
109223
+ var itemIndex = getItemIndexByValue(value);
109224
+ var category = itemIndex.category, item = itemIndex.item;
109225
+ var selectedItemLabel;
109226
+ if (item > -1) {
109227
+ selectedItemLabel = isCategorised
109228
+ ? items[category].items[item].label
109229
+ : items[item].label;
109230
+ }
109213
109231
  return (external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(FormGroup2, Select2_assign({ theme: classBinder_cx({ 'f-group2--open': isDropdownVisible }, theme) }, fromGroupProps),
109214
109232
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(contexts_Select2Context.Provider, { value: select2context },
109215
- external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Dropdown, { dropdownId: name + "_dropdown", forceVisibility: isDropdownVisible, hasSameWidthAsTrigger: hasFullWidthOptions, placement: "bottom-start", theme: dropdownTheme, trigger: null, triggerComponent: external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-controlWrap", "data-testid": testId, role: "combobox" },
109216
- external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("button", { "aria-expanded": isDropdownVisible, "aria-haspopup": "listbox", "aria-invalid": !!error, "aria-labelledby": name + "_label " + name, className: classBinder_cx('f-control2 f-control2--select', { 'f-control2--large': displayDetails }), disabled: isDisabled, id: name + "_button", name: name, type: "button", onClick: handleComboBoxClick, onFocus: onFocus, onKeyDown: handleButtonKeyPress },
109233
+ external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Dropdown, { dropdownId: name + "_dropdown", forceVisibility: isDropdownVisible, hasSameWidthAsTrigger: hasFullWidthOptions, placement: "bottom-start", tabIndex: 0, theme: dropdownTheme, trigger: null, triggerComponent: external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("div", { className: "f-controlWrap", "data-testid": testId, role: "combobox" },
109234
+ external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("button", { "aria-expanded": isDropdownVisible, "aria-haspopup": "listbox", "aria-invalid": !!error, "aria-label": selectedItemLabel, "aria-labelledby": name + "_label " + name, className: classBinder_cx('f-control2 f-control2--select', { 'f-control2--large': displayDetails }), disabled: isDisabled, id: name + "_button", name: name, type: "button", onClick: handleComboBoxClick, onFocus: onFocus, onKeyDown: handleButtonKeyPress },
109217
109235
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement("span", { className: classBinder_cx("f-control2__" + (buttonValue ? 'value' : 'placeholder')) }, buttonValue ? buttonValue : placeholder),
109218
109236
  external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Icon, { name: "arrowDown", size: "small", theme: "f-control2__selectIcon" }))), onVisibleChange: function (state) { return setIsDropdownVisible(state); } }, isCategorised ? external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Select2CategorisedOptions, null) : external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_default.a.createElement(Select2Options, null)))));
109219
109237
  };
@@ -15,12 +15,14 @@ export interface DropdownPropsType extends ComponentPropsType {
15
15
  delayShow?: number;
16
16
  /** Dropdown menu element ID */
17
17
  dropdownId?: string;
18
+ forceVisibility?: boolean;
18
19
  /** Set to use same width as triggerComponent. */
19
20
  hasSameWidthAsTrigger?: boolean;
20
21
  /** If true, hovering the tooltip will keep it open. */
21
22
  interactive?: boolean;
22
23
  /** Flag default opened state. */
23
24
  isOpenByDefault?: boolean;
25
+ onBlur?: () => void;
24
26
  /** Optional handler for visibility. */
25
27
  onVisibleChange?: (state: boolean) => void;
26
28
  /** Optional handler for scroll to end of lists. */
@@ -29,11 +31,12 @@ export interface DropdownPropsType extends ComponentPropsType {
29
31
  onOutsideClick?: () => void;
30
32
  /** The preferred placement of the tooltip. */
31
33
  placement?: DropdownPlacement;
34
+ /** Component tab-index */
35
+ tabIndex?: number;
32
36
  /** Event(s) that trigger dropdown to open. */
33
37
  trigger?: TriggerType | TriggerType[] | null;
34
38
  /** Component that triggers dropdown menu. */
35
39
  triggerComponent: ReactElement;
36
- forceVisibility?: boolean;
37
40
  }
38
- export declare const Dropdown: ({ children, closeOnOutsideClick, closeOnTriggerHidden, delayHide, delayShow, dropdownId, forceVisibility, hasSameWidthAsTrigger, interactive, isOpenByDefault, onOutsideClick, onScrollToEnd, onVisibleChange, placement, testId, theme, trigger, triggerComponent }: DropdownPropsType) => JSX.Element;
41
+ export declare const Dropdown: ({ children, closeOnOutsideClick, closeOnTriggerHidden, delayHide, delayShow, dropdownId, forceVisibility, hasSameWidthAsTrigger, interactive, isOpenByDefault, onBlur, onOutsideClick, onScrollToEnd, onVisibleChange, placement, tabIndex, testId, theme, trigger, triggerComponent }: DropdownPropsType) => JSX.Element;
39
42
  //# sourceMappingURL=Dropdown.d.ts.map
@@ -15,6 +15,8 @@ export interface FormGroup2PropsType extends ComponentPropsType, DisabledTooltip
15
15
  isDisabled?: boolean;
16
16
  /** Form field label. */
17
17
  label?: ReactNode;
18
+ /** htmlFor attribute for label (name is used by default) */
19
+ labelFor?: string;
18
20
  /** Content of additional label tooltip. */
19
21
  labelTooltip?: ReactNode;
20
22
  /** Defines counter of maximum characters to be inserted. */
@@ -27,5 +29,5 @@ export interface FormGroup2PropsType extends ComponentPropsType, DisabledTooltip
27
29
  /** Warning message shown in component warning state */
28
30
  warning?: string;
29
31
  }
30
- export declare const FormGroup2: ({ charCounter, children, disabledTooltip, disabledTooltipOffset, disabledTooltipType, error, hasError, hasWarning, help, isDisabled, label, labelTooltip, name, theme, warning }: FormGroup2PropsType) => JSX.Element;
32
+ export declare const FormGroup2: ({ charCounter, children, disabledTooltip, disabledTooltipOffset, disabledTooltipType, error, hasError, hasWarning, help, isDisabled, label, labelFor, labelTooltip, name, theme, warning }: FormGroup2PropsType) => JSX.Element;
31
33
  //# sourceMappingURL=FormGroup2.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmb-digital/ds-lilly",
3
- "version": "0.10.6",
3
+ "version": "0.10.8",
4
4
  "description": "MMB LILLY design system",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": false,