@searchcraft/javascript-sdk 0.9.7 → 0.10.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.
Files changed (128) hide show
  1. package/README.md +2 -2
  2. package/dist/components/defineCustomElements.js +8 -6
  3. package/dist/components/index.d.ts +2632 -68
  4. package/dist/components/index.js +51 -15
  5. package/dist/components/index.js.map +1 -1
  6. package/dist/components/{p-e41b0f43.js → p-0077f677.js} +14 -21
  7. package/dist/components/p-0077f677.js.map +1 -0
  8. package/dist/components/p-13e81b5d.js +147 -0
  9. package/dist/components/p-13e81b5d.js.map +1 -0
  10. package/dist/components/p-172a848d.js +93 -0
  11. package/dist/components/p-172a848d.js.map +1 -0
  12. package/dist/components/{p-580c09dc.js → p-17c646e2.js} +226 -190
  13. package/dist/components/p-17c646e2.js.map +1 -0
  14. package/dist/components/{p-e55a7970.js → p-1adf78b9.js} +2 -2
  15. package/dist/components/p-1adf78b9.js.map +1 -0
  16. package/dist/components/{p-e27a0dab.js → p-2be1a382.js} +5 -7
  17. package/dist/components/p-2be1a382.js.map +1 -0
  18. package/dist/components/{p-4df578e4.js → p-3e65aa91.js} +8 -8
  19. package/dist/components/p-3e65aa91.js.map +1 -0
  20. package/dist/components/{p-8f854dec.js → p-5d17ace0.js} +14 -13
  21. package/dist/components/p-5d17ace0.js.map +1 -0
  22. package/dist/components/{p-bf6a086a.js → p-73db9122.js} +3 -10
  23. package/dist/components/p-73db9122.js.map +1 -0
  24. package/dist/components/p-810a7850.js +17 -0
  25. package/dist/components/p-810a7850.js.map +1 -0
  26. package/dist/components/p-84e2cbd6.js +46 -0
  27. package/dist/components/p-84e2cbd6.js.map +1 -0
  28. package/dist/components/{p-bb12ab5a.js → p-868803f9.js} +4 -3
  29. package/dist/components/p-868803f9.js.map +1 -0
  30. package/dist/components/{p-60f05735.js → p-a62a2e74.js} +4 -4
  31. package/dist/components/p-a62a2e74.js.map +1 -0
  32. package/dist/components/{p-5fdaf1e6.js → p-a64b4cba.js} +2 -145
  33. package/dist/components/p-a64b4cba.js.map +1 -0
  34. package/dist/components/{p-71cc28c1.js → p-acf23bab.js} +2 -2
  35. package/dist/components/p-acf23bab.js.map +1 -0
  36. package/dist/components/{p-0e393fe1.js → p-f2585cdf.js} +3 -9
  37. package/dist/components/p-f2585cdf.js.map +1 -0
  38. package/dist/components/searchcraft-ad.js +1 -1
  39. package/dist/components/searchcraft-button.js +1 -1
  40. package/dist/components/searchcraft-error-message.js +1 -1
  41. package/dist/components/searchcraft-facet-list.js +1 -1
  42. package/dist/components/searchcraft-filter-panel.js +6 -5
  43. package/dist/components/searchcraft-filter-panel.js.map +1 -1
  44. package/dist/components/searchcraft-input-form.js +2 -2
  45. package/dist/components/searchcraft-input-label.js +1 -1
  46. package/dist/components/searchcraft-pagination.js +3 -9
  47. package/dist/components/searchcraft-pagination.js.map +1 -1
  48. package/dist/components/searchcraft-popover-button.js +95 -3
  49. package/dist/components/searchcraft-popover-button.js.map +1 -1
  50. package/dist/components/searchcraft-popover-footer.d.ts +11 -0
  51. package/dist/components/searchcraft-popover-footer.js +8 -0
  52. package/dist/components/searchcraft-popover-footer.js.map +1 -0
  53. package/dist/components/searchcraft-popover-form.js +36 -27
  54. package/dist/components/searchcraft-popover-form.js.map +1 -1
  55. package/dist/components/searchcraft-popover-list-item.js +1 -1
  56. package/dist/components/searchcraft-popover-list-view.js +1 -1
  57. package/dist/components/searchcraft-results-info.js +12 -23
  58. package/dist/components/searchcraft-results-info.js.map +1 -1
  59. package/dist/components/searchcraft-search-result.d.ts +11 -0
  60. package/dist/components/searchcraft-search-result.js +8 -0
  61. package/dist/components/searchcraft-search-result.js.map +1 -0
  62. package/dist/components/searchcraft-search-results-per-page.js +3 -10
  63. package/dist/components/searchcraft-search-results-per-page.js.map +1 -1
  64. package/dist/components/searchcraft-search-results.d.ts +11 -0
  65. package/dist/components/{searchcraft-base-search-results.js → searchcraft-search-results.js} +25 -71
  66. package/dist/components/searchcraft-search-results.js.map +1 -0
  67. package/dist/components/searchcraft-select.js +1 -1
  68. package/dist/components/searchcraft-slider.js +1 -1
  69. package/dist/components/searchcraft-theme.js +4 -42
  70. package/dist/components/searchcraft-theme.js.map +1 -1
  71. package/dist/components/searchcraft-toggle-button.js +1 -1
  72. package/dist/hydrate/index.d.ts +242 -0
  73. package/dist/hydrate/index.js +23479 -0
  74. package/dist/hydrate/index.mjs +23471 -0
  75. package/dist/hydrate/package.json +12 -0
  76. package/dist/themes/hologram.css +1 -0
  77. package/dist/themes/hologram.css.map +1 -0
  78. package/dist/types/components/searchcraft-ad/searchcraft-ad.d.ts +2 -0
  79. package/dist/types/components/searchcraft-button/searchcraft-button.d.ts +3 -2
  80. package/dist/types/components/searchcraft-error-message/searchcraft-error-message.d.ts +6 -7
  81. package/dist/types/components/searchcraft-facet-list/searchcraft-facet-list.d.ts +3 -1
  82. package/dist/types/components/searchcraft-filter-panel/searchcraft-filter-panel.d.ts +30 -1
  83. package/dist/types/components/searchcraft-input-form/searchcraft-input-form.d.ts +23 -14
  84. package/dist/types/components/searchcraft-input-label/searchcraft-input-label.d.ts +3 -2
  85. package/dist/types/components/searchcraft-pagination/searchcraft-pagination.d.ts +22 -8
  86. package/dist/types/components/searchcraft-popover-button/searchcraft-popover-button.d.ts +74 -0
  87. package/dist/types/components/searchcraft-popover-footer/searchcraft-popover-footer.d.ts +13 -0
  88. package/dist/types/components/searchcraft-popover-form/searchcraft-popover-form.d.ts +27 -15
  89. package/dist/types/components/searchcraft-popover-list-item/searchcraft-popover-list-item.d.ts +5 -3
  90. package/dist/types/components/searchcraft-popover-list-view/searchcraft-popover-list-view.d.ts +3 -2
  91. package/dist/types/components/searchcraft-results-info/searchcraft-results-info.d.ts +41 -19
  92. package/dist/types/components/searchcraft-search-result/searchcraft-search-result.d.ts +28 -0
  93. package/dist/types/components/searchcraft-search-results/searchcraft-search-results.d.ts +81 -0
  94. package/dist/types/components/searchcraft-search-results-per-page/searchcraft-search-results-per-page.d.ts +21 -5
  95. package/dist/types/components/searchcraft-select/searchcraft-select.d.ts +3 -5
  96. package/dist/types/components/searchcraft-slider/searchcraft-slider.d.ts +3 -3
  97. package/dist/types/components/searchcraft-theme/searchcraft-theme.d.ts +24 -16
  98. package/dist/types/components/searchcraft-toggle-button/searchcraft-toggle-button.d.ts +2 -1
  99. package/dist/types/components.d.ts +947 -612
  100. package/dist/types/index.d.ts +5 -4
  101. package/dist/types/store/SearchcraftStore.types.d.ts +3 -0
  102. package/dist/types/utils/html.d.ts +6 -0
  103. package/dist/types/utils/index.d.ts +1 -0
  104. package/package.json +13 -7
  105. package/dist/components/bundled.types.d.ts +0 -2275
  106. package/dist/components/p-0e393fe1.js.map +0 -1
  107. package/dist/components/p-19fe91f1.js +0 -136
  108. package/dist/components/p-19fe91f1.js.map +0 -1
  109. package/dist/components/p-4df578e4.js.map +0 -1
  110. package/dist/components/p-580c09dc.js.map +0 -1
  111. package/dist/components/p-5fdaf1e6.js.map +0 -1
  112. package/dist/components/p-60f05735.js.map +0 -1
  113. package/dist/components/p-71cc28c1.js.map +0 -1
  114. package/dist/components/p-8f854dec.js.map +0 -1
  115. package/dist/components/p-bb12ab5a.js.map +0 -1
  116. package/dist/components/p-bf6a086a.js.map +0 -1
  117. package/dist/components/p-d9551738.js +0 -25
  118. package/dist/components/p-d9551738.js.map +0 -1
  119. package/dist/components/p-e27a0dab.js.map +0 -1
  120. package/dist/components/p-e41b0f43.js.map +0 -1
  121. package/dist/components/p-e55a7970.js.map +0 -1
  122. package/dist/components/searchcraft-base-search-result.d.ts +0 -11
  123. package/dist/components/searchcraft-base-search-result.js +0 -8
  124. package/dist/components/searchcraft-base-search-result.js.map +0 -1
  125. package/dist/components/searchcraft-base-search-results.d.ts +0 -11
  126. package/dist/components/searchcraft-base-search-results.js.map +0 -1
  127. package/dist/types/components/searchcraft-base-search-result/searchcraft-base-search-result.d.ts +0 -55
  128. package/dist/types/components/searchcraft-base-search-results/searchcraft-base-search-results.d.ts +0 -89
@@ -1,18 +1,110 @@
1
1
  import { p as proxyCustomElement, H, h } from './p-5365011f.js';
