@viasat/beam-react 2.2.1 → 2.8.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.
- package/assets/ActionList.css +1 -1
- package/assets/Checkbox.css +1 -1
- package/assets/RadioButton.css +1 -1
- package/assets/Search.Results.css +1 -0
- package/assets/card.css +1 -1
- package/assets/panel.css +1 -0
- package/chunks/ActionList.Group.B4PX5SKS.js +111 -0
- package/chunks/ActionList.Group.C2R56u2A.js +1 -0
- package/chunks/ActionList.Item.5Y-SwzjK.js +1 -0
- package/chunks/{ActionList.Item.Dg_KHGsm.js → ActionList.Item.BFcT86lS.js} +3 -2
- package/chunks/Search.Results.Item.CLmMBPz1.js +41 -0
- package/chunks/Search.Results.Item.Dkh2yo4p.js +1 -0
- package/chunks/card.module.8KnCe1uR.js +1 -0
- package/chunks/{card.module.Dy87qmTH.js → card.module.ByBYpexJ.js} +12 -6
- package/chunks/dom.DGM-dxLe.js +21 -0
- package/chunks/dom.zgzOBFUw.js +1 -0
- package/chunks/{form.context.B1PXIJNq.js → form.context.B26th8Od.js} +1 -1
- package/chunks/{form.context.CNWjF5qA.js → form.context.CfsTSQpm.js} +1 -1
- package/chunks/panel.module.DbEoAg1J.js +1 -0
- package/chunks/panel.module.RGiUyC84.js +30 -0
- package/chunks/tokens.BD_71qmL.js +19 -0
- package/chunks/tokens.Bc11gmpN.js +1 -0
- package/index.cjs.js +1 -1
- package/index.es.js +17 -15
- package/lib/ActionList/ActionList.Group.cjs.js +1 -1
- package/lib/ActionList/ActionList.Group.d.ts +7 -4
- package/lib/ActionList/ActionList.Group.es.js +2 -2
- package/lib/ActionList/ActionList.IconButton.cjs.js +1 -1
- package/lib/ActionList/ActionList.IconButton.es.js +1 -1
- package/lib/ActionList/ActionList.Item.cjs.js +1 -1
- package/lib/ActionList/ActionList.Item.es.js +3 -3
- package/lib/ActionList/ActionList.cjs.js +1 -1
- package/lib/ActionList/ActionList.d.ts +1 -1
- package/lib/ActionList/ActionList.es.js +54 -54
- package/lib/ActionList/useActionListChildren.cjs.js +1 -1
- package/lib/ActionList/useActionListChildren.es.js +2 -2
- package/lib/Autocomplete/Autocomplete.cjs.js +1 -1
- package/lib/Autocomplete/Autocomplete.es.js +1 -1
- package/lib/Autocomplete/AutocompleteDropdown.cjs.js +1 -1
- package/lib/Autocomplete/AutocompleteDropdown.es.js +1 -1
- package/lib/Autocomplete/useAutocompleteA11y.cjs.js +1 -1
- package/lib/Autocomplete/useAutocompleteA11y.es.js +1 -1
- package/lib/Autocomplete/useAutocompleteDropdown.cjs.js +1 -1
- package/lib/Autocomplete/useAutocompleteDropdown.es.js +1 -1
- package/lib/Box/utils.cjs.js +1 -0
- package/lib/Box/utils.d.ts +6 -0
- package/lib/Box/utils.es.js +12 -0
- package/lib/Button/Button.cjs.js +1 -1
- package/lib/Button/Button.es.js +1 -1
- package/lib/Card/Card.Body.cjs.js +1 -1
- package/lib/Card/Card.Body.es.js +1 -1
- package/lib/Card/Card.Content.cjs.js +1 -1
- package/lib/Card/Card.Content.es.js +12 -17
- package/lib/Card/Card.Footer.cjs.js +1 -1
- package/lib/Card/Card.Footer.d.ts +1 -1
- package/lib/Card/Card.Footer.es.js +1 -1
- package/lib/Card/Card.Header.cjs.js +1 -1
- package/lib/Card/Card.Header.es.js +1 -1
- package/lib/Card/Card.Media.cjs.js +1 -1
- package/lib/Card/Card.Media.es.js +1 -1
- package/lib/Card/Card.cjs.js +1 -1
- package/lib/Card/Card.d.ts +61 -18
- package/lib/Card/Card.es.js +181 -82
- package/lib/Card/CardContext.cjs.js +1 -1
- package/lib/Card/CardContext.d.ts +10 -8
- package/lib/Card/CardContext.es.js +7 -12
- package/lib/Card/CardGroup.cjs.js +1 -0
- package/lib/Card/CardGroup.d.ts +55 -0
- package/lib/Card/CardGroup.es.js +67 -0
- package/lib/Card/card.utils.cjs.js +1 -0
- package/lib/Card/card.utils.d.ts +7 -0
- package/lib/Card/card.utils.es.js +14 -0
- package/lib/Card/index.cjs.js +1 -1
- package/lib/Card/index.d.ts +9 -1
- package/lib/Card/index.es.js +4 -2
- package/lib/Card/useCardGroup.cjs.js +1 -0
- package/lib/Card/useCardGroup.d.ts +27 -0
- package/lib/Card/useCardGroup.es.js +42 -0
- package/lib/Card/useCardGroupValue.cjs.js +1 -0
- package/lib/Card/useCardGroupValue.d.ts +14 -0
- package/lib/Card/useCardGroupValue.es.js +29 -0
- package/lib/Checkbox/Checkbox.cjs.js +1 -1
- package/lib/Checkbox/Checkbox.es.js +1 -1
- package/lib/Dialog/Dialog.Trigger.cjs.js +1 -1
- package/lib/Dialog/Dialog.Trigger.es.js +7 -6
- package/lib/EmptyState/EmptyState.cjs.js +1 -1
- package/lib/EmptyState/EmptyState.es.js +1 -1
- package/lib/FileUpload/FileUpload.List.Item.cjs.js +1 -1
- package/lib/FileUpload/FileUpload.List.Item.es.js +20 -20
- package/lib/FileUpload/FileUpload.cjs.js +1 -1
- package/lib/FileUpload/FileUpload.es.js +1 -1
- package/lib/FloatingUI/index.cjs.js +1 -1
- package/lib/FloatingUI/index.d.ts +1 -0
- package/lib/FloatingUI/index.es.js +7 -5
- package/lib/FloatingUI/useBlur.cjs.js +1 -0
- package/lib/FloatingUI/useBlur.d.ts +8 -0
- package/lib/FloatingUI/useBlur.es.js +15 -0
- package/lib/FloatingUI/useTyping.cjs.js +1 -0
- package/lib/FloatingUI/useTyping.d.ts +10 -0
- package/lib/FloatingUI/useTyping.es.js +42 -0
- package/lib/Form/Form.cjs.js +1 -1
- package/lib/Form/Form.es.js +1 -1
- package/lib/Form/contexts/form.context.cjs.js +1 -1
- package/lib/Form/contexts/form.context.es.js +1 -1
- package/lib/Form/contexts/index.cjs.js +1 -1
- package/lib/Form/contexts/index.es.js +1 -1
- package/lib/Form/hooks/index.cjs.js +1 -1
- package/lib/Form/hooks/index.es.js +1 -1
- package/lib/Form/hooks/useFieldValidator.hook.cjs.js +1 -1
- package/lib/Form/hooks/useFieldValidator.hook.es.js +2 -2
- package/lib/HelperText/HelperText.cjs.js +1 -1
- package/lib/HelperText/HelperText.es.js +1 -1
- package/lib/HelperText/index.cjs.js +1 -1
- package/lib/HelperText/index.es.js +1 -1
- package/lib/InputChoiceGroup/InputChoiceGroup.cjs.js +1 -1
- package/lib/InputChoiceGroup/InputChoiceGroup.es.js +1 -1
- package/lib/Label/Label.cjs.js +1 -1
- package/lib/Label/Label.es.js +1 -1
- package/lib/Link/Link.cjs.js +1 -1
- package/lib/Link/Link.es.js +6 -6
- package/lib/NativeSelect/NativeSelect.cjs.js +1 -1
- package/lib/NativeSelect/NativeSelect.es.js +1 -1
- package/lib/Popover/Popover.cjs.js +1 -1
- package/lib/Popover/Popover.es.js +1 -1
- package/lib/Popover/Popover.trigger.cjs.js +1 -1
- package/lib/Popover/Popover.trigger.es.js +7 -6
- package/lib/Popover/Popover.utils.cjs.js +1 -1
- package/lib/Popover/Popover.utils.es.js +1 -1
- package/lib/ProgressBar/ProgressBar.cjs.js +1 -1
- package/lib/ProgressBar/ProgressBar.es.js +1 -1
- package/lib/RadioButton/RadioButton.cjs.js +1 -1
- package/lib/RadioButton/RadioButton.es.js +1 -1
- package/lib/Select/Select.cjs.js +1 -1
- package/lib/Select/Select.es.js +1 -1
- package/lib/Select/SelectDropdown.cjs.js +1 -1
- package/lib/Select/SelectDropdown.es.js +1 -1
- package/lib/Select/useSelectA11y.cjs.js +1 -1
- package/lib/Select/useSelectA11y.es.js +1 -1
- package/lib/SideNav/SideNavActionListGroup.cjs.js +1 -1
- package/lib/SideNav/SideNavActionListGroup.es.js +1 -1
- package/lib/SideNav/SideNavActionListItem.cjs.js +1 -1
- package/lib/SideNav/SideNavActionListItem.es.js +1 -1
- package/lib/SideNav/SideNavActionListItemExpandable.cjs.js +1 -1
- package/lib/SideNav/SideNavActionListItemExpandable.es.js +1 -1
- package/lib/SideNav/SideNavActionListItemFlyout.cjs.js +1 -1
- package/lib/SideNav/SideNavActionListItemFlyout.es.js +1 -1
- package/lib/Slider/DualSlider.cjs.js +1 -1
- package/lib/Slider/DualSlider.d.ts +1 -1
- package/lib/Slider/DualSlider.es.js +73 -72
- package/lib/Slider/SingleSlider.cjs.js +1 -1
- package/lib/Slider/SingleSlider.d.ts +1 -1
- package/lib/Slider/SingleSlider.es.js +52 -51
- package/lib/Slider/Slider.Error.cjs.js +1 -1
- package/lib/Slider/Slider.Error.es.js +1 -1
- package/lib/Slider/Slider.Thumb.cjs.js +1 -1
- package/lib/Slider/Slider.Thumb.es.js +1 -1
- package/lib/Slider/Slider.cjs.js +1 -1
- package/lib/Slider/Slider.d.ts +1 -3
- package/lib/Slider/Slider.es.js +13 -11
- package/lib/Slider/Slider.types.d.ts +1 -1
- package/lib/Slider/hooks/useSliderBase.cjs.js +1 -1
- package/lib/Slider/hooks/useSliderBase.es.js +1 -1
- package/lib/Switch/Switch.cjs.js +1 -1
- package/lib/Switch/Switch.es.js +1 -1
- package/lib/Tabs/Tabs.Group.cjs.js +1 -1
- package/lib/Tabs/Tabs.Group.es.js +1 -1
- package/lib/TextArea/TextArea.cjs.js +1 -1
- package/lib/TextArea/TextArea.es.js +1 -1
- package/lib/TextField/TextField.cjs.js +1 -1
- package/lib/TextField/TextField.es.js +1 -1
- package/lib/Tooltip/Tooltip.cjs.js +1 -1
- package/lib/Tooltip/Tooltip.es.js +9 -9
- package/lib/_Options/useSelectValue.cjs.js +1 -1
- package/lib/_Options/useSelectValue.es.js +1 -1
- package/lib/index.cjs.js +1 -1
- package/lib/index.es.js +18 -16
- package/lib/wip/Panel/Panel.Body.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Body.d.ts +11 -0
- package/lib/wip/Panel/Panel.Body.es.js +17 -0
- package/lib/wip/Panel/Panel.Footer.Actions.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Footer.Actions.d.ts +17 -0
- package/lib/wip/Panel/Panel.Footer.Actions.es.js +22 -0
- package/lib/wip/Panel/Panel.Footer.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Footer.d.ts +20 -0
- package/lib/wip/Panel/Panel.Footer.es.js +24 -0
- package/lib/wip/Panel/Panel.Header.ContentAfter.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.ContentAfter.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.ContentAfter.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.ContentBefore.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.ContentBefore.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.ContentBefore.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.Description.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.Description.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.Description.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.Heading.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.Heading.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.Heading.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.Row.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.Row.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.Row.es.js +29 -0
- package/lib/wip/Panel/Panel.Header.Subheader.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.Subheader.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.Subheader.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.d.ts +40 -0
- package/lib/wip/Panel/Panel.Header.es.js +34 -0
- package/lib/wip/Panel/Panel.cjs.js +1 -0
- package/lib/wip/Panel/Panel.context.cjs.js +1 -0
- package/lib/wip/Panel/Panel.context.d.ts +16 -0
- package/lib/wip/Panel/Panel.context.es.js +11 -0
- package/lib/wip/Panel/Panel.d.ts +45 -0
- package/lib/wip/Panel/Panel.es.js +43 -0
- package/lib/wip/Panel/Panel.types.cjs.js +1 -0
- package/lib/wip/Panel/Panel.types.d.ts +71 -0
- package/lib/wip/Panel/Panel.types.es.js +1 -0
- package/lib/wip/Panel/index.cjs.js +1 -0
- package/lib/wip/Panel/index.d.ts +12 -0
- package/lib/wip/Panel/index.es.js +4 -0
- package/lib/wip/Search/Search.Results.Item.cjs.js +1 -0
- package/lib/wip/Search/Search.Results.Item.d.ts +8 -0
- package/lib/wip/Search/Search.Results.Item.es.js +12 -0
- package/lib/wip/Search/Search.Results.cjs.js +1 -0
- package/lib/wip/Search/Search.Results.d.ts +12 -0
- package/lib/wip/Search/Search.Results.es.js +19 -0
- package/lib/wip/Search/Search.cjs.js +1 -0
- package/lib/wip/Search/Search.d.ts +88 -0
- package/lib/wip/Search/Search.es.js +157 -0
- package/lib/wip/Search/SearchDropdown.cjs.js +1 -0
- package/lib/wip/Search/SearchDropdown.d.ts +19 -0
- package/lib/wip/Search/SearchDropdown.es.js +71 -0
- package/lib/wip/Search/index.cjs.js +1 -0
- package/lib/wip/Search/index.d.ts +1 -0
- package/lib/wip/Search/index.es.js +4 -0
- package/lib/wip/Search/useSearchDropdown.cjs.js +1 -0
- package/lib/wip/Search/useSearchDropdown.d.ts +875 -0
- package/lib/wip/Search/useSearchDropdown.es.js +92 -0
- package/lib/wip/index.cjs.js +1 -1
- package/lib/wip/index.d.ts +2 -0
- package/lib/wip/index.es.js +6 -1
- package/package.json +6 -6
- package/utils/hooks/index.cjs.js +1 -1
- package/utils/hooks/index.d.ts +1 -0
- package/utils/hooks/index.es.js +33 -31
- package/utils/hooks/useDebounced.cjs.js +1 -0
- package/utils/hooks/useDebounced.d.ts +5 -0
- package/utils/hooks/useDebounced.es.js +18 -0
- package/utils/hooks/useEffectAfterMount.cjs.js +1 -0
- package/utils/hooks/useEffectAfterMount.d.ts +2 -0
- package/utils/hooks/useEffectAfterMount.es.js +14 -0
- package/utils/hooks/useInteractiveProps.cjs.js +1 -0
- package/utils/hooks/useInteractiveProps.d.ts +24 -0
- package/utils/hooks/useInteractiveProps.es.js +31 -0
- package/chunks/ActionList.Group.Bv9vgU22.js +0 -1
- package/chunks/ActionList.Group.DuNxYNZQ.js +0 -107
- package/chunks/ActionList.Item.D7Rg5iMb.js +0 -1
- package/chunks/card.module.BG9mkRao.js +0 -1
- package/chunks/dom.CVmkHCnh.js +0 -21
- package/chunks/dom.PCrm8EUc.js +0 -1
- package/chunks/tokens.Bgac_JPh.js +0 -1
- package/chunks/tokens.CXaNS8Cf.js +0 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),le=require("../../../chunks/classNames.DAeKwerT.js"),oe=require("../../../chunks/constants.hwjHOsvT.js"),b=require("react"),r=require("../../../chunks/Search.Results.Item.Dkh2yo4p.js"),A=require("clsx"),ae=require("../../../chunks/form.context.B26th8Od.js"),ue=require("../../Form/contexts/label.context.cjs.js"),de=require("../../Form/contexts/helperText.context.cjs.js"),_e=require("../../Form/hooks/useUniversalRef.hook.cjs.js"),q=require("../../Form/hooks/useAccessibleId.hook.cjs.js"),pe=require("../../Icon/Icon.cjs.js"),fe=require("./Search.Results.cjs.js"),be=require("./useSearchDropdown.cjs.js"),he=require("./SearchDropdown.cjs.js"),me=require("../../ActionList/ActionList.cjs.js"),xe=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");function je(i){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const c in i)if(c!=="default"){const t=Object.getOwnPropertyDescriptor(i,c);Object.defineProperty(a,c,t.get?t:{enumerable:!0,get:()=>i[c]})}}return a.default=i,Object.freeze(a)}const T=je(b),Ie=i=>T.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},T.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M15.5 14H14.71L14.43 13.73C15.41 12.59 16 11.11 16 9.5C16 5.91 13.09 3 9.5 3C5.91 3 3 5.91 3 9.5C3 13.09 5.91 16 9.5 16C11.11 16 12.59 15.41 13.73 14.43L14 14.71V15.5L19 20.49L20.49 19L15.5 14ZM9.5 14C7.01 14 5 11.99 5 9.5C5 7.01 7.01 5 9.5 5C11.99 5 14 7.01 14 9.5C14 11.99 11.99 14 9.5 14Z",fill:"currentColor"})),{baseClassNamePrefix:ve,subElementClassPrefix:o,classModifierPrefix:f}=le.getBEMClassNames("search"),we=b.forwardRef(({id:i,defaultValue:a="",value:c,onChange:t,onSearch:F,loading:y=!1,debounce:H=200,onKeyDown:m,label:B,contentAfter:j,contentBefore:I,helperText:v,fluid:O,width:z,theme:w,disabled:n,hideIcon:V,icon:U=Ie,error:l,readOnly:d,clearable:P=!0,noResults:g,clearButtonAriaLabel:Z="Clear search",className:W,children:D,"aria-describedby":G,...x},J)=>{const{refFn:Q,ref:X}=_e.useUniversalRef(J),[Y,C]=b.useState(String(a)),_=c!==void 0,u=_?String(c):Y,K=e=>{_||C(e.target.value),t==null||t(e)},{immediate:S,debounced:N}=xe.useDebounced(F,H),ee=e=>{m==null||m(e),e.key==="Enter"&&!e.isDefaultPrevented()&&!e.isPropagationStopped()&&S(u),e.key==="Escape"&&(!P||$.open)&&e.preventDefault()},{id:p}=q.useAccessibleId(),{id:R}=q.useAccessibleId(),{id:k}=q.useAccessibleId(),M=!!(l!=null&&l.length),L=!!D||!!g,se=A(v&&k,M&&R,G),{dropdownProps:$,getFieldProps:te,getInputProps:re}=be.useSearchDropdown({enabled:L,disabled:!!n,readOnly:!!d});Se.useEffectAfterMount(()=>{N(u)},[u,N]);const ie=A(r.styles[ve],w&&oe.themeClassName(w),O&&r.styles[`${f}fluid`],n&&r.styles[`${f}disabled`],d&&r.styles[`${f}read-only`],l&&r.styles[`${f}error`],W),ce=e=>{var E;n||e.target instanceof HTMLInputElement||e.target.closest('button,[role="button"],a,[role="link"]')||(e.preventDefault(),e.stopPropagation(),(E=X.current)==null||E.focus())},ne=b.useCallback(()=>{_?t==null||t({target:{value:"",name:x.name,id:p,type:"search"}}):C(""),S("")},[p,_,t,S,x.name]);return s.jsxs("div",{id:i,className:ie,role:"search",style:{maxWidth:z},"aria-busy":y,children:[s.jsx(ue.LabelProvider,{ctxDisabled:!!n,ctxRequired:!1,ctxHtmlFor:p,children:B}),s.jsxs("div",{className:r.styles[`${o}field`],...te({onPointerDown:ce}),children:[!V&&s.jsx(pe.Icon,{icon:U,"aria-hidden":!0}),I&&s.jsx("div",{className:r.styles[`${o}content`],children:I}),s.jsx("input",{id:p,type:"search",className:r.styles[`${o}field__input`],value:u,disabled:n,readOnly:d,"aria-invalid":!!l,"aria-describedby":se,...re({...x,onChange:K,onKeyDown:ee}),ref:Q}),y&&s.jsx("div",{className:r.styles[`${o}field__spinner`],children:s.jsx(qe.Spinner,{size:"xxs"})}),P&&u&&!n&&!d&&s.jsx(ye.CloseButton,{onClick:ne,className:`${o}field__clear-button`,size:"sm","aria-label":Z}),j&&s.jsx("div",{className:r.styles[`${o}content`],children:j})]}),s.jsxs(de.HelperTextProvider,{ctxId:k,ctxDisabled:!!n,children:[v,M&&s.jsx(ae.HelperText,{id:R,appearance:"negative",children:l})]}),L&&s.jsx(he.SearchDropdown,{...$,children:s.jsx(me.ActionList,{role:"listbox",noResults:g,children:D})})]})}),h=we;h.Results=fe.SearchResults;h.displayName="Search";exports.Search=h;exports.default=h;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ThemeTypes } from '@viasat/beam-shared/utils';
|
|
2
|
+
import { Nullable } from '@viasat/beam-shared/utils/types';
|
|
3
|
+
import { default as React } from 'react';
|
|
4
|
+
import { default as Results } from './Search.Results';
|
|
5
|
+
import { IconComponentType } from '../../../utils/types';
|
|
6
|
+
export interface SearchProps extends React.ComponentPropsWithRef<'input'> {
|
|
7
|
+
/**
|
|
8
|
+
* Specify a callback called whenever a search is conducted
|
|
9
|
+
*/
|
|
10
|
+
onSearch: (query: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Specify the debounce time (in milliseconds) for the search input
|
|
13
|
+
* @default 200
|
|
14
|
+
*/
|
|
15
|
+
debounce?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Specify placeholder text for Search
|
|
18
|
+
*/
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Specify Label for Search
|
|
22
|
+
*/
|
|
23
|
+
label?: Nullable<React.ReactElement>;
|
|
24
|
+
/**
|
|
25
|
+
* Specify HelperText for Search
|
|
26
|
+
*/
|
|
27
|
+
helperText?: Nullable<React.ReactElement>;
|
|
28
|
+
/**
|
|
29
|
+
* Specify if Search is fluid
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
fluid?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Specify the width of Search
|
|
35
|
+
*/
|
|
36
|
+
width?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Display a loading state for Search
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
loading?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Adds a clear button to the Search input
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
clearable?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Specify if the icon displays on the Search
|
|
51
|
+
*/
|
|
52
|
+
hideIcon?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Specify a different icon for the Search
|
|
55
|
+
*/
|
|
56
|
+
icon?: IconComponentType;
|
|
57
|
+
/**
|
|
58
|
+
* Specify content to display before input
|
|
59
|
+
*/
|
|
60
|
+
contentBefore?: React.ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Specify content to display after input
|
|
63
|
+
*/
|
|
64
|
+
contentAfter?: React.ReactNode;
|
|
65
|
+
/**
|
|
66
|
+
* Specify error text and display error state of a Search
|
|
67
|
+
*/
|
|
68
|
+
error?: boolean | string;
|
|
69
|
+
/**
|
|
70
|
+
* Display a message if no results are found
|
|
71
|
+
*/
|
|
72
|
+
noResults?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Aria label for the clear button
|
|
75
|
+
* @default 'Clear search'
|
|
76
|
+
*/
|
|
77
|
+
clearButtonAriaLabel?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Specify the theme of the Search. By default it inherits the theme from the parent
|
|
80
|
+
*/
|
|
81
|
+
theme?: ThemeTypes;
|
|
82
|
+
children?: React.ReactNode;
|
|
83
|
+
}
|
|
84
|
+
declare const SearchComponent: React.ForwardRefExoticComponent<Omit<SearchProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
85
|
+
export declare const Search: typeof SearchComponent & {
|
|
86
|
+
Results: typeof Results;
|
|
87
|
+
};
|
|
88
|
+
export default Search;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { jsxs as x, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { g as ce } from "../../../chunks/classNames.DNsS4J__.js";
|
|
3
|
+
import { t as ne } from "../../../chunks/constants.BBi77pmH.js";
|
|
4
|
+
import * as k from "react";
|
|
5
|
+
import B, { useCallback as me } from "react";
|
|
6
|
+
import { s as r } from "../../../chunks/Search.Results.Item.CLmMBPz1.js";
|
|
7
|
+
import F from "clsx";
|
|
8
|
+
import { H as de } from "../../../chunks/form.context.CfsTSQpm.js";
|
|
9
|
+
import { LabelProvider as fe } from "../../Form/contexts/label.context.es.js";
|
|
10
|
+
import { HelperTextProvider as pe } from "../../Form/contexts/helperText.context.es.js";
|
|
11
|
+
import { useUniversalRef as ue } from "../../Form/hooks/useUniversalRef.hook.es.js";
|
|
12
|
+
import { useAccessibleId as b } from "../../Form/hooks/useAccessibleId.hook.es.js";
|
|
13
|
+
import { Icon as he } from "../../Icon/Icon.es.js";
|
|
14
|
+
import { SearchResults as xe } from "./Search.Results.es.js";
|
|
15
|
+
import { useSearchDropdown as be } from "./useSearchDropdown.es.js";
|
|
16
|
+
import { SearchDropdown as Se } from "./SearchDropdown.es.js";
|
|
17
|
+
import { ActionList as ve } from "../../ActionList/ActionList.es.js";
|
|
18
|
+
import { useDebounced as Pe } from "../../../utils/hooks/useDebounced.es.js";
|
|
19
|
+
import { useEffectAfterMount as Ce } from "../../../utils/hooks/useEffectAfterMount.es.js";
|
|
20
|
+
import { Spinner as Ie } from "../../Spinner/Spinner.es.js";
|
|
21
|
+
import { CloseButton as Ne } from "../../CloseButton/CloseButton.es.js";
|
|
22
|
+
const De = (f) => /* @__PURE__ */ k.createElement("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...f }, /* @__PURE__ */ k.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M15.5 14H14.71L14.43 13.73C15.41 12.59 16 11.11 16 9.5C16 5.91 13.09 3 9.5 3C5.91 3 3 5.91 3 9.5C3 13.09 5.91 16 9.5 16C11.11 16 12.59 15.41 13.73 14.43L14 14.71V15.5L19 20.49L20.49 19L15.5 14ZM9.5 14C7.01 14 5 11.99 5 9.5C5 7.01 7.01 5 9.5 5C11.99 5 14 7.01 14 9.5C14 11.99 11.99 14 9.5 14Z", fill: "currentColor" })), { baseClassNamePrefix: ge, subElementClassPrefix: a, classModifierPrefix: d } = ce("search"), we = B.forwardRef(({
|
|
23
|
+
id: f,
|
|
24
|
+
defaultValue: V = "",
|
|
25
|
+
value: S,
|
|
26
|
+
onChange: s,
|
|
27
|
+
onSearch: j,
|
|
28
|
+
loading: v = !1,
|
|
29
|
+
debounce: q = 200,
|
|
30
|
+
onKeyDown: p,
|
|
31
|
+
label: z,
|
|
32
|
+
contentAfter: P,
|
|
33
|
+
contentBefore: C,
|
|
34
|
+
helperText: I,
|
|
35
|
+
fluid: A,
|
|
36
|
+
width: Z,
|
|
37
|
+
theme: N,
|
|
38
|
+
disabled: i,
|
|
39
|
+
hideIcon: U,
|
|
40
|
+
icon: W = De,
|
|
41
|
+
error: o,
|
|
42
|
+
readOnly: c,
|
|
43
|
+
clearable: D = !0,
|
|
44
|
+
noResults: g,
|
|
45
|
+
clearButtonAriaLabel: G = "Clear search",
|
|
46
|
+
className: J,
|
|
47
|
+
children: w,
|
|
48
|
+
"aria-describedby": Q,
|
|
49
|
+
...u
|
|
50
|
+
}, X) => {
|
|
51
|
+
const { refFn: Y, ref: K } = ue(X), [O, R] = B.useState(String(V)), n = S !== void 0, l = n ? String(S) : O, ee = (e) => {
|
|
52
|
+
n || R(e.target.value), s == null || s(e);
|
|
53
|
+
}, { immediate: h, debounced: $ } = Pe(j, q), te = (e) => {
|
|
54
|
+
p == null || p(e), e.key === "Enter" && !e.isDefaultPrevented() && !e.isPropagationStopped() && h(l), e.key === "Escape" && (!D || M.open) && e.preventDefault();
|
|
55
|
+
}, { id: m } = b(), { id: y } = b(), { id: E } = b(), L = !!(o != null && o.length), _ = !!w || !!g, re = F(
|
|
56
|
+
I && E,
|
|
57
|
+
L && y,
|
|
58
|
+
Q
|
|
59
|
+
), {
|
|
60
|
+
dropdownProps: M,
|
|
61
|
+
getFieldProps: se,
|
|
62
|
+
getInputProps: ie
|
|
63
|
+
} = be({
|
|
64
|
+
enabled: _,
|
|
65
|
+
disabled: !!i,
|
|
66
|
+
readOnly: !!c
|
|
67
|
+
});
|
|
68
|
+
Ce(() => {
|
|
69
|
+
$(l);
|
|
70
|
+
}, [l, $]);
|
|
71
|
+
const oe = F(
|
|
72
|
+
r[ge],
|
|
73
|
+
N && ne(N),
|
|
74
|
+
A && r[`${d}fluid`],
|
|
75
|
+
i && r[`${d}disabled`],
|
|
76
|
+
c && r[`${d}read-only`],
|
|
77
|
+
o && r[`${d}error`],
|
|
78
|
+
J
|
|
79
|
+
), ae = (e) => {
|
|
80
|
+
var H;
|
|
81
|
+
i || e.target instanceof HTMLInputElement || e.target.closest('button,[role="button"],a,[role="link"]') || (e.preventDefault(), e.stopPropagation(), (H = K.current) == null || H.focus());
|
|
82
|
+
}, le = me(() => {
|
|
83
|
+
n ? s == null || s({
|
|
84
|
+
target: {
|
|
85
|
+
value: "",
|
|
86
|
+
name: u.name,
|
|
87
|
+
id: m,
|
|
88
|
+
type: "search"
|
|
89
|
+
}
|
|
90
|
+
}) : R(""), h("");
|
|
91
|
+
}, [m, n, s, h, u.name]);
|
|
92
|
+
return /* @__PURE__ */ x(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
id: f,
|
|
96
|
+
className: oe,
|
|
97
|
+
role: "search",
|
|
98
|
+
style: { maxWidth: Z },
|
|
99
|
+
"aria-busy": v,
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ t(
|
|
102
|
+
fe,
|
|
103
|
+
{
|
|
104
|
+
ctxDisabled: !!i,
|
|
105
|
+
ctxRequired: !1,
|
|
106
|
+
ctxHtmlFor: m,
|
|
107
|
+
children: z
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
/* @__PURE__ */ x(
|
|
111
|
+
"div",
|
|
112
|
+
{
|
|
113
|
+
className: r[`${a}field`],
|
|
114
|
+
...se({ onPointerDown: ae }),
|
|
115
|
+
children: [
|
|
116
|
+
!U && /* @__PURE__ */ t(he, { icon: W, "aria-hidden": !0 }),
|
|
117
|
+
C && /* @__PURE__ */ t("div", { className: r[`${a}content`], children: C }),
|
|
118
|
+
/* @__PURE__ */ t(
|
|
119
|
+
"input",
|
|
120
|
+
{
|
|
121
|
+
id: m,
|
|
122
|
+
type: "search",
|
|
123
|
+
className: r[`${a}field__input`],
|
|
124
|
+
value: l,
|
|
125
|
+
disabled: i,
|
|
126
|
+
readOnly: c,
|
|
127
|
+
"aria-invalid": !!o,
|
|
128
|
+
"aria-describedby": re,
|
|
129
|
+
...ie({
|
|
130
|
+
...u,
|
|
131
|
+
onChange: ee,
|
|
132
|
+
onKeyDown: te
|
|
133
|
+
}),
|
|
134
|
+
ref: Y
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
v && /* @__PURE__ */ t("div", { className: r[`${a}field__spinner`], children: /* @__PURE__ */ t(Ie, { size: "xxs" }) }),
|
|
138
|
+
D && l && !i && !c && /* @__PURE__ */ t(Ne, { onClick: le, className: `${a}field__clear-button`, size: "sm", "aria-label": G }),
|
|
139
|
+
P && /* @__PURE__ */ t("div", { className: r[`${a}content`], children: P })
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
),
|
|
143
|
+
/* @__PURE__ */ x(pe, { ctxId: E, ctxDisabled: !!i, children: [
|
|
144
|
+
I,
|
|
145
|
+
L && /* @__PURE__ */ t(de, { id: y, appearance: "negative", children: o })
|
|
146
|
+
] }),
|
|
147
|
+
_ && /* @__PURE__ */ t(Se, { ...M, children: /* @__PURE__ */ t(ve, { role: "listbox", noResults: g, children: w }) })
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
}), T = we;
|
|
152
|
+
T.Results = xe;
|
|
153
|
+
T.displayName = "Search";
|
|
154
|
+
export {
|
|
155
|
+
T as Search,
|
|
156
|
+
T as default
|
|
157
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("@floating-ui/react"),C=require("../../Box/Box.cjs.js"),q=require("clsx"),l=require("../../../chunks/classNames.DAeKwerT.js"),N=require("../../../chunks/constants.hwjHOsvT.js"),_=require("../../ActionList/ActionList.context.cjs.js"),b=require("react"),S=require("../../../chunks/floatingui.module.D3Aw_aYe.js"),F=require("../../../chunks/popover.module.Dum8SaSU.js"),a=require("./Search.Results.cjs.js"),{baseClassNamePrefix:j}=l.getBEMClassNames("floatingui"),{baseClassNamePrefix:B}=l.getBEMClassNames("popover"),P=[a.SearchResults,a.SearchResults.Item],v=({setOpen:r,isMounted:i,getFloatingProps:n,floatingStyles:c,labelsRef:u,elementsRef:d,getItemProps:m,setFloating:f,theme:t,className:x,children:g,context:o,activeIndex:h})=>{const p=b.useCallback(()=>r(!1),[r]);return i?e.jsx(s.FloatingTree,{children:e.jsx(s.FloatingNode,{id:o.floatingId,children:e.jsx(s.FloatingPortal,{children:e.jsx(s.FloatingFocusManager,{context:o,modal:!1,returnFocus:!0,closeOnFocusOut:!0,guards:!0,disabled:!1,restoreFocus:!0,order:["reference","content"],children:e.jsx(C.Box,{className:q(t&&N.themeClassName(t),S.floatinguiStyles[j],F.popoverStyles[B],x),...n(),style:c,ref:f,children:e.jsx(_.ActionListContextProvider,{allowChildrenTypes:P,getItemProps:m,itemsFocusable:!0,onItemClick:p,labelsRef:u,elementsRef:d,activeIndex:h,children:g})})})})})}):null};exports.SearchDropdown=v;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FloatingContext, UseInteractionsReturn } from '@floating-ui/react';
|
|
2
|
+
import { ThemeTypes } from '@viasat/beam-shared/utils';
|
|
3
|
+
import { CSSProperties, MutableRefObject } from 'react';
|
|
4
|
+
export interface SearchDropdownProps {
|
|
5
|
+
context: FloatingContext;
|
|
6
|
+
isMounted: boolean;
|
|
7
|
+
getFloatingProps: UseInteractionsReturn['getFloatingProps'];
|
|
8
|
+
floatingStyles: CSSProperties;
|
|
9
|
+
labelsRef: MutableRefObject<string[]>;
|
|
10
|
+
elementsRef: MutableRefObject<HTMLElement[]>;
|
|
11
|
+
getItemProps: UseInteractionsReturn['getItemProps'];
|
|
12
|
+
setOpen: (open: boolean) => void;
|
|
13
|
+
setFloating: (node: HTMLElement | null) => void;
|
|
14
|
+
activeIndex: number | null;
|
|
15
|
+
theme?: ThemeTypes;
|
|
16
|
+
className?: string;
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare const SearchDropdown: ({ setOpen, isMounted, getFloatingProps, floatingStyles, labelsRef, elementsRef, getItemProps, setFloating, theme, className: _className, children, context, activeIndex, }: SearchDropdownProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { FloatingTree as h, FloatingNode as F, FloatingPortal as N, FloatingFocusManager as x } from "@floating-ui/react";
|
|
3
|
+
import { Box as P } from "../../Box/Box.es.js";
|
|
4
|
+
import b from "clsx";
|
|
5
|
+
import { g as a } from "../../../chunks/classNames.DNsS4J__.js";
|
|
6
|
+
import { t as v } from "../../../chunks/constants.BBi77pmH.js";
|
|
7
|
+
import { ActionListContextProvider as y } from "../../ActionList/ActionList.context.es.js";
|
|
8
|
+
import { useCallback as B } from "react";
|
|
9
|
+
import { f as I } from "../../../chunks/floatingui.module.BcBFebz0.js";
|
|
10
|
+
import { p as S } from "../../../chunks/popover.module.C6KFea25.js";
|
|
11
|
+
import { SearchResults as t } from "./Search.Results.es.js";
|
|
12
|
+
const { baseClassNamePrefix: k } = a("floatingui"), { baseClassNamePrefix: w } = a("popover"), M = [t, t.Item], H = ({
|
|
13
|
+
setOpen: r,
|
|
14
|
+
isMounted: l,
|
|
15
|
+
getFloatingProps: i,
|
|
16
|
+
floatingStyles: m,
|
|
17
|
+
labelsRef: n,
|
|
18
|
+
elementsRef: c,
|
|
19
|
+
getItemProps: f,
|
|
20
|
+
setFloating: u,
|
|
21
|
+
theme: o,
|
|
22
|
+
className: p,
|
|
23
|
+
children: d,
|
|
24
|
+
context: s,
|
|
25
|
+
activeIndex: g
|
|
26
|
+
}) => {
|
|
27
|
+
const C = B(() => r(!1), [r]);
|
|
28
|
+
return l ? /* @__PURE__ */ e(h, { children: /* @__PURE__ */ e(F, { id: s.floatingId, children: /* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(
|
|
29
|
+
x,
|
|
30
|
+
{
|
|
31
|
+
context: s,
|
|
32
|
+
modal: !1,
|
|
33
|
+
returnFocus: !0,
|
|
34
|
+
closeOnFocusOut: !0,
|
|
35
|
+
guards: !0,
|
|
36
|
+
disabled: !1,
|
|
37
|
+
restoreFocus: !0,
|
|
38
|
+
order: ["reference", "content"],
|
|
39
|
+
children: /* @__PURE__ */ e(
|
|
40
|
+
P,
|
|
41
|
+
{
|
|
42
|
+
className: b(
|
|
43
|
+
o && v(o),
|
|
44
|
+
I[k],
|
|
45
|
+
S[w],
|
|
46
|
+
p
|
|
47
|
+
),
|
|
48
|
+
...i(),
|
|
49
|
+
style: m,
|
|
50
|
+
ref: u,
|
|
51
|
+
children: /* @__PURE__ */ e(
|
|
52
|
+
y,
|
|
53
|
+
{
|
|
54
|
+
allowChildrenTypes: M,
|
|
55
|
+
getItemProps: f,
|
|
56
|
+
itemsFocusable: !0,
|
|
57
|
+
onItemClick: C,
|
|
58
|
+
labelsRef: n,
|
|
59
|
+
elementsRef: c,
|
|
60
|
+
activeIndex: g,
|
|
61
|
+
children: d
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
) }) }) }) : null;
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
H as SearchDropdown
|
|
71
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Search.cjs.js");exports.Search=e.Search;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Search';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@floating-ui/react"),n=require("react"),T=require("../../FloatingUI/useTyping.cjs.js"),q=S=>{const{disabled:c,readOnly:a,enabled:e=!0}=S,[s,i]=n.useState(!1),d=n.useRef(s);d.current=s;const[f,g]=n.useState(null);n.useEffect(()=>s?void 0:g(null),[s]);const{context:r,refs:l,floatingStyles:p}=t.useFloating({placement:"bottom-start",middleware:[t.flip(),t.size({apply({elements:o,rects:u}){Object.assign(o.floating.style,{width:`${u.reference.width}px`})}})],whileElementsMounted:t.autoUpdate,open:s,onOpenChange:i}),b=n.useRef([]),k=n.useRef([]),h=t.useClick(r,{enabled:!s&&e&&!c&&!a,toggle:!1,stickIfOpen:!1,keyboardHandlers:!1}),x=t.useRole(r,{enabled:e,role:"listbox"}),E=T.useTyping(r,{enabled:!s&&e&&!c&&!a,event:"keyboard"}),M=t.useFocus(r,{enabled:!s&&e&&!c&&!a,visibleOnly:!0}),C=t.useDismiss(r,{enabled:s&&e&&!c&&!a,escapeKey:!0,outsidePress:!0,referencePress:!1}),D=t.useListNavigation(r,{enabled:e&&!c&&!a,listRef:b,activeIndex:f,onNavigate:g,focusItemOnHover:!1,focusItemOnOpen:"auto",openOnArrowKeyDown:!0,nested:!1,loop:!0,virtual:!1,scrollItemIntoView:!0}),{getReferenceProps:m,getFloatingProps:y,getItemProps:R}=t.useInteractions([x,E,D]),{getReferenceProps:v}=t.useInteractions([h,M,C]),{isMounted:I,styles:P}=t.useTransitionStyles(r,{duration:50});n.useEffect(()=>{if(!e||c||a||d.current)return;const o=l.domReference.current,u=document.activeElement;o&&u&&o.contains(u)&&i(!0)},[e,c,a,i,l.domReference]);const O=n.useCallback((o={})=>e?m(o):o,[m,e]),w=n.useCallback((o={})=>e?{ref:l.setReference,...v(o)}:o,[e,l.setReference,v]),F=n.useMemo(()=>({isMounted:I,getFloatingProps:y,getItemProps:R,floatingStyles:{...p,...P},setOpen:i,labelsRef:k,elementsRef:b,setFloating:l.setFloating,activeIndex:f,context:r,open:s}),[I,y,R,p,P,l.setFloating,f,r,s]);return n.useMemo(()=>({getFieldProps:w,getInputProps:O,dropdownProps:F,refs:l}),[F,w,O,l])};exports.useSearchDropdown=q;
|