@constructor-io/constructorio-ui-autocomplete 1.23.24 → 1.23.25
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/dist/constructorio-ui-autocomplete-bundled.js +11 -11
- package/lib/cjs/components/Autocomplete/AutocompleteResults/NoResults.js +8 -0
- package/lib/cjs/components/Autocomplete/SectionItemsList/SectionItemsList.js +10 -4
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/hooks/useCioAutocomplete.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/Autocomplete/AutocompleteResults/NoResults.js +4 -0
- package/lib/mjs/components/Autocomplete/SectionItemsList/SectionItemsList.js +7 -1
- package/lib/mjs/constants.js +1 -0
- package/lib/mjs/hooks/useCioAutocomplete.js +1 -1
- package/lib/mjs/version.js +1 -1
- package/lib/styles.css +6 -1
- package/lib/types/components/Autocomplete/AutocompleteResults/NoResults.d.ts +2 -0
- package/lib/types/constants.d.ts +1 -0
- package/lib/types/types.d.ts +1 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
function NoResults() {
|
|
6
|
+
return react_1.default.createElement("div", { className: 'cio-no-results-message' }, "No Results Found");
|
|
7
|
+
}
|
|
8
|
+
exports.default = NoResults;
|
|
@@ -5,13 +5,14 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
5
5
|
const SectionItem_1 = tslib_1.__importDefault(require("../SectionItem/SectionItem"));
|
|
6
6
|
const utils_1 = require("../../../utils");
|
|
7
7
|
const CioAutocompleteProvider_1 = require("../CioAutocompleteProvider");
|
|
8
|
+
const NoResults_1 = tslib_1.__importDefault(require("../AutocompleteResults/NoResults"));
|
|
8
9
|
// eslint-disable-next-line func-names
|
|
9
10
|
const DefaultRenderSectionItemsList = function ({ section }) {
|
|
10
|
-
var _a, _b;
|
|
11
|
+
var _a, _b, _c;
|
|
11
12
|
const { getSectionProps, query, getFormProps, advancedParameters, getItemProps } = (0, react_1.useContext)(CioAutocompleteProvider_1.CioAutocompleteContext);
|
|
12
13
|
const { displayShowAllResultsButton, translations } = advancedParameters || {};
|
|
13
14
|
const { onSubmit } = getFormProps();
|
|
14
|
-
const { type, displayName } = section;
|
|
15
|
+
const { type, displayName, displayNoResultsMessage } = section;
|
|
15
16
|
let sectionTitle = displayName;
|
|
16
17
|
if (!sectionTitle) {
|
|
17
18
|
switch (type) {
|
|
@@ -29,12 +30,17 @@ const DefaultRenderSectionItemsList = function ({ section }) {
|
|
|
29
30
|
break;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
+
// Display no results message
|
|
34
|
+
if (!((_a = section === null || section === void 0 ? void 0 : section.data) === null || _a === void 0 ? void 0 : _a.length) && displayNoResultsMessage)
|
|
35
|
+
return (react_1.default.createElement("li", Object.assign({}, getSectionProps(section)),
|
|
36
|
+
react_1.default.createElement("h5", { className: 'cio-section-name cio-sectionName', "aria-hidden": true }, (0, utils_1.camelToStartCase)(sectionTitle)),
|
|
37
|
+
react_1.default.createElement(NoResults_1.default, null)));
|
|
38
|
+
if (!((_b = section === null || section === void 0 ? void 0 : section.data) === null || _b === void 0 ? void 0 : _b.length))
|
|
33
39
|
return null;
|
|
34
40
|
// @deprecated `cio-sectionName` will be removed in the next major release
|
|
35
41
|
return (react_1.default.createElement("li", Object.assign({}, getSectionProps(section)),
|
|
36
42
|
react_1.default.createElement("h5", { className: 'cio-section-name cio-sectionName', "aria-hidden": true }, (0, utils_1.camelToStartCase)(sectionTitle)),
|
|
37
|
-
react_1.default.createElement("ul", { className: 'cio-section-items', role: 'none' }, (
|
|
43
|
+
react_1.default.createElement("ul", { className: 'cio-section-items', role: 'none' }, (_c = section === null || section === void 0 ? void 0 : section.data) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
38
44
|
if (typeof (section === null || section === void 0 ? void 0 : section.renderItem) === 'function') {
|
|
39
45
|
return section.renderItem({ item, query, getItemProps });
|
|
40
46
|
}
|
package/lib/cjs/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.displayShowAllResultsButtonDescription = exports.customRenderItemDescription = exports.translationsDescription = exports.fetchZeroStateOnFocusDescription = exports.debounceDescription = exports.termsWithImagesAndCountsDescription = exports.filteredSuggestionsDescription = exports.termsWithGroupSuggestionsDescription = exports.advancedParametersDefaultDescription = exports.advancedParametersDescription = exports.customStylesDescription = exports.multipleSectionsDescription = exports.openOnFocusDescription = exports.zeroStateSectionsDescription = exports.onSubmitDefault = exports.onSubmitDescription = exports.onIsOpenChangeDescription = exports.onChangeDescription = exports.onFocusDescription = exports.customSectionDescription = exports.displaySearchTermHighlightsDescription = exports.recommendationsDescription = exports.sectionOrderDescription = exports.numResultsDescription = exports.contentDescription = exports.productsDescription = exports.searchSuggestionsDescription = exports.placeholderDescription = exports.cioJsClientOptionsDescription = exports.cioJsClientDescription = exports.apiKeyDescription = exports.fullFeaturedAndStyledExampleDescription = exports.zeroStateDescription = exports.userEventsDescription = exports.sectionsDescription = exports.hookDescription = exports.componentDescription = exports.apiKey = void 0;
|
|
3
|
+
exports.displayShowAllResultsButtonDescription = exports.customRenderItemDescription = exports.translationsDescription = exports.fetchZeroStateOnFocusDescription = exports.debounceDescription = exports.termsWithImagesAndCountsDescription = exports.filteredSuggestionsDescription = exports.termsWithGroupSuggestionsDescription = exports.advancedParametersDefaultDescription = exports.advancedParametersDescription = exports.customStylesDescription = exports.multipleSectionsDescription = exports.openOnFocusDescription = exports.zeroStateSectionsDescription = exports.onSubmitDefault = exports.onSubmitDescription = exports.onIsOpenChangeDescription = exports.onChangeDescription = exports.onFocusDescription = exports.customSectionDescription = exports.displayNoResultsMessageDescription = exports.displaySearchTermHighlightsDescription = exports.recommendationsDescription = exports.sectionOrderDescription = exports.numResultsDescription = exports.contentDescription = exports.productsDescription = exports.searchSuggestionsDescription = exports.placeholderDescription = exports.cioJsClientOptionsDescription = exports.cioJsClientDescription = exports.apiKeyDescription = exports.fullFeaturedAndStyledExampleDescription = exports.zeroStateDescription = exports.userEventsDescription = exports.sectionsDescription = exports.hookDescription = exports.componentDescription = exports.apiKey = void 0;
|
|
4
4
|
// Autocomplete key index
|
|
5
5
|
exports.apiKey = 'key_M57QS8SMPdLdLx4x';
|
|
6
6
|
/// //////////////////////////////
|
|
@@ -128,6 +128,7 @@ exports.numResultsDescription = `Override default \`numResults\` to only suggest
|
|
|
128
128
|
exports.sectionOrderDescription = `Override default \`numResults\` to suggest products, then terms`;
|
|
129
129
|
exports.recommendationsDescription = `Use constructor's recommendations service, with \`"type": "recommendations"\``;
|
|
130
130
|
exports.displaySearchTermHighlightsDescription = `Use constructor's auto highlighting of words that match the search keyword, with \`"displaySearchTermHighlights": true\``;
|
|
131
|
+
exports.displayNoResultsMessageDescription = `Display a no results message for this section, with \`"displayNoResultsMessage": true\``;
|
|
131
132
|
exports.customSectionDescription = `Use a custom section, by managing and passing your own data, with \`"type": "custom"\` and \`"data":[{...}]\``;
|
|
132
133
|
exports.onFocusDescription = `Pass an \`onFocus\` callback function to execute some code each time the user applies focus to the text input field`;
|
|
133
134
|
exports.onChangeDescription = `Pass an \`onChange\` callback function to execute some code each time the user changes the value of the text input field`;
|
|
@@ -49,7 +49,7 @@ const useCioAutocomplete = (options) => {
|
|
|
49
49
|
totalNumResultsPerSection,
|
|
50
50
|
request,
|
|
51
51
|
featureToggles: features,
|
|
52
|
-
isOpen
|
|
52
|
+
isOpen,
|
|
53
53
|
getMenuProps: () => (Object.assign(Object.assign({}, getMenuProps()), { className: 'cio-results', 'data-testid': 'cio-results', 'data-cnstrc-autosuggest': '' })),
|
|
54
54
|
getLabelProps,
|
|
55
55
|
openMenu,
|
package/lib/cjs/version.js
CHANGED
|
@@ -2,12 +2,13 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import SectionItem from '../SectionItem/SectionItem';
|
|
3
3
|
import { camelToStartCase, translate } from '../../../utils';
|
|
4
4
|
import { CioAutocompleteContext } from '../CioAutocompleteProvider';
|
|
5
|
+
import NoResults from '../AutocompleteResults/NoResults';
|
|
5
6
|
// eslint-disable-next-line func-names
|
|
6
7
|
const DefaultRenderSectionItemsList = function ({ section }) {
|
|
7
8
|
const { getSectionProps, query, getFormProps, advancedParameters, getItemProps } = useContext(CioAutocompleteContext);
|
|
8
9
|
const { displayShowAllResultsButton, translations } = advancedParameters || {};
|
|
9
10
|
const { onSubmit } = getFormProps();
|
|
10
|
-
const { type, displayName } = section;
|
|
11
|
+
const { type, displayName, displayNoResultsMessage } = section;
|
|
11
12
|
let sectionTitle = displayName;
|
|
12
13
|
if (!sectionTitle) {
|
|
13
14
|
switch (type) {
|
|
@@ -25,6 +26,11 @@ const DefaultRenderSectionItemsList = function ({ section }) {
|
|
|
25
26
|
break;
|
|
26
27
|
}
|
|
27
28
|
}
|
|
29
|
+
// Display no results message
|
|
30
|
+
if (!section?.data?.length && displayNoResultsMessage)
|
|
31
|
+
return (React.createElement("li", { ...getSectionProps(section) },
|
|
32
|
+
React.createElement("h5", { className: 'cio-section-name cio-sectionName', "aria-hidden": true }, camelToStartCase(sectionTitle)),
|
|
33
|
+
React.createElement(NoResults, null)));
|
|
28
34
|
if (!section?.data?.length)
|
|
29
35
|
return null;
|
|
30
36
|
// @deprecated `cio-sectionName` will be removed in the next major release
|
package/lib/mjs/constants.js
CHANGED
|
@@ -125,6 +125,7 @@ export const numResultsDescription = `Override default \`numResults\` to only su
|
|
|
125
125
|
export const sectionOrderDescription = `Override default \`numResults\` to suggest products, then terms`;
|
|
126
126
|
export const recommendationsDescription = `Use constructor's recommendations service, with \`"type": "recommendations"\``;
|
|
127
127
|
export const displaySearchTermHighlightsDescription = `Use constructor's auto highlighting of words that match the search keyword, with \`"displaySearchTermHighlights": true\``;
|
|
128
|
+
export const displayNoResultsMessageDescription = `Display a no results message for this section, with \`"displayNoResultsMessage": true\``;
|
|
128
129
|
export const customSectionDescription = `Use a custom section, by managing and passing your own data, with \`"type": "custom"\` and \`"data":[{...}]\``;
|
|
129
130
|
export const onFocusDescription = `Pass an \`onFocus\` callback function to execute some code each time the user applies focus to the text input field`;
|
|
130
131
|
export const onChangeDescription = `Pass an \`onChange\` callback function to execute some code each time the user changes the value of the text input field`;
|
package/lib/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.23.
|
|
1
|
+
export default '1.23.25';
|
package/lib/styles.css
CHANGED
package/lib/types/constants.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const numResultsDescription = "Override default `numResults` to o
|
|
|
17
17
|
export declare const sectionOrderDescription = "Override default `numResults` to suggest products, then terms";
|
|
18
18
|
export declare const recommendationsDescription = "Use constructor's recommendations service, with `\"type\": \"recommendations\"`";
|
|
19
19
|
export declare const displaySearchTermHighlightsDescription = "Use constructor's auto highlighting of words that match the search keyword, with `\"displaySearchTermHighlights\": true`";
|
|
20
|
+
export declare const displayNoResultsMessageDescription = "Display a no results message for this section, with `\"displayNoResultsMessage\": true`";
|
|
20
21
|
export declare const customSectionDescription = "Use a custom section, by managing and passing your own data, with `\"type\": \"custom\"` and `\"data\":[{...}]`";
|
|
21
22
|
export declare const onFocusDescription = "Pass an `onFocus` callback function to execute some code each time the user applies focus to the text input field";
|
|
22
23
|
export declare const onChangeDescription = "Pass an `onChange` callback function to execute some code each time the user changes the value of the text input field";
|
package/lib/types/types.d.ts
CHANGED
package/lib/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.23.
|
|
1
|
+
declare const _default: "1.23.25";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED