@constructor-io/constructorio-ui-autocomplete 1.5.3 → 1.7.0

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.
@@ -5,6 +5,10 @@ export type CioClientConfig = {
5
5
  apiKey?: string;
6
6
  cioJsClient?: ConstructorIOClient;
7
7
  };
8
+ export type AdvancedParameters = {
9
+ numTermsWithGroupSuggestions?: number;
10
+ numGroupsSuggestedPerTerm?: number;
11
+ };
8
12
  export type CioAutocompleteProps = CioClientConfig & {
9
13
  openOnFocus?: boolean;
10
14
  onSubmit: OnSubmit;
@@ -12,9 +16,10 @@ export type CioAutocompleteProps = CioClientConfig & {
12
16
  onChange?: () => void;
13
17
  placeholder?: string;
14
18
  children?: ReactNode;
15
- sections?: Section[];
16
- zeroStateSections?: Section[];
19
+ sections?: UserDefinedSection[];
20
+ zeroStateSections?: UserDefinedSection[];
17
21
  autocompleteClassName?: string;
22
+ advancedParameters?: AdvancedParameters;
18
23
  };
19
24
  export type AutocompleteSubmitEvent = {
20
25
  item: Item;
@@ -31,13 +36,13 @@ export type ItemPropsOptions = DownshiftGetItemPropsOptions & {
31
36
  };
32
37
  export type GetItemProps = (options: ItemPropsOptions) => object;
33
38
  export interface ItemBase extends Record<string, any> {
34
- id?: string;
39
+ id: string;
40
+ section: string;
35
41
  url?: string;
36
42
  value?: string;
37
- section: string;
38
43
  data?: Record<string, any>;
39
44
  }
40
- export type Item = Product | SearchSuggestion | ItemBase;
45
+ export type Item = Product | SearchSuggestion | InGroupSuggestion | ItemBase;
41
46
  export type GetAutocompleteResultsOptions = {
42
47
  [sectionIdentifier: string]: {
43
48
  numResults: number;
@@ -56,11 +61,11 @@ export type SectionConfiguration = {
56
61
  };
57
62
  export interface AutocompleteSection extends SectionConfiguration {
58
63
  type?: 'autocomplete';
59
- data?: Item[];
64
+ data: Item[];
60
65
  }
61
66
  export interface RecommendationsSection extends SectionConfiguration {
62
67
  type: 'recommendations';
63
- data?: Item[];
68
+ data: Item[];
64
69
  itemIds?: string[];
65
70
  section?: string;
66
71
  term?: string;
@@ -70,7 +75,9 @@ export interface CustomSection extends SectionConfiguration {
70
75
  data: Item[];
71
76
  }
72
77
  export type Section = AutocompleteSection | RecommendationsSection | CustomSection;
73
- export type Product = {
78
+ export type UserDefinedSection = CustomSection | SectionConfiguration;
79
+ export type Product = ItemBase & {
80
+ section: 'Products';
74
81
  data: {
75
82
  facets: {
76
83
  name: string;
@@ -86,18 +93,20 @@ export type Product = {
86
93
  labels: Record<string, unknown>;
87
94
  matched_terms: string[];
88
95
  value: string;
89
- section: 'Products';
90
96
  };
91
- export type SearchSuggestion = {
97
+ export type SearchSuggestion = ItemBase & {
98
+ section: 'Search Suggestions';
92
99
  data: {
93
100
  id: string;
94
101
  url?: string;
95
102
  };
96
- id: string;
97
103
  is_slotted: boolean;
98
104
  labels: Record<string, unknown>;
99
105
  matched_terms: string[];
100
106
  value: string;
101
- section: 'Search Suggestions';
107
+ };
108
+ export type InGroupSuggestion = SearchSuggestion & {
109
+ groupId: string;
110
+ groupName: string;
102
111
  };
103
112
  export {};
@@ -1,8 +1,8 @@
1
1
  import ConstructorIOClient from '@constructor-io/constructorio-client-javascript';
2
- import { OnSubmit, Section, Item } from './types';
2
+ import { OnSubmit, Item } from './types';
3
3
  export type GetItemPosition = (args: {
4
4
  item: Item;
5
- activeSectionsWithData: Section[];
5
+ items: Item[];
6
6
  }) => {
7
7
  index: number;
8
8
  sectionId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructor-io/constructorio-ui-autocomplete",
3
- "version": "1.5.3",
3
+ "version": "1.7.0",
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.0-beta.40",
57
- "@storybook/addon-actions": "^7.0.0-beta.40",
58
- "@storybook/addon-essentials": "^7.0.0-beta.40",
59
- "@storybook/addon-interactions": "^7.0.0-beta.40",
60
- "@storybook/addon-links": "^7.0.0-beta.40",
61
- "@storybook/jest": "^0.0.11-next.0",
62
- "@storybook/react-webpack5": "7.0.0-beta.40",
63
- "@storybook/test-runner": "^0.10.0-next.8",
64
- "@storybook/testing-library": "^0.0.14-next.1",
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.8",
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.0-beta.40",
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": {