carbon-react 157.1.2 → 157.2.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 (26) hide show
  1. package/esm/components/action-popover/action-popover.component.js +1 -1
  2. package/esm/components/adaptive-sidebar/adaptive-sidebar.component.d.ts +3 -2
  3. package/esm/components/adaptive-sidebar/adaptive-sidebar.component.js +1 -1
  4. package/esm/components/multi-action-button/multi-action-button.component.js +1 -1
  5. package/esm/components/select/filterable-select/filterable-select.component.js +1 -1
  6. package/esm/components/select/multi-select/multi-select.component.js +1 -1
  7. package/esm/components/select/simple-select/simple-select.component.js +1 -1
  8. package/esm/components/split-button/split-button.component.js +1 -1
  9. package/esm/hooks/__internal__/useAdaptiveSidebarModalFocus/index.d.ts +1 -0
  10. package/esm/hooks/__internal__/useAdaptiveSidebarModalFocus/index.js +1 -0
  11. package/esm/hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.d.ts +2 -0
  12. package/esm/hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js +1 -0
  13. package/lib/components/action-popover/action-popover.component.js +1 -1
  14. package/lib/components/adaptive-sidebar/adaptive-sidebar.component.d.ts +3 -2
  15. package/lib/components/adaptive-sidebar/adaptive-sidebar.component.js +1 -1
  16. package/lib/components/multi-action-button/multi-action-button.component.js +1 -1
  17. package/lib/components/select/filterable-select/filterable-select.component.js +1 -1
  18. package/lib/components/select/multi-select/multi-select.component.js +1 -1
  19. package/lib/components/select/simple-select/simple-select.component.js +1 -1
  20. package/lib/components/split-button/split-button.component.js +1 -1
  21. package/lib/hooks/__internal__/useAdaptiveSidebarModalFocus/index.d.ts +1 -0
  22. package/lib/hooks/__internal__/useAdaptiveSidebarModalFocus/index.js +1 -0
  23. package/lib/hooks/__internal__/useAdaptiveSidebarModalFocus/package.json +6 -0
  24. package/lib/hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.d.ts +2 -0
  25. package/lib/hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js +1 -0
  26. package/package.json +1 -1
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t}from"react/jsx-runtime";import o,{forwardRef as r,useState as n,useRef as a,useContext as i,useMemo as l,useCallback as p,useImperativeHandle as c,useEffect as s}from"react";import u from"invariant";import d from"../../__internal__/utils/helpers/tags/tags.js";import{MenuItemDivider as b,MenuButton as m,StyledButtonIcon as f,ButtonIcon as v}from"./action-popover.style.js";import y from"../../__internal__/utils/helpers/events/events.js";import _ from"../../__internal__/popover/popover.component.js";import O from"../../__internal__/utils/helpers/guid/index.js";import j from"../../hooks/__internal__/useLocale/useLocale.js";import g from"./action-popover-menu/action-popover-menu.component.js";import{ActionPopoverItem as h}from"./action-popover-item/action-popover-item.component.js";import"./action-popover-divider/action-popover-divider.component.js";import{ActionPopoverProvider as P}from"./__internal__/action-popover.context.js";import x from"../../hooks/__internal__/useModalManager/useModalManager.js";import{getItems as w,findFirstFocusableItem as A,findLastFocusableItem as S,checkChildrenForString as D}from"./__internal__/action-popover.utils.js";import I from"../flat-table/__internal__/flat-table.context.js";function k(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}const E=()=>{},M=()=>{},L=r(((r,L)=>{var{children:B,id:K,onOpen:$=E,onClose:C=M,rightAlignMenu:z,renderButton:R,placement:F="bottom",horizontalAlignment:N="left",submenuPosition:U="left","aria-label":q,"aria-labelledby":T,"aria-describedby":V}=r,G=function(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},a=Object.keys(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}(r,["children","id","onOpen","onClose","rightAlignMenu","renderButton","placement","horizontalAlignment","submenuPosition","aria-label","aria-labelledby","aria-describedby"]);const H=j(),[J,Q]=n(!1),[W,X]=n(0),[Y]=n(O()),Z=a(null),ee=a(null),{isInFlatTable:te}=i(I),[oe,re]=n(null),ne=l((()=>!o.Children.toArray(B).find((e=>!o.isValidElement(e)||e.type!==h&&e.type!==b))),[B]),ae=l((()=>w(B)),[B]),ie=A(ae),le=S(ae);u(ne,`ActionPopover only accepts children of type \`${h.displayName}\` and \`${b.displayName}\`.`);const pe=l((()=>"top"!==F||z?"top"===F&&z?"top-start":"bottom"===F&&z?"bottom-start":"bottom-end":"top-end"),[F,z]),ce=p((e=>{e&&!J&&$(),!e&&J&&C(),Q(e)}),[J,$,C]),se=p((()=>{var e;const t=null===(e=Z.current)||void 0===e?void 0:e.querySelector("[data-element='action-popover-button']");null==t||t.focus()}),[]);c(L,(()=>({focusButton(){se()}})),[se]);const ue=p((e=>{e.stopPropagation();const t=!J;X(ie),ce(t),t||se()}),[J,ie,ce,se]),de=p((e=>{y.isSpaceKey(e)||y.isDownKey(e)||y.isEnterKey(e)?(e.preventDefault(),e.stopPropagation(),X(ie),ce(!0)):y.isUpKey(e)&&(e.preventDefault(),e.stopPropagation(),X(le),ce(!0))}),[ie,le,ce]),be=p((e=>{y.isEscKey(e)&&(ce(!1),se())}),[ce,se]);x({open:J,closeModal:be,modalRef:Z}),s((()=>{const e=({target:e})=>{var t,o;const r=null==ee||null===(t=ee.current)||void 0===t?void 0:t.contains(e),n=null==Z||null===(o=Z.current)||void 0===o?void 0:o.contains(e);r||n||ce(!1)},t="click";return document.addEventListener(t,e,{capture:!0}),function(){document.removeEventListener(t,e,{capture:!0})}}),[ce]);const me=K||`ActionPopoverButton_${Y}`,fe=`ActionPopoverMenu_${Y}`;return e(m,(ve=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),r.forEach((function(t){k(e,t,o[t])}))}return e}({id:me,onKeyDown:de,onClick:ue,isOpen:J,ref:Z},G,d("action-popover-wrapper",G)),ye=null!=(ye={children:[(e=>{if(R){const t=R({tabIndex:J?-1:0,"data-element":"action-popover-button",ariaAttributes:{"aria-haspopup":"true","aria-label":q||H.actionPopover.ariaLabel(),"aria-labelledby":T,"aria-describedby":V,"aria-controls":e,"aria-expanded":`${J}`}}),o=D(t);return R({tabIndex:J?-1:0,"data-element":"action-popover-button",ariaAttributes:{"aria-haspopup":"true","aria-label":o?void 0:q||H.actionPopover.ariaLabel(),"aria-labelledby":T,"aria-describedby":V,"aria-controls":e,"aria-expanded":`${J}`}})}return t(f,{role:"button","aria-haspopup":"true","aria-label":q||H.actionPopover.ariaLabel(),"aria-labelledby":T,"aria-describedby":V,"aria-controls":e,"aria-expanded":J,tabIndex:J?-1:0,"data-element":"action-popover-button",children:t(v,{type:"ellipsis_vertical"})})})(fe),t(P,{value:{setOpenPopover:ce,focusButton:se,submenuPosition:U,horizontalAlignment:N,selectedSubmenuRef:oe,setSelectedSubmenuRef:re},children:J&&t(_,{placement:pe,reference:Z,disableBackgroundUI:te,children:t(g,{"data-component":"action-popover",ref:ee,parentID:me,menuID:fe,focusIndex:W,setFocusIndex:X,isOpen:J,setOpen:ce,placement:F,children:B})})})]})?ye:{},Object.getOwnPropertyDescriptors?Object.defineProperties(ve,Object.getOwnPropertyDescriptors(ye)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(ye)).forEach((function(e){Object.defineProperty(ve,e,Object.getOwnPropertyDescriptor(ye,e))})),ve));var ve,ye}));export{L as ActionPopover,L as default};
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import o,{forwardRef as r,useState as n,useRef as a,useContext as i,useMemo as l,useCallback as p,useImperativeHandle as c,useEffect as s}from"react";import u from"invariant";import d from"../../__internal__/utils/helpers/tags/tags.js";import{MenuItemDivider as b,MenuButton as m,StyledButtonIcon as f,ButtonIcon as v}from"./action-popover.style.js";import y from"../../__internal__/utils/helpers/events/events.js";import _ from"../../__internal__/popover/popover.component.js";import O from"../../__internal__/utils/helpers/guid/index.js";import j from"../../hooks/__internal__/useLocale/useLocale.js";import g from"./action-popover-menu/action-popover-menu.component.js";import{ActionPopoverItem as h}from"./action-popover-item/action-popover-item.component.js";import"./action-popover-divider/action-popover-divider.component.js";import{ActionPopoverProvider as P}from"./__internal__/action-popover.context.js";import x from"../../hooks/__internal__/useModalManager/useModalManager.js";import w from"../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js";import{getItems as A,findFirstFocusableItem as S,findLastFocusableItem as D,checkChildrenForString as I}from"./__internal__/action-popover.utils.js";import M from"../flat-table/__internal__/flat-table.context.js";function k(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}const E=()=>{},L=()=>{},B=r(((r,B)=>{var{children:K,id:$,onOpen:C=E,onClose:F=L,rightAlignMenu:z,renderButton:R,placement:N="bottom",horizontalAlignment:U="left",submenuPosition:q="left","aria-label":T,"aria-labelledby":V,"aria-describedby":G}=r,H=function(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},a=Object.keys(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}(r,["children","id","onOpen","onClose","rightAlignMenu","renderButton","placement","horizontalAlignment","submenuPosition","aria-label","aria-labelledby","aria-describedby"]);const J=j(),[Q,W]=n(!1),[X,Y]=n(0),[Z]=n(O()),ee=a(null),te=a(null),{isInFlatTable:oe}=i(M),[re,ne]=n(null),ae=l((()=>!o.Children.toArray(K).find((e=>!o.isValidElement(e)||e.type!==h&&e.type!==b))),[K]),ie=l((()=>A(K)),[K]),le=S(ie),pe=D(ie);u(ae,`ActionPopover only accepts children of type \`${h.displayName}\` and \`${b.displayName}\`.`);const ce=l((()=>"top"!==N||z?"top"===N&&z?"top-start":"bottom"===N&&z?"bottom-start":"bottom-end":"top-end"),[N,z]),se=p((e=>{e&&!Q&&C(),!e&&Q&&F(),W(e)}),[Q,C,F]),ue=p((()=>{var e;const t=null===(e=ee.current)||void 0===e?void 0:e.querySelector("[data-element='action-popover-button']");null==t||t.focus()}),[]);c(B,(()=>({focusButton(){ue()}})),[ue]);const de=p((e=>{e.stopPropagation();const t=!Q;Y(le),se(t),t||ue()}),[Q,le,se,ue]),be=p((e=>{y.isSpaceKey(e)||y.isDownKey(e)||y.isEnterKey(e)?(e.preventDefault(),e.stopPropagation(),Y(le),se(!0)):y.isUpKey(e)&&(e.preventDefault(),e.stopPropagation(),Y(pe),se(!0))}),[le,pe,se]),me=p((e=>{y.isEscKey(e)&&(se(!1),ue())}),[se,ue]);x({open:Q,closeModal:me,modalRef:ee}),s((()=>{const e=({target:e})=>{var t,o;const r=null==te||null===(t=te.current)||void 0===t?void 0:t.contains(e),n=null==ee||null===(o=ee.current)||void 0===o?void 0:o.contains(e);r||n||se(!1)},t="click";return document.addEventListener(t,e,{capture:!0}),function(){document.removeEventListener(t,e,{capture:!0})}}),[se]),w((()=>W(!1)));const fe=$||`ActionPopoverButton_${Z}`,ve=`ActionPopoverMenu_${Z}`;return e(m,(ye=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),r.forEach((function(t){k(e,t,o[t])}))}return e}({id:fe,onKeyDown:be,onClick:de,isOpen:Q,ref:ee},H,d("action-popover-wrapper",H)),_e=null!=(_e={children:[(e=>{if(R){const t=R({tabIndex:Q?-1:0,"data-element":"action-popover-button",ariaAttributes:{"aria-haspopup":"true","aria-label":T||J.actionPopover.ariaLabel(),"aria-labelledby":V,"aria-describedby":G,"aria-controls":e,"aria-expanded":`${Q}`}}),o=I(t);return R({tabIndex:Q?-1:0,"data-element":"action-popover-button",ariaAttributes:{"aria-haspopup":"true","aria-label":o?void 0:T||J.actionPopover.ariaLabel(),"aria-labelledby":V,"aria-describedby":G,"aria-controls":e,"aria-expanded":`${Q}`}})}return t(f,{role:"button","aria-haspopup":"true","aria-label":T||J.actionPopover.ariaLabel(),"aria-labelledby":V,"aria-describedby":G,"aria-controls":e,"aria-expanded":Q,tabIndex:Q?-1:0,"data-element":"action-popover-button",children:t(v,{type:"ellipsis_vertical"})})})(ve),t(P,{value:{setOpenPopover:se,focusButton:ue,submenuPosition:q,horizontalAlignment:U,selectedSubmenuRef:re,setSelectedSubmenuRef:ne},children:Q&&t(_,{placement:ce,reference:ee,disableBackgroundUI:oe,children:t(g,{"data-component":"action-popover",ref:te,parentID:fe,menuID:ve,focusIndex:X,setFocusIndex:Y,isOpen:Q,setOpen:se,placement:N,children:K})})})]})?_e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(ye,Object.getOwnPropertyDescriptors(_e)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(_e)).forEach((function(e){Object.defineProperty(ye,e,Object.getOwnPropertyDescriptor(_e,e))})),ye));var ye,_e}));export{B as ActionPopover,B as default};
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { PaddingProps, MarginProps } from "styled-system";
3
3
  import { TagProps } from "../../__internal__/utils/helpers/tags";
