@carbon/ibmdotcom-web-components 1.32.0-rc.0 → 1.32.0-rc.2

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 (152) hide show
  1. package/custom-elements.json +18 -18
  2. package/dist/{20-2c34f739.js → 20-4d0d088b.js} +1 -1
  3. package/dist/{20-002a62f9.js → 20-c7872d45.js} +1 -1
  4. package/dist/{20-e53335d3.js → 20-d0071628.js} +1 -1
  5. package/dist/{20-4f726b86.js → 20-f07ed7a1.js} +1 -1
  6. package/dist/cloud-masthead.js +2 -2
  7. package/dist/cloud-masthead.min.js +1 -1
  8. package/dist/cloud-masthead.rtl.js +2 -2
  9. package/dist/cloud-masthead.rtl.min.js +1 -1
  10. package/dist/dotcom-shell.js +2 -2
  11. package/dist/dotcom-shell.min.js +1 -1
  12. package/dist/dotcom-shell.rtl.js +2 -2
  13. package/dist/dotcom-shell.rtl.min.js +1 -1
  14. package/dist/ibmdotcom-web-components-dotcom-shell.js +9 -7
  15. package/dist/ibmdotcom-web-components-dotcom-shell.min.js +2 -2
  16. package/dist/ibmdotcom-web-components-dotcom-shell.rtl.js +9 -7
  17. package/dist/ibmdotcom-web-components-dotcom-shell.rtl.min.js +2 -2
  18. package/dist/{left-nav-menu-72142ae5.js → left-nav-menu-0454e7fe.js} +1 -1
  19. package/dist/{left-nav-menu-136466dc.js → left-nav-menu-4bb5d738.js} +1 -1
  20. package/dist/{left-nav-menu-d0e0c8a1.js → left-nav-menu-a9193172.js} +1 -1
  21. package/dist/{left-nav-menu-3436909a.js → left-nav-menu-aa14d1fd.js} +1 -1
  22. package/dist/{left-nav-menu-category-heading-71bd687e.js → left-nav-menu-category-heading-308b7583.js} +1 -1
  23. package/dist/{left-nav-menu-category-heading-b2b5a65f.js → left-nav-menu-category-heading-c9962ac5.js} +1 -1
  24. package/dist/{left-nav-menu-category-heading-2a3e1e8f.js → left-nav-menu-category-heading-daf5ebfa.js} +1 -1
  25. package/dist/{left-nav-menu-category-heading-17849a08.js → left-nav-menu-category-heading-fc02a361.js} +1 -1
  26. package/dist/{left-nav-menu-item-19e02851.js → left-nav-menu-item-0275a3b9.js} +1 -1
  27. package/dist/{left-nav-menu-item-8caa4256.js → left-nav-menu-item-354f4261.js} +1 -1
  28. package/dist/{left-nav-menu-item-ee78e342.js → left-nav-menu-item-7814505a.js} +1 -1
  29. package/dist/{left-nav-menu-item-327fee2b.js → left-nav-menu-item-fa33cbd9.js} +1 -1
  30. package/dist/{left-nav-menu-section-5f999435.js → left-nav-menu-section-5c2e24f8.js} +2 -2
  31. package/dist/{left-nav-menu-section-518e5d37.js → left-nav-menu-section-94e4e49c.js} +1 -1
  32. package/dist/{left-nav-menu-section-e0a8964a.js → left-nav-menu-section-b5303d97.js} +2 -2
  33. package/dist/{left-nav-menu-section-6150369f.js → left-nav-menu-section-fcd88473.js} +1 -1
  34. package/dist/{left-nav-overlay-5731f7e5.js → left-nav-overlay-1e1910e9.js} +1 -1
  35. package/dist/{left-nav-overlay-6882d48d.js → left-nav-overlay-320c1270.js} +1 -1
  36. package/dist/{left-nav-overlay-a4cc3b3e.js → left-nav-overlay-81eb5e93.js} +1 -1
  37. package/dist/{left-nav-overlay-de7eb950.js → left-nav-overlay-ce49183f.js} +1 -1
  38. package/dist/{masthead-composite-c8dbcd61.js → masthead-composite-10b5102f.js} +3 -3
  39. package/dist/{masthead-composite-306adeb9.js → masthead-composite-1ed7f190.js} +3 -3
  40. package/dist/{masthead-composite-fb2bb203.js → masthead-composite-4096f117.js} +18 -14
  41. package/dist/{masthead-composite-73d938e4.js → masthead-composite-e578b925.js} +18 -14
  42. package/dist/{megamenu-category-group-43899a46.js → megamenu-category-group-0042c754.js} +1 -1
  43. package/dist/{megamenu-category-group-3bf5d73c.js → megamenu-category-group-b777facf.js} +1 -1
  44. package/dist/{megamenu-category-group-copy-2b87813d.js → megamenu-category-group-copy-69e90843.js} +1 -1
  45. package/dist/{megamenu-category-group-copy-283a25a3.js → megamenu-category-group-copy-6cc797f8.js} +1 -1
  46. package/dist/{megamenu-category-group-copy-93aa0a96.js → megamenu-category-group-copy-83e643e1.js} +1 -1
  47. package/dist/{megamenu-category-group-copy-775aaa80.js → megamenu-category-group-copy-e60dfb61.js} +1 -1
  48. package/dist/{megamenu-category-group-79513624.js → megamenu-category-group-d474b15d.js} +1 -1
  49. package/dist/{megamenu-category-group-999cba46.js → megamenu-category-group-f7dba932.js} +1 -1
  50. package/dist/{megamenu-category-link-71bd2020.js → megamenu-category-link-0df4440e.js} +1 -1
  51. package/dist/{megamenu-category-link-dbc8b4a4.js → megamenu-category-link-54e1011f.js} +1 -1
  52. package/dist/{megamenu-category-link-fb99f944.js → megamenu-category-link-68b5ea65.js} +1 -1
  53. package/dist/{megamenu-category-link-e3280b1e.js → megamenu-category-link-84732d66.js} +1 -1
  54. package/dist/{megamenu-left-navigation-3b9086ee.js → megamenu-left-navigation-7c8616c7.js} +1 -1
  55. package/dist/{megamenu-left-navigation-1f60ff1b.js → megamenu-left-navigation-862becf2.js} +1 -1
  56. package/dist/{megamenu-left-navigation-dd0372b5.js → megamenu-left-navigation-98f428cf.js} +1 -1
  57. package/dist/{megamenu-left-navigation-35bcade1.js → megamenu-left-navigation-c5ed7f0e.js} +1 -1
  58. package/dist/{megamenu-overlay-50af9c22.js → megamenu-overlay-213de889.js} +1 -1
  59. package/dist/{megamenu-overlay-2b2fe43c.js → megamenu-overlay-3ad6b0b2.js} +1 -1
  60. package/dist/{megamenu-overlay-5ff8fbf2.js → megamenu-overlay-ab9a9cff.js} +1 -1
  61. package/dist/{megamenu-overlay-ddd5122f.js → megamenu-overlay-d948063a.js} +1 -1
  62. package/es/components/image/image.d.ts +0 -3
  63. package/es/components/image/image.d.ts.map +1 -1
  64. package/es/components/image/image.js +1 -1
  65. package/es/components/image/image.js.map +1 -1
  66. package/es/components/locale-modal/locale-modal.d.ts.map +1 -1
  67. package/es/components/locale-modal/locale-modal.js +7 -5
  68. package/es/components/locale-modal/locale-modal.js.map +1 -1
  69. package/es/components/masthead/masthead-composite.d.ts +1 -1
  70. package/es/components/masthead/masthead-composite.d.ts.map +1 -1
  71. package/es/components/masthead/masthead-composite.js +4 -3
  72. package/es/components/masthead/masthead-composite.js.map +1 -1
  73. package/es/components/notice-choice/notice-choice.d.ts.map +1 -1
  74. package/es/components/notice-choice/notice-choice.js +0 -1
  75. package/es/components/notice-choice/notice-choice.js.map +1 -1
  76. package/es/components/search-with-typeahead/search-with-typeahead.d.ts.map +1 -1
  77. package/es/components/search-with-typeahead/search-with-typeahead.js +4 -1
  78. package/es/components/search-with-typeahead/search-with-typeahead.js.map +1 -1
  79. package/es/components/table-of-contents/table-of-contents.d.ts +12 -7
  80. package/es/components/table-of-contents/table-of-contents.d.ts.map +1 -1
  81. package/es/components/table-of-contents/table-of-contents.js +13 -2
  82. package/es/components/table-of-contents/table-of-contents.js.map +1 -1
  83. package/es/components/video-player/video-player.d.ts +1 -9
  84. package/es/components/video-player/video-player.d.ts.map +1 -1
  85. package/es/components/video-player/video-player.js +7 -2
  86. package/es/components/video-player/video-player.js.map +1 -1
  87. package/es/components-react/footer/dropdown.js +39 -0
  88. package/es/components-react/masthead/masthead-composite.d.ts +1 -1
  89. package/es/components-react/masthead/masthead-composite.js +241 -0
  90. package/es/components-react/masthead/masthead-container.js +25 -0
  91. package/es/components-react/masthead/masthead.js +23 -0
  92. package/es/components-react/quote/quote-link-with-icon.js +25 -0
  93. package/es/components-react/quote/quote-source-bottom-copy.js +30 -0
  94. package/es/components-react/quote/quote-source-copy.js +30 -0
  95. package/es/components-react/quote/quote-source-heading.js +30 -0
  96. package/es/components-react/search-with-typeahead/scoped-search-dropdown-mobile.js +32 -0
  97. package/es/components-react/search-with-typeahead/scoped-search-dropdown.js +39 -0
  98. package/es/components-react/search-with-typeahead/search-with-typeahead-item.js +47 -0
  99. package/es/components-react/search-with-typeahead/search-with-typeahead.js +175 -0
  100. package/es/components-react/structured-list/structured-list-body.js +23 -0
  101. package/es/components-react/structured-list/structured-list-cell.js +41 -0
  102. package/es/components-react/structured-list/structured-list-group.js +29 -0
  103. package/es/components-react/structured-list/structured-list-head.js +23 -0
  104. package/es/components-react/structured-list/structured-list-header-cell.js +23 -0
  105. package/es/components-react/structured-list/structured-list-header-row.js +23 -0
  106. package/es/components-react/structured-list/structured-list-row.js +23 -0
  107. package/es/components-react/structured-list/structured-list.js +23 -0
  108. package/es/components-react/table-of-contents/table-of-contents.js +49 -0
  109. package/es/components-react/tabs-extended/tab.js +53 -0
  110. package/es/components-react/tabs-extended/tabs-extended.js +36 -0
  111. package/es/components-react/tabs-extended-media/tabs-extended-media.js +34 -0
  112. package/es/components-react/tag-group/tag-group.js +23 -0
  113. package/es/components-react/tag-link/tag-link.js +57 -0
  114. package/es/components-react/universal-banner/universal-banner-copy.js +29 -0
  115. package/es/components-react/universal-banner/universal-banner-heading.js +30 -0
  116. package/es/components-react/universal-banner/universal-banner-image.js +25 -0
  117. package/es/components-react/universal-banner/universal-banner.js +57 -0
  118. package/es/components-react/video-player/video-player.js +134 -0
  119. package/lib/components-react-node/footer/dropdown.js +80 -0
  120. package/lib/components-react-node/masthead/masthead-composite.js +295 -0
  121. package/lib/components-react-node/masthead/masthead-container.js +41 -0
  122. package/lib/components-react-node/masthead/masthead.js +40 -0
  123. package/lib/components-react-node/quote/quote-link-with-icon.js +41 -0
  124. package/lib/components-react-node/quote/quote-source-bottom-copy.js +47 -0
  125. package/lib/components-react-node/quote/quote-source-copy.js +47 -0
  126. package/lib/components-react-node/quote/quote-source-heading.js +47 -0
  127. package/lib/components-react-node/search-with-typeahead/scoped-search-dropdown-mobile.js +49 -0
  128. package/lib/components-react-node/search-with-typeahead/scoped-search-dropdown.js +68 -0
  129. package/lib/components-react-node/search-with-typeahead/search-with-typeahead-item.js +102 -0
  130. package/lib/components-react-node/search-with-typeahead/search-with-typeahead.js +230 -0
  131. package/lib/components-react-node/structured-list/structured-list-body.js +40 -0
  132. package/lib/components-react-node/structured-list/structured-list-cell.js +58 -0
  133. package/lib/components-react-node/structured-list/structured-list-group.js +46 -0
  134. package/lib/components-react-node/structured-list/structured-list-head.js +40 -0
  135. package/lib/components-react-node/structured-list/structured-list-header-cell.js +40 -0
  136. package/lib/components-react-node/structured-list/structured-list-header-row.js +40 -0
  137. package/lib/components-react-node/structured-list/structured-list-row.js +40 -0
  138. package/lib/components-react-node/structured-list/structured-list.js +40 -0
  139. package/lib/components-react-node/table-of-contents/table-of-contents.js +104 -0
  140. package/lib/components-react-node/tabs-extended/tab.js +108 -0
  141. package/lib/components-react-node/tabs-extended/tabs-extended.js +53 -0
  142. package/lib/components-react-node/tabs-extended-media/tabs-extended-media.js +50 -0
  143. package/lib/components-react-node/tag-group/tag-group.js +40 -0
  144. package/lib/components-react-node/tag-link/tag-link.js +74 -0
  145. package/lib/components-react-node/universal-banner/universal-banner-copy.js +45 -0
  146. package/lib/components-react-node/universal-banner/universal-banner-heading.js +47 -0
  147. package/lib/components-react-node/universal-banner/universal-banner-image.js +41 -0
  148. package/lib/components-react-node/universal-banner/universal-banner.js +112 -0
  149. package/lib/components-react-node/video-player/video-player.js +197 -0
  150. package/package.json +7 -7
  151. package/scss/components/image/image.scss +1 -1
  152. package/es/components-react/notice-choice/notice-choice.d.ts +0 -48