2
- import { s as searchcraftStore } from './p-580c09dc.js';
2
+ import { s as searchcraftStore } from './p-17c646e2.js';
3
+ import { h as html } from './p-810a7850.js';
3
4
 
4
5
  const SearchcraftPopoverButton$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverButton extends H {
5
6
  constructor() {
6
7
  super();
7
8
  this.__registerHost();
8
9
  }
10
+ /**
11
+ * A callback function responsible for rendering the button contents.
12
+ */
13
+ template;
14
+ /**
15
+ * The type of popover button to render.
16
+ */
17
+ type;
18
+ hotkey;
19
+ hotkeyModifier;
20
+ hotkeyModifierSymbol;
21
+ isPopoverVisible;
22
+ userAgent;
23
+ unsubscribe = () => { };
9
24
  handleOnClick() {
10
25
  searchcraftStore.getState().setPopoverVisibility(true);
11
26
  }
27
+ componentDidLoad() {
28
+ const state = searchcraftStore.getState();
29
+ this.hotkey = state.hotkey.toUpperCase();
30
+ this.hotkeyModifier = state.hotkeyModifier;
31
+ this.isPopoverVisible = state.isPopoverVisible;
32
+ this.userAgent = this.setUserAgent();
33
+ this.hotkeyModifierSymbol = this.setHotkeyModifierSymbol();
34
+ this.unsubscribe = searchcraftStore.subscribe((state) => {
35
+ this.hotkey = state.hotkey.toUpperCase();
36
+ this.hotkeyModifier = state.hotkeyModifier;
37
+ this.hotkeyModifierSymbol = this.setHotkeyModifierSymbol();
38
+ });
39
+ }
40
+ disconnectedCallback() {
41
+ this.unsubscribe?.();
42
+ }
43
+ setUserAgent() {
44
+ const userAgent = navigator.userAgent.toLowerCase();
45
+ switch (true) {
46
+ case userAgent.includes('windows'):
47
+ return 'window';
48
+ case userAgent.includes('mac'):
49
+ return 'mac';
50
+ default:
51
+ return 'other';
52
+ }
53
+ }
54
+ renderOptionSymbol = () => {
55
+ return (h("svg", { version: '1.1', xmlns: 'http://www.w3.org/2000/svg', width: '20', height: '20', viewBox: '0 0 512 512', fill: 'none' }, h("title", null, "Option key"), h("path", { d: 'M283,112c0-11.58,9.42-21,21-21h160c11.58,0,21,9.42,21,21s-9.42,21-21,21h-160c-11.58,0-21-9.42-21-21Z', fill: 'currentColor' }), h("path", { d: 'M485,400c0,11.58-9.42,21-21,21h-128c-8.29,0-15.82-4.9-19.19-12.47l-122.46-275.53H48c-11.58,0-21-9.42-21-21s9.42-21,21-21h160c8.29,0,15.82,4.9,19.19,12.47l122.46,275.53h114.35c11.58,0,21,9.42,21,21Z', fill: 'currentColor' })));
56
+ };
57
+ renderCtrlSymbol = () => {
58
+ return (h("svg", { version: '1.1', xmlns: 'http://www.w3.org/2000/svg', width: '20', height: '20', viewBox: '0 0 512 512', fill: 'none' }, h("title", null, "Ctrl key"), h("path", { d: 'M388.95,209.4c-.37,5.59-2.9,10.71-7.12,14.4-3.83,3.35-8.74,5.2-13.82,5.2-6.06,0-11.83-2.61-15.81-7.17l-96.2-109.94-96.2,109.94c-3.98,4.56-9.75,7.17-15.81,7.17-5.08,0-9.99-1.84-13.82-5.2-4.22-3.69-6.75-8.81-7.12-14.4-.38-5.6,1.45-11.01,5.15-15.23l112-128c3.98-4.56,9.74-7.17,15.8-7.17s11.82,2.61,15.8,7.17l112,128c3.7,4.22,5.53,9.63,5.15,15.23Z', fill: 'currentColor' })));
59
+ };
60
+ renderWindowsMetaSymbol = () => {
61
+ return (h("svg", { version: '1.1', xmlns: 'http://www.w3.org/2000/svg', width: '20', height: '20', viewBox: '0 0 512 512', fill: 'none' }, h("title", null, "Windows meta key"), h("path", { d: 'M206.115 255.957c-23.854-12.259-47.043-18.479-68.94-18.479-2.978 0-5.976 0.090-8.974 0.354-27.94 2.312-53.461 9.684-69.875 15.414-4.354 1.599-8.817 3.288-13.415 5.153l-44.911 155.697c30.851-11.416 58.146-16.969 83.135-16.969 40.423 0 69.764 15.104 93.996 30.652 11.481-38.959 39.022-133.045 47.241-161.162-5.975-3.642-12.038-7.285-18.257-10.66zM264.174 295.535l-45.223 157.074c13.416 7.686 58.549 32.025 93.106 32.025 27.896 0 59.126-7.148 95.417-21.896l43.178-150.988c-29.316 9.461-57.438 14.26-83.732 14.26-47.975 0-81.557-15.549-102.746-30.475zM146.411 184.395c38.559 0.399 67.076 15.104 90.708 30.251l46.376-158.672c-9.773-5.598-35.403-19.547-53.929-24.3-12.193-2.842-25.010-4.308-38.602-4.308-25.898 0.488-54.194 6.973-86.444 19.9l-44.22 155.298c32.404-12.218 60.322-18.17 86.043-18.17 0.023 0.001 0.068 0.001 0.068 0.001zM512 99.062c-29.407 11.416-58.104 17.233-85.514 17.233-45.843 0-79.646-15.901-101.547-31.183l-45.975 159.118c30.873 19.854 64.145 29.939 99.061 29.939 28.474 0 57.97-6.84 87.731-20.344l-0.091-1.111 1.867-0.443 44.468-153.209z', fill: 'currentColor' })));
62
+ };
63
+ renderMacMetaSymbol = () => {
64
+ return (h("svg", { version: '1.1', xmlns: 'http://www.w3.org/2000/svg', width: '20', height: '20', viewBox: '0 0 512 512', fill: 'none' }, h("title", null, "Mac meta key"), h("path", { d: 'M368,283h-43v-54h43c46.87,0,85-38.13,85-85s-38.13-85-85-85-85,38.13-85,85v43h-54v-43c0-46.87-38.13-85-85-85s-85,38.13-85,85,38.13,85,85,85h43v54h-43c-46.87,0-85,38.13-85,85s38.13,85,85,85,85-38.13,85-85v-43h54v43c0,46.87,38.13,85,85,85s85-38.13,85-85-38.13-85-85-85ZM325,144c0-23.71,19.29-43,43-43s43,19.29,43,43-19.29,43-43,43h-43v-43ZM144,187c-23.71,0-43-19.29-43-43s19.29-43,43-43,43,19.29,43,43v43h-43ZM187,368c0,23.71-19.29,43-43,43s-43-19.29-43-43,19.29-43,43-43h43v43ZM283,283h-54v-54h54v54ZM368,411c-23.71,0-43-19.29-43-43v-43h43c23.71,0,43,19.29,43,43s-19.29,43-43,43Z', fill: 'currentColor' })));
65
+ };
66
+ setHotkeyModifierSymbol() {
67
+ switch (this.hotkeyModifier) {
68
+ case 'ctrl':
69
+ return this.userAgent === 'windows'
70
+ ? this.renderCtrlSymbol()
71
+ : this.renderMacMetaSymbol();
72
+ case 'alt':
73
+ case 'option':
74
+ return this.renderOptionSymbol();
75
+ default:
76
+ return this.userAgent === 'windows'
77
+ ? this.renderWindowsMetaSymbol()
78
+ : this.renderMacMetaSymbol();
79
+ }
80
+ }
81
+ renderSkeuomorphicSlot() {
82
+ return (h("div", { class: 'searchcraft-popover-button-wrapper' }, h("div", { class: 'searchcraft-popover-button-input' }, h("svg", { class: 'searchcraft-popover-button-input-search-icon', viewBox: '0 0 20 20', fill: 'none', xmlns: 'http://www.w3.org/2000/svg', version: '1.1' }, h("title", null, "Search icon"), h("path", { 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' })), h("span", null, "Search")), h("div", { class: 'searchcraft-popover-button-keycaps' }, h("div", { class: 'searchcraft-popover-button-keycaps-keycap searchcraft-popover-button-keycaps-keycap-modifier' }, h("span", null, this.hotkeyModifierSymbol)), h("div", { class: 'searchcraft-popover-button-keycaps-keycap searchcraft-popover-button-keycaps-keycap-key' }, h("span", null, this.hotkey)))));
83
+ }
84
+ renderSlot() {
85
+ switch (this.type) {
86
+ case 'skeuomorphic':
87
+ return this.renderSkeuomorphicSlot();
88
+ default:
89
+ return (h("div", null, h("slot", null)));
90
+ }
91
+ }
12
92
  render() {
13
- return (h("button", { key: 'a8ee70b49a5309cfb1363a272ea0870c48c59688', type: 'button', onClick: this.handleOnClick.bind(this) }, h("slot", { key: '9ac712ed1f6e69d73e7ade3d42501fb67a02c7ff' })));
93
+ return (h("button", { key: 'd24721368deab8e6e9ade770170712f5b8504364', class: `searchcraft-popover-button ${this.type ? ` searchcraft-popover-button-${this.type}` : ''}`, onClick: this.handleOnClick.bind(this), type: 'button' }, typeof this.template !== 'undefined'
94
+ ? this.template(this.isPopoverVisible, { html })
95
+ : this.type
96
+ ? this.renderSlot()
97
+ : 'Open Popover'));
14
98
  }
15
- }, [4, "searchcraft-popover-button"]);
99
+ }, [4, "searchcraft-popover-button", {
100
+ "template": [16],
101
+ "type": [1],
102
+ "hotkey": [32],
103
+ "hotkeyModifier": [32],
104
+ "hotkeyModifierSymbol": [32],
105
+ "isPopoverVisible": [32],
106
+ "userAgent": [32]
107
+ }]);
16
108
  function defineCustomElement$1() {
17
109
  if (typeof customElements === "undefined") {
18
110
  return;
@@ -1 +1 @@
1
- {"file":"searchcraft-popover-button.js","mappings":";;;MAUaA,0BAAwB;;;;;IACnC,aAAa;QACX,gBAAgB,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;KACxD;IAED,MAAM;QACJ,QACE,+DAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,IAC1D,8DAAQ,CACD,EACT;KACH;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftPopoverButton"],"sources":["src/components/searchcraft-popover-button/searchcraft-popover-button.tsx"],"sourcesContent":["import { searchcraftStore } from '@store';\nimport { Component, h } from '@stencil/core';\n\n/**\n * Renders a button which, when clicked, turns on popover visibility.\n */\n@Component({\n tag: 'searchcraft-popover-button',\n shadow: false,\n})\nexport class SearchcraftPopoverButton {\n handleOnClick() {\n searchcraftStore.getState().setPopoverVisibility(true);\n }\n\n render() {\n return (\n <button type='button' onClick={this.handleOnClick.bind(this)}>\n <slot />\n </button>\n );\n }\n}\n"],"version":3}
1
+ {"file":"searchcraft-popover-button.js","mappings":";;;;MAgEaA,0BAAwB;;;;;;;;IAI3B,QAAQ,CAAyB;;;;IAIjC,IAAI,CAAkB;IAErB,MAAM,CAAC;IACP,cAAc,CAAC;IACf,oBAAoB,CAAC;IACrB,gBAAgB,CAAC;IACjB,S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AAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,CAAC;cAC9C,IAAI,CAAC,IAAI;kBACP,IAAI,CAAC,UAAU,EAAE;kBACjB,cAAc,CACb,EACT;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftPopoverButton"],"sources":["src/components/searchcraft-popover-button/searchcraft-popover-button.tsx"],"sourcesContent":["import { Component, h, Prop, State } from '@stencil/core';\n\nimport type { PopoverButtonTemplate } from '@searchcraft/core';\n\nimport { searchcraftStore } from '@store';\n\nimport { html } from '@utils';\n\n/**\n * Renders a button which, when clicked, turns on popover visibility.\n *\n * @react-import\n * ```jsx\n * import { SearchcraftPopoverButton } from \"@searchcraft/react-sdk\";\n * ````\n *\n * @vue-import\n * ```jsx\n * import { SearchcraftPopoverButton } from \"@searchcraft/vue-sdk\";\n * ```\n *\n * @js-example\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-button>\n * Open popover\n * </searchcraft-popover-button>\n * ```\n *\n * ```js\n * // index.js\n * const popoverButton = document.querySelector('searchcraft-popover-button');\n *\n * popoverButton.template = (isPopoverVisible, { html }) => html`\n * <span>Click me</span>\n * `;\n * ```\n *\n * @react-example\n * ```jsx\n * <SearchcraftPopoverButton\n * template={(isPopoverVisible, { html }) => html`\n * <span>Click me</span>\n * `}\n * >\n * Open popover\n * </SearchcraftPopoverButton>\n * ```\n *\n * @vue-example\n * ```jsx\n * <SearchcraftPopoverButton\n * :template={(isPopoverVisible, { html }) => html`\n * <span>Click me</span>\n * `}\n * >\n * Open popover\n * </SearchcraftPopoverButton>\n * ```\n */\n@Component({\n tag: 'searchcraft-popover-button',\n shadow: false,\n})\nexport class SearchcraftPopoverButton {\n /**\n * A callback function responsible for rendering the button contents.\n */\n @Prop() template?: PopoverButtonTemplate;\n /**\n * The type of popover button to render.\n */\n @Prop() type?: 'skeuomorphic';\n\n @State() hotkey;\n @State() hotkeyModifier;\n @State() hotkeyModifierSymbol;\n @State() isPopoverVisible;\n @State() userAgent;\n\n private unsubscribe: () => void = () => {};\n\n handleOnClick() {\n searchcraftStore.getState().setPopoverVisibility(true);\n }\n\n componentDidLoad() {\n const state = searchcraftStore.getState();\n this.hotkey = state.hotkey.toUpperCase();\n this.hotkeyModifier = state.hotkeyModifier;\n this.isPopoverVisible = state.isPopoverVisible;\n this.userAgent = this.setUserAgent();\n this.hotkeyModifierSymbol = this.setHotkeyModifierSymbol();\n\n this.unsubscribe = searchcraftStore.subscribe((state) => {\n this.hotkey = state.hotkey.toUpperCase();\n this.hotkeyModifier = state.hotkeyModifier;\n this.hotkeyModifierSymbol = this.setHotkeyModifierSymbol();\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n }\n\n setUserAgent() {\n const userAgent = navigator.userAgent.toLowerCase();\n\n switch (true) {\n case userAgent.includes('windows'):\n return 'window';\n case userAgent.includes('mac'):\n return 'mac';\n default:\n return 'other';\n }\n }\n\n renderOptionSymbol = () => {\n return (\n <svg\n version='1.1'\n xmlns='http://www.w3.org/2000/svg'\n width='20'\n height='20'\n viewBox='0 0 512 512'\n fill='none'\n >\n <title>Option key</title>\n <path\n d='M283,112c0-11.58,9.42-21,21-21h160c11.58,0,21,9.42,21,21s-9.42,21-21,21h-160c-11.58,0-21-9.42-21-21Z'\n fill='currentColor'\n />\n <path\n d='M485,400c0,11.58-9.42,21-21,21h-128c-8.29,0-15.82-4.9-19.19-12.47l-122.46-275.53H48c-11.58,0-21-9.42-21-21s9.42-21,21-21h160c8.29,0,15.82,4.9,19.19,12.47l122.46,275.53h114.35c11.58,0,21,9.42,21,21Z'\n fill='currentColor'\n />\n </svg>\n );\n };\n\n renderCtrlSymbol = () => {\n return (\n <svg\n version='1.1'\n xmlns='http://www.w3.org/2000/svg'\n width='20'\n height='20'\n viewBox='0 0 512 512'\n fill='none'\n >\n <title>Ctrl key</title>\n <path\n d='M388.95,209.4c-.37,5.59-2.9,10.71-7.12,14.4-3.83,3.35-8.74,5.2-13.82,5.2-6.06,0-11.83-2.61-15.81-7.17l-96.2-109.94-96.2,109.94c-3.98,4.56-9.75,7.17-15.81,7.17-5.08,0-9.99-1.84-13.82-5.2-4.22-3.69-6.75-8.81-7.12-14.4-.38-5.6,1.45-11.01,5.15-15.23l112-128c3.98-4.56,9.74-7.17,15.8-7.17s11.82,2.61,15.8,7.17l112,128c3.7,4.22,5.53,9.63,5.15,15.23Z'\n fill='currentColor'\n />\n </svg>\n );\n };\n\n renderWindowsMetaSymbol = () => {\n return (\n <svg\n version='1.1'\n xmlns='http://www.w3.org/2000/svg'\n width='20'\n height='20'\n viewBox='0 0 512 512'\n fill='none'\n >\n <title>Windows meta key</title>\n <path\n d='M206.115 255.957c-23.854-12.259-47.043-18.479-68.94-18.479-2.978 0-5.976 0.090-8.974 0.354-27.94 2.312-53.461 9.684-69.875 15.414-4.354 1.599-8.817 3.288-13.415 5.153l-44.911 155.697c30.851-11.416 58.146-16.969 83.135-16.969 40.423 0 69.764 15.104 93.996 30.652 11.481-38.959 39.022-133.045 47.241-161.162-5.975-3.642-12.038-7.285-18.257-10.66zM264.174 295.535l-45.223 157.074c13.416 7.686 58.549 32.025 93.106 32.025 27.896 0 59.126-7.148 95.417-21.896l43.178-150.988c-29.316 9.461-57.438 14.26-83.732 14.26-47.975 0-81.557-15.549-102.746-30.475zM146.411 184.395c38.559 0.399 67.076 15.104 90.708 30.251l46.376-158.672c-9.773-5.598-35.403-19.547-53.929-24.3-12.193-2.842-25.010-4.308-38.602-4.308-25.898 0.488-54.194 6.973-86.444 19.9l-44.22 155.298c32.404-12.218 60.322-18.17 86.043-18.17 0.023 0.001 0.068 0.001 0.068 0.001zM512 99.062c-29.407 11.416-58.104 17.233-85.514 17.233-45.843 0-79.646-15.901-101.547-31.183l-45.975 159.118c30.873 19.854 64.145 29.939 99.061 29.939 28.474 0 57.97-6.84 87.731-20.344l-0.091-1.111 1.867-0.443 44.468-153.209z'\n fill='currentColor'\n />\n </svg>\n );\n };\n\n renderMacMetaSymbol = () => {\n return (\n <svg\n version='1.1'\n xmlns='http://www.w3.org/2000/svg'\n width='20'\n height='20'\n viewBox='0 0 512 512'\n fill='none'\n >\n <title>Mac meta key</title>\n <path\n d='M368,283h-43v-54h43c46.87,0,85-38.13,85-85s-38.13-85-85-85-85,38.13-85,85v43h-54v-43c0-46.87-38.13-85-85-85s-85,38.13-85,85,38.13,85,85,85h43v54h-43c-46.87,0-85,38.13-85,85s38.13,85,85,85,85-38.13,85-85v-43h54v43c0,46.87,38.13,85,85,85s85-38.13,85-85-38.13-85-85-85ZM325,144c0-23.71,19.29-43,43-43s43,19.29,43,43-19.29,43-43,43h-43v-43ZM144,187c-23.71,0-43-19.29-43-43s19.29-43,43-43,43,19.29,43,43v43h-43ZM187,368c0,23.71-19.29,43-43,43s-43-19.29-43-43,19.29-43,43-43h43v43ZM283,283h-54v-54h54v54ZM368,411c-23.71,0-43-19.29-43-43v-43h43c23.71,0,43,19.29,43,43s-19.29,43-43,43Z'\n fill='currentColor'\n />\n </svg>\n );\n };\n\n setHotkeyModifierSymbol() {\n switch (this.hotkeyModifier) {\n case 'ctrl':\n return this.userAgent === 'windows'\n ? this.renderCtrlSymbol()\n : this.renderMacMetaSymbol();\n case 'alt':\n case 'option':\n return this.renderOptionSymbol();\n default:\n return this.userAgent === 'windows'\n ? this.renderWindowsMetaSymbol()\n : this.renderMacMetaSymbol();\n }\n }\n\n renderSkeuomorphicSlot() {\n return (\n <div class='searchcraft-popover-button-wrapper'>\n <div class='searchcraft-popover-button-input'>\n <svg\n class='searchcraft-popover-button-input-search-icon'\n viewBox='0 0 20 20'\n fill='none'\n xmlns='http://www.w3.org/2000/svg'\n version='1.1'\n >\n <title>Search icon</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 <span>Search</span>\n </div>\n <div class='searchcraft-popover-button-keycaps'>\n <div class='searchcraft-popover-button-keycaps-keycap searchcraft-popover-button-keycaps-keycap-modifier'>\n <span>{this.hotkeyModifierSymbol}</span>\n </div>\n <div class='searchcraft-popover-button-keycaps-keycap searchcraft-popover-button-keycaps-keycap-key'>\n <span>{this.hotkey}</span>\n </div>\n </div>\n </div>\n );\n }\n\n renderSlot() {\n switch (this.type) {\n case 'skeuomorphic':\n return this.renderSkeuomorphicSlot();\n default:\n return (\n <div>\n <slot />\n </div>\n );\n }\n }\n\n render() {\n return (\n <button\n class={`searchcraft-popover-button ${this.type ? ` searchcraft-popover-button-${this.type}` : ''}`}\n onClick={this.handleOnClick.bind(this)}\n type='button'\n >\n {typeof this.template !== 'undefined'\n ? this.template(this.isPopoverVisible, { html })\n : this.type\n ? this.renderSlot()\n : 'Open Popover'}\n </button>\n );\n }\n}\n"],"version":3}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SearchcraftPopoverFooter extends Components.SearchcraftPopoverFooter, HTMLElement {}
4
+ export const SearchcraftPopoverFooter: {
5
+ prototype: SearchcraftPopoverFooter;
6
+ new (): SearchcraftPopoverFooter;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,8 @@
1
+ import { S as SearchcraftPopoverFooter$1, d as defineCustomElement$1 } from './p-84e2cbd6.js';
2
+
3
+ const SearchcraftPopoverFooter = SearchcraftPopoverFooter$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { SearchcraftPopoverFooter, defineCustomElement };
7
+
8
+ //# sourceMappingURL=searchcraft-popover-footer.js.map
@@ -0,0 +1 @@
1
+ {"file":"searchcraft-popover-footer.js","mappings":";;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}
@@ -1,13 +1,14 @@
1
1
  import { p as proxyCustomElement, H, h } from './p-5365011f.js';
2
2
  import { c as classNames } from './p-5cdc6210.js';
3
- import { s as searchcraftStore } from './p-580c09dc.js';
4
- import { d as defineCustomElement$8 } from './p-5fdaf1e6.js';
5
- import { d as defineCustomElement$7 } from './p-71cc28c1.js';
6
- import { d as defineCustomElement$6 } from './p-0e393fe1.js';
7
- import { d as defineCustomElement$5 } from './p-e41b0f43.js';
8
- import { d as defineCustomElement$4 } from './p-e55a7970.js';
9
- import { d as defineCustomElement$3 } from './p-8f854dec.js';
10
- import { d as defineCustomElement$2 } from './p-60f05735.js';
3
+ import { s as searchcraftStore } from './p-17c646e2.js';
4
+ import { d as defineCustomElement$9 } from './p-13e81b5d.js';
5
+ import { d as defineCustomElement$8 } from './p-acf23bab.js';
6
+ import { d as defineCustomElement$7 } from './p-f2585cdf.js';
7
+ import { d as defineCustomElement$6 } from './p-0077f677.js';
8
+ import { d as defineCustomElement$5 } from './p-1adf78b9.js';
9
+ import { d as defineCustomElement$4 } from './p-84e2cbd6.js';
10
+ import { d as defineCustomElement$3 } from './p-5d17ace0.js';
11
+ import { d as defineCustomElement$2 } from './p-a62a2e74.js';
11
12
 
12
13
  const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftPopoverForm extends H {
13
14
  constructor() {
@@ -16,7 +17,6 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
16
17
  }
17
18
  /**
18
19
  * The type of popover form to render.
19
- *
20
20
  * - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.
21
21
  * - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.
22
22
  * - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.
@@ -69,6 +69,10 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
69
69
  this.searchResultsPage = state.searchResultsPage;
70
70
  this.searchResultsPerPage = state.searchResultsPerPage;
71
71
  });
72
+ // Set hotkey and hotkeyModifier in state.
73
+ searchcraftStore
74
+ .getState()
75
+ .setHotKeyAndHotKeyModifier(this.hotkey, this.hotkeyModifier);
72
76
  }
73
77
  disconnectedCallback() {
74
78
  this.unsubscribe?.();
@@ -114,7 +118,7 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
114
118
  }
115
119
  };
116
120
  handleInputInit = () => {
117
- const input = this.hostElement.querySelector('.searchcraft-input');
121
+ const input = this.hostElement.querySelector('.searchcraft-input-form-input');
118
122
  input?.focus();
119
123
  };
120
124
  /**
@@ -149,7 +153,7 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
149
153
  (event.metaKey && this.hotkeyModifier === 'meta')) {
150
154
  event.preventDefault();
151
155
  if (this.type === 'inline' && !this.isPopoverVisibleInState) {
152
- const hostElementInput = this.hostElement.querySelector('.searchcraft-input');
156
+ const hostElementInput = this.hostElement.querySelector('.searchcraft-input-form-input');
153
157
  hostElementInput?.focus();
154
158
  }
155
159
  else {
@@ -169,7 +173,7 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
169
173
  * @param direction
170
174
  */
171
175
  focusOnNextListItem(direction) {
172
- const listItems = Array.from(document.querySelectorAll('a.searchcraft-popover-list-item')).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);
176
+ const listItems = Array.from(document.querySelectorAll('.searchcraft-popover-list-item-link')).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);
173
177
  const currentIndex = listItems.indexOf(document.activeElement);
174
178
  if (direction === 'ArrowDown') {
175
179
  listItems[(currentIndex + 1) % listItems.length]?.focus();
@@ -179,7 +183,7 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
179
183
  listItems[currentIndex - 1]?.focus();
180
184
  }
181
185
  else {
182
- const input = document.querySelector('.searchcraft-input');
186
+ const input = document.querySelector('.searchcraft-input-form-input');
183
187
  if (input) {
184
188
  input.focus();
185
189
  requestAnimationFrame(() => {
@@ -197,22 +201,22 @@ const SearchcraftPopoverForm$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
197
201
  }
198
202
  renderInlinePopover() {
199
203
  const isListViewVisible = this.hasResultsToShow && this.isFocused;
200
- const popoverFormClassNames = classNames('searchcraft-popover-form searchcraft-popover-form-inline', {
201
- 'searchcraft-popover-form-active': isListViewVisible,
202
- });
203
- return (h("div", { class: popoverFormClassNames }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this) }), isListViewVisible && (h("div", { class: 'searchcraft-popover-inline-wrapper-outer' }, h("div", { class: 'searchcraft-popover-inline-wrapper-inner' }, h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage }))))));
204
+ return (h("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-inline', {
205
+ 'searchcraft-popover-form-active': isListViewVisible,
206
+ }) }, h("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-inline-input' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this) })), isListViewVisible && (h("div", { class: 'searchcraft-popover-form-inline-wrapper' }, h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage }), h("searchcraft-popover-footer", null)))));
204
207
  }
205
208
  renderModalPopover() {
206
209
  if (this.isPopoverVisibleInState) {
207
- const popoverFormClassNames = classNames('searchcraft-popover-form', {
208
- 'searchcraft-popover-form-active': this.hasResultsToShow,
209
- });
210
- return (h("div", { class: 'searchcraft-popover-form-modal' }, h("div", { class: 'searchcraft-popover-form-modal-backdrop', onClick: this.handleModalBackdropClick }), h("div", { class: 'searchcraft-popover-form-modal-inner' }, h("div", { class: popoverFormClassNames }, h("div", { class: 'searchcraft-popover-form-input-wrapper' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this) }), h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage }))))));
210
+ return (h("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-modal', {
211
+ 'searchcraft-popover-form-active': this.hasResultsToShow,
212
+ }) }, h("div", { class: 'searchcraft-popover-form-modal-backdrop', onClick: this.handleModalBackdropClick }), h("div", { class: 'searchcraft-popover-form-modal-wrapper' }, h("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-modal-input' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this) }), h("button", { type: 'button', class: 'searchcraft-popover-form-input-cancel-button searchcraft-popover-form-modal-input-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage })), h("searchcraft-popover-footer", null))));
211
213
  }
212
214
  }
