react-addsearch-ui 0.1.2
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/LICENSE +21 -0
- package/README.md +134 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.es.js +9420 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +247 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +98 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 AddSearch Oy https://www.addsearch.com/
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# React AddSearch UI
|
|
2
|
+
|
|
3
|
+
Implemements [AddSearch](www.addsearch.com)'s [search-ui](https://github.com/AddSearch/search-ui)
|
|
4
|
+
package as a ReactJS library exposing one single Component for Integration.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
### 1. Add `react-addsearch-ui` to your dependencies:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i react-addsearch-ui
|
|
12
|
+
// pnpm i react-addsearch-ui
|
|
13
|
+
// yarn add react-addsearch-ui
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### 2. Import and configure `AddSearchUiIntegration` component
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { AddSearchUiIntegration } from 'react-addsearch-ui';
|
|
20
|
+
import 'react-addsearch-ui/dist/style.css';
|
|
21
|
+
|
|
22
|
+
export default function App() {
|
|
23
|
+
return (
|
|
24
|
+
<div className="flex flex-col w-full h-full gap-6 p-6 items-center">
|
|
25
|
+
<h1>My React AddSearch UI Integration Example</h1>
|
|
26
|
+
<AddSearchUiIntegration publicSiteKey="YOUR_PUBLIC_SITEKEY(as ENV VAR ideally)" />
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- `publicSiteKey` can be found in your dashboard
|
|
33
|
+
|
|
34
|
+
### 3. Brand your Search UI
|
|
35
|
+
|
|
36
|
+
#### Brand Color:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<AddSearchUiIntegration publicSiteKey="YOUR_PUBLIC_SITEKEY" primaryColor="#004225" />
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Custom Font:
|
|
43
|
+
|
|
44
|
+
Load font, e.g. by adding to your document head, e.g.:
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
48
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
49
|
+
<link
|
|
50
|
+
href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
|
|
51
|
+
rel="stylesheet"
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
then use the customFont property on `AddSearchUiIntegration`:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<AddSearchUiIntegration
|
|
59
|
+
publicSiteKey="YOUR_PUBLIC_SITEKEY"
|
|
60
|
+
primaryColor="#004225"
|
|
61
|
+
customFont="Poppins"
|
|
62
|
+
/>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 4. Configure the UI
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
<AddSearchUiIntegration
|
|
69
|
+
publicSiteKey="YOUR_PUBLIC_SITEKEY"
|
|
70
|
+
primaryColor="#004225" // default AddSearch primary color
|
|
71
|
+
customFont="Poppins" // no default
|
|
72
|
+
searchFieldHeaderText="Search" // no default
|
|
73
|
+
searchButtonText="Apply" // no default
|
|
74
|
+
hasSearchInputFieldIcon={false} // default true
|
|
75
|
+
hasSearchInputAutofocus={false} // default true
|
|
76
|
+
searchInputPlaceholderText="What are you looking for?" // default "keyword"
|
|
77
|
+
hasSearchAsYouType={true} // default false
|
|
78
|
+
minLengthToShowSearchAsYouTypeResults={1} // default 3
|
|
79
|
+
hasAutocomplete={true} // default true
|
|
80
|
+
loadMoreResults={'button'} // default 'pagination'
|
|
81
|
+
hasLoadMore={true} // default true
|
|
82
|
+
sortByOptions={sortByOptions} // default []
|
|
83
|
+
filters={[
|
|
84
|
+
{
|
|
85
|
+
labelText: 'Categories',
|
|
86
|
+
type: 'checkbox-group',
|
|
87
|
+
options: {
|
|
88
|
+
pricing: {
|
|
89
|
+
label: 'Pricing',
|
|
90
|
+
filter: { category: '1xpricing' }
|
|
91
|
+
},
|
|
92
|
+
partners: {
|
|
93
|
+
label: 'Partners',
|
|
94
|
+
filter: { category: '1xpartners' }
|
|
95
|
+
},
|
|
96
|
+
customers: {
|
|
97
|
+
label: 'Customers',
|
|
98
|
+
filter: { category: '1xcustomers' }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
labelText: 'Documents',
|
|
104
|
+
type: 'tags',
|
|
105
|
+
options: {
|
|
106
|
+
nofilter: {
|
|
107
|
+
label: 'All results'
|
|
108
|
+
},
|
|
109
|
+
blog: {
|
|
110
|
+
label: 'Blog',
|
|
111
|
+
filter: { category: '1xblog' }
|
|
112
|
+
},
|
|
113
|
+
docs: {
|
|
114
|
+
label: 'Documentation',
|
|
115
|
+
filter: { category: '1xdocs' }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
]}
|
|
120
|
+
hasActiveFilters={true} // default true
|
|
121
|
+
/>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
- `minLengthToShowSearchAsYouTypeResults` affects both `hasAutocomplete` and `hasSearchAsYouType`
|
|
125
|
+
- `loadMoreResults` defines what UI option to use for loading more results
|
|
126
|
+
- `sortByOptions` and `filtersOptions` for configuration details visit
|
|
127
|
+
[SortBy Documentation](https://github.com/AddSearch/search-ui?tab=readme-ov-file#sort-by) and
|
|
128
|
+
[Filters Documentation](https://github.com/AddSearch/search-ui?tab=readme-ov-file#filters)
|
|
129
|
+
respectively
|
|
130
|
+
- `filterTypes`
|
|
131
|
+
- `filters` can handle 1 'tabs' filter and 1 'select-list' filter and multiple filters of the
|
|
132
|
+
other types (all supported types are 'tabs' | 'checkbox-group' | 'radio-group' | 'tags' |
|
|
133
|
+
'select-list')
|
|
134
|
+
- `hasActiveFilters`is disabled when using Tab Filters
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as React_2 from 'react';
|
|
2
|
+
|
|
3
|
+
export declare const AddSearchUiIntegration: React_2.FC<AddSearchUiIntegrationProps>;
|
|
4
|
+
|
|
5
|
+
declare interface AddSearchUiIntegrationProps {
|
|
6
|
+
readonly publicSiteKey: string;
|
|
7
|
+
readonly primaryColor?: string;
|
|
8
|
+
readonly customFont?: string;
|
|
9
|
+
readonly searchFieldHeaderText?: string;
|
|
10
|
+
readonly searchButtonText?: string;
|
|
11
|
+
readonly searchInputPlaceholderText?: string;
|
|
12
|
+
readonly hasSearchInputAutofocus?: boolean;
|
|
13
|
+
readonly hasSearchAsYouType?: boolean;
|
|
14
|
+
readonly minLengthToShowSearchAsYouTypeResults?: number;
|
|
15
|
+
readonly hasSearchInputFieldIcon?: boolean;
|
|
16
|
+
readonly hasAutocomplete?: boolean;
|
|
17
|
+
readonly loadMoreResults?: 'button' | 'pagination';
|
|
18
|
+
readonly sortByOptions?: SortByOption[];
|
|
19
|
+
readonly filters?: Filter[];
|
|
20
|
+
readonly hasActiveFilters?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare interface Filter {
|
|
24
|
+
readonly labelText?: string;
|
|
25
|
+
readonly type: FilterType;
|
|
26
|
+
readonly options: {
|
|
27
|
+
[key: string]: {
|
|
28
|
+
readonly label: string;
|
|
29
|
+
readonly filter?: {
|
|
30
|
+
readonly category: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare type FilterType = 'tabs' | 'checkbox-group' | 'radio-group' | 'tags' | 'select-list';
|
|
37
|
+
|
|
38
|
+
declare interface SortByOption {
|
|
39
|
+
readonly label: string;
|
|
40
|
+
readonly sortBy: string | string[];
|
|
41
|
+
readonly order: string | string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { }
|