@@ -1 +1 @@
1
- {"version":3,"sources":["components/notice-choice/notice-choice.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAQ,UAAU,EAAY,MAAM,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBzD;;;;;;;GAOG;AACH,cACM,YAAa,SAAQ,iBAA+B;IACxD;;OAEG;IAEH,eAAe,SAAO;IAGtB,OAAO,SAAQ;IAGf,KAAK,SAAM;IAGX,MAAM,SAAW;IAGjB,kBAAkB,uCAAU;IAG5B,aAAa,uCAAU;IAGvB,cAAc,MAAC;IAGf,aAAa,KAAM;IAGnB,KAAK,SAAM;IAGX,UAAU,KAAM;IAGhB,MAAM,EAAE,GAAG,CAAC;IAGZ,OAAO,UAAS;IAGhB,WAAW,SAAM;IAGjB,YAAY,KAAM;IAElB;;OAEG;IAEH;;OAEG;IAEH,OAAO,uCAAU;IAGjB,cAAc,uCAAU;IAGxB,MAAM;;;;;;;MAOJ;IAEF,iBAAiB;IAUjB,iBAAiB;IAkBjB,oBAAoB;IAuBpB,mBAAmB;IAsBnB,cAAc,CAAC,MAAM,KAAA;IAuBrB;;;;;OAKG;IACH,wBAAwB,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,MAAM,KAAA;IAkE7C,OAAO,CAAC,cAAc;IAYtB,MAAM,KAAK,cAAc,WAExB;IACD,MAAM,CAAC,MAAM,MAAU;IACvB,gBAAgB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA;IAoBlC,gBAAgB;IAmFhB,gBAAgB;IAOhB,MAAM;IAsBN,SAAS,CAAC,YAAY,CAAC,KAAK,KAAA;IAqB5B,SAAS,CAAC,oBAAoB,iDAyB5B;IACF,SAAS,CAAC,gBAAgB,CAAC,YAAY,EAAE,GAAG;IAoC5C,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAoB9C;AAED,eAAe,YAAY,CAAC","file":"notice-choice.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2020, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { checkPreferencesv3, loadContent } from './services';\nimport { html, LitElement, property } from 'lit-element';\nimport {\n emailRegExp,\n getMappedValue,\n getNcContentFromWindow,\n pwsValueMap,\n resetToWorldWideContent,\n} from './utils';\n\nimport countrySettings from './country-settings';\nimport ddsSettings from '../../internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings';\nimport settings from 'carbon-components/es/globals/js/settings';\nimport StableSelectorMixin from '../../globals/mixins/stable-selector';\nimport styles from './notice-choice.scss';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html';\nimport { worldWideContent } from './world-wide-content';\nimport { carbonElement as customElement } from '../../internal/vendor/@carbon/web-components/globals/decorators/carbon-element';\n\nconst { stablePrefix: ddsPrefix } = ddsSettings;\nconst { prefix } = settings;\n\n/**\n * Notice Choice\n *\n * @element dds-notice-choice\n * @fires dds-notice-choice-change\n * The custom event fired when default choice loaded or user change some preferences.\n * The field and value should be taken from the detail object and send it to MRS.\n */\n@customElement(`dds-notice-choice`)\nclass NoticeChoice extends StableSelectorMixin(LitElement) {\n /**\n * properties for passed attributes.\n */\n @property({ type: String, reflect: true, attribute: 'question-choices' })\n questionchoices = '1';\n\n @property({ type: String, attribute: 'country' })\n country = 'US';\n\n @property({ type: String, attribute: 'state' })\n state = '';\n\n @property({ type: String, attribute: 'locale' })\n locale = 'us-en';\n\n @property({ type: String, attribute: 'terms-condition-link' })\n termsConditionLink = html``;\n\n @property({ type: String, attribute: 'bpid-legal-text' })\n bpidLegalText = html``;\n\n @property({ type: Boolean, attribute: 'enable-all-opt-in' })\n enableAllOptIn;\n\n @property({ attribute: 'default-values' })\n defaultValues = {};\n\n @property({ type: String, attribute: 'email' })\n email = '';\n\n @property({ type: Object, attribute: false })\n checkboxes = {};\n\n @property({ type: Object, attribute: false })\n ncData: any;\n\n @property({ type: Boolean, attribute: false })\n changed = false;\n\n @property({ type: String, attribute: false })\n fetchedPref = '';\n\n @property({ type: Object, attribute: false })\n optInContent = {};\n\n /**\n * End properties for passed attributes.\n */\n\n /**\n * properties for local state state management.\n */\n @property({ type: html, attribute: false })\n preText = html``;\n\n @property({ type: html, attribute: false })\n defaultPreText = html``;\n\n @property({ type: Object, attribute: false })\n values = {\n EMAIL: false,\n PHONE: false,\n POSTAL: false,\n NC_HIDDEN_EMAIL: worldWideContent.cc_default_status,\n NC_HIDDEN_PHONE: worldWideContent.cc_default_status,\n NC_HIDDEN_POSTAL: worldWideContent.cc_default_status,\n };\n\n prepareCheckboxes() {\n if (this.ncData) {\n const OptInContent = this.ncData.OptInContent;\n this.preText = OptInContent.preText;\n this.defaultPreText = OptInContent.preText;\n const newCheckboxes = this._buildCheckboxes(OptInContent);\n this.checkboxes = newCheckboxes;\n this.performUpdate();\n }\n }\n connectedCallback() {\n super.connectedCallback();\n const { cc, lc } = getMappedValue(this.locale);\n loadContent(\n cc,\n lc,\n (ncData) => {\n this.ncData = ncData;\n this.prepareCheckboxes();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n if (this.country && this.country !== cc) {\n this.countryChanged(this.country);\n }\n }\n setDefaultSelections() {\n if (!this.enableAllOptIn && this.checkboxes) {\n const newValues = { ...this.values };\n Object.keys(this.checkboxes).forEach((key) => {\n const optInContent = this.optInContent || this.ncData.OptInContent;\n const option = this._getOptionByQuestion(key, optInContent);\n newValues[key] = !!(\n option.checked === 'true' || option.checked === true\n );\n if (\n this.defaultValues &&\n Object.prototype.hasOwnProperty.call(this.defaultValues, key)\n ) {\n newValues[key] = this.defaultValues[key];\n }\n const hiddenFieldName = `NC_HIDDEN_${key}`;\n this._onChange(hiddenFieldName, newValues[key] ? 'OPT_IN' : null);\n });\n if (JSON.stringify(this.values) !== JSON.stringify(newValues)) {\n this.values = newValues;\n }\n }\n }\n countryChangeAction() {\n const splitValue = this.locale.split('-', 2);\n const ncData = getNcContentFromWindow();\n if (splitValue[1] === 'en') {\n let preText = this.defaultPreText;\n if (ncData.OtherPreferences.englishNoticeText !== '') {\n preText = ncData.OtherPreferences.englishNoticeText;\n }\n this.preText = preText;\n }\n /**\n * @description if the user already interacted with the checkboxes,\n * skip country default selection.\n */\n if (!this.changed && !this.fetchedPref) {\n /**\n * @description\n * change checkbox checked option based on new country.\n */\n this.setDefaultSelections();\n }\n }\n countryChanged(newVal) {\n const cc = newVal.toLocaleLowerCase();\n const lc = countrySettings[newVal.toLocaleLowerCase()].lang;\n resetToWorldWideContent();\n loadContent(\n cc,\n lc,\n (ncData) => {\n /**\n * @description Do not change content language.\n * Change the checkbox according to the country rule.\n */\n this.optInContent = {\n ...ncData.OptInContent,\n cclc: `${worldWideContent.cc_name}-${worldWideContent.cc_lang}`,\n };\n this.countryChangeAction();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n }\n /**\n *\n * @param name name of the attribute\n * @param oldVal old value of the attribute\n * @param newVal new value of the attrbute\n */\n attributeChangedCallback(name, oldVal, newVal) {\n const hasValue = newVal !== null && oldVal !== null;\n super.attributeChangedCallback(name, oldVal, newVal);\n switch (name) {\n case 'question-choices': {\n // Reload checkbox options when questionchoices changed\n if (oldVal !== newVal) {\n this.prepareCheckboxes();\n this.setDefaultSelections();\n }\n break;\n }\n case 'locale': {\n // load content when locale changed.\n if (hasValue && oldVal !== newVal) {\n const { cc, lc } = getMappedValue(newVal);\n loadContent(\n cc,\n lc,\n (ncData) => {\n this.ncData = ncData;\n this.prepareCheckboxes();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n }\n break;\n }\n case 'country': {\n /**\n * load content when country value changed.\n */\n if (\n hasValue &&\n oldVal !== newVal &&\n countrySettings[newVal.toLocaleLowerCase()]\n ) {\n this.countryChanged(newVal);\n }\n break;\n }\n case 'enable-all-opt-in':\n this.setDefaultSelections();\n break;\n case 'email': {\n if (newVal) {\n if (newVal !== this.fetchedPref) {\n // Handle throttle using debounce approach.\n if (emailRegExp.test(newVal)) {\n setTimeout(() => {\n this.emailChanged(newVal);\n }, 1000);\n }\n }\n } else {\n if (this.fetchedPref) {\n this.fetchedPref = newVal;\n }\n }\n break;\n }\n }\n }\n\n private checkBoxChange($event: any) {\n const id = $event.target.id;\n const checked = $event.target.checked;\n const newValues = {\n ...this.values,\n };\n newValues[id] = !!checked;\n this.values = newValues;\n this.changed = true;\n const hiddenFieldName = `NC_HIDDEN_${id}`;\n this._onChange(hiddenFieldName, checked ? 'PERMISSION' : 'SUPPRESSION');\n }\n static get stableSelector() {\n return `${ddsPrefix}--notice-choice`;\n }\n static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader\n checkBoxTemplate(checkbox, checked) {\n return html`<span>\n <div class=\"${prefix}--form-item bx--checkbox-wrapper\">\n <input\n type=\"checkbox\"\n class=\"${prefix}--checkbox\"\n id=\"${checkbox.id}\"\n name=\"${checkbox.id}\"\n ?checked=${checked}\n @change=\"${this.checkBoxChange}\" />\n <label\n for=\"${checkbox.id}\"\n class=\"${prefix}--checkbox-label ${prefix}--nc__checkbox-${checkbox.id}\"\n ><span class=\"${prefix}--checkbox-label-text\" dir=\"auto\"\n >${checkbox.labelText}\n </span>\n </label>\n </div>\n </span>`;\n }\n postTextTemplate() {\n if (this.ncData) {\n const OptInContent = this.ncData.OptInContent;\n const OtherPreferences = this.ncData.OtherPreferences;\n let postText = OptInContent.postText;\n let tcHtml = '';\n if (this.termsConditionLink) {\n let originalValue = OtherPreferences.trailPrivacyText;\n const matchedValue = originalValue.match(/<tc>.*<\\/tc>/g);\n if (matchedValue) {\n const anrTagHtml = matchedValue[0].replace(/<tc>|<\\/tc>/g, '');\n const link = `<a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' >${anrTagHtml}</a>`;\n const reg = new RegExp('<tc>' + anrTagHtml + '</tc>', 'g');\n tcHtml = `<p>I accept the product <a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' >${anrTagHtml}</a> of this registration form.</p>`;\n postText = originalValue.replace(reg, link);\n }\n }\n // replace default privacy link\n try {\n const { cc, lc } = getMappedValue(this.locale);\n postText = postText.replaceAll(\n 'www.ibm.com/privacy/zz/en/',\n `www.ibm.com/${cc}-${lc}/privacy`\n );\n } catch (e) {\n console.log('unable to replace privacy link locale code.');\n }\n const ccLcObject = getMappedValue(this.locale);\n const cc = ccLcObject.cc;\n const lc = ccLcObject.lc;\n const ccpa =\n this.country === 'US' && (this.state === 'CA' || this.state === '');\n if (this.country === 'CN' && lc === 'en') {\n return html`<p class=\"nc-gdpr-info\">\n I agree and acknowledge that IBM may share my personal information\n with IBM affiliates and third parties globally. I understand that I\n can withdraw my marketing consent at any time by submitting an\n <a\n href=\"https://www.ibm.com/account/reg/${cc}-${lc}/signup?formid=urx-42537\"\n target=\"_blank\"\n >opt-out request</a\n >, and also may unsubscribe from receiving marketing emails by\n clicking the unsubscribe link in each email. More information in\n IBM’s use and processing of personal information can be found in the\n <a href=\"https://www.ibm.com/privacy\" target=\"_blank\"\n >IBM Privacy Statement</a\n >.\n </p>\n\n <p class=\"nc-gdpr-ack\">\n By ticking the above boxes and submitting this form, I have read and\n understand the above notice and IBM Privacy Statement.\n </p>\n ${unsafeHTML(tcHtml)}`;\n } else if (lc === 'en' && ccpa) {\n return html`<p class=\"nc-gdpr-info\">\n You can withdraw your marketing consent at any time by submitting an\n <a\n href=\"https://www.ibm.com/account/reg/us-en/signup?formid=urx-42537\"\n target=\"_blank\"\n >opt-out request</a\n >. Also you may unsubscribe from receiving marketing emails by\n clicking the unsubscribe link in each email.\n </p>\n <p class=\"nc-gdpr-ack\">\n More information on our processing can be found in the\n <a href=\"https://www.ibm.com/privacy\" target=\"_blank\"\n >IBM Privacy Statement.</a\n >\n California residents, review\n <a href=\"https://www.ibm.com/privacy/ccpa\" target=\"_blank\"\n >our notice and your privacy choices</a\n >. <br />\n By submitting this form, I acknowledge that I have read and\n understand the IBM Privacy Statement.\n </p>\n ${unsafeHTML(tcHtml)}`;\n }\n return html`${unsafeHTML(postText)}`;\n } else {\n return html``;\n }\n }\n getBpidLegalText() {\n if (this.bpidLegalText) {\n return html`<p>${this.bpidLegalText}</p>`;\n } else {\n return ``;\n }\n }\n render() {\n return html`<section class=\"${prefix}--nc\">\n <p id=\"ncHeading\" class=\"${ddsPrefix}--nc__pre-text\">${unsafeHTML(\n this.preText\n )}</p>\n <div class=\"${prefix}--checkbox-group\">\n ${\n this.checkboxes &&\n Object.keys(this.checkboxes).length > 0 &&\n Object.keys(this.checkboxes).map((key) => {\n const checked = this.values[key];\n const checkbox = this.checkboxes[key];\n return this.checkBoxTemplate(checkbox, checked);\n })\n }\n </div>\n <div class=\"${prefix}--nc__post-text\"\n >${this.postTextTemplate()}</div>\n </div>\n ${this.getBpidLegalText()}\n </section>`;\n }\n protected emailChanged(email) {\n if (this.changed === false) {\n checkPreferencesv3(email).then((response) => {\n if (\n response === 'S' &&\n JSON.stringify(this.values) !==\n JSON.stringify({\n ...this.values,\n EMAIL: false,\n })\n ) {\n this.fetchedPref = email;\n this.values = {\n ...this.values,\n EMAIL: false,\n };\n this._onChange('NC_HIDDEN_EMAIL', null);\n }\n });\n }\n }\n protected _getOptionByQuestion = (question, OptInContentValue) => {\n let OptInContent = OptInContentValue;\n if (!OptInContent) {\n OptInContent = this.ncData.OptInContent;\n }\n let option;\n switch (question) {\n case 'EMAIL': {\n option = OptInContent.fourQuestionApp[0];\n break;\n }\n case 'PHONE': {\n option = OptInContent.fourQuestionApp[1];\n break;\n }\n case 'POSTAL': {\n option = OptInContent.fourQuestionApp[2];\n break;\n }\n default: {\n option = OptInContent.fourQuestionApp[0];\n break;\n }\n }\n return option;\n };\n protected _buildCheckboxes(OptInContent: any) {\n const fieldElements: any = {};\n const fieldCollections = {\n EMAIL: {\n id: 'EMAIL',\n labelText: this._getOptionByQuestion('EMAIL', OptInContent)\n .optionTextPost,\n },\n PHONE: {\n id: 'PHONE',\n labelText: this._getOptionByQuestion('PHONE', OptInContent)\n .optionTextPost,\n },\n POSTAL: {\n id: 'POSTAL',\n labelText: this._getOptionByQuestion('POSTAL', OptInContent)\n .optionTextPost,\n },\n };\n if (this.questionchoices) {\n // by email\n if (this.questionchoices.indexOf('1') > -1) {\n fieldElements.EMAIL = fieldCollections.EMAIL;\n }\n // by Phone\n if (this.questionchoices.indexOf('2') > -1) {\n fieldElements.PHONE = fieldCollections.PHONE;\n }\n // by Postal mail\n if (this.questionchoices.indexOf('3') > -1) {\n fieldElements.POSTAL = fieldCollections.POSTAL;\n }\n }\n return fieldElements;\n }\n\n _onChange(field: string, value: string | null) {\n const pwsFieldsMap = {\n NC_HIDDEN_EMAIL: 'permission_email',\n NC_HIDDEN_PHONE: 'permission_phone',\n NC_HIDDEN_POSTAL: 'permission_postal',\n };\n if (Object.prototype.hasOwnProperty.call(pwsFieldsMap, field)) {\n field = pwsFieldsMap[field];\n }\n const init = {\n bubbles: true,\n detail: {\n field,\n value: pwsValueMap(value),\n },\n };\n this.dispatchEvent(\n new CustomEvent(`${ddsPrefix}-notice-choice-change`, init)\n );\n }\n}\n/* @__GENERATE_REACT_CUSTOM_ELEMENT_TYPE__ */\nexport default NoticeChoice;\n"]}
1
+ {"version":3,"sources":["components/notice-choice/notice-choice.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAQ,UAAU,EAAY,MAAM,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBzD;;;;;;;GAOG;AACH,cACM,YAAa,SAAQ,iBAA+B;IACxD;;OAEG;IAEH,eAAe,SAAO;IAGtB,OAAO,SAAQ;IAGf,KAAK,SAAM;IAGX,MAAM,SAAW;IAGjB,kBAAkB,uCAAU;IAG5B,aAAa,uCAAU;IAGvB,cAAc,MAAC;IAGf,aAAa,KAAM;IAGnB,KAAK,SAAM;IAGX,UAAU,KAAM;IAGhB,MAAM,EAAE,GAAG,CAAC;IAGZ,OAAO,UAAS;IAGhB,WAAW,SAAM;IAGjB,YAAY,KAAM;IAElB;;OAEG;IAEH;;OAEG;IAEH,OAAO,uCAAU;IAGjB,cAAc,uCAAU;IAGxB,MAAM;;;;;;;MAOJ;IAEF,iBAAiB;IAUjB,iBAAiB;IAkBjB,oBAAoB;IAuBpB,mBAAmB;IAsBnB,cAAc,CAAC,MAAM,KAAA;IAuBrB;;;;;OAKG;IACH,wBAAwB,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,MAAM,KAAA;IAkE7C,OAAO,CAAC,cAAc;IAYtB,MAAM,KAAK,cAAc,WAExB;IACD,MAAM,CAAC,MAAM,MAAU;IACvB,gBAAgB,CAAC,QAAQ,KAAA,EAAE,OAAO,KAAA;IAoBlC,gBAAgB;IAmFhB,gBAAgB;IAOhB,MAAM;IAsBN,SAAS,CAAC,YAAY,CAAC,KAAK,KAAA;IAqB5B,SAAS,CAAC,oBAAoB,iDAyB5B;IACF,SAAS,CAAC,gBAAgB,CAAC,YAAY,EAAE,GAAG;IAoC5C,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAoB9C;AAED,eAAe,YAAY,CAAC","file":"notice-choice.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2020, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { checkPreferencesv3, loadContent } from './services';\nimport { html, LitElement, property } from 'lit-element';\nimport {\n emailRegExp,\n getMappedValue,\n getNcContentFromWindow,\n pwsValueMap,\n resetToWorldWideContent,\n} from './utils';\n\nimport countrySettings from './country-settings';\nimport ddsSettings from '../../internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings';\nimport settings from 'carbon-components/es/globals/js/settings';\nimport StableSelectorMixin from '../../globals/mixins/stable-selector';\nimport styles from './notice-choice.scss';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html';\nimport { worldWideContent } from './world-wide-content';\nimport { carbonElement as customElement } from '../../internal/vendor/@carbon/web-components/globals/decorators/carbon-element';\n\nconst { stablePrefix: ddsPrefix } = ddsSettings;\nconst { prefix } = settings;\n\n/**\n * Notice Choice\n *\n * @element dds-notice-choice\n * @fires dds-notice-choice-change\n * The custom event fired when default choice loaded or user change some preferences.\n * The field and value should be taken from the detail object and send it to MRS.\n */\n@customElement(`dds-notice-choice`)\nclass NoticeChoice extends StableSelectorMixin(LitElement) {\n /**\n * properties for passed attributes.\n */\n @property({ type: String, reflect: true, attribute: 'question-choices' })\n questionchoices = '1';\n\n @property({ type: String, attribute: 'country' })\n country = 'US';\n\n @property({ type: String, attribute: 'state' })\n state = '';\n\n @property({ type: String, attribute: 'locale' })\n locale = 'us-en';\n\n @property({ type: String, attribute: 'terms-condition-link' })\n termsConditionLink = html``;\n\n @property({ type: String, attribute: 'bpid-legal-text' })\n bpidLegalText = html``;\n\n @property({ type: Boolean, attribute: 'enable-all-opt-in' })\n enableAllOptIn;\n\n @property({ attribute: 'default-values' })\n defaultValues = {};\n\n @property({ type: String, attribute: 'email' })\n email = '';\n\n @property({ type: Object, attribute: false })\n checkboxes = {};\n\n @property({ type: Object, attribute: false })\n ncData: any;\n\n @property({ type: Boolean, attribute: false })\n changed = false;\n\n @property({ type: String, attribute: false })\n fetchedPref = '';\n\n @property({ type: Object, attribute: false })\n optInContent = {};\n\n /**\n * End properties for passed attributes.\n */\n\n /**\n * properties for local state state management.\n */\n @property({ type: html, attribute: false })\n preText = html``;\n\n @property({ type: html, attribute: false })\n defaultPreText = html``;\n\n @property({ type: Object, attribute: false })\n values = {\n EMAIL: false,\n PHONE: false,\n POSTAL: false,\n NC_HIDDEN_EMAIL: worldWideContent.cc_default_status,\n NC_HIDDEN_PHONE: worldWideContent.cc_default_status,\n NC_HIDDEN_POSTAL: worldWideContent.cc_default_status,\n };\n\n prepareCheckboxes() {\n if (this.ncData) {\n const OptInContent = this.ncData.OptInContent;\n this.preText = OptInContent.preText;\n this.defaultPreText = OptInContent.preText;\n const newCheckboxes = this._buildCheckboxes(OptInContent);\n this.checkboxes = newCheckboxes;\n this.performUpdate();\n }\n }\n connectedCallback() {\n super.connectedCallback();\n const { cc, lc } = getMappedValue(this.locale);\n loadContent(\n cc,\n lc,\n (ncData) => {\n this.ncData = ncData;\n this.prepareCheckboxes();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n if (this.country && this.country !== cc) {\n this.countryChanged(this.country);\n }\n }\n setDefaultSelections() {\n if (!this.enableAllOptIn && this.checkboxes) {\n const newValues = { ...this.values };\n Object.keys(this.checkboxes).forEach((key) => {\n const optInContent = this.optInContent || this.ncData.OptInContent;\n const option = this._getOptionByQuestion(key, optInContent);\n newValues[key] = !!(\n option.checked === 'true' || option.checked === true\n );\n if (\n this.defaultValues &&\n Object.prototype.hasOwnProperty.call(this.defaultValues, key)\n ) {\n newValues[key] = this.defaultValues[key];\n }\n const hiddenFieldName = `NC_HIDDEN_${key}`;\n this._onChange(hiddenFieldName, newValues[key] ? 'OPT_IN' : null);\n });\n if (JSON.stringify(this.values) !== JSON.stringify(newValues)) {\n this.values = newValues;\n }\n }\n }\n countryChangeAction() {\n const splitValue = this.locale.split('-', 2);\n const ncData = getNcContentFromWindow();\n if (splitValue[1] === 'en') {\n let preText = this.defaultPreText;\n if (ncData.OtherPreferences.englishNoticeText !== '') {\n preText = ncData.OtherPreferences.englishNoticeText;\n }\n this.preText = preText;\n }\n /**\n * @description if the user already interacted with the checkboxes,\n * skip country default selection.\n */\n if (!this.changed && !this.fetchedPref) {\n /**\n * @description\n * change checkbox checked option based on new country.\n */\n this.setDefaultSelections();\n }\n }\n countryChanged(newVal) {\n const cc = newVal.toLocaleLowerCase();\n const lc = countrySettings[newVal.toLocaleLowerCase()].lang;\n resetToWorldWideContent();\n loadContent(\n cc,\n lc,\n (ncData) => {\n /**\n * @description Do not change content language.\n * Change the checkbox according to the country rule.\n */\n this.optInContent = {\n ...ncData.OptInContent,\n cclc: `${worldWideContent.cc_name}-${worldWideContent.cc_lang}`,\n };\n this.countryChangeAction();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n }\n /**\n *\n * @param name name of the attribute\n * @param oldVal old value of the attribute\n * @param newVal new value of the attrbute\n */\n attributeChangedCallback(name, oldVal, newVal) {\n const hasValue = newVal !== null && oldVal !== null;\n super.attributeChangedCallback(name, oldVal, newVal);\n switch (name) {\n case 'question-choices': {\n // Reload checkbox options when questionchoices changed\n if (oldVal !== newVal) {\n this.prepareCheckboxes();\n this.setDefaultSelections();\n }\n break;\n }\n case 'locale': {\n // load content when locale changed.\n if (hasValue && oldVal !== newVal) {\n const { cc, lc } = getMappedValue(newVal);\n loadContent(\n cc,\n lc,\n (ncData) => {\n this.ncData = ncData;\n this.prepareCheckboxes();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n }\n break;\n }\n case 'country': {\n /**\n * load content when country value changed.\n */\n if (\n hasValue &&\n oldVal !== newVal &&\n countrySettings[newVal.toLocaleLowerCase()]\n ) {\n this.countryChanged(newVal);\n }\n break;\n }\n case 'enable-all-opt-in':\n this.setDefaultSelections();\n break;\n case 'email': {\n if (newVal) {\n if (newVal !== this.fetchedPref) {\n // Handle throttle using debounce approach.\n if (emailRegExp.test(newVal)) {\n setTimeout(() => {\n this.emailChanged(newVal);\n }, 1000);\n }\n }\n } else {\n if (this.fetchedPref) {\n this.fetchedPref = newVal;\n }\n }\n break;\n }\n }\n }\n\n private checkBoxChange($event: any) {\n const id = $event.target.id;\n const checked = $event.target.checked;\n const newValues = {\n ...this.values,\n };\n newValues[id] = !!checked;\n this.values = newValues;\n this.changed = true;\n const hiddenFieldName = `NC_HIDDEN_${id}`;\n this._onChange(hiddenFieldName, checked ? 'PERMISSION' : 'SUPPRESSION');\n }\n static get stableSelector() {\n return `${ddsPrefix}--notice-choice`;\n }\n static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader\n checkBoxTemplate(checkbox, checked) {\n return html`<span>\n <div class=\"${prefix}--form-item bx--checkbox-wrapper\">\n <input\n type=\"checkbox\"\n class=\"${prefix}--checkbox\"\n id=\"${checkbox.id}\"\n name=\"${checkbox.id}\"\n ?checked=${checked}\n @change=\"${this.checkBoxChange}\" />\n <label\n for=\"${checkbox.id}\"\n class=\"${prefix}--checkbox-label ${prefix}--nc__checkbox-${checkbox.id}\"\n ><span class=\"${prefix}--checkbox-label-text\" dir=\"auto\"\n >${checkbox.labelText}\n </span>\n </label>\n </div>\n </span>`;\n }\n postTextTemplate() {\n if (this.ncData) {\n const OptInContent = this.ncData.OptInContent;\n const OtherPreferences = this.ncData.OtherPreferences;\n let postText = OptInContent.postText;\n let tcHtml = '';\n if (this.termsConditionLink) {\n let originalValue = OtherPreferences.trailPrivacyText;\n const matchedValue = originalValue.match(/<tc>.*<\\/tc>/g);\n if (matchedValue) {\n const anrTagHtml = matchedValue[0].replace(/<tc>|<\\/tc>/g, '');\n const link = `<a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' >${anrTagHtml}</a>`;\n const reg = new RegExp('<tc>' + anrTagHtml + '</tc>', 'g');\n tcHtml = `<p>I accept the product <a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' >${anrTagHtml}</a> of this registration form.</p>`;\n postText = originalValue.replace(reg, link);\n }\n }\n // replace default privacy link\n try {\n const { cc, lc } = getMappedValue(this.locale);\n postText = postText.replaceAll(\n 'www.ibm.com/privacy/zz/en/',\n `www.ibm.com/${cc}-${lc}/privacy`\n );\n } catch (e) {\n console.log('unable to replace privacy link locale code.');\n }\n const ccLcObject = getMappedValue(this.locale);\n const cc = ccLcObject.cc;\n const lc = ccLcObject.lc;\n const ccpa =\n this.country === 'US' && (this.state === 'CA' || this.state === '');\n if (this.country === 'CN' && lc === 'en') {\n return html`<p class=\"nc-gdpr-info\">\n I agree and acknowledge that IBM may share my personal information\n with IBM affiliates and third parties globally. I understand that I\n can withdraw my marketing consent at any time by submitting an\n <a\n href=\"https://www.ibm.com/account/reg/${cc}-${lc}/signup?formid=urx-42537\"\n target=\"_blank\"\n >opt-out request</a\n >, and also may unsubscribe from receiving marketing emails by\n clicking the unsubscribe link in each email. More information in\n IBM’s use and processing of personal information can be found in the\n <a href=\"https://www.ibm.com/privacy\" target=\"_blank\"\n >IBM Privacy Statement</a\n >.\n </p>\n\n <p class=\"nc-gdpr-ack\">\n By ticking the above boxes and submitting this form, I have read and\n understand the above notice and IBM Privacy Statement.\n </p>\n ${unsafeHTML(tcHtml)}`;\n } else if (lc === 'en' && ccpa) {\n return html`<p class=\"nc-gdpr-info\">\n You can withdraw your marketing consent at any time by submitting an\n <a\n href=\"https://www.ibm.com/account/reg/us-en/signup?formid=urx-42537\"\n target=\"_blank\"\n >opt-out request</a\n >. Also you may unsubscribe from receiving marketing emails by\n clicking the unsubscribe link in each email.\n </p>\n <p class=\"nc-gdpr-ack\">\n More information on our processing can be found in the\n <a href=\"https://www.ibm.com/privacy\" target=\"_blank\"\n >IBM Privacy Statement.</a\n >\n California residents, review\n <a href=\"https://www.ibm.com/privacy/ccpa\" target=\"_blank\"\n >our notice and your privacy choices</a\n >. <br />\n By submitting this form, I acknowledge that I have read and\n understand the IBM Privacy Statement.\n </p>\n ${unsafeHTML(tcHtml)}`;\n }\n return html`${unsafeHTML(postText)}`;\n } else {\n return html``;\n }\n }\n getBpidLegalText() {\n if (this.bpidLegalText) {\n return html`<p>${this.bpidLegalText}</p>`;\n } else {\n return ``;\n }\n }\n render() {\n return html`<section class=\"${prefix}--nc\">\n <p id=\"ncHeading\" class=\"${ddsPrefix}--nc__pre-text\">${unsafeHTML(\n this.preText\n )}</p>\n <div class=\"${prefix}--checkbox-group\">\n ${\n this.checkboxes &&\n Object.keys(this.checkboxes).length > 0 &&\n Object.keys(this.checkboxes).map((key) => {\n const checked = this.values[key];\n const checkbox = this.checkboxes[key];\n return this.checkBoxTemplate(checkbox, checked);\n })\n }\n </div>\n <div class=\"${prefix}--nc__post-text\"\n >${this.postTextTemplate()}</div>\n </div>\n ${this.getBpidLegalText()}\n </section>`;\n }\n protected emailChanged(email) {\n if (this.changed === false) {\n checkPreferencesv3(email).then((response) => {\n if (\n response === 'S' &&\n JSON.stringify(this.values) !==\n JSON.stringify({\n ...this.values,\n EMAIL: false,\n })\n ) {\n this.fetchedPref = email;\n this.values = {\n ...this.values,\n EMAIL: false,\n };\n this._onChange('NC_HIDDEN_EMAIL', null);\n }\n });\n }\n }\n protected _getOptionByQuestion = (question, OptInContentValue) => {\n let OptInContent = OptInContentValue;\n if (!OptInContent) {\n OptInContent = this.ncData.OptInContent;\n }\n let option;\n switch (question) {\n case 'EMAIL': {\n option = OptInContent.fourQuestionApp[0];\n break;\n }\n case 'PHONE': {\n option = OptInContent.fourQuestionApp[1];\n break;\n }\n case 'POSTAL': {\n option = OptInContent.fourQuestionApp[2];\n break;\n }\n default: {\n option = OptInContent.fourQuestionApp[0];\n break;\n }\n }\n return option;\n };\n protected _buildCheckboxes(OptInContent: any) {\n const fieldElements: any = {};\n const fieldCollections = {\n EMAIL: {\n id: 'EMAIL',\n labelText: this._getOptionByQuestion('EMAIL', OptInContent)\n .optionTextPost,\n },\n PHONE: {\n id: 'PHONE',\n labelText: this._getOptionByQuestion('PHONE', OptInContent)\n .optionTextPost,\n },\n POSTAL: {\n id: 'POSTAL',\n labelText: this._getOptionByQuestion('POSTAL', OptInContent)\n .optionTextPost,\n },\n };\n if (this.questionchoices) {\n // by email\n if (this.questionchoices.indexOf('1') > -1) {\n fieldElements.EMAIL = fieldCollections.EMAIL;\n }\n // by Phone\n if (this.questionchoices.indexOf('2') > -1) {\n fieldElements.PHONE = fieldCollections.PHONE;\n }\n // by Postal mail\n if (this.questionchoices.indexOf('3') > -1) {\n fieldElements.POSTAL = fieldCollections.POSTAL;\n }\n }\n return fieldElements;\n }\n\n _onChange(field: string, value: string | null) {\n const pwsFieldsMap = {\n NC_HIDDEN_EMAIL: 'permission_email',\n NC_HIDDEN_PHONE: 'permission_phone',\n NC_HIDDEN_POSTAL: 'permission_postal',\n };\n if (Object.prototype.hasOwnProperty.call(pwsFieldsMap, field)) {\n field = pwsFieldsMap[field];\n }\n const init = {\n bubbles: true,\n detail: {\n field,\n value: pwsValueMap(value),\n },\n };\n this.dispatchEvent(\n new CustomEvent(`${ddsPrefix}-notice-choice-change`, init)\n );\n }\n}\n\nexport default NoticeChoice;\n"]}
@@ -642,7 +642,6 @@ var NoticeChoice = (0, _decorate2["default"])([(0, _carbonElement.carbonElement)
642
642
  }]
