@searchcraft/javascript-sdk 0.8.0 → 0.8.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.
@@ -8,7 +8,7 @@ const styles = require('./styles-7b2d06f2.js');
8
8
  const index$1 = require('./index-5b0b9d4c.js');
9
9
 
10
10
  const name = "@searchcraft/javascript-sdk";
11
- const version = "0.8.0";
11
+ const version = "0.8.1";
12
12
  const description = "Searchcraft Javascript SDK";
13
13
  const author = "Searchcraft";
14
14
  const license = "Apache-2.0";
@@ -57,7 +57,7 @@ const dependencies = {
57
57
  classnames: "^2.3.2"
58
58
  };
59
59
  const devDependencies = {
60
- "@searchcraft/core": "^0.8.0",
60
+ "@searchcraft/core": "^0.8.1",
61
61
  "@searchcraft/javascript-sdk": "*",
62
62
  "@stencil/core": "^4.7.0",
63
63
  "@stencil/react-output-target": "^0.8.2",
@@ -7,7 +7,7 @@ import { d as defineCustomElement$2 } from './p-0e393fe1.js';
7
7
  import { d as defineCustomElement$1 } from './p-e55a7970.js';
8
8
 
9
9
  const name = "@searchcraft/javascript-sdk";
10
- const version = "0.8.0";
10
+ const version = "0.8.1";
11
11
  const description = "Searchcraft Javascript SDK";
12
12
  const author = "Searchcraft";
13
13
  const license = "Apache-2.0";
@@ -56,7 +56,7 @@ const dependencies = {
56
56
  classnames: "^2.3.2"
57
57
  };
58
58
  const devDependencies = {
59
- "@searchcraft/core": "^0.8.0",
59
+ "@searchcraft/core": "^0.8.1",
60
60
  "@searchcraft/javascript-sdk": "*",
61
61
  "@stencil/core": "^4.7.0",
62
62
  "@stencil/react-output-target": "^0.8.2",
@@ -277,4 +277,4 @@ function defineCustomElement() {
277
277
 
278
278
  export { SearchcraftInput as S, defineCustomElement as d };
279
279
 
280
- //# sourceMappingURL=p-3df3ff8b.js.map
280
+ //# sourceMappingURL=p-ae78be68.js.map
@@ -1 +1 @@
1
- {"file":"p-3df3ff8b.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;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,EAAC,KAAK,EAClB,KAAK,EAAC,mBAAmB,EACzB,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,EACtC,MAAM,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,EACpC,OAAO,EAAE,CAAC,KAAK;gBACb,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;aAC3B,EACD,WAAW,EAAE,IAAI,CAAC,gBAAgB,EAClC,KAAK,EAAE,qBAAqB,EAC5B,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,IAAI,CAAC,UAAU,GACtB,EACF,4DAAK,KAAK,EAAC,uCAAuC,IAChD,4DACE,KAAK,EAAC,+BAA+B,EACrC,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,qBAClB,mBAAmB,IAEnC,8DAAO,EAAE,EAAC,mBAAmB,oCAErB,EACR,6DACE,CAAC,EAAC,mNAAmN,EACrN,MAAM,EAAC,cAAc,kBACR,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACF,EACL,oBAAoB,KACnB,+DACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,gCAAgC,EACtC,OAAO,EAAE,IAAI,CAAC,gBAAgB,IAE9B,4DACE,KAAK,EAAC,8BAA8B,EACpC,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,qBAClB,YAAY,IAE5B,8DAAO,EAAE,EAAC,YAAY,yCAEd,EACR,6DACE,CAAC,EAAC,uIAAuI,EACzI,MAAM,EAAC,cAAc,kBACR,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACC,CACV,CACG,CACF,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftCore"],"sources":["src/components/searchcraft-input-form/searchcraft-input-form.tsx"],"sourcesContent":["import {\n Component,\n h,\n Prop,\n State,\n Event,\n type EventEmitter,\n Watch,\n} from '@stencil/core';\n\nimport { type SearchcraftConfig, SearchcraftCore } from '@searchcraft/core';\nimport packageJson from '../../../package.json';\n\nimport { parseCustomStyles } from '@utils';\nimport { useSearchcraftStore } from '@provider/store';\nimport classNames from 'classnames';\n\n/**\n * This web component provides a user-friendly interface for querying an indexed dataset, enabling users to easily search large collections of data.\n * It abstracts the complexities of index-based searching, making it accessible to users of all technical levels.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-input-form placeholder-value=\"Search here\" />\n * ```\n *\n * ```js\n * // index.js\n * const searchInputForm = document.querySelector('searchcraft-input-form');\n *\n * searchInputForm.config = {\n * index: [],\n * readKey: '',\n * endpointUrl: '',\n * };\n *\n * searchForm.addEventListener('querySubmit', (event) => {\n * console.log('Query submitted', event.detail);\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-input-form',\n shadow: false,\n})\nexport class SearchcraftInput {\n /**\n * The Searchcraft config object.\n */\n @Prop() config: SearchcraftConfig | undefined;\n /**\n * Whether or not to automatically submit the search term when the input changes.\n */\n @Prop() autoSearch = true;\n /**\n * Where to place the search button.\n */\n @Prop() buttonPlacement: 'left' | 'right' | 'none' = 'none';\n /**\n * The label for the submit button.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * The label rendered above the input.\n */\n @Prop() inputLabel: string | undefined;\n /**\n * A custom styles object to be applied to the input element.\n */\n @Prop() customStyles: string | Record<string, string> = {};\n /**\n * The input element's placeholder value.\n */\n @Prop() placeholderValue = 'Enter Search';\n /**\n * The starting value of the input element.\n */\n @Prop() searchTerm = '';\n /**\n * When the input is cleared.\n */\n @Event() inputCleared?: EventEmitter<void>;\n /**\n * When no results are returned.\n */\n @Event() noResultsReceived?: EventEmitter<void>;\n /**\n * When the input becomes focused.\n */\n @Event() inputFocus?: EventEmitter<void>;\n /**\n * When the input becomes unfocused.\n */\n @Event() inputBlur?: EventEmitter<void>;\n /**\n * Event emitted when input initializes.\n */\n @Event() inputInit?: EventEmitter<void>;\n /**\n * Event emitted when a query has been submitted.\n */\n @Event() querySubmit?: EventEmitter<string>;\n\n @State() inputValue = this.searchTerm;\n @State() error = false;\n @State() isSearchcraftInitialized = false;\n\n private searchStore = useSearchcraftStore.getState();\n\n init() {\n if (this.config && !this.isSearchcraftInitialized) {\n const searchcraft = new SearchcraftCore(this.config, {\n sdkName: packageJson.name,\n sdkVersion: packageJson.version,\n });\n this.searchStore.initialize(searchcraft, true);\n this.isSearchcraftInitialized = true;\n this.inputInit?.emit();\n }\n }\n\n componentDidLoad() {\n this.init();\n }\n\n @Watch('config')\n onConfigChange() {\n this.init();\n }\n\n handleOnInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n this.inputValue = input.value;\n\n if (!this.autoSearch) {\n return;\n }\n\n if (input.value.trim() === '') {\n this.inputCleared?.emit();\n }\n\n this.performSearch(input.value);\n };\n\n private performSearch = async (value: string) => {\n if (value === useSearchcraftStore.getState().searchTerm) {\n return;\n }\n\n this.searchTerm = value.trim();\n this.error = false;\n this.searchStore.setSearchTerm(this.searchTerm);\n this.querySubmit?.emit(this.searchTerm);\n\n try {\n await this.searchStore.search();\n } catch (error) {\n this.error = true;\n this.inputCleared?.emit();\n }\n };\n\n handleClearInput = () => {\n this.inputValue = '';\n this.searchTerm = '';\n this.searchStore.setSearchTerm('');\n this.searchStore.setSearchClientResponseItems([]);\n this.error = false;\n\n this.inputCleared?.emit();\n };\n\n handleFormSubmit = async (event: Event) => {\n event.preventDefault();\n await this.performSearch(this.searchTerm);\n };\n\n render() {\n const validatedCustomStyles = parseCustomStyles(this.customStyles);\n\n const isShowingClearButton = this.inputValue.length > 0;\n\n const inputGridClassNames = classNames('searchcraft-input-grid', {\n 'searchcraft-input-grid-buttonLeft': this.buttonPlacement === 'left',\n 'searchcraft-input-grid-buttonRight': this.buttonPlacement === 'right',\n 'searchcraft-input-grid-buttonNone': this.buttonPlacement === 'none',\n });\n\n const shouldHaveVerticalGap = this.inputLabel || this.error;\n const inputGridStyles = {\n gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',\n };\n\n return (\n <form class='searchcraft-input-form' onSubmit={this.handleFormSubmit}>\n <div class={inputGridClassNames} style={inputGridStyles}>\n <div class='searchcraft-input-button-wrapper'>\n <searchcraft-button\n onButtonClick={this.handleFormSubmit}\n label={this.buttonLabel}\n />\n </div>\n {this.inputLabel && (\n <div class='searchcraft-input-label-wrapper'>\n <searchcraft-input-label label={this.inputLabel} />\n </div>\n )}\n {this.error && (\n <div class='searchcraft-input-error-wrapper'>\n <searchcraft-error-message errorMessage='Something went wrong.' />\n </div>\n )}\n <div class='searchcraft-input-wrapper'>\n <input\n autoComplete='off'\n class='searchcraft-input'\n onFocus={() => this.inputFocus?.emit()}\n onBlur={() => this.inputBlur?.emit()}\n onInput={(event) => {\n this.handleOnInput(event);\n }}\n placeholder={this.placeholderValue}\n style={validatedCustomStyles}\n type='text'\n value={this.inputValue}\n />\n <div class='searchcraft-input-search-icon-wrapper'>\n <svg\n class='searchcraft-input-search-icon'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='searchcraft-title'\n >\n <title id='searchcraft-title'>\n Searchcraft Search Icon Light\n </title>\n <path\n d='M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </div>\n {isShowingClearButton && (\n <button\n type='button'\n class='searchcraft-input-clear-button'\n onClick={this.handleClearInput}\n >\n <svg\n class='searchcraft-input-clear-icon'\n viewBox='0 0 22 22'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='icon-title'\n >\n <title id='icon-title'>\n Searchcraft Clear Input Icon Light\n </title>\n <path\n d='M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </button>\n )}\n </div>\n </div>\n </form>\n );\n }\n}\n"],"version":3}
1
+ {"file":"p-ae78be68.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA8Ca,gBAAgB;;;;;;;;;;;;;;IAInB,MAAM,CAAgC;;;;IAItC,UAAU,GAAG,IAAI,CAAC;;;;IAIlB,eAAe,GAA8B,MAAM,CAAC;;;;IAIpD,WAAW,CAAqB;;;;IAIhC,UAAU,CAAqB;;;;IAI/B,YAAY,GAAoC,EAAE,CAAC;;;;IAInD,gBAAgB,GAAG,cAAc,CAAC;;;;IAIlC,UAAU,GAAG,EAAE,CAAC;;;;IAIf,YAAY,CAAsB;;;;IAIlC,iBAAiB,CAAsB;;;;IAIvC,UAAU,CAAsB;;;;IAIhC,SAAS,CAAsB;;;;IAI/B,SAAS,CAAsB;;;;IAI/B,WAAW,CAAwB;IAEnC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,KAAK,GAAG,KAAK,CAAC;IACd,wBAAwB,GAAG,KAAK,CAAC;IAElC,WAAW,GAAG,mBAAmB,CAAC,QAAQ,EAAE,CAAC;IAErD,IAAI;QACF,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE;YACjD,MAAM,WAAW,GAAG,IAAIA,EAAe,CAAC,IAAI,CAAC,MAAM,EAAE;gBACnD,OAAO,EAAE,WAAW,CAAC,IAAI;gBACzB,UAAU,EAAE,WAAW,CAAC,OAAO;aAChC,CAAC,CAAC;YACH,IAAI,CAAC,WAAW,CAAC,U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E,EAAC,YAAY,yCAEd,EACR,6DACE,CAAC,EAAC,uIAAuI,EACzI,MAAM,EAAC,cAAc,kBACR,KAAK,oBACH,OAAO,qBACN,OAAO,GACvB,CACE,CACC,CACV,CACG,CACF,CACD,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftCore"],"sources":["src/components/searchcraft-input-form/searchcraft-input-form.tsx"],"sourcesContent":["import {\n Component,\n h,\n Prop,\n State,\n Event,\n type EventEmitter,\n Watch,\n} from '@stencil/core';\n\nimport { type SearchcraftConfig, SearchcraftCore } from '@searchcraft/core';\nimport packageJson from '../../../package.json';\n\nimport { parseCustomStyles } from '@utils';\nimport { useSearchcraftStore } from '@provider/store';\nimport classNames from 'classnames';\n\n/**\n * This web component provides a user-friendly interface for querying an indexed dataset, enabling users to easily search large collections of data.\n * It abstracts the complexities of index-based searching, making it accessible to users of all technical levels.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-input-form placeholder-value=\"Search here\" />\n * ```\n *\n * ```js\n * // index.js\n * const searchInputForm = document.querySelector('searchcraft-input-form');\n *\n * searchInputForm.config = {\n * index: [],\n * readKey: '',\n * endpointUrl: '',\n * };\n *\n * searchForm.addEventListener('querySubmit', (event) => {\n * console.log('Query submitted', event.detail);\n * });\n * ```\n */\n@Component({\n tag: 'searchcraft-input-form',\n shadow: false,\n})\nexport class SearchcraftInput {\n /**\n * The Searchcraft config object.\n */\n @Prop() config: SearchcraftConfig | undefined;\n /**\n * Whether or not to automatically submit the search term when the input changes.\n */\n @Prop() autoSearch = true;\n /**\n * Where to place the search button.\n */\n @Prop() buttonPlacement: 'left' | 'right' | 'none' = 'none';\n /**\n * The label for the submit button.\n */\n @Prop() buttonLabel: string | undefined;\n /**\n * The label rendered above the input.\n */\n @Prop() inputLabel: string | undefined;\n /**\n * A custom styles object to be applied to the input element.\n */\n @Prop() customStyles: string | Record<string, string> = {};\n /**\n * The input element's placeholder value.\n */\n @Prop() placeholderValue = 'Enter Search';\n /**\n * The starting value of the input element.\n */\n @Prop() searchTerm = '';\n /**\n * When the input is cleared.\n */\n @Event() inputCleared?: EventEmitter<void>;\n /**\n * When no results are returned.\n */\n @Event() noResultsReceived?: EventEmitter<void>;\n /**\n * When the input becomes focused.\n */\n @Event() inputFocus?: EventEmitter<void>;\n /**\n * When the input becomes unfocused.\n */\n @Event() inputBlur?: EventEmitter<void>;\n /**\n * Event emitted when input initializes.\n */\n @Event() inputInit?: EventEmitter<void>;\n /**\n * Event emitted when a query has been submitted.\n */\n @Event() querySubmit?: EventEmitter<string>;\n\n @State() inputValue = this.searchTerm;\n @State() error = false;\n @State() isSearchcraftInitialized = false;\n\n private searchStore = useSearchcraftStore.getState();\n\n init() {\n if (this.config && !this.isSearchcraftInitialized) {\n const searchcraft = new SearchcraftCore(this.config, {\n sdkName: packageJson.name,\n sdkVersion: packageJson.version,\n });\n this.searchStore.initialize(searchcraft, true);\n this.isSearchcraftInitialized = true;\n this.inputInit?.emit();\n }\n }\n\n componentDidLoad() {\n this.init();\n }\n\n @Watch('config')\n onConfigChange() {\n this.init();\n }\n\n handleOnInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n this.inputValue = input.value;\n\n if (!this.autoSearch) {\n return;\n }\n\n if (input.value.trim() === '') {\n this.inputCleared?.emit();\n }\n\n this.performSearch(input.value);\n };\n\n private performSearch = async (value: string) => {\n if (value === useSearchcraftStore.getState().searchTerm) {\n return;\n }\n\n this.searchTerm = value.trim();\n this.error = false;\n this.searchStore.setSearchTerm(this.searchTerm);\n this.querySubmit?.emit(this.searchTerm);\n\n try {\n await this.searchStore.search();\n } catch (error) {\n this.error = true;\n this.inputCleared?.emit();\n }\n };\n\n handleClearInput = () => {\n this.inputValue = '';\n this.searchTerm = '';\n this.searchStore.setSearchTerm('');\n this.searchStore.setSearchClientResponseItems([]);\n this.error = false;\n\n this.inputCleared?.emit();\n };\n\n handleFormSubmit = async (event: Event) => {\n event.preventDefault();\n await this.performSearch(this.searchTerm);\n };\n\n render() {\n const validatedCustomStyles = parseCustomStyles(this.customStyles);\n\n const isShowingClearButton = this.inputValue.length > 0;\n\n const inputGridClassNames = classNames('searchcraft-input-grid', {\n 'searchcraft-input-grid-buttonLeft': this.buttonPlacement === 'left',\n 'searchcraft-input-grid-buttonRight': this.buttonPlacement === 'right',\n 'searchcraft-input-grid-buttonNone': this.buttonPlacement === 'none',\n });\n\n const shouldHaveVerticalGap = this.inputLabel || this.error;\n const inputGridStyles = {\n gap: shouldHaveVerticalGap ? '4px 8px' : '0px 8px',\n };\n\n return (\n <form class='searchcraft-input-form' onSubmit={this.handleFormSubmit}>\n <div class={inputGridClassNames} style={inputGridStyles}>\n <div class='searchcraft-input-button-wrapper'>\n <searchcraft-button\n onButtonClick={this.handleFormSubmit}\n label={this.buttonLabel}\n />\n </div>\n {this.inputLabel && (\n <div class='searchcraft-input-label-wrapper'>\n <searchcraft-input-label label={this.inputLabel} />\n </div>\n )}\n {this.error && (\n <div class='searchcraft-input-error-wrapper'>\n <searchcraft-error-message errorMessage='Something went wrong.' />\n </div>\n )}\n <div class='searchcraft-input-wrapper'>\n <input\n autoComplete='off'\n class='searchcraft-input'\n onFocus={() => this.inputFocus?.emit()}\n onBlur={() => this.inputBlur?.emit()}\n onInput={(event) => {\n this.handleOnInput(event);\n }}\n placeholder={this.placeholderValue}\n style={validatedCustomStyles}\n type='text'\n value={this.inputValue}\n />\n <div class='searchcraft-input-search-icon-wrapper'>\n <svg\n class='searchcraft-input-search-icon'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='searchcraft-title'\n >\n <title id='searchcraft-title'>\n Searchcraft Search Icon Light\n </title>\n <path\n d='M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </div>\n {isShowingClearButton && (\n <button\n type='button'\n class='searchcraft-input-clear-button'\n onClick={this.handleClearInput}\n >\n <svg\n class='searchcraft-input-clear-icon'\n viewBox='0 0 22 22'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n aria-labelledby='icon-title'\n >\n <title id='icon-title'>\n Searchcraft Clear Input Icon Light\n </title>\n <path\n d='M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z'\n stroke='currentColor'\n stroke-width='1.5'\n stroke-linecap='round'\n stroke-linejoin='round'\n />\n </svg>\n </button>\n )}\n </div>\n </div>\n </form>\n );\n }\n}\n"],"version":3}
@@ -1,4 +1,4 @@
1
- import { S as SearchcraftInput, d as defineCustomElement$1 } from './p-3df3ff8b.js';
1
+ import { S as SearchcraftInput, d as defineCustomElement$1 } from './p-ae78be68.js';
2
2
 
3
3
  const SearchcraftInputForm = SearchcraftInput;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -3,7 +3,7 @@ import { c as classNames } from './p-5cdc6210.js';
3
3
  import { u as useSearchcraftStore } from './p-38419178.js';
4
4
  import { d as defineCustomElement$8 } from './p-d19bf6ff.js';
5
5
  import { d as defineCustomElement$7 } from './p-0e393fe1.js';
6
- import { d as defineCustomElement$6 } from './p-3df3ff8b.js';
6
+ import { d as defineCustomElement$6 } from './p-ae78be68.js';
7
7
  import { d as defineCustomElement$5 } from './p-e55a7970.js';
8
8
  import { d as defineCustomElement$4 } from './p-ec0d230e.js';
9
9
  import { d as defineCustomElement$3 } from './p-bff4d3fc.js';
@@ -4,7 +4,7 @@ import { p as parseCustomStyles } from './styles-961644ef.js';
4
4
  import { c as classNames } from './index-72ac5051.js';
5
5
 
6
6
  const name = "@searchcraft/javascript-sdk";
7
- const version = "0.8.0";
7
+ const version = "0.8.1";
8
8
  const description = "Searchcraft Javascript SDK";
9
9
  const author = "Searchcraft";
10
10
  const license = "Apache-2.0";
@@ -53,7 +53,7 @@ const dependencies = {
53
53
  classnames: "^2.3.2"
54
54
  };
55
55
  const devDependencies = {
56
- "@searchcraft/core": "^0.8.0",
56
+ "@searchcraft/core": "^0.8.1",
57
57
  "@searchcraft/javascript-sdk": "*",
58
58
  "@stencil/core": "^4.7.0",
59
59
  "@stencil/react-output-target": "^0.8.2",
@@ -1,2 +1,2 @@
1
- import{r as t,c as e,h as s}from"./p-7e13c128.js";import{u as c,g as a}from"./p-38419178.js";import{p as i}from"./p-d9551738.js";import{c as r}from"./p-5cdc6210.js";const n="@searchcraft/javascript-sdk";const o="0.8.0";const d="Searchcraft Javascript SDK";const h="Searchcraft";const p="Apache-2.0";const l="dist/index.cjs.js";const f="dist/index.js";const u="dist/types/index.d.ts";const b="dist/collection/collection-manifest.json";const m="dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js";const y={".":{import:"./dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js",require:"./dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.cjs.js",types:"./dist/types/index.d.ts"},"./components":{import:"./dist/components/index.js",types:"./dist/components/index.d.ts"},"./loader":{import:"./dist/loader/index.js",require:"./dist/loader/index.cjs",types:"./dist/loader/index.d.ts"},"./dist/components/*":{import:"./dist/components/*",types:"./dist/components/*"}};const k={type:"git",url:"https://bitbucket.org/madebychalk/searchcraft-javascript-sdks/"};const v=["dist/"];const g={build:"stencil build && yarn docs",docs:"typedoc --options typedoc.json",dev:"stencil build --dev --watch",test:"stencil test --spec --e2e","test.watch":"stencil test --spec --e2e --watchAll",generate:"stencil generate"};const j={"@stencil/vue-output-target":"^0.9.2",classnames:"^2.3.2"};const w={"@searchcraft/core":"^0.8.0","@searchcraft/javascript-sdk":"*","@stencil/core":"^4.7.0","@stencil/react-output-target":"^0.8.2","@stencil/sass":"^3.0.12","@types/node":"^16.18.11",zustand:"^5.0.1"};const C={name:n,private:false,version:o,description:d,author:h,license:p,main:l,module:f,types:u,collection:b,"collection:main":"dist/collection/index.js",unpkg:m,exports:y,repository:k,files:v,scripts:g,dependencies:j,devDependencies:w};const x=class{constructor(s){t(this,s);this.inputCleared=e(this,"inputCleared",7);this.noResultsReceived=e(this,"noResultsReceived",7);this.inputFocus=e(this,"inputFocus",7);this.inputBlur=e(this,"inputBlur",7);this.inputInit=e(this,"inputInit",7);this.querySubmit=e(this,"querySubmit",7)}config;autoSearch=true;buttonPlacement="none";buttonLabel;inputLabel;customStyles={};placeholderValue="Enter Search";searchTerm="";inputCleared;noResultsReceived;inputFocus;inputBlur;inputInit;querySubmit;inputValue=this.searchTerm;error=false;isSearchcraftInitialized=false;searchStore=c.getState();init(){if(this.config&&!this.isSearchcraftInitialized){const t=new a(this.config,{sdkName:C.name,sdkVersion:C.version});this.searchStore.initialize(t,true);this.isSearchcraftInitialized=true;this.inputInit?.emit()}}componentDidLoad(){this.init()}onConfigChange(){this.init()}handleOnInput=t=>{const e=t.target;this.inputValue=e.value;if(!this.autoSearch){return}if(e.value.trim()===""){this.inputCleared?.emit()}this.performSearch(e.value)};performSearch=async t=>{if(t===c.getState().searchTerm){return}this.searchTerm=t.trim();this.error=false;this.searchStore.setSearchTerm(this.searchTerm);this.querySubmit?.emit(this.searchTerm);try{await this.searchStore.search()}catch(t){this.error=true;this.inputCleared?.emit()}};handleClearInput=()=>{this.inputValue="";this.searchTerm="";this.searchStore.setSearchTerm("");this.searchStore.setSearchClientResponseItems([]);this.error=false;this.inputCleared?.emit()};handleFormSubmit=async t=>{t.preventDefault();await this.performSearch(this.searchTerm)};render(){const t=i(this.customStyles);const e=this.inputValue.length>0;const c=r("searchcraft-input-grid",{"searchcraft-input-grid-buttonLeft":this.buttonPlacement==="left","searchcraft-input-grid-buttonRight":this.buttonPlacement==="right","searchcraft-input-grid-buttonNone":this.buttonPlacement==="none"});const a=this.inputLabel||this.error;const n={gap:a?"4px 8px":"0px 8px"};return s("form",{key:"bc665c50db8de601a3c95266bdf063ebb988d6a8",class:"searchcraft-input-form",onSubmit:this.handleFormSubmit},s("div",{key:"a6936858c08d866b66b887c7ae03b35961cf04a1",class:c,style:n},s("div",{key:"915ac892fccb771f1c5338cd2d52f16f1793615d",class:"searchcraft-input-button-wrapper"},s("searchcraft-button",{key:"81447da28dcb9cb80a8cdf0c6765c909c2746585",onButtonClick:this.handleFormSubmit,label:this.buttonLabel})),this.inputLabel&&s("div",{key:"939c3407d16075be25ff23bf9b379c05ba1a66d4",class:"searchcraft-input-label-wrapper"},s("searchcraft-input-label",{key:"9d9c4043c04132b27710cca47abf102a188a80b9",label:this.inputLabel})),this.error&&s("div",{key:"7e309f8a5c81a41bdd593f4e4ee1ba30c531c97d",class:"searchcraft-input-error-wrapper"},s("searchcraft-error-message",{key:"de947c04f0948e36786f50ac65720eeb598ae7bf",errorMessage:"Something went wrong."})),s("div",{key:"bcf774e3fa5164ab838b634badf2002495437fe7",class:"searchcraft-input-wrapper"},s("input",{key:"fd9759559712a39d3493e069ddddf7c267879c84",autoComplete:"off",class:"searchcraft-input",onFocus:()=>this.inputFocus?.emit(),onBlur:()=>this.inputBlur?.emit(),onInput:t=>{this.handleOnInput(t)},placeholder:this.placeholderValue,style:t,type:"text",value:this.inputValue}),s("div",{key:"8564b18962feeea8d9ab8bb46af4ba28a089d8f4",class:"searchcraft-input-search-icon-wrapper"},s("svg",{key:"90c3636ea306ed70887d76deaf058ab3ace61134",class:"searchcraft-input-search-icon",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"searchcraft-title"},s("title",{key:"c9921263b87df28e06bab9990e324aa1bebac767",id:"searchcraft-title"},"Searchcraft Search Icon Light"),s("path",{key:"bb82073fd722ff4a74e1a86c74cdf0dd9a8080b4",d:"M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))),e&&s("button",{key:"e708cb9426171bfdfb29e0a98206d086fa14e15e",type:"button",class:"searchcraft-input-clear-button",onClick:this.handleClearInput},s("svg",{key:"243b6eacc68fa8cc57d5e11b9b317d7fe581406f",class:"searchcraft-input-clear-icon",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"icon-title"},s("title",{key:"d8a8b44fe04345b5b27ba33ec4ba510500eab3bf",id:"icon-title"},"Searchcraft Clear Input Icon Light"),s("path",{key:"0602cbff7aac6755dabb496b84e6ef3e4e2ac7a6",d:"M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))))))}static get watchers(){return{config:["onConfigChange"]}}};const S=class{constructor(e){t(this,e)}popoverResultMappings;searchClientResponseItems;adClientResponseItems;searchResultsPage;searchResultsPerPage;render(){return s("div",{key:"a869d98e96f6fbbc80ecb79058c4753b4a3a8b1d",class:"searchcraft-popover-list-view"},this.adClientResponseItems?.map((t=>s("searchcraft-popover-list-item-ad",{adClientResponseItem:t,key:t.adId}))),this.searchClientResponseItems?.map(((t,e)=>s("searchcraft-popover-list-item",{item:t,key:t.id,popoverResultMappings:this.popoverResultMappings,documentPosition:this.searchResultsPerPage*(this.searchResultsPage-1)+e}))))}};export{x as searchcraft_input_form,S as searchcraft_popover_list_view};
2
- //# sourceMappingURL=p-a3074a6d.entry.js.map
1
+ import{r as t,c as e,h as s}from"./p-7e13c128.js";import{u as c,g as a}from"./p-38419178.js";import{p as i}from"./p-d9551738.js";import{c as r}from"./p-5cdc6210.js";const n="@searchcraft/javascript-sdk";const o="0.8.1";const d="Searchcraft Javascript SDK";const h="Searchcraft";const p="Apache-2.0";const l="dist/index.cjs.js";const f="dist/index.js";const u="dist/types/index.d.ts";const b="dist/collection/collection-manifest.json";const m="dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js";const y={".":{import:"./dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.esm.js",require:"./dist/searchcraft-javascript-sdk/searchcraft-javascript-sdk.cjs.js",types:"./dist/types/index.d.ts"},"./components":{import:"./dist/components/index.js",types:"./dist/components/index.d.ts"},"./loader":{import:"./dist/loader/index.js",require:"./dist/loader/index.cjs",types:"./dist/loader/index.d.ts"},"./dist/components/*":{import:"./dist/components/*",types:"./dist/components/*"}};const k={type:"git",url:"https://bitbucket.org/madebychalk/searchcraft-javascript-sdks/"};const v=["dist/"];const g={build:"stencil build && yarn docs",docs:"typedoc --options typedoc.json",dev:"stencil build --dev --watch",test:"stencil test --spec --e2e","test.watch":"stencil test --spec --e2e --watchAll",generate:"stencil generate"};const j={"@stencil/vue-output-target":"^0.9.2",classnames:"^2.3.2"};const w={"@searchcraft/core":"^0.8.1","@searchcraft/javascript-sdk":"*","@stencil/core":"^4.7.0","@stencil/react-output-target":"^0.8.2","@stencil/sass":"^3.0.12","@types/node":"^16.18.11",zustand:"^5.0.1"};const C={name:n,private:false,version:o,description:d,author:h,license:p,main:l,module:f,types:u,collection:b,"collection:main":"dist/collection/index.js",unpkg:m,exports:y,repository:k,files:v,scripts:g,dependencies:j,devDependencies:w};const x=class{constructor(s){t(this,s);this.inputCleared=e(this,"inputCleared",7);this.noResultsReceived=e(this,"noResultsReceived",7);this.inputFocus=e(this,"inputFocus",7);this.inputBlur=e(this,"inputBlur",7);this.inputInit=e(this,"inputInit",7);this.querySubmit=e(this,"querySubmit",7)}config;autoSearch=true;buttonPlacement="none";buttonLabel;inputLabel;customStyles={};placeholderValue="Enter Search";searchTerm="";inputCleared;noResultsReceived;inputFocus;inputBlur;inputInit;querySubmit;inputValue=this.searchTerm;error=false;isSearchcraftInitialized=false;searchStore=c.getState();init(){if(this.config&&!this.isSearchcraftInitialized){const t=new a(this.config,{sdkName:C.name,sdkVersion:C.version});this.searchStore.initialize(t,true);this.isSearchcraftInitialized=true;this.inputInit?.emit()}}componentDidLoad(){this.init()}onConfigChange(){this.init()}handleOnInput=t=>{const e=t.target;this.inputValue=e.value;if(!this.autoSearch){return}if(e.value.trim()===""){this.inputCleared?.emit()}this.performSearch(e.value)};performSearch=async t=>{if(t===c.getState().searchTerm){return}this.searchTerm=t.trim();this.error=false;this.searchStore.setSearchTerm(this.searchTerm);this.querySubmit?.emit(this.searchTerm);try{await this.searchStore.search()}catch(t){this.error=true;this.inputCleared?.emit()}};handleClearInput=()=>{this.inputValue="";this.searchTerm="";this.searchStore.setSearchTerm("");this.searchStore.setSearchClientResponseItems([]);this.error=false;this.inputCleared?.emit()};handleFormSubmit=async t=>{t.preventDefault();await this.performSearch(this.searchTerm)};render(){const t=i(this.customStyles);const e=this.inputValue.length>0;const c=r("searchcraft-input-grid",{"searchcraft-input-grid-buttonLeft":this.buttonPlacement==="left","searchcraft-input-grid-buttonRight":this.buttonPlacement==="right","searchcraft-input-grid-buttonNone":this.buttonPlacement==="none"});const a=this.inputLabel||this.error;const n={gap:a?"4px 8px":"0px 8px"};return s("form",{key:"bc665c50db8de601a3c95266bdf063ebb988d6a8",class:"searchcraft-input-form",onSubmit:this.handleFormSubmit},s("div",{key:"a6936858c08d866b66b887c7ae03b35961cf04a1",class:c,style:n},s("div",{key:"915ac892fccb771f1c5338cd2d52f16f1793615d",class:"searchcraft-input-button-wrapper"},s("searchcraft-button",{key:"81447da28dcb9cb80a8cdf0c6765c909c2746585",onButtonClick:this.handleFormSubmit,label:this.buttonLabel})),this.inputLabel&&s("div",{key:"939c3407d16075be25ff23bf9b379c05ba1a66d4",class:"searchcraft-input-label-wrapper"},s("searchcraft-input-label",{key:"9d9c4043c04132b27710cca47abf102a188a80b9",label:this.inputLabel})),this.error&&s("div",{key:"7e309f8a5c81a41bdd593f4e4ee1ba30c531c97d",class:"searchcraft-input-error-wrapper"},s("searchcraft-error-message",{key:"de947c04f0948e36786f50ac65720eeb598ae7bf",errorMessage:"Something went wrong."})),s("div",{key:"bcf774e3fa5164ab838b634badf2002495437fe7",class:"searchcraft-input-wrapper"},s("input",{key:"fd9759559712a39d3493e069ddddf7c267879c84",autoComplete:"off",class:"searchcraft-input",onFocus:()=>this.inputFocus?.emit(),onBlur:()=>this.inputBlur?.emit(),onInput:t=>{this.handleOnInput(t)},placeholder:this.placeholderValue,style:t,type:"text",value:this.inputValue}),s("div",{key:"8564b18962feeea8d9ab8bb46af4ba28a089d8f4",class:"searchcraft-input-search-icon-wrapper"},s("svg",{key:"90c3636ea306ed70887d76deaf058ab3ace61134",class:"searchcraft-input-search-icon",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"searchcraft-title"},s("title",{key:"c9921263b87df28e06bab9990e324aa1bebac767",id:"searchcraft-title"},"Searchcraft Search Icon Light"),s("path",{key:"bb82073fd722ff4a74e1a86c74cdf0dd9a8080b4",d:"M17.5 17.5L13.875 13.875M15.8333 9.16667C15.8333 12.8486 12.8486 15.8333 9.16667 15.8333C5.48477 15.8333 2.5 12.8486 2.5 9.16667C2.5 5.48477 5.48477 2.5 9.16667 2.5C12.8486 2.5 15.8333 5.48477 15.8333 9.16667Z",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))),e&&s("button",{key:"e708cb9426171bfdfb29e0a98206d086fa14e15e",type:"button",class:"searchcraft-input-clear-button",onClick:this.handleClearInput},s("svg",{key:"243b6eacc68fa8cc57d5e11b9b317d7fe581406f",class:"searchcraft-input-clear-icon",viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-labelledby":"icon-title"},s("title",{key:"d8a8b44fe04345b5b27ba33ec4ba510500eab3bf",id:"icon-title"},"Searchcraft Clear Input Icon Light"),s("path",{key:"0602cbff7aac6755dabb496b84e6ef3e4e2ac7a6",d:"M14 8L8 14M8 8L14 14M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1C16.5228 1 21 5.47715 21 11Z",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))))))}static get watchers(){return{config:["onConfigChange"]}}};const S=class{constructor(e){t(this,e)}popoverResultMappings;searchClientResponseItems;adClientResponseItems;searchResultsPage;searchResultsPerPage;render(){return s("div",{key:"a869d98e96f6fbbc80ecb79058c4753b4a3a8b1d",class:"searchcraft-popover-list-view"},this.adClientResponseItems?.map((t=>s("searchcraft-popover-list-item-ad",{adClientResponseItem:t,key:t.adId}))),this.searchClientResponseItems?.map(((t,e)=>s("searchcraft-popover-list-item",{item:t,key:t.id,popoverResultMappings:this.popoverResultMappings,documentPosition:this.searchResultsPerPage*(this.searchResultsPage-1)+e}))))}};export{x as searchcraft_input_form,S as searchcraft_popover_list_view};
2
+ //# sourceMappingURL=p-75779e4b.entry.js.map
@@ -1,2 +1,2 @@
1
- import{p as e,b as t}from"./p-7e13c128.js";export{s as setNonce}from"./p-7e13c128.js";import{g as a}from"./p-e1255160.js";var r=()=>{const t=import.meta.url;const s={};if(t!==""){s.resourcesUrl=new URL(".",t).href}return e(s)};r().then((async e=>{await a();return t([["p-6bffd3f5",[[4,"searchcraft-base-search-results",{customStylesForResults:[1,"custom-styles-for-results"],searchResultMappings:[16],resultImagePlacement:[1,"result-image-placement"],buttonLabel:[1,"button-label"],buttonTarget:[1,"button-target"],buttonRel:[1,"button-rel"],containerTarget:[1,"container-target"],containerRel:[1,"container-rel"],searchTerm:[32],searchClientResponseItems:[32],adClientResponseItems:[32],searchResultsPerPage:[32],searchResultsPage:[32]}]]],["p-9340f4e4",[[0,"searchcraft-filter-panel",{items:[16],unsubscribe:[32],lastSearchTerm:[32]}]]],["p-69da4e58",[[0,"searchcraft-pagination",{customStyles:[1,"custom-styles"],searchTerm:[32],searchResultsPerPage:[32],searchResultsPage:[32],searchResultsCount:[32],searchResultsPagesCount:[32],searchResultsRangeMin:[32],searchResultsRangeMax:[32],setSearchResultsPage:[32]}]]],["p-5e064c07",[[0,"searchcraft-search-results-per-page",{increment:[8],customStyles:[1,"custom-styles"],searchTerm:[32],searchResultsPage:[32],searchResultsPerPage:[32],searchResultsCount:[32],searchResultsPagesCount:[32],initialSearchResultsPerPage:[32],setSearchResultsPerPage:[32],setSearchResultsPage:[32]}]]],["p-7f4dd50c",[[4,"searchcraft-popover-button"]]],["p-a84b1548",[[0,"searchcraft-results-info",{customFormatter:[16],customStyles:[1,"custom-styles"],searchTerm:[32],searchResultsPage:[32],searchResultsPerPage:[32],searchResultsCount:[32],count:[32],range:[32],responseTime:[32]}]]],["p-e11de2d6",[[0,"searchcraft-theme",{theme:[1],customTheme:[1,"custom-theme"]}]]],["p-a3074a6d",[[0,"searchcraft-input-form",{config:[16],autoSearch:[4,"auto-search"],buttonPlacement:[1,"button-placement"],buttonLabel:[1,"button-label"],inputLabel:[1,"input-label"],customStyles:[1,"custom-styles"],placeholderValue:[1,"placeholder-value"],searchTerm:[1,"search-term"],inputValue:[32],error:[32],isSearchcraftInitialized:[32]},null,{config:["onConfigChange"]}],[0,"searchcraft-popover-list-view",{popoverResultMappings:[16],searchClientResponseItems:[16],adClientResponseItems:[16],searchResultsPage:[2,"search-results-page"],searchResultsPerPage:[2,"search-results-per-page"]}]]],["p-2dc07b47",[[0,"searchcraft-popover-form",{config:[16],type:[1],popoverResultMappings:[16],hotkey:[1],hotkeyModifier:[1,"hotkey-modifier"],isPopoverVisibleInState:[32],unsubscribe:[32],searchClientResponseItems:[32],adClientResponseItems:[32],searchTerm:[32],isFocused:[32],breakpointSm:[32],breakpointMd:[32],breakpointLg:[32],searchResultsPage:[32],searchResultsPerPage:[32],modalElement:[32]}]]],["p-b8ea0454",[[0,"searchcraft-select",{caption:[1],disabled:[4],inputId:[1,"input-id"],label:[1],labelId:[1,"label-id"],name:[1],options:[1],customStyles:[1,"custom-styles"],searchResultsPerPage:[32],setSearchResultsPage:[32],setSearchResultsPerPage:[32]}]]],["p-279f3e15",[[0,"searchcraft-base-search-result",{item:[16],searchResultMappings:[16],containerTarget:[1,"container-target"],containerRel:[1,"container-rel"],buttonTarget:[1,"button-target"],buttonRel:[1,"button-rel"],imagePlacement:[1,"image-placement"],customStyles:[1,"custom-styles"],documentPosition:[2,"document-position"],titleContent:[32],subtitleContent:[32],bodyContent:[32],footerContent:[32],buttonLabel:[32],buttonHref:[32],containerHref:[32],imageSrc:[32],imageAlt:[32]}],[0,"searchcraft-base-search-result-ad",{adClientResponseItem:[16]}]]],["p-2bc82b48",[[0,"searchcraft-facet-list",{fieldName:[1,"field-name"],baseFacetRoot:[32],facetRoot:[32],selectedPaths:[32],lastTimeTaken:[32],hasNewSearchTerm:[32],lastSearchTerm:[32],lastSearchMode:[32],lastSortType:[32],unsubscribe:[32]}],[0,"searchcraft-slider",{max:[2],min:[2],granularity:[2],dataType:[1,"data-type"],endValue:[32],startValue:[32],lastFocusedHandle:[32]}],[0,"searchcraft-toggle-button",{label:[1],subLabel:[1,"sub-label"],isActive:[32],unsubscribe:[32],lastSearchTerm:[32]}]]],["p-c4a9d8ab",[[0,"searchcraft-popover-list-item",{item:[16],popoverResultMappings:[16],documentPosition:[2,"document-position"],href:[32],imageSrc:[32],imageAlt:[32],titleContent:[32],subtitleContent:[32]}],[0,"searchcraft-popover-list-item-ad",{adClientResponseItem:[16]}]]],["p-d2fffca9",[[0,"searchcraft-input-label",{inputLabelClassName:[1,"input-label-class-name"],label:[1]}],[0,"searchcraft-button",{hierarchy:[1],disabled:[4],icon:[16],iconOnly:[4,"icon-only"],iconPosition:[1,"icon-position"],label:[1],type:[1]}],[0,"searchcraft-error-message",{errorMessage:[1,"error-message"]}]]]],e)}));
1
+ import{p as e,b as t}from"./p-7e13c128.js";export{s as setNonce}from"./p-7e13c128.js";import{g as a}from"./p-e1255160.js";var r=()=>{const t=import.meta.url;const s={};if(t!==""){s.resourcesUrl=new URL(".",t).href}return e(s)};r().then((async e=>{await a();return t([["p-6bffd3f5",[[4,"searchcraft-base-search-results",{customStylesForResults:[1,"custom-styles-for-results"],searchResultMappings:[16],resultImagePlacement:[1,"result-image-placement"],buttonLabel:[1,"button-label"],buttonTarget:[1,"button-target"],buttonRel:[1,"button-rel"],containerTarget:[1,"container-target"],containerRel:[1,"container-rel"],searchTerm:[32],searchClientResponseItems:[32],adClientResponseItems:[32],searchResultsPerPage:[32],searchResultsPage:[32]}]]],["p-9340f4e4",[[0,"searchcraft-filter-panel",{items:[16],unsubscribe:[32],lastSearchTerm:[32]}]]],["p-69da4e58",[[0,"searchcraft-pagination",{customStyles:[1,"custom-styles"],searchTerm:[32],searchResultsPerPage:[32],searchResultsPage:[32],searchResultsCount:[32],searchResultsPagesCount:[32],searchResultsRangeMin:[32],searchResultsRangeMax:[32],setSearchResultsPage:[32]}]]],["p-5e064c07",[[0,"searchcraft-search-results-per-page",{increment:[8],customStyles:[1,"custom-styles"],searchTerm:[32],searchResultsPage:[32],searchResultsPerPage:[32],searchResultsCount:[32],searchResultsPagesCount:[32],initialSearchResultsPerPage:[32],setSearchResultsPerPage:[32],setSearchResultsPage:[32]}]]],["p-7f4dd50c",[[4,"searchcraft-popover-button"]]],["p-a84b1548",[[0,"searchcraft-results-info",{customFormatter:[16],customStyles:[1,"custom-styles"],searchTerm:[32],searchResultsPage:[32],searchResultsPerPage:[32],searchResultsCount:[32],count:[32],range:[32],responseTime:[32]}]]],["p-e11de2d6",[[0,"searchcraft-theme",{theme:[1],customTheme:[1,"custom-theme"]}]]],["p-75779e4b",[[0,"searchcraft-input-form",{config:[16],autoSearch:[4,"auto-search"],buttonPlacement:[1,"button-placement"],buttonLabel:[1,"button-label"],inputLabel:[1,"input-label"],customStyles:[1,"custom-styles"],placeholderValue:[1,"placeholder-value"],searchTerm:[1,"search-term"],inputValue:[32],error:[32],isSearchcraftInitialized:[32]},null,{config:["onConfigChange"]}],[0,"searchcraft-popover-list-view",{popoverResultMappings:[16],searchClientResponseItems:[16],adClientResponseItems:[16],searchResultsPage:[2,"search-results-page"],searchResultsPerPage:[2,"search-results-per-page"]}]]],["p-2dc07b47",[[0,"searchcraft-popover-form",{config:[16],type:[1],popoverResultMappings:[16],hotkey:[1],hotkeyModifier:[1,"hotkey-modifier"],isPopoverVisibleInState:[32],unsubscribe:[32],searchClientResponseItems:[32],adClientResponseItems:[32],searchTerm:[32],isFocused:[32],breakpointSm:[32],breakpointMd:[32],breakpointLg:[32],searchResultsPage:[32],searchResultsPerPage:[32],modalElement:[32]}]]],["p-b8ea0454",[[0,"searchcraft-select",{caption:[1],disabled:[4],inputId:[1,"input-id"],label:[1],labelId:[1,"label-id"],name:[1],options:[1],customStyles:[1,"custom-styles"],searchResultsPerPage:[32],setSearchResultsPage:[32],setSearchResultsPerPage:[32]}]]],["p-279f3e15",[[0,"searchcraft-base-search-result",{item:[16],searchResultMappings:[16],containerTarget:[1,"container-target"],containerRel:[1,"container-rel"],buttonTarget:[1,"button-target"],buttonRel:[1,"button-rel"],imagePlacement:[1,"image-placement"],customStyles:[1,"custom-styles"],documentPosition:[2,"document-position"],titleContent:[32],subtitleContent:[32],bodyContent:[32],footerContent:[32],buttonLabel:[32],buttonHref:[32],containerHref:[32],imageSrc:[32],imageAlt:[32]}],[0,"searchcraft-base-search-result-ad",{adClientResponseItem:[16]}]]],["p-2bc82b48",[[0,"searchcraft-facet-list",{fieldName:[1,"field-name"],baseFacetRoot:[32],facetRoot:[32],selectedPaths:[32],lastTimeTaken:[32],hasNewSearchTerm:[32],lastSearchTerm:[32],lastSearchMode:[32],lastSortType:[32],unsubscribe:[32]}],[0,"searchcraft-slider",{max:[2],min:[2],granularity:[2],dataType:[1,"data-type"],endValue:[32],startValue:[32],lastFocusedHandle:[32]}],[0,"searchcraft-toggle-button",{label:[1],subLabel:[1,"sub-label"],isActive:[32],unsubscribe:[32],lastSearchTerm:[32]}]]],["p-c4a9d8ab",[[0,"searchcraft-popover-list-item",{item:[16],popoverResultMappings:[16],documentPosition:[2,"document-position"],href:[32],imageSrc:[32],imageAlt:[32],titleContent:[32],subtitleContent:[32]}],[0,"searchcraft-popover-list-item-ad",{adClientResponseItem:[16]}]]],["p-d2fffca9",[[0,"searchcraft-input-label",{inputLabelClassName:[1,"input-label-class-name"],label:[1]}],[0,"searchcraft-button",{hierarchy:[1],disabled:[4],icon:[16],iconOnly:[4,"icon-only"],iconPosition:[1,"icon-position"],label:[1],type:[1]}],[0,"searchcraft-error-message",{errorMessage:[1,"error-message"]}]]]],e)}));
2
2
  //# sourceMappingURL=searchcraft-javascript-sdk.esm.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@searchcraft/javascript-sdk",
3
3
  "private": false,
4
- "version": "0.8.0",
4
+ "version": "0.8.1",
5
5
  "description": "Searchcraft Javascript SDK",
6
6
  "author": "Searchcraft",
7
7
  "license": "Apache-2.0",
@@ -51,7 +51,7 @@
51
51
  "classnames": "^2.3.2"
52
52
  },
53
53
  "devDependencies": {
54
- "@searchcraft/core": "^0.8.0",
54
+ "@searchcraft/core": "^0.8.1",
55
55
  "@searchcraft/javascript-sdk": "*",
56
56
  "@stencil/core": "^4.7.0",
57
57
  "@stencil/react-output-target": "^0.8.2",
@@ -59,5 +59,5 @@
59
59
  "@types/node": "^16.18.11",
60
60
  "zustand": "^5.0.1"
61
61
  },
62
- "gitHead": "0e03fc445dfbba9404e1c4e7c878a564bd2f96bb"
62
+ "gitHead": "8e7f1726596a6d96a07dd86e5346248e88636cfc"
63
63
  }