@viasat/beam-react 2.21.1 → 2.23.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 (68) hide show
  1. package/assets/Search.css +1 -1
  2. package/assets/panel.css +1 -1
  3. package/chunks/Search.Results.BM9NkYBp.js +1 -0
  4. package/chunks/Search.Results.wKBufUSo.js +64 -0
  5. package/chunks/{panel.module.a_gaicKX.js → panel.module.DCpj0tSX.js} +1 -1
  6. package/lib/Alert/Alert.figma.d.ts +1 -0
  7. package/lib/Switch/Switch.figma.d.ts +1 -0
  8. package/lib/Tooltip/Tooltip.figma.d.ts +1 -0
  9. package/lib/wip/Panel/Panel.Body.cjs.js +1 -1
  10. package/lib/wip/Panel/Panel.Body.d.ts +6 -1
  11. package/lib/wip/Panel/Panel.Body.es.js +11 -9
  12. package/lib/wip/Panel/Panel.Divider.cjs.js +1 -0
  13. package/lib/wip/Panel/Panel.Divider.d.ts +6 -0
  14. package/lib/wip/Panel/Panel.Divider.es.js +18 -0
  15. package/lib/wip/Panel/Panel.Footer.Actions.cjs.js +1 -1
  16. package/lib/wip/Panel/Panel.Footer.Actions.es.js +1 -1
  17. package/lib/wip/Panel/Panel.Footer.cjs.js +1 -1
  18. package/lib/wip/Panel/Panel.Footer.d.ts +12 -1
  19. package/lib/wip/Panel/Panel.Footer.es.js +28 -15
  20. package/lib/wip/Panel/Panel.Header.ContentAfter.cjs.js +1 -1
  21. package/lib/wip/Panel/Panel.Header.ContentAfter.es.js +1 -1
  22. package/lib/wip/Panel/Panel.Header.ContentBefore.cjs.js +1 -1
  23. package/lib/wip/Panel/Panel.Header.ContentBefore.es.js +1 -1
  24. package/lib/wip/Panel/Panel.Header.Description.cjs.js +1 -1
  25. package/lib/wip/Panel/Panel.Header.Description.es.js +1 -1
  26. package/lib/wip/Panel/Panel.Header.Heading.cjs.js +1 -1
  27. package/lib/wip/Panel/Panel.Header.Heading.es.js +1 -1
  28. package/lib/wip/Panel/Panel.Header.Row.cjs.js +1 -1
  29. package/lib/wip/Panel/Panel.Header.Row.es.js +1 -1
  30. package/lib/wip/Panel/Panel.Header.Subheader.cjs.js +1 -1
  31. package/lib/wip/Panel/Panel.Header.Subheader.es.js +1 -1
  32. package/lib/wip/Panel/Panel.Header.cjs.js +1 -1
  33. package/lib/wip/Panel/Panel.Header.d.ts +12 -1
  34. package/lib/wip/Panel/Panel.Header.es.js +37 -24
  35. package/lib/wip/Panel/Panel.Inline.cjs.js +1 -1
  36. package/lib/wip/Panel/Panel.Inline.d.ts +3 -6
  37. package/lib/wip/Panel/Panel.Inline.es.js +62 -70
  38. package/lib/wip/Panel/Panel.Overlay.cjs.js +1 -1
  39. package/lib/wip/Panel/Panel.Overlay.d.ts +3 -2
  40. package/lib/wip/Panel/Panel.Overlay.es.js +23 -22
  41. package/lib/wip/Panel/Panel.cjs.js +1 -1
  42. package/lib/wip/Panel/Panel.d.ts +4 -4
  43. package/lib/wip/Panel/Panel.es.js +69 -60
  44. package/lib/wip/Panel/Panel.helpers.cjs.js +1 -1
  45. package/lib/wip/Panel/Panel.helpers.d.ts +2 -1
  46. package/lib/wip/Panel/Panel.helpers.es.js +8 -7
  47. package/lib/wip/Panel/Panel.types.cjs.js +1 -1
  48. package/lib/wip/Panel/Panel.types.d.ts +11 -1
  49. package/lib/wip/Panel/Panel.types.es.js +5 -1
  50. package/lib/wip/Search/Search.Results.Item.cjs.js +1 -1
  51. package/lib/wip/Search/Search.Results.Item.d.ts +6 -6
  52. package/lib/wip/Search/Search.Results.Item.es.js +5 -6
  53. package/lib/wip/Search/Search.Results.ViewAll.cjs.js +1 -1
  54. package/lib/wip/Search/Search.Results.ViewAll.d.ts +7 -7
  55. package/lib/wip/Search/Search.Results.ViewAll.es.js +2 -2
  56. package/lib/wip/Search/Search.Results.cjs.js +1 -1
  57. package/lib/wip/Search/Search.Results.es.js +3 -5
  58. package/lib/wip/Search/Search.cjs.js +1 -1
  59. package/lib/wip/Search/Search.d.ts +17 -8
  60. package/lib/wip/Search/Search.es.js +175 -157
  61. package/lib/wip/Search/SearchDropdown.cjs.js +1 -1
  62. package/lib/wip/Search/SearchDropdown.es.js +25 -24
  63. package/lib/wip/Search/index.d.ts +4 -1
  64. package/package.json +6 -6
  65. package/chunks/Search.Results.CFA_KEdP.js +0 -1
  66. package/chunks/Search.Results.DVf6WKnI.js +0 -68
  67. package/lib/wip/Search/Search.Results.d.ts +0 -15
  68. package/chunks/{panel.module.DGxSyRdA.js → panel.module.DJLJpnm_.js} +2 -2