213
215
  renderFullscreenPopover() {
214
216
  if (this.isPopoverVisibleInState) {
215
- return (h("div", { class: 'searchcraft-popover-form-fullscreen' }, h("div", { class: 'searchcraft-popover-form' }, h("div", { class: 'searchcraft-popover-form-input-wrapper' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this) }), h("button", { type: 'button', class: 'searchcraft-popover-form-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage })))));
217
+ return (h("div", { class: classNames('searchcraft-popover-form searchcraft-popover-form-fullscreen', {
218
+ 'searchcraft-popover-form-active': this.hasResultsToShow,
219
+ }) }, h("div", { class: 'searchcraft-popover-form-input searchcraft-popover-form-fullscreen-input' }, h("searchcraft-input-form", { onInputFocus: this.handleInputFocus.bind(this), onInputInit: this.handleInputInit.bind(this) }), h("button", { type: 'button', class: 'searchcraft-popover-form-input-cancel-button searchcraft-popover-form-fullscreen-input-cancel-button', onClick: this.handleCancelButtonClick.bind(this) }, "Cancel")), this.hasResultsToShow && (h("searchcraft-popover-list-view", { popoverResultMappings: this.popoverResultMappings, searchClientResponseItems: this.searchClientResponseItems, adClientResponseItems: this.adClientResponseItems, searchResultsPage: this.searchResultsPage, searchResultsPerPage: this.searchResultsPerPage })), h("searchcraft-popover-footer", null)));
216
220
  }
217
221
  }
218
222
  render() {
@@ -247,7 +251,7 @@ function defineCustomElement$1() {
247
251
  if (typeof customElements === "undefined") {
248
252
  return;
249
253
  }
250
- const components = ["searchcraft-popover-form", "searchcraft-ad", "searchcraft-button", "searchcraft-error-message", "searchcraft-input-form", "searchcraft-input-label", "searchcraft-popover-form", "searchcraft-popover-list-item", "searchcraft-popover-list-view"];
254
+ const components = ["searchcraft-popover-form", "searchcraft-ad", "searchcraft-button", "searchcraft-error-message", "searchcraft-input-form", "searchcraft-input-label", "searchcraft-popover-footer", "searchcraft-popover-form", "searchcraft-popover-list-item", "searchcraft-popover-list-view"];
251
255
  components.forEach(tagName => { switch (tagName) {
252
256
  case "searchcraft-popover-form":
253
257
  if (!customElements.get(tagName)) {
@@ -256,25 +260,30 @@ function defineCustomElement$1() {
256
260
  break;
257
261
  case "searchcraft-ad":
258
262
  if (!customElements.get(tagName)) {
259
- defineCustomElement$8();
263
+ defineCustomElement$9();
260
264
  }
261
265
  break;
262
266
  case "searchcraft-button":
263
267
  if (!customElements.get(tagName)) {
264
- defineCustomElement$7();
268
+ defineCustomElement$8();
265
269
  }
266
270
  break;
267
271
  case "searchcraft-error-message":
268
272
  if (!customElements.get(tagName)) {
269
- defineCustomElement$6();
273
+ defineCustomElement$7();
270
274
  }
271
275
  break;
272
276
  case "searchcraft-input-form":
273
277
  if (!customElements.get(tagName)) {
274
- defineCustomElement$5();
278
+ defineCustomElement$6();
275
279
  }
276
280
  break;
277
281
  case "searchcraft-input-label":
282
+ if (!customElements.get(tagName)) {
283
+ defineCustomElement$5();
284
+ }
285
+ break;
286
+ case "searchcraft-popover-footer":
278
287
  if (!customElements.get(tagName)) {
279
288
  defineCustomElement$4();
280
289
  }
@@ -1 +1 @@
1
- {"file":"searchcraft-popover-form.js","mappings":";;;;;;;;;;;MAsCaA,wBAAsB;;;;;;;;;;;;IAQzB,IAAI,GAAsC,QAAQ,CAAC;;;;IAInD,qBAAqB,CAAyB;;;;IAI9C,MAAM,GAAG,GAAG,CAAC;;;;IAIb,cAAc,GAAuC,MAAM,CAAC;IAE3D,uBAAuB,GAAG,KAAK,CAAC;IAChC,WAAW,CAA2B;IACtC,yBAAyB,GAA+B,EAAE,CAAC;IAC3D,qBAAqB,GAA2B,EAAE,CAAC;IACnD,UAAU,CAAqB;IAC/B,SAAS,GAAG,KAAK,CAAC;IAClB,YAAY,GAAG,GAAG,CAAC;IACnB,YAAY,GAAG,GAAG,CAAC;IACnB,YAAY,GAAG,GAAG,CAAC;IACnB,iBAAiB,CAAC;IAClB,oBAAoB,CAAC;IAErB,YAAY,CAAC;;IAItB,gBAAgB;;QAEd,MAAM,aAAa,GAAG,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACjE,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CACnC,aAAa,CAAC,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V,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACnC,KAAK,YAAY;gBACf,OAAO,IAAI,CAAC,uBAAuB,EAAE,CAAC;SACzC;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftPopoverForm"],"sources":["src/components/searchcraft-popover-form/searchcraft-popover-form.tsx"],"sourcesContent":["import { Component, Element, Prop, State, h } from '@stencil/core';\nimport classNames from 'classnames';\nimport type {\n SearchClientResponseItem,\n AdClientResponseItem,\n PopoverResultMappings,\n} from '@searchcraft/core';\n\nimport { searchcraftStore } from '@store';\n\n/**\n * This web component is designed to display search results in a popover container that dynamically appears when the user interacts with a search input field, or when a popover-button is pressed.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-form type=\"fullscreen\" />\n * ```\n *\n * ```js\n * // index.js\n * const popoverForm = document.querySelector('searchcraft-popover-form');\n *\n * popoverForm.popoverResultMappings = {\n * containerHref: {\n * fieldNames: [\n * {\n * fieldName: 'canonical_link',\n * dataType: 'text',\n * },\n * ],\n * };\n * ```\n */\n@Component({\n tag: 'searchcraft-popover-form',\n shadow: false,\n})\nexport class SearchcraftPopoverForm {\n /**\n * The type of popover form to render.\n *\n * - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.\n * - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.\n * - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.\n */\n @Prop() type: 'inline' | 'fullscreen' | 'modal' = 'inline';\n /**\n * Formats the content rendered for each result.\n */\n @Prop() popoverResultMappings?: PopoverResultMappings;\n /**\n * The hotkey that activates the popover.\n */\n @Prop() hotkey = 'k';\n /**\n * The hotkey modifier that activates the popover. Used together with the `hotkey` prop.\n */\n @Prop() hotkeyModifier: 'ctrl' | 'meta' | 'alt' | 'option' = 'meta';\n\n @State() isPopoverVisibleInState = false;\n @State() unsubscribe: (() => void) | undefined;\n @State() searchClientResponseItems: SearchClientResponseItem[] = [];\n @State() adClientResponseItems: AdClientResponseItem[] = [];\n @State() searchTerm: string | undefined;\n @State() isFocused = false;\n @State() breakpointSm = 576;\n @State() breakpointMd = 768;\n @State() breakpointLg = 992;\n @State() searchResultsPage;\n @State() searchResultsPerPage;\n\n @State() modalElement;\n\n @Element() hostElement!: HTMLElement;\n\n componentDidLoad() {\n // Loads the breakpoint values into state\n const computedStyle = getComputedStyle(document.documentElement);\n this.breakpointSm = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-sm').trim(),\n );\n this.breakpointMd = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-md').trim(),\n );\n this.breakpointLg = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-lg').trim(),\n );\n // Set popover visiblity in state\n this.isPopoverVisibleInState = searchcraftStore.getState().isPopoverVisible;\n\n // Add event listeners\n document.addEventListener('click', this.handleDocumentClick);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n\n // Subscribe to state events\n this.unsubscribe = searchcraftStore.subscribe((state) => {\n if (this.isPopoverVisibleInState !== state.isPopoverVisible) {\n this.handlePopoverVisibilityChange(state.isPopoverVisible);\n }\n\n this.searchClientResponseItems = [...state.searchClientResponseItems];\n this.adClientResponseItems = [...state.adClientResponseItems];\n this.searchTerm = state.searchTerm;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsPerPage = state.searchResultsPerPage;\n });\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n document.removeEventListener('click', this.handleDocumentClick);\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n handleDocumentClick = (event: MouseEvent) => {\n if (!this.hostElement.contains(event.target as Node)) {\n this.isFocused = false;\n }\n };\n\n /**\n * Handles when popover visibility is changed in state\n */\n handlePopoverVisibilityChange(isVisible: boolean) {\n this.isPopoverVisibleInState = isVisible;\n document.body.style.overflow = isVisible ? 'hidden' : 'auto';\n }\n\n /**\n * Actions to perform when various keys are pressed within the popover form.\n */\n handleDocumentKeyDown = (event: KeyboardEvent) => {\n // Document-scoped actions\n if (event.key === this.hotkey) {\n this.handleHotkeyPressed(event);\n }\n\n // Document-scoped -> Popover-scoped keyboard event boundary\n if (!this.hostElement.contains(document.activeElement)) {\n return;\n }\n\n // Popover-scoped actions\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n event.preventDefault();\n this.focusOnNextListItem(event.key);\n break;\n case 'Escape':\n searchcraftStore.getState().setPopoverVisibility(false);\n break;\n default:\n return;\n }\n };\n\n handleInputInit = () => {\n const input = this.hostElement.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n input?.focus();\n };\n\n /**\n * When popover is `inline` and the viewport is at the smallest breakpoint,\n * focusing on the input will open a modal version of the popover form.\n */\n handleInputFocus() {\n this.isFocused = true;\n\n if (\n this.type === 'inline' &&\n window.visualViewport &&\n window.visualViewport.width < this.breakpointSm\n ) {\n searchcraftStore.getState().setPopoverVisibility(true);\n\n // Appends a popover form of type=`modal` to the body\n if (!this.modalElement) {\n this.modalElement = document.createElement('searchcraft-popover-form');\n this.modalElement.popoverResultMappings = this.popoverResultMappings;\n this.modalElement.setAttribute('type', 'fullscreen');\n document.body.appendChild(this.modalElement);\n }\n }\n }\n\n handleModalBackdropClick(_event: MouseEvent) {\n searchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * When a hotkey is pressed, tests if the modifiers also match.\n * If modifiers match, toggles visibility of the popover modal.\n */\n handleHotkeyPressed(event: KeyboardEvent) {\n if (\n (event.ctrlKey && this.hotkeyModifier === 'ctrl') ||\n (event.altKey && this.hotkeyModifier === 'alt') ||\n (event.metaKey && this.hotkeyModifier === 'meta')\n ) {\n event.preventDefault();\n if (this.type === 'inline' && !this.isPopoverVisibleInState) {\n const hostElementInput = this.hostElement.querySelector(\n '.searchcraft-input',\n ) as HTMLInputElement | undefined;\n hostElementInput?.focus();\n } else {\n searchcraftStore\n .getState()\n .setPopoverVisibility(!this.isPopoverVisibleInState);\n }\n }\n }\n\n handleCancelButtonClick() {\n searchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * Moves focus to the next/previous list item in the list view. If you are at the top\n * of the list view, it moves focus back to the input.\n *\n * @param direction\n */\n focusOnNextListItem(direction: 'ArrowDown' | 'ArrowUp') {\n const listItems = Array.from(\n document.querySelectorAll<HTMLAnchorElement>(\n 'a.searchcraft-popover-list-item',\n ),\n ).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);\n\n const currentIndex = listItems.indexOf(\n document.activeElement as HTMLAnchorElement,\n );\n\n if (direction === 'ArrowDown') {\n listItems[(currentIndex + 1) % listItems.length]?.focus();\n } else if (direction === 'ArrowUp') {\n if (currentIndex >= 1) {\n listItems[currentIndex - 1]?.focus();\n } else {\n const input = document.querySelector('.searchcraft-input') as\n | HTMLInputElement\n | undefined;\n\n if (input) {\n input.focus();\n requestAnimationFrame(() => {\n input.selectionEnd = input.value.length;\n input.selectionStart = input.value.length;\n });\n }\n }\n }\n }\n\n get hasResultsToShow() {\n return (\n this.searchTerm &&\n this.searchTerm?.trim()?.length > 0 &&\n this.searchClientResponseItems.length > 0\n );\n }\n\n renderInlinePopover() {\n const isListViewVisible = this.hasResultsToShow && this.isFocused;\n\n const popoverFormClassNames = classNames(\n 'searchcraft-popover-form searchcraft-popover-form-inline',\n {\n 'searchcraft-popover-form-active': isListViewVisible,\n },\n );\n\n return (\n <div class={popoverFormClassNames}>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n />\n {isListViewVisible && (\n <div class='searchcraft-popover-inline-wrapper-outer'>\n <div class='searchcraft-popover-inline-wrapper-inner'>\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n </div>\n </div>\n )}\n </div>\n );\n }\n\n renderModalPopover() {\n if (this.isPopoverVisibleInState) {\n const popoverFormClassNames = classNames('searchcraft-popover-form', {\n 'searchcraft-popover-form-active': this.hasResultsToShow,\n });\n\n return (\n <div class='searchcraft-popover-form-modal'>\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}\n <div\n class='searchcraft-popover-form-modal-backdrop'\n onClick={this.handleModalBackdropClick}\n />\n <div class='searchcraft-popover-form-modal-inner'>\n <div class={popoverFormClassNames}>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n )}\n </div>\n </div>\n </div>\n );\n }\n }\n\n renderFullscreenPopover() {\n if (this.isPopoverVisibleInState) {\n return (\n <div class='searchcraft-popover-form-fullscreen'>\n <div class='searchcraft-popover-form'>\n <div class='searchcraft-popover-form-input-wrapper'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n )}\n </div>\n </div>\n );\n }\n }\n\n render() {\n switch (this.type) {\n case 'inline':\n return this.renderInlinePopover();\n case 'modal':\n return this.renderModalPopover();\n case 'fullscreen':\n return this.renderFullscreenPopover();\n }\n }\n}\n"],"version":3}
1
+ {"file":"searchcraft-popover-form.js","mappings":";;;;;;;;;;;;MAmDaA,wBAAsB;;;;;;;;;;;IAOzB,IAAI,GAAuC,QAAQ,CAAC;;;;IAIpD,qBAAqB,CAAyB;;;;IAI9C,MAAM,GAAY,GAAG,CAAC;;;;IAItB,cAAc,GAAwC,MAAM,CAAC;IAE5D,uBAAuB,GAAG,KAAK,CAAC;IAChC,WAAW,CAA2B;IACtC,yBAAyB,GAA+B,EAAE,CAAC;IAC3D,qBAAqB,GAA2B,EAAE,CAAC;IACnD,UAAU,CAAqB;IAC/B,SAAS,GAAG,KAAK,CAAC;IAClB,YAAY,GAAG,GAAG,CAAC;IACnB,YAAY,GAAG,GAAG,CAAC;IACnB,YAAY,GAAG,GAAG,CAAC;IACnB,iBAAiB,CAAC;IAClB,oBAAoB,CAAC;IAErB,YAAY,CAAC;;IAItB,gBAAgB;;QAEd,MAAM,aAAa,GAAG,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QACjE,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CACnC,aAAa,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,IAAI,EAAE,CAC5D,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CACnC,aAAa,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,IAAI,EAAE,CAC5D,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CACnC,aAAa,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,IAAI,EAAE,CAC5D,CAAC;;QAEF,IAAI,CAAC,uBAAuB,GAAG,gBAAgB,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC;;QAG5E,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC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AE;YAChC,QACE,WACE,KAAK,EAAE,UAAU,CACf,8DAA8D,EAC9D;oBACE,iCAAiC,EAAE,IAAI,CAAC,gBAAgB;iBACzD,CACF,IAED,WAAK,KAAK,EAAC,0EAA0E,IACnF,8BACE,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAC9C,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAC5C,EACF,cACE,IAAI,EAAC,QAAQ,EACb,KAAK,EAAC,sGAAsG,EAC5G,OAAO,EAAE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,aAGzC,CACL,EACL,IAAI,CAAC,gBAAgB,KACpB,qCACE,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,EACjD,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,EACzD,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,EACjD,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EACzC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,GAC/C,CACH,EACD,qCAA8B,CAC1B,EACN;SACH;KACF;IAED,MAAM;QACJ,QAAQ,IAAI,CAAC,IAAI;YACf,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACpC,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACnC,KAAK,YAAY;gBACf,OAAO,IAAI,CAAC,uBAAuB,EAAE,CAAC;SACzC;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftPopoverForm"],"sources":["src/components/searchcraft-popover-form/searchcraft-popover-form.tsx"],"sourcesContent":["import { Component, Element, Prop, State, h } from '@stencil/core';\nimport classNames from 'classnames';\nimport type {\n SearchClientResponseItem,\n AdClientResponseItem,\n PopoverResultMappings,\n} from '@searchcraft/core';\n\nimport { searchcraftStore } from '@store';\n\n/**\n * This web component is designed to display search results in a popover container that dynamically appears when the user interacts with a search input field, or when a popover-button is pressed.\n *\n * @react-import\n * ```jsx\n * import { SearchcraftPopoverForm } from \"@searchcraft/react-sdk\";\n * ```\n *\n * @vue-import\n * ```jsx\n * import { SearchcraftPopoverForm } from \"@searchcraft/vue-sdk\";\n * ```\n *\n * @js-example\n * ```html\n * <!-- index.html -->\n * <searchcraft-popover-form type=\"inline\" />\n * ```\n *\n * ```js\n * // index.js\n * const popoverForm = document.querySelector('searchcraft-popover-form');\n *\n * popoverForm.popoverResultMappings = {};\n * ```\n *\n * @react-example\n * ```jsx\n * <SearchcraftPopoverForm type=\"inline\" popoverResultMappings={[]} />\n * ```\n *\n * @vue-example\n * ```jsx\n * <SearchcraftPopoverForm type=\"inline\" :popoverResultMappings=\"[]\"\" />\n * ```\n *\n */\n@Component({\n tag: 'searchcraft-popover-form',\n shadow: false,\n})\nexport class SearchcraftPopoverForm {\n /**\n * The type of popover form to render.\n * - `inline` - Renders inline with the rest of the content on the page. The search results pop over the page content.\n * - `fullscreen` - Renders in fullscreen view. Used together with the `searchcraft-popover-button` component.\n * - `modal` - Renders in a modal view. Used together with the `searchcraft-popover-button` component.\n */\n @Prop() type?: 'inline' | 'fullscreen' | 'modal' = 'inline';\n /**\n * Formats the content rendered for each result.\n */\n @Prop() popoverResultMappings?: PopoverResultMappings;\n /**\n * The hotkey that activates the popover.\n */\n @Prop() hotkey?: string = 'k';\n /**\n * The hotkey modifier that activates the popover. Used together with the `hotkey` prop.\n */\n @Prop() hotkeyModifier?: 'ctrl' | 'meta' | 'alt' | 'option' = 'meta';\n\n @State() isPopoverVisibleInState = false;\n @State() unsubscribe: (() => void) | undefined;\n @State() searchClientResponseItems: SearchClientResponseItem[] = [];\n @State() adClientResponseItems: AdClientResponseItem[] = [];\n @State() searchTerm: string | undefined;\n @State() isFocused = false;\n @State() breakpointSm = 576;\n @State() breakpointMd = 768;\n @State() breakpointLg = 992;\n @State() searchResultsPage;\n @State() searchResultsPerPage;\n\n @State() modalElement;\n\n @Element() hostElement!: HTMLElement;\n\n componentDidLoad() {\n // Loads the breakpoint values into state\n const computedStyle = getComputedStyle(document.documentElement);\n this.breakpointSm = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-sm').trim(),\n );\n this.breakpointMd = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-md').trim(),\n );\n this.breakpointLg = Number.parseFloat(\n computedStyle.getPropertyValue('--sc-breakpoint-lg').trim(),\n );\n // Set popover visiblity in state\n this.isPopoverVisibleInState = searchcraftStore.getState().isPopoverVisible;\n\n // Add event listeners\n document.addEventListener('click', this.handleDocumentClick);\n document.addEventListener('keydown', this.handleDocumentKeyDown);\n\n // Subscribe to state events\n this.unsubscribe = searchcraftStore.subscribe((state) => {\n if (this.isPopoverVisibleInState !== state.isPopoverVisible) {\n this.handlePopoverVisibilityChange(state.isPopoverVisible);\n }\n\n this.searchClientResponseItems = [...state.searchClientResponseItems];\n this.adClientResponseItems = [...state.adClientResponseItems];\n this.searchTerm = state.searchTerm;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsPerPage = state.searchResultsPerPage;\n });\n\n // Set hotkey and hotkeyModifier in state.\n searchcraftStore\n .getState()\n .setHotKeyAndHotKeyModifier(this.hotkey, this.hotkeyModifier);\n }\n\n disconnectedCallback() {\n this.unsubscribe?.();\n document.removeEventListener('click', this.handleDocumentClick);\n document.removeEventListener('keydown', this.handleDocumentKeyDown);\n }\n\n handleDocumentClick = (event: MouseEvent) => {\n if (!this.hostElement.contains(event.target as Node)) {\n this.isFocused = false;\n }\n };\n\n /**\n * Handles when popover visibility is changed in state\n */\n handlePopoverVisibilityChange(isVisible: boolean) {\n this.isPopoverVisibleInState = isVisible;\n document.body.style.overflow = isVisible ? 'hidden' : 'auto';\n }\n\n /**\n * Actions to perform when various keys are pressed within the popover form.\n */\n handleDocumentKeyDown = (event: KeyboardEvent) => {\n // Document-scoped actions\n if (event.key === this.hotkey) {\n this.handleHotkeyPressed(event);\n }\n\n // Document-scoped -> Popover-scoped keyboard event boundary\n if (!this.hostElement.contains(document.activeElement)) {\n return;\n }\n\n // Popover-scoped actions\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n event.preventDefault();\n this.focusOnNextListItem(event.key);\n break;\n case 'Escape':\n searchcraftStore.getState().setPopoverVisibility(false);\n break;\n default:\n return;\n }\n };\n\n handleInputInit = () => {\n const input = this.hostElement.querySelector(\n '.searchcraft-input-form-input',\n ) as HTMLInputElement | undefined;\n input?.focus();\n };\n\n /**\n * When popover is `inline` and the viewport is at the smallest breakpoint,\n * focusing on the input will open a modal version of the popover form.\n */\n handleInputFocus() {\n this.isFocused = true;\n\n if (\n this.type === 'inline' &&\n window.visualViewport &&\n window.visualViewport.width < this.breakpointSm\n ) {\n searchcraftStore.getState().setPopoverVisibility(true);\n\n // Appends a popover form of type=`modal` to the body\n if (!this.modalElement) {\n this.modalElement = document.createElement('searchcraft-popover-form');\n this.modalElement.popoverResultMappings = this.popoverResultMappings;\n this.modalElement.setAttribute('type', 'fullscreen');\n document.body.appendChild(this.modalElement);\n }\n }\n }\n\n handleModalBackdropClick(_event: MouseEvent) {\n searchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * When a hotkey is pressed, tests if the modifiers also match.\n * If modifiers match, toggles visibility of the popover modal.\n */\n handleHotkeyPressed(event: KeyboardEvent) {\n if (\n (event.ctrlKey && this.hotkeyModifier === 'ctrl') ||\n (event.altKey && this.hotkeyModifier === 'alt') ||\n (event.metaKey && this.hotkeyModifier === 'meta')\n ) {\n event.preventDefault();\n if (this.type === 'inline' && !this.isPopoverVisibleInState) {\n const hostElementInput = this.hostElement.querySelector(\n '.searchcraft-input-form-input',\n ) as HTMLInputElement | undefined;\n hostElementInput?.focus();\n } else {\n searchcraftStore\n .getState()\n .setPopoverVisibility(!this.isPopoverVisibleInState);\n }\n }\n }\n\n handleCancelButtonClick() {\n searchcraftStore.getState().setPopoverVisibility(false);\n }\n\n /**\n * Moves focus to the next/previous list item in the list view. If you are at the top\n * of the list view, it moves focus back to the input.\n *\n * @param direction\n */\n focusOnNextListItem(direction: 'ArrowDown' | 'ArrowUp') {\n const listItems = Array.from(\n document.querySelectorAll<HTMLAnchorElement>(\n '.searchcraft-popover-list-item-link',\n ),\n ).filter((el) => !el.hasAttribute('disabled') && el.offsetParent !== null);\n\n const currentIndex = listItems.indexOf(\n document.activeElement as HTMLAnchorElement,\n );\n\n if (direction === 'ArrowDown') {\n listItems[(currentIndex + 1) % listItems.length]?.focus();\n } else if (direction === 'ArrowUp') {\n if (currentIndex >= 1) {\n listItems[currentIndex - 1]?.focus();\n } else {\n const input = document.querySelector('.searchcraft-input-form-input') as\n | HTMLInputElement\n | undefined;\n\n if (input) {\n input.focus();\n requestAnimationFrame(() => {\n input.selectionEnd = input.value.length;\n input.selectionStart = input.value.length;\n });\n }\n }\n }\n }\n\n get hasResultsToShow() {\n return (\n this.searchTerm &&\n this.searchTerm?.trim()?.length > 0 &&\n this.searchClientResponseItems.length > 0\n );\n }\n\n renderInlinePopover() {\n const isListViewVisible = this.hasResultsToShow && this.isFocused;\n\n return (\n <div\n class={classNames(\n 'searchcraft-popover-form searchcraft-popover-form-inline',\n {\n 'searchcraft-popover-form-active': isListViewVisible,\n },\n )}\n >\n <div class='searchcraft-popover-form-input searchcraft-popover-form-inline-input'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n />\n </div>\n {isListViewVisible && (\n <div class='searchcraft-popover-form-inline-wrapper'>\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n <searchcraft-popover-footer />\n </div>\n )}\n </div>\n );\n }\n\n renderModalPopover() {\n if (this.isPopoverVisibleInState) {\n return (\n <div\n class={classNames(\n 'searchcraft-popover-form searchcraft-popover-form-modal',\n {\n 'searchcraft-popover-form-active': this.hasResultsToShow,\n },\n )}\n >\n {/* biome-ignore lint/a11y/useKeyWithClickEvents: <explanation> */}\n <div\n class='searchcraft-popover-form-modal-backdrop'\n onClick={this.handleModalBackdropClick}\n />\n <div class='searchcraft-popover-form-modal-wrapper'>\n <div class='searchcraft-popover-form-input searchcraft-popover-form-modal-input'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-input-cancel-button searchcraft-popover-form-modal-input-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n )}\n <searchcraft-popover-footer />\n </div>\n </div>\n );\n }\n }\n\n renderFullscreenPopover() {\n if (this.isPopoverVisibleInState) {\n return (\n <div\n class={classNames(\n 'searchcraft-popover-form searchcraft-popover-form-fullscreen',\n {\n 'searchcraft-popover-form-active': this.hasResultsToShow,\n },\n )}\n >\n <div class='searchcraft-popover-form-input searchcraft-popover-form-fullscreen-input'>\n <searchcraft-input-form\n onInputFocus={this.handleInputFocus.bind(this)}\n onInputInit={this.handleInputInit.bind(this)}\n />\n <button\n type='button'\n class='searchcraft-popover-form-input-cancel-button searchcraft-popover-form-fullscreen-input-cancel-button'\n onClick={this.handleCancelButtonClick.bind(this)}\n >\n Cancel\n </button>\n </div>\n {this.hasResultsToShow && (\n <searchcraft-popover-list-view\n popoverResultMappings={this.popoverResultMappings}\n searchClientResponseItems={this.searchClientResponseItems}\n adClientResponseItems={this.adClientResponseItems}\n searchResultsPage={this.searchResultsPage}\n searchResultsPerPage={this.searchResultsPerPage}\n />\n )}\n <searchcraft-popover-footer />\n </div>\n );\n }\n }\n\n render() {\n switch (this.type) {\n case 'inline':\n return this.renderInlinePopover();\n case 'modal':\n return this.renderModalPopover();\n case 'fullscreen':\n return this.renderFullscreenPopover();\n }\n }\n}\n"],"version":3}
@@ -1,4 +1,4 @@
1
- import { S as SearchcraftPopoverListItem$1, d as defineCustomElement$1 } from './p-8f854dec.js';
1
+ import { S as SearchcraftPopoverListItem$1, d as defineCustomElement$1 } from './p-5d17ace0.js';
2
2
 
3
3
  const SearchcraftPopoverListItem = SearchcraftPopoverListItem$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,4 +1,4 @@
1
- import { S as SearchcraftPopoverListView$1, d as defineCustomElement$1 } from './p-60f05735.js';
1
+ import { S as SearchcraftPopoverListView$1, d as defineCustomElement$1 } from './p-a62a2e74.js';
2
2
 
3
3
  const SearchcraftPopoverListView = SearchcraftPopoverListView$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,8 +1,7 @@
1
1
  import { p as proxyCustomElement, H, h } from './p-5365011f.js';
2
- import { c as classNames } from './p-5cdc6210.js';
3
- import { s as searchcraftStore } from './p-580c09dc.js';
2
+ import { s as searchcraftStore } from './p-17c646e2.js';
4
3
  import { f as formatNumberWithCommas } from './p-6104fe5d.js';
5
- import { p as parseCustomStyles } from './p-d9551738.js';
4
+ import { h as html } from './p-810a7850.js';
6
5
 
7
6
  const SearchcraftResultsInfo$1 = /*@__PURE__*/ proxyCustomElement(class SearchcraftResultsInfo extends H {
8
7
  constructor() {
@@ -10,19 +9,9 @@ const SearchcraftResultsInfo$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
10
9
  this.__registerHost();
11
10
  }
12
11
  /**
13
- * The custom formatter for the resulting string.
14
- *
15
- * @example
16
- * ```ts
17
- * resultsInfo.customFormatter = (range, count, responseTime) =>
18
- * `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;
19
- * ```
12
+ * A callback function responsible for rendering the results info.
20
13
  */
21
- customFormatter;
22
- /**
23
- * The custom styles object.
24
- */
25
- customStyles;
14
+ template;
26
15
  // store vars
27
16
  searchTerm;
28
17
  searchResultsPage;
@@ -63,16 +52,16 @@ const SearchcraftResultsInfo$1 = /*@__PURE__*/ proxyCustomElement(class Searchcr
63
52
  if (!this.searchTerm || this.searchResultsCount === 0) {
64
53
  return null;
65
54
  }
66
- return (h("p", { class: classNames('searchcraft-results-info', parseCustomStyles(this.customStyles || {})) }, this.customFormatter
67
- ? this.customFormatter([
68
- formatNumberWithCommas(this.range[0]),
69
- formatNumberWithCommas(this.range[1]),
70
- ], formatNumberWithCommas(this.count), this.responseTime)
71
- : `${this.count} results found in ${this.responseTime}ms`));
55
+ return (h("p", { class: 'searchcraft-results-info' }, typeof this.template !== 'undefined'
56
+ ? this.template({
57
+ range: [Number(this.range[0]), Number(this.range[1])],
58
+ count: this.count,
59
+ responseTime: this.responseTime,
60
+ }, { html })
61
+ : `${formatNumberWithCommas(this.count)} results found in ${this.responseTime}ms`));
72
62
  }
73
63
  }, [0, "searchcraft-results-info", {
74
- "customFormatter": [16],
75
- "customStyles": [1, "custom-styles"],
64
+ "template": [16],
76
65
  "searchTerm": [32],
77
66
  "searchResultsPage": [32],
78
67
  "searchResultsPerPage": [32],
@@ -1 +1 @@
1
- {"file":"searchcraft-results-info.js","mappings":";;;;;;MA0BaA,wBAAsB;;;;;;;;;;;;;;IAUzB,eAAe,CAIb;;;;IAIF,YAAY,CAAU;;IAGrB,UAAU,CAAC;IACX,iBAAiB,CAAC;IAClB,oBAAoB,CAAC;IACrB,kBAAkB,CAAC;;IAGnB,KAAK,GAAG,CAAC,CAAC;IACV,KAAK,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzB,YAAY,GAAG,GAAG,CAAC;IAE5B,WAAW,GAAe,SAAQ,CAAC;IAEnC,iBAAiB;QACf,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,KA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,IAAI,CAAC,eAAe;cACjB,IAAI,CAAC,eAAe,CAClB;gBACE,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACrC,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACtC,EACD,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,EAClC,IAAI,CAAC,YAAY,CAClB;cACD,GAAG,IAAI,CAAC,KAAK,qBAAqB,IAAI,CAAC,YAAY,IAAI,CACzD,EACJ;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftResultsInfo"],"sources":["src/components/searchcraft-results-info/searchcraft-results-info.tsx"],"sourcesContent":["import { Component, h, State, Prop } from '@stencil/core';\nimport classNames from 'classnames';\n\nimport { searchcraftStore } from '@store';\n\nimport { formatNumberWithCommas, parseCustomStyles } from '@utils';\n\n/**\n * This web component is designed to display the number of results returned from a search query.\n *\n * ## Usage\n * ```html\n * <!-- index.html -->\n * <script>\n * const resultsInfo = document.querySelector('searchcraft-results-info');\n * resultsInfo.customFormatter = (range, count, responseTime) =>\n * `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;\n * </script>\n *\n * <searchcraft-results-info />\n * ```\n */\n@Component({\n tag: 'searchcraft-results-info',\n shadow: false,\n})\nexport class SearchcraftResultsInfo {\n /**\n * The custom formatter for the resulting string.\n *\n * @example\n * ```ts\n * resultsInfo.customFormatter = (range, count, responseTime) =>\n * `${range[0]}-${range[1]} of ${count} results in ${responseTime}ms`;\n * ```\n */\n @Prop() customFormatter?: (\n range: [string, string],\n count: string,\n responseTime: string,\n ) => void;\n /**\n * The custom styles object.\n */\n @Prop() customStyles?: string;\n\n // store vars\n @State() searchTerm;\n @State() searchResultsPage;\n @State() searchResultsPerPage;\n @State() searchResultsCount;\n\n // local vars\n @State() count = 0;\n @State() range: number[] = [0, 0];\n @State() responseTime = '0';\n\n unsubscribe: () => void = () => {};\n\n connectedCallback() {\n this.unsubscribe = searchcraftStore.subscribe((state) => {\n // store vars\n this.searchTerm = state.searchTerm;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsPerPage = state.searchResultsPerPage;\n this.searchResultsCount = state.searchResultsCount;\n\n // local vars\n this.count = this.searchResultsCount;\n this.range[0] =\n this.searchResultsPage <= 1\n ? 1\n : this.searchResultsPerPage * (this.searchResultsPage - 1);\n this.range[1] = this.searchResultsPerPage * this.searchResultsPage;\n this.range[1] =\n this.range[1] > this.searchResultsCount\n ? this.searchResultsCount\n : this.range[1];\n this.responseTime = ((state.searchResponseTimeTaken || 0) * 1000).toFixed(\n 2,\n );\n });\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n render() {\n if (!this.searchTerm || this.searchResultsCount === 0) {\n return null;\n }\n\n return (\n <p\n class={classNames(\n 'searchcraft-results-info',\n parseCustomStyles(this.customStyles || {}),\n )}\n >\n {this.customFormatter\n ? this.customFormatter(\n [\n formatNumberWithCommas(this.range[0]),\n formatNumberWithCommas(this.range[1]),\n ],\n formatNumberWithCommas(this.count),\n this.responseTime,\n )\n : `${this.count} results found in ${this.responseTime}ms`}\n </p>\n );\n }\n}\n"],"version":3}
1
+ {"file":"searchcraft-results-info.js","mappings":";;;;;MA0DaA,wBAAsB;;;;;;;;IAIzB,QAAQ,CAAuB;;IAG9B,UAAU,CAAC;IACX,iBAAiB,CAAC;IAClB,oBAAoB,CAAC;IACrB,kBAAkB,CAAC;;IAGnB,KAAK,GAAG,CAAC,CAAC;IACV,KAAK,GAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACzB,YAAY,GAAG,GAAG,CAAC;IAE5B,WAAW,GAAe,SAAQ,CAAC;IAEnC,iBAAiB;QACf,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,KAAK;;YAElD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;YACnC,IAAI,CAAC,iBAAiB,GAAG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IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACrD,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,YAAY,EAAE,IAAI,CAAC,YAAY;aAChC,EACD,EAAE,IAAI,EAAE,CACT;cACD,GAAG,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,YAAY,IAAI,CACjF,EACJ;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["SearchcraftResultsInfo"],"sources":["src/components/searchcraft-results-info/searchcraft-results-info.tsx"],"sourcesContent":["import { Component, h, State, Prop } from '@stencil/core';\n\nimport type { ResultsInfoTemplate } from '@searchcraft/core';\n\nimport { searchcraftStore } from '@store';\n\nimport { formatNumberWithCommas, html } from '@utils';\n\n/**\n * This web component is designed to display the number of results returned from a search query.\n *\n * @react-import\n * ```jsx\n * import { SearchcraftResultsInfo } from \"@searchcraft/react-sdk\";\n * ```\n *\n * @vue-import\n * ```jsx\n * import { SearchcraftResultsInfo } from \"@searchcraft/vue-sdk\";\n * ```\n *\n * @js-example\n * ```html\n * <!-- index.html -->\n * <searchcraft-results-info />\n * ```\n *\n * ```js\n * // index.js\n * const resultsInfo = document.querySelector('searchcraft-results-info');\n *\n * resultsInfo.template = (info, { html }) => html`\n * ${info.range[0]}-${info.range[1]} of ${info.count} results in ${info.responseTime}ms\n * `;\n * ```\n *\n * @react-example\n * ```jsx\n * <SearchcraftResultsInfo\n * template={(info, { html }) => html`\n * ${info.range[0]}-${info.range[1]} of ${info.count} results in ${info.responseTime}ms\n * `}\n * />\n * ```\n *\n * @vue-example\n * ```jsx\n * <SearchcraftResultsInfo\n * :template={(info, { html }) => html`\n * ${info.range[0]}-${info.range[1]} of ${info.count} results in ${info.responseTime}ms\n * `}\n * />\n * ```\n */\n@Component({\n tag: 'searchcraft-results-info',\n shadow: false,\n})\nexport class SearchcraftResultsInfo {\n /**\n * A callback function responsible for rendering the results info.\n */\n @Prop() template?: ResultsInfoTemplate;\n\n // store vars\n @State() searchTerm;\n @State() searchResultsPage;\n @State() searchResultsPerPage;\n @State() searchResultsCount;\n\n // local vars\n @State() count = 0;\n @State() range: number[] = [0, 0];\n @State() responseTime = '0';\n\n unsubscribe: () => void = () => {};\n\n connectedCallback() {\n this.unsubscribe = searchcraftStore.subscribe((state) => {\n // store vars\n this.searchTerm = state.searchTerm;\n this.searchResultsPage = state.searchResultsPage;\n this.searchResultsPerPage = state.searchResultsPerPage;\n this.searchResultsCount = state.searchResultsCount;\n\n // local vars\n this.count = this.searchResultsCount;\n this.range[0] =\n this.searchResultsPage <= 1\n ? 1\n : this.searchResultsPerPage * (this.searchResultsPage - 1);\n this.range[1] = this.searchResultsPerPage * this.searchResultsPage;\n this.range[1] =\n this.range[1] > this.searchResultsCount\n ? this.searchResultsCount\n : this.range[1];\n this.responseTime = ((state.searchResponseTimeTaken || 0) * 1000).toFixed(\n 2,\n );\n });\n }\n\n disconnectedCallback() {\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n }\n\n render() {\n if (!this.searchTerm || this.searchResultsCount === 0) {\n return null;\n }\n\n return (\n <p class='searchcraft-results-info'>\n {typeof this.template !== 'undefined'\n ? this.template(\n {\n range: [Number(this.range[0]), Number(this.range[1])],\n count: this.count,\n responseTime: this.responseTime,\n },\n { html },\n )\n : `${formatNumberWithCommas(this.count)} results found in ${this.responseTime}ms`}\n </p>\n );\n }\n}\n"],"version":3}
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SearchcraftSearchResult extends Components.SearchcraftSearchResult, HTMLElement {}
4
+ export const SearchcraftSearchResult: {
5
+ prototype: SearchcraftSearchResult;
6
+ new (): SearchcraftSearchResult;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,8 @@
1
+ import { S as SearchcraftSearchResult$1, d as defineCustomElement$1 } from './p-172a848d.js';
2
+
3
+ const SearchcraftSearchResult = SearchcraftSearchResult$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { SearchcraftSearchResult, defineCustomElement };
7
+
8
+ //# sourceMappingURL=searchcraft-search-result.js.map
@@ -0,0 +1 @@
1
+ {"file":"searchcraft-search-result.js","mappings":";;;;;;;","names":[],"sources":[],"sourcesContent":[],"version":3}