4
- export interface AdaptiveSidebarProps extends MarginProps, PaddingProps, Omit<TagProps, "data-component"> {
4
+ import { SidebarProps } from "../sidebar";
5
+ export interface AdaptiveSidebarProps extends MarginProps, PaddingProps, Omit<TagProps, "data-component">, Pick<SidebarProps, "restoreFocusOnClose"> {
5
6
  /** The breakpoint (in pixels) at which the sidebar will convert to a dialog-based sidebar */
6
7
  adaptiveBreakpoint?: number;
7
8
  /** The time in milliseconds for the sidebar to animate */
@@ -23,5 +24,5 @@ export interface AdaptiveSidebarProps extends MarginProps, PaddingProps, Omit<Ta
23
24
  /** The width of the sidebar */
24
25
  width?: string;
25
26
  }
26
- export declare const AdaptiveSidebar: ({ adaptiveBreakpoint, backgroundColor, borderColor, children, height, hidden, open, renderAsModal, width, ...props }: AdaptiveSidebarProps) => React.JSX.Element | null;
27
+ export declare const AdaptiveSidebar: ({ adaptiveBreakpoint, backgroundColor, borderColor, children, height, hidden, open, renderAsModal, width, restoreFocusOnClose, ...props }: AdaptiveSidebarProps) => React.JSX.Element | null;
27
28
  export default AdaptiveSidebar;
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useRef as r,useEffect as t}from"react";import{getColors as o,kebabToCamelCase as n}from"./__internal__/utils.js";import{Box as i}from"../box/box.component.js";import a from"../../style/utils/filter-styled-system-padding-props.js";import l from"../../style/utils/filter-styled-system-margin-props.js";import d from"../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js";import{StyledSidebar as c,StyledAdaptiveSidebar as p}from"./adaptive-sidebar.style.js";function s(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function b(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){s(e,r,t[r])}))}return e}function u(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}const f=s=>{var{adaptiveBreakpoint:f=768,backgroundColor:m="white",borderColor:y="none",children:O,height:h="100%",hidden:g=!1,open:j,renderAsModal:v=!1,width:w="320px"}=s,k=function(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)t=i[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(s,["adaptiveBreakpoint","backgroundColor","borderColor","children","height","hidden","open","renderAsModal","width"]);const P=d(f),x=r(null),_=Object.entries(o(m)).reduce(((e,[r,t])=>(e[n(r)]=t,e)),{});return t((()=>{x.current&&x.current.focus()}),[j]),t((()=>{g&&j&&document.querySelectorAll("[inert]").forEach((e=>{e.removeAttribute("inert")}))}),[g,j]),v||!P?e(c,{backgroundColor:m,className:"adaptive-sidebar-modal-view","data-role":"adaptive-sidebar-modal-view",enableBackgroundUI:j&&g,hidden:g,open:j,p:0,ref:x,children:e(i,u(b({"data-role":"adaptive-sidebar-content-wrapper",height:"100%"},_),{children:O}))}):j?e(p,u(b({backgroundColor:m,borderColor:"none"===y?void 0:y,"data-element":"adaptive-sidebar","data-role":"adaptive-sidebar",height:h,hidden:g,ref:x,role:"region",tabIndex:-1,width:w},l(k),a(k)),{children:e(i,{"data-role":"adaptive-sidebar-content-wrapper",children:O})})):null};export{f as AdaptiveSidebar,f as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{useRef as r,useEffect as t}from"react";import{getColors as o,kebabToCamelCase as n}from"./__internal__/utils.js";import{Box as i}from"../box/box.component.js";import a from"../../style/utils/filter-styled-system-padding-props.js";import l from"../../style/utils/filter-styled-system-margin-props.js";import d from"../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js";import{StyledSidebar as s,StyledAdaptiveSidebar as c}from"./adaptive-sidebar.style.js";function p(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function u(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){p(e,r,t[r])}))}return e}function b(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}const f=p=>{var{adaptiveBreakpoint:f=768,backgroundColor:m="white",borderColor:O="none",children:y,height:h="100%",hidden:v=!1,open:g,renderAsModal:j=!1,width:w="320px",restoreFocusOnClose:k=!1}=p,P=function(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)t=i[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(p,["adaptiveBreakpoint","backgroundColor","borderColor","children","height","hidden","open","renderAsModal","width","restoreFocusOnClose"]);const C=d(f),S=j||!C,x=r(null),_=Object.entries(o(m)).reduce(((e,[r,t])=>(e[n(r)]=t,e)),{});return t((()=>{x.current&&x.current.focus()}),[g]),t((()=>{v&&g&&document.querySelectorAll("[inert]").forEach((e=>{e.removeAttribute("inert")}))}),[v,g]),t((()=>{S&&document.dispatchEvent(new CustomEvent("adaptiveSidebarModalFocusIn",{bubbles:!0,detail:{source:"adaptiveSidebarModal"}}))}),[S]),S?e(s,{backgroundColor:m,className:"adaptive-sidebar-modal-view","data-role":"adaptive-sidebar-modal-view",enableBackgroundUI:g&&v,hidden:v,restoreFocusOnClose:k,open:g,p:0,ref:x,children:e(i,b(u({"data-role":"adaptive-sidebar-content-wrapper",height:"100%"},_),{children:y}))}):g?e(c,b(u({backgroundColor:m,borderColor:"none"===O?void 0:O,"data-element":"adaptive-sidebar","data-role":"adaptive-sidebar",height:h,hidden:v,ref:x,role:"region",tabIndex:-1,width:w},l(P),a(P)),{children:e(i,{"data-role":"adaptive-sidebar-content-wrapper",children:y})})):null};export{f as AdaptiveSidebar,f as default};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import r,{forwardRef as o,useRef as n,useContext as i,useImperativeHandle as l}from"react";import{offset as a,flip as s}from"@floating-ui/dom";import c from"../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js";import u from"../split-button/__internal__/split-button.context.js";import{StyledMultiActionButton as p,StyledButtonChildrenContainer as d}from"./multi-action-button.style.js";import f from"../button/button.component.js";import m from"../../__internal__/popover/popover.component.js";import"../../style/utils/filter-styled-system-padding-props.js";import b from"../../style/utils/filter-styled-system-margin-props.js";import y from"../../style/utils/filter-out-styled-system-spacing-props.js";import g from"../../hooks/__internal__/useChildButtons/useChildButtons.js";import j from"../flat-table/__internal__/flat-table.context.js";import O from"../../__internal__/utils/helpers/guid/index.js";function h(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){h(t,e,r[e])}))}return t}function w(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}const P=o(((o,h)=>{var{align:P="left",position:v="left",disabled:x,buttonType:k,size:S,children:B,text:C,subtext:T,width:D,onClick:z,"data-element":A,"data-role":E}=o,I=function(t,e){if(null==t)return{};var r,o,n=function(t,e){if(null==t)return{};var r,o,n={},i=Object.keys(t);for(o=0;o<i.length;o++)r=i[o],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}(o,["align","position","disabled","buttonType","size","children","text","subtext","width","onClick","data-element","data-role"]);const K=n(null),{isInFlatTable:L}=i(j),F=n(O());l(h,(()=>({focusMainButton(){var t;null===(t=K.current)||void 0===t||t.focus({preventScroll:!0})}})),[]);const{showAdditionalButtons:M,showButtons:N,hideButtons:U,buttonNode:V,handleToggleButtonKeyDown:q,wrapperProps:G,contextValue:H}=g(K),J=c(U),Q=_({disabled:x,displayed:M,onTouchStart:N,onKeyDown:q,onClick:t=>{M?U():N(),J(),z&&z(t)},buttonType:k,size:S,subtext:T},y(I)),R=b(I);return t(p,w(_({ref:V,"data-component":"multi-action-button","data-element":A,"data-role":E,displayed:M,width:D},R),{children:[e(f,w(_({"aria-expanded":M,"aria-controls":F.current,"data-element":"toggle-button"},Q),{ref:K,iconPosition:"after",iconType:"dropdown",children:C}),"toggle-button"),M&&e(m,{disableBackgroundUI:L,disablePortal:!0,placement:"left"===v?"bottom-start":"bottom-end",reference:V,popoverStrategy:"fixed",middleware:[a(6),s({fallbackStrategy:"initialPlacement"})],children:e(d,w(_({id:F.current},G),{align:P,children:e(u.Provider,{value:H,children:r.Children.map(B,(t=>e("li",{children:t})))})}))})]}))}));export{P as MultiActionButton,P as default};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import r,{forwardRef as o,useRef as n,useContext as i,useImperativeHandle as l}from"react";import{offset as a,flip as s}from"@floating-ui/dom";import c from"../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js";import u from"../split-button/__internal__/split-button.context.js";import{StyledMultiActionButton as p,StyledButtonChildrenContainer as d}from"./multi-action-button.style.js";import f from"../button/button.component.js";import m from"../../__internal__/popover/popover.component.js";import"../../style/utils/filter-styled-system-padding-props.js";import b from"../../style/utils/filter-styled-system-margin-props.js";import y from"../../style/utils/filter-out-styled-system-spacing-props.js";import g from"../../hooks/__internal__/useChildButtons/useChildButtons.js";import j from"../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js";import O from"../flat-table/__internal__/flat-table.context.js";import h from"../../__internal__/utils/helpers/guid/index.js";function _(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function w(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){_(t,e,r[e])}))}return t}function v(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}const P=o(((o,_)=>{var{align:P="left",position:x="left",disabled:k,buttonType:S,size:B,children:C,text:T,subtext:D,width:A,onClick:z,"data-element":E,"data-role":F}=o,I=function(t,e){if(null==t)return{};var r,o,n=function(t,e){if(null==t)return{};var r,o,n={},i=Object.keys(t);for(o=0;o<i.length;o++)r=i[o],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}(o,["align","position","disabled","buttonType","size","children","text","subtext","width","onClick","data-element","data-role"]);const M=n(null),{isInFlatTable:K}=i(O),L=n(h());l(_,(()=>({focusMainButton(){var t;null===(t=M.current)||void 0===t||t.focus({preventScroll:!0})}})),[]);const{showAdditionalButtons:N,showButtons:U,hideButtons:V,buttonNode:q,handleToggleButtonKeyDown:G,wrapperProps:H,contextValue:J}=g(M),Q=c(V);j((()=>V()));const R=w({disabled:k,displayed:N,onTouchStart:U,onKeyDown:G,onClick:t=>{N?V():U(),Q(),z&&z(t)},buttonType:S,size:B,subtext:D},y(I)),W=b(I);return t(p,v(w({ref:q,"data-component":"multi-action-button","data-element":E,"data-role":F,displayed:N,width:A},W),{children:[e(f,v(w({"aria-expanded":N,"aria-controls":L.current,"data-element":"toggle-button"},R),{ref:M,iconPosition:"after",iconType:"dropdown",children:T}),"toggle-button"),N&&e(m,{disableBackgroundUI:K,disablePortal:!0,placement:"left"===x?"bottom-start":"bottom-end",reference:q,popoverStrategy:"fixed",middleware:[a(6),s({fallbackStrategy:"initialPlacement"})],children:e(d,v(w({id:L.current},H),{align:P,children:e(u.Provider,{value:J,children:r.Children.map(C,(t=>e("li",{children:t})))})}))})]}))}));export{P as MultiActionButton,P as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useState as r,useRef as o,useCallback as l,useEffect as i}from"react";import a from"invariant";import"../../../style/utils/filter-styled-system-padding-props.js";import s from"../../../style/utils/filter-styled-system-margin-props.js";import c from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../__internal__/select-textbox/select-textbox.component.js";import d from"../../../__internal__/utils/helpers/guid/index.js";import p from"../__internal__/utils/with-filter.hoc.js";import m from"../select.style.js";import f from"../__internal__/select-list/select-list.component.js";import b from"../__internal__/utils/is-expected-option.js";import v from"../__internal__/utils/are-objects-equal.js";import y from"../__internal__/utils/is-navigation-key.js";import{useStableCallback as g}from"../../../hooks/__internal__/useStableCallback/useStableCallback.js";import h from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){O(e,t,n[t])}))}return e}function j(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const w=p(f),C=n.forwardRef(((p,O)=>{var{"aria-label":C,"aria-labelledby":x,value:L,id:S,name:P,label:k,children:D,onOpen:A,onChange:E,onFilterChange:B,onClick:F,onKeyDown:M,onFocus:T,onBlur:I,openOnFocus:V,noResultsMessage:H,listActionButton:W,listMaxHeight:q,onListAction:K,isLoading:R,disabled:z,readOnly:G,onListScrollBottom:J,tableHeader:N,multiColumn:Q,"data-element":U,"data-role":X,tooltipPosition:Y,listPlacement:Z="bottom",flipEnabled:$=!0,enableVirtualScroll:ee,virtualScrollOverscan:te,disableDefaultFiltering:ne=!1,required:re,listWidth:oe}=p,le=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(p,["aria-label","aria-labelledby","value","id","name","label","children","onOpen","onChange","onFilterChange","onClick","onKeyDown","onFocus","onBlur","openOnFocus","noResultsMessage","listActionButton","listMaxHeight","onListAction","isLoading","disabled","readOnly","onListScrollBottom","tableHeader","multiColumn","data-element","data-role","tooltipPosition","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","disableDefaultFiltering","required","listWidth"]);const[ie,ae]=r(""),se=o(d()),ce=o(null),ue=o(null),de=o(!1),pe=o(!1),me=o(!1),[fe,be]=r(),[ve,ye]=r(!1),[ge,he]=r(""),[Oe,_e]=r(L||""),je=o(L),[we,Ce]=r(""),[xe,Le]=r(""),Se=o(S||d()),{labelId:Pe}=h({id:Se.current,label:k}),ke=o(null),De=o(!1),Ae=l(((e,t)=>({target:j(_({},P&&{name:P},S&&{id:S}),{value:e}),selectionConfirmed:t})),[P,S]),Ee=l(((e,t)=>{E&&E(Ae(e,t))}),[E,Ae]),Be=l(((e,t)=>{_e((()=>{var r;const o=e.trimStart(),l=(i=o,a=D,n.Children.toArray(a).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==i?void 0:i.toLowerCase()))})));var i,a;const s=t&&!e.length;return!l||s||l.props.disabled?(he(e),Ee("",!1),""):(o.length&&Ee(l.props.value,!1),t?(he(e),l.props.value):(o.length&&(null===(r=l.props.text)||void 0===r?void 0:r.toLowerCase().startsWith(o.toLowerCase()))?he(l.props.text):he(e),Ce(l.props.value),l.props.value))}))}),[D,Ee]),Fe=l(((e,t=!1)=>{var r;const o=n.Children.toArray(D).find((t=>n.isValidElement(t)&&b(t,e)));o&&void 0!==o.props.text?(t||(null===(r=o.props.text)||void 0===r?void 0:r.toLowerCase().startsWith(null==xe?void 0:xe.toLowerCase().trim())))&&he(o.props.text):he(xe||"")}),[D,xe]),Me=l((e=>{const t=e.target.value,{inputType:n}=e.nativeEvent;Be(t,"deleteContentBackward"===n||"deleteContentForward"===n||"delete"===n),Le(t),ye(!0)}),[Be]),Te=l((e=>{Le((t=>(null==t?void 0:t.length)===(null==ge?void 0:ge.length)-1&&e===ge.slice(-1)?ge:t))}),[ge]),Ie=l((e=>{const{key:t}=e;M&&M(e),G||(!e.defaultPrevented&&y(t)&&(e.preventDefault(),ye(!0)),Te(t))}),[Te,M,G]),Ve=l((e=>{const t=ce.current&&!ce.current.contains(e.target),n=ue.current&&!ue.current.contains(e.target);de.current=!1,t&&n&&(Fe(L,!0),ye(!1))}),[Fe,L]);i((()=>{_e((e=>(L&&e!==L&&Fe(L),L))),Ce(L)}),[L,E,D]);const He=g(A);i((()=>{ve?He&&He():Le("")}),[He,ve]),i((()=>{const e=void 0!==W;a(!e||e&&K,"onListAction prop required when using listActionButton prop")}),[W,K]);const We=o(!0);i((()=>{We.current&&Fe(Oe),"object"==typeof L&&"object"==typeof je.current?v(L,je.current)||(Fe(L),je.current=L):Fe(L)}),[L,D]);const qe=g(B);i((()=>{qe&&!We.current&&qe(xe)}),[qe,xe]),i((()=>{We.current=!1}),[]),i((()=>{const e="click";return window.addEventListener(e,Ve),function(){window.removeEventListener(e,Ve)}}),[Ve]),i((()=>{const e=null==xe?void 0:xe.trimStart(),t=null==ge?void 0:ge.toLowerCase().startsWith(e.toLowerCase());!z&&!G&&fe&&e.length&&(null==ge?void 0:ge.length)>e.length&&t&&(fe.selectionStart=e.length)}),[ge,xe,fe,z,G]);const Ke=l((e=>{const{id:t,text:n,value:r,selectionType:o,selectionConfirmed:l}=e;he(n),Ee(r,!!l),ae(t),"navigationKey"!==o&&(De.current=!!V,ye(!1),null==fe||fe.focus(),null==fe||fe.select(),De.current=!1)}),[fe,Ee,V]),Re=l((()=>{ye(!1),Fe(Oe,!0)}),[Oe,Fe]);function ze(e){de.current=!0,"input"===e.target.dataset.element&&(me.current=!0)}i((()=>()=>{ke.current&&clearTimeout(ke.current)}),[]);const Ge=l((e=>{e&&(be(e),O&&("function"==typeof O?O(e):O.current=e))}),[O]);let Je;switch(Z){case"top":Je="top-end";break;case"bottom":Je="bottom-end";break;default:Je=Z}const Ne={ref:ue,id:se.current,labelId:Pe,anchorElement:(null==fe?void 0:fe.parentElement)||void 0,onSelect:Ke,onSelectListClose:Re,onMouseDown:function(){de.current=!0},filterText:xe.trim(),highlightedValue:we,noResultsMessage:H,listActionButton:W,listMaxHeight:q,onListAction:function(){ye(!1),null==K||K()},isLoading:R,onListScrollBottom:J,tableHeader:N,multiColumn:Q,listPlacement:void 0!==oe?Je:Z,flipEnabled:$,isOpen:ve,enableVirtualScroll:ee,virtualScrollOverscan:te,listWidth:oe},Qe=e(ne?f:w,j(_({},Ne),{children:D})),Ue=s(le);return t(m,j(_({hasTextCursor:!0,readOnly:G,disabled:z,"data-component":"filterable-select","data-role":X,"data-element":U,isOpen:ve},Ue),{children:[e("div",{ref:ce,children:e(u,j(_({ref:Ge,activeDescendantId:ie,ariaLabel:C,ariaLabelledby:x,labelId:k?Pe:void 0,"aria-controls":se.current,isOpen:ve,hasTextCursor:!0},j(_({id:Se.current,name:P,label:k,disabled:z,readOnly:G,selectedValue:Oe,formattedValue:ge,onClick:function(e){de.current=!1,F&&F(e),ye(!0)},iconOnClick:function(e){de.current=!1,F&&F(e),ye((e=>!e))},iconOnMouseDown:ze,onFocus:function(e){const t=()=>null==T?void 0:T(e);if(V){if(ke.current&&clearTimeout(ke.current),De.current)return;ke.current=setTimeout((()=>{ye((e=>!(!e&&(T&&!pe.current&&(t(),pe.current=!0),de.current&&!me.current))))}))}else T&&!pe.current&&(t(),pe.current=!0)},onBlur:function(e){me.current=!1,de.current||(pe.current=!1,I&&I(e))},onKeyDown:Ie,onChange:Me,onMouseDown:ze,tooltipPosition:Y,required:re},c(le)),{"data-component":void 0})),{onChange:Me,value:ge}))}),Qe]}))}));export{C as FilterableSelect,C as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useState as r,useRef as o,useCallback as l,useEffect as i}from"react";import a from"invariant";import"../../../style/utils/filter-styled-system-padding-props.js";import s from"../../../style/utils/filter-styled-system-margin-props.js";import c from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../__internal__/select-textbox/select-textbox.component.js";import d from"../../../__internal__/utils/helpers/guid/index.js";import p from"../__internal__/utils/with-filter.hoc.js";import m from"../select.style.js";import f from"../__internal__/select-list/select-list.component.js";import b from"../__internal__/utils/is-expected-option.js";import v from"../__internal__/utils/are-objects-equal.js";import y from"../__internal__/utils/is-navigation-key.js";import{useStableCallback as g}from"../../../hooks/__internal__/useStableCallback/useStableCallback.js";import h from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";import O from"../../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js";function _(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){_(e,t,n[t])}))}return e}function w(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const C=p(f),x=n.forwardRef(((p,_)=>{var{"aria-label":x,"aria-labelledby":S,value:L,id:P,name:k,label:A,children:D,onOpen:E,onChange:F,onFilterChange:B,onClick:M,onKeyDown:T,onFocus:I,onBlur:V,openOnFocus:H,noResultsMessage:W,listActionButton:q,listMaxHeight:K,onListAction:R,isLoading:z,disabled:G,readOnly:J,onListScrollBottom:N,tableHeader:Q,multiColumn:U,"data-element":X,"data-role":Y,tooltipPosition:Z,listPlacement:$="bottom",flipEnabled:ee=!0,enableVirtualScroll:te,virtualScrollOverscan:ne,disableDefaultFiltering:re=!1,required:oe,listWidth:le}=p,ie=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(p,["aria-label","aria-labelledby","value","id","name","label","children","onOpen","onChange","onFilterChange","onClick","onKeyDown","onFocus","onBlur","openOnFocus","noResultsMessage","listActionButton","listMaxHeight","onListAction","isLoading","disabled","readOnly","onListScrollBottom","tableHeader","multiColumn","data-element","data-role","tooltipPosition","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","disableDefaultFiltering","required","listWidth"]);const[ae,se]=r(""),ce=o(d()),ue=o(null),de=o(null),pe=o(!1),me=o(!1),fe=o(!1),[be,ve]=r(),[ye,ge]=r(!1),[he,Oe]=r(""),[_e,je]=r(L||""),we=o(L),[Ce,xe]=r(""),[Se,Le]=r(""),Pe=o(P||d()),{labelId:ke}=h({id:Pe.current,label:A}),Ae=o(null),De=o(!1),Ee=l(((e,t)=>({target:w(j({},k&&{name:k},P&&{id:P}),{value:e}),selectionConfirmed:t})),[k,P]),Fe=l(((e,t)=>{F&&F(Ee(e,t))}),[F,Ee]),Be=l(((e,t)=>{je((()=>{var r;const o=e.trimStart(),l=(i=o,a=D,n.Children.toArray(a).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==i?void 0:i.toLowerCase()))})));var i,a;const s=t&&!e.length;return!l||s||l.props.disabled?(Oe(e),Fe("",!1),""):(o.length&&Fe(l.props.value,!1),t?(Oe(e),l.props.value):(o.length&&(null===(r=l.props.text)||void 0===r?void 0:r.toLowerCase().startsWith(o.toLowerCase()))?Oe(l.props.text):Oe(e),xe(l.props.value),l.props.value))}))}),[D,Fe]),Me=l(((e,t=!1)=>{var r;const o=n.Children.toArray(D).find((t=>n.isValidElement(t)&&b(t,e)));o&&void 0!==o.props.text?(t||(null===(r=o.props.text)||void 0===r?void 0:r.toLowerCase().startsWith(null==Se?void 0:Se.toLowerCase().trim())))&&Oe(o.props.text):Oe(Se||"")}),[D,Se]),Te=l((e=>{const t=e.target.value,{inputType:n}=e.nativeEvent;Be(t,"deleteContentBackward"===n||"deleteContentForward"===n||"delete"===n),Le(t),ge(!0)}),[Be]),Ie=l((e=>{Le((t=>(null==t?void 0:t.length)===(null==he?void 0:he.length)-1&&e===he.slice(-1)?he:t))}),[he]),Ve=l((e=>{const{key:t}=e;T&&T(e),J||(!e.defaultPrevented&&y(t)&&(e.preventDefault(),ge(!0)),Ie(t))}),[Ie,T,J]),He=l((e=>{const t=ue.current&&!ue.current.contains(e.target),n=de.current&&!de.current.contains(e.target);pe.current=!1,t&&n&&(Me(L,!0),ge(!1))}),[Me,L]);i((()=>{je((e=>(L&&e!==L&&Me(L),L))),xe(L)}),[L,F,D]);const We=g(E);i((()=>{ye?We&&We():Le("")}),[We,ye]),i((()=>{const e=void 0!==q;a(!e||e&&R,"onListAction prop required when using listActionButton prop")}),[q,R]);const qe=o(!0);i((()=>{qe.current&&Me(_e),"object"==typeof L&&"object"==typeof we.current?v(L,we.current)||(Me(L),we.current=L):Me(L)}),[L,D]);const Ke=g(B);i((()=>{Ke&&!qe.current&&Ke(Se)}),[Ke,Se]),i((()=>{qe.current=!1}),[]),i((()=>{const e="click";return window.addEventListener(e,He),function(){window.removeEventListener(e,He)}}),[He]),i((()=>{const e=null==Se?void 0:Se.trimStart(),t=null==he?void 0:he.toLowerCase().startsWith(e.toLowerCase());!G&&!J&&be&&e.length&&(null==he?void 0:he.length)>e.length&&t&&(be.selectionStart=e.length)}),[he,Se,be,G,J]);const Re=l((e=>{const{id:t,text:n,value:r,selectionType:o,selectionConfirmed:l}=e;Oe(n),Fe(r,!!l),se(t),"navigationKey"!==o&&(De.current=!!H,ge(!1),null==be||be.focus(),null==be||be.select(),De.current=!1)}),[be,Fe,H]),ze=l((()=>{ge(!1),Me(_e,!0)}),[_e,Me]);function Ge(e){pe.current=!0,"input"===e.target.dataset.element&&(fe.current=!0)}i((()=>()=>{Ae.current&&clearTimeout(Ae.current)}),[]),O((()=>ge(!1)));const Je=l((e=>{e&&(ve(e),_&&("function"==typeof _?_(e):_.current=e))}),[_]);let Ne;switch($){case"top":Ne="top-end";break;case"bottom":Ne="bottom-end";break;default:Ne=$}const Qe={ref:de,id:ce.current,labelId:ke,anchorElement:(null==be?void 0:be.parentElement)||void 0,onSelect:Re,onSelectListClose:ze,onMouseDown:function(){pe.current=!0},filterText:Se.trim(),highlightedValue:Ce,noResultsMessage:W,listActionButton:q,listMaxHeight:K,onListAction:function(){ge(!1),null==R||R()},isLoading:z,onListScrollBottom:N,tableHeader:Q,multiColumn:U,listPlacement:void 0!==le?Ne:$,flipEnabled:ee,isOpen:ye,enableVirtualScroll:te,virtualScrollOverscan:ne,listWidth:le},Ue=e(re?f:C,w(j({},Qe),{children:D})),Xe=s(ie);return t(m,w(j({hasTextCursor:!0,readOnly:J,disabled:G,"data-component":"filterable-select","data-role":Y,"data-element":X,isOpen:ye},Xe),{children:[e("div",{ref:ue,children:e(u,w(j({ref:Je,activeDescendantId:ae,ariaLabel:x,ariaLabelledby:S,labelId:A?ke:void 0,"aria-controls":ce.current,isOpen:ye,hasTextCursor:!0},w(j({id:Pe.current,name:k,label:A,disabled:G,readOnly:J,selectedValue:_e,formattedValue:he,onClick:function(e){pe.current=!1,M&&M(e),ge(!0)},iconOnClick:function(e){pe.current=!1,M&&M(e),ge((e=>!e))},iconOnMouseDown:Ge,onFocus:function(e){const t=()=>null==I?void 0:I(e);if(H){if(Ae.current&&clearTimeout(Ae.current),De.current)return;Ae.current=setTimeout((()=>{ge((e=>!(!e&&(I&&!me.current&&(t(),me.current=!0),pe.current&&!fe.current))))}))}else I&&!me.current&&(t(),me.current=!0)},onBlur:function(e){fe.current=!1,pe.current||(me.current=!1,V&&V(e))},onKeyDown:Ve,onChange:Te,onMouseDown:Ge,tooltipPosition:Z,required:oe},c(ie)),{"data-component":void 0})),{onChange:Te,value:he}))}),Ue]}))}));export{x as FilterableSelect,x as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import r,{useState as n,useRef as l,useCallback as o,useMemo as i,useEffect as a}from"react";import"../../../style/utils/filter-styled-system-padding-props.js";import s from"../../../style/utils/filter-styled-system-margin-props.js";import c from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../__internal__/select-textbox/select-textbox.component.js";import d from"../../../__internal__/utils/helpers/guid/index.js";import p from"../__internal__/utils/with-filter.hoc.js";import m from"../__internal__/select-list/select-list.component.js";import{StyledSelectPillContainer as f,StyledSelectMultiSelect as b,StyledAccessibilityLabelContainer as v}from"./multi-select.style.js";import{Pill as y}from"../../pill/pill.component.js";import h from"../__internal__/utils/is-expected-option.js";import g from"../__internal__/utils/is-expected-value.js";import O from"../__internal__/utils/is-navigation-key.js";import{useStableCallback as _}from"../../../hooks/__internal__/useStableCallback/useStableCallback.js";import j from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function C(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){w(e,t,r[t])}))}return e}function x(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const P=p(m),S=r.forwardRef(((p,m)=>{var{"aria-label":w,"aria-labelledby":S,value:k,id:D,label:L,name:E,disabled:V,readOnly:I,children:M,onOpen:T,onFilterChange:B,onChange:F,onClick:H,onFocus:z,onBlur:A,onKeyDown:K,openOnFocus:R=!1,noResultsMessage:q,placeholder:W,isLoading:$,onListScrollBottom:G,tableHeader:J,multiColumn:N,tooltipPosition:Q,size:U="medium","data-element":X,"data-role":Y,listPlacement:Z="bottom",listMaxHeight:ee,flipEnabled:te=!0,wrapPillText:re=!0,enableVirtualScroll:ne,virtualScrollOverscan:le,required:oe,listWidth:ie}=p,ae=function(e,t){if(null==e)return{};var r,n,l=function(e,t){if(null==e)return{};var r,n,l={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(l[r]=e[r]);return l}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r])}return l}(p,["aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","onOpen","onFilterChange","onChange","onClick","onFocus","onBlur","onKeyDown","openOnFocus","noResultsMessage","placeholder","isLoading","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","size","data-element","data-role","listPlacement","listMaxHeight","flipEnabled","wrapPillText","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const[se,ce]=n(""),ue=l(d()),de=l(d()),pe=l(null),me=l(null),fe=l(!1),be=l(!1),ve=l(!1),ye=l(!1),he=l(!1),[ge,Oe]=n(),[_e,je]=n(!1),[we,Ce]=n(""),[xe,Pe]=n(""),[Se,ke]=n(""),[De,Le]=n(),Ee=l(D||d()),{labelId:Ve}=j({id:Ee.current,label:L}),Ie=l(null),Me=o((()=>{je((e=>(!e&&T&&T(),!0)))}),[T]),Te=o(((e,t)=>({target:x(C({},E&&{name:E},D&&{id:D}),{value:e}),selectionConfirmed:t})),[E,D]),Be=o(((e,t)=>{const r=e(k);r.length!==(null==k?void 0:k.length)&&F(Te(r,t))}),[Te,F,k]),Fe=o((e=>{const t=e.target.value,n=(l=t,o=M,r.Children.toArray(o).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==l?void 0:l.toLowerCase()))})));var l,o;n&&Pe(n.props.value),ke(t),Ce(t),Me()}),[M,Me]),He=o((e=>{be.current=!0,Be((t=>{if(!t.length)return t;const r=t.slice();return r.splice(e,1),r}),!0)}),[Be]),ze=o((e=>{const{key:t}=e,r="Backspace"===t||"Delete"===t;K&&K(e),I||(!e.defaultPrevented&&O(t)&&(e.preventDefault(),Me()),!r||""!==Se&&""!==we||He(-1))}),[K,I,Se,we,Me,He]),Ae=i((()=>{var e;return k&&k.length?null===(e=r.Children.map(M,(e=>!(!r.isValidElement(e)||!k.includes(e.props.value))&&e.props.text)))||void 0===e?void 0:e.filter((e=>e)).reduce(((e,t)=>e?`${e}, ${t}`:t),""):null}),[M,k]),Ke=o((e=>{if(ve.current=!1,!_e)return;const t=pe.current&&!pe.current.contains(e.target),r=me.current&&!me.current.contains(e.target);t&&r&&!be.current&&(Ce(""),ke(""),Pe(""),je(!1)),be.current=!1}),[_e]),Re=i((()=>{const t=!V&&!I;let n;return(null==k?void 0:k.length)?k.map(((l,o)=>{const i=r.Children.toArray(M).find((e=>r.isValidElement(e)&&h(e,l)));let a={};if(!i)return null;var s,c;r.isValidElement(i)&&(n=void 0!==(null==i||null===(s=i.props.value)||void 0===s?void 0:s.value)?null==i||null===(c=i.props.value)||void 0===c?void 0:c.value:null==i?void 0:i.props.value,a={title:i.props.text,fill:i.props.fill,borderColor:i.props.borderColor});const u=a.title||"",d=u+n||o;return e(f,{children:e(y,x(C({onDelete:t?()=>He(o):void 0,wrapText:re},a),{children:u}))},d)})):""}),[M,V,I,k]);a((()=>{const e=null==k?void 0:k.length;Le(e?" ":W)}),[k,W]),a((()=>{const e="click";return window.addEventListener(e,Ke),function(){window.removeEventListener(e,Ke)}}),[Ke]);const qe=_(B),We=l(!0);function $e(e){if(ve.current=!1,H&&H(e),!R||R&&!he.current){if(_e)return ke(""),void je(!1);null==T||T(),je(!0)}else he.current=!1}function Ge(e){ve.current=!1,H&&H(e),je((e=>e?(ke(""),!1):(T&&T(),!0)))}function Je(e){ye.current=!1,ve.current||(fe.current=!1,A&&A(e))}function Ne(e){ve.current=!0,"input"===e.target.dataset.element&&(ye.current=!0)}function Qe(e){const t=()=>null==z?void 0:z(e);R?(Ie.current&&clearTimeout(Ie.current),Ie.current=setTimeout((()=>{je((e=>!!e||(T&&T(),z&&!fe.current&&(t(),fe.current=!0),ve.current&&!ye.current?(he.current=!1,!1):(ye.current&&(he.current=!0),!0))))}))):z&&!fe.current&&(t(),fe.current=!0)}a((()=>{qe&&!We.current&&qe(Se)}),[qe,Se]),a((()=>{We.current=!1}),[]);const Ue=o((e=>{const{value:t,selectionType:r,id:n,selectionConfirmed:l}=e;if("navigationKey"===r)return Pe(t),void ce(n);"click"===r&&(be.current=!0),Ce("");const o=-1!==(null==k?void 0:k.findIndex((e=>g(e,t))));null==ge||ge.focus(),ve.current=!1,Be((e=>o?e:[...e,t]),l)}),[ge,k,Be]),Xe=o((()=>{je(!1),ke("")}),[]),Ye=o((e=>{e&&(Oe(e),m&&("function"==typeof m?m(e):m.current=e))}),[m]);function Ze(){return x(C({id:Ee.current,name:E,disabled:V,label:L,readOnly:I,placeholder:De,leftChildren:Re,formattedValue:we,selectedValue:k,onClick:$e,onMouseDown:Ne,onFocus:Qe,onBlur:Je,iconOnClick:Ge,iconOnMouseDown:Ne,onKeyDown:ze,onChange:Fe,tooltipPosition:Q,size:U,required:oe},c(ae)),{"data-component":void 0})}let et;switch(Z){case"top":et="top-end";break;case"bottom":et="bottom-end";break;default:et=Z}const tt=e(P,{ref:me,id:ue.current,labelId:Ve,anchorElement:(null==ge?void 0:ge.parentElement)||void 0,onSelect:Ue,onSelectListClose:Xe,onMouseDown:function(){ve.current=!0},filterText:Se.trim(),highlightedValue:xe,noResultsMessage:q,isLoading:$,onListScrollBottom:G,tableHeader:J,multiColumn:N,listPlacement:void 0!==ie?et:Z,listMaxHeight:ee,flipEnabled:te,multiselectValues:k,isOpen:_e,enableVirtualScroll:ne,virtualScrollOverscan:le,listWidth:ie,children:M}),rt=s(ae);return t(b,x(C({disabled:V,readOnly:I,hasTextCursor:!0,size:U,"data-component":"multiselect","data-role":Y,"data-element":X,isOpen:_e},rt),{children:[t("div",{ref:pe,children:[e(v,{"data-element":"accessibility-label",id:de.current,children:Ae}),e(u,C({ref:Ye,accessibilityLabelId:de.current,activeDescendantId:se,"aria-controls":ue.current,ariaLabel:w,ariaLabelledby:S,hasTextCursor:!0,isOpen:_e,labelId:Ve,value:Ze().formattedValue},Ze()))]}),tt]}))}));export{S as MultiSelect,S as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import r,{useState as n,useRef as l,useCallback as o,useMemo as i,useEffect as a}from"react";import"../../../style/utils/filter-styled-system-padding-props.js";import s from"../../../style/utils/filter-styled-system-margin-props.js";import c from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../__internal__/select-textbox/select-textbox.component.js";import d from"../../../__internal__/utils/helpers/guid/index.js";import p from"../__internal__/utils/with-filter.hoc.js";import m from"../__internal__/select-list/select-list.component.js";import{StyledSelectPillContainer as f,StyledSelectMultiSelect as b,StyledAccessibilityLabelContainer as v}from"./multi-select.style.js";import{Pill as y}from"../../pill/pill.component.js";import h from"../__internal__/utils/is-expected-option.js";import g from"../__internal__/utils/is-expected-value.js";import O from"../__internal__/utils/is-navigation-key.js";import{useStableCallback as _}from"../../../hooks/__internal__/useStableCallback/useStableCallback.js";import j from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";import w from"../../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js";function C(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function x(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){C(e,t,r[t])}))}return e}function P(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const S=p(m),k=r.forwardRef(((p,m)=>{var{"aria-label":C,"aria-labelledby":k,value:D,id:L,label:E,name:M,disabled:V,readOnly:F,children:I,onOpen:T,onFilterChange:B,onChange:A,onClick:H,onFocus:z,onBlur:K,onKeyDown:R,openOnFocus:q=!1,noResultsMessage:W,placeholder:$,isLoading:G,onListScrollBottom:J,tableHeader:N,multiColumn:Q,tooltipPosition:U,size:X="medium","data-element":Y,"data-role":Z,listPlacement:ee="bottom",listMaxHeight:te,flipEnabled:re=!0,wrapPillText:ne=!0,enableVirtualScroll:le,virtualScrollOverscan:oe,required:ie,listWidth:ae}=p,se=function(e,t){if(null==e)return{};var r,n,l=function(e,t){if(null==e)return{};var r,n,l={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(l[r]=e[r]);return l}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r])}return l}(p,["aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","onOpen","onFilterChange","onChange","onClick","onFocus","onBlur","onKeyDown","openOnFocus","noResultsMessage","placeholder","isLoading","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","size","data-element","data-role","listPlacement","listMaxHeight","flipEnabled","wrapPillText","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const[ce,ue]=n(""),de=l(d()),pe=l(d()),me=l(null),fe=l(null),be=l(!1),ve=l(!1),ye=l(!1),he=l(!1),ge=l(!1),[Oe,_e]=n(),[je,we]=n(!1),[Ce,xe]=n(""),[Pe,Se]=n(""),[ke,De]=n(""),[Le,Ee]=n(),Me=l(L||d()),{labelId:Ve}=j({id:Me.current,label:E}),Fe=l(null),Ie=o((()=>{we((e=>(!e&&T&&T(),!0)))}),[T]),Te=o(((e,t)=>({target:P(x({},M&&{name:M},L&&{id:L}),{value:e}),selectionConfirmed:t})),[M,L]),Be=o(((e,t)=>{const r=e(D);r.length!==(null==D?void 0:D.length)&&A(Te(r,t))}),[Te,A,D]),Ae=o((e=>{const t=e.target.value,n=(l=t,o=I,r.Children.toArray(o).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==l?void 0:l.toLowerCase()))})));var l,o;n&&Se(n.props.value),De(t),xe(t),Ie()}),[I,Ie]),He=o((e=>{ve.current=!0,Be((t=>{if(!t.length)return t;const r=t.slice();return r.splice(e,1),r}),!0)}),[Be]),ze=o((e=>{const{key:t}=e,r="Backspace"===t||"Delete"===t;R&&R(e),F||(!e.defaultPrevented&&O(t)&&(e.preventDefault(),Ie()),!r||""!==ke&&""!==Ce||He(-1))}),[R,F,ke,Ce,Ie,He]),Ke=i((()=>{var e;return D&&D.length?null===(e=r.Children.map(I,(e=>!(!r.isValidElement(e)||!D.includes(e.props.value))&&e.props.text)))||void 0===e?void 0:e.filter((e=>e)).reduce(((e,t)=>e?`${e}, ${t}`:t),""):null}),[I,D]),Re=o((e=>{if(ye.current=!1,!je)return;const t=me.current&&!me.current.contains(e.target),r=fe.current&&!fe.current.contains(e.target);t&&r&&!ve.current&&(xe(""),De(""),Se(""),we(!1)),ve.current=!1}),[je]),qe=i((()=>{const t=!V&&!F;let n;return(null==D?void 0:D.length)?D.map(((l,o)=>{const i=r.Children.toArray(I).find((e=>r.isValidElement(e)&&h(e,l)));let a={};if(!i)return null;var s,c;r.isValidElement(i)&&(n=void 0!==(null==i||null===(s=i.props.value)||void 0===s?void 0:s.value)?null==i||null===(c=i.props.value)||void 0===c?void 0:c.value:null==i?void 0:i.props.value,a={title:i.props.text,fill:i.props.fill,borderColor:i.props.borderColor});const u=a.title||"",d=u+n||o;return e(f,{children:e(y,P(x({onDelete:t?()=>He(o):void 0,wrapText:ne},a),{children:u}))},d)})):""}),[I,V,F,D]);a((()=>{const e=null==D?void 0:D.length;Ee(e?" ":$)}),[D,$]),a((()=>{const e="click";return window.addEventListener(e,Re),function(){window.removeEventListener(e,Re)}}),[Re]);const We=_(B),$e=l(!0);function Ge(e){if(ye.current=!1,H&&H(e),!q||q&&!ge.current){if(je)return De(""),void we(!1);null==T||T(),we(!0)}else ge.current=!1}function Je(e){ye.current=!1,H&&H(e),we((e=>e?(De(""),!1):(T&&T(),!0)))}function Ne(e){he.current=!1,ye.current||(be.current=!1,K&&K(e))}function Qe(e){ye.current=!0,"input"===e.target.dataset.element&&(he.current=!0)}function Ue(e){const t=()=>null==z?void 0:z(e);q?(Fe.current&&clearTimeout(Fe.current),Fe.current=setTimeout((()=>{we((e=>!!e||(T&&T(),z&&!be.current&&(t(),be.current=!0),ye.current&&!he.current?(ge.current=!1,!1):(he.current&&(ge.current=!0),!0))))}))):z&&!be.current&&(t(),be.current=!0)}a((()=>{We&&!$e.current&&We(ke)}),[We,ke]),a((()=>{$e.current=!1}),[]),w((()=>we(!1)));const Xe=o((e=>{const{value:t,selectionType:r,id:n,selectionConfirmed:l}=e;if("navigationKey"===r)return Se(t),void ue(n);"click"===r&&(ve.current=!0),xe("");const o=-1!==(null==D?void 0:D.findIndex((e=>g(e,t))));null==Oe||Oe.focus(),ye.current=!1,Be((e=>o?e:[...e,t]),l)}),[Oe,D,Be]),Ye=o((()=>{we(!1),De("")}),[]),Ze=o((e=>{e&&(_e(e),m&&("function"==typeof m?m(e):m.current=e))}),[m]);function et(){return P(x({id:Me.current,name:M,disabled:V,label:E,readOnly:F,placeholder:Le,leftChildren:qe,formattedValue:Ce,selectedValue:D,onClick:Ge,onMouseDown:Qe,onFocus:Ue,onBlur:Ne,iconOnClick:Je,iconOnMouseDown:Qe,onKeyDown:ze,onChange:Ae,tooltipPosition:U,size:X,required:ie},c(se)),{"data-component":void 0})}let tt;switch(ee){case"top":tt="top-end";break;case"bottom":tt="bottom-end";break;default:tt=ee}const rt=e(S,{ref:fe,id:de.current,labelId:Ve,anchorElement:(null==Oe?void 0:Oe.parentElement)||void 0,onSelect:Xe,onSelectListClose:Ye,onMouseDown:function(){ye.current=!0},filterText:ke.trim(),highlightedValue:Pe,noResultsMessage:W,isLoading:G,onListScrollBottom:J,tableHeader:N,multiColumn:Q,listPlacement:void 0!==ae?tt:ee,listMaxHeight:te,flipEnabled:re,multiselectValues:D,isOpen:je,enableVirtualScroll:le,virtualScrollOverscan:oe,listWidth:ae,children:I}),nt=s(se);return t(b,P(x({disabled:V,readOnly:F,hasTextCursor:!0,size:X,"data-component":"multiselect","data-role":Z,"data-element":Y,isOpen:je},nt),{children:[t("div",{ref:me,children:[e(v,{"data-element":"accessibility-label",id:pe.current,children:Ke}),e(u,x({ref:Ze,accessibilityLabelId:pe.current,activeDescendantId:ce,"aria-controls":de.current,ariaLabel:C,ariaLabelledby:k,hasTextCursor:!0,isOpen:je,labelId:Ve,value:et().formattedValue},et()))]}),rt]}))}));export{k as MultiSelect,k as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useRef as r,useState as l,useMemo as o,useCallback as i,useEffect as a}from"react";import"../../../style/utils/filter-styled-system-padding-props.js";import c from"../../../style/utils/filter-styled-system-margin-props.js";import s from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../select.style.js";import d from"../__internal__/select-textbox/select-textbox.component.js";import p from"../__internal__/select-list/select-list.component.js";import m from"../../../__internal__/utils/helpers/guid/index.js";import b from"../__internal__/utils/get-next-child-by-text.js";import f from"../__internal__/utils/is-expected-option.js";import y from"../__internal__/utils/is-navigation-key.js";import O from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){g(e,t,n[t])}))}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const h=n.forwardRef(((g,h)=>{var{"aria-describedby":j,"aria-label":_,"aria-labelledby":P,value:x,id:S,label:k,name:C,disabled:D,readOnly:E,children:L,transparent:I,openOnFocus:T=!1,onOpen:V,onChange:B,onClick:H,onFocus:K,onKeyDown:F,onBlur:M,isLoading:q,listMaxHeight:A,onListScrollBottom:W,tableHeader:R,multiColumn:z,tooltipPosition:G,"data-element":J,"data-role":N,listPlacement:Q="bottom",flipEnabled:U=!0,enableVirtualScroll:X,virtualScrollOverscan:Y,required:Z,listWidth:$}=g,ee=function(e,t){if(null==e)return{};var n,r,l=function(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}(g,["aria-describedby","aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","transparent","openOnFocus","onOpen","onChange","onClick","onFocus","onKeyDown","onBlur","isLoading","listMaxHeight","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","data-element","data-role","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const te=r(m()),ne=r(null),re=r(null),le=r(void 0),oe=r(),ie=r(),ae=r(),ce=r(),[se,ue]=l(),[de,pe]=l(!1),[me,be]=l(""),[fe,ye]=l(""),[Oe,ge]=l(x),we=r(S||m()),{labelId:ve}=O({id:we.current,label:k}),he=r(void 0),je=o((()=>n.Children.toArray(L)),[L]),_e=i(((e,t=!1)=>({target:v(w({},C&&{name:C},S&&{id:S}),{value:e}),selectionConfirmed:t})),[C,S]),Pe=i((e=>{const t=je.findIndex((e=>n.isValidElement(e)&&f(e,Oe))),r=b(e,je,t);r&&B(_e(r.props.value))}),[je,_e,B,Oe]),xe=i((e=>{if(ie.current){const t=ce.current+e;ce.current=t,Pe(t),window.clearTimeout(le.current)}else ce.current=e,Pe(e);ie.current=!0,window.clearTimeout(le.current),le.current=window.setTimeout((()=>{ie.current=!1,ce.current=""}),500)}),[Pe]),Se=i((e=>{const{key:t}=e;null==F||F(e),E||(" "===t||y(t)?(e.preventDefault(),pe((e=>(e||null==V||V(),!0)))):1!==t.length||e.metaKey||e.ctrlKey||xe(t))}),[xe,F,V,E]),ke=i((e=>{const t=ne.current&&!ne.current.contains(e.target),n=re.current&&!re.current.contains(e.target);oe.current=!1,t&&n&&!ae.current&&pe(!1),ae.current=!1}),[]);function Ce(e){oe.current=!1,null==H||H(e),pe((e=>!e&&(null==V||V(),!0)))}a((()=>{ge(x)}),[x]),a((()=>{const e=je.find((e=>f(e,Oe)));let t="";e&&(t=e.props.text),ye(t)}),[Oe,je]),a((()=>{const e="click";return window.addEventListener(e,ke),function(){window.removeEventListener(e,ke)}}),[ke]),a((()=>function(){window.clearTimeout(le.current),window.clearTimeout(he.current)}),[]);const De=i((()=>{pe(!1)}),[]),Ee=i((e=>{e&&(ue(e),h&&("function"==typeof h?h(e):h.current=e))}),[h]);let Le;switch(Q){case"top":Le="top-end";break;case"bottom":Le="bottom-end";break;default:Le=Q}const Ie=e(p,{ref:re,id:te.current,labelId:ve,anchorElement:(null==se?void 0:se.parentElement)||void 0,onSelect:e=>{const{text:t,value:n,selectionType:r,id:l,selectionConfirmed:o}=e,i="click"===r;!function(e,t,n){null==B||B(_e(e,n))}(n,0,o),be(l),"navigationKey"!==r&&pe(!1),i&&(ae.current=!0,null==se||se.focus())},onMouseDown:function(){oe.current=!0},onSelectListClose:De,highlightedValue:Oe,listMaxHeight:A,isLoading:q,onListScrollBottom:W,tableHeader:R,multiColumn:z,listPlacement:void 0!==$?Le:Q,flipEnabled:U,isOpen:de,enableVirtualScroll:X,virtualScrollOverscan:Y,listWidth:$,children:L}),Te=c(ee);return t(u,v(w({transparent:I,disabled:D,readOnly:E,"data-component":"simple-select","data-role":N,"data-element":J,isOpen:de},Te),{children:[e("div",{ref:ne,children:e(d,v(w({ref:Ee,ariaLabel:_,"aria-controls":te.current,activeDescendantId:me,ariaLabelledby:P,"aria-describedby":j,isOpen:de,value:fe},v(w({id:we.current,name:C,disabled:D,readOnly:E,selectedValue:Oe,formattedValue:fe,onClick:Ce,iconOnClick:function(e){Ce(e)},label:k,labelId:ve,onMouseDown:function(){oe.current=!0},onFocus:function(e){ae.current||(null==K||K(e),oe.current?oe.current=!1:T&&(window.clearTimeout(he.current),he.current=window.setTimeout((()=>{pe((e=>(e||null==V||V(),!0)))}))))},onKeyDown:Se,onBlur:function(e){oe.current||null==M||M(e)},tooltipPosition:G,required:Z,transparent:I},s(ee)),{"data-component":void 0})),{onChange:()=>{}}))}),Ie]}))}));export{h as SimpleSelect,h as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import n,{useRef as r,useState as o,useMemo as l,useCallback as i,useEffect as a}from"react";import"../../../style/utils/filter-styled-system-padding-props.js";import c from"../../../style/utils/filter-styled-system-margin-props.js";import s from"../../../style/utils/filter-out-styled-system-spacing-props.js";import u from"../select.style.js";import d from"../__internal__/select-textbox/select-textbox.component.js";import p from"../__internal__/select-list/select-list.component.js";import m from"../../../__internal__/utils/helpers/guid/index.js";import b from"../__internal__/utils/get-next-child-by-text.js";import f from"../__internal__/utils/is-expected-option.js";import y from"../__internal__/utils/is-navigation-key.js";import O from"../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js";import v from"../../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js";function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){g(e,t,n[t])}))}return e}function _(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const h=n.forwardRef(((g,h)=>{var{"aria-describedby":j,"aria-label":P,"aria-labelledby":S,value:x,id:k,label:C,name:D,disabled:E,readOnly:L,children:I,transparent:T,openOnFocus:F=!1,onOpen:M,onChange:V,onClick:B,onFocus:H,onKeyDown:K,onBlur:A,isLoading:q,listMaxHeight:W,onListScrollBottom:R,tableHeader:z,multiColumn:G,tooltipPosition:J,"data-element":N,"data-role":Q,listPlacement:U="bottom",flipEnabled:X=!0,enableVirtualScroll:Y,virtualScrollOverscan:Z,required:$,listWidth:ee}=g,te=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(g,["aria-describedby","aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","transparent","openOnFocus","onOpen","onChange","onClick","onFocus","onKeyDown","onBlur","isLoading","listMaxHeight","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","data-element","data-role","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const ne=r(m()),re=r(null),oe=r(null),le=r(void 0),ie=r(),ae=r(),ce=r(),se=r(),[ue,de]=o(),[pe,me]=o(!1),[be,fe]=o(""),[ye,Oe]=o(""),[ve,ge]=o(x),we=r(k||m()),{labelId:_e}=O({id:we.current,label:C}),he=r(void 0),je=l((()=>n.Children.toArray(I)),[I]),Pe=i(((e,t=!1)=>({target:_(w({},D&&{name:D},k&&{id:k}),{value:e}),selectionConfirmed:t})),[D,k]),Se=i((e=>{const t=je.findIndex((e=>n.isValidElement(e)&&f(e,ve))),r=b(e,je,t);r&&V(Pe(r.props.value))}),[je,Pe,V,ve]),xe=i((e=>{if(ae.current){const t=se.current+e;se.current=t,Se(t),window.clearTimeout(le.current)}else se.current=e,Se(e);ae.current=!0,window.clearTimeout(le.current),le.current=window.setTimeout((()=>{ae.current=!1,se.current=""}),500)}),[Se]),ke=i((e=>{const{key:t}=e;null==K||K(e),L||(" "===t||y(t)?(e.preventDefault(),me((e=>(e||null==M||M(),!0)))):1!==t.length||e.metaKey||e.ctrlKey||xe(t))}),[xe,K,M,L]),Ce=i((e=>{const t=re.current&&!re.current.contains(e.target),n=oe.current&&!oe.current.contains(e.target);ie.current=!1,t&&n&&!ce.current&&me(!1),ce.current=!1}),[]);function De(e){ie.current=!1,null==B||B(e),me((e=>!e&&(null==M||M(),!0)))}a((()=>{ge(x)}),[x]),a((()=>{const e=je.find((e=>f(e,ve)));let t="";e&&(t=e.props.text),Oe(t)}),[ve,je]),a((()=>{const e="click";return window.addEventListener(e,Ce),function(){window.removeEventListener(e,Ce)}}),[Ce]),a((()=>function(){window.clearTimeout(le.current),window.clearTimeout(he.current)}),[]),v((()=>me(!1)));const Ee=i((()=>{me(!1)}),[]),Le=i((e=>{e&&(de(e),h&&("function"==typeof h?h(e):h.current=e))}),[h]);let Ie;switch(U){case"top":Ie="top-end";break;case"bottom":Ie="bottom-end";break;default:Ie=U}const Te=e(p,{ref:oe,id:ne.current,labelId:_e,anchorElement:(null==ue?void 0:ue.parentElement)||void 0,onSelect:e=>{const{text:t,value:n,selectionType:r,id:o,selectionConfirmed:l}=e,i="click"===r;!function(e,t,n){null==V||V(Pe(e,n))}(n,0,l),fe(o),"navigationKey"!==r&&me(!1),i&&(ce.current=!0,null==ue||ue.focus())},onMouseDown:function(){ie.current=!0},onSelectListClose:Ee,highlightedValue:ve,listMaxHeight:W,isLoading:q,onListScrollBottom:R,tableHeader:z,multiColumn:G,listPlacement:void 0!==ee?Ie:U,flipEnabled:X,isOpen:pe,enableVirtualScroll:Y,virtualScrollOverscan:Z,listWidth:ee,children:I}),Fe=c(te);return t(u,_(w({transparent:T,disabled:E,readOnly:L,"data-component":"simple-select","data-role":Q,"data-element":N,isOpen:pe},Fe),{children:[e("div",{ref:re,children:e(d,_(w({ref:Le,ariaLabel:P,"aria-controls":ne.current,activeDescendantId:be,ariaLabelledby:S,"aria-describedby":j,isOpen:pe,value:ye},_(w({id:we.current,name:D,disabled:E,readOnly:L,selectedValue:ve,formattedValue:ye,onClick:De,iconOnClick:function(e){De(e)},label:C,labelId:_e,onMouseDown:function(){ie.current=!0},onFocus:function(e){ce.current||(null==H||H(e),ie.current?ie.current=!1:F&&(window.clearTimeout(he.current),he.current=window.setTimeout((()=>{me((e=>(e||null==M||M(),!0)))}))))},onKeyDown:ke,onBlur:function(e){ie.current||null==A||A(e)},tooltipPosition:J,required:$,transparent:T},s(te)),{"data-component":void 0})),{onChange:()=>{}}))}),Te]}))}));export{h as SimpleSelect,h as default};
@@ -1 +1 @@
1
- import{jsxs as t,jsx as e}from"react/jsx-runtime";import o,{forwardRef as r,useContext as n,useRef as i,useImperativeHandle as l}from"react";import{ThemeContext as s}from"styled-components";import{offset as a,flip as c}from"@floating-ui/dom";import u from"../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js";import p from"../icon/icon.component.js";import m from"../button/button.component.js";import d from"./split-button.style.js";import b from"./split-button-toggle.style.js";import f from"./split-button-children.style.js";import y from"../../__internal__/utils/helpers/guid/index.js";import g from"../../__internal__/popover/popover.component.js";import"../../style/utils/filter-styled-system-padding-props.js";import h from"../../style/utils/filter-styled-system-margin-props.js";import j from"../../style/utils/filter-out-styled-system-spacing-props.js";import"../../style/themes/sage/index.js";import O from"../../style/themes/base/index.js";import"../../style/themes/none/index.js";import _ from"../../hooks/__internal__/useChildButtons/useChildButtons.js";import v from"./__internal__/split-button.context.js";import w from"../../hooks/__internal__/useLocale/useLocale.js";import P from"../flat-table/__internal__/flat-table.context.js";function x(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function k(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable})))),r.forEach((function(e){x(t,e,o[e])}))}return t}function T(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach((function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))})),t}const S=r(((r,x)=>{var{align:S="left",position:B="right",buttonType:C="secondary",children:D,disabled:L=!1,iconPosition:z="before",iconType:W,onClick:A,size:E="medium",subtext:I,text:F,"data-element":K,"data-role":M,"aria-label":N,isWhite:U=!1}=r,V=function(t,e){if(null==t)return{};var o,r,n=function(t,e){if(null==t)return{};var o,r,n={},i=Object.keys(t);for(r=0;r<i.length;r++)o=i[r],e.indexOf(o)>=0||(n[o]=t[o]);return n}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)o=i[r],e.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(n[o]=t[o])}return n}(r,["align","position","buttonType","children","disabled","iconPosition","iconType","onClick","size","subtext","text","data-element","data-role","aria-label","isWhite"]);const q=w(),G=n(s)||O,H=i(y()),J=i(y()),Q=i(null),R=i(null),{isInFlatTable:X}=n(P),Y="secondary"===C&&U;l(x,(()=>({focusMainButton(){var t;null===(t=Q.current)||void 0===t||t.focus()},focusToggleButton(){var t;null===(t=R.current)||void 0===t||t.focus()}})),[]);const{showAdditionalButtons:Z,showButtons:$,hideButtons:tt,buttonNode:et,handleToggleButtonKeyDown:ot,wrapperProps:rt,contextValue:nt}=_(R,.75),it=k({onFocus:tt,onTouchStart:tt,iconPosition:z,buttonType:C,disabled:L,iconType:W,onClick:t=>{var e;null===(e=Q.current)||void 0===e||e.focus(),A&&A(t)},size:E,subtext:I,isWhite:Y},j(V)),lt={isWhite:Y,disabled:L,displayed:Z,onTouchStart:$,onKeyDown:ot,onClick:()=>{var t;null===(t=R.current)||void 0===t||t.focus({preventScroll:!0}),Z?tt():$()},buttonType:C,size:E},st=u(tt),at=h(V);return t(d,T(k({onClick:st,ref:et},{"data-component":"split-button","data-element":K,"data-role":M},at),{children:[[e(m,T(k({"data-element":"main-button",id:H.current,ref:Q},it),{children:F}),"main-button"),e(b,T(k({"aria-expanded":Z,"aria-controls":J.current,"aria-label":N||q.splitButton.ariaLabel(),"data-element":"toggle-button",type:"button",ref:R},lt),{children:e(p,{type:"dropdown",color:{primary:G.colors.white,secondary:G.colors.primary}[C],bg:"transparent",disabled:L})}),"toggle-button")],Z?e(g,{disableBackgroundUI:X,disablePortal:!0,placement:"left"===B?"bottom-start":"bottom-end",popoverStrategy:"fixed",reference:et,middleware:[a(6),c({fallbackStrategy:"initialPlacement"})],children:e(f,T(k({id:J.current},rt),{align:S,children:e(v.Provider,{value:nt,children:o.Children.map(D,(t=>e("li",{children:t})))})}))}):null]}))}));export{S as SplitButton,S as default};
1
+ import{jsxs as t,jsx as e}from"react/jsx-runtime";import o,{forwardRef as r,useContext as n,useRef as i,useImperativeHandle as l}from"react";import{ThemeContext as s}from"styled-components";import{offset as a,flip as c}from"@floating-ui/dom";import u from"../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js";import p from"../icon/icon.component.js";import d from"../button/button.component.js";import m from"./split-button.style.js";import b from"./split-button-toggle.style.js";import f from"./split-button-children.style.js";import y from"../../__internal__/utils/helpers/guid/index.js";import h from"../../__internal__/popover/popover.component.js";import"../../style/utils/filter-styled-system-padding-props.js";import g from"../../style/utils/filter-styled-system-margin-props.js";import j from"../../style/utils/filter-out-styled-system-spacing-props.js";import"../../style/themes/sage/index.js";import _ from"../../style/themes/base/index.js";import"../../style/themes/none/index.js";import O from"../../hooks/__internal__/useChildButtons/useChildButtons.js";import v from"../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js";import w from"./__internal__/split-button.context.js";import P from"../../hooks/__internal__/useLocale/useLocale.js";import x from"../flat-table/__internal__/flat-table.context.js";function k(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function S(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(t){return Object.getOwnPropertyDescriptor(o,t).enumerable})))),r.forEach((function(e){k(t,e,o[e])}))}return t}function T(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e.push.apply(e,o)}return e}(Object(e)).forEach((function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(e,o))})),t}const B=r(((r,k)=>{var{align:B="left",position:C="right",buttonType:D="secondary",children:A,disabled:L=!1,iconPosition:z="before",iconType:F,onClick:W,size:E="medium",subtext:I,text:M,"data-element":K,"data-role":N,"aria-label":U,isWhite:V=!1}=r,q=function(t,e){if(null==t)return{};var o,r,n=function(t,e){if(null==t)return{};var o,r,n={},i=Object.keys(t);for(r=0;r<i.length;r++)o=i[r],e.indexOf(o)>=0||(n[o]=t[o]);return n}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)o=i[r],e.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(t,o)&&(n[o]=t[o])}return n}(r,["align","position","buttonType","children","disabled","iconPosition","iconType","onClick","size","subtext","text","data-element","data-role","aria-label","isWhite"]);const G=P(),H=n(s)||_,J=i(y()),Q=i(y()),R=i(null),X=i(null),{isInFlatTable:Y}=n(x),Z="secondary"===D&&V;l(k,(()=>({focusMainButton(){var t;null===(t=R.current)||void 0===t||t.focus()},focusToggleButton(){var t;null===(t=X.current)||void 0===t||t.focus()}})),[]);const{showAdditionalButtons:$,showButtons:tt,hideButtons:et,buttonNode:ot,handleToggleButtonKeyDown:rt,wrapperProps:nt,contextValue:it}=O(X,.75),lt=S({onFocus:et,onTouchStart:et,iconPosition:z,buttonType:D,disabled:L,iconType:F,onClick:t=>{var e;null===(e=R.current)||void 0===e||e.focus(),W&&W(t)},size:E,subtext:I,isWhite:Z},j(q));v((()=>et()));const st={isWhite:Z,disabled:L,displayed:$,onTouchStart:tt,onKeyDown:rt,onClick:()=>{var t;null===(t=X.current)||void 0===t||t.focus({preventScroll:!0}),$?et():tt()},buttonType:D,size:E},at=u(et),ct=g(q);return t(m,T(S({onClick:at,ref:ot},{"data-component":"split-button","data-element":K,"data-role":N},ct),{children:[[e(d,T(S({"data-element":"main-button",id:J.current,ref:R},lt),{children:M}),"main-button"),e(b,T(S({"aria-expanded":$,"aria-controls":Q.current,"aria-label":U||G.splitButton.ariaLabel(),"data-element":"toggle-button",type:"button",ref:X},st),{children:e(p,{type:"dropdown",color:{primary:H.colors.white,secondary:H.colors.primary}[D],bg:"transparent",disabled:L})}),"toggle-button")],$?e(h,{disableBackgroundUI:Y,disablePortal:!0,placement:"left"===C?"bottom-start":"bottom-end",popoverStrategy:"fixed",reference:ot,middleware:[a(6),c({fallbackStrategy:"initialPlacement"})],children:e(f,T(S({id:Q.current},nt),{align:B,children:e(w.Provider,{value:it,children:o.Children.map(A,(t=>e("li",{children:t})))})}))}):null]}))}));export{B as SplitButton,B as default};
@@ -0,0 +1 @@
1
+ export { default } from "./useAdaptiveSidebarModalFocus";
@@ -0,0 +1 @@
1
+ export{default}from"./useAdaptiveSidebarModalFocus.js";
@@ -0,0 +1,2 @@
1
+ declare const useAdaptiveSidebarModalFocus: (closeFunction: () => void) => void;
2
+ export default useAdaptiveSidebarModalFocus;
@@ -0,0 +1 @@
1
+ import{useEffect as e}from"react";const t=t=>{e((()=>{const e=()=>t();return document.addEventListener("adaptiveSidebarModalFocusIn",e),()=>{document.removeEventListener("adaptiveSidebarModalFocusIn",e)}}),[t])};export{t as default};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("invariant"),n=require("../../__internal__/utils/helpers/tags/tags.js"),o=require("./action-popover.style.js"),a=require("../../__internal__/utils/helpers/events/events.js"),i=require("../../__internal__/popover/popover.component.js"),l=require("../../__internal__/utils/helpers/guid/index.js"),u=require("../../hooks/__internal__/useLocale/useLocale.js"),s=require("./action-popover-menu/action-popover-menu.component.js"),c=require("./action-popover-item/action-popover-item.component.js");require("./action-popover-divider/action-popover-divider.component.js");var p=require("./__internal__/action-popover.context.js"),d=require("../../hooks/__internal__/useModalManager/useModalManager.js"),b=require("./__internal__/action-popover.utils.js"),f=require("../flat-table/__internal__/flat-table.context.js");function v(e){return e&&e.__esModule?e:{default:e}}var m=v(t),y=v(r);function _(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const j=()=>{},O=()=>{},g=t.forwardRef(((r,v)=>{var{children:g,id:P,onOpen:h=j,onClose:x=O,rightAlignMenu:I,renderButton:q,placement:S="bottom",horizontalAlignment:M="left",submenuPosition:w="left","aria-label":A,"aria-labelledby":k,"aria-describedby":D}=r,C=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(r,["children","id","onOpen","onClose","rightAlignMenu","renderButton","placement","horizontalAlignment","submenuPosition","aria-label","aria-labelledby","aria-describedby"]);const B=u.default(),[E,L]=t.useState(!1),[F,K]=t.useState(0),[R]=t.useState(l.default()),$=t.useRef(null),z=t.useRef(null),{isInFlatTable:N}=t.useContext(f.default),[U,H]=t.useState(null),T=t.useMemo((()=>!m.default.Children.toArray(g).find((e=>!m.default.isValidElement(e)||e.type!==c.ActionPopoverItem&&e.type!==o.MenuItemDivider))),[g]),V=t.useMemo((()=>b.getItems(g)),[g]),G=b.findFirstFocusableItem(V),J=b.findLastFocusableItem(V);y.default(T,`ActionPopover only accepts children of type \`${c.ActionPopoverItem.displayName}\` and \`${o.MenuItemDivider.displayName}\`.`);const Q=t.useMemo((()=>"top"!==S||I?"top"===S&&I?"top-start":"bottom"===S&&I?"bottom-start":"bottom-end":"top-end"),[S,I]),W=t.useCallback((e=>{e&&!E&&h(),!e&&E&&x(),L(e)}),[E,h,x]),X=t.useCallback((()=>{var e;const t=null===(e=$.current)||void 0===e?void 0:e.querySelector("[data-element='action-popover-button']");null==t||t.focus()}),[]);t.useImperativeHandle(v,(()=>({focusButton(){X()}})),[X]);const Y=t.useCallback((e=>{e.stopPropagation();const t=!E;K(G),W(t),t||X()}),[E,G,W,X]),Z=t.useCallback((e=>{a.default.isSpaceKey(e)||a.default.isDownKey(e)||a.default.isEnterKey(e)?(e.preventDefault(),e.stopPropagation(),K(G),W(!0)):a.default.isUpKey(e)&&(e.preventDefault(),e.stopPropagation(),K(J),W(!0))}),[G,J,W]),ee=t.useCallback((e=>{a.default.isEscKey(e)&&(W(!1),X())}),[W,X]);d.default({open:E,closeModal:ee,modalRef:$}),t.useEffect((()=>{const e=({target:e})=>{var t,r;const n=null==z||null===(t=z.current)||void 0===t?void 0:t.contains(e),o=null==$||null===(r=$.current)||void 0===r?void 0:r.contains(e);n||o||W(!1)},t="click";return document.addEventListener(t,e,{capture:!0}),function(){document.removeEventListener(t,e,{capture:!0})}}),[W]);const te=P||`ActionPopoverButton_${R}`,re=`ActionPopoverMenu_${R}`;return e.jsxs(o.MenuButton,(ne=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){_(e,t,r[t])}))}return e}({id:te,onKeyDown:Z,onClick:Y,isOpen:E,ref:$},C,n.default("action-popover-wrapper",C)),oe=null!=(oe={children:[(t=>{if(q){const e=q({tabIndex:E?-1:0,"data-element":"action-popover-button",ariaAttributes:{"aria-haspopup":"true","aria-label":A||B.actionPopover.ariaLabel(),"aria-labelledby":k,"aria-describedby":D,"aria-controls":t,"aria-expanded":`${E}`}}),r=b.checkChildrenForString(e);return q({tabIndex:E?-1:0,"data-element":"action-popover-button",ariaAttributes:{"aria-haspopup":"true","aria-label":r?void 0:A||B.actionPopover.ariaLabel(),"aria-labelledby":k,"aria-describedby":D,"aria-controls":t,"aria-expanded":`${E}`}})}return e.jsx(o.StyledButtonIcon,{role:"button","aria-haspopup":"true","aria-label":A||B.actionPopover.ariaLabel(),"aria-labelledby":k,"aria-describedby":D,"aria-controls":t,"aria-expanded":E,tabIndex:E?-1:0,"data-element":"action-popover-button",children:e.jsx(o.ButtonIcon,{type:"ellipsis_vertical"})})})(re),e.jsx(p.ActionPopoverProvider,{value:{setOpenPopover:W,focusButton:X,submenuPosition:w,horizontalAlignment:M,selectedSubmenuRef:U,setSelectedSubmenuRef:H},children:E&&e.jsx(i.default,{placement:Q,reference:$,disableBackgroundUI:N,children:e.jsx(s.default,{"data-component":"action-popover",ref:z,parentID:te,menuID:re,focusIndex:F,setFocusIndex:K,isOpen:E,setOpen:W,placement:S,children:g})})})]})?oe:{},Object.getOwnPropertyDescriptors?Object.defineProperties(ne,Object.getOwnPropertyDescriptors(oe)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(oe)).forEach((function(e){Object.defineProperty(ne,e,Object.getOwnPropertyDescriptor(oe,e))})),ne));var ne,oe}));exports.ActionPopover=g,exports.default=g;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("invariant"),n=require("../../__internal__/utils/helpers/tags/tags.js"),o=require("./action-popover.style.js"),a=require("../../__internal__/utils/helpers/events/events.js"),i=require("../../__internal__/popover/popover.component.js"),l=require("../../__internal__/utils/helpers/guid/index.js"),u=require("../../hooks/__internal__/useLocale/useLocale.js"),s=require("./action-popover-menu/action-popover-menu.component.js"),c=require("./action-popover-item/action-popover-item.component.js");require("./action-popover-divider/action-popover-divider.component.js");var p=require("./__internal__/action-popover.context.js"),d=require("../../hooks/__internal__/useModalManager/useModalManager.js"),b=require("../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js"),f=require("./__internal__/action-popover.utils.js"),v=require("../flat-table/__internal__/flat-table.context.js");function m(e){return e&&e.__esModule?e:{default:e}}var y=m(t),_=m(r);function j(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const O=()=>{},g=()=>{},P=t.forwardRef(((r,m)=>{var{children:P,id:h,onOpen:x=O,onClose:I=g,rightAlignMenu:S,renderButton:q,placement:M="bottom",horizontalAlignment:A="left",submenuPosition:k="left","aria-label":w,"aria-labelledby":D,"aria-describedby":C}=r,B=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(r,["children","id","onOpen","onClose","rightAlignMenu","renderButton","placement","horizontalAlignment","submenuPosition","aria-label","aria-labelledby","aria-describedby"]);const E=u.default(),[F,L]=t.useState(!1),[K,R]=t.useState(0),[$]=t.useState(l.default()),z=t.useRef(null),N=t.useRef(null),{isInFlatTable:U}=t.useContext(v.default),[H,T]=t.useState(null),V=t.useMemo((()=>!y.default.Children.toArray(P).find((e=>!y.default.isValidElement(e)||e.type!==c.ActionPopoverItem&&e.type!==o.MenuItemDivider))),[P]),G=t.useMemo((()=>f.getItems(P)),[P]),J=f.findFirstFocusableItem(G),Q=f.findLastFocusableItem(G);_.default(V,`ActionPopover only accepts children of type \`${c.ActionPopoverItem.displayName}\` and \`${o.MenuItemDivider.displayName}\`.`);const W=t.useMemo((()=>"top"!==M||S?"top"===M&&S?"top-start":"bottom"===M&&S?"bottom-start":"bottom-end":"top-end"),[M,S]),X=t.useCallback((e=>{e&&!F&&x(),!e&&F&&I(),L(e)}),[F,x,I]),Y=t.useCallback((()=>{var e;const t=null===(e=z.current)||void 0===e?void 0:e.querySelector("[data-element='action-popover-button']");null==t||t.focus()}),[]);t.useImperativeHandle(m,(()=>({focusButton(){Y()}})),[Y]);const Z=t.useCallback((e=>{e.stopPropagation();const t=!F;R(J),X(t),t||Y()}),[F,J,X,Y]),ee=t.useCallback((e=>{a.default.isSpaceKey(e)||a.default.isDownKey(e)||a.default.isEnterKey(e)?(e.preventDefault(),e.stopPropagation(),R(J),X(!0)):a.default.isUpKey(e)&&(e.preventDefault(),e.stopPropagation(),R(Q),X(!0))}),[J,Q,X]),te=t.useCallback((e=>{a.default.isEscKey(e)&&(X(!1),Y())}),[X,Y]);d.default({open:F,closeModal:te,modalRef:z}),t.useEffect((()=>{const e=({target:e})=>{var t,r;const n=null==N||null===(t=N.current)||void 0===t?void 0:t.contains(e),o=null==z||null===(r=z.current)||void 0===r?void 0:r.contains(e);n||o||X(!1)},t="click";return document.addEventListener(t,e,{capture:!0}),function(){document.removeEventListener(t,e,{capture:!0})}}),[X]),b.default((()=>L(!1)));const re=h||`ActionPopoverButton_${$}`,ne=`ActionPopoverMenu_${$}`;return e.jsxs(o.MenuButton,(oe=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){j(e,t,r[t])}))}return e}({id:re,onKeyDown:ee,onClick:Z,isOpen:F,ref:z},B,n.default("action-popover-wrapper",B)),ae=null!=(ae={children:[(t=>{if(q){const e=q({tabIndex:F?-1:0,"data-element":"action-popover-button",ariaAttributes:{"aria-haspopup":"true","aria-label":w||E.actionPopover.ariaLabel(),"aria-labelledby":D,"aria-describedby":C,"aria-controls":t,"aria-expanded":`${F}`}}),r=f.checkChildrenForString(e);return q({tabIndex:F?-1:0,"data-element":"action-popover-button",ariaAttributes:{"aria-haspopup":"true","aria-label":r?void 0:w||E.actionPopover.ariaLabel(),"aria-labelledby":D,"aria-describedby":C,"aria-controls":t,"aria-expanded":`${F}`}})}return e.jsx(o.StyledButtonIcon,{role:"button","aria-haspopup":"true","aria-label":w||E.actionPopover.ariaLabel(),"aria-labelledby":D,"aria-describedby":C,"aria-controls":t,"aria-expanded":F,tabIndex:F?-1:0,"data-element":"action-popover-button",children:e.jsx(o.ButtonIcon,{type:"ellipsis_vertical"})})})(ne),e.jsx(p.ActionPopoverProvider,{value:{setOpenPopover:X,focusButton:Y,submenuPosition:k,horizontalAlignment:A,selectedSubmenuRef:H,setSelectedSubmenuRef:T},children:F&&e.jsx(i.default,{placement:W,reference:z,disableBackgroundUI:U,children:e.jsx(s.default,{"data-component":"action-popover",ref:N,parentID:re,menuID:ne,focusIndex:K,setFocusIndex:R,isOpen:F,setOpen:X,placement:M,children:P})})})]})?ae:{},Object.getOwnPropertyDescriptors?Object.defineProperties(oe,Object.getOwnPropertyDescriptors(ae)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(ae)).forEach((function(e){Object.defineProperty(oe,e,Object.getOwnPropertyDescriptor(ae,e))})),oe));var oe,ae}));exports.ActionPopover=P,exports.default=P;
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { PaddingProps, MarginProps } from "styled-system";
3
3
  import { TagProps } from "../../__internal__/utils/helpers/tags";