643
643
  };
644
644
  }, (0, _stableSelector["default"])(_litElement.LitElement));
645
- /* @__GENERATE_REACT_CUSTOM_ELEMENT_TYPE__ */
646
645
  var _default = NoticeChoice;
647
646
  exports["default"] = _default;
648
647
  //# sourceMappingURL=notice-choice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"notice-choice.js","names":["_services","require","_litElement","_utils","_countrySettings","_interopRequireDefault","_settings","_settings2","_stableSelector","_noticeChoiceCss","_unsafeHtml","_worldWideContent","_carbonElement","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","_templateObject7","_templateObject8","_templateObject9","_templateObject10","_templateObject11","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","result","NewTarget","constructor","Reflect","construct","_possibleConstructorReturn2","sham","Proxy","Boolean","prototype","valueOf","call","e","ddsPrefix","ddsSettings","stablePrefix","prefix","settings","NoticeChoice","_decorate2","customElement","_initialize","_StableSelectorMixin","_StableSelectorMixin2","_inherits2","_super","_this","_classCallCheck2","_len","args","Array","_key","concat","_assertThisInitialized2","_createClass2","F","d","kind","decorators","property","type","String","reflect","attribute","value","html","_taggedTemplateLiteral2","EMAIL","PHONE","POSTAL","NC_HIDDEN_EMAIL","worldWideContent","cc_default_status","NC_HIDDEN_PHONE","NC_HIDDEN_POSTAL","prepareCheckboxes","ncData","OptInContent","preText","defaultPreText","newCheckboxes","_buildCheckboxes","checkboxes","performUpdate","connectedCallback","_this2","_get2","_getMappedValue","getMappedValue","locale","cc","lc","loadContent","error","console","country","countryChanged","setDefaultSelections","_this3","enableAllOptIn","newValues","values","optInContent","option","_getOptionByQuestion","checked","defaultValues","hasOwnProperty","hiddenFieldName","_onChange","JSON","stringify","countryChangeAction","splitValue","split","getNcContentFromWindow","OtherPreferences","englishNoticeText","changed","fetchedPref","newVal","_this4","toLocaleLowerCase","countrySettings","lang","resetToWorldWideContent","cclc","cc_name","cc_lang","attributeChangedCallback","name","oldVal","_this5","hasValue","_getMappedValue2","emailRegExp","test","setTimeout","emailChanged","checkBoxChange","$event","id","stableSelector","styles","checkBoxTemplate","checkbox","labelText","postTextTemplate","postText","tcHtml","termsConditionLink","originalValue","trailPrivacyText","matchedValue","match","anrTagHtml","replace","link","reg","RegExp","_getMappedValue3","replaceAll","log","ccLcObject","ccpa","state","unsafeHTML","getBpidLegalText","bpidLegalText","render","_this6","map","email","_this7","checkPreferencesv3","then","response","_this8","question","OptInContentValue","fourQuestionApp","fieldElements","fieldCollections","optionTextPost","questionchoices","indexOf","field","pwsFieldsMap","init","bubbles","detail","pwsValueMap","dispatchEvent","CustomEvent","StableSelectorMixin","LitElement","_default","exports"],"sources":["components/notice-choice/notice-choice.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2020, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { checkPreferencesv3, loadContent } from './services';\nimport { html, LitElement, property } from 'lit-element';\nimport {\n emailRegExp,\n getMappedValue,\n getNcContentFromWindow,\n pwsValueMap,\n resetToWorldWideContent,\n} from './utils';\n\nimport countrySettings from './country-settings';\nimport ddsSettings from '../../internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings';\nimport settings from 'carbon-components/es/globals/js/settings';\nimport StableSelectorMixin from '../../globals/mixins/stable-selector';\nimport styles from './notice-choice.scss';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html';\nimport { worldWideContent } from './world-wide-content';\nimport { carbonElement as customElement } from '../../internal/vendor/@carbon/web-components/globals/decorators/carbon-element';\n\nconst { stablePrefix: ddsPrefix } = ddsSettings;\nconst { prefix } = settings;\n\n/**\n * Notice Choice\n *\n * @element dds-notice-choice\n * @fires dds-notice-choice-change\n * The custom event fired when default choice loaded or user change some preferences.\n * The field and value should be taken from the detail object and send it to MRS.\n */\n@customElement(`dds-notice-choice`)\nclass NoticeChoice extends StableSelectorMixin(LitElement) {\n /**\n * properties for passed attributes.\n */\n @property({ type: String, reflect: true, attribute: 'question-choices' })\n questionchoices = '1';\n\n @property({ type: String, attribute: 'country' })\n country = 'US';\n\n @property({ type: String, attribute: 'state' })\n state = '';\n\n @property({ type: String, attribute: 'locale' })\n locale = 'us-en';\n\n @property({ type: String, attribute: 'terms-condition-link' })\n termsConditionLink = html``;\n\n @property({ type: String, attribute: 'bpid-legal-text' })\n bpidLegalText = html``;\n\n @property({ type: Boolean, attribute: 'enable-all-opt-in' })\n enableAllOptIn;\n\n @property({ attribute: 'default-values' })\n defaultValues = {};\n\n @property({ type: String, attribute: 'email' })\n email = '';\n\n @property({ type: Object, attribute: false })\n checkboxes = {};\n\n @property({ type: Object, attribute: false })\n ncData: any;\n\n @property({ type: Boolean, attribute: false })\n changed = false;\n\n @property({ type: String, attribute: false })\n fetchedPref = '';\n\n @property({ type: Object, attribute: false })\n optInContent = {};\n\n /**\n * End properties for passed attributes.\n */\n\n /**\n * properties for local state state management.\n */\n @property({ type: html, attribute: false })\n preText = html``;\n\n @property({ type: html, attribute: false })\n defaultPreText = html``;\n\n @property({ type: Object, attribute: false })\n values = {\n EMAIL: false,\n PHONE: false,\n POSTAL: false,\n NC_HIDDEN_EMAIL: worldWideContent.cc_default_status,\n NC_HIDDEN_PHONE: worldWideContent.cc_default_status,\n NC_HIDDEN_POSTAL: worldWideContent.cc_default_status,\n };\n\n prepareCheckboxes() {\n if (this.ncData) {\n const OptInContent = this.ncData.OptInContent;\n this.preText = OptInContent.preText;\n this.defaultPreText = OptInContent.preText;\n const newCheckboxes = this._buildCheckboxes(OptInContent);\n this.checkboxes = newCheckboxes;\n this.performUpdate();\n }\n }\n connectedCallback() {\n super.connectedCallback();\n const { cc, lc } = getMappedValue(this.locale);\n loadContent(\n cc,\n lc,\n (ncData) => {\n this.ncData = ncData;\n this.prepareCheckboxes();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n if (this.country && this.country !== cc) {\n this.countryChanged(this.country);\n }\n }\n setDefaultSelections() {\n if (!this.enableAllOptIn && this.checkboxes) {\n const newValues = { ...this.values };\n Object.keys(this.checkboxes).forEach((key) => {\n const optInContent = this.optInContent || this.ncData.OptInContent;\n const option = this._getOptionByQuestion(key, optInContent);\n newValues[key] = !!(\n option.checked === 'true' || option.checked === true\n );\n if (\n this.defaultValues &&\n Object.prototype.hasOwnProperty.call(this.defaultValues, key)\n ) {\n newValues[key] = this.defaultValues[key];\n }\n const hiddenFieldName = `NC_HIDDEN_${key}`;\n this._onChange(hiddenFieldName, newValues[key] ? 'OPT_IN' : null);\n });\n if (JSON.stringify(this.values) !== JSON.stringify(newValues)) {\n this.values = newValues;\n }\n }\n }\n countryChangeAction() {\n const splitValue = this.locale.split('-', 2);\n const ncData = getNcContentFromWindow();\n if (splitValue[1] === 'en') {\n let preText = this.defaultPreText;\n if (ncData.OtherPreferences.englishNoticeText !== '') {\n preText = ncData.OtherPreferences.englishNoticeText;\n }\n this.preText = preText;\n }\n /**\n * @description if the user already interacted with the checkboxes,\n * skip country default selection.\n */\n if (!this.changed && !this.fetchedPref) {\n /**\n * @description\n * change checkbox checked option based on new country.\n */\n this.setDefaultSelections();\n }\n }\n countryChanged(newVal) {\n const cc = newVal.toLocaleLowerCase();\n const lc = countrySettings[newVal.toLocaleLowerCase()].lang;\n resetToWorldWideContent();\n loadContent(\n cc,\n lc,\n (ncData) => {\n /**\n * @description Do not change content language.\n * Change the checkbox according to the country rule.\n */\n this.optInContent = {\n ...ncData.OptInContent,\n cclc: `${worldWideContent.cc_name}-${worldWideContent.cc_lang}`,\n };\n this.countryChangeAction();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n }\n /**\n *\n * @param name name of the attribute\n * @param oldVal old value of the attribute\n * @param newVal new value of the attrbute\n */\n attributeChangedCallback(name, oldVal, newVal) {\n const hasValue = newVal !== null && oldVal !== null;\n super.attributeChangedCallback(name, oldVal, newVal);\n switch (name) {\n case 'question-choices': {\n // Reload checkbox options when questionchoices changed\n if (oldVal !== newVal) {\n this.prepareCheckboxes();\n this.setDefaultSelections();\n }\n break;\n }\n case 'locale': {\n // load content when locale changed.\n if (hasValue && oldVal !== newVal) {\n const { cc, lc } = getMappedValue(newVal);\n loadContent(\n cc,\n lc,\n (ncData) => {\n this.ncData = ncData;\n this.prepareCheckboxes();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n }\n break;\n }\n case 'country': {\n /**\n * load content when country value changed.\n */\n if (\n hasValue &&\n oldVal !== newVal &&\n countrySettings[newVal.toLocaleLowerCase()]\n ) {\n this.countryChanged(newVal);\n }\n break;\n }\n case 'enable-all-opt-in':\n this.setDefaultSelections();\n break;\n case 'email': {\n if (newVal) {\n if (newVal !== this.fetchedPref) {\n // Handle throttle using debounce approach.\n if (emailRegExp.test(newVal)) {\n setTimeout(() => {\n this.emailChanged(newVal);\n }, 1000);\n }\n }\n } else {\n if (this.fetchedPref) {\n this.fetchedPref = newVal;\n }\n }\n break;\n }\n }\n }\n\n private checkBoxChange($event: any) {\n const id = $event.target.id;\n const checked = $event.target.checked;\n const newValues = {\n ...this.values,\n };\n newValues[id] = !!checked;\n this.values = newValues;\n this.changed = true;\n const hiddenFieldName = `NC_HIDDEN_${id}`;\n this._onChange(hiddenFieldName, checked ? 'PERMISSION' : 'SUPPRESSION');\n }\n static get stableSelector() {\n return `${ddsPrefix}--notice-choice`;\n }\n static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader\n checkBoxTemplate(checkbox, checked) {\n return html`<span>\n <div class=\"${prefix}--form-item bx--checkbox-wrapper\">\n <input\n type=\"checkbox\"\n class=\"${prefix}--checkbox\"\n id=\"${checkbox.id}\"\n name=\"${checkbox.id}\"\n ?checked=${checked}\n @change=\"${this.checkBoxChange}\" />\n <label\n for=\"${checkbox.id}\"\n class=\"${prefix}--checkbox-label ${prefix}--nc__checkbox-${checkbox.id}\"\n ><span class=\"${prefix}--checkbox-label-text\" dir=\"auto\"\n >${checkbox.labelText}\n </span>\n </label>\n </div>\n </span>`;\n }\n postTextTemplate() {\n if (this.ncData) {\n const OptInContent = this.ncData.OptInContent;\n const OtherPreferences = this.ncData.OtherPreferences;\n let postText = OptInContent.postText;\n let tcHtml = '';\n if (this.termsConditionLink) {\n let originalValue = OtherPreferences.trailPrivacyText;\n const matchedValue = originalValue.match(/<tc>.*<\\/tc>/g);\n if (matchedValue) {\n const anrTagHtml = matchedValue[0].replace(/<tc>|<\\/tc>/g, '');\n const link = `<a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' >${anrTagHtml}</a>`;\n const reg = new RegExp('<tc>' + anrTagHtml + '</tc>', 'g');\n tcHtml = `<p>I accept the product <a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' >${anrTagHtml}</a> of this registration form.</p>`;\n postText = originalValue.replace(reg, link);\n }\n }\n // replace default privacy link\n try {\n const { cc, lc } = getMappedValue(this.locale);\n postText = postText.replaceAll(\n 'www.ibm.com/privacy/zz/en/',\n `www.ibm.com/${cc}-${lc}/privacy`\n );\n } catch (e) {\n console.log('unable to replace privacy link locale code.');\n }\n const ccLcObject = getMappedValue(this.locale);\n const cc = ccLcObject.cc;\n const lc = ccLcObject.lc;\n const ccpa =\n this.country === 'US' && (this.state === 'CA' || this.state === '');\n if (this.country === 'CN' && lc === 'en') {\n return html`<p class=\"nc-gdpr-info\">\n I agree and acknowledge that IBM may share my personal information\n with IBM affiliates and third parties globally. I understand that I\n can withdraw my marketing consent at any time by submitting an\n <a\n href=\"https://www.ibm.com/account/reg/${cc}-${lc}/signup?formid=urx-42537\"\n target=\"_blank\"\n >opt-out request</a\n >, and also may unsubscribe from receiving marketing emails by\n clicking the unsubscribe link in each email. More information in\n IBM’s use and processing of personal information can be found in the\n <a href=\"https://www.ibm.com/privacy\" target=\"_blank\"\n >IBM Privacy Statement</a\n >.\n </p>\n\n <p class=\"nc-gdpr-ack\">\n By ticking the above boxes and submitting this form, I have read and\n understand the above notice and IBM Privacy Statement.\n </p>\n ${unsafeHTML(tcHtml)}`;\n } else if (lc === 'en' && ccpa) {\n return html`<p class=\"nc-gdpr-info\">\n You can withdraw your marketing consent at any time by submitting an\n <a\n href=\"https://www.ibm.com/account/reg/us-en/signup?formid=urx-42537\"\n target=\"_blank\"\n >opt-out request</a\n >. Also you may unsubscribe from receiving marketing emails by\n clicking the unsubscribe link in each email.\n </p>\n <p class=\"nc-gdpr-ack\">\n More information on our processing can be found in the\n <a href=\"https://www.ibm.com/privacy\" target=\"_blank\"\n >IBM Privacy Statement.</a\n >\n California residents, review\n <a href=\"https://www.ibm.com/privacy/ccpa\" target=\"_blank\"\n >our notice and your privacy choices</a\n >. <br />\n By submitting this form, I acknowledge that I have read and\n understand the IBM Privacy Statement.\n </p>\n ${unsafeHTML(tcHtml)}`;\n }\n return html`${unsafeHTML(postText)}`;\n } else {\n return html``;\n }\n }\n getBpidLegalText() {\n if (this.bpidLegalText) {\n return html`<p>${this.bpidLegalText}</p>`;\n } else {\n return ``;\n }\n }\n render() {\n return html`<section class=\"${prefix}--nc\">\n <p id=\"ncHeading\" class=\"${ddsPrefix}--nc__pre-text\">${unsafeHTML(\n this.preText\n )}</p>\n <div class=\"${prefix}--checkbox-group\">\n ${\n this.checkboxes &&\n Object.keys(this.checkboxes).length > 0 &&\n Object.keys(this.checkboxes).map((key) => {\n const checked = this.values[key];\n const checkbox = this.checkboxes[key];\n return this.checkBoxTemplate(checkbox, checked);\n })\n }\n </div>\n <div class=\"${prefix}--nc__post-text\"\n >${this.postTextTemplate()}</div>\n </div>\n ${this.getBpidLegalText()}\n </section>`;\n }\n protected emailChanged(email) {\n if (this.changed === false) {\n checkPreferencesv3(email).then((response) => {\n if (\n response === 'S' &&\n JSON.stringify(this.values) !==\n JSON.stringify({\n ...this.values,\n EMAIL: false,\n })\n ) {\n this.fetchedPref = email;\n this.values = {\n ...this.values,\n EMAIL: false,\n };\n this._onChange('NC_HIDDEN_EMAIL', null);\n }\n });\n }\n }\n protected _getOptionByQuestion = (question, OptInContentValue) => {\n let OptInContent = OptInContentValue;\n if (!OptInContent) {\n OptInContent = this.ncData.OptInContent;\n }\n let option;\n switch (question) {\n case 'EMAIL': {\n option = OptInContent.fourQuestionApp[0];\n break;\n }\n case 'PHONE': {\n option = OptInContent.fourQuestionApp[1];\n break;\n }\n case 'POSTAL': {\n option = OptInContent.fourQuestionApp[2];\n break;\n }\n default: {\n option = OptInContent.fourQuestionApp[0];\n break;\n }\n }\n return option;\n };\n protected _buildCheckboxes(OptInContent: any) {\n const fieldElements: any = {};\n const fieldCollections = {\n EMAIL: {\n id: 'EMAIL',\n labelText: this._getOptionByQuestion('EMAIL', OptInContent)\n .optionTextPost,\n },\n PHONE: {\n id: 'PHONE',\n labelText: this._getOptionByQuestion('PHONE', OptInContent)\n .optionTextPost,\n },\n POSTAL: {\n id: 'POSTAL',\n labelText: this._getOptionByQuestion('POSTAL', OptInContent)\n .optionTextPost,\n },\n };\n if (this.questionchoices) {\n // by email\n if (this.questionchoices.indexOf('1') > -1) {\n fieldElements.EMAIL = fieldCollections.EMAIL;\n }\n // by Phone\n if (this.questionchoices.indexOf('2') > -1) {\n fieldElements.PHONE = fieldCollections.PHONE;\n }\n // by Postal mail\n if (this.questionchoices.indexOf('3') > -1) {\n fieldElements.POSTAL = fieldCollections.POSTAL;\n }\n }\n return fieldElements;\n }\n\n _onChange(field: string, value: string | null) {\n const pwsFieldsMap = {\n NC_HIDDEN_EMAIL: 'permission_email',\n NC_HIDDEN_PHONE: 'permission_phone',\n NC_HIDDEN_POSTAL: 'permission_postal',\n };\n if (Object.prototype.hasOwnProperty.call(pwsFieldsMap, field)) {\n field = pwsFieldsMap[field];\n }\n const init = {\n bubbles: true,\n detail: {\n field,\n value: pwsValueMap(value),\n },\n };\n this.dispatchEvent(\n new CustomEvent(`${ddsPrefix}-notice-choice-change`, init)\n );\n }\n}\n/* @__GENERATE_REACT_CUSTOM_ELEMENT_TYPE__ */\nexport default NoticeChoice;\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAQA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,UAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,eAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,gBAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AACA,IAAAW,cAAA,GAAAX,OAAA;AAAgI,IAAAY,eAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,iBAAA,EAAAC,iBAAA;AAAA,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,O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EAAE;YAC1CJ,aAAa,CAAChH,MAAM,GAAGiH,gBAAgB,CAACjH,MAAM;UAChD;QACF;QACA,OAAOgH,aAAa;MACtB;IAAC;MAAA5H,IAAA;MAAAjD,GAAA;MAAAwD,KAAA,EAED,SAAA6C,UAAU6E,KAAa,EAAE1H,KAAoB,EAAE;QAC7C,IAAM2H,YAAY,GAAG;UACnBrH,eAAe,EAAE,kBAAkB;UACnCG,eAAe,EAAE,kBAAkB;UACnCC,gBAAgB,EAAE;QACpB,CAAC;QACD,IAAIlF,MAAM,CAACqC,SAAS,CAAC8E,cAAc,CAAC5E,IAAI,CAAC4J,YAAY,EAAED,KAAK,CAAC,EAAE;UAC7DA,KAAK,GAAGC,YAAY,CAACD,KAAK,CAAC;QAC7B;QACA,IAAME,IAAI,GAAG;UACXC,OAAO,EAAE,IAAI;UACbC,MAAM,EAAE;YACNJ,KAAK,EAALA,KAAK;YACL1H,KAAK,EAAE,IAAA+H,kBAAW,EAAC/H,KAAK;UAC1B;QACF,CAAC;QACD,IAAI,CAACgI,aAAa,CAChB,IAAIC,WAAW,IAAA7I,MAAA,CAAInB,SAAS,4BAAyB2J,IAAI,CAC3D,CAAC;MACH;IAAC;EAAA;AAAA,GAvewB,IAAAM,0BAAmB,EAACC,sBAAU,CAAC;AAye1D;AAAA,IAAAC,QAAA,GACe9J,YAAY;AAAA+J,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"notice-choice.js","names":["_services","require","_litElement","_utils","_countrySettings","_interopRequireDefault","_settings","_settings2","_stableSelector","_noticeChoiceCss","_unsafeHtml","_worldWideContent","_carbonElement","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","_templateObject7","_templateObject8","_templateObject9","_templateObject10","_templateObject11","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","result","NewTarget","constructor","Reflect","construct","_possibleConstructorReturn2","sham","Proxy","Boolean","prototype","valueOf","call","e","ddsPrefix","ddsSettings","stablePrefix","prefix","settings","NoticeChoice","_decorate2","customElement","_initialize","_StableSelectorMixin","_StableSelectorMixin2","_inherits2","_super","_this","_classCallCheck2","_len","args","Array","_key","concat","_assertThisInitialized2","_createClass2","F","d","kind","decorators","property","type","String","reflect","attribute","value","html","_taggedTemplateLiteral2","EMAIL","PHONE","POSTAL","NC_HIDDEN_EMAIL","worldWideContent","cc_default_status","NC_HIDDEN_PHONE","NC_HIDDEN_POSTAL","prepareCheckboxes","ncData","OptInContent","preText","defaultPreText","newCheckboxes","_buildCheckboxes","checkboxes","performUpdate","connectedCallback","_this2","_get2","_getMappedValue","getMappedValue","locale","cc","lc","loadContent","error","console","country","countryChanged","setDefaultSelections","_this3","enableAllOptIn","newValues","values","optInContent","option","_getOptionByQuestion","checked","defaultValues","hasOwnProperty","hiddenFieldName","_onChange","JSON","stringify","countryChangeAction","splitValue","split","getNcContentFromWindow","OtherPreferences","englishNoticeText","changed","fetchedPref","newVal","_this4","toLocaleLowerCase","countrySettings","lang","resetToWorldWideContent","cclc","cc_name","cc_lang","attributeChangedCallback","name","oldVal","_this5","hasValue","_getMappedValue2","emailRegExp","test","setTimeout","emailChanged","checkBoxChange","$event","id","stableSelector","styles","checkBoxTemplate","checkbox","labelText","postTextTemplate","postText","tcHtml","termsConditionLink","originalValue","trailPrivacyText","matchedValue","match","anrTagHtml","replace","link","reg","RegExp","_getMappedValue3","replaceAll","log","ccLcObject","ccpa","state","unsafeHTML","getBpidLegalText","bpidLegalText","render","_this6","map","email","_this7","checkPreferencesv3","then","response","_this8","question","OptInContentValue","fourQuestionApp","fieldElements","fieldCollections","optionTextPost","questionchoices","indexOf","field","pwsFieldsMap","init","bubbles","detail","pwsValueMap","dispatchEvent","CustomEvent","StableSelectorMixin","LitElement","_default","exports"],"sources":["components/notice-choice/notice-choice.ts"],"sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2020, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { checkPreferencesv3, loadContent } from './services';\nimport { html, LitElement, property } from 'lit-element';\nimport {\n emailRegExp,\n getMappedValue,\n getNcContentFromWindow,\n pwsValueMap,\n resetToWorldWideContent,\n} from './utils';\n\nimport countrySettings from './country-settings';\nimport ddsSettings from '../../internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings';\nimport settings from 'carbon-components/es/globals/js/settings';\nimport StableSelectorMixin from '../../globals/mixins/stable-selector';\nimport styles from './notice-choice.scss';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html';\nimport { worldWideContent } from './world-wide-content';\nimport { carbonElement as customElement } from '../../internal/vendor/@carbon/web-components/globals/decorators/carbon-element';\n\nconst { stablePrefix: ddsPrefix } = ddsSettings;\nconst { prefix } = settings;\n\n/**\n * Notice Choice\n *\n * @element dds-notice-choice\n * @fires dds-notice-choice-change\n * The custom event fired when default choice loaded or user change some preferences.\n * The field and value should be taken from the detail object and send it to MRS.\n */\n@customElement(`dds-notice-choice`)\nclass NoticeChoice extends StableSelectorMixin(LitElement) {\n /**\n * properties for passed attributes.\n */\n @property({ type: String, reflect: true, attribute: 'question-choices' })\n questionchoices = '1';\n\n @property({ type: String, attribute: 'country' })\n country = 'US';\n\n @property({ type: String, attribute: 'state' })\n state = '';\n\n @property({ type: String, attribute: 'locale' })\n locale = 'us-en';\n\n @property({ type: String, attribute: 'terms-condition-link' })\n termsConditionLink = html``;\n\n @property({ type: String, attribute: 'bpid-legal-text' })\n bpidLegalText = html``;\n\n @property({ type: Boolean, attribute: 'enable-all-opt-in' })\n enableAllOptIn;\n\n @property({ attribute: 'default-values' })\n defaultValues = {};\n\n @property({ type: String, attribute: 'email' })\n email = '';\n\n @property({ type: Object, attribute: false })\n checkboxes = {};\n\n @property({ type: Object, attribute: false })\n ncData: any;\n\n @property({ type: Boolean, attribute: false })\n changed = false;\n\n @property({ type: String, attribute: false })\n fetchedPref = '';\n\n @property({ type: Object, attribute: false })\n optInContent = {};\n\n /**\n * End properties for passed attributes.\n */\n\n /**\n * properties for local state state management.\n */\n @property({ type: html, attribute: false })\n preText = html``;\n\n @property({ type: html, attribute: false })\n defaultPreText = html``;\n\n @property({ type: Object, attribute: false })\n values = {\n EMAIL: false,\n PHONE: false,\n POSTAL: false,\n NC_HIDDEN_EMAIL: worldWideContent.cc_default_status,\n NC_HIDDEN_PHONE: worldWideContent.cc_default_status,\n NC_HIDDEN_POSTAL: worldWideContent.cc_default_status,\n };\n\n prepareCheckboxes() {\n if (this.ncData) {\n const OptInContent = this.ncData.OptInContent;\n this.preText = OptInContent.preText;\n this.defaultPreText = OptInContent.preText;\n const newCheckboxes = this._buildCheckboxes(OptInContent);\n this.checkboxes = newCheckboxes;\n this.performUpdate();\n }\n }\n connectedCallback() {\n super.connectedCallback();\n const { cc, lc } = getMappedValue(this.locale);\n loadContent(\n cc,\n lc,\n (ncData) => {\n this.ncData = ncData;\n this.prepareCheckboxes();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n if (this.country && this.country !== cc) {\n this.countryChanged(this.country);\n }\n }\n setDefaultSelections() {\n if (!this.enableAllOptIn && this.checkboxes) {\n const newValues = { ...this.values };\n Object.keys(this.checkboxes).forEach((key) => {\n const optInContent = this.optInContent || this.ncData.OptInContent;\n const option = this._getOptionByQuestion(key, optInContent);\n newValues[key] = !!(\n option.checked === 'true' || option.checked === true\n );\n if (\n this.defaultValues &&\n Object.prototype.hasOwnProperty.call(this.defaultValues, key)\n ) {\n newValues[key] = this.defaultValues[key];\n }\n const hiddenFieldName = `NC_HIDDEN_${key}`;\n this._onChange(hiddenFieldName, newValues[key] ? 'OPT_IN' : null);\n });\n if (JSON.stringify(this.values) !== JSON.stringify(newValues)) {\n this.values = newValues;\n }\n }\n }\n countryChangeAction() {\n const splitValue = this.locale.split('-', 2);\n const ncData = getNcContentFromWindow();\n if (splitValue[1] === 'en') {\n let preText = this.defaultPreText;\n if (ncData.OtherPreferences.englishNoticeText !== '') {\n preText = ncData.OtherPreferences.englishNoticeText;\n }\n this.preText = preText;\n }\n /**\n * @description if the user already interacted with the checkboxes,\n * skip country default selection.\n */\n if (!this.changed && !this.fetchedPref) {\n /**\n * @description\n * change checkbox checked option based on new country.\n */\n this.setDefaultSelections();\n }\n }\n countryChanged(newVal) {\n const cc = newVal.toLocaleLowerCase();\n const lc = countrySettings[newVal.toLocaleLowerCase()].lang;\n resetToWorldWideContent();\n loadContent(\n cc,\n lc,\n (ncData) => {\n /**\n * @description Do not change content language.\n * Change the checkbox according to the country rule.\n */\n this.optInContent = {\n ...ncData.OptInContent,\n cclc: `${worldWideContent.cc_name}-${worldWideContent.cc_lang}`,\n };\n this.countryChangeAction();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n }\n /**\n *\n * @param name name of the attribute\n * @param oldVal old value of the attribute\n * @param newVal new value of the attrbute\n */\n attributeChangedCallback(name, oldVal, newVal) {\n const hasValue = newVal !== null && oldVal !== null;\n super.attributeChangedCallback(name, oldVal, newVal);\n switch (name) {\n case 'question-choices': {\n // Reload checkbox options when questionchoices changed\n if (oldVal !== newVal) {\n this.prepareCheckboxes();\n this.setDefaultSelections();\n }\n break;\n }\n case 'locale': {\n // load content when locale changed.\n if (hasValue && oldVal !== newVal) {\n const { cc, lc } = getMappedValue(newVal);\n loadContent(\n cc,\n lc,\n (ncData) => {\n this.ncData = ncData;\n this.prepareCheckboxes();\n },\n (error) => {\n console.error('error loading content', error);\n }\n );\n }\n break;\n }\n case 'country': {\n /**\n * load content when country value changed.\n */\n if (\n hasValue &&\n oldVal !== newVal &&\n countrySettings[newVal.toLocaleLowerCase()]\n ) {\n this.countryChanged(newVal);\n }\n break;\n }\n case 'enable-all-opt-in':\n this.setDefaultSelections();\n break;\n case 'email': {\n if (newVal) {\n if (newVal !== this.fetchedPref) {\n // Handle throttle using debounce approach.\n if (emailRegExp.test(newVal)) {\n setTimeout(() => {\n this.emailChanged(newVal);\n }, 1000);\n }\n }\n } else {\n if (this.fetchedPref) {\n this.fetchedPref = newVal;\n }\n }\n break;\n }\n }\n }\n\n private checkBoxChange($event: any) {\n const id = $event.target.id;\n const checked = $event.target.checked;\n const newValues = {\n ...this.values,\n };\n newValues[id] = !!checked;\n this.values = newValues;\n this.changed = true;\n const hiddenFieldName = `NC_HIDDEN_${id}`;\n this._onChange(hiddenFieldName, checked ? 'PERMISSION' : 'SUPPRESSION');\n }\n static get stableSelector() {\n return `${ddsPrefix}--notice-choice`;\n }\n static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader\n checkBoxTemplate(checkbox, checked) {\n return html`<span>\n <div class=\"${prefix}--form-item bx--checkbox-wrapper\">\n <input\n type=\"checkbox\"\n class=\"${prefix}--checkbox\"\n id=\"${checkbox.id}\"\n name=\"${checkbox.id}\"\n ?checked=${checked}\n @change=\"${this.checkBoxChange}\" />\n <label\n for=\"${checkbox.id}\"\n class=\"${prefix}--checkbox-label ${prefix}--nc__checkbox-${checkbox.id}\"\n ><span class=\"${prefix}--checkbox-label-text\" dir=\"auto\"\n >${checkbox.labelText}\n </span>\n </label>\n </div>\n </span>`;\n }\n postTextTemplate() {\n if (this.ncData) {\n const OptInContent = this.ncData.OptInContent;\n const OtherPreferences = this.ncData.OtherPreferences;\n let postText = OptInContent.postText;\n let tcHtml = '';\n if (this.termsConditionLink) {\n let originalValue = OtherPreferences.trailPrivacyText;\n const matchedValue = originalValue.match(/<tc>.*<\\/tc>/g);\n if (matchedValue) {\n const anrTagHtml = matchedValue[0].replace(/<tc>|<\\/tc>/g, '');\n const link = `<a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' >${anrTagHtml}</a>`;\n const reg = new RegExp('<tc>' + anrTagHtml + '</tc>', 'g');\n tcHtml = `<p>I accept the product <a href='${this.termsConditionLink}' target='_blank' class='ibm-tooltip' >${anrTagHtml}</a> of this registration form.</p>`;\n postText = originalValue.replace(reg, link);\n }\n }\n // replace default privacy link\n try {\n const { cc, lc } = getMappedValue(this.locale);\n postText = postText.replaceAll(\n 'www.ibm.com/privacy/zz/en/',\n `www.ibm.com/${cc}-${lc}/privacy`\n );\n } catch (e) {\n console.log('unable to replace privacy link locale code.');\n }\n const ccLcObject = getMappedValue(this.locale);\n const cc = ccLcObject.cc;\n const lc = ccLcObject.lc;\n const ccpa =\n this.country === 'US' && (this.state === 'CA' || this.state === '');\n if (this.country === 'CN' && lc === 'en') {\n return html`<p class=\"nc-gdpr-info\">\n I agree and acknowledge that IBM may share my personal information\n with IBM affiliates and third parties globally. I understand that I\n can withdraw my marketing consent at any time by submitting an\n <a\n href=\"https://www.ibm.com/account/reg/${cc}-${lc}/signup?formid=urx-42537\"\n target=\"_blank\"\n >opt-out request</a\n >, and also may unsubscribe from receiving marketing emails by\n clicking the unsubscribe link in each email. More information in\n IBM’s use and processing of personal information can be found in the\n <a href=\"https://www.ibm.com/privacy\" target=\"_blank\"\n >IBM Privacy Statement</a\n >.\n </p>\n\n <p class=\"nc-gdpr-ack\">\n By ticking the above boxes and submitting this form, I have read and\n understand the above notice and IBM Privacy Statement.\n </p>\n ${unsafeHTML(tcHtml)}`;\n } else if (lc === 'en' && ccpa) {\n return html`<p class=\"nc-gdpr-info\">\n You can withdraw your marketing consent at any time by submitting an\n <a\n href=\"https://www.ibm.com/account/reg/us-en/signup?formid=urx-42537\"\n target=\"_blank\"\n >opt-out request</a\n >. Also you may unsubscribe from receiving marketing emails by\n clicking the unsubscribe link in each email.\n </p>\n <p class=\"nc-gdpr-ack\">\n More information on our processing can be found in the\n <a href=\"https://www.ibm.com/privacy\" target=\"_blank\"\n >IBM Privacy Statement.</a\n >\n California residents, review\n <a href=\"https://www.ibm.com/privacy/ccpa\" target=\"_blank\"\n >our notice and your privacy choices</a\n >. <br />\n By submitting this form, I acknowledge that I have read and\n understand the IBM Privacy Statement.\n </p>\n ${unsafeHTML(tcHtml)}`;\n }\n return html`${unsafeHTML(postText)}`;\n } else {\n return html``;\n }\n }\n getBpidLegalText() {\n if (this.bpidLegalText) {\n return html`<p>${this.bpidLegalText}</p>`;\n } else {\n return ``;\n }\n }\n render() {\n return html`<section class=\"${prefix}--nc\">\n <p id=\"ncHeading\" class=\"${ddsPrefix}--nc__pre-text\">${unsafeHTML(\n this.preText\n )}</p>\n <div class=\"${prefix}--checkbox-group\">\n ${\n this.checkboxes &&\n Object.keys(this.checkboxes).length > 0 &&\n Object.keys(this.checkboxes).map((key) => {\n const checked = this.values[key];\n const checkbox = this.checkboxes[key];\n return this.checkBoxTemplate(checkbox, checked);\n })\n }\n </div>\n <div class=\"${prefix}--nc__post-text\"\n >${this.postTextTemplate()}</div>\n </div>\n ${this.getBpidLegalText()}\n </section>`;\n }\n protected emailChanged(email) {\n if (this.changed === false) {\n checkPreferencesv3(email).then((response) => {\n if (\n response === 'S' &&\n JSON.stringify(this.values) !==\n JSON.stringify({\n ...this.values,\n EMAIL: false,\n })\n ) {\n this.fetchedPref = email;\n this.values = {\n ...this.values,\n EMAIL: false,\n };\n this._onChange('NC_HIDDEN_EMAIL', null);\n }\n });\n }\n }\n protected _getOptionByQuestion = (question, OptInContentValue) => {\n let OptInContent = OptInContentValue;\n if (!OptInContent) {\n OptInContent = this.ncData.OptInContent;\n }\n let option;\n switch (question) {\n case 'EMAIL': {\n option = OptInContent.fourQuestionApp[0];\n break;\n }\n case 'PHONE': {\n option = OptInContent.fourQuestionApp[1];\n break;\n }\n case 'POSTAL': {\n option = OptInContent.fourQuestionApp[2];\n break;\n }\n default: {\n option = OptInContent.fourQuestionApp[0];\n break;\n }\n }\n return option;\n };\n protected _buildCheckboxes(OptInContent: any) {\n const fieldElements: any = {};\n const fieldCollections = {\n EMAIL: {\n id: 'EMAIL',\n labelText: this._getOptionByQuestion('EMAIL', OptInContent)\n .optionTextPost,\n },\n PHONE: {\n id: 'PHONE',\n labelText: this._getOptionByQuestion('PHONE', OptInContent)\n .optionTextPost,\n },\n POSTAL: {\n id: 'POSTAL',\n labelText: this._getOptionByQuestion('POSTAL', OptInContent)\n .optionTextPost,\n },\n };\n if (this.questionchoices) {\n // by email\n if (this.questionchoices.indexOf('1') > -1) {\n fieldElements.EMAIL = fieldCollections.EMAIL;\n }\n // by Phone\n if (this.questionchoices.indexOf('2') > -1) {\n fieldElements.PHONE = fieldCollections.PHONE;\n }\n // by Postal mail\n if (this.questionchoices.indexOf('3') > -1) {\n fieldElements.POSTAL = fieldCollections.POSTAL;\n }\n }\n return fieldElements;\n }\n\n _onChange(field: string, value: string | null) {\n const pwsFieldsMap = {\n NC_HIDDEN_EMAIL: 'permission_email',\n NC_HIDDEN_PHONE: 'permission_phone',\n NC_HIDDEN_POSTAL: 'permission_postal',\n };\n if (Object.prototype.hasOwnProperty.call(pwsFieldsMap, field)) {\n field = pwsFieldsMap[field];\n }\n const init = {\n bubbles: true,\n detail: {\n field,\n value: pwsValueMap(value),\n },\n };\n this.dispatchEvent(\n new CustomEvent(`${ddsPrefix}-notice-choice-change`, init)\n );\n }\n}\n\nexport default NoticeChoice;\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAQA,IAAAG,gBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,UAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,eAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,gBAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AACA,IAAAW,cAAA,GAAAX,OAAA;AAAgI,IAAAY,eAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC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CAAgC,SAAuB;IAEvD;;OAEG;IAEH,iBAAiB,SAAuB;IAExC;;OAEG;IAEH,WAAW,SAA2C;IAEtD;;OAEG;IAEH,WAAW,SAAsB;IAEjC;;OAEG;IAEH,IAAI,SAAY;IAEhB;;OAEG;IAEH,gBAAgB,UAAS;IAEzB;;OAEG;IACH,IAAI,iBAAiB,WAEpB;IAED;;OAEG;IACH,OAAO,CAAC,eAAe;IAWvB,YAAY;IAaZ,OAAO,CAAC,iBAAiB,KAAA;IA+CzB,MAAM;IA6EN;;OAEG;IACH,MAAM,KAAK,uBAAuB,WAEjC;IAED;;OAEG;IACH,MAAM,KAAK,YAAY,WAEtB;IAED;;;OAGG;IACH,MAAM,KAAK,mBAAmB,WAE7B;IAED;;OAEG;IACH,MAAM,KAAK,UAAU,WAEpB;IAED;;OAEG;IACH,MAAM,KAAK,gBAAgB,WAE1B;IAED;;OAEG;IACH,MAAM,KAAK,kBAAkB,WAE5B;IAED;;OAEG;IACH,MAAM,KAAK,WAAW,WAErB;IAED,MAAM,KAAK,cAAc,WAExB;IAED,MAAM,CAAC,MAAM,MAAU;CACxB;AAGD,eAAe,sBAAsB,CAAC","file":"search-with-typeahead.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2019, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport ifNonNull from '../../internal/vendor/@carbon/web-components/globals/directives/if-non-null.js';\nimport { classMap } from 'lit-html/directives/class-map.js';\nimport { html, property, query } from 'lit-element';\nimport settings from 'carbon-components/es/globals/js/settings.js';\nimport Close20 from '../../internal/vendor/@carbon/web-components/icons/close/20.js';\nimport Search20 from '../../internal/vendor/@carbon/web-components/icons/search/20.js';\nimport BXDropdown, {\n DROPDOWN_KEYBOARD_ACTION,\n} from '../../internal/vendor/@carbon/web-components/components/dropdown/dropdown.js';\nimport BXDropdownItem from '../../internal/vendor/@carbon/web-components/components/dropdown/dropdown-item.js';\nimport HostListener from '../../internal/vendor/@carbon/web-components/globals/decorators/host-listener.js';\nimport HostListenerMixin from '../../internal/vendor/@carbon/web-components/globals/mixins/host-listener.js';\nimport { baseFontSize, breakpoints } from '@carbon/layout';\nimport ddsSettings from '../../internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings';\nimport SearchTypeaheadAPI from '../../internal/vendor/@carbon/ibmdotcom-services/services/SearchTypeahead/SearchTypeahead';\nimport { forEach, indexOf } from '../../globals/internal/collection-helpers';\nimport styles from './search-with-typeahead.scss';\nimport StableSelectorMixin from '../../globals/mixins/stable-selector';\nimport './search-with-typeahead-item';\nimport { carbonElement as customElement } from '../../internal/vendor/@carbon/web-components/globals/decorators/carbon-element.js';\n\nconst { stablePrefix: ddsPrefix } = ddsSettings;\nconst { prefix } = settings;\nconst gridBreakpoint = parseFloat(breakpoints.lg.width) * baseFontSize;\n\n/**\n * Search with Typeahead\n *\n * @element dds-search-with-typeahead\n * @csspart open-button The button to show the search box.\n * @csspart close-button The button to hide the search box.\n * @csspart search-input The input box for search.\n * @fires dds-search-with-typeahead-beingredirected\n * The custom event fired before the page is being redirected to the search result page.\n * Cancellation of this event stops the user-initiated action of redirection.\n * @fires dds-search-with-typeahead-input\n * The name of the custom event fired after the search content is changed upon a user gesture.\n * @fires dds-search-with-typeahead-toggled\n * The name of the custom event fired after this search box is toggled upon a user gesture.\n */\n@customElement(`${ddsPrefix}-search-with-typeahead`)\nclass DDSSearchWithTypeahead extends HostListenerMixin(\n StableSelectorMixin(BXDropdown)\n) {\n // eslint-disable-next-line class-methods-use-this\n async getResults(searchQuery) {\n const response = await SearchTypeaheadAPI.getResults(\n searchQuery,\n this.appId\n );\n return response.map((res) => res[0]);\n }\n\n /**\n * The formatter for the placeholder text on the search box.\n * Should be changed upon the locale the UI is rendered with.\n */\n @property({ attribute: false })\n placeholderFormatter = ({ appId }) => `Search in ${appId}`;\n\n @property({ attribute: 'leadspace-search', type: Boolean })\n leadspaceSearch = false;\n\n @property({ attribute: 'custom-typeahead-api', type: Boolean })\n customTypeaheadAPI = false;\n\n @property()\n currentSearchResults;\n\n @property()\n searchResults;\n\n @property()\n groupedResults;\n\n @property({ attribute: 'scope-parameters' })\n scopeParameters;\n\n @property({ attribute: 'should-remain-open', type: Boolean })\n shouldRemainOpen = false;\n\n @property({ attribute: 'appid', reflect: true })\n appId;\n\n @property({ attribute: 'scope-label', reflect: true })\n scopeLabel;\n\n @property({ attribute: 'scope-value', reflect: true })\n scopeValue;\n\n /**\n * The `<button>` to open the search box.\n */\n @query(`.${prefix}--header__search--search`)\n private _searchButtonNode!: HTMLButtonElement;\n\n /**\n * The `<button>` to open the search box.\n */\n @query(`.${prefix}--header__search--close`)\n private _closeButtonNode!: HTMLButtonElement;\n\n /**\n * The `<input>` of the search box.\n */\n @query(`.${prefix}--header__search--input`)\n private _searchInputNode!: HTMLInputElement;\n\n /**\n * The `<ul>` containing the search suggestions.\n */\n @query(`.react-autosuggest__suggestions-list`)\n private _searchSuggestions!: HTMLElement;\n\n /**\n * Handles hiding search suggestions if focusing on other buttons.\n *\n * @param event The event.\n */\n @HostListener('shadowRoot:focusin')\n // @ts-ignore: The decorator refers to this method but TS thinks this method is not referred to\n private _handleFocus = async ({ target }: FocusEvent) => {\n if (!this._searchSuggestions) return;\n\n if (target === this._searchInputNode) {\n this._searchSuggestions.removeAttribute('hidden');\n } else if (target === (this._searchButtonNode || this._closeButtonNode)) {\n this._searchSuggestions.setAttribute('hidden', '');\n }\n\n if (target === this._closeButtonNode) {\n this.setAttribute('unfocused', '');\n } else {\n this.removeAttribute('unfocused');\n }\n };\n\n /**\n * Handles `click` event on the close button.\n */\n private async _handleClickCloseButton() {\n if (this.leadspaceSearch) {\n this._closeButtonNode?.classList.add(`${prefix}--header__search--hide`);\n }\n this._handleUserInitiatedToggleActiveState(false);\n }\n\n /**\n * Handles `click` event on the top-level element in the shadow DOM.\n *\n * @param event The event.\n */\n protected _handleClickInner(event: MouseEvent) {\n if (\n (event.target as HTMLElement).closest('.bx--header__search--input') ===\n event.target\n ) {\n this._handleUserInitiatedToggle();\n if (this._searchInputNode.value && this.leadspaceSearch) {\n this._closeButtonNode?.classList.remove(\n `${prefix}--header__search--hide`\n );\n }\n } else {\n const item = (event.target as Element).closest(\n (this.constructor as typeof BXDropdown).selectorItem\n ) as BXDropdownItem;\n if (this.shadowRoot!.contains(item) && !item.hasAttribute('groupTitle')) {\n this._handleUserInitiatedSelectItem(item);\n }\n }\n }\n\n /**\n * Handles `click` event on the search button.\n */\n private async _handleClickSearchButton() {\n const { active } = this;\n\n if (active) {\n if (this._searchInputNode.value) {\n this._handleUserInitiatedRedirect();\n }\n } else {\n this._handleUserInitiatedToggleActiveState(true);\n }\n }\n\n /**\n * Handles user-initiated toggling of activated state of the search box.\n *\n * @param active `true` to activate the search box.\n * @param moveFocus\n * `true` to move focus upon toggling, to the input box when activated, to the trigger button when deactivated.\n */\n private async _handleUserInitiatedToggleActiveState(\n active,\n moveFocus = true\n ) {\n if (active === this.active) {\n return;\n }\n const { _searchInputNode: searchInputNode } = this;\n const { eventInput, eventToggle } = this\n .constructor as typeof DDSSearchWithTypeahead;\n if (!active && searchInputNode.value) {\n searchInputNode.value = '';\n this.dispatchEvent(\n new CustomEvent(eventInput, {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail: {\n value: '',\n },\n })\n );\n }\n this.active = this.shouldRemainOpen ? true : !this.active;\n this.searchResults = [];\n this.groupedResults = [];\n\n this.dispatchEvent(\n new CustomEvent(eventToggle, {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail: {\n active,\n },\n })\n );\n await this.updateComplete;\n if (moveFocus) {\n // Does not reuse destructed `searchInputNode` given it's `null` before expanded\n (this.active ? this._searchInputNode : this._searchButtonNode).focus();\n }\n }\n\n /**\n * Prevents key types in the `<input>` causing other keyboard shortcuts in application UI.\n *\n * @param event The event.\n */\n private _handleKeyInput(event: KeyboardEvent) {\n if (\n (this.constructor as typeof DDSSearchWithTypeahead).getAction(\n event.key\n ) === DROPDOWN_KEYBOARD_ACTION.NONE\n ) {\n event.stopPropagation();\n }\n }\n\n /**\n * Handles user-initiated redirect to the search query page.\n *\n * @param [options] The options.\n * @param [options.targetQuery] The query string the search query page should be of.\n * @param [options.targetHref] The href string to be redirected to.\n */\n private _handleUserInitiatedRedirect({\n targetQuery,\n targetHref,\n }: { targetQuery?: string; targetHref?: string } = {}) {\n const { eventBeforeRedirect, eventInput } = this\n .constructor as typeof DDSSearchWithTypeahead;\n const { language, redirectUrl } = this;\n const [primary, country] = language.split('-');\n const tokens = redirectUrl.split('?');\n const base = tokens.shift();\n const searchParams = new URLSearchParams(tokens.join('?'));\n // Setting `this._searchInputNode?.value` as the default value of `targetQuery` seems to cause a Babel bug\n searchParams.append('q', targetQuery ?? this._searchInputNode?.value);\n searchParams.append('lang', primary);\n searchParams.append('cc', country);\n\n this.dispatchEvent(\n new CustomEvent(eventInput, {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail: {\n value: targetQuery,\n },\n })\n );\n\n if (this.appId) {\n searchParams.append('scope-domain', 'scope');\n searchParams.append('scope-value', this.scopeValue);\n searchParams.append('scope-type', this.appId);\n\n if (this.scopeLabel) {\n searchParams.append('scope-label', this.scopeLabel ?? '');\n }\n }\n\n const redirectUrlWithSearch = targetHref\n ? `${targetHref}`\n : `${base}?${searchParams.toString()}`;\n if (\n this.dispatchEvent(\n new CustomEvent(eventBeforeRedirect, {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail: {\n redirectUrl: redirectUrlWithSearch,\n },\n })\n )\n ) {\n this._redirect(redirectUrlWithSearch);\n }\n }\n\n /**\n * Handles component reset if focusing outside.\n *\n * @param event The event.\n */\n @HostListener('focusout')\n // @ts-ignore: The decorator refers to this method but TS thinks this method is not referred to\n protected _handleFocusOut(event: FocusEvent) {\n super._handleFocusOut(event);\n }\n\n /**\n * Handles search results when using a custom API.\n *\n * @param event The event.\n */\n @HostListener('document:eventCustomResults')\n protected _handleCustomResults = (event: CustomEvent) => {\n if (this.customTypeaheadAPI) {\n [this.searchResults] = event.detail;\n this.groupedResults = event.detail.slice(1);\n }\n };\n\n /**\n * Queries scoped search suggestions.\n *\n * @param event The event.\n */\n @HostListener('document:eventSelectScope')\n protected _handleScopeSelect = (event: CustomEvent) => {\n this.appId = event.detail.appId;\n let targetScope;\n this.scopeParameters.forEach((scope) => {\n if (scope.appId === this.appId) {\n targetScope = scope;\n }\n });\n\n this.scopeValue = Array.isArray(targetScope?.value)\n ? `[${targetScope.value\n .toString()\n .split(',')\n .map((word) => `\"${word.trim()}\"`)\n .join(',')}]`\n : targetScope.value;\n this.scopeLabel = targetScope.label ?? '';\n };\n\n /**\n * Handles `input` event in the search input.\n */\n private _handleInput(event: InputEvent) {\n const { target } = event;\n const { value } = target as HTMLInputElement;\n this.removeAttribute('unfocused');\n\n const items = this.shadowRoot!.querySelectorAll(\n (this.constructor as typeof BXDropdown).selectorItem\n );\n items.forEach((e) => {\n if (e.hasAttribute('highlighted')) {\n this.setAttribute('unfocused', '');\n }\n });\n\n this.dispatchEvent(\n new CustomEvent(\n (this.constructor as typeof DDSSearchWithTypeahead).eventInput,\n {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail: {\n value,\n },\n }\n )\n );\n this.value = value;\n\n if (!this.customTypeaheadAPI) {\n this.getResults(value).then((res) => {\n this.searchResults = res;\n });\n }\n\n if (value) {\n this.open = true;\n if (this.leadspaceSearch)\n this._closeButtonNode?.classList.remove(\n `${prefix}--header__search--hide`\n );\n }\n\n // accomodate search results box's width with the scope dropdown\n if (\n gridBreakpoint < document.body.clientWidth &&\n this._searchSuggestions &&\n this.scopeParameters\n ) {\n const scopeBarWidth = (\n this.shadowRoot?.querySelector(\n 'dds-scoped-search-dropdown'\n ) as HTMLElement\n ).offsetWidth;\n (this._searchSuggestions?.parentElement as HTMLElement)?.setAttribute(\n 'style',\n `left: ${scopeBarWidth}px; width: calc(100% - ${scopeBarWidth}px);`\n );\n } else {\n (this._searchSuggestions?.parentElement as HTMLElement)?.removeAttribute(\n 'style'\n );\n }\n }\n\n /**\n * Prevents form submission if there is a highlighted item.\n * In such case, `._handleUserInitiatedRedirect()` should have navigated the user to the search result page.\n *\n * @param event The event.\n */\n private _handleSubmit(event: Event) {\n const { eventBeforeRedirect } = this\n .constructor as typeof DDSSearchWithTypeahead;\n const { selectorItemHighlighted } = this.constructor as typeof BXDropdown;\n const highlightedItem = this.shadowRoot!.querySelector(\n selectorItemHighlighted\n ) as BXDropdownItem;\n if (highlightedItem || !this._searchInputNode.value) {\n event.preventDefault();\n }\n if (\n !this.dispatchEvent(\n new CustomEvent(eventBeforeRedirect, {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail: {\n redirectUrl: this.redirectUrl,\n },\n })\n )\n ) {\n event.preventDefault();\n }\n }\n\n protected _handleUserInitiatedSelectItem(item?: BXDropdownItem) {\n if (item) {\n this._searchInputNode.value = (item as unknown as any).text;\n this._handleUserInitiatedRedirect({\n targetQuery: (item as unknown as any).text,\n targetHref: (item as unknown as any).href,\n });\n }\n }\n\n /**\n * Handler for the `keypress` event on the top-level element in the shadow DOM.\n */\n protected _handleKeypressInner(event: KeyboardEvent) {\n const { key } = event;\n const action = (this.constructor as typeof BXDropdown).getAction(key);\n if (!this.open) {\n switch (action) {\n case DROPDOWN_KEYBOARD_ACTION.TRIGGERING:\n this._handleUserInitiatedToggle(true);\n break;\n default:\n break;\n }\n } else {\n switch (action) {\n case DROPDOWN_KEYBOARD_ACTION.TRIGGERING:\n {\n const constructor = this.constructor as typeof BXDropdown;\n const highlightedItem = this.shadowRoot!.querySelector(\n constructor.selectorItemHighlighted\n ) as BXDropdownItem;\n if (highlightedItem) {\n this._handleUserInitiatedSelectItem(highlightedItem);\n } else {\n this._handleUserInitiatedToggle(false);\n }\n }\n break;\n default:\n break;\n }\n }\n }\n\n /**\n * Redirects the page to the given target.\n *\n * @param target The target URL.\n */\n private _redirect(target) {\n this.ownerDocument!.defaultView!.location.assign(target);\n }\n\n /**\n * Navigate through dropdown items.\n *\n * @param direction `-1` to navigate backward, `1` to navigate forward.\n */\n protected _navigate(direction: number) {\n const constructor = this.constructor as typeof DDSSearchWithTypeahead;\n const items = this.shadowRoot!.querySelectorAll(constructor.selectorItem);\n const highlightedItem = this.shadowRoot!.querySelector(\n constructor.selectorItemHighlighted\n );\n const highlightedIndex = indexOf(items, highlightedItem!);\n let nextIndex = highlightedIndex + direction;\n\n if (items[nextIndex] && items[nextIndex].hasAttribute('groupTitle')) {\n nextIndex += direction;\n }\n\n if (nextIndex < 0) {\n nextIndex = items.length - 1;\n }\n if (nextIndex >= items.length) {\n nextIndex = 0;\n }\n forEach(items, (item, i) => {\n (item as BXDropdownItem).highlighted = i === nextIndex;\n });\n\n this.setAttribute('unfocused', '');\n\n const nextItem = items[nextIndex];\n // Using `{ block: 'nearest' }` to prevent scrolling unless scrolling is absolutely necessary.\n // `scrollIntoViewOptions` seems to work in latest Safari despite of MDN/caniuse table.\n // IE falls back to the old behavior.\n nextItem.scrollIntoView({ block: 'nearest' });\n\n // @ts-ignore: TS does not believe nextItem has a text object\n const nextItemText = nextItem.text;\n if (nextItemText) {\n this._assistiveStatusText = nextItemText;\n }\n this.requestUpdate();\n }\n\n /**\n * @returns The main content of the trigger button.\n */\n protected _renderTriggerContent() {\n const {\n searchPlaceholder,\n searchLabel,\n _handleInput: handleInput,\n _handleKeyInput: handleKeyInput,\n } = this;\n return html`\n <input\n type=\"text\"\n part=\"search-input\"\n class=\"${prefix}--header__search--input\"\n name=\"q\"\n placeholder=\"${searchPlaceholder}\"\n autocomplete=\"off\"\n aria-controls=\"result-list\"\n aria-autocomplete=\"list\"\n aria-label=\"${ifNonNull(searchLabel)}\"\n @input=\"${handleInput}\"\n @keydown=\"${handleKeyInput}\"\n @keypress=\"${handleKeyInput}\" />\n `;\n }\n\n /**\n * Handles `click` event to redirect based on selected item.\n *\n * @param event The event.\n */\n protected _handleClickItem(event: MouseEvent) {\n const item = (event.target as Element).closest(\n (this.constructor as typeof BXDropdown).selectorItem\n ) as BXDropdownItem;\n if (this.shadowRoot!.contains(item)) {\n this._handleUserInitiatedSelectItem(item);\n }\n }\n\n /**\n * @returns The content of the search box.\n */\n private _renderForm() {\n const {\n active,\n language,\n open,\n redirectUrl,\n searchLabel,\n _assistiveStatusText: assistiveStatusText,\n _handleClickInner: handleClickInner,\n _handleKeydownInner: handleKeydownInner,\n _handleKeypressInner: handleKeypressInner,\n _handleSubmit: handleSubmit,\n } = this;\n if (!active) {\n return undefined;\n }\n const [primary, country] = language.split('-');\n const classes = classMap({\n 'react-autosuggest__container': true,\n 'react-autosuggest__suggestions-container--open': open,\n });\n return html`\n <form\n role=\"search\"\n method=\"get\"\n action=\"${redirectUrl}\"\n @submit=\"${handleSubmit}\">\n <input type=\"hidden\" name=\"lang\" value=\"${primary}\" />\n <input type=\"hidden\" name=\"cc\" value=\"${country}\" />\n <input type=\"hidden\" name=\"lnk\" value=\"mhsrch\" />\n ${this.scopeParameters\n ? html`\n <input type=\"hidden\" name=\"scope-domain\" value=\"scope\" />\n <input type=\"hidden\" name=\"scope-type\" value=\"${this.appId}\" />\n <input\n type=\"hidden\"\n name=\"scope-value\"\n value=\"${this.scopeValue}\" />\n <input\n type=\"hidden\"\n name=\"scope-label\"\n value=\"${this.scopeLabel}\" />\n `\n : ''}\n\n <div\n role=\"combobox\"\n class=\"${classes}\"\n aria-haspopup=\"listbox\"\n aria-owns=\"result-list\"\n aria-expanded=\"${Boolean(this.active)}\"\n aria-label=\"${ifNonNull(searchLabel)}\"\n @click=${handleClickInner}\n @keydown=\"${handleKeydownInner}\"\n @keypress=\"${handleKeypressInner}\">\n ${this.scopeParameters\n ? html`\n <dds-scoped-search-dropdown value=\"${this.appId}\">\n ${this.scopeParameters.map(\n (scope) => html`\n <bx-dropdown-item value=\"${scope.appId}\"\n >${scope.name}</bx-dropdown-item\n >\n `\n )}\n </dds-scoped-search-dropdown>\n\n <dds-scoped-search-dropdown-mobile value=\"${this.appId}\">\n ${this.scopeParameters.map(\n (scope) => html`\n <bx-select-item\n label=\"${scope.name}\"\n value=\"${scope.appId}\"\n >${scope.name}</bx-select-item\n >\n `\n )}\n </dds-scoped-search-dropdown-mobile>\n `\n : ``}\n ${this._renderTriggerContent()}\n ${!this.leadspaceSearch\n ? html`\n <div\n id=\"result-list\"\n class=\"react-autosuggest__suggestions-container\">\n <ul\n role=\"listbox\"\n class=\"${ddsPrefix}-ce__search__list react-autosuggest__suggestions-list\">\n ${this.searchResults &&\n this.searchResults.map(\n (item) =>\n html`\n <dds-search-with-typeahead-item\n text=\"${item}\"></dds-search-with-typeahead-item>\n `\n )}\n ${this.groupedResults &&\n this.groupedResults.map(\n (group) =>\n html`\n <dds-search-with-typeahead-item\n groupTitle\n text=\"${group.title}\"></dds-search-with-typeahead-item>\n ${group.items.map(\n (item) =>\n html`\n <dds-search-with-typeahead-item\n text=\"${item.name}\"\n href=\"${item.href}\"></dds-search-with-typeahead-item>\n `\n )}\n `\n )}\n </ul>\n </div>\n `\n : ``}\n </div>\n </form>\n <div\n class=\"${prefix}--assistive-text\"\n role=\"status\"\n aria-live=\"assertive\"\n aria-relevant=\"additions text\">\n ${assistiveStatusText}\n </div>\n `;\n }\n\n /**\n * @returns `true` if the selection of this dropdown should change if the given item is selected upon user interaction.\n */\n // eslint-disable-next-line class-methods-use-this\n protected _selectionShouldChange() {\n return true;\n }\n\n /**\n * `true` if this the search box should represent its active state.\n */\n @property({ type: Boolean, reflect: true })\n active = false;\n\n /**\n * The assistive text for the button to close the search box.\n */\n @property({ attribute: 'close-search-button-assistive-text' })\n closeSearchButtonAssistiveText = 'Clear input';\n\n /**\n * The language embedded in the inner form.\n */\n @property()\n language = 'en-US';\n\n /**\n * The assistive text for the button to open the search box.\n */\n @property({ attribute: 'open-search-button-assistive-text' })\n openSearchButtonAssistiveText = 'Open IBM search field';\n\n /**\n * The assistive text for the button to perform search.\n */\n @property({ attribute: 'perform-search-button-assistive-text' })\n performSearchButtonAssistiveText = 'Search all of IBM';\n\n /**\n * Value to display when the input has an empty `value`.\n */\n @property()\n searchPlaceholder = 'Search all of IBM';\n\n /**\n * The redirect URL when a user selects a search suggestion.\n */\n @property({ attribute: 'redirect-url' })\n redirectUrl = 'https://www.ibm.com/search?lnk=mhsrch';\n\n /**\n * The `aria-label` attribute for the search input.\n */\n @property({ attribute: 'search-label' })\n searchLabel = 'IBM search field';\n\n /**\n * The shadow slot this search UI should be in.\n */\n @property({ reflect: true })\n slot = 'search';\n\n /**\n * `true` to activate the search box on page load.\n */\n @property({ type: Boolean, attribute: 'search-open-on-load' })\n searchOpenOnload = false;\n\n /**\n * The input value.\n */\n get searchQueryString() {\n return this._searchInputNode?.value ?? '';\n }\n\n /**\n * Returns query param `q` for search input if exists. Only available when searchOpenOnload is `true`\n */\n private _setSearchParam() {\n const { _searchInputNode: searchInputNode } = this;\n const URLParams = new URLSearchParams(\n this.ownerDocument!.defaultView!.location.search\n );\n const searchParam: any = this.searchOpenOnload ? URLParams.get('q') : '';\n if (searchParam) {\n searchInputNode.value = searchParam;\n }\n }\n\n firstUpdated() {\n this._setSearchParam();\n if (this.leadspaceSearch) {\n this.setAttribute('should-remain-open', '');\n this.setAttribute('active', '');\n }\n\n if (!this.appId && this.scopeParameters) {\n this.appId = 'all';\n this.redirectUrl = 'https://www.ibm.com/search/scoped';\n }\n }\n\n updated(changedProperties) {\n if (changedProperties.has('searchResults')) {\n const titleElements = this.shadowRoot?.querySelectorAll(\n 'dds-search-with-typeahead-item[groupTitle]'\n );\n titleElements?.forEach((e) => {\n e.previousElementSibling?.setAttribute('lastBeforeGroup', '');\n });\n }\n\n if (changedProperties.has('appId')) {\n if (\n gridBreakpoint < document.body.clientWidth &&\n this._searchSuggestions &&\n this.scopeParameters\n ) {\n const scopeBarWidth = (\n this.shadowRoot?.querySelector(\n 'dds-scoped-search-dropdown'\n ) as HTMLElement\n ).offsetWidth;\n (this._searchSuggestions?.parentElement as HTMLElement)?.setAttribute(\n 'style',\n `left: ${scopeBarWidth}px; width: calc(100% - ${scopeBarWidth}px);`\n );\n } else {\n (\n this._searchSuggestions?.parentElement as HTMLElement\n )?.removeAttribute('style');\n }\n\n if (!this.customTypeaheadAPI) {\n this.getResults(this.value).then((res) => {\n this.searchResults = res;\n });\n }\n\n const newPlaceholder = this.placeholderFormatter({\n appId: this.scopeParameters.filter(\n (e) => e.value === `${this.appId}`\n )[0]?.name,\n });\n this.setAttribute('placeholder', newPlaceholder);\n this.performSearchButtonAssistiveText = newPlaceholder;\n }\n }\n\n render() {\n const {\n active,\n closeSearchButtonAssistiveText,\n openSearchButtonAssistiveText,\n performSearchButtonAssistiveText,\n _handleClickCloseButton: handleClickCloseButton,\n _handleClickSearchButton: handleClickSearchButton,\n _handleClickItem: handleClickItem,\n } = this;\n const searchButtonAssistiveText = !active\n ? openSearchButtonAssistiveText\n : performSearchButtonAssistiveText;\n return html`\n ${!this.leadspaceSearch\n ? html`\n ${this._renderForm()}\n <div class=\"${prefix}--header__search--actions\">\n <button\n type=\"button\"\n part=\"open-button\"\n class=\"${prefix}--header__action ${prefix}--header__search--search\"\n aria-label=\"${searchButtonAssistiveText}\"\n @click=\"${handleClickSearchButton}\">\n ${Search20()}\n </button>\n <button\n type=\"button\"\n part=\"close-button\"\n class=\"${prefix}--header__action ${prefix}--header__search--close\"\n aria-label=\"${closeSearchButtonAssistiveText}\"\n @click=\"${handleClickCloseButton}\">\n ${Close20()}\n </button>\n </div>\n `\n : html`\n <div class=\"${prefix}--header__search--actions\">\n ${Search20({\n part: 'search-icon',\n class: `${prefix}--search-magnifier-icon`,\n role: 'img',\n })}\n ${this._renderForm()}\n <button\n type=\"button\"\n part=\"close-button\"\n class=\"${prefix}--header__action ${prefix}--header__search--close ${this\n .value.length === 0\n ? `${prefix}--header__search--hide`\n : ''}\"\n aria-label=\"${closeSearchButtonAssistiveText}\"\n @click=\"${handleClickCloseButton}\">\n ${Close20()}\n </button>\n </div>\n <div\n id=\"result-list\"\n class=\"react-autosuggest__suggestions-container\">\n <ul\n role=\"listbox\"\n class=\"${ddsPrefix}-ce__search__list react-autosuggest__suggestions-list\">\n ${this.searchResults &&\n this.searchResults.map(\n (item) =>\n html`\n <dds-search-with-typeahead-item\n text=\"${item}\"\n @click=${handleClickItem}></dds-search-with-typeahead-item>\n `\n )}\n </ul>\n </div>\n `}\n `;\n }\n\n /**\n * A selector that will return highlighted search result items.\n */\n static get selectorItemHighlighted() {\n return `${ddsPrefix}-search-with-typeahead-item[highlighted]`;\n }\n\n /**\n * A selector that will return search result items.\n */\n static get selectorItem() {\n return `${ddsPrefix}-search-with-typeahead-item`;\n }\n\n /**\n * The name of the custom event fired before the page is being redirected to the search result page.\n * Cancellation of this event stops the user-initiated action of redirection.\n */\n static get eventBeforeRedirect() {\n return `${ddsPrefix}-search-with-typeahead-beingredirected`;\n }\n\n /**\n * The name of the custom event fired after the search content is changed upon a user gesture.\n */\n static get eventInput() {\n return `${ddsPrefix}-search-with-typeahead-input`;\n }\n\n /**\n * The name of the custom event captured to retrieve the new search scope.\n */\n static get eventSelectScope() {\n return `${prefix}-select-selected`;\n }\n\n /**\n * The name of the custom event captured to retrieve the custom typeahead API results.\n */\n static get eventCustomResults() {\n return `${ddsPrefix}-custom-typeahead-api-results`;\n }\n\n /**\n * The name of the custom event fired after this search box is toggled upon a user gesture.\n */\n static get eventToggle() {\n return `${ddsPrefix}-search-with-typeahead-toggled`;\n }\n\n static get stableSelector() {\n return `${ddsPrefix}--search-with-typeahead`;\n }\n\n static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader\n}\n\n/* @__GENERATE_REACT_CUSTOM_ELEMENT_TYPE__ */\nexport default DDSSearchWithTypeahead;\n"]}
