@constructor-io/constructorio-ui-autocomplete 1.6.0 → 1.7.1
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 +40 -21
- package/dist/constructorio-ui-autocomplete-bundled.js +43 -0
- package/lib/cjs/hooks/useCioAutocomplete.js +20 -45
- package/lib/cjs/hooks/useConsoleErrors.js +16 -0
- package/lib/cjs/hooks/useDebouncedFetchSections.js +18 -12
- package/lib/cjs/hooks/useDownShift.js +1 -8
- package/lib/cjs/hooks/useFetchRecommendationPod.js +6 -1
- package/lib/cjs/hooks/useItems.js +12 -0
- package/lib/cjs/hooks/useSections.js +36 -0
- package/lib/cjs/utils.js +36 -17
- package/lib/mjs/hooks/useCioAutocomplete.js +20 -45
- package/lib/mjs/hooks/useConsoleErrors.js +14 -0
- package/lib/mjs/hooks/useDebouncedFetchSections.js +18 -14
- package/lib/mjs/hooks/useDownShift.js +1 -7
- package/lib/mjs/hooks/useFetchRecommendationPod.js +6 -1
- package/lib/mjs/hooks/useItems.js +10 -0
- package/lib/mjs/hooks/useSections.js +32 -0
- package/lib/mjs/utils.js +34 -15
- package/lib/types/hooks/useCioAutocomplete.d.ts +3 -3
- package/lib/types/hooks/useConsoleErrors.d.ts +2 -0
- package/lib/types/hooks/useDownShift.d.ts +0 -1
- package/lib/types/hooks/useItems.d.ts +3 -0
- package/lib/types/hooks/useSections.d.ts +8 -0
- package/lib/types/types.d.ts +1 -1
- package/lib/types/utils.d.ts +6 -4
- package/package.json +21 -14
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ConstructorIO from '@constructor-io/constructorio-client-javascript';
|
|
2
|
+
import { Nullable } from '@constructor-io/constructorio-client-javascript/lib/types/types';
|
|
3
|
+
import { AdvancedParameters, UserDefinedSection } from '../types';
|
|
4
|
+
export default function useSections(query: string, cioClient: Nullable<ConstructorIO>, sections: UserDefinedSection[], zeroStateSections: UserDefinedSection[] | undefined, advancedParameters: AdvancedParameters): {
|
|
5
|
+
activeSections: UserDefinedSection[];
|
|
6
|
+
activeSectionsWithData: import("../types").Section[];
|
|
7
|
+
zeroStateActiveSections: false | UserDefinedSection[] | undefined;
|
|
8
|
+
};
|
package/lib/types/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type CioAutocompleteProps = CioClientConfig & {
|
|
|
13
13
|
openOnFocus?: boolean;
|
|
14
14
|
onSubmit: OnSubmit;
|
|
15
15
|
onFocus?: () => void;
|
|
16
|
-
onChange?: () => void;
|
|
16
|
+
onChange?: (string: any) => void;
|
|
17
17
|
placeholder?: string;
|
|
18
18
|
children?: ReactNode;
|
|
19
19
|
sections?: UserDefinedSection[];
|
package/lib/types/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
|
|
2
|
-
import { OnSubmit, Item } from './types';
|
|
2
|
+
import { OnSubmit, Item, Section, UserDefinedSection, AutocompleteResultSections } from './types';
|
|
3
3
|
export type GetItemPosition = (args: {
|
|
4
4
|
item: Item;
|
|
5
5
|
items: Item[];
|
|
@@ -23,12 +23,14 @@ export declare const getStoryParams: (storyCode: any, templateCode: any, importC
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
export declare const
|
|
27
|
-
|
|
26
|
+
export declare const functionStrings: {
|
|
27
|
+
onSubmit: string;
|
|
28
|
+
};
|
|
28
29
|
export declare const stringifyWithDefaults: (obj: {
|
|
29
30
|
apiKey: string;
|
|
30
31
|
onSubmit: OnSubmit;
|
|
31
|
-
}) =>
|
|
32
|
+
}) => string;
|
|
32
33
|
export declare const disableStoryActions: (story: any) => void;
|
|
33
34
|
export declare const getCioClient: (apiKey?: string) => ConstructorIOClient | null;
|
|
35
|
+
export declare const getActiveSectionsWithData: (activeSections: UserDefinedSection[], sectionResults: AutocompleteResultSections) => Section[];
|
|
34
36
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructor-io/constructorio-ui-autocomplete",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
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",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"import": "./lib/mjs/index.js",
|
|
14
14
|
"require": "./lib/cjs/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./constructorio-ui-autocomplete-bundled": {
|
|
17
|
+
"import": "./dist/constructorio-ui-autocomplete-bundled.js",
|
|
18
|
+
"require": "./dist/constructorio-ui-autocomplete-bundled.js"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"homepage": "https://github.com/Constructor-io/constructorio-ui-autocomplete#readme",
|
|
@@ -30,7 +34,7 @@
|
|
|
30
34
|
"serve-built-storybook": "npx http-server docs",
|
|
31
35
|
"verify-node-version": "chmod +x ./scripts/verify-node-version.sh && ./scripts/verify-node-version.sh",
|
|
32
36
|
"version": "npm run verify-node-version && npm run build-storybook && git add -u ./docs && git add ./docs/* && npm run compile",
|
|
33
|
-
"compile": "rm -rf lib && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && npm run copy-styles"
|
|
37
|
+
"compile": "rm -rf lib && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && npm run copy-styles && vite build"
|
|
34
38
|
},
|
|
35
39
|
"author": "constructor.io",
|
|
36
40
|
"license": "MIT",
|
|
@@ -46,22 +50,23 @@
|
|
|
46
50
|
"url": "https://github.com/Constructor-io/constructorio-ui-autocomplete/issues"
|
|
47
51
|
},
|
|
48
52
|
"files": [
|
|
49
|
-
"lib/**/*"
|
|
53
|
+
"lib/**/*",
|
|
54
|
+
"dist/constructorio-ui-autocomplete-bundled.js"
|
|
50
55
|
],
|
|
51
56
|
"engines": {
|
|
52
57
|
"node": ">=14"
|
|
53
58
|
},
|
|
54
59
|
"devDependencies": {
|
|
55
60
|
"@cspell/eslint-plugin": "^6.18.1",
|
|
56
|
-
"@storybook/addon-a11y": "^7.0.
|
|
57
|
-
"@storybook/addon-actions": "^7.0.
|
|
58
|
-
"@storybook/addon-essentials": "^7.0.
|
|
59
|
-
"@storybook/addon-interactions": "^7.0.
|
|
60
|
-
"@storybook/addon-links": "^7.0.
|
|
61
|
-
"@storybook/jest": "^0.
|
|
62
|
-
"@storybook/react-webpack5": "7.0.
|
|
63
|
-
"@storybook/test-runner": "^0.10.0
|
|
64
|
-
"@storybook/testing-library": "^0.0
|
|
61
|
+
"@storybook/addon-a11y": "^7.0.14",
|
|
62
|
+
"@storybook/addon-actions": "^7.0.14",
|
|
63
|
+
"@storybook/addon-essentials": "^7.0.14",
|
|
64
|
+
"@storybook/addon-interactions": "^7.0.14",
|
|
65
|
+
"@storybook/addon-links": "^7.0.14",
|
|
66
|
+
"@storybook/jest": "^0.1.0",
|
|
67
|
+
"@storybook/react-webpack5": "7.0.14",
|
|
68
|
+
"@storybook/test-runner": "^0.10.0",
|
|
69
|
+
"@storybook/testing-library": "^0.1.0",
|
|
65
70
|
"@types/react": "^18.0.20",
|
|
66
71
|
"@types/react-dom": "^18.0.6",
|
|
67
72
|
"@typescript-eslint/eslint-plugin": "^5.38.0",
|
|
@@ -75,13 +80,15 @@
|
|
|
75
80
|
"eslint-plugin-prettier": "^4.2.1",
|
|
76
81
|
"eslint-plugin-react": "^7.31.11",
|
|
77
82
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
78
|
-
"eslint-plugin-storybook": "^0.6.
|
|
83
|
+
"eslint-plugin-storybook": "^0.6.12",
|
|
79
84
|
"husky": "^8.0.1",
|
|
80
85
|
"react": "^18.2.0",
|
|
81
86
|
"react-dom": "^18.2.0",
|
|
82
87
|
"start-server-and-test": "^1.15.2",
|
|
83
|
-
"storybook": "^7.0.
|
|
88
|
+
"storybook": "^7.0.14",
|
|
84
89
|
"typescript": "^4.8.3",
|
|
90
|
+
"vite": "^4.3.7",
|
|
91
|
+
"vite-plugin-css-injected-by-js": "^3.1.1",
|
|
85
92
|
"webpack": "^5.75.0"
|
|
86
93
|
},
|
|
87
94
|
"peerDependencies": {
|