@entur-partner/common 11.1.2 → 11.1.3

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.
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { localeDate, localeDateTime, isDate, isDateString, splitUrlPath, isString, isFunction, assertIsDefined, hasAllPermissions, hasOneOfPermissions } from '@entur-partner/util';
3
3
  import cx from 'classnames';
4
- import { Children, Component, useState, useRef, useEffect } from 'react';
4
+ import { Children, Component, useState, useEffect, useRef } from 'react';
5
5
  import { BreadcrumbItem, BreadcrumbNavigation, Pagination } from '@entur/menu';
6
6
  import { Link as Link$1, useInRouterContext, useBlocker } from 'react-router-dom';
7
7
  import { ButtonGroup, SecondaryButton, PrimaryButton, Button } from '@entur/button';
@@ -694,16 +694,12 @@ var MultiLanguageInput = function MultiLanguageInput(_ref) {
694
694
  };
695
695
 
696
696
  var _excluded$4 = ["label", "organisations", "onChange", "selectedOrganisationId"];
697
- function isInShadowDom(el) {
698
- return (el == null ? void 0 : el.getRootNode()) instanceof ShadowRoot;
699
- }
700
697
  var OrganisationDropDown = function OrganisationDropDown(_ref) {
701
698
  var label = _ref.label,
702
699
  organisations = _ref.organisations,
703
700
  handleChange = _ref.onChange,
704
701
  selectedOrganisationId = _ref.selectedOrganisationId,
705
702
  rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
706
- var wrapperRef = useRef(null);
707
703
  var _useState = useState(),
708
704
  selectedOrganisation = _useState[0],
709
705
  setSelectedOrganisation = _useState[1];
@@ -712,53 +708,27 @@ var OrganisationDropDown = function OrganisationDropDown(_ref) {
712
708
  return org.organisationId === selectedOrganisationId;
713
709
  }));
714
710
  }, [selectedOrganisationId, organisations]);
715
- var handleMouseDown = function handleMouseDown(e) {
716
- if (!isInShadowDom(wrapperRef.current)) return;
717
- // In shadow DOM, mouse events are retargeted at the shadow boundary,
718
- // causing downshift's window-level outside-click detection to misidentify
719
- // clicks within the dropdown as outside clicks. Stop propagation to prevent
720
- // the retargeted event from reaching window-level listeners.
721
- e.nativeEvent.stopPropagation();
722
- // Prevent default on non-input elements to stop the browser from moving
723
- // focus away from the combobox input, which would trigger a blur that
724
- // closes the dropdown before the click event can register a selection.
725
- if (e.target.tagName !== "INPUT") {
726
- e.preventDefault();
727
- }
728
- };
729
- var handleMouseUp = function handleMouseUp(e) {
730
- if (!isInShadowDom(wrapperRef.current)) return;
731
- e.nativeEvent.stopPropagation();
732
- };
733
- return (
734
- // biome-ignore lint/a11y/noStaticElementInteractions: Temporary fix. See comment above. Will be fixed in design system level in the future.
735
- jsx("div", {
736
- ref: wrapperRef,
737
- onMouseDown: handleMouseDown,
738
- onMouseUp: handleMouseUp,
739
- children: jsx(SearchableDropdown, _extends({
740
- label: label,
741
- items: [].concat(organisations.sort(function (a, b) {
742
- return a.tradingName.localeCompare(b.tradingName, "nb");
743
- }).map(function (organisation) {
744
- return {
745
- value: organisation.organisationId,
746
- label: organisation.tradingName
747
- };
748
- })),
749
- selectedItem: selectedOrganisation ? {
750
- value: selectedOrganisation.organisationId,
751
- label: selectedOrganisation.tradingName
752
- } : null,
753
- onChange: function onChange(selectedValue) {
754
- if (selectedValue) {
755
- handleChange(selectedValue.value);
756
- }
757
- },
758
- clearable: false
759
- }, rest))
760
- })
761
- );
711
+ return jsx(SearchableDropdown, _extends({
712
+ label: label,
713
+ items: [].concat(organisations.sort(function (a, b) {
714
+ return a.tradingName.localeCompare(b.tradingName, "nb");
715
+ }).map(function (organisation) {
716
+ return {
717
+ value: organisation.organisationId,
718
+ label: organisation.tradingName
719
+ };
720
+ })),
721
+ selectedItem: selectedOrganisation ? {
722
+ value: selectedOrganisation.organisationId,
723
+ label: selectedOrganisation.tradingName
724
+ } : null,
725
+ onChange: function onChange(selectedValue) {
726
+ if (selectedValue) {
727
+ handleChange(selectedValue.value);
728
+ }
729
+ },
730
+ clearable: false
731
+ }, rest));
762
732
  };
763
733
 
764
734
  /**