@@ -1 +1 @@
1
- "use strict";
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../chunks/constants.hwjHOsvT.js");const e=["00","00-alt","01","02","03"],o=e;exports.PanelDividerColors=o;
@@ -1,4 +1,7 @@
1
1
  import { ComponentPropsWithoutRef } from 'react';
2
+ import { PanelDividerColor, PanelDividerColors } from '@viasat/beam-shared/components/panel';
3
+ export type { PanelDividerColor };
4
+ export { PanelDividerColors };
2
5
  export type PanelKind = 'inline' | 'overlay';
3
6
  export type PanelPosition = 'start' | 'end' | 'bottom' | 'full';
4
7
  export type PanelModalType = 'nonModal' | 'isModal' | 'alert';
@@ -40,7 +43,9 @@ interface BasePanelProps extends ComponentPropsWithoutRef<'aside'> {
40
43
  */
41
44
  onOpenChange?: (open: boolean) => void;
42
45
  /**
43
- * Specify the size of the Panel
46
+ * Specify the size of the Panel.
47
+ * When `position="bottom"`, only `size="full"` has an effect (enables full-viewport height).
48
+ * All other values are ignored for bottom panels — width is always 100%.
44
49
  * @default 'md'
45
50
  */
46
51
  size?: PanelSize;
@@ -71,6 +76,11 @@ interface BasePanelProps extends ComponentPropsWithoutRef<'aside'> {
71
76
  * @default true
72
77
  */
73
78
  divider?: boolean;
79
+ /**
80
+ * Specify the border color of the external divider between panel and page content
81
+ * @default '01'
82
+ */
83
+ dividerColor?: PanelDividerColor;
74
84
  /**
75
85
  * Specify the position of the Panel
76
86
  * 'start' | 'end' | 'bottom' | 'full'
@@ -1 +1,5 @@
1
-
1
+ import "../../../chunks/constants.CKKGf1-i.js";
2
+ const o = ["00", "00-alt", "01", "02", "03"], r = o;
3
+ export {
4
+ r as PanelDividerColors
5
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),c=require("react"),o=require("../../ActionList/ActionList.cjs.js"),e=c.forwardRef(({children:t,...s},r)=>i.jsx(o.ActionList.Item,{ref:r,...s,children:t}));e.displayName="Search.Results.Item";exports.SearchResultsItem=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),o=require("react"),n=require("../../ActionList/ActionList.cjs.js"),s=o.forwardRef(({children:t,...e},i)=>r.jsx(n.ActionList.Item,{ref:i,...e,children:t}));exports.Item=s;
@@ -1,11 +1,11 @@
1
- import { default as React } from 'react';
1
+ import { ComponentPropsWithRef, ElementType, ReactElement } from 'react';
2
2
  import { ActionListItemProps } from '../../ActionList/ActionList.Item';
3
- export type SearchResultsItemProps<C extends React.ElementType = 'div'> = ActionListItemProps<C>;
4
- export declare const SearchResultsItem: SearchResultsItemComponent;
3
+ export type SearchResultsItemProps<C extends ElementType = 'div'> = Omit<ActionListItemProps<C>, 'defaultSelected' | 'kind' | 'onSelectionChange' | 'role'>;
5
4
  interface SearchResultsItemComponent {
6
- <C extends React.ElementType = 'div'>(props: ActionListItemProps<C> & {
7
- ref?: React.ComponentPropsWithRef<C>['ref'];
8
- }): React.ReactElement | null;
5
+ <C extends ElementType = 'div'>(props: ActionListItemProps<C> & {
6
+ ref?: ComponentPropsWithRef<C>['ref'];
7
+ }): ReactElement | null;
9
8
  displayName?: string;
10
9
  }
10
+ export declare const Item: SearchResultsItemComponent;
11
11
  export {};
@@ -1,10 +1,9 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
- import o from "react";
3
- import { ActionList as s } from "../../ActionList/ActionList.es.js";
4
- const a = o.forwardRef(
5
- ({ children: t, ...e }, r) => /* @__PURE__ */ m(s.Item, { ref: r, ...e, children: t })
2
+ import { forwardRef as e } from "react";
3
+ import { ActionList as f } from "../../ActionList/ActionList.es.js";
4
+ const s = e(
5
+ ({ children: r, ...o }, t) => /* @__PURE__ */ m(f.Item, { ref: t, ...o, children: r })
6
6
  );
7
- a.displayName = "Search.Results.Item";
8
7
  export {
9
- a as SearchResultsItem
8
+ s as Item
10
9
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("react");require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");require("clsx");const e=require("../../../chunks/Search.Results.CFA_KEdP.js");require("../../ActionList/ActionList.cjs.js");require("../../Icon/Icon.cjs.js");exports.SearchResultsViewAll=e.SearchResultsViewAll;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("react");require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");require("clsx");const e=require("../../../chunks/Search.Results.BM9NkYBp.js");require("../../ActionList/ActionList.cjs.js");require("../../Icon/Icon.cjs.js");exports.ViewAll=e.ViewAll;
@@ -1,5 +1,5 @@
1
- import { default as React } from 'react';
2
- export type SearchResultsViewAllProps<C extends React.ElementType = 'div'> = {
1
+ import { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType, ReactElement } from 'react';
2
+ export type SearchResultsViewAllProps<C extends ElementType = 'div'> = {
3
3
  /**
4
4
  * Specify a different component to render the item, such as an anchor tag for links
5
5
  *
@@ -11,12 +11,12 @@ export type SearchResultsViewAllProps<C extends React.ElementType = 'div'> = {
11
11
  * 'group' when inside a Search.Results, 'global' when directly inside Search.
12
12
  */
13
13
  variant?: 'group' | 'global';
14
- } & React.ComponentPropsWithoutRef<C>;
15
- export declare const SearchResultsViewAll: SearchResultsViewAllComponent;
14
+ } & ComponentPropsWithoutRef<C>;
16
15
  interface SearchResultsViewAllComponent {
17
- <C extends React.ElementType = 'div'>(props: SearchResultsViewAllProps<C> & {
18
- ref?: React.ComponentPropsWithRef<C>['ref'];
19
- }): React.ReactElement | null;
16
+ <C extends ElementType = 'div'>(props: SearchResultsViewAllProps<C> & {
17
+ ref?: ComponentPropsWithRef<C>['ref'];
18
+ }): ReactElement | null;
20
19
  displayName?: string;
21
20
  }
21
+ export declare const ViewAll: SearchResultsViewAllComponent;
22
22
  export {};
@@ -3,9 +3,9 @@ import "react";
3
3
  import "../../../chunks/classNames.BTJmrO_L.js";
4
4
  import "../../../chunks/constants.CKKGf1-i.js";
5
5
  import "clsx";
6
- import { b as a } from "../../../chunks/Search.Results.DVf6WKnI.js";
6
+ import { V as a } from "../../../chunks/Search.Results.wKBufUSo.js";
7
7
  import "../../ActionList/ActionList.es.js";
8
8
  import "../../Icon/Icon.es.js";
9
9
  export {
10
- a as SearchResultsViewAll
10
+ a as ViewAll
11
11
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("react/jsx-runtime");require("react");require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");require("clsx");const e=require("../../../chunks/Search.Results.CFA_KEdP.js");require("./Search.Results.Item.cjs.js");require("../../ActionList/ActionList.cjs.js");exports.SearchResults=e.SearchResults;exports.SearchResultsComponent=e.SearchResultsComponent;exports.SearchResultsContext=e.SearchResultsContext;exports.default=e.SearchResults;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("react");require("../../../chunks/classNames.DAeKwerT.js");require("../../../chunks/constants.hwjHOsvT.js");require("clsx");const e=require("../../../chunks/Search.Results.BM9NkYBp.js");require("./Search.Results.Item.cjs.js");require("../../ActionList/ActionList.cjs.js");exports.Results=e.Results;exports.SearchResultsContext=e.SearchResultsContext;
@@ -3,12 +3,10 @@ import "react";
3
3
  import "../../../chunks/classNames.BTJmrO_L.js";
4
4
  import "../../../chunks/constants.CKKGf1-i.js";
5
5
  import "clsx";
6
- import { a as c, c as l, d as u, a as h } from "../../../chunks/Search.Results.DVf6WKnI.js";
6
+ import { R, a as l } from "../../../chunks/Search.Results.wKBufUSo.js";
7
7
  import "./Search.Results.Item.es.js";
8
8
  import "../../ActionList/ActionList.es.js";
9
9
  export {
10
- c as SearchResults,
11
- l as SearchResultsComponent,
12
- u as SearchResultsContext,
13
- h as default
10
+ R as Results,
11
+ l as SearchResultsContext
14
12
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),oe=require("../../../chunks/classNames.DAeKwerT.js"),ae=require("../../../chunks/constants.hwjHOsvT.js"),S=require("react"),t=require("../../../chunks/Search.Results.CFA_KEdP.js"),F=require("clsx"),ue=require("../../../chunks/form.context.hesWPMlU.js"),de=require("../../Form/contexts/label.context.cjs.js"),_e=require("../../Form/contexts/helperText.context.cjs.js"),pe=require("../../Form/hooks/useUniversalRef.hook.cjs.js"),q=require("../../Form/hooks/useAccessibleId.hook.cjs.js"),fe=require("../../Icon/Icon.cjs.js"),be=require("./useSearchDropdown.cjs.js"),xe=require("./SearchDropdown.cjs.js"),he=require("../../ActionList/ActionList.cjs.js"),me=require("../../../utils/hooks/useDebounced.cjs.js"),Se=require("../../../utils/hooks/useEffectAfterMount.cjs.js"),qe=require("../../Spinner/Spinner.cjs.js"),ye=require("../../CloseButton/CloseButton.cjs.js"),{baseClassNamePrefix:Ie,subElementClassPrefix:n,classModifierPrefix:_}=oe.getBEMClassNames("search"),je=S.forwardRef(({id:T,defaultValue:H="",value:y,onChange:r,onSearch:C,loading:I=!1,debounce:L=200,onKeyDown:f,label:B,contentAfter:j,contentBefore:D,helperText:P,fluid:V,width:z,theme:v,disabled:i,hideIcon:U,icon:W=t.SvgSearch,error:c,readOnly:a,clearable:N=!0,noResults:k,clearButtonAriaLabel:G="Clear search",className:J,children:w,"aria-describedby":Q,...b},X)=>{const{refFn:Y,ref:Z}=pe.useUniversalRef(X),[O,R]=S.useState(String(H)),u=y!==void 0,o=u?String(y):O,K=e=>{u||R(e.target.value),r==null||r(e)},{immediate:x,debounced:A}=me.useDebounced(C,L),ee=e=>{if(f==null||f(e),e.key==="Enter"){if(e.isDefaultPrevented()||e.isPropagationStopped())return;const{activeIndex:l,elementsRef:ne}=h,m=l!==null?ne.current[l]:null;m&&m.getAttribute("aria-disabled")!=="true"?(e.preventDefault(),m.click()):l===null&&x(o)}e.key==="Escape"&&(!N||h.open)&&e.preventDefault()},{id:d}=q.useAccessibleId(),{id:$}=q.useAccessibleId(),{id:g}=q.useAccessibleId(),E=!!(c!=null&&c.length),M=!!w||!!k,se=F(P&&g,E&&$,Q),{dropdownProps:h,getFieldProps:te,getInputProps:re}=be.useSearchDropdown({enabled:M,disabled:!!i,readOnly:!!a});Se.useEffectAfterMount(()=>{A(o)},[o,A]);const ie=F(t.styles[Ie],v&&ae.themeClassName(v),V&&t.styles[`${_}fluid`],i&&t.styles[`${_}disabled`],a&&t.styles[`${_}read-only`],c&&t.styles[`${_}error`],J),ce=e=>{var l;i||e.target instanceof HTMLInputElement||e.target.closest('button,[role="button"],a,[role="link"]')||(e.preventDefault(),e.stopPropagation(),(l=Z.current)==null||l.focus())},le=S.useCallback(()=>{u?r==null||r({target:{value:"",name:b.name,id:d,type:"search"}}):R(""),x("")},[d,u,r,x,b.name]);return s.jsxs("div",{id:T,className:ie,role:"search",style:{maxWidth:z},"aria-busy":I,children:[s.jsx(de.LabelProvider,{ctxDisabled:!!i,ctxRequired:!1,ctxHtmlFor:d,children:B}),s.jsxs("div",{className:t.styles[`${n}field`],...te({onPointerDown:ce}),children:[!U&&s.jsx(fe.Icon,{icon:W,"aria-hidden":!0}),D&&s.jsx("div",{className:t.styles[`${n}content`],children:D}),s.jsx("input",{id:d,type:"search",className:t.styles[`${n}field__input`],value:o,disabled:i,readOnly:a,"aria-invalid":!!c,"aria-describedby":se,...re({...b,onChange:K,onKeyDown:ee}),ref:Y}),I&&s.jsx("div",{className:t.styles[`${n}field__spinner`],children:s.jsx(qe.Spinner,{size:"xxs"})}),N&&o&&!i&&!a&&s.jsx(ye.CloseButton,{onClick:le,className:`${n}field__clear-button`,size:"sm","aria-label":G}),j&&s.jsx("div",{className:t.styles[`${n}content`],children:j})]}),s.jsxs(_e.HelperTextProvider,{ctxId:g,ctxDisabled:!!i,children:[P,E&&s.jsx(ue.HelperText,{id:$,appearance:"negative",children:c})]}),M&&s.jsx(xe.SearchDropdown,{...h,children:s.jsx(he.ActionList,{role:"listbox",noResults:k,children:w})})]})}),p=je;p.Results=t.SearchResults;p.displayName="Search";exports.Search=p;exports.default=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),be=require("../../../chunks/classNames.DAeKwerT.js"),_e=require("../../../chunks/constants.hwjHOsvT.js"),S=require("react"),t=require("../../../chunks/Search.Results.BM9NkYBp.js"),V=require("clsx"),pe=require("../../../chunks/form.context.hesWPMlU.js"),fe=require("../../Form/contexts/label.context.cjs.js"),xe=require("../../Form/contexts/helperText.context.cjs.js"),me=require("../../Form/hooks/useUniversalRef.hook.cjs.js"),_=require("../../Form/hooks/useAccessibleId.hook.cjs.js"),he=require("../../Icon/Icon.cjs.js"),ye=require("./useSearchDropdown.cjs.js"),Se=require("./SearchDropdown.cjs.js"),Ie=require("../../ActionList/ActionList.cjs.js"),qe=require("../../../utils/hooks/useDebounced.cjs.js"),Re=require("../../../utils/hooks/useEffectAfterMount.cjs.js"),je=require("../../Spinner/Spinner.cjs.js"),Ne=require("../../CloseButton/CloseButton.cjs.js"),{baseClassNamePrefix:De,subElementClassPrefix:c,classModifierPrefix:p}=be.getBEMClassNames("search"),n=S.forwardRef(({id:C,defaultValue:z="",value:I,onChange:i,onSearch:U,loading:q=!1,debounce:W=200,onKeyDown:f,label:R,contentAfter:j,contentBefore:N,helperText:D,fluid:G,width:J,theme:P,disabled:r,hideIcon:Q,icon:X=t.SvgSearch,error:l,readOnly:u,clearable:v=!0,noResults:w,clearButtonAriaLabel:Y="Clear search",className:Z,children:A,"aria-describedby":O,"aria-labelledby":K,"aria-label":k,...x},ee)=>{const{refFn:se,ref:te}=me.useUniversalRef(ee),[ie,$]=S.useState(String(z)),d=I!==void 0,o=d?String(I):ie,re=e=>{d||$(e.target.value),i==null||i(e)},{immediate:m,debounced:g}=qe.useDebounced(U,W),le=e=>{if(f==null||f(e),e.key==="Enter"){if(e.isDefaultPrevented()||e.isPropagationStopped())return;const{activeIndex:a,elementsRef:de}=h,y=a!==null?de.current[a]:null;y&&y.getAttribute("aria-disabled")!=="true"?(e.preventDefault(),y.click()):a===null&&m(o)}e.key==="Escape"&&(!v||h.open)&&e.preventDefault()},{id:b}=_.useAccessibleId(),{id:E}=_.useAccessibleId(),{id:F}=_.useAccessibleId(),{id:M}=_.useAccessibleId(),T=!!(l!=null&&l.length),H=!!A||!!w,B=V(D&&M,T&&F,O),L=K??(R?E:void 0),{dropdownProps:h,getFieldProps:ae,getInputProps:ce}=ye.useSearchDropdown({enabled:H,disabled:!!r,readOnly:!!u});Re.useEffectAfterMount(()=>{g(o)},[o,g]);const ne=V(t.styles[De],P&&_e.themeClassName(P),G&&t.styles[`${p}fluid`],r&&t.styles[`${p}disabled`],u&&t.styles[`${p}read-only`],l&&t.styles[`${p}error`],Z),oe=e=>{var a;r||e.target instanceof HTMLInputElement||e.target.closest('button,[role="button"],a,[role="link"]')||(e.preventDefault(),e.stopPropagation(),(a=te.current)==null||a.focus())},ue=S.useCallback(()=>{d?i==null||i({target:{value:"",name:x.name,id:b,type:"search"}}):$(""),m("")},[b,d,i,m,x.name]);return s.jsxs("div",{id:C,className:ne,role:"search",style:{maxWidth:J},"aria-labelledby":L,"aria-label":k,"aria-describedby":B,"aria-busy":q,children:[s.jsx(fe.LabelProvider,{ctxDisabled:!!r,ctxRequired:!1,ctxHtmlFor:b,ctxId:E,children:R}),s.jsxs("div",{className:t.styles[`${c}field`],...ae({onPointerDown:oe}),children:[!Q&&s.jsx(he.Icon,{icon:X,"aria-hidden":!0}),N&&s.jsx("div",{className:t.styles[`${c}content`],children:N}),s.jsx("input",{id:b,type:"search",className:t.styles[`${c}field__input`],value:o,disabled:r,readOnly:u,"aria-invalid":!!l,"aria-labelledby":L,"aria-label":k,"aria-describedby":B,...ce({...x,onChange:re,onKeyDown:le}),ref:se}),q&&s.jsx("div",{className:t.styles[`${c}field__spinner`],children:s.jsx(je.Spinner,{size:"xxs"})}),v&&o&&!r&&!u&&s.jsx(Ne.CloseButton,{onClick:ue,className:`${c}field__clear-button`,size:"sm","aria-label":Y}),j&&s.jsx("div",{className:t.styles[`${c}content`],children:j})]}),s.jsxs(xe.HelperTextProvider,{ctxId:M,ctxDisabled:!!r,children:[D,T&&s.jsx(pe.HelperText,{id:F,appearance:"negative",children:l})]}),H&&s.jsx(Se.SearchDropdown,{...h,children:s.jsx(Ie.ActionList,{role:"listbox",noResults:w,children:A})})]})});n.displayName="Search";n.Results=t.Results;n.Results.displayName="Search.Results";n.Results.Item.displayName="Search.Results.Item";n.Results.ViewAll.displayName="Search.Results.ViewAll";exports.Search=n;
@@ -1,11 +1,11 @@
1
1
  import { ThemeTypes } from '@viasat/beam-shared/utils';
2
2
  import { Nullable } from '@viasat/beam-shared/utils/types';
3
- import { default as React } from 'react';
4
- import { default as Results } from './Search.Results';
3
+ import { default as React, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes } from 'react';
4
+ import { Results } from './Search.Results';
5
5
  import { IconComponentType } from '../../../utils/types';
6
6
  export interface SearchProps extends React.ComponentPropsWithRef<'input'> {
7
7
  /**
8
- * Specify a callback called whenever a search is conducted
8
+ * Specify a callback that gets called whenever a search is conducted
9
9
  */
10
10
  onSearch: (query: string) => void;
11
11
  /**
@@ -72,17 +72,26 @@ export interface SearchProps extends React.ComponentPropsWithRef<'input'> {
72
72
  noResults?: string;
73
73
  /**
74
74
  * Aria label for the clear button
75
- * @default 'Clear search'
75
+ * @default Clear search
76
76
  */
77
77
  clearButtonAriaLabel?: string;
78
+ /**
79
+ * Specify if Search displays in a disabled state
80
+ * @default false
81
+ */
82
+ disabled?: boolean;
78
83
  /**
79
84
  * Specify the theme of the Search. By default it inherits the theme from the parent
80
85
  */
81
86
  theme?: ThemeTypes;
87
+ /**
88
+ * Speficy the Search results to display in the Search dropdown
89
+ * (see Search.Results)
90
+ */
82
91
  children?: React.ReactNode;
83
92
  }
84
- declare const SearchComponent: React.ForwardRefExoticComponent<Omit<SearchProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
85
- export declare const Search: typeof SearchComponent & {
93
+ interface SearchComponent extends ForwardRefExoticComponent<PropsWithoutRef<SearchProps> & RefAttributes<HTMLInputElement>> {
86
94
  Results: typeof Results;
87
- };
88
- export default Search;
95
+ }
96
+ export declare const Search: SearchComponent;
97
+ export {};
@@ -1,161 +1,179 @@
1
1
  import { jsxs as S, jsx as t } from "react/jsx-runtime";
2
- import { g as ne } from "../../../chunks/classNames.BTJmrO_L.js";
3
- import { t as me } from "../../../chunks/constants.CKKGf1-i.js";
4
- import C, { useCallback as de } from "react";
5
- import { s as r, S as fe, a as ue } from "../../../chunks/Search.Results.DVf6WKnI.js";
6
- import F from "clsx";
7
- import { H as pe } from "../../../chunks/form.context.D7b4066_.js";
8
- import { LabelProvider as he } from "../../Form/contexts/label.context.es.js";
9
- import { HelperTextProvider as be } from "../../Form/contexts/helperText.context.es.js";
10
- import { useUniversalRef as xe } from "../../Form/hooks/useUniversalRef.hook.es.js";
11
- import { useAccessibleId as I } from "../../Form/hooks/useAccessibleId.hook.es.js";
12
- import { Icon as Se } from "../../Icon/Icon.es.js";
13
- import { useSearchDropdown as Ie } from "./useSearchDropdown.es.js";
14
- import { SearchDropdown as Pe } from "./SearchDropdown.es.js";
15
- import { ActionList as De } from "../../ActionList/ActionList.es.js";
16
- import { useDebounced as Ne } from "../../../utils/hooks/useDebounced.es.js";
17
- import { useEffectAfterMount as ve } from "../../../utils/hooks/useEffectAfterMount.es.js";
18
- import { Spinner as $e } from "../../Spinner/Spinner.es.js";
19
- import { CloseButton as ye } from "../../CloseButton/CloseButton.es.js";
20
- const { baseClassNamePrefix: ge, subElementClassPrefix: l, classModifierPrefix: f } = ne("search"), Re = C.forwardRef(({
21
- id: T,
22
- defaultValue: j = "",
23
- value: P,
24
- onChange: s,
25
- onSearch: q,
26
- loading: D = !1,
27
- debounce: z = 200,
28
- onKeyDown: u,
29
- label: B,
30
- contentAfter: N,
31
- contentBefore: v,
32
- helperText: $,
33
- fluid: V,
34
- width: U,
35
- theme: y,
36
- disabled: i,
37
- hideIcon: W,
38
- icon: G = fe,
39
- error: a,
40
- readOnly: n,
41
- clearable: g = !0,
42
- noResults: R,
43
- clearButtonAriaLabel: J = "Clear search",
44
- className: Q,
45
- children: _,
46
- "aria-describedby": X,
47
- ...p
48
- }, Y) => {
49
- const { refFn: Z, ref: K } = xe(Y), [O, E] = C.useState(String(j)), m = P !== void 0, c = m ? String(P) : O, ee = (e) => {
50
- m || E(e.target.value), s == null || s(e);
51
- }, { immediate: h, debounced: k } = Ne(q, z), te = (e) => {
52
- if (u == null || u(e), e.key === "Enter") {
53
- if (e.isDefaultPrevented() || e.isPropagationStopped())
54
- return;
55
- const { activeIndex: o, elementsRef: ce } = b, x = o !== null ? ce.current[o] : null;
56
- x && x.getAttribute("aria-disabled") !== "true" ? (e.preventDefault(), x.click()) : o === null && h(c);
57
- }
58
- e.key === "Escape" && (!g || b.open) && e.preventDefault();
59
- }, { id: d } = I(), { id: w } = I(), { id: H } = I(), M = !!(a != null && a.length), A = !!_ || !!R, re = F(
60
- $ && H,
61
- M && w,
62
- X
63
- ), {
64
- dropdownProps: b,
65
- getFieldProps: se,
66
- getInputProps: ie
67
- } = Ie({
68
- enabled: A,
69
- disabled: !!i,
70
- readOnly: !!n
71
- });
72
- ve(() => {
73
- k(c);
74
- }, [c, k]);
75
- const ae = F(
76
- r[ge],
77
- y && me(y),
78
- V && r[`${f}fluid`],
79
- i && r[`${f}disabled`],
80
- n && r[`${f}read-only`],
81
- a && r[`${f}error`],
82
- Q
83
- ), oe = (e) => {
84
- var o;
85
- i || e.target instanceof HTMLInputElement || e.target.closest('button,[role="button"],a,[role="link"]') || (e.preventDefault(), e.stopPropagation(), (o = K.current) == null || o.focus());
86
- }, le = de(() => {
87
- m ? s == null || s({
88
- target: {
89
- value: "",
90
- name: p.name,
91
- id: d,
92
- type: "search"
2
+ import { g as ue } from "../../../chunks/classNames.BTJmrO_L.js";
3
+ import { t as fe } from "../../../chunks/constants.CKKGf1-i.js";
4
+ import pe, { forwardRef as be, useCallback as he } from "react";
5
+ import { s as r, S as xe, R as Ie } from "../../../chunks/Search.Results.wKBufUSo.js";
6
+ import q from "clsx";
7
+ import { H as ye } from "../../../chunks/form.context.D7b4066_.js";
8
+ import { LabelProvider as Se } from "../../Form/contexts/label.context.es.js";
9
+ import { HelperTextProvider as Ne } from "../../Form/contexts/helperText.context.es.js";
10
+ import { useUniversalRef as Re } from "../../Form/hooks/useUniversalRef.hook.es.js";
11
+ import { useAccessibleId as f } from "../../Form/hooks/useAccessibleId.hook.es.js";
12
+ import { Icon as Pe } from "../../Icon/Icon.es.js";
13
+ import { useSearchDropdown as ve } from "./useSearchDropdown.es.js";
14
+ import { SearchDropdown as De } from "./SearchDropdown.es.js";
15
+ import { ActionList as $e } from "../../ActionList/ActionList.es.js";
16
+ import { useDebounced as ge } from "../../../utils/hooks/useDebounced.es.js";
17
+ import { useEffectAfterMount as _e } from "../../../utils/hooks/useEffectAfterMount.es.js";
18
+ import { Spinner as we } from "../../Spinner/Spinner.es.js";
19
+ import { CloseButton as Ee } from "../../CloseButton/CloseButton.es.js";
20
+ const { baseClassNamePrefix: ke, subElementClassPrefix: o, classModifierPrefix: p } = ue("search"), n = be(
21
+ ({
22
+ id: z,
23
+ defaultValue: C = "",
24
+ value: N,
25
+ onChange: a,
26
+ onSearch: U,
27
+ loading: R = !1,
28
+ debounce: W = 200,
29
+ onKeyDown: b,
30
+ label: P,
31
+ contentAfter: v,
32
+ contentBefore: D,
33
+ helperText: $,
34
+ fluid: G,
35
+ width: J,
36
+ theme: g,
37
+ disabled: s,
38
+ hideIcon: Q,
39
+ icon: X = xe,
40
+ error: i,
41
+ readOnly: d,
42
+ clearable: _ = !0,
43
+ noResults: w,
44
+ clearButtonAriaLabel: Y = "Clear search",
45
+ className: Z,
46
+ children: E,
47
+ "aria-describedby": K,
48
+ "aria-labelledby": O,
49
+ "aria-label": k,
50
+ ...h
51
+ }, ee) => {
52
+ const { refFn: te, ref: re } = Re(ee), [ae, A] = pe.useState(String(C)), m = N !== void 0, c = m ? String(N) : ae, se = (e) => {
53
+ m || A(e.target.value), a == null || a(e);
54
+ }, { immediate: x, debounced: H } = ge(U, W), ie = (e) => {
55
+ if (b == null || b(e), e.key === "Enter") {
56
+ if (e.isDefaultPrevented() || e.isPropagationStopped())
57
+ return;
58
+ const { activeIndex: l, elementsRef: me } = I, y = l !== null ? me.current[l] : null;
59
+ y && y.getAttribute("aria-disabled") !== "true" ? (e.preventDefault(), y.click()) : l === null && x(c);
93
60
  }
94
- }) : E(""), h("");
95
- }, [d, m, s, h, p.name]);
96
- return /* @__PURE__ */ S(
97
- "div",
98
- {
99
- id: T,
100
- className: ae,
101
- role: "search",
102
- style: { maxWidth: U },
103
- "aria-busy": D,
104
- children: [
105
- /* @__PURE__ */ t(
106
- he,
107
- {
108
- ctxDisabled: !!i,
109
- ctxRequired: !1,
110
- ctxHtmlFor: d,
111
- children: B
112
- }
113
- ),
114
- /* @__PURE__ */ S(
115
- "div",
116
- {
117
- className: r[`${l}field`],
118
- ...se({ onPointerDown: oe }),
119
- children: [
120
- !W && /* @__PURE__ */ t(Se, { icon: G, "aria-hidden": !0 }),
121
- v && /* @__PURE__ */ t("div", { className: r[`${l}content`], children: v }),
122
- /* @__PURE__ */ t(
123
- "input",
124
- {
125
- id: d,
126
- type: "search",
127
- className: r[`${l}field__input`],
128
- value: c,
129
- disabled: i,
130
- readOnly: n,
131
- "aria-invalid": !!a,
132
- "aria-describedby": re,
133
- ...ie({
134
- ...p,
135
- onChange: ee,
136
- onKeyDown: te
137
- }),
138
- ref: Z
139
- }
140
- ),
141
- D && /* @__PURE__ */ t("div", { className: r[`${l}field__spinner`], children: /* @__PURE__ */ t($e, { size: "xxs" }) }),
142
- g && c && !i && !n && /* @__PURE__ */ t(ye, { onClick: le, className: `${l}field__clear-button`, size: "sm", "aria-label": J }),
143
- N && /* @__PURE__ */ t("div", { className: r[`${l}content`], children: N })
144
- ]
145
- }
146
- ),
147
- /* @__PURE__ */ S(be, { ctxId: H, ctxDisabled: !!i, children: [
148
- $,
149
- M && /* @__PURE__ */ t(pe, { id: w, appearance: "negative", children: a })
150
- ] }),
151
- A && /* @__PURE__ */ t(Pe, { ...b, children: /* @__PURE__ */ t(De, { role: "listbox", noResults: R, children: _ }) })
152
- ]
153
- }
154
- );
155
- }), L = Re;
156
- L.Results = ue;
157
- L.displayName = "Search";
61
+ e.key === "Escape" && (!_ || I.open) && e.preventDefault();
62
+ }, { id: u } = f(), { id: M } = f(), { id: V } = f(), { id: B } = f(), F = !!(i != null && i.length), L = !!E || !!w, T = q(
63
+ $ && B,
64
+ F && V,
65
+ K
66
+ ), j = O ?? (P ? M : void 0), { dropdownProps: I, getFieldProps: le, getInputProps: oe } = ve({
67
+ enabled: L,
68
+ disabled: !!s,
69
+ readOnly: !!d
70
+ });
71
+ _e(() => {
72
+ H(c);
73
+ }, [c, H]);
74
+ const ce = q(
75
+ r[ke],
76
+ g && fe(g),
77
+ G && r[`${p}fluid`],
78
+ s && r[`${p}disabled`],
79
+ d && r[`${p}read-only`],
80
+ i && r[`${p}error`],
81
+ Z
82
+ ), ne = (e) => {
83
+ var l;
84
+ s || e.target instanceof HTMLInputElement || e.target.closest(
85
+ 'button,[role="button"],a,[role="link"]'
86
+ ) || (e.preventDefault(), e.stopPropagation(), (l = re.current) == null || l.focus());
87
+ }, de = he(() => {
88
+ m ? a == null || a({
89
+ target: {
90
+ value: "",
91
+ name: h.name,
92
+ id: u,
93
+ type: "search"
94
+ }
95
+ }) : A(""), x("");
96
+ }, [u, m, a, x, h.name]);
97
+ return /* @__PURE__ */ S(
98
+ "div",
99
+ {
100
+ id: z,
101
+ className: ce,
102
+ role: "search",
103
+ style: { maxWidth: J },
104
+ "aria-labelledby": j,
105
+ "aria-label": k,
106
+ "aria-describedby": T,
107
+ "aria-busy": R,
108
+ children: [
109
+ /* @__PURE__ */ t(
110
+ Se,
111
+ {
112
+ ctxDisabled: !!s,
113
+ ctxRequired: !1,
114
+ ctxHtmlFor: u,
115
+ ctxId: M,
116
+ children: P
117
+ }
118
+ ),
119
+ /* @__PURE__ */ S(
120
+ "div",
121
+ {
122
+ className: r[`${o}field`],
123
+ ...le({ onPointerDown: ne }),
124
+ children: [
125
+ !Q && /* @__PURE__ */ t(Pe, { icon: X, "aria-hidden": !0 }),
126
+ D && /* @__PURE__ */ t("div", { className: r[`${o}content`], children: D }),
127
+ /* @__PURE__ */ t(
128
+ "input",
129
+ {
130
+ id: u,
131
+ type: "search",
132
+ className: r[`${o}field__input`],
133
+ value: c,
134
+ disabled: s,
135
+ readOnly: d,
136
+ "aria-invalid": !!i,
137
+ "aria-labelledby": j,
138
+ "aria-label": k,
139
+ "aria-describedby": T,
140
+ ...oe({
141
+ ...h,
142
+ onChange: se,
143
+ onKeyDown: ie
144
+ }),
145
+ ref: te
146
+ }
147
+ ),
148
+ R && /* @__PURE__ */ t("div", { className: r[`${o}field__spinner`], children: /* @__PURE__ */ t(we, { size: "xxs" }) }),
149
+ _ && c && !s && !d && /* @__PURE__ */ t(
150
+ Ee,
151
+ {
152
+ onClick: de,
153
+ className: `${o}field__clear-button`,
154
+ size: "sm",
155
+ "aria-label": Y
156
+ }
157
+ ),
158
+ v && /* @__PURE__ */ t("div", { className: r[`${o}content`], children: v })
159
+ ]
160
+ }
161
+ ),
162
+ /* @__PURE__ */ S(Ne, { ctxId: B, ctxDisabled: !!s, children: [
163
+ $,
164
+ F && /* @__PURE__ */ t(ye, { id: V, appearance: "negative", children: i })
165
+ ] }),
166
+ L && /* @__PURE__ */ t(De, { ...I, children: /* @__PURE__ */ t($e, { role: "listbox", noResults: w, children: E }) })
167
+ ]
168
+ }
169
+ );
170
+ }
171
+ );
172
+ n.displayName = "Search";
173
+ n.Results = Ie;
174
+ n.Results.displayName = "Search.Results";
175
+ n.Results.Item.displayName = "Search.Results.Item";
176
+ n.Results.ViewAll.displayName = "Search.Results.ViewAll";
158
177
  export {
159
- L as Search,
160
- L as default
178
+ n as Search
161
179
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),_=require("@floating-ui/react"),d=require("../../Box/Box.cjs.js"),h=require("clsx"),o=require("../../../chunks/classNames.DAeKwerT.js"),q=require("../../../chunks/constants.hwjHOsvT.js"),S=require("../../ActionList/ActionList.context.cjs.js"),N=require("react"),b=require("../../../chunks/floatingui.module.D3Aw_aYe.js"),g=require("../../../chunks/popover.module.DGUJIXrP.js"),s=require("../../../chunks/Search.Results.CFA_KEdP.js"),{baseClassNamePrefix:B}=o.getBEMClassNames("floatingui"),{baseClassNamePrefix:P}=o.getBEMClassNames("popover"),v=[s.SearchResults,s.SearchResults.Item,s.SearchResults.ViewAll],w=({setOpen:t,isMounted:l,getFloatingProps:a,floatingStyles:i,labelsRef:c,elementsRef:n,getItemProps:u,setFloating:m,theme:r,className:x,children:f,activeIndex:p})=>{const C=N.useCallback(()=>t(!1),[t]);return l?e.jsx(_.FloatingPortal,{children:e.jsx(d.Box,{className:h(r&&q.themeClassName(r),b.floatinguiStyles[B],g.popoverStyles[P],x),...a(),style:i,ref:m,children:e.jsx(S.ActionListContextProvider,{allowChildrenTypes:v,getItemProps:u,itemsFocusable:!1,onItemClick:C,labelsRef:c,elementsRef:n,activeIndex:p,children:f})})}):null};exports.SearchDropdown=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),p=require("@floating-ui/react"),_=require("../../Box/Box.cjs.js"),q=require("clsx"),t=require("../../../chunks/classNames.DAeKwerT.js"),N=require("../../../chunks/constants.hwjHOsvT.js"),b=require("../../ActionList/ActionList.context.cjs.js"),g=require("react"),e=require("../../../chunks/Search.Results.BM9NkYBp.js"),h=require("../../../chunks/floatingui.module.D3Aw_aYe.js"),B=require("../../../chunks/popover.module.DGUJIXrP.js"),{baseClassNamePrefix:P}=t.getBEMClassNames("floatingui"),{baseClassNamePrefix:S}=t.getBEMClassNames("popover"),{subElementClassPrefix:w}=t.getBEMClassNames("search"),y=[e.Results,e.Results.Item,e.Results.ViewAll],v=({setOpen:o,isMounted:r,getFloatingProps:a,floatingStyles:i,labelsRef:n,elementsRef:c,getItemProps:u,setFloating:m,theme:l,className:x,children:f,activeIndex:C})=>{const d=g.useCallback(()=>o(!1),[o]);return r?s.jsx(p.FloatingPortal,{children:s.jsx(_.Box,{className:q(l&&N.themeClassName(l),h.floatinguiStyles[P],B.popoverStyles[S],e.styles[`${w}dropdown`],x),...a(),style:i,ref:m,children:s.jsx(b.ActionListContextProvider,{allowChildrenTypes:y,getItemProps:u,itemsFocusable:!1,onItemClick:d,labelsRef:n,elementsRef:c,activeIndex:C,children:f})})}):null};exports.SearchDropdown=v;