1
+ {"version":3,"sources":["components/search-with-typeahead/search-with-typeahead.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,UAEN,MAAM,8EAA8E,CAAC;AACtF,OAAO,cAAc,MAAM,mFAAmF,CAAC;AAS/G,OAAO,8BAA8B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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WAAW,SAA2C;IAEtD;;OAEG;IAEH,WAAW,SAAsB;IAEjC;;OAEG;IAEH,IAAI,SAAY;IAEhB;;OAEG;IAEH,gBAAgB,UAAS;IAEzB;;OAEG;IACH,IAAI,iBAAiB,WAEpB;IAED;;OAEG;IACH,OAAO,CAAC,eAAe;IAWvB,YAAY;IAaZ,OAAO,CAAC,iBAAiB,KAAA;IA+CzB,MAAM;IA6EN;;OAEG;IACH,MAAM,KAAK,uBAAuB,WAEjC;IAED;;OAEG;IACH,MAAM,KAAK,YAAY,WAEtB;IAED;;;OAGG;IACH,MAAM,KAAK,mBAAmB,WAE7B;IAED;;OAEG;IACH,MAAM,KAAK,UAAU,WAEpB;IAED;;OAEG;IACH,MAAM,KAAK,gBAAgB,WAE1B;IAED;;OAEG;IACH,MAAM,KAAK,kBAAkB,WAE5B;IAED;;OAEG;IACH,MAAM,KAAK,WAAW,WAErB;IAED,MAAM,KAAK,cAAc,WAExB;IAED,MAAM,CAAC,MAAM,MAAU;CACxB;AAGD,eAAe,sBAAsB,CAAC","file":"search-with-typeahead.d.ts","sourcesContent":["/**\n * @license\n *\n * Copyright IBM Corp. 2019, 2023\n *\n * This source code is licensed under the Apache-2.0 license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport ifNonNull from '../../internal/vendor/@carbon/web-components/globals/directives/if-non-null.js';\nimport { classMap } from 'lit-html/directives/class-map.js';\nimport { html, property, query } from 'lit-element';\nimport settings from 'carbon-components/es/globals/js/settings.js';\nimport Close20 from '../../internal/vendor/@carbon/web-components/icons/close/20.js';\nimport Search20 from '../../internal/vendor/@carbon/web-components/icons/search/20.js';\nimport BXDropdown, {\n DROPDOWN_KEYBOARD_ACTION,\n} from '../../internal/vendor/@carbon/web-components/components/dropdown/dropdown.js';\nimport BXDropdownItem from '../../internal/vendor/@carbon/web-components/components/dropdown/dropdown-item.js';\nimport HostListener from '../../internal/vendor/@carbon/web-components/globals/decorators/host-listener.js';\nimport HostListenerMixin from '../../internal/vendor/@carbon/web-components/globals/mixins/host-listener.js';\nimport { baseFontSize, breakpoints } from '@carbon/layout';\nimport ddsSettings from '../../internal/vendor/@carbon/ibmdotcom-utilities/utilities/settings/settings';\nimport SearchTypeaheadAPI from '../../internal/vendor/@carbon/ibmdotcom-services/services/SearchTypeahead/SearchTypeahead';\nimport { forEach, indexOf } from '../../globals/internal/collection-helpers';\nimport styles from './search-with-typeahead.scss';\nimport StableSelectorMixin from '../../globals/mixins/stable-selector';\nimport './search-with-typeahead-item';\nimport { carbonElement as customElement } from '../../internal/vendor/@carbon/web-components/globals/decorators/carbon-element.js';\n\nconst { stablePrefix: ddsPrefix } = ddsSettings;\nconst { prefix } = settings;\nconst gridBreakpoint = parseFloat(breakpoints.lg.width) * baseFontSize;\n\n/**\n * Search with Typeahead\n *\n * @element dds-search-with-typeahead\n * @csspart open-button The button to show the search box.\n * @csspart close-button The button to hide the search box.\n * @csspart search-input The input box for search.\n * @fires dds-search-with-typeahead-beingredirected\n * The custom event fired before the page is being redirected to the search result page.\n * Cancellation of this event stops the user-initiated action of redirection.\n * @fires dds-search-with-typeahead-input\n * The name of the custom event fired after the search content is changed upon a user gesture.\n * @fires dds-search-with-typeahead-toggled\n * The name of the custom event fired after this search box is toggled upon a user gesture.\n */\n@customElement(`${ddsPrefix}-search-with-typeahead`)\nclass DDSSearchWithTypeahead extends HostListenerMixin(\n StableSelectorMixin(BXDropdown)\n) {\n // eslint-disable-next-line class-methods-use-this\n async getResults(searchQuery) {\n const response = await SearchTypeaheadAPI.getResults(\n searchQuery,\n this.appId\n );\n return response.map((res) => res[0]);\n }\n\n /**\n * The formatter for the placeholder text on the search box.\n * Should be changed upon the locale the UI is rendered with.\n */\n @property({ attribute: false })\n placeholderFormatter = ({ appId }) => `Search in ${appId}`;\n\n @property({ attribute: 'leadspace-search', type: Boolean })\n leadspaceSearch = false;\n\n @property({ attribute: 'custom-typeahead-api', type: Boolean })\n customTypeaheadAPI = false;\n\n @property()\n currentSearchResults;\n\n @property()\n searchResults;\n\n @property()\n groupedResults;\n\n @property({ attribute: 'scope-parameters' })\n scopeParameters;\n\n @property({ attribute: 'should-remain-open', type: Boolean })\n shouldRemainOpen = false;\n\n @property({ attribute: 'appid', reflect: true })\n appId;\n\n @property({ attribute: 'scope-label', reflect: true })\n scopeLabel;\n\n @property({ attribute: 'scope-value', reflect: true })\n scopeValue;\n\n /**\n * The `<button>` to open the search box.\n */\n @query(`.${prefix}--header__search--search`)\n private _searchButtonNode!: HTMLButtonElement;\n\n /**\n * The `<button>` to open the search box.\n */\n @query(`.${prefix}--header__search--close`)\n private _closeButtonNode!: HTMLButtonElement;\n\n /**\n * The `<input>` of the search box.\n */\n @query(`.${prefix}--header__search--input`)\n private _searchInputNode!: HTMLInputElement;\n\n /**\n * The `<ul>` containing the search suggestions.\n */\n @query(`.react-autosuggest__suggestions-list`)\n private _searchSuggestions!: HTMLElement;\n\n /**\n * Handles hiding search suggestions if focusing on other buttons.\n *\n * @param event The event.\n */\n @HostListener('shadowRoot:focusin')\n // @ts-ignore: The decorator refers to this method but TS thinks this method is not referred to\n private _handleFocus = async ({ target }: FocusEvent) => {\n if (!this._searchSuggestions) return;\n\n if (target === this._searchInputNode) {\n this._searchSuggestions.removeAttribute('hidden');\n } else if (target === (this._searchButtonNode || this._closeButtonNode)) {\n this._searchSuggestions.setAttribute('hidden', '');\n }\n\n if (target === this._closeButtonNode) {\n this.setAttribute('unfocused', '');\n } else {\n this.removeAttribute('unfocused');\n }\n };\n\n /**\n * Handles `click` event on the close button.\n */\n private async _handleClickCloseButton() {\n if (this.leadspaceSearch) {\n this._closeButtonNode?.classList.add(`${prefix}--header__search--hide`);\n }\n this._handleUserInitiatedToggleActiveState(false);\n }\n\n /**\n * Handles `click` event on the top-level element in the shadow DOM.\n *\n * @param event The event.\n */\n protected _handleClickInner(event: MouseEvent) {\n if (\n (event.target as HTMLElement).closest('.bx--header__search--input') ===\n event.target\n ) {\n this._handleUserInitiatedToggle();\n if (this._searchInputNode.value && this.leadspaceSearch) {\n this._closeButtonNode?.classList.remove(\n `${prefix}--header__search--hide`\n );\n }\n } else {\n const item = (event.target as Element).closest(\n (this.constructor as typeof BXDropdown).selectorItem\n ) as BXDropdownItem;\n if (this.shadowRoot!.contains(item) && !item.hasAttribute('groupTitle')) {\n this._handleUserInitiatedSelectItem(item);\n }\n }\n }\n\n /**\n * Handles `click` event on the search button.\n */\n private async _handleClickSearchButton() {\n const { active } = this;\n\n if (active) {\n if (this._searchInputNode.value) {\n this._handleUserInitiatedRedirect();\n }\n } else {\n this._handleUserInitiatedToggleActiveState(true);\n }\n }\n\n /**\n * Handles user-initiated toggling of activated state of the search box.\n *\n * @param active `true` to activate the search box.\n * @param moveFocus\n * `true` to move focus upon toggling, to the input box when activated, to the trigger button when deactivated.\n */\n private async _handleUserInitiatedToggleActiveState(\n active,\n moveFocus = true\n ) {\n if (active === this.active) {\n return;\n }\n const { _searchInputNode: searchInputNode } = this;\n const { eventInput, eventToggle } = this\n .constructor as typeof DDSSearchWithTypeahead;\n if (!active && searchInputNode.value) {\n searchInputNode.value = '';\n this.dispatchEvent(\n new CustomEvent(eventInput, {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail: {\n value: '',\n },\n })\n );\n }\n this.active = this.shouldRemainOpen ? true : !this.active;\n this.searchResults = [];\n this.groupedResults = [];\n\n this.dispatchEvent(\n new CustomEvent(eventToggle, {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail: {\n active,\n },\n })\n );\n await this.updateComplete;\n if (moveFocus) {\n // Does not reuse destructed `searchInputNode` given it's `null` before expanded\n (this.active ? this._searchInputNode : this._searchButtonNode).focus();\n }\n }\n\n /**\n * Prevents key types in the `<input>` causing other keyboard shortcuts in application UI.\n *\n * @param event The event.\n */\n private _handleKeyInput(event: KeyboardEvent) {\n if (\n (this.constructor as typeof DDSSearchWithTypeahead).getAction(\n event.key\n ) === DROPDOWN_KEYBOARD_ACTION.NONE\n ) {\n event.stopPropagation();\n }\n }\n\n /**\n * Handles user-initiated redirect to the search query page.\n *\n * @param [options] The options.\n * @param [options.targetQuery] The query string the search query page should be of.\n * @param [options.targetHref] The href string to be redirected to.\n */\n private _handleUserInitiatedRedirect({\n targetQuery,\n targetHref,\n }: { targetQuery?: string; targetHref?: string } = {}) {\n const { eventBeforeRedirect, eventInput } = this\n .constructor as typeof DDSSearchWithTypeahead;\n const { language, redirectUrl } = this;\n const [primary, country] = language.split('-');\n const tokens = redirectUrl.split('?');\n const base = tokens.shift();\n const searchParams = new URLSearchParams(tokens.join('?'));\n // Setting `this._searchInputNode?.value` as the default value of `targetQuery` seems to cause a Babel bug\n searchParams.append('q', targetQuery ?? this._searchInputNode?.value);\n searchParams.append('lang', primary);\n searchParams.append('cc', country);\n\n this.dispatchEvent(\n new CustomEvent(eventInput, {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail: {\n value: targetQuery,\n },\n })\n );\n\n if (this.appId) {\n searchParams.append('scope-domain', 'scope');\n searchParams.append('scope-value', this.scopeValue);\n searchParams.append('scope-type', this.appId);\n\n if (this.scopeLabel) {\n searchParams.append('scope-label', this.scopeLabel ?? '');\n }\n }\n\n const redirectUrlWithSearch = targetHref\n ? `${targetHref}`\n : `${base}?${searchParams.toString()}`;\n if (\n this.dispatchEvent(\n new CustomEvent(eventBeforeRedirect, {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail: {\n redirectUrl: redirectUrlWithSearch,\n },\n })\n )\n ) {\n this._redirect(redirectUrlWithSearch);\n }\n }\n\n /**\n * Handles component reset if focusing outside.\n *\n * @param event The event.\n */\n @HostListener('focusout')\n // @ts-ignore: The decorator refers to this method but TS thinks this method is not referred to\n protected _handleFocusOut(event: FocusEvent) {\n super._handleFocusOut(event);\n }\n\n /**\n * Handles search results when using a custom API.\n *\n * @param event The event.\n */\n @HostListener('document:eventCustomResults')\n protected _handleCustomResults = (event: CustomEvent) => {\n if (this.customTypeaheadAPI) {\n [this.searchResults] = event.detail;\n this.groupedResults = event.detail.slice(1);\n }\n };\n\n /**\n * Queries scoped search suggestions.\n *\n * @param event The event.\n */\n @HostListener('document:eventSelectScope')\n protected _handleScopeSelect = (event: CustomEvent) => {\n this.appId = event.detail.appId;\n let targetScope;\n this.scopeParameters.forEach((scope) => {\n if (scope.appId === this.appId) {\n targetScope = scope;\n }\n });\n\n this.scopeValue = Array.isArray(targetScope?.value)\n ? `[${targetScope.value\n .toString()\n .split(',')\n .map((word) => `\"${word.trim()}\"`)\n .join(',')}]`\n : targetScope.value;\n this.scopeLabel = targetScope.label ?? '';\n };\n\n /**\n * Handles `input` event in the search input.\n */\n private _handleInput(event: InputEvent) {\n const { target } = event;\n const { value } = target as HTMLInputElement;\n this.removeAttribute('unfocused');\n\n const items = this.shadowRoot!.querySelectorAll(\n (this.constructor as typeof BXDropdown).selectorItem\n );\n items.forEach((e) => {\n if (e.hasAttribute('highlighted')) {\n this.setAttribute('unfocused', '');\n }\n });\n\n this.dispatchEvent(\n new CustomEvent(\n (this.constructor as typeof DDSSearchWithTypeahead).eventInput,\n {\n bubbles: true,\n composed: true,\n cancelable: false,\n detail: {\n value,\n },\n }\n )\n );\n this.value = value;\n\n if (!this.customTypeaheadAPI) {\n this.getResults(value).then((res) => {\n this.searchResults = res;\n });\n }\n\n if (value) {\n this.open = true;\n if (this.leadspaceSearch)\n this._closeButtonNode?.classList.remove(\n `${prefix}--header__search--hide`\n );\n }\n\n // accomodate search results box's width with the scope dropdown\n if (\n gridBreakpoint < document.body.clientWidth &&\n this._searchSuggestions &&\n this.scopeParameters\n ) {\n const scopeBarWidth = (\n this.shadowRoot?.querySelector(\n 'dds-scoped-search-dropdown'\n ) as HTMLElement\n ).offsetWidth;\n (this._searchSuggestions?.parentElement as HTMLElement)?.setAttribute(\n 'style',\n `left: ${scopeBarWidth}px; width: calc(100% - ${scopeBarWidth}px);`\n );\n } else {\n (this._searchSuggestions?.parentElement as HTMLElement)?.removeAttribute(\n 'style'\n );\n }\n }\n\n /**\n * Prevents form submission if there is a highlighted item.\n * In such case, `._handleUserInitiatedRedirect()` should have navigated the user to the search result page.\n *\n * @param event The event.\n */\n private _handleSubmit(event: Event) {\n const { eventBeforeRedirect } = this\n .constructor as typeof DDSSearchWithTypeahead;\n const { selectorItemHighlighted } = this.constructor as typeof BXDropdown;\n const highlightedItem = this.shadowRoot!.querySelector(\n selectorItemHighlighted\n ) as BXDropdownItem;\n if (highlightedItem || !this._searchInputNode.value) {\n event.preventDefault();\n }\n if (\n !this.dispatchEvent(\n new CustomEvent(eventBeforeRedirect, {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail: {\n redirectUrl: this.redirectUrl,\n },\n })\n )\n ) {\n event.preventDefault();\n }\n }\n\n protected _handleUserInitiatedSelectItem(item?: BXDropdownItem) {\n if (item) {\n this._searchInputNode.value = (item as unknown as any).text;\n this._handleUserInitiatedRedirect({\n targetQuery: (item as unknown as any).text,\n targetHref: (item as unknown as any).href,\n });\n }\n }\n\n /**\n * Handler for the `keypress` event on the top-level element in the shadow DOM.\n */\n protected _handleKeypressInner(event: KeyboardEvent) {\n const { key } = event;\n const action = (this.constructor as typeof BXDropdown).getAction(key);\n if (!this.open) {\n switch (action) {\n case DROPDOWN_KEYBOARD_ACTION.TRIGGERING:\n this._handleUserInitiatedToggle(true);\n break;\n default:\n break;\n }\n } else {\n switch (action) {\n case DROPDOWN_KEYBOARD_ACTION.TRIGGERING:\n {\n const constructor = this.constructor as typeof BXDropdown;\n const highlightedItem = this.shadowRoot!.querySelector(\n constructor.selectorItemHighlighted\n ) as BXDropdownItem;\n if (highlightedItem) {\n this._handleUserInitiatedSelectItem(highlightedItem);\n } else {\n this._handleUserInitiatedToggle(false);\n }\n }\n break;\n default:\n break;\n }\n }\n }\n\n /**\n * Redirects the page to the given target.\n *\n * @param target The target URL.\n */\n private _redirect(target) {\n this.ownerDocument!.defaultView!.location.assign(target);\n }\n\n /**\n * Navigate through dropdown items.\n *\n * @param direction `-1` to navigate backward, `1` to navigate forward.\n */\n protected _navigate(direction: number) {\n const constructor = this.constructor as typeof DDSSearchWithTypeahead;\n const items = this.shadowRoot!.querySelectorAll(constructor.selectorItem);\n const highlightedItem = this.shadowRoot!.querySelector(\n constructor.selectorItemHighlighted\n );\n const highlightedIndex = indexOf(items, highlightedItem!);\n let nextIndex = highlightedIndex + direction;\n\n if (items[nextIndex] && items[nextIndex].hasAttribute('groupTitle')) {\n nextIndex += direction;\n }\n\n if (nextIndex < 0) {\n nextIndex = items.length - 1;\n }\n if (nextIndex >= items.length) {\n nextIndex = 0;\n }\n forEach(items, (item, i) => {\n (item as BXDropdownItem).highlighted = i === nextIndex;\n });\n\n this.setAttribute('unfocused', '');\n\n const nextItem = items[nextIndex];\n // Using `{ block: 'nearest' }` to prevent scrolling unless scrolling is absolutely necessary.\n // `scrollIntoViewOptions` seems to work in latest Safari despite of MDN/caniuse table.\n // IE falls back to the old behavior.\n nextItem.scrollIntoView({ block: 'nearest' });\n\n // @ts-ignore: TS does not believe nextItem has a text object\n const nextItemText = nextItem.text;\n if (nextItemText) {\n this._assistiveStatusText = nextItemText;\n }\n this.requestUpdate();\n }\n\n /**\n * @returns The main content of the trigger button.\n */\n protected _renderTriggerContent() {\n const {\n searchPlaceholder,\n searchLabel,\n _handleInput: handleInput,\n _handleKeyInput: handleKeyInput,\n } = this;\n return html`\n <input\n type=\"text\"\n part=\"search-input\"\n class=\"${prefix}--header__search--input\"\n name=\"q\"\n placeholder=\"${searchPlaceholder}\"\n autocomplete=\"off\"\n aria-controls=\"result-list\"\n aria-autocomplete=\"list\"\n aria-label=\"${ifNonNull(searchLabel)}\"\n @input=\"${handleInput}\"\n @keydown=\"${handleKeyInput}\"\n @keypress=\"${handleKeyInput}\" />\n `;\n }\n\n /**\n * Handles `click` event to redirect based on selected item.\n *\n * @param event The event.\n */\n protected _handleClickItem(event: MouseEvent) {\n const item = (event.target as Element).closest(\n (this.constructor as typeof BXDropdown).selectorItem\n ) as BXDropdownItem;\n if (this.shadowRoot!.contains(item)) {\n this._handleUserInitiatedSelectItem(item);\n }\n }\n\n /**\n * @returns The content of the search box.\n */\n private _renderForm() {\n const {\n active,\n language,\n open,\n redirectUrl,\n searchLabel,\n _assistiveStatusText: assistiveStatusText,\n _handleClickInner: handleClickInner,\n _handleKeydownInner: handleKeydownInner,\n _handleKeypressInner: handleKeypressInner,\n _handleSubmit: handleSubmit,\n } = this;\n if (!active) {\n return undefined;\n }\n const [primary, country] = language.split('-');\n const classes = classMap({\n 'react-autosuggest__container': true,\n 'react-autosuggest__suggestions-container--open': open,\n });\n return html`\n <form\n role=\"search\"\n method=\"get\"\n action=\"${redirectUrl}\"\n @submit=\"${handleSubmit}\">\n <input type=\"hidden\" name=\"lang\" value=\"${primary}\" />\n <input type=\"hidden\" name=\"cc\" value=\"${country}\" />\n <input type=\"hidden\" name=\"lnk\" value=\"mhsrch\" />\n ${this.scopeParameters\n ? html`\n <input type=\"hidden\" name=\"scope-domain\" value=\"scope\" />\n <input type=\"hidden\" name=\"scope-type\" value=\"${this.appId}\" />\n <input\n type=\"hidden\"\n name=\"scope-value\"\n value=\"${this.scopeValue}\" />\n <input\n type=\"hidden\"\n name=\"scope-label\"\n value=\"${this.scopeLabel}\" />\n `\n : ''}\n\n <div\n role=\"combobox\"\n class=\"${classes}\"\n aria-haspopup=\"listbox\"\n aria-owns=\"result-list\"\n aria-expanded=\"${Boolean(this.active)}\"\n aria-label=\"${ifNonNull(searchLabel)}\"\n @click=${handleClickInner}\n @keydown=\"${handleKeydownInner}\"\n @keypress=\"${handleKeypressInner}\">\n ${this.scopeParameters\n ? html`\n <dds-scoped-search-dropdown value=\"${this.appId}\">\n ${this.scopeParameters.map(\n (scope) => html`\n <bx-dropdown-item value=\"${scope.appId}\"\n >${scope.name}</bx-dropdown-item\n >\n `\n )}\n </dds-scoped-search-dropdown>\n\n <dds-scoped-search-dropdown-mobile value=\"${this.appId}\">\n ${this.scopeParameters.map(\n (scope) => html`\n <bx-select-item\n label=\"${scope.name}\"\n value=\"${scope.appId}\"\n >${scope.name}</bx-select-item\n >\n `\n )}\n </dds-scoped-search-dropdown-mobile>\n `\n : ``}\n ${this._renderTriggerContent()}\n ${!this.leadspaceSearch\n ? html`\n <div\n id=\"result-list\"\n class=\"react-autosuggest__suggestions-container\">\n <ul\n role=\"listbox\"\n class=\"${ddsPrefix}-ce__search__list react-autosuggest__suggestions-list\">\n ${this.searchResults &&\n this.searchResults.map(\n (item) =>\n html`\n <dds-search-with-typeahead-item\n text=\"${item}\"></dds-search-with-typeahead-item>\n `\n )}\n ${this.groupedResults &&\n this.groupedResults.map(\n (group) =>\n html`\n <dds-search-with-typeahead-item\n groupTitle\n text=\"${group.title}\"></dds-search-with-typeahead-item>\n ${group.items.map(\n (item) =>\n html`\n <dds-search-with-typeahead-item\n text=\"${item.name}\"\n href=\"${item.href}\"></dds-search-with-typeahead-item>\n `\n )}\n `\n )}\n </ul>\n </div>\n `\n : ``}\n </div>\n </form>\n <div\n class=\"${prefix}--assistive-text\"\n role=\"status\"\n aria-live=\"assertive\"\n aria-relevant=\"additions text\">\n ${assistiveStatusText}\n </div>\n `;\n }\n\n /**\n * @returns `true` if the selection of this dropdown should change if the given item is selected upon user interaction.\n */\n // eslint-disable-next-line class-methods-use-this\n protected _selectionShouldChange() {\n return true;\n }\n\n /**\n * `true` if this the search box should represent its active state.\n */\n @property({ type: Boolean, reflect: true })\n active = false;\n\n /**\n * The assistive text for the button to close the search box.\n */\n @property({ attribute: 'close-search-button-assistive-text' })\n closeSearchButtonAssistiveText = 'Clear input';\n\n /**\n * The language embedded in the inner form.\n */\n @property()\n language = 'en-US';\n\n /**\n * The assistive text for the button to open the search box.\n */\n @property({ attribute: 'open-search-button-assistive-text' })\n openSearchButtonAssistiveText = 'Open IBM search field';\n\n /**\n * The assistive text for the button to perform search.\n */\n @property({ attribute: 'perform-search-button-assistive-text' })\n performSearchButtonAssistiveText = 'Search all of IBM';\n\n /**\n * Value to display when the input has an empty `value`.\n */\n @property({ attribute: 'placeholder', reflect: true })\n searchPlaceholder = 'Search all of IBM';\n\n /**\n * The redirect URL when a user selects a search suggestion.\n */\n @property({ attribute: 'redirect-url' })\n redirectUrl = 'https://www.ibm.com/search?lnk=mhsrch';\n\n /**\n * The `aria-label` attribute for the search input.\n */\n @property({ attribute: 'search-label' })\n searchLabel = 'IBM search field';\n\n /**\n * The shadow slot this search UI should be in.\n */\n @property({ reflect: true })\n slot = 'search';\n\n /**\n * `true` to activate the search box on page load.\n */\n @property({ type: Boolean, attribute: 'search-open-on-load' })\n searchOpenOnload = false;\n\n /**\n * The input value.\n */\n get searchQueryString() {\n return this._searchInputNode?.value ?? '';\n }\n\n /**\n * Returns query param `q` for search input if exists. Only available when searchOpenOnload is `true`\n */\n private _setSearchParam() {\n const { _searchInputNode: searchInputNode } = this;\n const URLParams = new URLSearchParams(\n this.ownerDocument!.defaultView!.location.search\n );\n const searchParam: any = this.searchOpenOnload ? URLParams.get('q') : '';\n if (searchParam) {\n searchInputNode.value = searchParam;\n }\n }\n\n firstUpdated() {\n this._setSearchParam();\n if (this.leadspaceSearch) {\n this.setAttribute('should-remain-open', '');\n this.setAttribute('active', '');\n }\n\n if (!this.appId && this.scopeParameters) {\n this.appId = 'all';\n this.redirectUrl = 'https://www.ibm.com/search/scoped';\n }\n }\n\n updated(changedProperties) {\n if (changedProperties.has('searchResults')) {\n const titleElements = this.shadowRoot?.querySelectorAll(\n 'dds-search-with-typeahead-item[groupTitle]'\n );\n titleElements?.forEach((e) => {\n e.previousElementSibling?.setAttribute('lastBeforeGroup', '');\n });\n }\n\n if (changedProperties.has('appId')) {\n if (\n gridBreakpoint < document.body.clientWidth &&\n this._searchSuggestions &&\n this.scopeParameters\n ) {\n const scopeBarWidth = (\n this.shadowRoot?.querySelector(\n 'dds-scoped-search-dropdown'\n ) as HTMLElement\n ).offsetWidth;\n (this._searchSuggestions?.parentElement as HTMLElement)?.setAttribute(\n 'style',\n `left: ${scopeBarWidth}px; width: calc(100% - ${scopeBarWidth}px);`\n );\n } else {\n (\n this._searchSuggestions?.parentElement as HTMLElement\n )?.removeAttribute('style');\n }\n\n if (!this.customTypeaheadAPI) {\n this.getResults(this.value).then((res) => {\n this.searchResults = res;\n });\n }\n\n const newPlaceholder = this.placeholderFormatter({\n appId: this.scopeParameters.filter(\n (e) => e.value === `${this.appId}`\n )[0]?.name,\n });\n this.setAttribute('placeholder', newPlaceholder);\n this.performSearchButtonAssistiveText = newPlaceholder;\n }\n }\n\n render() {\n const {\n active,\n closeSearchButtonAssistiveText,\n openSearchButtonAssistiveText,\n performSearchButtonAssistiveText,\n _handleClickCloseButton: handleClickCloseButton,\n _handleClickSearchButton: handleClickSearchButton,\n _handleClickItem: handleClickItem,\n } = this;\n const searchButtonAssistiveText = !active\n ? openSearchButtonAssistiveText\n : performSearchButtonAssistiveText;\n return html`\n ${!this.leadspaceSearch\n ? html`\n ${this._renderForm()}\n <div class=\"${prefix}--header__search--actions\">\n <button\n type=\"button\"\n part=\"open-button\"\n class=\"${prefix}--header__action ${prefix}--header__search--search\"\n aria-label=\"${searchButtonAssistiveText}\"\n @click=\"${handleClickSearchButton}\">\n ${Search20()}\n </button>\n <button\n type=\"button\"\n part=\"close-button\"\n class=\"${prefix}--header__action ${prefix}--header__search--close\"\n aria-label=\"${closeSearchButtonAssistiveText}\"\n @click=\"${handleClickCloseButton}\">\n ${Close20()}\n </button>\n </div>\n `\n : html`\n <div class=\"${prefix}--header__search--actions\">\n ${Search20({\n part: 'search-icon',\n class: `${prefix}--search-magnifier-icon`,\n role: 'img',\n })}\n ${this._renderForm()}\n <button\n type=\"button\"\n part=\"close-button\"\n class=\"${prefix}--header__action ${prefix}--header__search--close ${this\n .value.length === 0\n ? `${prefix}--header__search--hide`\n : ''}\"\n aria-label=\"${closeSearchButtonAssistiveText}\"\n @click=\"${handleClickCloseButton}\">\n ${Close20()}\n </button>\n </div>\n <div\n id=\"result-list\"\n class=\"react-autosuggest__suggestions-container\">\n <ul\n role=\"listbox\"\n class=\"${ddsPrefix}-ce__search__list react-autosuggest__suggestions-list\">\n ${this.searchResults &&\n this.searchResults.map(\n (item) =>\n html`\n <dds-search-with-typeahead-item\n text=\"${item}\"\n @click=${handleClickItem}></dds-search-with-typeahead-item>\n `\n )}\n </ul>\n </div>\n `}\n `;\n }\n\n /**\n * A selector that will return highlighted search result items.\n */\n static get selectorItemHighlighted() {\n return `${ddsPrefix}-search-with-typeahead-item[highlighted]`;\n }\n\n /**\n * A selector that will return search result items.\n */\n static get selectorItem() {\n return `${ddsPrefix}-search-with-typeahead-item`;\n }\n\n /**\n * The name of the custom event fired before the page is being redirected to the search result page.\n * Cancellation of this event stops the user-initiated action of redirection.\n */\n static get eventBeforeRedirect() {\n return `${ddsPrefix}-search-with-typeahead-beingredirected`;\n }\n\n /**\n * The name of the custom event fired after the search content is changed upon a user gesture.\n */\n static get eventInput() {\n return `${ddsPrefix}-search-with-typeahead-input`;\n }\n\n /**\n * The name of the custom event captured to retrieve the new search scope.\n */\n static get eventSelectScope() {\n return `${prefix}-select-selected`;\n }\n\n /**\n * The name of the custom event captured to retrieve the custom typeahead API results.\n */\n static get eventCustomResults() {\n return `${ddsPrefix}-custom-typeahead-api-results`;\n }\n\n /**\n * The name of the custom event fired after this search box is toggled upon a user gesture.\n */\n static get eventToggle() {\n return `${ddsPrefix}-search-with-typeahead-toggled`;\n }\n\n static get stableSelector() {\n return `${ddsPrefix}--search-with-typeahead`;\n }\n\n static styles = styles; // `styles` here is a `CSSResult` generated by custom WebPack loader\n}\n\n/* @__GENERATE_REACT_CUSTOM_ELEMENT_TYPE__ */\nexport default DDSSearchWithTypeahead;\n"]}
@@ -879,7 +879,10 @@ var DDSSearchWithTypeahead = (0, _decorate2["default"])([(0, _carbonElement.carb
879
879
  }
880
880
  }, {
881
881
  kind: "field",
882
- decorators: [(0, _litElement.property)()],
882
+ decorators: [(0, _litElement.property)({
883
+ attribute: 'placeholder',
884
+ reflect: true
885
+ })],
883
886
  key: "searchPlaceholder",
884
887
  value: function value() {
885
888
  return 'Search all of IBM';