4
- export interface AdaptiveSidebarProps extends MarginProps, PaddingProps, Omit<TagProps, "data-component"> {
4
+ import { SidebarProps } from "../sidebar";
5
+ export interface AdaptiveSidebarProps extends MarginProps, PaddingProps, Omit<TagProps, "data-component">, Pick<SidebarProps, "restoreFocusOnClose"> {
5
6
  /** The breakpoint (in pixels) at which the sidebar will convert to a dialog-based sidebar */
6
7
  adaptiveBreakpoint?: number;
7
8
  /** The time in milliseconds for the sidebar to animate */
@@ -23,5 +24,5 @@ export interface AdaptiveSidebarProps extends MarginProps, PaddingProps, Omit<Ta
23
24
  /** The width of the sidebar */
24
25
  width?: string;
25
26
  }
26
- export declare const AdaptiveSidebar: ({ adaptiveBreakpoint, backgroundColor, borderColor, children, height, hidden, open, renderAsModal, width, ...props }: AdaptiveSidebarProps) => React.JSX.Element | null;
27
+ export declare const AdaptiveSidebar: ({ adaptiveBreakpoint, backgroundColor, borderColor, children, height, hidden, open, renderAsModal, width, restoreFocusOnClose, ...props }: AdaptiveSidebarProps) => React.JSX.Element | null;
27
28
  export default AdaptiveSidebar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("./__internal__/utils.js"),o=require("../box/box.component.js"),n=require("../../style/utils/filter-styled-system-padding-props.js"),i=require("../../style/utils/filter-styled-system-margin-props.js"),a=require("../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js"),l=require("./adaptive-sidebar.style.js");function d(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function s(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){d(e,r,t[r])}))}return e}function c(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}const u=d=>{var{adaptiveBreakpoint:u=768,backgroundColor:p="white",borderColor:b="none",children:f,height:y="100%",hidden:O=!1,open:j,renderAsModal:h=!1,width:v="320px"}=d,g=function(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)t=i[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(d,["adaptiveBreakpoint","backgroundColor","borderColor","children","height","hidden","open","renderAsModal","width"]);const m=a.default(u),w=r.useRef(null),x=Object.entries(t.getColors(p)).reduce(((e,[r,o])=>(e[t.kebabToCamelCase(r)]=o,e)),{});return r.useEffect((()=>{w.current&&w.current.focus()}),[j]),r.useEffect((()=>{O&&j&&document.querySelectorAll("[inert]").forEach((e=>{e.removeAttribute("inert")}))}),[O,j]),h||!m?e.jsx(l.StyledSidebar,{backgroundColor:p,className:"adaptive-sidebar-modal-view","data-role":"adaptive-sidebar-modal-view",enableBackgroundUI:j&&O,hidden:O,open:j,p:0,ref:w,children:e.jsx(o.Box,c(s({"data-role":"adaptive-sidebar-content-wrapper",height:"100%"},x),{children:f}))}):j?e.jsx(l.StyledAdaptiveSidebar,c(s({backgroundColor:p,borderColor:"none"===b?void 0:b,"data-element":"adaptive-sidebar","data-role":"adaptive-sidebar",height:y,hidden:O,ref:w,role:"region",tabIndex:-1,width:v},i.default(g),n.default(g)),{children:e.jsx(o.Box,{"data-role":"adaptive-sidebar-content-wrapper",children:f})})):null};exports.AdaptiveSidebar=u,exports.default=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("./__internal__/utils.js"),o=require("../box/box.component.js"),n=require("../../style/utils/filter-styled-system-padding-props.js"),i=require("../../style/utils/filter-styled-system-margin-props.js"),a=require("../../hooks/__internal__/useIsAboveBreakpoint/useIsAboveBreakpoint.js"),s=require("./adaptive-sidebar.style.js");function l(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function d(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){l(e,r,t[r])}))}return e}function c(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}const u=l=>{var{adaptiveBreakpoint:u=768,backgroundColor:b="white",borderColor:p="none",children:f,height:y="100%",hidden:O=!1,open:v,renderAsModal:h=!1,width:j="320px",restoreFocusOnClose:g=!1}=l,m=function(e,r){if(null==e)return{};var t,o,n=function(e,r){if(null==e)return{};var t,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)t=i[o],r.indexOf(t)>=0||(n[t]=e[t]);return n}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)t=i[o],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t])}return n}(l,["adaptiveBreakpoint","backgroundColor","borderColor","children","height","hidden","open","renderAsModal","width","restoreFocusOnClose"]);const w=a.default(u),x=h||!w,k=r.useRef(null),C=Object.entries(t.getColors(b)).reduce(((e,[r,o])=>(e[t.kebabToCamelCase(r)]=o,e)),{});return r.useEffect((()=>{k.current&&k.current.focus()}),[v]),r.useEffect((()=>{O&&v&&document.querySelectorAll("[inert]").forEach((e=>{e.removeAttribute("inert")}))}),[O,v]),r.useEffect((()=>{x&&document.dispatchEvent(new CustomEvent("adaptiveSidebarModalFocusIn",{bubbles:!0,detail:{source:"adaptiveSidebarModal"}}))}),[x]),x?e.jsx(s.StyledSidebar,{backgroundColor:b,className:"adaptive-sidebar-modal-view","data-role":"adaptive-sidebar-modal-view",enableBackgroundUI:v&&O,hidden:O,restoreFocusOnClose:g,open:v,p:0,ref:k,children:e.jsx(o.Box,c(d({"data-role":"adaptive-sidebar-content-wrapper",height:"100%"},C),{children:f}))}):v?e.jsx(s.StyledAdaptiveSidebar,c(d({backgroundColor:b,borderColor:"none"===p?void 0:p,"data-element":"adaptive-sidebar","data-role":"adaptive-sidebar",height:y,hidden:O,ref:k,role:"region",tabIndex:-1,width:j},i.default(m),n.default(m)),{children:e.jsx(o.Box,{"data-role":"adaptive-sidebar-content-wrapper",children:f})})):null};exports.AdaptiveSidebar=u,exports.default=u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@floating-ui/dom"),n=require("../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js"),o=require("../split-button/__internal__/split-button.context.js"),l=require("./multi-action-button.style.js"),i=require("../button/button.component.js"),u=require("../../__internal__/popover/popover.component.js");require("../../style/utils/filter-styled-system-padding-props.js");var a=require("../../style/utils/filter-styled-system-margin-props.js"),s=require("../../style/utils/filter-out-styled-system-spacing-props.js"),c=require("../../hooks/__internal__/useChildButtons/useChildButtons.js"),d=require("../flat-table/__internal__/flat-table.context.js"),p=require("../../__internal__/utils/helpers/guid/index.js");function f(e){return e&&e.__esModule?e:{default:e}}var b=f(t);function y(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){y(e,t,r[t])}))}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const m=t.forwardRef(((f,y)=>{var{align:m="left",position:O="left",disabled:h,buttonType:_,size:w,children:x,text:v,subtext:P,width:q,onClick:k,"data-element":S,"data-role":B}=f,C=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},l=Object.keys(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(f,["align","position","disabled","buttonType","size","children","text","subtext","width","onClick","data-element","data-role"]);const T=t.useRef(null),{isInFlatTable:D}=t.useContext(d.default),A=t.useRef(p.default());t.useImperativeHandle(y,(()=>({focusMainButton(){var e;null===(e=T.current)||void 0===e||e.focus({preventScroll:!0})}})),[]);const{showAdditionalButtons:M,showButtons:I,hideButtons:z,buttonNode:E,handleToggleButtonKeyDown:R,wrapperProps:K,contextValue:L}=c.default(T),F=n.default(z),H=j({disabled:h,displayed:M,onTouchStart:I,onKeyDown:R,onClick:e=>{M?z():I(),F(),k&&k(e)},buttonType:_,size:w,subtext:P},s.default(C)),N=a.default(C);return e.jsxs(l.StyledMultiActionButton,g(j({ref:E,"data-component":"multi-action-button","data-element":S,"data-role":B,displayed:M,width:q},N),{children:[e.jsx(i.default,g(j({"aria-expanded":M,"aria-controls":A.current,"data-element":"toggle-button"},H),{ref:T,iconPosition:"after",iconType:"dropdown",children:v}),"toggle-button"),M&&e.jsx(u.default,{disableBackgroundUI:D,disablePortal:!0,placement:"left"===O?"bottom-start":"bottom-end",reference:E,popoverStrategy:"fixed",middleware:[r.offset(6),r.flip({fallbackStrategy:"initialPlacement"})],children:e.jsx(l.StyledButtonChildrenContainer,g(j({id:A.current},K),{align:m,children:e.jsx(o.default.Provider,{value:L,children:b.default.Children.map(x,(t=>e.jsx("li",{children:t})))})}))})]}))}));exports.MultiActionButton=m,exports.default=m;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@floating-ui/dom"),n=require("../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js"),o=require("../split-button/__internal__/split-button.context.js"),i=require("./multi-action-button.style.js"),l=require("../button/button.component.js"),u=require("../../__internal__/popover/popover.component.js");require("../../style/utils/filter-styled-system-padding-props.js");var a=require("../../style/utils/filter-styled-system-margin-props.js"),s=require("../../style/utils/filter-out-styled-system-spacing-props.js"),d=require("../../hooks/__internal__/useChildButtons/useChildButtons.js"),c=require("../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js"),p=require("../flat-table/__internal__/flat-table.context.js"),f=require("../../__internal__/utils/helpers/guid/index.js");function b(e){return e&&e.__esModule?e:{default:e}}var y=b(t);function j(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){j(e,t,r[t])}))}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const m=t.forwardRef(((b,j)=>{var{align:m="left",position:O="left",disabled:h,buttonType:v,size:w,children:x,text:P,subtext:q,width:S,onClick:k,"data-element":B,"data-role":C}=b,A=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(b,["align","position","disabled","buttonType","size","children","text","subtext","width","onClick","data-element","data-role"]);const M=t.useRef(null),{isInFlatTable:T}=t.useContext(p.default),D=t.useRef(f.default());t.useImperativeHandle(j,(()=>({focusMainButton(){var e;null===(e=M.current)||void 0===e||e.focus({preventScroll:!0})}})),[]);const{showAdditionalButtons:I,showButtons:z,hideButtons:E,buttonNode:F,handleToggleButtonKeyDown:R,wrapperProps:K,contextValue:L}=d.default(M),H=n.default(E);c.default((()=>E()));const N=_({disabled:h,displayed:I,onTouchStart:z,onKeyDown:R,onClick:e=>{I?E():z(),H(),k&&k(e)},buttonType:v,size:w,subtext:q},s.default(A)),U=a.default(A);return e.jsxs(i.StyledMultiActionButton,g(_({ref:F,"data-component":"multi-action-button","data-element":B,"data-role":C,displayed:I,width:S},U),{children:[e.jsx(l.default,g(_({"aria-expanded":I,"aria-controls":D.current,"data-element":"toggle-button"},N),{ref:M,iconPosition:"after",iconType:"dropdown",children:P}),"toggle-button"),I&&e.jsx(u.default,{disableBackgroundUI:T,disablePortal:!0,placement:"left"===O?"bottom-start":"bottom-end",reference:F,popoverStrategy:"fixed",middleware:[r.offset(6),r.flip({fallbackStrategy:"initialPlacement"})],children:e.jsx(i.StyledButtonChildrenContainer,g(_({id:D.current},K),{align:m,children:e.jsx(o.default.Provider,{value:L,children:y.default.Children.map(x,(t=>e.jsx("li",{children:t})))})}))})]}))}));exports.MultiActionButton=m,exports.default=m;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("invariant");require("../../../style/utils/filter-styled-system-padding-props.js");var r=require("../../../style/utils/filter-styled-system-margin-props.js"),l=require("../../../style/utils/filter-out-styled-system-spacing-props.js"),o=require("../__internal__/select-textbox/select-textbox.component.js"),i=require("../../../__internal__/utils/helpers/guid/index.js"),a=require("../__internal__/utils/with-filter.hoc.js"),s=require("../select.style.js"),u=require("../__internal__/select-list/select-list.component.js"),c=require("../__internal__/utils/is-expected-option.js"),d=require("../__internal__/utils/are-objects-equal.js"),f=require("../__internal__/utils/is-navigation-key.js"),p=require("../../../hooks/__internal__/useStableCallback/useStableCallback.js"),b=require("../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js");function v(e){return e&&e.__esModule?e:{default:e}}var y=v(t),m=v(n);function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){g(e,t,n[t])}))}return e}function O(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const C=a.default(u.default),j=y.default.forwardRef(((n,a)=>{var{"aria-label":v,"aria-labelledby":g,value:j,id:_,name:w,label:S,children:x,onOpen:k,onChange:L,onFilterChange:q,onClick:E,onKeyDown:P,onFocus:R,onBlur:D,openOnFocus:A,noResultsMessage:B,listActionButton:F,listMaxHeight:M,onListAction:T,isLoading:I,disabled:V,readOnly:H,onListScrollBottom:W,tableHeader:K,multiColumn:z,"data-element":G,"data-role":J,tooltipPosition:N,listPlacement:Q="bottom",flipEnabled:U=!0,enableVirtualScroll:X,virtualScrollOverscan:Y,disableDefaultFiltering:Z=!1,required:$,listWidth:ee}=n,te=function(e,t){if(null==e)return{};var n,r,l=function(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}(n,["aria-label","aria-labelledby","value","id","name","label","children","onOpen","onChange","onFilterChange","onClick","onKeyDown","onFocus","onBlur","openOnFocus","noResultsMessage","listActionButton","listMaxHeight","onListAction","isLoading","disabled","readOnly","onListScrollBottom","tableHeader","multiColumn","data-element","data-role","tooltipPosition","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","disableDefaultFiltering","required","listWidth"]);const[ne,re]=t.useState(""),le=t.useRef(i.default()),oe=t.useRef(null),ie=t.useRef(null),ae=t.useRef(!1),se=t.useRef(!1),ue=t.useRef(!1),[ce,de]=t.useState(),[fe,pe]=t.useState(!1),[be,ve]=t.useState(""),[ye,me]=t.useState(j||""),ge=t.useRef(j),[he,Oe]=t.useState(""),[Ce,je]=t.useState(""),_e=t.useRef(_||i.default()),{labelId:we}=b.default({id:_e.current,label:S}),Se=t.useRef(null),xe=t.useRef(!1),ke=t.useCallback(((e,t)=>({target:O(h({},w&&{name:w},_&&{id:_}),{value:e}),selectionConfirmed:t})),[w,_]),Le=t.useCallback(((e,t)=>{L&&L(ke(e,t))}),[L,ke]),qe=t.useCallback(((e,t)=>{me((()=>{var n;const r=e.trimStart(),l=(o=r,i=x,y.default.Children.toArray(i).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==o?void 0:o.toLowerCase()))})));var o,i;const a=t&&!e.length;return!l||a||l.props.disabled?(ve(e),Le("",!1),""):(r.length&&Le(l.props.value,!1),t?(ve(e),l.props.value):(r.length&&(null===(n=l.props.text)||void 0===n?void 0:n.toLowerCase().startsWith(r.toLowerCase()))?ve(l.props.text):ve(e),Oe(l.props.value),l.props.value))}))}),[x,Le]),Ee=t.useCallback(((e,t=!1)=>{var n;const r=y.default.Children.toArray(x).find((t=>y.default.isValidElement(t)&&c.default(t,e)));r&&void 0!==r.props.text?(t||(null===(n=r.props.text)||void 0===n?void 0:n.toLowerCase().startsWith(null==Ce?void 0:Ce.toLowerCase().trim())))&&ve(r.props.text):ve(Ce||"")}),[x,Ce]),Pe=t.useCallback((e=>{const t=e.target.value,{inputType:n}=e.nativeEvent;qe(t,"deleteContentBackward"===n||"deleteContentForward"===n||"delete"===n),je(t),pe(!0)}),[qe]),Re=t.useCallback((e=>{je((t=>(null==t?void 0:t.length)===(null==be?void 0:be.length)-1&&e===be.slice(-1)?be:t))}),[be]),De=t.useCallback((e=>{const{key:t}=e;P&&P(e),H||(!e.defaultPrevented&&f.default(t)&&(e.preventDefault(),pe(!0)),Re(t))}),[Re,P,H]),Ae=t.useCallback((e=>{const t=oe.current&&!oe.current.contains(e.target),n=ie.current&&!ie.current.contains(e.target);ae.current=!1,t&&n&&(Ee(j,!0),pe(!1))}),[Ee,j]);t.useEffect((()=>{me((e=>(j&&e!==j&&Ee(j),j))),Oe(j)}),[j,L,x]);const Be=p.useStableCallback(k);t.useEffect((()=>{fe?Be&&Be():je("")}),[Be,fe]),t.useEffect((()=>{const e=void 0!==F;m.default(!e||e&&T,"onListAction prop required when using listActionButton prop")}),[F,T]);const Fe=t.useRef(!0);t.useEffect((()=>{Fe.current&&Ee(ye),"object"==typeof j&&"object"==typeof ge.current?d.default(j,ge.current)||(Ee(j),ge.current=j):Ee(j)}),[j,x]);const Me=p.useStableCallback(q);t.useEffect((()=>{Me&&!Fe.current&&Me(Ce)}),[Me,Ce]),t.useEffect((()=>{Fe.current=!1}),[]),t.useEffect((()=>{const e="click";return window.addEventListener(e,Ae),function(){window.removeEventListener(e,Ae)}}),[Ae]),t.useEffect((()=>{const e=null==Ce?void 0:Ce.trimStart(),t=null==be?void 0:be.toLowerCase().startsWith(e.toLowerCase());!V&&!H&&ce&&e.length&&(null==be?void 0:be.length)>e.length&&t&&(ce.selectionStart=e.length)}),[be,Ce,ce,V,H]);const Te=t.useCallback((e=>{const{id:t,text:n,value:r,selectionType:l,selectionConfirmed:o}=e;ve(n),Le(r,!!o),re(t),"navigationKey"!==l&&(xe.current=!!A,pe(!1),null==ce||ce.focus(),null==ce||ce.select(),xe.current=!1)}),[ce,Le,A]),Ie=t.useCallback((()=>{pe(!1),Ee(ye,!0)}),[ye,Ee]);function Ve(e){ae.current=!0,"input"===e.target.dataset.element&&(ue.current=!0)}t.useEffect((()=>()=>{Se.current&&clearTimeout(Se.current)}),[]);const He=t.useCallback((e=>{e&&(de(e),a&&("function"==typeof a?a(e):a.current=e))}),[a]);let We;switch(Q){case"top":We="top-end";break;case"bottom":We="bottom-end";break;default:We=Q}const Ke={ref:ie,id:le.current,labelId:we,anchorElement:(null==ce?void 0:ce.parentElement)||void 0,onSelect:Te,onSelectListClose:Ie,onMouseDown:function(){ae.current=!0},filterText:Ce.trim(),highlightedValue:he,noResultsMessage:B,listActionButton:F,listMaxHeight:M,onListAction:function(){pe(!1),null==T||T()},isLoading:I,onListScrollBottom:W,tableHeader:K,multiColumn:z,listPlacement:void 0!==ee?We:Q,flipEnabled:U,isOpen:fe,enableVirtualScroll:X,virtualScrollOverscan:Y,listWidth:ee},ze=Z?e.jsx(u.default,O(h({},Ke),{children:x})):e.jsx(C,O(h({},Ke),{children:x})),Ge=r.default(te);return e.jsxs(s.default,O(h({hasTextCursor:!0,readOnly:H,disabled:V,"data-component":"filterable-select","data-role":J,"data-element":G,isOpen:fe},Ge),{children:[e.jsx("div",{ref:oe,children:e.jsx(o.default,O(h({ref:He,activeDescendantId:ne,ariaLabel:v,ariaLabelledby:g,labelId:S?we:void 0,"aria-controls":le.current,isOpen:fe,hasTextCursor:!0},O(h({id:_e.current,name:w,label:S,disabled:V,readOnly:H,selectedValue:ye,formattedValue:be,onClick:function(e){ae.current=!1,E&&E(e),pe(!0)},iconOnClick:function(e){ae.current=!1,E&&E(e),pe((e=>!e))},iconOnMouseDown:Ve,onFocus:function(e){const t=()=>null==R?void 0:R(e);if(A){if(Se.current&&clearTimeout(Se.current),xe.current)return;Se.current=setTimeout((()=>{pe((e=>!(!e&&(R&&!se.current&&(t(),se.current=!0),ae.current&&!ue.current))))}))}else R&&!se.current&&(t(),se.current=!0)},onBlur:function(e){ue.current=!1,ae.current||(se.current=!1,D&&D(e))},onKeyDown:De,onChange:Pe,onMouseDown:Ve,tooltipPosition:N,required:$},l.default(te)),{"data-component":void 0})),{onChange:Pe,value:be}))}),ze]}))}));exports.FilterableSelect=j,exports.default=j;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("invariant");require("../../../style/utils/filter-styled-system-padding-props.js");var r=require("../../../style/utils/filter-styled-system-margin-props.js"),l=require("../../../style/utils/filter-out-styled-system-spacing-props.js"),o=require("../__internal__/select-textbox/select-textbox.component.js"),i=require("../../../__internal__/utils/helpers/guid/index.js"),a=require("../__internal__/utils/with-filter.hoc.js"),s=require("../select.style.js"),u=require("../__internal__/select-list/select-list.component.js"),c=require("../__internal__/utils/is-expected-option.js"),d=require("../__internal__/utils/are-objects-equal.js"),f=require("../__internal__/utils/is-navigation-key.js"),p=require("../../../hooks/__internal__/useStableCallback/useStableCallback.js"),b=require("../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js"),v=require("../../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js");function y(e){return e&&e.__esModule?e:{default:e}}var m=y(t),g=y(n);function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){h(e,t,n[t])}))}return e}function C(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const _=a.default(u.default),j=m.default.forwardRef(((n,a)=>{var{"aria-label":y,"aria-labelledby":h,value:j,id:w,name:S,label:k,children:x,onOpen:L,onChange:q,onFilterChange:E,onClick:P,onKeyDown:R,onFocus:A,onBlur:D,openOnFocus:F,noResultsMessage:M,listActionButton:B,listMaxHeight:T,onListAction:I,isLoading:V,disabled:H,readOnly:W,onListScrollBottom:K,tableHeader:z,multiColumn:G,"data-element":J,"data-role":N,tooltipPosition:Q,listPlacement:U="bottom",flipEnabled:X=!0,enableVirtualScroll:Y,virtualScrollOverscan:Z,disableDefaultFiltering:$=!1,required:ee,listWidth:te}=n,ne=function(e,t){if(null==e)return{};var n,r,l=function(e,t){if(null==e)return{};var n,r,l={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}(n,["aria-label","aria-labelledby","value","id","name","label","children","onOpen","onChange","onFilterChange","onClick","onKeyDown","onFocus","onBlur","openOnFocus","noResultsMessage","listActionButton","listMaxHeight","onListAction","isLoading","disabled","readOnly","onListScrollBottom","tableHeader","multiColumn","data-element","data-role","tooltipPosition","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","disableDefaultFiltering","required","listWidth"]);const[re,le]=t.useState(""),oe=t.useRef(i.default()),ie=t.useRef(null),ae=t.useRef(null),se=t.useRef(!1),ue=t.useRef(!1),ce=t.useRef(!1),[de,fe]=t.useState(),[pe,be]=t.useState(!1),[ve,ye]=t.useState(""),[me,ge]=t.useState(j||""),he=t.useRef(j),[Oe,Ce]=t.useState(""),[_e,je]=t.useState(""),we=t.useRef(w||i.default()),{labelId:Se}=b.default({id:we.current,label:k}),ke=t.useRef(null),xe=t.useRef(!1),Le=t.useCallback(((e,t)=>({target:C(O({},S&&{name:S},w&&{id:w}),{value:e}),selectionConfirmed:t})),[S,w]),qe=t.useCallback(((e,t)=>{q&&q(Le(e,t))}),[q,Le]),Ee=t.useCallback(((e,t)=>{ge((()=>{var n;const r=e.trimStart(),l=(o=r,i=x,m.default.Children.toArray(i).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==o?void 0:o.toLowerCase()))})));var o,i;const a=t&&!e.length;return!l||a||l.props.disabled?(ye(e),qe("",!1),""):(r.length&&qe(l.props.value,!1),t?(ye(e),l.props.value):(r.length&&(null===(n=l.props.text)||void 0===n?void 0:n.toLowerCase().startsWith(r.toLowerCase()))?ye(l.props.text):ye(e),Ce(l.props.value),l.props.value))}))}),[x,qe]),Pe=t.useCallback(((e,t=!1)=>{var n;const r=m.default.Children.toArray(x).find((t=>m.default.isValidElement(t)&&c.default(t,e)));r&&void 0!==r.props.text?(t||(null===(n=r.props.text)||void 0===n?void 0:n.toLowerCase().startsWith(null==_e?void 0:_e.toLowerCase().trim())))&&ye(r.props.text):ye(_e||"")}),[x,_e]),Re=t.useCallback((e=>{const t=e.target.value,{inputType:n}=e.nativeEvent;Ee(t,"deleteContentBackward"===n||"deleteContentForward"===n||"delete"===n),je(t),be(!0)}),[Ee]),Ae=t.useCallback((e=>{je((t=>(null==t?void 0:t.length)===(null==ve?void 0:ve.length)-1&&e===ve.slice(-1)?ve:t))}),[ve]),De=t.useCallback((e=>{const{key:t}=e;R&&R(e),W||(!e.defaultPrevented&&f.default(t)&&(e.preventDefault(),be(!0)),Ae(t))}),[Ae,R,W]),Fe=t.useCallback((e=>{const t=ie.current&&!ie.current.contains(e.target),n=ae.current&&!ae.current.contains(e.target);se.current=!1,t&&n&&(Pe(j,!0),be(!1))}),[Pe,j]);t.useEffect((()=>{ge((e=>(j&&e!==j&&Pe(j),j))),Ce(j)}),[j,q,x]);const Me=p.useStableCallback(L);t.useEffect((()=>{pe?Me&&Me():je("")}),[Me,pe]),t.useEffect((()=>{const e=void 0!==B;g.default(!e||e&&I,"onListAction prop required when using listActionButton prop")}),[B,I]);const Be=t.useRef(!0);t.useEffect((()=>{Be.current&&Pe(me),"object"==typeof j&&"object"==typeof he.current?d.default(j,he.current)||(Pe(j),he.current=j):Pe(j)}),[j,x]);const Te=p.useStableCallback(E);t.useEffect((()=>{Te&&!Be.current&&Te(_e)}),[Te,_e]),t.useEffect((()=>{Be.current=!1}),[]),t.useEffect((()=>{const e="click";return window.addEventListener(e,Fe),function(){window.removeEventListener(e,Fe)}}),[Fe]),t.useEffect((()=>{const e=null==_e?void 0:_e.trimStart(),t=null==ve?void 0:ve.toLowerCase().startsWith(e.toLowerCase());!H&&!W&&de&&e.length&&(null==ve?void 0:ve.length)>e.length&&t&&(de.selectionStart=e.length)}),[ve,_e,de,H,W]);const Ie=t.useCallback((e=>{const{id:t,text:n,value:r,selectionType:l,selectionConfirmed:o}=e;ye(n),qe(r,!!o),le(t),"navigationKey"!==l&&(xe.current=!!F,be(!1),null==de||de.focus(),null==de||de.select(),xe.current=!1)}),[de,qe,F]),Ve=t.useCallback((()=>{be(!1),Pe(me,!0)}),[me,Pe]);function He(e){se.current=!0,"input"===e.target.dataset.element&&(ce.current=!0)}t.useEffect((()=>()=>{ke.current&&clearTimeout(ke.current)}),[]),v.default((()=>be(!1)));const We=t.useCallback((e=>{e&&(fe(e),a&&("function"==typeof a?a(e):a.current=e))}),[a]);let Ke;switch(U){case"top":Ke="top-end";break;case"bottom":Ke="bottom-end";break;default:Ke=U}const ze={ref:ae,id:oe.current,labelId:Se,anchorElement:(null==de?void 0:de.parentElement)||void 0,onSelect:Ie,onSelectListClose:Ve,onMouseDown:function(){se.current=!0},filterText:_e.trim(),highlightedValue:Oe,noResultsMessage:M,listActionButton:B,listMaxHeight:T,onListAction:function(){be(!1),null==I||I()},isLoading:V,onListScrollBottom:K,tableHeader:z,multiColumn:G,listPlacement:void 0!==te?Ke:U,flipEnabled:X,isOpen:pe,enableVirtualScroll:Y,virtualScrollOverscan:Z,listWidth:te},Ge=$?e.jsx(u.default,C(O({},ze),{children:x})):e.jsx(_,C(O({},ze),{children:x})),Je=r.default(ne);return e.jsxs(s.default,C(O({hasTextCursor:!0,readOnly:W,disabled:H,"data-component":"filterable-select","data-role":N,"data-element":J,isOpen:pe},Je),{children:[e.jsx("div",{ref:ie,children:e.jsx(o.default,C(O({ref:We,activeDescendantId:re,ariaLabel:y,ariaLabelledby:h,labelId:k?Se:void 0,"aria-controls":oe.current,isOpen:pe,hasTextCursor:!0},C(O({id:we.current,name:S,label:k,disabled:H,readOnly:W,selectedValue:me,formattedValue:ve,onClick:function(e){se.current=!1,P&&P(e),be(!0)},iconOnClick:function(e){se.current=!1,P&&P(e),be((e=>!e))},iconOnMouseDown:He,onFocus:function(e){const t=()=>null==A?void 0:A(e);if(F){if(ke.current&&clearTimeout(ke.current),xe.current)return;ke.current=setTimeout((()=>{be((e=>!(!e&&(A&&!ue.current&&(t(),ue.current=!0),se.current&&!ce.current))))}))}else A&&!ue.current&&(t(),ue.current=!0)},onBlur:function(e){ce.current=!1,se.current||(ue.current=!1,D&&D(e))},onKeyDown:De,onChange:Re,onMouseDown:He,tooltipPosition:Q,required:ee},l.default(ne)),{"data-component":void 0})),{onChange:Re,value:ve}))}),Ge]}))}));exports.FilterableSelect=j,exports.default=j;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");require("../../../style/utils/filter-styled-system-padding-props.js");var l=require("../../../style/utils/filter-styled-system-margin-props.js"),r=require("../../../style/utils/filter-out-styled-system-spacing-props.js"),n=require("../__internal__/select-textbox/select-textbox.component.js"),i=require("../../../__internal__/utils/helpers/guid/index.js"),u=require("../__internal__/utils/with-filter.hoc.js"),o=require("../__internal__/select-list/select-list.component.js"),a=require("./multi-select.style.js"),s=require("../../pill/pill.component.js"),c=require("../__internal__/utils/is-expected-option.js"),d=require("../__internal__/utils/is-expected-value.js"),f=require("../__internal__/utils/is-navigation-key.js"),p=require("../../../hooks/__internal__/useStableCallback/useStableCallback.js"),b=require("../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js");function v(e){return e&&e.__esModule?e:{default:e}}var m=v(t);function y(e,t,l){return t in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function h(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{},r=Object.keys(l);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(l).filter((function(e){return Object.getOwnPropertyDescriptor(l,e).enumerable})))),r.forEach((function(t){y(e,t,l[t])}))}return e}function O(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t.push.apply(t,l)}return t}(Object(t)).forEach((function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(t,l))})),e}const g=u.default(o.default),j=m.default.forwardRef(((u,o)=>{var{"aria-label":v,"aria-labelledby":y,value:j,id:C,label:_,name:x,disabled:S,readOnly:k,children:w,onOpen:P,onFilterChange:q,onChange:E,onClick:R,onFocus:L,onBlur:M,onKeyDown:D,openOnFocus:V=!1,noResultsMessage:I,placeholder:T,isLoading:B,onListScrollBottom:F,tableHeader:H,multiColumn:A,tooltipPosition:z,size:K="medium","data-element":W,"data-role":$,listPlacement:G="bottom",listMaxHeight:J,flipEnabled:N=!0,wrapPillText:Q=!0,enableVirtualScroll:U,virtualScrollOverscan:X,required:Y,listWidth:Z}=u,ee=function(e,t){if(null==e)return{};var l,r,n=function(e,t){if(null==e)return{};var l,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)l=i[r],t.indexOf(l)>=0||(n[l]=e[l]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)l=i[r],t.indexOf(l)>=0||Object.prototype.propertyIsEnumerable.call(e,l)&&(n[l]=e[l])}return n}(u,["aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","onOpen","onFilterChange","onChange","onClick","onFocus","onBlur","onKeyDown","openOnFocus","noResultsMessage","placeholder","isLoading","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","size","data-element","data-role","listPlacement","listMaxHeight","flipEnabled","wrapPillText","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const[te,le]=t.useState(""),re=t.useRef(i.default()),ne=t.useRef(i.default()),ie=t.useRef(null),ue=t.useRef(null),oe=t.useRef(!1),ae=t.useRef(!1),se=t.useRef(!1),ce=t.useRef(!1),de=t.useRef(!1),[fe,pe]=t.useState(),[be,ve]=t.useState(!1),[me,ye]=t.useState(""),[he,Oe]=t.useState(""),[ge,je]=t.useState(""),[Ce,_e]=t.useState(),xe=t.useRef(C||i.default()),{labelId:Se}=b.default({id:xe.current,label:_}),ke=t.useRef(null),we=t.useCallback((()=>{ve((e=>(!e&&P&&P(),!0)))}),[P]),Pe=t.useCallback(((e,t)=>({target:O(h({},x&&{name:x},C&&{id:C}),{value:e}),selectionConfirmed:t})),[x,C]),qe=t.useCallback(((e,t)=>{const l=e(j);l.length!==(null==j?void 0:j.length)&&E(Pe(l,t))}),[Pe,E,j]),Ee=t.useCallback((e=>{const t=e.target.value,l=(r=t,n=w,m.default.Children.toArray(n).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==r?void 0:r.toLowerCase()))})));var r,n;l&&Oe(l.props.value),je(t),ye(t),we()}),[w,we]),Re=t.useCallback((e=>{ae.current=!0,qe((t=>{if(!t.length)return t;const l=t.slice();return l.splice(e,1),l}),!0)}),[qe]),Le=t.useCallback((e=>{const{key:t}=e,l="Backspace"===t||"Delete"===t;D&&D(e),k||(!e.defaultPrevented&&f.default(t)&&(e.preventDefault(),we()),!l||""!==ge&&""!==me||Re(-1))}),[D,k,ge,me,we,Re]),Me=t.useMemo((()=>{var e;return j&&j.length?null===(e=m.default.Children.map(w,(e=>!(!m.default.isValidElement(e)||!j.includes(e.props.value))&&e.props.text)))||void 0===e?void 0:e.filter((e=>e)).reduce(((e,t)=>e?`${e}, ${t}`:t),""):null}),[w,j]),De=t.useCallback((e=>{if(se.current=!1,!be)return;const t=ie.current&&!ie.current.contains(e.target),l=ue.current&&!ue.current.contains(e.target);t&&l&&!ae.current&&(ye(""),je(""),Oe(""),ve(!1)),ae.current=!1}),[be]),Ve=t.useMemo((()=>{const t=!S&&!k;let l;return(null==j?void 0:j.length)?j.map(((r,n)=>{const i=m.default.Children.toArray(w).find((e=>m.default.isValidElement(e)&&c.default(e,r)));let u={};if(!i)return null;var o,d;m.default.isValidElement(i)&&(l=void 0!==(null==i||null===(o=i.props.value)||void 0===o?void 0:o.value)?null==i||null===(d=i.props.value)||void 0===d?void 0:d.value:null==i?void 0:i.props.value,u={title:i.props.text,fill:i.props.fill,borderColor:i.props.borderColor});const f=u.title||"",p=f+l||n;return e.jsx(a.StyledSelectPillContainer,{children:e.jsx(s.Pill,O(h({onDelete:t?()=>Re(n):void 0,wrapText:Q},u),{children:f}))},p)})):""}),[w,S,k,j]);t.useEffect((()=>{const e=null==j?void 0:j.length;_e(e?" ":T)}),[j,T]),t.useEffect((()=>{const e="click";return window.addEventListener(e,De),function(){window.removeEventListener(e,De)}}),[De]);const Ie=p.useStableCallback(q),Te=t.useRef(!0);function Be(e){if(se.current=!1,R&&R(e),!V||V&&!de.current){if(be)return je(""),void ve(!1);null==P||P(),ve(!0)}else de.current=!1}function Fe(e){se.current=!1,R&&R(e),ve((e=>e?(je(""),!1):(P&&P(),!0)))}function He(e){ce.current=!1,se.current||(oe.current=!1,M&&M(e))}function Ae(e){se.current=!0,"input"===e.target.dataset.element&&(ce.current=!0)}function ze(e){const t=()=>null==L?void 0:L(e);V?(ke.current&&clearTimeout(ke.current),ke.current=setTimeout((()=>{ve((e=>!!e||(P&&P(),L&&!oe.current&&(t(),oe.current=!0),se.current&&!ce.current?(de.current=!1,!1):(ce.current&&(de.current=!0),!0))))}))):L&&!oe.current&&(t(),oe.current=!0)}t.useEffect((()=>{Ie&&!Te.current&&Ie(ge)}),[Ie,ge]),t.useEffect((()=>{Te.current=!1}),[]);const Ke=t.useCallback((e=>{const{value:t,selectionType:l,id:r,selectionConfirmed:n}=e;if("navigationKey"===l)return Oe(t),void le(r);"click"===l&&(ae.current=!0),ye("");const i=-1!==(null==j?void 0:j.findIndex((e=>d.default(e,t))));null==fe||fe.focus(),se.current=!1,qe((e=>i?e:[...e,t]),n)}),[fe,j,qe]),We=t.useCallback((()=>{ve(!1),je("")}),[]),$e=t.useCallback((e=>{e&&(pe(e),o&&("function"==typeof o?o(e):o.current=e))}),[o]);function Ge(){return O(h({id:xe.current,name:x,disabled:S,label:_,readOnly:k,placeholder:Ce,leftChildren:Ve,formattedValue:me,selectedValue:j,onClick:Be,onMouseDown:Ae,onFocus:ze,onBlur:He,iconOnClick:Fe,iconOnMouseDown:Ae,onKeyDown:Le,onChange:Ee,tooltipPosition:z,size:K,required:Y},r.default(ee)),{"data-component":void 0})}let Je;switch(G){case"top":Je="top-end";break;case"bottom":Je="bottom-end";break;default:Je=G}const Ne=e.jsx(g,{ref:ue,id:re.current,labelId:Se,anchorElement:(null==fe?void 0:fe.parentElement)||void 0,onSelect:Ke,onSelectListClose:We,onMouseDown:function(){se.current=!0},filterText:ge.trim(),highlightedValue:he,noResultsMessage:I,isLoading:B,onListScrollBottom:F,tableHeader:H,multiColumn:A,listPlacement:void 0!==Z?Je:G,listMaxHeight:J,flipEnabled:N,multiselectValues:j,isOpen:be,enableVirtualScroll:U,virtualScrollOverscan:X,listWidth:Z,children:w}),Qe=l.default(ee);return e.jsxs(a.StyledSelectMultiSelect,O(h({disabled:S,readOnly:k,hasTextCursor:!0,size:K,"data-component":"multiselect","data-role":$,"data-element":W,isOpen:be},Qe),{children:[e.jsxs("div",{ref:ie,children:[e.jsx(a.StyledAccessibilityLabelContainer,{"data-element":"accessibility-label",id:ne.current,children:Me}),e.jsx(n.default,h({ref:$e,accessibilityLabelId:ne.current,activeDescendantId:te,"aria-controls":re.current,ariaLabel:v,ariaLabelledby:y,hasTextCursor:!0,isOpen:be,labelId:Se,value:Ge().formattedValue},Ge()))]}),Ne]}))}));exports.MultiSelect=j,exports.default=j;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");require("../../../style/utils/filter-styled-system-padding-props.js");var l=require("../../../style/utils/filter-styled-system-margin-props.js"),r=require("../../../style/utils/filter-out-styled-system-spacing-props.js"),n=require("../__internal__/select-textbox/select-textbox.component.js"),i=require("../../../__internal__/utils/helpers/guid/index.js"),u=require("../__internal__/utils/with-filter.hoc.js"),o=require("../__internal__/select-list/select-list.component.js"),a=require("./multi-select.style.js"),s=require("../../pill/pill.component.js"),c=require("../__internal__/utils/is-expected-option.js"),d=require("../__internal__/utils/is-expected-value.js"),f=require("../__internal__/utils/is-navigation-key.js"),p=require("../../../hooks/__internal__/useStableCallback/useStableCallback.js"),b=require("../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js"),v=require("../../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js");function m(e){return e&&e.__esModule?e:{default:e}}var y=m(t);function h(e,t,l){return t in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function O(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{},r=Object.keys(l);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(l).filter((function(e){return Object.getOwnPropertyDescriptor(l,e).enumerable})))),r.forEach((function(t){h(e,t,l[t])}))}return e}function g(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t.push.apply(t,l)}return t}(Object(t)).forEach((function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(t,l))})),e}const _=u.default(o.default),j=y.default.forwardRef(((u,o)=>{var{"aria-label":m,"aria-labelledby":h,value:j,id:C,label:S,name:x,disabled:k,readOnly:w,children:P,onOpen:q,onFilterChange:E,onChange:M,onClick:R,onFocus:L,onBlur:D,onKeyDown:V,openOnFocus:F=!1,noResultsMessage:I,placeholder:T,isLoading:A,onListScrollBottom:B,tableHeader:H,multiColumn:z,tooltipPosition:K,size:W="medium","data-element":$,"data-role":G,listPlacement:J="bottom",listMaxHeight:N,flipEnabled:Q=!0,wrapPillText:U=!0,enableVirtualScroll:X,virtualScrollOverscan:Y,required:Z,listWidth:ee}=u,te=function(e,t){if(null==e)return{};var l,r,n=function(e,t){if(null==e)return{};var l,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)l=i[r],t.indexOf(l)>=0||(n[l]=e[l]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)l=i[r],t.indexOf(l)>=0||Object.prototype.propertyIsEnumerable.call(e,l)&&(n[l]=e[l])}return n}(u,["aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","onOpen","onFilterChange","onChange","onClick","onFocus","onBlur","onKeyDown","openOnFocus","noResultsMessage","placeholder","isLoading","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","size","data-element","data-role","listPlacement","listMaxHeight","flipEnabled","wrapPillText","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const[le,re]=t.useState(""),ne=t.useRef(i.default()),ie=t.useRef(i.default()),ue=t.useRef(null),oe=t.useRef(null),ae=t.useRef(!1),se=t.useRef(!1),ce=t.useRef(!1),de=t.useRef(!1),fe=t.useRef(!1),[pe,be]=t.useState(),[ve,me]=t.useState(!1),[ye,he]=t.useState(""),[Oe,ge]=t.useState(""),[_e,je]=t.useState(""),[Ce,Se]=t.useState(),xe=t.useRef(C||i.default()),{labelId:ke}=b.default({id:xe.current,label:S}),we=t.useRef(null),Pe=t.useCallback((()=>{me((e=>(!e&&q&&q(),!0)))}),[q]),qe=t.useCallback(((e,t)=>({target:g(O({},x&&{name:x},C&&{id:C}),{value:e}),selectionConfirmed:t})),[x,C]),Ee=t.useCallback(((e,t)=>{const l=e(j);l.length!==(null==j?void 0:j.length)&&M(qe(l,t))}),[qe,M,j]),Me=t.useCallback((e=>{const t=e.target.value,l=(r=t,n=P,y.default.Children.toArray(n).find((e=>{const{text:t}=e.props;return-1!==(null==t?void 0:t.toLowerCase().indexOf(null==r?void 0:r.toLowerCase()))})));var r,n;l&&ge(l.props.value),je(t),he(t),Pe()}),[P,Pe]),Re=t.useCallback((e=>{se.current=!0,Ee((t=>{if(!t.length)return t;const l=t.slice();return l.splice(e,1),l}),!0)}),[Ee]),Le=t.useCallback((e=>{const{key:t}=e,l="Backspace"===t||"Delete"===t;V&&V(e),w||(!e.defaultPrevented&&f.default(t)&&(e.preventDefault(),Pe()),!l||""!==_e&&""!==ye||Re(-1))}),[V,w,_e,ye,Pe,Re]),De=t.useMemo((()=>{var e;return j&&j.length?null===(e=y.default.Children.map(P,(e=>!(!y.default.isValidElement(e)||!j.includes(e.props.value))&&e.props.text)))||void 0===e?void 0:e.filter((e=>e)).reduce(((e,t)=>e?`${e}, ${t}`:t),""):null}),[P,j]),Ve=t.useCallback((e=>{if(ce.current=!1,!ve)return;const t=ue.current&&!ue.current.contains(e.target),l=oe.current&&!oe.current.contains(e.target);t&&l&&!se.current&&(he(""),je(""),ge(""),me(!1)),se.current=!1}),[ve]),Fe=t.useMemo((()=>{const t=!k&&!w;let l;return(null==j?void 0:j.length)?j.map(((r,n)=>{const i=y.default.Children.toArray(P).find((e=>y.default.isValidElement(e)&&c.default(e,r)));let u={};if(!i)return null;var o,d;y.default.isValidElement(i)&&(l=void 0!==(null==i||null===(o=i.props.value)||void 0===o?void 0:o.value)?null==i||null===(d=i.props.value)||void 0===d?void 0:d.value:null==i?void 0:i.props.value,u={title:i.props.text,fill:i.props.fill,borderColor:i.props.borderColor});const f=u.title||"",p=f+l||n;return e.jsx(a.StyledSelectPillContainer,{children:e.jsx(s.Pill,g(O({onDelete:t?()=>Re(n):void 0,wrapText:U},u),{children:f}))},p)})):""}),[P,k,w,j]);t.useEffect((()=>{const e=null==j?void 0:j.length;Se(e?" ":T)}),[j,T]),t.useEffect((()=>{const e="click";return window.addEventListener(e,Ve),function(){window.removeEventListener(e,Ve)}}),[Ve]);const Ie=p.useStableCallback(E),Te=t.useRef(!0);function Ae(e){if(ce.current=!1,R&&R(e),!F||F&&!fe.current){if(ve)return je(""),void me(!1);null==q||q(),me(!0)}else fe.current=!1}function Be(e){ce.current=!1,R&&R(e),me((e=>e?(je(""),!1):(q&&q(),!0)))}function He(e){de.current=!1,ce.current||(ae.current=!1,D&&D(e))}function ze(e){ce.current=!0,"input"===e.target.dataset.element&&(de.current=!0)}function Ke(e){const t=()=>null==L?void 0:L(e);F?(we.current&&clearTimeout(we.current),we.current=setTimeout((()=>{me((e=>!!e||(q&&q(),L&&!ae.current&&(t(),ae.current=!0),ce.current&&!de.current?(fe.current=!1,!1):(de.current&&(fe.current=!0),!0))))}))):L&&!ae.current&&(t(),ae.current=!0)}t.useEffect((()=>{Ie&&!Te.current&&Ie(_e)}),[Ie,_e]),t.useEffect((()=>{Te.current=!1}),[]),v.default((()=>me(!1)));const We=t.useCallback((e=>{const{value:t,selectionType:l,id:r,selectionConfirmed:n}=e;if("navigationKey"===l)return ge(t),void re(r);"click"===l&&(se.current=!0),he("");const i=-1!==(null==j?void 0:j.findIndex((e=>d.default(e,t))));null==pe||pe.focus(),ce.current=!1,Ee((e=>i?e:[...e,t]),n)}),[pe,j,Ee]),$e=t.useCallback((()=>{me(!1),je("")}),[]),Ge=t.useCallback((e=>{e&&(be(e),o&&("function"==typeof o?o(e):o.current=e))}),[o]);function Je(){return g(O({id:xe.current,name:x,disabled:k,label:S,readOnly:w,placeholder:Ce,leftChildren:Fe,formattedValue:ye,selectedValue:j,onClick:Ae,onMouseDown:ze,onFocus:Ke,onBlur:He,iconOnClick:Be,iconOnMouseDown:ze,onKeyDown:Le,onChange:Me,tooltipPosition:K,size:W,required:Z},r.default(te)),{"data-component":void 0})}let Ne;switch(J){case"top":Ne="top-end";break;case"bottom":Ne="bottom-end";break;default:Ne=J}const Qe=e.jsx(_,{ref:oe,id:ne.current,labelId:ke,anchorElement:(null==pe?void 0:pe.parentElement)||void 0,onSelect:We,onSelectListClose:$e,onMouseDown:function(){ce.current=!0},filterText:_e.trim(),highlightedValue:Oe,noResultsMessage:I,isLoading:A,onListScrollBottom:B,tableHeader:H,multiColumn:z,listPlacement:void 0!==ee?Ne:J,listMaxHeight:N,flipEnabled:Q,multiselectValues:j,isOpen:ve,enableVirtualScroll:X,virtualScrollOverscan:Y,listWidth:ee,children:P}),Ue=l.default(te);return e.jsxs(a.StyledSelectMultiSelect,g(O({disabled:k,readOnly:w,hasTextCursor:!0,size:W,"data-component":"multiselect","data-role":G,"data-element":$,isOpen:ve},Ue),{children:[e.jsxs("div",{ref:ue,children:[e.jsx(a.StyledAccessibilityLabelContainer,{"data-element":"accessibility-label",id:ie.current,children:De}),e.jsx(n.default,O({ref:Ge,accessibilityLabelId:ie.current,activeDescendantId:le,"aria-controls":ne.current,ariaLabel:m,ariaLabelledby:h,hasTextCursor:!0,isOpen:ve,labelId:ke,value:Je().formattedValue},Je()))]}),Qe]}))}));exports.MultiSelect=j,exports.default=j;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");require("../../../style/utils/filter-styled-system-padding-props.js");var n=require("../../../style/utils/filter-styled-system-margin-props.js"),r=require("../../../style/utils/filter-out-styled-system-spacing-props.js"),l=require("../select.style.js"),i=require("../__internal__/select-textbox/select-textbox.component.js"),o=require("../__internal__/select-list/select-list.component.js"),a=require("../../../__internal__/utils/helpers/guid/index.js"),u=require("../__internal__/utils/get-next-child-by-text.js"),s=require("../__internal__/utils/is-expected-option.js"),c=require("../__internal__/utils/is-navigation-key.js"),d=require("../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js");function f(e){return e&&e.__esModule?e:{default:e}}var b=f(t);function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){p(e,t,n[t])}))}return e}function m(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const O=b.default.forwardRef(((f,p)=>{var{"aria-describedby":O,"aria-label":v,"aria-labelledby":g,value:w,id:j,label:_,name:h,disabled:x,readOnly:S,children:k,transparent:C,openOnFocus:P=!1,onOpen:q,onChange:E,onClick:D,onFocus:L,onKeyDown:R,onBlur:I,isLoading:M,listMaxHeight:T,onListScrollBottom:V,tableHeader:B,multiColumn:H,tooltipPosition:K,"data-element":F,"data-role":A,listPlacement:W="bottom",flipEnabled:z=!0,enableVirtualScroll:G,virtualScrollOverscan:J,required:N,listWidth:Q}=f,U=function(e,t){if(null==e)return{};var n,r,l=function(e,t){if(null==e)return{};var n,r,l={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}(f,["aria-describedby","aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","transparent","openOnFocus","onOpen","onChange","onClick","onFocus","onKeyDown","onBlur","isLoading","listMaxHeight","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","data-element","data-role","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const X=t.useRef(a.default()),Y=t.useRef(null),Z=t.useRef(null),$=t.useRef(void 0),ee=t.useRef(),te=t.useRef(),ne=t.useRef(),re=t.useRef(),[le,ie]=t.useState(),[oe,ae]=t.useState(!1),[ue,se]=t.useState(""),[ce,de]=t.useState(""),[fe,be]=t.useState(w),pe=t.useRef(j||a.default()),{labelId:ye}=d.default({id:pe.current,label:_}),me=t.useRef(void 0),Oe=t.useMemo((()=>b.default.Children.toArray(k)),[k]),ve=t.useCallback(((e,t=!1)=>({target:m(y({},h&&{name:h},j&&{id:j}),{value:e}),selectionConfirmed:t})),[h,j]),ge=t.useCallback((e=>{const t=Oe.findIndex((e=>b.default.isValidElement(e)&&s.default(e,fe))),n=u.default(e,Oe,t);n&&E(ve(n.props.value))}),[Oe,ve,E,fe]),we=t.useCallback((e=>{if(te.current){const t=re.current+e;re.current=t,ge(t),window.clearTimeout($.current)}else re.current=e,ge(e);te.current=!0,window.clearTimeout($.current),$.current=window.setTimeout((()=>{te.current=!1,re.current=""}),500)}),[ge]),je=t.useCallback((e=>{const{key:t}=e;null==R||R(e),S||(" "===t||c.default(t)?(e.preventDefault(),ae((e=>(e||null==q||q(),!0)))):1!==t.length||e.metaKey||e.ctrlKey||we(t))}),[we,R,q,S]),_e=t.useCallback((e=>{const t=Y.current&&!Y.current.contains(e.target),n=Z.current&&!Z.current.contains(e.target);ee.current=!1,t&&n&&!ne.current&&ae(!1),ne.current=!1}),[]);function he(e){ee.current=!1,null==D||D(e),ae((e=>!e&&(null==q||q(),!0)))}t.useEffect((()=>{be(w)}),[w]),t.useEffect((()=>{const e=Oe.find((e=>s.default(e,fe)));let t="";e&&(t=e.props.text),de(t)}),[fe,Oe]),t.useEffect((()=>{const e="click";return window.addEventListener(e,_e),function(){window.removeEventListener(e,_e)}}),[_e]),t.useEffect((()=>function(){window.clearTimeout($.current),window.clearTimeout(me.current)}),[]);const xe=t.useCallback((()=>{ae(!1)}),[]),Se=t.useCallback((e=>{e&&(ie(e),p&&("function"==typeof p?p(e):p.current=e))}),[p]);let ke;switch(W){case"top":ke="top-end";break;case"bottom":ke="bottom-end";break;default:ke=W}const Ce=e.jsx(o.default,{ref:Z,id:X.current,labelId:ye,anchorElement:(null==le?void 0:le.parentElement)||void 0,onSelect:e=>{const{text:t,value:n,selectionType:r,id:l,selectionConfirmed:i}=e,o="click"===r;!function(e,t,n){null==E||E(ve(e,n))}(n,0,i),se(l),"navigationKey"!==r&&ae(!1),o&&(ne.current=!0,null==le||le.focus())},onMouseDown:function(){ee.current=!0},onSelectListClose:xe,highlightedValue:fe,listMaxHeight:T,isLoading:M,onListScrollBottom:V,tableHeader:B,multiColumn:H,listPlacement:void 0!==Q?ke:W,flipEnabled:z,isOpen:oe,enableVirtualScroll:G,virtualScrollOverscan:J,listWidth:Q,children:k}),Pe=n.default(U);return e.jsxs(l.default,m(y({transparent:C,disabled:x,readOnly:S,"data-component":"simple-select","data-role":A,"data-element":F,isOpen:oe},Pe),{children:[e.jsx("div",{ref:Y,children:e.jsx(i.default,m(y({ref:Se,ariaLabel:v,"aria-controls":X.current,activeDescendantId:ue,ariaLabelledby:g,"aria-describedby":O,isOpen:oe,value:ce},m(y({id:pe.current,name:h,disabled:x,readOnly:S,selectedValue:fe,formattedValue:ce,onClick:he,iconOnClick:function(e){he(e)},label:_,labelId:ye,onMouseDown:function(){ee.current=!0},onFocus:function(e){ne.current||(null==L||L(e),ee.current?ee.current=!1:P&&(window.clearTimeout(me.current),me.current=window.setTimeout((()=>{ae((e=>(e||null==q||q(),!0)))}))))},onKeyDown:je,onBlur:function(e){ee.current||null==I||I(e)},tooltipPosition:K,required:N,transparent:C},r.default(U)),{"data-component":void 0})),{onChange:()=>{}}))}),Ce]}))}));exports.SimpleSelect=O,exports.default=O;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");require("../../../style/utils/filter-styled-system-padding-props.js");var n=require("../../../style/utils/filter-styled-system-margin-props.js"),r=require("../../../style/utils/filter-out-styled-system-spacing-props.js"),l=require("../select.style.js"),i=require("../__internal__/select-textbox/select-textbox.component.js"),o=require("../__internal__/select-list/select-list.component.js"),a=require("../../../__internal__/utils/helpers/guid/index.js"),u=require("../__internal__/utils/get-next-child-by-text.js"),s=require("../__internal__/utils/is-expected-option.js"),c=require("../__internal__/utils/is-navigation-key.js"),d=require("../../../hooks/__internal__/useInputAccessibility/useInputAccessibility.js"),f=require("../../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js");function b(e){return e&&e.__esModule?e:{default:e}}var p=b(t);function y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),r.forEach((function(t){y(e,t,n[t])}))}return e}function O(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t}(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})),e}const v=p.default.forwardRef(((b,y)=>{var{"aria-describedby":v,"aria-label":g,"aria-labelledby":j,value:w,id:_,label:h,name:S,disabled:x,readOnly:k,children:C,transparent:P,openOnFocus:q=!1,onOpen:E,onChange:D,onClick:L,onFocus:R,onKeyDown:M,onBlur:I,isLoading:T,listMaxHeight:F,onListScrollBottom:V,tableHeader:B,multiColumn:H,tooltipPosition:K,"data-element":A,"data-role":W,listPlacement:z="bottom",flipEnabled:G=!0,enableVirtualScroll:J,virtualScrollOverscan:N,required:Q,listWidth:U}=b,X=function(e,t){if(null==e)return{};var n,r,l=function(e,t){if(null==e)return{};var n,r,l={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(l[n]=e[n]);return l}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(l[n]=e[n])}return l}(b,["aria-describedby","aria-label","aria-labelledby","value","id","label","name","disabled","readOnly","children","transparent","openOnFocus","onOpen","onChange","onClick","onFocus","onKeyDown","onBlur","isLoading","listMaxHeight","onListScrollBottom","tableHeader","multiColumn","tooltipPosition","data-element","data-role","listPlacement","flipEnabled","enableVirtualScroll","virtualScrollOverscan","required","listWidth"]);const Y=t.useRef(a.default()),Z=t.useRef(null),$=t.useRef(null),ee=t.useRef(void 0),te=t.useRef(),ne=t.useRef(),re=t.useRef(),le=t.useRef(),[ie,oe]=t.useState(),[ae,ue]=t.useState(!1),[se,ce]=t.useState(""),[de,fe]=t.useState(""),[be,pe]=t.useState(w),ye=t.useRef(_||a.default()),{labelId:me}=d.default({id:ye.current,label:h}),Oe=t.useRef(void 0),ve=t.useMemo((()=>p.default.Children.toArray(C)),[C]),ge=t.useCallback(((e,t=!1)=>({target:O(m({},S&&{name:S},_&&{id:_}),{value:e}),selectionConfirmed:t})),[S,_]),je=t.useCallback((e=>{const t=ve.findIndex((e=>p.default.isValidElement(e)&&s.default(e,be))),n=u.default(e,ve,t);n&&D(ge(n.props.value))}),[ve,ge,D,be]),we=t.useCallback((e=>{if(ne.current){const t=le.current+e;le.current=t,je(t),window.clearTimeout(ee.current)}else le.current=e,je(e);ne.current=!0,window.clearTimeout(ee.current),ee.current=window.setTimeout((()=>{ne.current=!1,le.current=""}),500)}),[je]),_e=t.useCallback((e=>{const{key:t}=e;null==M||M(e),k||(" "===t||c.default(t)?(e.preventDefault(),ue((e=>(e||null==E||E(),!0)))):1!==t.length||e.metaKey||e.ctrlKey||we(t))}),[we,M,E,k]),he=t.useCallback((e=>{const t=Z.current&&!Z.current.contains(e.target),n=$.current&&!$.current.contains(e.target);te.current=!1,t&&n&&!re.current&&ue(!1),re.current=!1}),[]);function Se(e){te.current=!1,null==L||L(e),ue((e=>!e&&(null==E||E(),!0)))}t.useEffect((()=>{pe(w)}),[w]),t.useEffect((()=>{const e=ve.find((e=>s.default(e,be)));let t="";e&&(t=e.props.text),fe(t)}),[be,ve]),t.useEffect((()=>{const e="click";return window.addEventListener(e,he),function(){window.removeEventListener(e,he)}}),[he]),t.useEffect((()=>function(){window.clearTimeout(ee.current),window.clearTimeout(Oe.current)}),[]),f.default((()=>ue(!1)));const xe=t.useCallback((()=>{ue(!1)}),[]),ke=t.useCallback((e=>{e&&(oe(e),y&&("function"==typeof y?y(e):y.current=e))}),[y]);let Ce;switch(z){case"top":Ce="top-end";break;case"bottom":Ce="bottom-end";break;default:Ce=z}const Pe=e.jsx(o.default,{ref:$,id:Y.current,labelId:me,anchorElement:(null==ie?void 0:ie.parentElement)||void 0,onSelect:e=>{const{text:t,value:n,selectionType:r,id:l,selectionConfirmed:i}=e,o="click"===r;!function(e,t,n){null==D||D(ge(e,n))}(n,0,i),ce(l),"navigationKey"!==r&&ue(!1),o&&(re.current=!0,null==ie||ie.focus())},onMouseDown:function(){te.current=!0},onSelectListClose:xe,highlightedValue:be,listMaxHeight:F,isLoading:T,onListScrollBottom:V,tableHeader:B,multiColumn:H,listPlacement:void 0!==U?Ce:z,flipEnabled:G,isOpen:ae,enableVirtualScroll:J,virtualScrollOverscan:N,listWidth:U,children:C}),qe=n.default(X);return e.jsxs(l.default,O(m({transparent:P,disabled:x,readOnly:k,"data-component":"simple-select","data-role":W,"data-element":A,isOpen:ae},qe),{children:[e.jsx("div",{ref:Z,children:e.jsx(i.default,O(m({ref:ke,ariaLabel:g,"aria-controls":Y.current,activeDescendantId:se,ariaLabelledby:j,"aria-describedby":v,isOpen:ae,value:de},O(m({id:ye.current,name:S,disabled:x,readOnly:k,selectedValue:be,formattedValue:de,onClick:Se,iconOnClick:function(e){Se(e)},label:h,labelId:me,onMouseDown:function(){te.current=!0},onFocus:function(e){re.current||(null==R||R(e),te.current?te.current=!1:q&&(window.clearTimeout(Oe.current),Oe.current=window.setTimeout((()=>{ue((e=>(e||null==E||E(),!0)))}))))},onKeyDown:_e,onBlur:function(e){te.current||null==I||I(e)},tooltipPosition:K,required:Q,transparent:P},r.default(X)),{"data-component":void 0})),{onChange:()=>{}}))}),Pe]}))}));exports.SimpleSelect=v,exports.default=v;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("styled-components"),n=require("@floating-ui/dom"),o=require("../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js"),i=require("../icon/icon.component.js"),l=require("../button/button.component.js"),s=require("./split-button.style.js"),u=require("./split-button-toggle.style.js"),a=require("./split-button-children.style.js"),c=require("../../__internal__/utils/helpers/guid/index.js"),d=require("../../__internal__/popover/popover.component.js");require("../../style/utils/filter-styled-system-padding-props.js");var p=require("../../style/utils/filter-styled-system-margin-props.js"),f=require("../../style/utils/filter-out-styled-system-spacing-props.js");require("../../style/themes/sage/index.js");var b=require("../../style/themes/base/index.js");require("../../style/themes/none/index.js");var y=require("../../hooks/__internal__/useChildButtons/useChildButtons.js"),j=require("./__internal__/split-button.context.js"),m=require("../../hooks/__internal__/useLocale/useLocale.js"),h=require("../flat-table/__internal__/flat-table.context.js");function g(e){return e&&e.__esModule?e:{default:e}}var _=g(t);function x(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){x(e,t,r[t])}))}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const q=t.forwardRef(((g,x)=>{var{align:q="left",position:w="right",buttonType:P="secondary",children:k,disabled:C=!1,iconPosition:T="before",iconType:S,onClick:B,size:D="medium",subtext:L,text:R,"data-element":z,"data-role":I,"aria-label":W,isWhite:A=!1}=g,E=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(g,["align","position","buttonType","children","disabled","iconPosition","iconType","onClick","size","subtext","text","data-element","data-role","aria-label","isWhite"]);const M=m.default(),F=t.useContext(r.ThemeContext)||b.default,K=t.useRef(c.default()),H=t.useRef(c.default()),N=t.useRef(null),U=t.useRef(null),{isInFlatTable:V}=t.useContext(h.default),G="secondary"===P&&A;t.useImperativeHandle(x,(()=>({focusMainButton(){var e;null===(e=N.current)||void 0===e||e.focus()},focusToggleButton(){var e;null===(e=U.current)||void 0===e||e.focus()}})),[]);const{showAdditionalButtons:J,showButtons:Q,hideButtons:X,buttonNode:Y,handleToggleButtonKeyDown:Z,wrapperProps:$,contextValue:ee}=y.default(U,.75),te=O({onFocus:X,onTouchStart:X,iconPosition:T,buttonType:P,disabled:C,iconType:S,onClick:e=>{var t;null===(t=N.current)||void 0===t||t.focus(),B&&B(e)},size:D,subtext:L,isWhite:G},f.default(E)),re={isWhite:G,disabled:C,displayed:J,onTouchStart:Q,onKeyDown:Z,onClick:()=>{var e;null===(e=U.current)||void 0===e||e.focus({preventScroll:!0}),J?X():Q()},buttonType:P,size:D},ne=o.default(X),oe=p.default(E);return e.jsxs(s.default,v(O({onClick:ne,ref:Y},{"data-component":"split-button","data-element":z,"data-role":I},oe),{children:[[e.jsx(l.default,v(O({"data-element":"main-button",id:K.current,ref:N},te),{children:R}),"main-button"),e.jsx(u.default,v(O({"aria-expanded":J,"aria-controls":H.current,"aria-label":W||M.splitButton.ariaLabel(),"data-element":"toggle-button",type:"button",ref:U},re),{children:e.jsx(i.default,{type:"dropdown",color:{primary:F.colors.white,secondary:F.colors.primary}[P],bg:"transparent",disabled:C})}),"toggle-button")],J?e.jsx(d.default,{disableBackgroundUI:V,disablePortal:!0,placement:"left"===w?"bottom-start":"bottom-end",popoverStrategy:"fixed",reference:Y,middleware:[n.offset(6),n.flip({fallbackStrategy:"initialPlacement"})],children:e.jsx(a.default,v(O({id:H.current},$),{align:q,children:e.jsx(j.default.Provider,{value:ee,children:_.default.Children.map(k,(t=>e.jsx("li",{children:t})))})}))}):null]}))}));exports.SplitButton=q,exports.default=q;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("styled-components"),n=require("@floating-ui/dom"),o=require("../../hooks/__internal__/useClickAwayListener/useClickAwayListener.js"),i=require("../icon/icon.component.js"),l=require("../button/button.component.js"),s=require("./split-button.style.js"),u=require("./split-button-toggle.style.js"),a=require("./split-button-children.style.js"),c=require("../../__internal__/utils/helpers/guid/index.js"),d=require("../../__internal__/popover/popover.component.js");require("../../style/utils/filter-styled-system-padding-props.js");var p=require("../../style/utils/filter-styled-system-margin-props.js"),f=require("../../style/utils/filter-out-styled-system-spacing-props.js");require("../../style/themes/sage/index.js");var b=require("../../style/themes/base/index.js");require("../../style/themes/none/index.js");var y=require("../../hooks/__internal__/useChildButtons/useChildButtons.js"),j=require("../../hooks/__internal__/useAdaptiveSidebarModalFocus/useAdaptiveSidebarModalFocus.js"),m=require("./__internal__/split-button.context.js"),h=require("../../hooks/__internal__/useLocale/useLocale.js"),g=require("../flat-table/__internal__/flat-table.context.js");function _(e){return e&&e.__esModule?e:{default:e}}var v=_(t);function x(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){x(e,t,r[t])}))}return e}function q(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const w=t.forwardRef(((_,x)=>{var{align:w="left",position:P="right",buttonType:k="secondary",children:S,disabled:C=!1,iconPosition:T="before",iconType:B,onClick:D,size:A="medium",subtext:L,text:M,"data-element":R,"data-role":z,"aria-label":F,isWhite:I=!1}=_,W=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(_,["align","position","buttonType","children","disabled","iconPosition","iconType","onClick","size","subtext","text","data-element","data-role","aria-label","isWhite"]);const E=h.default(),K=t.useContext(r.ThemeContext)||b.default,H=t.useRef(c.default()),N=t.useRef(c.default()),U=t.useRef(null),V=t.useRef(null),{isInFlatTable:G}=t.useContext(g.default),J="secondary"===k&&I;t.useImperativeHandle(x,(()=>({focusMainButton(){var e;null===(e=U.current)||void 0===e||e.focus()},focusToggleButton(){var e;null===(e=V.current)||void 0===e||e.focus()}})),[]);const{showAdditionalButtons:Q,showButtons:X,hideButtons:Y,buttonNode:Z,handleToggleButtonKeyDown:$,wrapperProps:ee,contextValue:te}=y.default(V,.75),re=O({onFocus:Y,onTouchStart:Y,iconPosition:T,buttonType:k,disabled:C,iconType:B,onClick:e=>{var t;null===(t=U.current)||void 0===t||t.focus(),D&&D(e)},size:A,subtext:L,isWhite:J},f.default(W));j.default((()=>Y()));const ne={isWhite:J,disabled:C,displayed:Q,onTouchStart:X,onKeyDown:$,onClick:()=>{var e;null===(e=V.current)||void 0===e||e.focus({preventScroll:!0}),Q?Y():X()},buttonType:k,size:A},oe=o.default(Y),ie=p.default(W);return e.jsxs(s.default,q(O({onClick:oe,ref:Z},{"data-component":"split-button","data-element":R,"data-role":z},ie),{children:[[e.jsx(l.default,q(O({"data-element":"main-button",id:H.current,ref:U},re),{children:M}),"main-button"),e.jsx(u.default,q(O({"aria-expanded":Q,"aria-controls":N.current,"aria-label":F||E.splitButton.ariaLabel(),"data-element":"toggle-button",type:"button",ref:V},ne),{children:e.jsx(i.default,{type:"dropdown",color:{primary:K.colors.white,secondary:K.colors.primary}[k],bg:"transparent",disabled:C})}),"toggle-button")],Q?e.jsx(d.default,{disableBackgroundUI:G,disablePortal:!0,placement:"left"===P?"bottom-start":"bottom-end",popoverStrategy:"fixed",reference:Z,middleware:[n.offset(6),n.flip({fallbackStrategy:"initialPlacement"})],children:e.jsx(a.default,q(O({id:N.current},ee),{align:w,children:e.jsx(m.default.Provider,{value:te,children:v.default.Children.map(S,(t=>e.jsx("li",{children:t})))})}))}):null]}))}));exports.SplitButton=w,exports.default=w;
@@ -0,0 +1 @@
1
+ export { default } from "./useAdaptiveSidebarModalFocus";
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./useAdaptiveSidebarModalFocus.js");exports.default=e.default;
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "main": "./index.js",
4
+ "module": "../../../esm/hooks/__internal__/useAdaptiveSidebarModalFocus/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1,2 @@
1
+ declare const useAdaptiveSidebarModalFocus: (closeFunction: () => void) => void;
2
+ export default useAdaptiveSidebarModalFocus;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");exports.default=t=>{e.useEffect((()=>{const e=()=>t();return document.addEventListener("adaptiveSidebarModalFocusIn",e),()=>{document.removeEventListener("adaptiveSidebarModalFocusIn",e)}}),[t])};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "157.1.2",
3
+ "version": "157.2.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",