@sps-woodland/list-bar 8.0.0-rc1

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.
@@ -0,0 +1,1047 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const W=require("react"),l=require("@sps-woodland/core"),T=require("@sps-woodland/buttons"),A=require("@sps-woodland/tags"),o=require("@spscommerce/utils"),r=require("@spscommerce/ds-react"),Y=require("@sps-woodland/tokens");function z(t){if(t&&t.__esModule)return t;const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const e=z(W);function Z(t,a,n){return a in t?Object.defineProperty(t,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[a]=n,t}function V(t,a){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);a&&(s=s.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,s)}return n}function _(t){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?V(Object(n),!0).forEach(function(s){Z(t,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(n,s))})}return t}var J=(t,a,n)=>{for(var s of Object.keys(t)){var i;if(t[s]!==((i=a[s])!==null&&i!==void 0?i:n[s]))return!1}return!0},P=t=>a=>{var n=t.defaultClassName,s=_(_({},t.defaultVariants),a);for(var i in s){var m,h=(m=s[i])!==null&&m!==void 0?m:t.defaultVariants[i];if(h!=null){var c=h;typeof c=="boolean"&&(c=c===!0?"true":"false");var S=t.variantClassNames[i][c];S&&(n+=" "+S)}}for(var[d,p]of t.compoundVariants)J(d,s,t.defaultVariants)&&(n+=" "+p);return n},Q="_9h4p70e",X=P({defaultClassName:"_9h4p701",variantClassNames:{pinned:{true:"_9h4p702",false:"_9h4p703"}},defaultVariants:{pinned:!1},compoundVariants:[]}),$="_9h4p709",ee="_9h4p70a",te="_9h4p707",ae="_9h4p708",re="_9h4p704",D="_9h4p70b",ne="_9h4p706",se="_9h4p70d",oe="_9h4p70c",le="_9h4p705",ce="_9h4p70f";function G({children:t}){const a=l.modChildren(t,n=>n.type===T.Button?[{className:l.cl(n.props.className,Q)}]:[]);return e.createElement(e.Fragment,null,a)}function y({onSubmit:t,children:a}){function n(s){s.preventDefault(),t&&t(s)}return e.createElement("form",{onSubmit:n,className:oe,noValidate:!0},e.createElement(r.SpsInputGroup,{className:se},e.createElement(G,null,a)))}l.Metadata.set(y,{name:"ListBarSearch",props:{onSubmit:{type:"FormEventHandler"}}});function C({children:t}){return e.createElement("div",null,t)}l.Metadata.set(C,{name:"ListBarSearchInfo"});var ie="_1gxdcgc1",de="_1gxdcgc8",ue="_1gxdcgc7",me="_1gxdcgc2",pe="_1gxdcgc5",he="_1gxdcgc6",Se="_1gxdcgc4",fe="_1gxdcgc0",ve="_1gxdcgc3";function x({results:t,selections:a,zeroStateText:n,onClear:s,className:i,children:m,...h}){const{t:c}=e.useContext(l.I18nContext),S=a?Object.keys(a).reduce((d,p)=>(a[p].length>0&&(d[p]=a[p]),d),{}):{};return e.createElement("div",{className:ie,...h},t!=null&&e.createElement("div",{className:me},e.createElement("span",null,c("design-system:searchResultsBar.results")),e.createElement(A.Tag,{className:ve,kind:"info"},e.createElement("span",null,t))),e.createElement("div",{className:Se},Object.keys(S).length>0?Object.keys(S).map((d,p)=>e.createElement(e.Fragment,null,e.createElement("span",{key:p,className:pe},d,":"),S[d].map((b,B)=>e.createElement(A.Tag,{className:he,key:B,kind:"key"},e.createElement("span",null,b))))):e.createElement("span",{className:"font-italic"},n||c("design-system:searchResultsBar.noAdvancedSearchSelections"))),e.createElement("div",{className:ue},e.createElement(T.Button,{className:de,kind:"link",onClick:s},c("design-system:searchResultsBar.clearResults"))))}l.Metadata.set(x,{name:"Search Results Bar",props:{results:{type:"number | null"},selections:{type:"{ [key: string]: string[] }"},zeroStateText:{type:"string"},onClear:{type:"() => void"}}});function w({advancedSearch:t,onToggleAdvancedSearch:a,title:n,onToolbarPinned:s,selectable:i,isSelected:m,isIndeterminate:h,onSelectionChange:c,pinResultsBar:S,pinToolbar:d=!0,children:p,className:b,...B}){const{t:j}=e.useContext(l.I18nContext);let L=null;const[f,M]=e.useState(!1),g=e.useRef(null),v=e.useRef(null),I=o.lockToAnimationFrames(()=>{if(g.current&&d){const u=g.current.getBoundingClientRect();u&&u.height>0&&u.top<=60&&(typeof L=="number"?window.scrollY<L&&(L=null,M(!1)):(L=window.scrollY,M(!0),a&&a(!1)))}});e.useEffect(()=>(window.addEventListener("scroll",I),()=>{window.removeEventListener("scroll",I)}),[]);const E=e.useRef();e.useLayoutEffect(()=>{if(v.current&&g.current&&d){if(f&&E.current)v.current.style.height=E.current.height,v.current.style.width=E.current.width,v.current.style.marginBottom=E.current.marginBottom;else if(!f){v.current.style.height="",v.current.style.width="",v.current.style.marginBottom="";const u=window.getComputedStyle(g.current);E.current={height:u.height,width:u.width,marginBottom:u.marginBottom}}}},[f]);function q(){a&&a(!(t!=null&&t.isOpen))}function U(u){s&&s(u)}e.useEffect(()=>{U(f)},[f]);const[O,H,K,[k],N]=l.selectChildren(p,[{type:y},{type:C},{type:x},{custom:u=>l.Metadata.isWoodlandComponent(u)&&l.Metadata.get(u).name==="Tabs"}]);return e.createElement("div",{className:l.cl(b),ref:v,...B},e.createElement("div",{className:X({pinned:f}),ref:g,...B},k?l.addProps(k,{context:"container"}):e.createElement(e.Fragment,null,e.createElement("div",{className:re},!!i&&e.createElement("div",{className:le},e.createElement(r.SpsCheckbox,{checked:m,indeterminate:h,onChange:()=>{c==null||c(!m)}})),e.createElement("div",{className:ne},!n&&O,!n&&H,O.length>0&&t&&e.createElement("div",{className:te},e.createElement("div",{className:ae},e.createElement(T.Button,{kind:"link",onClick:q},j("design-system:listToolbar.advancedSearchToggle"))),(t.enteredFields||0)>0&&e.createElement(A.Tag,{className:$,kind:"info"},e.createElement("span",null,t.enteredFields))),n&&e.createElement("div",{className:ee},n)),f?e.createElement("div",{className:D},e.createElement(l.PortalContext.Provider,{value:{fixed:!0}},N)):e.createElement("div",{className:D},N)),e.createElement("div",{className:fe},(!f||f&&S)&&K))))}l.Metadata.set(w,{name:"ListBar",props:{activeTab:{type:"Tab"},advancedSearch:{type:"{ isOpen: boolean, enteredFields: number }"},onToggleAdvancedSearch:{type:"(boolean) => void"},onTabChange:{type:"(Tab) => void"},title:{type:"string"},onToolbarPinned:{type:"(boolean) => void"},selectable:{type:"boolean"},isSelected:{type:"boolean"},isIndeterminate:{type:"boolean"},onSelectionChange:{type:"(boolean) => void"},pinResultsBar:{type:"boolean"},pinToolbar:{type:"boolean",default:"true"}}});function R({options:t,activeOption:a,onSortChange:n,defaultOption:s,className:i,...m}){const h=(t||[]).map(c=>[{label:c.label,icon:c.icon},()=>{n&&n(c)}]);return e.createElement(r.SpsDropdown,{className:l.cl(i,ce),icon:(a==null?void 0:a.icon)||(s==null?void 0:s.icon),label:(a==null?void 0:a.label)||(s==null?void 0:s.label),options:h})}l.Metadata.set(R,{name:"ListBarSortBy",props:{options:{type:"SortOption[]"},activeOption:{type:"SortOption"},onSortChange:{type:"(option: SortOption) => void"},defaultOption:{type:"SortOption"}}});var be=P({defaultClassName:"q4fj410",variantClassNames:{open:{true:"q4fj411",false:"q4fj412"}},defaultVariants:{open:!1},compoundVariants:[]}),Be="q4fj414",Te="q4fj415",ge="q4fj413";function F({formArray:t,formGroup:a,formMeta:n,onSubmit:s,controlsDisabled:i,footerLinks:m,isOpen:h,onClear:c,className:S,children:d,...p}){const{t:b}=e.useContext(l.I18nContext);function B(){c&&c()}return e.createElement("div",{className:l.cl(be({open:h})),...p},e.createElement(r.SpsForm,{onSubmit:s,formArray:t,formGroup:a,formMeta:n},e.createElement("div",{className:ge},d),e.createElement("div",{className:Be},m&&e.createElement("div",{id:"footer_links"},l.contentOf(m)),e.createElement("div",{className:Te},e.createElement(T.Button,{kind:"default",type:"button",className:Y.sprinkles({mr:"sm"}),onClick:B,disabled:i},b("design-system:advancedSearch.clear")),e.createElement(T.Button,{kind:"key",type:"submit",disabled:i},b("design-system:advancedSearch.search"))))))}l.Metadata.set(F,{name:"Advanced Search",props:{formArray:{type:"SpsFormArray<any>"},formGroup:{type:"SpsFormGroup"},formMeta:{type:"SpsFormSetMeta<any>"},onSubmit:{type:"React.FormEventHandler"},controlsDisabled:{type:"boolean"},footerLinks:{type:"React.ReactNode | (() => React.ReactNode)"},isOpen:{type:"boolean"},onClear:{type:"() => void"}}});const Ee={components:[F],examples:{general:{label:"General Usage",description:({NavigateTo:t,Link:a})=>e.createElement(e.Fragment,null,e.createElement("p",null,'Advanced Search is comprised of a panel of input fields, and a text button that exposes and hides the panel. By default, the Advanced Search panel is hidden (with the exception of "Advanced Search Only" scenarios).'),e.createElement("p",null,"Advanced Search works in conjunction with the"," ",e.createElement(t,{to:"list-toolbar"},"List Bar")," and"," ",e.createElement(t,{to:"search-results-bar"},"Search Results")," components. Refer to those pages for additional details."),e.createElement("p",null,"Use the following guidelines when including Advanced Search on your page:",e.createElement("ul",null,e.createElement("li",null,"The Advanced Search Panel can contain any number of input fields."),e.createElement("li",null,"The Advanced Search Panel can place input fields in any unique layout to best serve the needs of the search criteria, but must adhere to the rules of the"," ",e.createElement(a,{to:"/style-and-layout/grid/"},"SPS Grid")," and guidelines for"," ",e.createElement(t,{to:"form"},"Form Layouts"),"."))))},basic:{label:"Basic Usage",description:({NavigateTo:t})=>e.createElement(e.Fragment,null,e.createElement("p",null,"A Basic Advanced Search consists of the List Bar with a search input and an Advanced Search text button. For more details on additional button and component options in the List Bar reference the ",e.createElement(t,{to:"list-toolbar"},"List Bar")," page.")),examples:{basic:{react:o.code`
2
+ import { ListBar, ListBarSearch, SearchResultsBar, AdvancedSearch } from "@sps-woodland/list-bar";
3
+ import { Button } from "@sps-woodland/buttons";
4
+ import { grid } from "@sps-woodland/tokens";
5
+ import { SpsLabel, SpsTextInput } from "@spscommerce/ds-react";
6
+
7
+ function Component() {
8
+ const [toolbarSearchText, setToolbarSearchText] = React.useState("");
9
+ const [advSearch, patchAdvSearch] = usePatchReducer({
10
+ isOpen: false,
11
+ enteredFields: 0,
12
+ });
13
+
14
+ const initValue = {
15
+ sender: "",
16
+ receiver: "",
17
+ doctype: "",
18
+ status: "",
19
+ };
20
+ const { formValue, formMeta, updateForm } = useSpsForm(initValue);
21
+
22
+ React.useEffect(() => {
23
+ // Simulate that someone has entered a search term
24
+ updateForm({
25
+ ...formValue,
26
+ receiver: "Walmart"
27
+ });
28
+ patchAdvSearch({ enteredFields: 1 });
29
+ }, []);
30
+
31
+ function handleToolbarSearchChange(event) {
32
+ setToolbarSearchText(event.target.value);
33
+ }
34
+
35
+ function handleToggleAdvancedSearch(isOpen) {
36
+ patchAdvSearch({ isOpen });
37
+ }
38
+
39
+ function handleAdvancedSearchSubmit() {
40
+ patchAdvSearch({ enteredFields: diff(initValue, formValue).length });
41
+ }
42
+
43
+ function handleAdvancedSearchClear() {
44
+ updateForm(initValue);
45
+ patchAdvSearch({ enteredFields: 0 });
46
+ }
47
+
48
+ return (
49
+ <>
50
+ <ListBar
51
+ advancedSearch={advSearch}
52
+ onToggleAdvancedSearch={handleToggleAdvancedSearch}
53
+ >
54
+ <ListBarSearch>
55
+ <SpsTextInput
56
+ value={toolbarSearchText}
57
+ onChange={handleToolbarSearchChange}
58
+ disabled={advSearch.isOpen}
59
+ title="Search"
60
+ />
61
+ <Button kind="icon" icon="search" disabled={advSearch.isOpen} data-testid="search-button" />
62
+ </ListBarSearch>
63
+ </ListBar>
64
+ <AdvancedSearch
65
+ {...advSearch}
66
+ formMeta={formMeta}
67
+ onSubmit={handleAdvancedSearchSubmit}
68
+ onClear={handleAdvancedSearchClear}
69
+ data-testid="advanced-search"
70
+ >
71
+ <div className={grid.root}>
72
+ <div className={grid[4]}>
73
+ <SpsLabel for={formMeta.fields.sender}>Sender</SpsLabel>
74
+ <SpsTextInput formMeta={formMeta.fields.sender}
75
+ value={formValue.sender}
76
+ />
77
+ </div>
78
+ <div className={grid[4]}>
79
+ <SpsLabel for={formMeta.fields.receiver}>Receiver</SpsLabel>
80
+ <SpsTextInput formMeta={formMeta.fields.receiver}
81
+ value={formValue.receiver}
82
+ />
83
+ </div>
84
+ <div className={grid[4]}>
85
+ <SpsLabel for={formMeta.fields.doctype}>Document Type</SpsLabel>
86
+ <SpsTextInput formMeta={formMeta.fields.doctype}
87
+ value={formValue.doctype}
88
+ />
89
+ </div>
90
+ <div className={grid[4]}>
91
+ <SpsLabel for={formMeta.fields.status}>Status</SpsLabel>
92
+ <SpsTextInput formMeta={formMeta.fields.status}
93
+ value={formValue.status}
94
+ />
95
+ </div>
96
+ </div>
97
+ </AdvancedSearch>
98
+ </>
99
+ )
100
+ }
101
+ `}}},footerLink:{label:"Footer Link",description:()=>e.createElement(e.Fragment,null,e.createElement("p",null,"A Footer Link can be included in the Advanced Search footer (visible only when the menu is exposed). The Footer Link is used to link to preferences that control the Advanced Search panel display (such as customized fields and defaults).")),examples:{footerLink:{react:o.code`
102
+ import { ListBar, ListBarSearch, AdvancedSearch } from "@sps-woodland/list-bar";
103
+ import { Button } from "@sps-woodland/buttons";
104
+ import { SpsTextInput } from "@spscommerce/ds-react";
105
+
106
+ function Component(props) {
107
+ const [toolbarSearchText, setToolbarSearchText] = React.useState("");
108
+ const [advSearch, setAdvSearch] = React.useState({
109
+ isOpen: false
110
+ });
111
+
112
+ function handleToggleAdvancedSearch(isOpen) {
113
+ setAdvSearch({ isOpen });
114
+ }
115
+
116
+ function handleToolbarSearchChange(event) {
117
+ setToolbarSearchText(event.target.value);
118
+ }
119
+
120
+ return (
121
+ <>
122
+ <ListBar advancedSearch={advSearch}
123
+ onToggleAdvancedSearch={handleToggleAdvancedSearch}
124
+ >
125
+ <ListBarSearch>
126
+ <SpsTextInput value={toolbarSearchText}
127
+ onChange={handleToolbarSearchChange}
128
+ disabled={advSearch.isOpen}
129
+ title="Search"
130
+ />
131
+ <Button kind="icon"
132
+ icon="search"
133
+ disabled={advSearch.isOpen}
134
+ />
135
+ </ListBarSearch>
136
+ </ListBar>
137
+ <AdvancedSearch {...advSearch}
138
+ footerLinks={
139
+ <Button kind="link" icon="gear">
140
+ Advanced Search Defaults
141
+ </Button>
142
+ }
143
+ data-testid="advanced-search"
144
+ >
145
+ <br />
146
+ <br />
147
+ <br />
148
+ <br />
149
+ </AdvancedSearch>
150
+ </>
151
+ )
152
+ }
153
+ `}}},disabledButtons:{label:"Disabling the Clear/Search Buttons",description:()=>e.createElement(e.Fragment,null,e.createElement("p",null,"The Search and Clear Fields buttons in the footer can be disabled when no input fields in the Advanced Search Panel contain values.")),examples:{disabledButtons:{react:o.code`
154
+ import { ListBar, ListBarSearch, AdvancedSearch } from "@sps-woodland/list-bar";
155
+ import { Button } from "@sps-woodland/buttons";
156
+ import { SpsTextInput } from "@spscommerce/ds-react";
157
+
158
+ function Component() {
159
+ const [toolbarSearchText, setToolbarSearchText] = React.useState("");
160
+ const [advSearch, setAdvSearch] = React.useState({
161
+ isOpen: false,
162
+ controlsDisabled: true,
163
+ });
164
+
165
+ function handleToggleAdvancedSearch(isOpen) {
166
+ setAdvSearch({ ...advSearch, isOpen });
167
+ }
168
+
169
+ function handleToolbarSearchChange(event) {
170
+ setToolbarSearchText(event.target.value);
171
+ }
172
+
173
+ return (
174
+ <>
175
+ <ListBar advancedSearch={advSearch}
176
+ onToggleAdvancedSearch={handleToggleAdvancedSearch}
177
+ >
178
+ <ListBarSearch>
179
+ <SpsTextInput value={toolbarSearchText}
180
+ onChange={handleToolbarSearchChange}
181
+ disabled={advSearch.isOpen}
182
+ title="Search"
183
+ />
184
+ <Button kind="icon"
185
+ icon="search"
186
+ disabled={advSearch.isOpen}
187
+ />
188
+ </ListBarSearch>
189
+ </ListBar>
190
+ <AdvancedSearch {...advSearch}>
191
+ <br />
192
+ <br />
193
+ <br />
194
+ <br />
195
+ </AdvancedSearch>
196
+ </>
197
+ )
198
+ }
199
+ `}}},advancedSearchOnly:{label:'"Advanced Search Only" List Bar',description:()=>e.createElement(e.Fragment,null,e.createElement("p",null,"Certain scenarios may require an Advanced Search Panel to display by default (eschewing a basic search). In these scenarios a title will replace the search input in the List Bar."),e.createElement("p",null,"To achieve an Advanced Search Only effect, remove the basic search input from the List Bar.")),examples:{withTitle:{react:o.code`
200
+ import { ListBar, AdvancedSearch } from "@sps-woodland/list-bar";
201
+
202
+ function Component() {
203
+ const [advSearch, patchAdvSearch] = usePatchReducer({
204
+ isOpen: true,
205
+ });
206
+
207
+ return (
208
+ <>
209
+ <ListBar title="Advanced Search" advancedSearch={advSearch} />
210
+ <AdvancedSearch isOpen={advSearch.isOpen} data-testid="advanced-search">
211
+ <br />
212
+ <br />
213
+ <br />
214
+ <br />
215
+ </AdvancedSearch>
216
+ </>
217
+ )
218
+ }
219
+ `}}}}};function Le(){const[t,a]=e.useState(!1);function n(){a(!1)}function s(){a(!0)}return e.createElement(e.Fragment,null,e.createElement("p",null,"The List Bar is divided into a number of different sections. It spans the entire width of the corresponding list."),e.createElement(T.Button,{kind:"link",onClick:s},"View Content Order Example"),e.createElement(r.SpsFocusedTask,{isOpen:t,onClose:n},e.createElement("h1",null,"Content Order"),e.createElement("img",{src:"assets/images/list-toolbar-example.svg",alt:"A List Toolbar with labels on each section",className:"w-100 mb-3"}),e.createElement(r.SpsTable,null,e.createElement(r.SpsTableHead,null,e.createElement(r.SpsTableHeader,{style:{width:"80px"}},"Order"),e.createElement(r.SpsTableHeader,null,"Section"),e.createElement(r.SpsTableHeader,null,"Notes")),e.createElement(r.SpsTableBody,null,e.createElement(r.SpsTableRow,null,e.createElement(r.SpsTableCell,null,e.createElement("span",{className:"sps-tag sps-tag--info"},"1")),e.createElement(r.SpsTableCell,null,"Checkbox"),e.createElement(r.SpsTableCell,null,"For Content Rows and Content Tiles only.")),e.createElement(r.SpsTableRow,null,e.createElement(r.SpsTableCell,null,e.createElement("span",{className:"sps-tag sps-tag--info"},"2")),e.createElement(r.SpsTableCell,null,"Search/Filter Box"),e.createElement(r.SpsTableCell,null)),e.createElement(r.SpsTableRow,null,e.createElement(r.SpsTableCell,null,e.createElement("span",{className:"sps-tag sps-tag--info"},"3")),e.createElement(r.SpsTableCell,null,"Saved Search"),e.createElement(r.SpsTableCell,null)),e.createElement(r.SpsTableRow,null,e.createElement(r.SpsTableCell,null,e.createElement("span",{className:"sps-tag sps-tag--info"},"4")),e.createElement(r.SpsTableCell,null,"Advanced Search"),e.createElement(r.SpsTableCell,null,"For more information, visit the Advanced Search page.")),e.createElement(r.SpsTableRow,null,e.createElement(r.SpsTableCell,null,e.createElement("span",{className:"sps-tag sps-tag--info"},"5")),e.createElement(r.SpsTableCell,null,"Column Editor"),e.createElement(r.SpsTableCell,{wrap:500},"Use for Tables only. For more information, visit the Column Editor page.")),e.createElement(r.SpsTableRow,null,e.createElement(r.SpsTableCell,null,e.createElement("span",{className:"sps-tag sps-tag--info"},"6")),e.createElement(r.SpsTableCell,null,"List View Selector"),e.createElement(r.SpsTableCell,null)),e.createElement(r.SpsTableRow,null,e.createElement(r.SpsTableCell,null,e.createElement("span",{className:"sps-tag sps-tag--info"},"7")),e.createElement(r.SpsTableCell,null,"Sorting"),e.createElement(r.SpsTableCell,null)),e.createElement(r.SpsTableRow,null,e.createElement(r.SpsTableCell,null,e.createElement("span",{className:"sps-tag sps-tag--info"},"8")),e.createElement(r.SpsTableCell,null,"Buttons"),e.createElement(r.SpsTableCell,{wrap:500},"Buttons always appear in the rightmost section of the List Toolbar. For the ordering of Buttons, refer to the Button Groups section on the Buttons page."))))))}const ye={description:()=>e.createElement("p",null,"The List Toolbar provides the ability to interact with elements in a list or table. It can contain elements to search, filter, sort, or perform other actions."),components:[w,y,C,R],examples:{general:{label:"General Usage",description:()=>e.createElement(e.Fragment,null,e.createElement("h5",null,"Use a List Toolbar:"),e.createElement("ul",null,e.createElement("li",null,"When list content needs to be searched, filtered, sorted, or otherwise interacted with.")),e.createElement("h5",null,"Avoid a List Toolbar:"),e.createElement("ul",null,e.createElement("li",null,"When no list is present."),e.createElement("li",null,"When there will always be a small number of elements in the list, or the list does not require searching, filtering, or other actions.")))},contentOrder:{label:"Content Order",description:e.createElement(Le,null)},checkbox:{label:"Checkbox",description:({NavigateTo:t})=>e.createElement("p",null,"Use a Checkbox in the List Bar when items in a"," ",e.createElement(t,{to:"content-row"},"Content Row")," or"," ",e.createElement(t,{to:"content-tile"},"Content Tile")," are selectable. The Checkbox selects all items in the list, and will cause the Action Bar to appear. Do not use this with a Table, as Tables have a built-in checkbox in the header row."),examples:{basic:{react:o.code`
220
+ import { ListBar, ListBarSearch } from "@sps-woodland/list-bar";
221
+
222
+ function Component() {
223
+ const { formValue, formMeta, updateForm } = useSpsForm({
224
+ searchText: "",
225
+ });
226
+
227
+ function handleSearch(event) {
228
+ console.log(event, formValue.searchText)
229
+ }
230
+
231
+ const [selectedColors, setSelectedColors] = React.useState([]);
232
+ colors = ['Red', 'Blue', 'Green']
233
+
234
+ const isIndeterminate = selectedColors.length > 0 && selectedColors.length < colors.length
235
+ const isSelected = selectedColors.length > 0
236
+
237
+ return (
238
+ <>
239
+ <ListBar
240
+ selectable
241
+ isIndeterminate={isIndeterminate}
242
+ isSelected={isSelected}
243
+ onSelectionChange={() => {
244
+ if (isIndeterminate || isSelected) {
245
+ setSelectedColors([])
246
+ } else {
247
+ etSelectedColors(colors);
248
+ }
249
+ }}
250
+ data-testid="list-bar"
251
+ >
252
+ <ListBarSearch onSubmit={handleSearch}>
253
+ <SpsTextInput
254
+ value={formValue.searchText}
255
+ formMeta={formMeta.fields.searchText}
256
+ icon={SpsIcon.FILTER}
257
+ placeholder="Filter fields"
258
+ />
259
+ </ListBarSearch>
260
+ </ListBar>
261
+ {colors.map((color) => (
262
+ <SpsCheckbox
263
+ checked={selectedColors.includes(color)}
264
+ inline
265
+ label={color}
266
+ onChange={() => {
267
+ if (selectedColors.includes(color)) {
268
+ setSelectedColors(selectedColors.filter((c) => c !== color))
269
+ } else {
270
+ setSelectedColors([...selectedColors, color])
271
+ }
272
+ }
273
+ }
274
+ />
275
+ ))}
276
+ </>
277
+ )
278
+ }
279
+ `}}},searchAndFilter:{label:"Search + Filter Inputs",description:()=>e.createElement("p",null,"Use Search and Filter inputs to make it easier to quickly find list items."),examples:{search:{description:()=>e.createElement(e.Fragment,null,e.createElement("h5",null,"Search"),e.createElement("p",null,"Use Search to find list item(s) starting from an empty list.")),react:o.code`
280
+ import { ListBar, ListBarSearch } from "@sps-woodland/list-bar";
281
+ import { Button } from "@sps-woodland/buttons";
282
+
283
+ function Component() {
284
+ const { formValue, formMeta, updateForm } = useSpsForm({
285
+ searchText: "",
286
+ });
287
+
288
+ function handleSearch(event) {
289
+ console.log(event, formValue.searchText)
290
+ }
291
+
292
+ return (
293
+ <ListBar>
294
+ <ListBarSearch onSubmit={handleSearch}>
295
+ <SpsTextInput
296
+ value={formValue.searchText}
297
+ formMeta={formMeta.fields.searchText}
298
+ placeholder="Search fields"
299
+ />
300
+ <Button kind="icon" icon="search" type="submit" />
301
+ </ListBarSearch>
302
+ </ListBar>
303
+ )
304
+ }
305
+ `},searchAndSelect:{description:()=>e.createElement(e.Fragment,null,e.createElement("h5",null,"Search + Select"),e.createElement("p",null,"Use Select to search for list item(s) in a particular category.")),react:o.code`
306
+ import { ListBar, ListBarSearch } from "@sps-woodland/list-bar";
307
+ import { Button } from "@sps-woodland/buttons";
308
+ import { SpsSelect, SpsTextInput } from "@spscommerce/ds-react";
309
+
310
+ function Component() {
311
+ const filterKeys = ["Document Type", "Sender Name", "Receiver Name"];
312
+
313
+ const { formValue, formMeta, updateForm } = useSpsForm({
314
+ searchText: "",
315
+ filterOption: filterKeys[0],
316
+ });
317
+
318
+ function handleSearch(event) {
319
+ console.log(event, formValue.searchText)
320
+ }
321
+
322
+ return (
323
+ <ListBar>
324
+ <ListBarSearch onSubmit={handleSearch}>
325
+ <SpsSelect
326
+ options={filterKeys}
327
+ formMeta={formMeta.fields.filterOption}
328
+ value={formValue.filterOption}
329
+ notClearable
330
+ />
331
+ <SpsTextInput
332
+ value={formValue.searchText}
333
+ formMeta={formMeta.fields.searchText}
334
+ placeholder="Search fields"
335
+ />
336
+ <Button kind="icon" icon="search" type="submit" />
337
+ </ListBarSearch>
338
+ </ListBar>
339
+ )
340
+ }
341
+ `},filter:{description:()=>e.createElement(e.Fragment,null,e.createElement("h5",null,"Filter"),e.createElement("p",null,"Use Filter to find list item(s) starting from a populated list.")),react:o.code`
342
+ import { ListBar, ListBarSearch } from "@sps-woodland/list-bar";
343
+ import { Button } from "@sps-woodland/buttons";
344
+ import { SpsTextInput } from "@spscommerce/ds-react";
345
+
346
+ function Component() {
347
+ const { formValue, formMeta, updateForm } = useSpsForm({
348
+ searchText: "",
349
+ });
350
+
351
+ function handleSearch(event) {
352
+ console.log(event, formValue.searchText)
353
+ }
354
+
355
+ return (
356
+ <ListBar>
357
+ <ListBarSearch onSubmit={handleSearch}>
358
+ <SpsTextInput
359
+ value={formValue.searchText}
360
+ formMeta={formMeta.fields.searchText}
361
+ icon={SpsIcon.FILTER}
362
+ placeholder="Filter fields"
363
+ />
364
+ </ListBarSearch>
365
+ </ListBar>
366
+ )
367
+ }
368
+ `},filterAndSelect:{description:()=>e.createElement(e.Fragment,null,e.createElement("h5",null,"Filter + Select"),e.createElement("p",null,"Use Select to filter list item(s) in a particular category.")),react:o.code`
369
+ import { ListBar, ListBarSearch } from "@sps-woodland/list-bar";
370
+ import { Button } from "@sps-woodland/buttons";
371
+ import { SpsSelect, SpsTextInput } from "@spscommerce/ds-react";
372
+
373
+ function Component() {
374
+ const filterKeys = ["Document Type", "Sender Name", "Receiver Name"];
375
+
376
+ const { formValue, formMeta, updateForm } = useSpsForm({
377
+ searchText: "",
378
+ filterOption: filterKeys[0],
379
+ });
380
+
381
+ function handleSearch(event) {
382
+ console.log(event, formValue.searchText)
383
+ }
384
+
385
+ return (
386
+ <ListBar>
387
+ <ListBarSearch onSubmit={handleSearch}>
388
+ <SpsSelect
389
+ options={filterKeys}
390
+ formMeta={formMeta.fields.filterOption}
391
+ value={formValue.filterOption}
392
+ notClearable
393
+ />
394
+ <SpsTextInput
395
+ value={formValue.searchText}
396
+ formMeta={formMeta.fields.searchText}
397
+ icon={SpsIcon.FILTER}
398
+ placeholder="Filter fields"
399
+ />
400
+ </ListBarSearch>
401
+ </ListBar>
402
+ )
403
+ }
404
+ `},searchInfo:{description:()=>e.createElement(e.Fragment,null,e.createElement("h5",null,"Search Info"),e.createElement("p",null,"Use SpsListToolbarSearchInfo component to add additional information about your search.")),react:o.code`
405
+ import { ListBar, ListBarSearch, ListBarSearchInfo } from "@sps-woodland/list-bar";
406
+ import { Icon } from "@sps-woodland/core";
407
+ import { SpsSelect, SpsTextInput } from "@spscommerce/ds-react";
408
+
409
+ function Component() {
410
+ const filterKeys = ["Key Item ID", "Document Type", "Sender Name", "Receiver Name"];
411
+
412
+ const { formValue, formMeta, updateForm } = useSpsForm({
413
+ searchText: "",
414
+ filterOption: filterKeys[0],
415
+ });
416
+
417
+ function handleSearch(event) {
418
+ console.log(event, formValue.searchText)
419
+ }
420
+
421
+ return (
422
+ <ListBar>
423
+ <ListBarSearch onSubmit={handleSearch}>
424
+ <SpsSelect
425
+ options={filterKeys}
426
+ formMeta={formMeta.fields.filterOption}
427
+ value={formValue.filterOption}
428
+ notClearable
429
+ />
430
+ <SpsTextInput
431
+ value={formValue.searchText}
432
+ formMeta={formMeta.fields.searchText}
433
+ icon={SpsIcon.FILTER}
434
+ placeholder="Filter fields"
435
+ />
436
+ </ListBarSearch>
437
+ <ListBarSearchInfo>
438
+ <div style={{ display: 'flex', alignItems: 'center'}}>
439
+ <span style={{ marginRight: 5 }} >
440
+ Key Item ID = Vendor Part Number
441
+ </span>
442
+ <Icon icon="info-circle" className="blue200"/>
443
+ </div>
444
+ </ListBarSearchInfo>
445
+ </ListBar>
446
+ )
447
+ }
448
+ `}}},advancedSearch:{label:"Advanced Search",description:({NavigateTo:t})=>e.createElement("p",null,"Include the Advanced Search feature when more complex options are required to narrow down search results. For more information, visit the"," ",e.createElement(t,{to:"advanced-search"},"Advanced Search")," page."),examples:{advancedSearch:{react:o.code`
449
+ import { ListBar, ListBarSearch, AdvancedSearch } from "@sps-woodland/list-bar";
450
+ import { Button } from "@sps-woodland/buttons";
451
+ import { SpsTextInput } from "@spscommerce/ds-react";
452
+
453
+ function Component() {
454
+ const [advSearch, setAdvSearch] = React.useState({
455
+ isOpen: false,
456
+ controlsDisabled: true,
457
+ });
458
+
459
+ const { formValue, formMeta, updateForm } = useSpsForm({
460
+ searchText: "",
461
+ });
462
+
463
+ function handleToggleAdvancedSearch(isOpen) {
464
+ setAdvSearch({ isOpen });
465
+ }
466
+
467
+ return (
468
+ <>
469
+ <ListBar
470
+ advancedSearch={advSearch}
471
+ onToggleAdvancedSearch={handleToggleAdvancedSearch}
472
+ >
473
+ <ListBarSearch>
474
+ <SpsTextInput
475
+ value={formValue.searchText}
476
+ formMeta={formMeta.fields.searchText}
477
+ placeholder="Search fields"
478
+ />
479
+ <Button kind="icon" icon="search" />
480
+ </ListBarSearch>
481
+ </ListBar>
482
+ <AdvancedSearch {...advSearch}>
483
+ <i>insert form here</i>
484
+ </AdvancedSearch>
485
+ </>
486
+ )
487
+ }
488
+ `},withResultsBar:{description:({NavigateTo:t})=>e.createElement("p",null,"You can include ",e.createElement(t,{to:"search-results-bar"},"Search Results Bar"),"."),react:o.code`
489
+ import { ListBar, ListBarSearch, SearchResultsBar, AdvancedSearch } from "@sps-woodland/list-bar";
490
+ import { Button } from "@sps-woodland/buttons";
491
+ import { SpsTextInput, SpsLabel, SpsMultiselect } from "@spscommerce/ds-react";
492
+
493
+ function Component() {
494
+ const senderOptions = ["Aktie Sports", "FGL Sports","Modells Sporting Goods", "Perry Sport", "Sportman Warhouse Australia"];
495
+ const receiverOptions = ["FGL Sports", "Foot Asylum", "Hervis", "Lovell Rugby", "Aktie Sports"];
496
+ const doctypeOptions = [".doc", ".txt", ".pdf"];
497
+ const statusOptions = ["pending", "done"];
498
+
499
+ const [advSearch, setAdvSearch] = React.useState({
500
+ isOpen: false
501
+ });
502
+
503
+ const [showSearchBar, setShowSearchBar] = React.useState(true);
504
+
505
+ const [selections, setSelections] = React.useState();
506
+ const [results, setResults] = React.useState(0);
507
+
508
+ const initValue = {
509
+ searchText: "",
510
+ sender: [],
511
+ receiver: [],
512
+ doctype: [],
513
+ status: [],
514
+ };
515
+
516
+ const { formValue, formMeta, updateForm } = useSpsForm(initValue);
517
+
518
+ function handleToggleAdvancedSearch(isOpen) {
519
+ setAdvSearch({ isOpen });
520
+ }
521
+
522
+ function handleAdvancedSearchSubmit() {
523
+ console.log("submit");
524
+ setShowSearchBar(true);
525
+ setSelections(omit(formValue, "searchText"));
526
+ setResults(Math.floor(Math.random() * 100));
527
+ }
528
+
529
+ function handleAdvancedSearchClear() {
530
+ updateForm(initValue);
531
+ }
532
+
533
+ return (
534
+ <>
535
+ <ListBar advancedSearch={advSearch}
536
+ onToggleAdvancedSearch={handleToggleAdvancedSearch}
537
+ >
538
+ <ListBarSearch>
539
+ <SpsTextInput
540
+ value={formValue.searchText}
541
+ formMeta={formMeta.fields.searchText}
542
+ placeholder="Search fields"
543
+ />
544
+ <Button kind="icon" icon="search" />
545
+ </ListBarSearch>
546
+ <Button className={sprinkles({ mr: "sm" })} kind="icon" icon="download-cloud" />
547
+ <Button className={sprinkles({ mr: "sm" })}>Button</Button>
548
+ <Button kind="key">Button</Button>
549
+ {showSearchBar && (
550
+ <SearchResultsBar
551
+ results={results}
552
+ selections={selections}
553
+ onClear={() => setShowSearchBar(false)}
554
+ />
555
+ )}
556
+ </ListBar>
557
+ <AdvancedSearch {...advSearch}
558
+ formMeta={formMeta}
559
+ onSubmit={handleAdvancedSearchSubmit}
560
+ onClear={handleAdvancedSearchClear}
561
+ >
562
+ <div className="sfg-row">
563
+ <div className="sfg-col-4">
564
+ <SpsLabel for={formMeta.fields.sender}>Sender</SpsLabel>
565
+ <SpsMultiSelect
566
+ formMeta={formMeta.fields.sender}
567
+ value={formValue.sender}
568
+ options={senderOptions}
569
+ />
570
+ </div>
571
+ <div className="sfg-col-4">
572
+ <SpsLabel for={formMeta.fields.receiver}>Receiver</SpsLabel>
573
+ <SpsMultiSelect
574
+ formMeta={formMeta.fields.receiver}
575
+ value={formValue.receiver}
576
+ options={receiverOptions}
577
+ />
578
+ </div>
579
+ <div className="sfg-col-4">
580
+ <SpsLabel for={formMeta.fields.doctype}>Document Type</SpsLabel>
581
+ <SpsMultiSelect
582
+ formMeta={formMeta.fields.doctype}
583
+ value={formValue.doctype}
584
+ options={doctypeOptions}
585
+ />
586
+ </div>
587
+ <div className="sfg-col-4">
588
+ <SpsLabel for={formMeta.fields.status}>Status</SpsLabel>
589
+ <SpsMultiSelect
590
+ formMeta={formMeta.fields.status}
591
+ value={formValue.status}
592
+ options={statusOptions}
593
+ />
594
+ </div>
595
+ </div>
596
+ </AdvancedSearch>
597
+ </>
598
+ )
599
+ }
600
+ `},pinnedResultsBar:{description:()=>e.createElement("p",null,"You can pin the Results Bar by passing pinResultsBar prop to SpsListToolbar."),react:o.code`
601
+ import { ListBar, ListBarSearch, SearchResultsBar, AdvancedSearch } from "@sps-woodland/list-bar";
602
+ import { Button } from "@sps-woodland/buttons";
603
+ import { SpsTextInput } from "@spscommerce/ds-react";
604
+
605
+ function Component() {
606
+ const [advSearch, setAdvSearch] = React.useState({
607
+ isOpen: false
608
+ });
609
+
610
+ const [showSearchBar, setShowSearchBar] = React.useState(true);
611
+
612
+ const [results, setResults] = React.useState(0);
613
+
614
+ const initValue = {
615
+ searchText: "",
616
+ };
617
+
618
+ const { formValue, formMeta, updateForm } = useSpsForm(initValue);
619
+
620
+ function handleToggleAdvancedSearch(isOpen) {
621
+ setAdvSearch({ isOpen });
622
+ }
623
+
624
+ function handleAdvancedSearchSubmit() {
625
+ setShowSearchBar(true);
626
+ setResults(Math.floor(Math.random() * 100));
627
+ }
628
+
629
+ function handleAdvancedSearchClear() {
630
+ updateForm(initValue);
631
+ }
632
+
633
+ return (
634
+ <>
635
+ <ListBar advancedSearch={advSearch}
636
+ onToggleAdvancedSearch={handleToggleAdvancedSearch}
637
+ pinResultsBar
638
+ >
639
+ <ListBarSearch>
640
+ <SpsTextInput
641
+ value={formValue.searchText}
642
+ formMeta={formMeta.fields.searchText}
643
+ placeholder="Search fields"
644
+ />
645
+ <Button kind="icon" icon="search" />
646
+ </ListBarSearch>
647
+ <Button className={sprinkles({ mr: "sm" })} kind="icon" icon="download-cloud" />
648
+ <Button className={sprinkles({ mr: "sm" })}>Button</Button>
649
+ <Button kind="key">Button</Button>
650
+ {showSearchBar && (
651
+ <SearchResultsBar
652
+ results={results}
653
+ onClear={() => setShowSearchBar(false)}
654
+ />
655
+ )}
656
+ </ListBar>
657
+ <AdvancedSearch {...advSearch}
658
+ onSubmit={handleAdvancedSearchSubmit}
659
+ >
660
+ <i>insert form here</i>
661
+ </AdvancedSearch>
662
+ </>
663
+ )
664
+ }
665
+ `}}},columnEditor:{label:"Column Editor",description:({NavigateTo:t})=>e.createElement("p",null,"Use a Column Editor when tables require the ability to show or hide specific columns based on the user's preferences. The Column Editor should only be used for"," ",e.createElement(t,{to:"tables"},"Tables"),", and not any other type of list view. For more information, visit the ",e.createElement(t,{to:"column-chooser"},"Column Editor")," page."),examples:{columnEditor:{react:o.code`
666
+ import { ListBar, ListBarSearch } from "@sps-woodland/list-bar";
667
+ import { Button } from "@sps-woodland/buttons";
668
+
669
+ function Component() {
670
+ const unselectedCols = [
671
+ { name: "Title" },
672
+ ];
673
+ const selectedCols = [
674
+ { name: "Documents" },
675
+ { name: "Price" },
676
+ ]
677
+
678
+ const { formValue, formMeta, updateForm } = useSpsForm({
679
+ searchText: "",
680
+ });
681
+
682
+ function handleSearch(event) {
683
+ console.log(event, formValue.searchText)
684
+ }
685
+
686
+ return (
687
+ <ListBar>
688
+ <ListBarSearch onSubmit={handleSearch}>
689
+ <SpsTextInput
690
+ value={formValue.searchText}
691
+ formMeta={formMeta.fields.searchText}
692
+ placeholder="Search fields"
693
+ />
694
+ <Button kind="icon" icon="search" type="submit" />
695
+ </ListBarSearch>
696
+ <SpsColumnChooser
697
+ unselectedColumns={unselectedCols}
698
+ selectedColumns={selectedCols}
699
+ onApplyChanges={(selectedColumns) => {console.log(selectedColumns)}}
700
+ />
701
+ </ListBar>
702
+ )
703
+ }
704
+ `}}},buttons:{label:"Buttons",description:({NavigateTo:t})=>e.createElement("p",null,"Use Buttons only for actions that do not affect existing list items, such as exporting the list or creating a new list item. For actions that are taken on list items, such as changing a status of a list item, refer to the"," ",e.createElement(t,{to:"list-action-bar"},"List Action Bar"),"."),examples:{buttons:{react:o.code`
705
+ import { ListBar, ListBarSearch } from "@sps-woodland/list-bar";
706
+ import { Button } from "@sps-woodland/buttons";
707
+ import { SpsTextInput } from "@spscommerce/ds-react";
708
+
709
+ function Component() {
710
+ const { formValue, formMeta, updateForm } = useSpsForm({
711
+ searchText: "",
712
+ });
713
+
714
+ function handleSearch(event) {
715
+ console.log(event, formValue.searchText)
716
+ }
717
+
718
+ return (
719
+ <ListBar>
720
+ <ListBarSearch onSubmit={handleSearch}>
721
+ <SpsTextInput
722
+ value={formValue.searchText}
723
+ formMeta={formMeta.fields.searchText}
724
+ placeholder="Search fields"
725
+ />
726
+ <Button kind="icon" icon="search" type="submit" />
727
+ </ListBarSearch>
728
+ <Button className={sprinkles({ mr: "sm" })} kind="link">Text Button</Button>
729
+ <Button className={sprinkles({ mr: "sm" })} kind="icon" icon="download-cloud" />
730
+ <Button className={sprinkles({ mr: "sm" })}>Button</Button>
731
+ <Button kind="key">Button</Button>
732
+ </ListBar>
733
+ )
734
+ }
735
+ `}}},tabs:{label:"Tabs",description:({NavigateTo:t})=>e.createElement(e.Fragment,null,e.createElement("p",null,"When tabs are included, they appear above the List Toolbar. Tab rules are outlined on the ",e.createElement(t,{to:"cards"},"Cards")," page."),e.createElement("p",null,e.createElement("code",null,"<Item>")," comes from the ",e.createElement("code",null,"@react-stately/collections"),"package, which is a peer dependency of our React components.")),examples:{tabs:{react:o.code`
736
+ import { ListBar, ListBarSearch } from "@sps-woodland/list-bar";
737
+ import { Button } from "@sps-woodland/buttons";
738
+ import { SpsSelect, SpsTextInput } from "@spscommerce/ds-react";
739
+ import { Item } from "@react-stately/collections";
740
+
741
+ function Component() {
742
+ const filterKeys = ["Document Type", "Sender Name", "Receiver Name"];
743
+ const { formValue, formMeta, updateForm } = useSpsForm({
744
+ searchText: "",
745
+ })
746
+
747
+ function handleTabChange(tab) {
748
+ console.log(tab);
749
+ }
750
+
751
+ return (
752
+ <ListBar
753
+ onTabChange={handleTabChange}
754
+ >
755
+ <Tabs>
756
+ <Item key="tab1" title="Tab 1">
757
+ <ListBarSearch>
758
+ <SpsTextInput formMeta={formMeta.fields.searchText} value={formValue.searchText} placeholder="Search fields" />
759
+ <Button kind="icon" icon="search" type="submit" />
760
+ </ListBarSearch>
761
+ </Item>
762
+ <Item key="tab2" title="Tab 2">
763
+ <ListBarSearch>
764
+ <SpsSelect
765
+ options={filterKeys}
766
+ notClearable
767
+ />
768
+ <SpsTextInput
769
+ value={formValue.searchText}
770
+ formMeta={formMeta.fields.searchText}
771
+ icon={SpsIcon.FILTER}
772
+ placeholder="Filter fields"
773
+ />
774
+ </ListBarSearch>
775
+ </Item>
776
+ </Tabs>
777
+ </ListBar>
778
+ )
779
+ }
780
+ `}}},title:{label:"Title",description:({NavigateTo:t})=>e.createElement("p",null,"Use Titles when there is no Search or Filter input required for the list items, such as when the only search options are in an Advanced Search panel. For more information, visit the ",e.createElement(t,{to:"advanced-search"},"Advanced Search")," page."),examples:{title:{react:o.code`
781
+ import { ListBar } from "@sps-woodland/list-bar";
782
+ import { Button } from "@sps-woodland/buttons";
783
+
784
+ function Component() {
785
+ return (
786
+ <ListBar title="Good List Title">
787
+ <Button>Button</Button>
788
+ </ListBar>
789
+ )
790
+ }
791
+ `}}},sortBy:{label:"Sort By",description:()=>e.createElement("p",null,"Use Sort By component to sort list of rows. It looks like SpsDropdown but with sorting interface."),examples:{basic:{react:o.code`
792
+ import { ListBar, ListBarSortBy } from "@sps-woodland/list-bar";
793
+ import { Button } from "@sps-woodland/buttons";
794
+ import { VerticalRule } from "@sps-woodland/core";
795
+
796
+ function Component() {
797
+ const [activeOption, setActiveOption] = React.useState(null);
798
+ const defaultOption = {
799
+ label: "Default",
800
+ key: "default",
801
+ direction: SortDirection.ASCENDING,
802
+ icon: SpsIcon.SORT_ALPHA_ASC,
803
+ }
804
+ const options = [
805
+ defaultOption,
806
+ {
807
+ label: "Company Name: A-Z",
808
+ key: "name",
809
+ direction: SortDirection.ASCENDING,
810
+ icon: SpsIcon.SORT_ALPHA_ASC,
811
+ },
812
+ {
813
+ label: "Company Name: Z-A",
814
+ key: "name",
815
+ direction: SortDirection.DESCENDING,
816
+ icon: SpsIcon.SORT_ALPHA_DESC,
817
+ },
818
+ {
819
+ label: 'Created Date: Oldest to Newest',
820
+ key: 'created',
821
+ direction: SortDirection.ASCENDING,
822
+ icon: SpsIcon.SORT_NUM_ASC,
823
+ },
824
+ {
825
+ label: 'Created Date: Newest to Oldest',
826
+ key: 'created',
827
+ direction: SortDirection.DESCENDING,
828
+ icon: SpsIcon.SORT_NUM_DESC,
829
+ }
830
+ ]
831
+
832
+ return (
833
+ <ListBar title="List of sortable rows">
834
+ <Button kind="icon" icon="download-cloud" />
835
+ <VerticalRule />
836
+ <ListBarSortBy
837
+ options={options}
838
+ activeOption={activeOption}
839
+ defaultOption={defaultOption}
840
+ onSortChange={(option) => setActiveOption(option)}
841
+ />
842
+ <VerticalRule />
843
+ <Button kind="confirm">Create New</Button>
844
+ </ListBar>
845
+ )
846
+ }
847
+ `}}}}},Ce={components:[x],examples:{basic:{label:"Basic",description:({NavigateTo:t})=>e.createElement(e.Fragment,null,e.createElement("p",null,"The SearchResultsBar should be used with List Bar and Advanced Search."),e.createElement("p",null,"For more examples go to the Advanced Search section on the"," ",e.createElement(t,{to:"list-bar"},"List Bar")," page.")),examples:{basic:{react:o.code`
848
+ import { ListBar, ListBarSearch, SearchResultsBar, AdvancedSearch } from "@sps-woodland/list-bar";
849
+ import { Button } from "@sps-woodland/buttons";
850
+ import { SpsTextInput } from "@spscommerce/ds-react";
851
+
852
+ function Component() {
853
+ const [advSearch, setAdvSearch] = React.useState({
854
+ isOpen: false
855
+ });
856
+
857
+ const [showSearchBar, setShowSearchBar] = React.useState(true);
858
+
859
+ const [results, setResults] = React.useState(10);
860
+
861
+ const initialSelections = {
862
+ sender: ["Aktie Sports","Modells Sporting Goods", "Perry Sport"],
863
+ receiver: ["FGL Sports", "Foot Asylum", "Hervis", "Lovell Rugby"],
864
+ };
865
+
866
+ const [selections, setSelections] = React.useState(initialSelections);
867
+
868
+ const initValue = {
869
+ searchText: "",
870
+ };
871
+
872
+ const { formValue, formMeta, updateForm } = useSpsForm(initValue);
873
+
874
+ function handleToggleAdvancedSearch(isOpen) {
875
+ setAdvSearch({ isOpen });
876
+ }
877
+
878
+ function handleAdvancedSearchSubmit() {
879
+ console.log("submit");
880
+ setResults(10);
881
+ setSelections(initialSelections);
882
+ }
883
+
884
+ function handleClear() {
885
+ setResults(0);
886
+ setSelections({});
887
+ }
888
+
889
+ return (
890
+ <>
891
+ <ListBar
892
+ advancedSearch={advSearch}
893
+ onToggleAdvancedSearch={handleToggleAdvancedSearch}
894
+ >
895
+ <ListBarSearch>
896
+ <SpsTextInput
897
+ value={formValue.searchText}
898
+ formMeta={formMeta.fields.searchText}
899
+ placeholder="Search fields"
900
+ />
901
+ <Button kind="icon" icon="search" />
902
+ </ListBarSearch>
903
+ <SearchResultsBar
904
+ results={results}
905
+ onClear={handleClear}
906
+ selections={selections}
907
+ />
908
+ </ListBar>
909
+ <AdvancedSearch {...advSearch} onSubmit={handleAdvancedSearchSubmit}>
910
+ <i>insert form here</i>
911
+ </AdvancedSearch>
912
+ </>
913
+ )
914
+ }
915
+ `},situational:{description:()=>e.createElement(e.Fragment,null,e.createElement("h4",null,"Unknown Results Count"),e.createElement("p",null,"In cases where the exact count of results is not able to be determined, Results section won't be displayed.")),react:o.code`
916
+ import { ListBar, ListBarSearch, SearchResultsBar, AdvancedSearch } from "@sps-woodland/list-bar";
917
+ import { Button } from "@sps-woodland/buttons";
918
+ import { SpsTextInput } from "@spscommerce/ds-react";
919
+
920
+ function Component() {
921
+ const [advSearch, setAdvSearch] = React.useState({
922
+ isOpen: false
923
+ });
924
+
925
+ const [showSearchBar, setShowSearchBar] = React.useState(true);
926
+
927
+ const initialSelections = {
928
+ sender: ["Aktie Sports","Modells Sporting Goods", "Perry Sport"],
929
+ receiver: ["FGL Sports", "Foot Asylum", "Hervis", "Lovell Rugby"],
930
+ };
931
+
932
+ const [selections, setSelections] = React.useState(initialSelections);
933
+
934
+ const initValue = {
935
+ searchText: "",
936
+ };
937
+
938
+ const { formValue, formMeta, updateForm } = useSpsForm(initValue);
939
+
940
+ function handleToggleAdvancedSearch(isOpen) {
941
+ setAdvSearch({ isOpen });
942
+ }
943
+
944
+ function handleAdvancedSearchSubmit() {
945
+ console.log("submit");
946
+ setSelections(initialSelections);
947
+ }
948
+
949
+ function handleClear() {
950
+ setSelections({});
951
+ }
952
+
953
+ return (
954
+ <>
955
+ <ListBar
956
+ advancedSearch={advSearch}
957
+ onToggleAdvancedSearch={handleToggleAdvancedSearch}
958
+ >
959
+ <ListBarSearch>
960
+ <SpsTextInput
961
+ value={formValue.searchText}
962
+ formMeta={formMeta.fields.searchText}
963
+ placeholder="Search fields"
964
+ />
965
+ <Button kind="icon" icon="search" />
966
+ </ListBarSearch>
967
+ <SearchResultsBar
968
+ onClear={handleClear}
969
+ selections={selections}
970
+ />
971
+ </ListBar>
972
+ <AdvancedSearch {...advSearch} onSubmit={handleAdvancedSearchSubmit}>
973
+ <i>insert form here</i>
974
+ </AdvancedSearch>
975
+ </>
976
+ )
977
+ }
978
+ `}}},customText:{label:"Custom Text",description:()=>e.createElement("p",null,"You can pass in custom text to be displayed when there are no selections."),examples:{customText:{react:o.code`
979
+ import { ListBar, ListBarSearch, SearchResultsBar, AdvancedSearch } from "@sps-woodland/list-bar";
980
+ import { Button } from "@sps-woodland/buttons";
981
+ import { SpsTextInput } from "@spscommerce/ds-react";
982
+
983
+ function Component() {
984
+ const [advSearch, setAdvSearch] = React.useState({
985
+ isOpen: false
986
+ });
987
+
988
+ const [showSearchBar, setShowSearchBar] = React.useState(true);
989
+
990
+ const [results, setResults] = React.useState(0);
991
+
992
+ const initialSelections = {
993
+ sender: ["Aktie Sports","Modells Sporting Goods", "Perry Sport"],
994
+ receiver: ["FGL Sports", "Foot Asylum", "Hervis", "Lovell Rugby"],
995
+ };
996
+
997
+ const [selections, setSelections] = React.useState({});
998
+
999
+ const initValue = {
1000
+ searchText: "",
1001
+ };
1002
+
1003
+ const { formValue, formMeta, updateForm } = useSpsForm(initValue);
1004
+
1005
+ function handleToggleAdvancedSearch(isOpen) {
1006
+ setAdvSearch({ isOpen });
1007
+ }
1008
+
1009
+ function handleAdvancedSearchSubmit() {
1010
+ console.log("submit");
1011
+ setResults(10);
1012
+ setSelections(initialSelections);
1013
+ }
1014
+
1015
+ function handleClear() {
1016
+ setResults(0);
1017
+ setSelections({});
1018
+ }
1019
+
1020
+ return (
1021
+ <>
1022
+ <ListBar
1023
+ advancedSearch={advSearch}
1024
+ onToggleAdvancedSearch={handleToggleAdvancedSearch}
1025
+ >
1026
+ <ListBarSearch>
1027
+ <SpsTextInput
1028
+ value={formValue.searchText}
1029
+ formMeta={formMeta.fields.searchText}
1030
+ placeholder="Search fields"
1031
+ />
1032
+ <Button kind="icon" icon="search" />
1033
+ </ListBarSearch>
1034
+ <SearchResultsBar
1035
+ results={results}
1036
+ onClear={handleClear}
1037
+ selections={selections}
1038
+ zeroStateText="There are no selections here"
1039
+ />
1040
+ </ListBar>
1041
+ <AdvancedSearch {...advSearch} onSubmit={handleAdvancedSearchSubmit}>
1042
+ <i>insert form here</i>
1043
+ </AdvancedSearch>
1044
+ </>
1045
+ )
1046
+ }
1047
+ `}}}}},xe={"Advanced Search":Ee,"List Bar":ye,"Search Results Bar":Ce};exports.AdvancedSearch=F;exports.InputGroupWrapper=G;exports.ListBar=w;exports.ListBarSearch=y;exports.ListBarSearchInfo=C;exports.ListBarSortBy=R;exports.MANIFEST=xe;exports.SearchResultsBar=x;