@constructor-io/constructorio-ui-autocomplete 1.25.3 → 1.25.4
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/README.md +220 -176
- package/dist/constructorio-ui-autocomplete-bundled.js +3 -3
- package/lib/cjs/components/Autocomplete/SearchInput/SearchInput.js +9 -1
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/Autocomplete/SearchInput/SearchInput.js +8 -1
- package/lib/mjs/version.js +1 -1
- package/lib/styles.css +0 -3
- package/lib/types/types.d.ts +50 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +6 -3
|
@@ -17,7 +17,15 @@ function DefaultRenderInput({ getFormProps, getInputProps, getLabelProps, setQue
|
|
|
17
17
|
react_1.default.createElement("div", { className: 'cio-icon' },
|
|
18
18
|
react_1.default.createElement("svg", { stroke: 'currentColor', fill: 'currentColor', strokeWidth: '0', viewBox: '0 0 512 512', height: '1em', width: '1em', xmlns: 'http://www.w3.org/2000/svg' },
|
|
19
19
|
react_1.default.createElement("path", { d: 'M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z' })))),
|
|
20
|
-
react_1.default.createElement("button", { className: 'cio-submit-btn', "data-testid": 'cio-submit-btn',
|
|
20
|
+
react_1.default.createElement("button", { className: 'cio-submit-btn', "data-testid": 'cio-submit-btn', "data-cnstrc-search-submit-btn": true, onClick: (e) => {
|
|
21
|
+
var _a;
|
|
22
|
+
if (!inputProps.value) {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
if (inputProps.id) {
|
|
25
|
+
(_a = document.getElementById(inputProps.id)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, type: 'submit', "aria-label": 'Submit Search' },
|
|
21
29
|
react_1.default.createElement("div", { className: 'cio-icon' },
|
|
22
30
|
react_1.default.createElement("svg", { stroke: 'currentColor', fill: 'currentColor', strokeWidth: '0', viewBox: '0 0 512 512', height: '1em', width: '1em', xmlns: 'http://www.w3.org/2000/svg' },
|
|
23
31
|
react_1.default.createElement("path", { d: 'M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z' }))))));
|
package/lib/cjs/version.js
CHANGED
|
@@ -14,7 +14,14 @@ function DefaultRenderInput({ getFormProps, getInputProps, getLabelProps, setQue
|
|
|
14
14
|
React.createElement("div", { className: 'cio-icon' },
|
|
15
15
|
React.createElement("svg", { stroke: 'currentColor', fill: 'currentColor', strokeWidth: '0', viewBox: '0 0 512 512', height: '1em', width: '1em', xmlns: 'http://www.w3.org/2000/svg' },
|
|
16
16
|
React.createElement("path", { d: 'M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z' })))),
|
|
17
|
-
React.createElement("button", { className: 'cio-submit-btn', "data-testid": 'cio-submit-btn',
|
|
17
|
+
React.createElement("button", { className: 'cio-submit-btn', "data-testid": 'cio-submit-btn', "data-cnstrc-search-submit-btn": true, onClick: (e) => {
|
|
18
|
+
if (!inputProps.value) {
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
if (inputProps.id) {
|
|
21
|
+
document.getElementById(inputProps.id)?.focus();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}, type: 'submit', "aria-label": 'Submit Search' },
|
|
18
25
|
React.createElement("div", { className: 'cio-icon' },
|
|
19
26
|
React.createElement("svg", { stroke: 'currentColor', fill: 'currentColor', strokeWidth: '0', viewBox: '0 0 512 512', height: '1em', width: '1em', xmlns: 'http://www.w3.org/2000/svg' },
|
|
20
27
|
React.createElement("path", { d: 'M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z' }))))));
|
package/lib/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.25.
|
|
1
|
+
export default '1.25.4';
|
package/lib/styles.css
CHANGED
package/lib/types/types.d.ts
CHANGED
|
@@ -4,8 +4,17 @@ import ConstructorIOClient from '@constructor-io/constructorio-client-javascript
|
|
|
4
4
|
import { IAutocompleteParameters, SearchSuggestion as SearchSuggestionFromClient, Product as ProductFromClient, Item as ItemBase, AutocompleteRequestType, ConstructorClientOptions, RecommendationsParameters } from '@constructor-io/constructorio-client-javascript/lib/types';
|
|
5
5
|
export type { IAutocompleteParameters } from '@constructor-io/constructorio-client-javascript/lib/types';
|
|
6
6
|
export type CioClientConfig = {
|
|
7
|
+
/**
|
|
8
|
+
* Your Constructor API key. Either `apiKey` or `cioJsClient` are required
|
|
9
|
+
*/
|
|
7
10
|
apiKey?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional custom constructor instance. Either `apiKey` or `cioJsClient` are required
|
|
13
|
+
*/
|
|
8
14
|
cioJsClient?: ConstructorIOClient;
|
|
15
|
+
/**
|
|
16
|
+
* Pass a `cioJsClientOptions` object to customize the client's configurations w/o creating a new instance of `ConstructorIOClient`. You can learn more about the possible values [Here](https://constructor-io.github.io/constructorio-client-javascript/ConstructorIO.html)
|
|
17
|
+
*/
|
|
9
18
|
cioJsClientOptions?: ConstructorClientOptions;
|
|
10
19
|
};
|
|
11
20
|
export interface AdvancedParametersBase {
|
|
@@ -24,17 +33,58 @@ type OptionalItemsComboboxProps<Item> = Partial<UseComboboxProps<Item>> & {
|
|
|
24
33
|
};
|
|
25
34
|
export type UseCioAutocompleteOptions = Omit<CioAutocompleteProps, 'children'>;
|
|
26
35
|
export type CioAutocompleteProps = CioClientConfig & OptionalItemsComboboxProps<Item> & {
|
|
36
|
+
/**
|
|
37
|
+
* Set to `false` to show suggestions only after a user clears their query,
|
|
38
|
+
* but not when they initially select the input
|
|
39
|
+
*/
|
|
27
40
|
openOnFocus?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Transforms a `SearchSuggestion` into the desired URL string to be used when rendering anchor tags
|
|
43
|
+
* i.e. <a href=getSearchResultsUrl([selected_search_suggestion])>[Search Suggestion]</a>
|
|
44
|
+
*/
|
|
28
45
|
getSearchResultsUrl?: (item: SearchSuggestion) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Callback function that runs when the user submits a search.
|
|
48
|
+
* Usually used to trigger a redirect
|
|
49
|
+
*/
|
|
29
50
|
onSubmit: OnSubmit;
|
|
51
|
+
/**
|
|
52
|
+
* Callback function that runs when the user focuses on the input
|
|
53
|
+
*/
|
|
30
54
|
onFocus?: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Callback function that runs when the user modifies input
|
|
57
|
+
*/
|
|
31
58
|
onChange?: (input: string) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Search input placeholder
|
|
61
|
+
*/
|
|
32
62
|
placeholder?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Children to be rendered according to the RenderProps pattern
|
|
65
|
+
*/
|
|
33
66
|
children?: ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* Configure the sections rendered, based on the user's input. This can be either Constructor-powered sections,
|
|
69
|
+
* or your own custom sections. Defaults to Products and Search Suggestion sections powered by Constructor
|
|
70
|
+
*/
|
|
34
71
|
sections?: UserDefinedSection[];
|
|
72
|
+
/**
|
|
73
|
+
* Configure either Constructor-powered sections or power your own custom sections,
|
|
74
|
+
* to be rendered for [Autocomplete Zero-State](link-tbd)
|
|
75
|
+
*/
|
|
35
76
|
zeroStateSections?: UserDefinedSection[];
|
|
77
|
+
/**
|
|
78
|
+
* Configure the parent container's class. Defaults to `cio-autocomplete`
|
|
79
|
+
*/
|
|
36
80
|
autocompleteClassName?: string;
|
|
81
|
+
/**
|
|
82
|
+
* See Advanced Parameters
|
|
83
|
+
*/
|
|
37
84
|
advancedParameters?: AdvancedParameters;
|
|
85
|
+
/**
|
|
86
|
+
* Search input default value
|
|
87
|
+
*/
|
|
38
88
|
defaultInput?: string;
|
|
39
89
|
};
|
|
40
90
|
/**
|
package/lib/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.25.
|
|
1
|
+
declare const _default: "1.25.4";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-ui-autocomplete",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.4",
|
|
4
4
|
"description": "Constructor.io Autocomplete UI library for web applications",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -36,9 +36,11 @@
|
|
|
36
36
|
"test-storybook": "test-storybook",
|
|
37
37
|
"test-storybook:watch": "test-storybook --watch",
|
|
38
38
|
"test-storybook:ci": "start-server-and-test storybook:ci http://localhost:6006 test-storybook",
|
|
39
|
-
"build-storybook": "storybook build -o 'docs'",
|
|
39
|
+
"build-storybook": "storybook build --docs -o 'docs'",
|
|
40
|
+
"storybook-docs-dev": "storybook dev --docs -p 6007",
|
|
40
41
|
"serve-built-storybook": "npx http-server docs",
|
|
41
|
-
"compile": "rm -rf lib && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && npm run copy-styles && vite build"
|
|
42
|
+
"compile": "rm -rf lib && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && npm run copy-styles && vite build",
|
|
43
|
+
"doctoc-readme": "doctoc README.md --title '## 📌 Table of Contents'"
|
|
42
44
|
},
|
|
43
45
|
"author": "Constructor.io Corporation",
|
|
44
46
|
"license": "MIT",
|
|
@@ -84,6 +86,7 @@
|
|
|
84
86
|
"@types/react-dom": "^18.0.6",
|
|
85
87
|
"@typescript-eslint/eslint-plugin": "^5.38.0",
|
|
86
88
|
"@typescript-eslint/parser": "^5.38.0",
|
|
89
|
+
"doctoc": "^2.2.1",
|
|
87
90
|
"eslint": "^8.23.1",
|
|
88
91
|
"eslint-config-airbnb": "^19.0.4",
|
|
89
92
|
"eslint-config-airbnb-typescript": "^17.0.0",
|