@dintero/discounts-web-sdk 0.2.3 → 0.2.5

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 (38) hide show
  1. package/.github/workflows/build.yml +14 -10
  2. package/.github/workflows/release.yml +6 -6
  3. package/README.md +2 -2
  4. package/dist/declarations/src/index.d.ts +1 -1
  5. package/dist/dintero-discounts-web-sdk.cjs.d.ts +1 -0
  6. package/dist/dintero-discounts-web-sdk.cjs.d.ts.map +1 -0
  7. package/dist/dintero-discounts-web-sdk.cjs.dev.js +29 -101
  8. package/dist/dintero-discounts-web-sdk.cjs.prod.js +29 -101
  9. package/dist/dintero-discounts-web-sdk.esm.js +29 -101
  10. package/dist/dintero-discounts-web-sdk.umd.min.js +1 -1
  11. package/dist/dintero-discounts-web-sdk.umd.min.js.map +1 -1
  12. package/package.json +12 -18
  13. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/base.css +0 -224
  14. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/block-navigation.js +0 -87
  15. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/discounts.ts.html +0 -1093
  16. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/dom.ts.html +0 -310
  17. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/error.ts.html +0 -244
  18. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/favicon.png +0 -0
  19. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/fetch.ts.html +0 -385
  20. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/formatters.ts.html +0 -223
  21. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/index.html +0 -236
  22. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/index.ts.html +0 -436
  23. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/loading.ts.html +0 -214
  24. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/normalize.ts.html +0 -136
  25. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/prettify.css +0 -1
  26. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/prettify.js +0 -2
  27. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/sort-arrow-sprite.png +0 -0
  28. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/sorter.js +0 -196
  29. package/coverage/Chrome Headless 110.0.5478.0 (Linux x86_64)/html/translations.ts.html +0 -199
  30. package/dist/declarations/src/discounts.d.ts +0 -7
  31. package/dist/declarations/src/dom.d.ts +0 -15
  32. package/dist/declarations/src/error.d.ts +0 -2
  33. package/dist/declarations/src/fetch.d.ts +0 -2
  34. package/dist/declarations/src/formatters.d.ts +0 -7
  35. package/dist/declarations/src/loading.d.ts +0 -2
  36. package/dist/declarations/src/normalize.d.ts +0 -1
  37. package/dist/declarations/src/translations.d.ts +0 -25
  38. package/karma.conf.js +0 -33
@@ -1 +1 @@
1
- {"version":3,"file":"dintero-discounts-web-sdk.umd.min.js","sources":["../src/dom.ts","../src/translations.ts","../src/formatters.ts","../src/normalize.ts","../src/discounts.ts","../src/fetch.ts","../src/error.ts","../src/loading.ts","../src/index.ts"],"sourcesContent":["import { Theme } from './types';\n\ntype CreateElementOptions ={\n tag: string,\n attributes?: {[key: string]: any};\n styles?:((className:string, theme?: Theme) => string)[];\n handlers?:{[key: string]: EventListenerOrEventListenerObject};\n innerHTML?: string;\n theme?: Theme,\n}\n\nexport const createElement = (options: CreateElementOptions) => {\n const elem = document.createElement(options.tag);\n if (options.attributes) {\n addAttributes(elem, options.attributes)\n }\n if (options.handlers) {\n addEventListeners(elem, options.handlers)\n }\n if(options.styles){\n addStyles(elem, options.styles, options.theme);\n }\n if(options.innerHTML){\n elem.innerHTML = options.innerHTML;\n }\n return elem;\n};\n\nconst addClass = (elem:HTMLElement, className:string) => {\n const names = elem.className.split(\" \");\n if (!names.includes(className)) {\n elem.className = elem.className + \" \" + className;\n }\n};\n\nconst hash = (input: string) => {\n let hash = 0;\n for (var i = 0; i < input.length; i++) {\n var char = input.charCodeAt(i);\n hash = ((hash<<5)-hash)+char;\n hash = hash & hash;\n }\n return hash.toString(36);\n}\n\nconst addStyles = (elem: HTMLElement , styles: ((className:string, theme?: Theme) => string)[], theme: Theme | undefined) => {\n // \"styled components\" light\n styles.forEach((cssFn)=> {\n // get class name from hash\n const className = 'dintero-deals-' + hash(cssFn('dintero-deals', theme));\n addClass(elem, className);\n // add style tag to DOM if not exists\n const hit = document.querySelector(`[data-css-hash=${className}]`);\n if (!hit) {\n const style = document.createElement('style')\n style.innerHTML = cssFn(className, theme);\n style.setAttribute('data-css-hash', className);\n document.head.appendChild(style);\n }\n });\n};\n\nconst addAttributes = (elem:HTMLElement , attributes: {[key: string]: string}) => {\n Object.keys(attributes).forEach((key) => {\n elem.setAttribute(key, attributes[key]);\n });\n};\n\nconst addEventListeners = (elem:HTMLElement , handlers: {[key: string]: EventListenerOrEventListenerObject}) => {\n Object.keys(handlers).forEach((key) => {\n elem.addEventListener(key, handlers[key]);\n });\n};\n\n\n","const no = {\n rewards: {\n discount_item_quantity: {\n three_for_two: '3 for 2',\n generic: \"Kjøp {{require}} betal for {{payFor}}\"\n },\n discount_amount: \"{{monetaryAmount}} rabatt\",\n },\n limitations: {\n discount_reward_usage: \"Antall: <strong>{{discount_reward_usage}}</strong>\",\n discount_repeat_usage: \"Maks kjøp: <strong>{{discount_repeat_usage}}</strong>\"\n },\n requirements: {\n purchase_from: \"Tilbudet starter <strong>{{purchase_from}}</strong>\",\n purchase_to: \"Tilbudet utgår <strong>{{purchase_to}}</strong>\"\n },\n errors: {\n fetch: \"⚠️ <br/>En feil oppstod under lasting av tilbud...\"\n }\n} \n\nexport const translations ={\n no\n}\n\nconst findValuesRegex = /(\\{\\{)[^}]*(\\}\\})/g;\n// i18n light\nexport const t = (translateString: string, values?: {[key:string]: any}):string => {\n const matches = translateString.match(findValuesRegex) || [];\n const _values = values || {};\n return matches.reduce<string>((interpolated, match) => {\n const key = match.replace('{{', '').replace('}}', '');\n const value = _values[key] || '';\n return interpolated.replace(match, value);\n }, translateString);\n}\n\n\n","import { Configuration } from './types';\n\nexport const monetaryString = (amount:number, configuration: Configuration, options?: {\n decimal?: boolean,\n currency?: boolean,\n variant?: 'short'\n}) =>{\n const opt = options || {};\n const amountString = amount.toString();\n const dotIndex = amountString.length - configuration.currency.exponent;\n const beforeDot = amountString.slice(0, dotIndex) || '0';\n const afterDot = amountString.slice(dotIndex);\n const exponentAmount = (afterDot == \"00\" && !opt.decimal) ? beforeDot : beforeDot + '.' + afterDot;\n if(opt.variant === 'short' && afterDot === '00'){\n return beforeDot + ',-';\n }\n if(!opt.currency){\n return exponentAmount;\n }\n if(configuration.currency.position === 'prefix'){\n return configuration.currency.value + ' ' + exponentAmount\n }\n return exponentAmount + ' ' + configuration.currency.value; \n}\n\nconst padZero = (value:number) =>{\n if( value< 10){\n return `0${value}`;\n }\n return value.toString();\n}\n\nexport const dateString = (isoString: string, configuration: Configuration) => {\n try{\n const date = new Date(isoString);\n if(configuration.language === 'no'){\n const dd = padZero(date.getDate());\n const mm = padZero(date.getMonth() + 1);\n const yyyy = date.getFullYear();\n return [dd,mm,yyyy].join('.');\n }\n return new Intl.DateTimeFormat().format(date)\n } catch(e) {\n return isoString.substr(0, 10);\n }\n}\n","export const normalize = (className: string) => `\n.${className} {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n outline: none;\n border: none;\n box-shadow: none;\n line-height: auto;\n background: transparent;\n opacity: 1;\n border-radius: 0;\n display: block;\n position: relative;\n font-weight: normal;\n}\n`;\n","import { createElement } from \"./dom\";\nimport { Discount, Configuration, Theme } from \"./types\";\nimport { translations, t } from \"./translations\";\nimport { monetaryString, dateString } from \"./formatters\";\nimport { normalize } from \"./normalize\";\n\nexport const findWebshopLink = (discount: Discount) => discount.links && discount.links.find(x => x.rel && x.rel === 'webshop');\n\nconst discountStyle = (className: string, theme: Theme) => `\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${className} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: ${theme.borderRadius};\n text-align: center;\n padding-top: 5px;\n padding-bottom: 105px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 1em;\n margin: 5px 20px;\n background: ${theme.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n color: inherit;\n text-decoration: none;\n}\n\n@media screen and (max-width: 679px) {\n .${className} {\n width: 100%;\n max-width: 100%;\n } \n }\n`;\n\nconst imageWrapperStyles = (className: string) => `\n.${className} {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 300px;\n width: 100%,\n}`;\n\nconst imageStyle = (className: string) => `\n.${className} {\n max-width: 100%;\n max-height: 100%;\n text-align: center;\n display: inline-block;\n}`;\n\nconst ribbonTopStyle = (className: string, theme?: Theme) => `\n.${className} {\n position: absolute;\n bottom: 60px;\n left: -20px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: 0 ${theme.borderRadius} ${theme.borderRadius} 0;\n padding: 5px 0;\n background: ${theme?.secondary};\n}\n.${className}:after {\n position: absolute;\n content: \"\";\n bottom: -10px;\n left: 0;\n border-color: transparent;\n border-style: solid;\n border-width: 0 20px 10px 0;\n border-right-color: ${theme.secondary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`;\n\nconst ribbonBottomStyle = (className: string, theme?: Theme) => `\n.${className} {\n position: absolute;\n right: -20px;\n bottom: 15px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: ${theme.borderRadius} 0 0 ${theme.borderRadius};\n padding: 5px 0;\n background: ${theme?.primary};\n}\n.${className}:after {\n position: absolute;\n content: \"\";\n right: 0;\n bottom: -10px;\n border-color: transparent;\n border-style: solid;\n border-width: 10px 20px 0 0;\n border-top-color: ${theme.primary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`;\n\nconst titleStyle = (className: string) => `\n.${className} {\n margin-bottom: 0;\n font-size: 1em;\n margin-bottom: 2px;\n font-size: 1.3em;\n font-weight: 700;\n}`;\n\nconst subtitleStyle = (className: string) => `\n.${className} {\n margin-top: 0;\n}`;\n\nconst limitationsWrapperStyle = (className: string) => `\n.${className} {\n font-size: 0.75em;\n}\n.${className} > span{\n display: block;\n}\n`;\n\n\nconst getTopRibbonText = (discount: Discount) => {\n return (\n (discount && discount.metadata && discount.metadata.label) || undefined\n );\n};\n\nconst createTopRibbon = (discount: Discount, configuration: Configuration) => {\n const text = getTopRibbonText(discount);\n return (\n text &&\n createElement({\n tag: \"div\",\n innerHTML: text,\n theme: configuration.theme,\n styles: [ribbonTopStyle],\n })\n );\n};\n\nconst getBottomRibbonText = (\n discount: Discount,\n configuration: Configuration\n) => {\n const tStrings = translations[configuration.language];\n if (discount.reward.type === \"discount_item_new_price\") {\n return monetaryString(discount.reward.value, configuration, {\n variant: \"short\",\n });\n } else if (discount.reward.type === \"discount_percent\") {\n return discount.reward.value + \"%\";\n } else if (discount.reward.type === \"discount_item_quantity\") {\n if (\n discount.requirement.item.quantity === 3 &&\n discount.reward.value === 1\n ) {\n // Show custom 3 for 2 message\n return tStrings.rewards.discount_item_quantity.three_for_two;\n } else {\n const require = discount.requirement.item.quantity;\n const payFor =\n discount.requirement.item.quantity - discount.reward.value;\n return t(tStrings.rewards.discount_item_quantity.generic, {\n require,\n payFor,\n });\n }\n } else if (discount.reward.type === \"discount_amount\") {\n const monetaryAmount = monetaryString(\n discount.reward.value,\n configuration,\n { decimal: false }\n );\n return t(tStrings.rewards.discount_amount, { monetaryAmount });\n } else if (discount.reward.type === \"discount_item_percent\") {\n return discount.reward.value + \"%\";\n }\n return \"\";\n};\n\nconst createBottomRibbon = (\n discount: Discount,\n configuration: Configuration\n) => {\n const text = getBottomRibbonText(discount, configuration);\n return (\n text &&\n createElement({\n tag: \"div\",\n innerHTML: text,\n theme: configuration.theme,\n styles: [ribbonBottomStyle],\n })\n );\n};\n\nconst createImage = (discount: Discount) => {\n const imageWrapper = createElement({\n tag: \"div\",\n styles: [normalize, imageWrapperStyles],\n });\n const imageSrc = discount.links.find((link) => [\n \"medium_discount_image\",\n \"thumbnail_discount_image\".includes(link.rel),\n ]);\n const image =\n imageSrc &&\n createElement({\n tag: \"img\",\n attributes: { src: imageSrc.href, alt: discount.name, loading: \"lazy\"},\n styles: [normalize, imageStyle],\n });\n if (image) {\n imageWrapper.appendChild(image);\n }\n return imageWrapper;\n};\n\nconst createLimitations = (\n discount: Discount,\n configuration: Configuration\n) => {\n const tStrings = translations[configuration.language];\n\n const wrapper = createElement({\n tag: \"small\",\n styles: [normalize, limitationsWrapperStyle],\n });\n\n const quantity =\n discount.limitation.discount_reward_usage &&\n discount.limitation.discount_reward_usage !== -1 &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.limitations.discount_reward_usage, {\n discount_reward_usage: discount.limitation.discount_reward_usage,\n }),\n });\n const repeat =\n discount.limitation.discount_repeat_usage &&\n discount.limitation.discount_repeat_usage !== -1 &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.limitations.discount_repeat_usage, {\n discount_repeat_usage: discount.limitation.discount_repeat_usage,\n }),\n });\n\n const startDate = new Date(discount.requirement.purchase_from || 0);\n const start = startDate > new Date() && createElement({\n tag: \"span\",\n innerHTML: t(tStrings.requirements.purchase_from, {\n purchase_from: dateString(discount.requirement.purchase_from, configuration),\n }),\n });\n const endDate = new Date(discount.requirement.purchase_to || 0);\n const end = endDate > new Date() && createElement({\n tag: \"span\",\n innerHTML: t(tStrings.requirements.purchase_to, {\n purchase_to: dateString(discount.requirement.purchase_to, configuration),\n }),\n });\n const children = [\n quantity,\n repeat,\n start,\n end\n ].filter((child) => child);\n children.forEach((child) => wrapper.appendChild(child));\n console.log({discount, wrapper});\n return wrapper;\n};\n\nexport const createDiscount = (\n discount: Discount,\n configuration: Configuration\n): HTMLElement => {\n const discountElem = createElement({\n tag: findWebshopLink(discount) ? \"a\" : \"div\",\n styles: [normalize, discountStyle],\n theme: configuration.theme\n });\n const ribbonTop = createTopRibbon(discount, configuration);\n const ribbonBottom = createBottomRibbon(discount, configuration);\n const image = createImage(discount);\n const title =\n discount?.name &&\n createElement({ tag: \"h4\", innerHTML: discount.name , styles:[titleStyle]});\n const subtitle =\n discount?.metadata?.subtitle &&\n createElement({ tag: \"p\", innerHTML: discount.metadata.subtitle, styles: [subtitleStyle] });\n const description =\n discount.description &&\n createElement({ tag: \"p\", innerHTML: discount.description });\n\n const limitations = createLimitations(discount, configuration);\n // add children to discount wrapper\n const children = [\n ribbonTop,\n ribbonBottom,\n image,\n title,\n subtitle,\n description,\n limitations\n ].filter((child) => child);\n children.forEach((child) => discountElem.appendChild(child));\n return discountElem;\n};\n","import { Configuration, Discount, TokenResponse } from \"./types\";\n\nconst createHeaders = (\n keyValues: { [key: string]: string },\n configuration: Configuration\n) => {\n const headers: HeadersInit = new Headers();\n Object.entries({\n ...keyValues,\n \"Dintero-System-Name\": \"deals-web-sdk\",\n \"Dintero-System-Version\": configuration.version,\n }).forEach(([key, value]) => {\n headers.append(key, value);\n });\n return headers;\n};\n\nconst fetchAccessToken = (\n configuration: Configuration\n): Promise<TokenResponse> => {\n if (!configuration.api) {\n throw new Error(\"Authentication configuration missing\");\n }\n const basicAuthCredentials = window.btoa(\n `${configuration.api.key}:${configuration.api.secret}`\n );\n const headers = createHeaders(\n {\n Authorization: `Basic ${basicAuthCredentials}`,\n \"content-type\": \"application/json\",\n },\n configuration\n );\n const body = JSON.stringify({\n grant_type: \"client_credentials\",\n audience: `${configuration.api.url}/v1/accounts/${configuration.api.account}`,\n });\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/auth/token`,\n {\n method: \"POST\",\n headers,\n body,\n }\n )\n .then((response) => {\n if (response.status === 200) {\n return response.json() as Promise<TokenResponse>;\n }\n throw new Error(\"Authentication failed\");\n });\n};\n\nexport const fetchDiscounts = (\n configuration: Configuration\n): Promise<Discount[]> => {\n return fetchAccessToken(configuration).then((tokenResponse) => {\n const headers = createHeaders(\n {\n Authorization: `${tokenResponse.token_type} ${tokenResponse.access_token}`,\n },\n configuration\n );\n \n if (configuration.api.discountId) {\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/discounts/public/rules/${configuration.api.discountId}`,\n {\n headers,\n }\n )\n .then((response) => {\n if (response.status === 200) {\n return response\n .json()\n .then((discount) => [discount]) as Promise<\n Discount[]\n >;\n }\n throw new Error(\"Authentication failed\");\n });\n }\n\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/discounts/public/rules?limit=${configuration.api.limit}`,\n {\n headers,\n }\n )\n .then((response) => {\n if (response.status === 200) {\n return response.json() as Promise<Discount[]>;\n }\n throw new Error(\"Authentication failed\");\n });\n });\n};\n","import { createElement } from \"./dom\";\nimport { Configuration, Theme } from \"./types\";\nimport { translations } from \"./translations\";\nimport { normalize } from \"./normalize\";\n\nconst errorStyle = (className: string, theme: Theme) => `\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${className} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: 3px;\n text-align: center;\n padding-top: 65px;\n padding-bottom: 70px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 14px;\n margin: 5px auto;\n background: ${theme.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n}\n`;\n\n\nexport const createError = (\n configuration: Configuration\n): HTMLElement => {\n const tString = translations[configuration.language];\n const errorElem = createElement({\n tag: \"div\",\n styles: [normalize, errorStyle],\n theme: configuration.theme,\n innerHTML: tString.errors.fetch\n });\n \n return errorElem;\n};\n","import { createElement } from \"./dom\";\nimport { Configuration, Theme } from \"./types\";\nimport { normalize } from \"./normalize\";\n\nconst loadingStyle = (className: string, theme: Theme) => `\n.${className} {\n margin: 10px auto;\n display: block;\n width: 80px;\n height: 80px;\n}\n\n.${className}:after {\n content: \" \";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #000;\n border-color: rgba(0,0,0,0.2) transparent rgba(0,0,0,0.2) transparent;\n animation: loading 0.6s linear infinite;\n}\n\n@keyframes loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n`;\n\nexport const createLoading = (configuration: Configuration): HTMLElement => {\n const errorElem = createElement({\n tag: \"div\",\n styles: [normalize, loadingStyle],\n theme: configuration.theme,\n });\n\n return errorElem;\n};\n","import { createDiscount, findWebshopLink } from \"./discounts\";\nimport { Discount, Configuration, Theme, Embed } from \"./types\";\nimport { createElement } from \"./dom\";\nimport { fetchDiscounts } from \"./fetch\";\nimport { createError } from \"./error\";\nimport { createLoading } from \"./loading\";\nimport { normalize } from \"./normalize\";\nimport pkg from \"../package.json\";\n\n\n\nconst defaultConfig:Partial<Configuration> = {\n language: 'no',\n version: pkg.version,\n linkTarget: '_self',\n currency: {\n value: 'Kr',\n position: 'suffix',\n exponent: 2\n },\n theme: {\n background: \"#fff\",\n primary: \"#333\",\n secondary: \"#333\",\n color: \"inherit\",\n borderRadius: \"2px\",\n fontSize: \"inherit\",\n },\n api: {\n account: \"\",\n key: \"\",\n secret: \"\",\n url: \"https://api.dintero.com\",\n limit: 50,\n },\n}\n\nconst mergeConfig = (a:Partial<Configuration>, b:Configuration): Configuration =>{\n return {\n ...a,\n ...b,\n currency:{\n ...a.currency,\n ...b.currency,\n },\n theme: {\n ...a.theme,\n ...b.theme\n },\n api:{\n ...a.api,\n ...b.api\n }\n }\n}\n\nconst wrapperStyles = (className: string, theme:Theme) => `\n.${className} {\n display: flex;\n flex-flow: wrap;\n align-items: stretch;\n justify-content: center;\n position: relative;\n font-weight: normal;\n width: 100%;\n font-size: ${theme.fontSize};\n color: ${theme.color};\n}`;\n\nexport const embed = async (configuration: Configuration):Promise<Embed> => {\n\n const _configuration = mergeConfig(defaultConfig, configuration);\n if(!_configuration.container ||!_configuration.container.appendChild){\n console.error(\"Invalid configuration\");\n throw new Error(\"Invalid configuration\");\n }\n if (_configuration.discounts) {\n return renderDeals(_configuration, _configuration.discounts);\n } else {\n\n const loader = createLoading(_configuration);\n try{\n configuration.container.appendChild(loader);\n const discounts = await fetchDiscounts(_configuration);\n _configuration.container.removeChild(loader);\n return renderDeals(_configuration, discounts);\n } catch(error) {\n configuration.container.removeChild(loader);\n const errorMessage = createError(_configuration);\n _configuration.container.appendChild(errorMessage);\n return {\n destroy: () => {\n configuration.container.removeChild(errorMessage);\n }\n }\n }\n }\n};\n\nconst renderDeals = (configuration: Configuration, discounts: Discount[]):Embed => {\n const wrapper = createElement({ tag: \"div\", styles: [normalize, wrapperStyles], theme: configuration.theme });\n discounts.forEach((discount) => {\n const elem = createDiscount(discount, configuration);\n const webShopLink = findWebshopLink(discount);\n if (webShopLink) {\n elem.setAttribute('target', configuration?.linkTarget || '_self');\n elem.setAttribute('href', webShopLink.href);\n }\n wrapper.appendChild(elem);\n });\n configuration.container.appendChild(wrapper);\n return {\n destroy: () => {\n configuration.container.removeChild(wrapper);\n }\n }\n};\n"],"names":["createElement","options","elem","document","tag","attributes","addAttributes","handlers","addEventListeners","styles","addStyles","theme","innerHTML","forEach","cssFn","className","input","hash","i","length","charCodeAt","toString","split","includes","addClass","querySelector","style","setAttribute","head","appendChild","Object","keys","key","addEventListener","translations","no","rewards","discount_item_quantity","three_for_two","generic","discount_amount","limitations","discount_reward_usage","discount_repeat_usage","requirements","purchase_from","purchase_to","errors","fetch","findValuesRegex","t","translateString","values","matches","match","_values","reduce","interpolated","replace","value","monetaryString","amount","configuration","opt","amountString","dotIndex","currency","exponent","beforeDot","slice","afterDot","exponentAmount","decimal","variant","position","padZero","dateString","isoString","date","Date","language","dd","getDate","mm","getMonth","getFullYear","join","Intl","DateTimeFormat","format","e","substr","normalize","findWebshopLink","discount","links","find","x","rel","discountStyle","borderRadius","background","imageWrapperStyles","imageStyle","ribbonTopStyle","secondary","ribbonBottomStyle","primary","titleStyle","subtitleStyle","limitationsWrapperStyle","createBottomRibbon","text","tStrings","reward","type","requirement","item","quantity","require","payFor","monetaryAmount","getBottomRibbonText","createDiscount","discountElem","ribbonTop","metadata","label","undefined","getTopRibbonText","createTopRibbon","ribbonBottom","image","imageWrapper","imageSrc","link","src","href","alt","name","loading","createImage","title","subtitle","description","wrapper","limitation","filter","child","console","log","createLimitations","createHeaders","keyValues","headers","Headers","entries","version","append","fetchDiscounts","api","Error","basicAuthCredentials","window","btoa","secret","Authorization","body","JSON","stringify","grant_type","audience","url","account","method","then","response","status","json","fetchAccessToken","tokenResponse","token_type","access_token","discountId","limit","errorStyle","loadingStyle","defaultConfig","linkTarget","color","fontSize","wrapperStyles","renderDeals","discounts","webShopLink","container","destroy","removeChild","async","_configuration","a","b","error","loader","createLoading","errorMessage","tString","createError"],"mappings":"iPAWO,MAAMA,EAAiBC,IACpBC,MAAAA,EAAOC,SAASH,cAAcC,EAAQG,KAa5C,OAZIH,EAAQI,YACRC,EAAcJ,EAAMD,EAAQI,YAE5BJ,EAAQM,UACRC,EAAkBN,EAAMD,EAAQM,UAEjCN,EAAQQ,QACPC,EAAUR,EAAMD,EAAQQ,OAAQR,EAAQU,OAEzCV,EAAQW,YACPV,EAAKU,UAAYX,EAAQW,WAEtBV,CAAP,EAoBEQ,EAAY,CAACR,EAAoBO,EAAyDE,KAE5FF,EAAOI,SAASC,IAENC,MAAAA,EAAY,iBAdZC,KACNC,IAAAA,EAAO,EACX,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAMG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tK,YAErD,MADAwH,QAAQqD,MAAM,yBACR,IAAIzC,MAAM,yBAEhBsC,GAAAA,EAAeN,UACf,OAAOD,EAAYO,EAAgBA,EAAeN,WAC/C,CAEH,MAAMU,ED9CgB7I,IACR9D,EAAc,CAC5BI,IAAK,MACLK,OAAQ,CAACmF,EAAW8F,GACpB/K,MAAOmD,EAAcnD,QC0CNiM,CAAcL,GAC1B,IACCzI,EAAcqI,UAAUtK,YAAY8K,GACpC,MAAMV,QAAkBlC,EAAewC,GAEvC,OADAA,EAAeJ,UAAUE,YAAYM,GAC9BX,EAAYO,EAAgBN,EAUtC,CATC,MAAMS,GACJ5I,EAAcqI,UAAUE,YAAYM,GACpC,MAAME,EF/Cd/I,KAEA,MAAMgJ,EAAW5K,EAAa4B,EAAckB,UAQ5C,OAPkBhF,EAAc,CAC5BI,IAAK,MACLK,OAAQ,CAACmF,EAAW6F,GACpB9K,MAAOmD,EAAcnD,MACrBC,UAAWkM,EAAQ/J,OAAOC,OAG9B,EEqC6B+J,CAAYR,GAE1B,OADPA,EAAeJ,UAAUtK,YAAYgL,GAC9B,CACHT,QAAS,KACLtI,EAAcqI,UAAUE,YAAYQ,EAApC,EAGX,CACJ"}
1
+ {"version":3,"file":"dintero-discounts-web-sdk.umd.min.js","sources":["../src/dom.ts","../src/translations.ts","../src/formatters.ts","../src/normalize.ts","../src/discounts.ts","../src/fetch.ts","../src/error.ts","../src/loading.ts","../src/index.ts"],"sourcesContent":["import { Theme } from './types';\n\ntype CreateElementOptions ={\n tag: string,\n attributes?: {[key: string]: any};\n styles?:((className:string, theme?: Theme) => string)[];\n handlers?:{[key: string]: EventListenerOrEventListenerObject};\n innerHTML?: string;\n theme?: Theme,\n}\n\nexport const createElement = (options: CreateElementOptions) => {\n const elem = document.createElement(options.tag);\n if (options.attributes) {\n addAttributes(elem, options.attributes)\n }\n if (options.handlers) {\n addEventListeners(elem, options.handlers)\n }\n if(options.styles){\n addStyles(elem, options.styles, options.theme);\n }\n if(options.innerHTML){\n elem.innerHTML = options.innerHTML;\n }\n return elem;\n};\n\nconst addClass = (elem:HTMLElement, className:string) => {\n const names = elem.className.split(\" \");\n if (!names.includes(className)) {\n elem.className = elem.className + \" \" + className;\n }\n};\n\nconst hash = (input: string) => {\n let hash = 0;\n for (var i = 0; i < input.length; i++) {\n var char = input.charCodeAt(i);\n hash = ((hash<<5)-hash)+char;\n hash = hash & hash;\n }\n return hash.toString(36);\n}\n\nconst addStyles = (elem: HTMLElement , styles: ((className:string, theme?: Theme) => string)[], theme: Theme | undefined) => {\n // \"styled components\" light\n styles.forEach((cssFn)=> {\n // get class name from hash\n const className = 'dintero-deals-' + hash(cssFn('dintero-deals', theme));\n addClass(elem, className);\n // add style tag to DOM if not exists\n const hit = document.querySelector(`[data-css-hash=${className}]`);\n if (!hit) {\n const style = document.createElement('style')\n style.innerHTML = cssFn(className, theme);\n style.setAttribute('data-css-hash', className);\n document.head.appendChild(style);\n }\n });\n};\n\nconst addAttributes = (elem:HTMLElement , attributes: {[key: string]: string}) => {\n Object.keys(attributes).forEach((key) => {\n elem.setAttribute(key, attributes[key]);\n });\n};\n\nconst addEventListeners = (elem:HTMLElement , handlers: {[key: string]: EventListenerOrEventListenerObject}) => {\n Object.keys(handlers).forEach((key) => {\n elem.addEventListener(key, handlers[key]);\n });\n};\n\n\n","const no = {\n rewards: {\n discount_item_quantity: {\n three_for_two: '3 for 2',\n generic: \"Kjøp {{require}} betal for {{payFor}}\"\n },\n discount_amount: \"{{monetaryAmount}} rabatt\",\n },\n limitations: {\n discount_reward_usage: \"Antall: <strong>{{discount_reward_usage}}</strong>\",\n discount_repeat_usage: \"Maks kjøp: <strong>{{discount_repeat_usage}}</strong>\"\n },\n requirements: {\n purchase_from: \"Tilbudet starter <strong>{{purchase_from}}</strong>\",\n purchase_to: \"Tilbudet utgår <strong>{{purchase_to}}</strong>\"\n },\n errors: {\n fetch: \"⚠️ <br/>En feil oppstod under lasting av tilbud...\"\n }\n} \n\nexport const translations ={\n no\n}\n\nconst findValuesRegex = /(\\{\\{)[^}]*(\\}\\})/g;\n// i18n light\nexport const t = (translateString: string, values?: {[key:string]: any}):string => {\n const matches: string[] = translateString.match(findValuesRegex) || [];\n const _values = values || {};\n return matches.reduce<string>((interpolated, match) => {\n const key = match.replace('{{', '').replace('}}', '');\n const value = _values[key] || '';\n return interpolated.replace(match, value);\n }, translateString);\n}\n\n\n","import { Configuration } from './types';\n\nexport const monetaryString = (amount:number, configuration: Configuration, options?: {\n decimal?: boolean,\n currency?: boolean,\n variant?: 'short'\n}) =>{\n const opt = options || {};\n const amountString = amount.toString();\n const dotIndex = amountString.length - configuration.currency.exponent;\n const beforeDot = amountString.slice(0, dotIndex) || '0';\n const afterDot = amountString.slice(dotIndex);\n const exponentAmount = (afterDot == \"00\" && !opt.decimal) ? beforeDot : beforeDot + '.' + afterDot;\n if(opt.variant === 'short' && afterDot === '00'){\n return beforeDot + ',-';\n }\n if(!opt.currency){\n return exponentAmount;\n }\n if(configuration.currency.position === 'prefix'){\n return configuration.currency.value + ' ' + exponentAmount\n }\n return exponentAmount + ' ' + configuration.currency.value; \n}\n\nconst padZero = (value:number) =>{\n if( value< 10){\n return `0${value}`;\n }\n return value.toString();\n}\n\nexport const dateString = (isoString: string, configuration: Configuration) => {\n try{\n const date = new Date(isoString);\n if(configuration.language === 'no'){\n const dd = padZero(date.getDate());\n const mm = padZero(date.getMonth() + 1);\n const yyyy = date.getFullYear();\n return [dd,mm,yyyy].join('.');\n }\n return new Intl.DateTimeFormat().format(date)\n } catch(e) {\n return isoString.substr(0, 10);\n }\n}\n","export const normalize = (className: string) => `\n.${className} {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n outline: none;\n border: none;\n box-shadow: none;\n line-height: auto;\n background: transparent;\n opacity: 1;\n border-radius: 0;\n display: block;\n position: relative;\n font-weight: normal;\n}\n`;\n","import { createElement } from \"./dom\";\nimport { Discount, Configuration, Theme } from \"./types\";\nimport { translations, t } from \"./translations\";\nimport { monetaryString, dateString } from \"./formatters\";\nimport { normalize } from \"./normalize\";\n\nexport const findWebshopLink = (discount: Discount) => discount.links && discount.links.find(x => x.rel && x.rel === 'webshop');\n\nconst discountStyle = (className: string, theme: Theme) => `\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${className} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: ${theme.borderRadius};\n text-align: center;\n padding-top: 5px;\n padding-bottom: 105px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 1em;\n margin: 5px 20px;\n background: ${theme.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n color: inherit;\n text-decoration: none;\n}\n\n@media screen and (max-width: 679px) {\n .${className} {\n width: 100%;\n max-width: 100%;\n } \n }\n`;\n\nconst imageWrapperStyles = (className: string) => `\n.${className} {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 300px;\n width: 100%,\n}`;\n\nconst imageStyle = (className: string) => `\n.${className} {\n max-width: 100%;\n max-height: 100%;\n text-align: center;\n display: inline-block;\n}`;\n\nconst ribbonTopStyle = (className: string, theme?: Theme) => `\n.${className} {\n position: absolute;\n bottom: 60px;\n left: -20px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: 0 ${theme.borderRadius} ${theme.borderRadius} 0;\n padding: 5px 0;\n background: ${theme?.secondary};\n}\n.${className}:after {\n position: absolute;\n content: \"\";\n bottom: -10px;\n left: 0;\n border-color: transparent;\n border-style: solid;\n border-width: 0 20px 10px 0;\n border-right-color: ${theme.secondary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`;\n\nconst ribbonBottomStyle = (className: string, theme?: Theme) => `\n.${className} {\n position: absolute;\n right: -20px;\n bottom: 15px;\n color: #fff;\n z-index: 9;\n width: 80%;\n font-size: 1.3em;\n border-radius: ${theme.borderRadius} 0 0 ${theme.borderRadius};\n padding: 5px 0;\n background: ${theme?.primary};\n}\n.${className}:after {\n position: absolute;\n content: \"\";\n right: 0;\n bottom: -10px;\n border-color: transparent;\n border-style: solid;\n border-width: 10px 20px 0 0;\n border-top-color: ${theme.primary};\n width: 0;\n height: 0;\n opacity: 0.5;\n}\n`;\n\nconst titleStyle = (className: string) => `\n.${className} {\n margin-bottom: 0;\n font-size: 1em;\n margin-bottom: 2px;\n font-size: 1.3em;\n font-weight: 700;\n}`;\n\nconst subtitleStyle = (className: string) => `\n.${className} {\n margin-top: 0;\n}`;\n\nconst limitationsWrapperStyle = (className: string) => `\n.${className} {\n font-size: 0.75em;\n}\n.${className} > span{\n display: block;\n}\n`;\n\n\nconst getTopRibbonText = (discount: Discount) => {\n return (\n (discount && discount.metadata && discount.metadata.label) || undefined\n );\n};\n\nconst createTopRibbon = (discount: Discount, configuration: Configuration) => {\n const text = getTopRibbonText(discount);\n return (\n text &&\n createElement({\n tag: \"div\",\n innerHTML: text,\n theme: configuration.theme,\n styles: [ribbonTopStyle],\n })\n );\n};\n\nconst getBottomRibbonText = (\n discount: Discount,\n configuration: Configuration\n) => {\n const tStrings = translations[configuration.language];\n if (discount.reward.type === \"discount_item_new_price\") {\n return monetaryString(discount.reward.value, configuration, {\n variant: \"short\",\n });\n } else if (discount.reward.type === \"discount_percent\") {\n return discount.reward.value + \"%\";\n } else if (discount.reward.type === \"discount_item_quantity\") {\n if (\n discount.requirement.item.quantity === 3 &&\n discount.reward.value === 1\n ) {\n // Show custom 3 for 2 message\n return tStrings.rewards.discount_item_quantity.three_for_two;\n } else {\n const require = discount.requirement.item.quantity;\n const payFor =\n discount.requirement.item.quantity - discount.reward.value;\n return t(tStrings.rewards.discount_item_quantity.generic, {\n require,\n payFor,\n });\n }\n } else if (discount.reward.type === \"discount_amount\") {\n const monetaryAmount = monetaryString(\n discount.reward.value,\n configuration,\n { decimal: false }\n );\n return t(tStrings.rewards.discount_amount, { monetaryAmount });\n } else if (discount.reward.type === \"discount_item_percent\") {\n return discount.reward.value + \"%\";\n }\n return \"\";\n};\n\nconst createBottomRibbon = (\n discount: Discount,\n configuration: Configuration\n) => {\n const text = getBottomRibbonText(discount, configuration);\n return (\n text &&\n createElement({\n tag: \"div\",\n innerHTML: text,\n theme: configuration.theme,\n styles: [ribbonBottomStyle],\n })\n );\n};\n\nconst createImage = (discount: Discount) => {\n const imageWrapper = createElement({\n tag: \"div\",\n styles: [normalize, imageWrapperStyles],\n });\n const imageSrc = discount.links.find((link) => [\n \"medium_discount_image\",\n \"thumbnail_discount_image\".includes(link.rel),\n ]);\n const image =\n imageSrc &&\n createElement({\n tag: \"img\",\n attributes: { src: imageSrc.href, alt: discount.name, loading: \"lazy\"},\n styles: [normalize, imageStyle],\n });\n if (image) {\n imageWrapper.appendChild(image);\n }\n return imageWrapper;\n};\n\nconst createLimitations = (\n discount: Discount,\n configuration: Configuration\n) => {\n const tStrings = translations[configuration.language];\n\n const wrapper = createElement({\n tag: \"small\",\n styles: [normalize, limitationsWrapperStyle],\n });\n\n const quantity =\n discount.limitation.discount_reward_usage &&\n discount.limitation.discount_reward_usage !== -1 &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.limitations.discount_reward_usage, {\n discount_reward_usage: discount.limitation.discount_reward_usage,\n }),\n });\n const repeat =\n discount.limitation.discount_repeat_usage &&\n discount.limitation.discount_repeat_usage !== -1 &&\n createElement({\n tag: \"span\",\n innerHTML: t(tStrings.limitations.discount_repeat_usage, {\n discount_repeat_usage: discount.limitation.discount_repeat_usage,\n }),\n });\n\n const startDate = new Date(discount.requirement.purchase_from || 0);\n const start = startDate > new Date() && createElement({\n tag: \"span\",\n innerHTML: t(tStrings.requirements.purchase_from, {\n purchase_from: dateString(discount.requirement.purchase_from, configuration),\n }),\n });\n const endDate = new Date(discount.requirement.purchase_to || 0);\n const end = endDate > new Date() && createElement({\n tag: \"span\",\n innerHTML: t(tStrings.requirements.purchase_to, {\n purchase_to: dateString(discount.requirement.purchase_to, configuration),\n }),\n });\n const children = [\n quantity,\n repeat,\n start,\n end\n ].filter((child) => child);\n children.forEach((child) => wrapper.appendChild(child));\n return wrapper;\n};\n\nexport const createDiscount = (\n discount: Discount,\n configuration: Configuration\n): HTMLElement => {\n const discountElem = createElement({\n tag: findWebshopLink(discount) ? \"a\" : \"div\",\n styles: [normalize, discountStyle],\n theme: configuration.theme\n });\n const ribbonTop = createTopRibbon(discount, configuration);\n const ribbonBottom = createBottomRibbon(discount, configuration);\n const image = createImage(discount);\n const title =\n discount?.name &&\n createElement({ tag: \"h4\", innerHTML: discount.name , styles:[titleStyle]});\n const subtitle =\n discount?.metadata?.subtitle &&\n createElement({ tag: \"p\", innerHTML: discount.metadata.subtitle, styles: [subtitleStyle] });\n const description =\n discount.description &&\n createElement({ tag: \"p\", innerHTML: discount.description });\n\n const limitations = createLimitations(discount, configuration);\n // add children to discount wrapper\n const children = [\n ribbonTop,\n ribbonBottom,\n image,\n title,\n subtitle,\n description,\n limitations\n ].filter((child) => child);\n children.forEach((child) => discountElem.appendChild(child));\n return discountElem;\n};\n","import { Configuration, Discount, TokenResponse } from \"./types\";\n\nconst createHeaders = (\n keyValues: { [key: string]: string },\n configuration: Configuration\n) => {\n const headers: HeadersInit = new Headers();\n Object.entries({\n ...keyValues,\n \"Dintero-System-Name\": \"deals-web-sdk\",\n \"Dintero-System-Version\": configuration.version,\n }).forEach(([key, value]) => {\n headers.append(key, value);\n });\n return headers;\n};\n\nconst fetchAccessToken = (\n configuration: Configuration\n): Promise<TokenResponse> => {\n if (!configuration.api) {\n throw new Error(\"Authentication configuration missing\");\n }\n const basicAuthCredentials = window.btoa(\n `${configuration.api.key}:${configuration.api.secret}`\n );\n const headers = createHeaders(\n {\n Authorization: `Basic ${basicAuthCredentials}`,\n \"content-type\": \"application/json\",\n },\n configuration\n );\n const body = JSON.stringify({\n grant_type: \"client_credentials\",\n audience: `${configuration.api.url}/v1/accounts/${configuration.api.account}`,\n });\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/auth/token`,\n {\n method: \"POST\",\n headers,\n body,\n }\n )\n .then((response) => {\n if (response.status === 200) {\n return response.json() as Promise<TokenResponse>;\n }\n throw new Error(\"Authentication failed\");\n });\n};\n\nexport const fetchDiscounts = (\n configuration: Configuration\n): Promise<Discount[]> => {\n return fetchAccessToken(configuration).then((tokenResponse) => {\n const headers = createHeaders(\n {\n Authorization: `${tokenResponse.token_type} ${tokenResponse.access_token}`,\n },\n configuration\n );\n \n if (configuration.api.discountId) {\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/discounts/public/rules/${configuration.api.discountId}`,\n {\n headers,\n }\n )\n .then((response) => {\n if (response.status === 200) {\n return response\n .json()\n .then((discount) => [discount]) as Promise<\n Discount[]\n >;\n }\n throw new Error(\"Authentication failed\");\n });\n }\n\n return window\n .fetch(\n `${configuration.api.url}/v1/accounts/${configuration.api.account}/discounts/public/rules?limit=${configuration.api.limit}`,\n {\n headers,\n }\n )\n .then((response) => {\n if (response.status === 200) {\n return response.json() as Promise<Discount[]>;\n }\n throw new Error(\"Authentication failed\");\n });\n });\n};\n","import { createElement } from \"./dom\";\nimport { Configuration, Theme } from \"./types\";\nimport { translations } from \"./translations\";\nimport { normalize } from \"./normalize\";\n\nconst errorStyle = (className: string, theme: Theme) => `\n@keyframes appear {\n from {\n transform: scaleY(0%);\n height: 0;\n opacity: 0;\n }\n \n to {\n transform: scaleY(100%);\n height: auto;\n opacity: 1;\n }\n }\n.${className} {\n box-shadow: rgb(212, 212, 213) 0px 1px 3px 0px, rgb(212, 212, 213) 0px 0px 0px 1px;\n border-radius: 3px;\n text-align: center;\n padding-top: 65px;\n padding-bottom: 70px;\n padding-left: 5px;\n padding-right: 5px;\n max-width: 300px;\n width: 250px;\n font-size: 14px;\n margin: 5px auto;\n background: ${theme.background};\n animation-duration: 0.2s;\n animation-name: appear;\n animation-timing-function: ease-in;\n transform-origin: top center;\n}\n`;\n\n\nexport const createError = (\n configuration: Configuration\n): HTMLElement => {\n const tString = translations[configuration.language];\n const errorElem = createElement({\n tag: \"div\",\n styles: [normalize, errorStyle],\n theme: configuration.theme,\n innerHTML: tString.errors.fetch\n });\n \n return errorElem;\n};\n","import { createElement } from \"./dom\";\nimport { Configuration, Theme } from \"./types\";\nimport { normalize } from \"./normalize\";\n\nconst loadingStyle = (className: string, theme: Theme) => `\n.${className} {\n margin: 10px auto;\n display: block;\n width: 80px;\n height: 80px;\n}\n\n.${className}:after {\n content: \" \";\n display: block;\n width: 64px;\n height: 64px;\n margin: 8px;\n border-radius: 50%;\n border: 6px solid #000;\n border-color: rgba(0,0,0,0.2) transparent rgba(0,0,0,0.2) transparent;\n animation: loading 0.6s linear infinite;\n}\n\n@keyframes loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n`;\n\nexport const createLoading = (configuration: Configuration): HTMLElement => {\n const errorElem = createElement({\n tag: \"div\",\n styles: [normalize, loadingStyle],\n theme: configuration.theme,\n });\n\n return errorElem;\n};\n","import { createDiscount, findWebshopLink } from \"./discounts\";\nimport { Discount, Configuration, Theme, Embed } from \"./types\";\nimport { createElement } from \"./dom\";\nimport { fetchDiscounts } from \"./fetch\";\nimport { createError } from \"./error\";\nimport { createLoading } from \"./loading\";\nimport { normalize } from \"./normalize\";\nimport pkg from \"../package.json\";\n\n\n\nconst defaultConfig:Partial<Configuration> = {\n language: 'no',\n version: pkg?.version || \"SNAPSHOT\",\n linkTarget: '_self',\n currency: {\n value: 'Kr',\n position: 'suffix',\n exponent: 2\n },\n theme: {\n background: \"#fff\",\n primary: \"#333\",\n secondary: \"#333\",\n color: \"inherit\",\n borderRadius: \"2px\",\n fontSize: \"inherit\",\n },\n api: {\n account: \"\",\n key: \"\",\n secret: \"\",\n url: \"https://api.dintero.com\",\n limit: 50,\n },\n}\n\nconst mergeConfig = (a:Partial<Configuration>, b:Configuration): Configuration =>{\n return {\n ...a,\n ...b,\n currency:{\n ...a.currency,\n ...b.currency,\n },\n theme: {\n ...a.theme,\n ...b.theme\n },\n api:{\n ...a.api,\n ...b.api\n }\n }\n}\n\nconst wrapperStyles = (className: string, theme:Theme) => `\n.${className} {\n display: flex;\n flex-flow: wrap;\n align-items: stretch;\n justify-content: center;\n position: relative;\n font-weight: normal;\n width: 100%;\n font-size: ${theme.fontSize};\n color: ${theme.color};\n}`;\n\nexport const embed = async (configuration: Configuration):Promise<Embed> => {\n\n const _configuration = mergeConfig(defaultConfig, configuration);\n if(!_configuration.container ||!_configuration.container.appendChild){\n console.error(\"Invalid configuration\");\n throw new Error(\"Invalid configuration\");\n }\n if (_configuration.discounts) {\n return renderDeals(_configuration, _configuration.discounts);\n } else {\n\n const loader = createLoading(_configuration);\n try{\n configuration.container.appendChild(loader);\n const discounts = await fetchDiscounts(_configuration);\n _configuration.container.removeChild(loader);\n return renderDeals(_configuration, discounts);\n } catch(error) {\n configuration.container.removeChild(loader);\n const errorMessage = createError(_configuration);\n _configuration.container.appendChild(errorMessage);\n return {\n destroy: () => {\n configuration.container.removeChild(errorMessage);\n }\n }\n }\n }\n};\n\nconst renderDeals = (configuration: Configuration, discounts: Discount[]):Embed => {\n const wrapper = createElement({ tag: \"div\", styles: [normalize, wrapperStyles], theme: configuration.theme });\n discounts.forEach((discount) => {\n const elem = createDiscount(discount, configuration);\n const webShopLink = findWebshopLink(discount);\n if (webShopLink) {\n elem.setAttribute('target', configuration?.linkTarget || '_self');\n elem.setAttribute('href', webShopLink.href);\n }\n wrapper.appendChild(elem);\n });\n configuration.container.appendChild(wrapper);\n return {\n destroy: () => {\n configuration.container.removeChild(wrapper);\n }\n }\n};\n"],"names":["createElement","options","elem","document","tag","attributes","addAttributes","handlers","addEventListeners","styles","addStyles","theme","innerHTML","forEach","cssFn","className","input","hash","i","length","charCodeAt","toString","addClass","split","includes","querySelector","style","setAttribute","head","appendChild","Object","keys","key","addEventListener","translations","no","rewards","discount_item_quantity","three_for_two","generic","discount_amount","limitations","discount_reward_usage","discount_repeat_usage","requirements","purchase_from","purchase_to","errors","fetch","findValuesRegex","t","translateString","values","matches","match","_values","reduce","interpolated","replace","value","monetaryString","amount","configuration","opt","amountString","dotIndex","currency","exponent","beforeDot","slice","afterDot","exponentAmount","decimal","variant","position","padZero","dateString","isoString","date","Date","language","dd","getDate","mm","getMonth","getFullYear","join","Intl","DateTimeFormat","format","e","substr","normalize","findWebshopLink","discount","links","find","x","rel","discountStyle","borderRadius","background","imageWrapperStyles","imageStyle","ribbonTopStyle","secondary","ribbonBottomStyle","primary","titleStyle","subtitleStyle","limitationsWrapperStyle","createBottomRibbon","text","getBottomRibbonText","tStrings","reward","type","requirement","item","quantity","require","payFor","monetaryAmount","createDiscount","discountElem","ribbonTop","createTopRibbon","metadata","label","undefined","getTopRibbonText","ribbonBottom","image","imageWrapper","imageSrc","link","src","href","alt","name","loading","createImage","title","subtitle","description","createLimitations","wrapper","limitation","filter","child","createHeaders","keyValues","headers","Headers","entries","version","append","fetchDiscounts","api","Error","basicAuthCredentials","window","btoa","secret","Authorization","body","JSON","stringify","grant_type","audience","url","account","method","then","response","status","json","fetchAccessToken","tokenResponse","token_type","access_token","discountId","limit","errorStyle","loadingStyle","defaultConfig","linkTarget","color","fontSize","wrapperStyles","renderDeals","discounts","webShopLink","container","destroy","removeChild","async","_configuration","a","b","mergeConfig","console","error","loader","createLoading","errorMessage","tString","createError"],"mappings":"iPAWO,MAAMA,EAAiBC,IAC1B,MAAMC,EAAOC,SAASH,cAAcC,EAAQG,KAa5C,OAZIH,EAAQI,YACRC,EAAcJ,EAAMD,EAAQI,YAE5BJ,EAAQM,UACRC,EAAkBN,EAAMD,EAAQM,UAEjCN,EAAQQ,QACPC,EAAUR,EAAMD,EAAQQ,OAAQR,EAAQU,OAEzCV,EAAQW,YACPV,EAAKU,UAAYX,EAAQW,WAEtBV,CAAI,EAoBTQ,EAAYA,CAACR,EAAoBO,EAAyDE,KAE5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,IAAI,IACGwC,EAAExC,OACFyC,EAAEzC,OAdG0C,IAACF,EAA0BC,EAmC3C,IAAIF,EAAeJ,YAAaI,EAAeJ,UAAUpK,YAErD,MADA4K,QAAQC,MAAM,yBACR,IAAI3C,MAAM,yBAEpB,GAAIsC,EAAeN,UACf,OAAOD,EAAYO,EAAgBA,EAAeN,WAC/C,CAEH,MAAMY,ED9CgB7I,IACR9D,EAAc,CAC5BI,IAAK,MACLK,OAAQ,CAACmF,EAAW4F,GACpB7K,MAAOmD,EAAcnD,QC0CNiM,CAAcP,GAC7B,IACIvI,EAAcmI,UAAUpK,YAAY8K,GACpC,MAAMZ,QAAkBlC,EAAewC,GAEvC,OADAA,EAAeJ,UAAUE,YAAYQ,GAC9Bb,EAAYO,EAAgBN,EACtC,CAAC,MAAMW,GACJ5I,EAAcmI,UAAUE,YAAYQ,GACpC,MAAME,EF/Cd/I,KAEA,MAAMgJ,EAAW5K,EAAa4B,EAAckB,UAQ5C,OAPkBhF,EAAc,CAC5BI,IAAK,MACLK,OAAQ,CAACmF,EAAW2F,GACpB5K,MAAOmD,EAAcnD,MACrBC,UAAWkM,EAAQ/J,OAAOC,OAGd,EEqCa+J,CAAYV,GAEjC,OADAA,EAAeJ,UAAUpK,YAAYgL,GAC9B,CACHX,QAASA,KACLpI,EAAcmI,UAAUE,YAAYU,EAAa,EAG7D,CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dintero/discounts-web-sdk",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Dintero Discounts SDK for web frontends",
5
5
  "main": "dist/dintero-discounts-web-sdk.cjs.js",
6
6
  "module": "dist/dintero-discounts-web-sdk.esm.js",
@@ -11,10 +11,10 @@
11
11
  "umdName": "discounts"
12
12
  },
13
13
  "scripts": {
14
- "test": "karma start",
14
+ "test": "vitest --dom",
15
15
  "watch": "preconstruct watch",
16
16
  "build": "preconstruct build",
17
- "prepublishOnly": "npm run build",
17
+ "prepublishOnly": "yarn build",
18
18
  "semantic-release": "semantic-release"
19
19
  },
20
20
  "private": false,
@@ -29,20 +29,14 @@
29
29
  "url": "https://github.com/Dintero/Dintero.Discounts.Web.SDK/issues"
30
30
  },
31
31
  "devDependencies": {
32
- "@babel/preset-env": "^7.14.1",
33
- "@babel/preset-typescript": "^7.13.0",
34
- "@preconstruct/cli": "^2.1.0",
35
- "@semantic-release/git": "^10.0.1",
36
- "chai": "^4.2.0",
37
- "karma": "^6.3.16",
38
- "karma-chai": "^0.1.0",
39
- "karma-chrome-launcher": "^3.1.0",
40
- "karma-mocha": "^2.0.1",
41
- "karma-typescript": "^5.0.3",
42
- "mocha": "^8.1.1",
43
- "prettier": "^2.7.0",
44
- "puppeteer": "^19.0.0",
45
- "semantic-release": "^19.0.3",
46
- "typescript": "^4.2.4"
32
+ "@babel/core": "7.13.0",
33
+ "@babel/preset-typescript": "7.13.0",
34
+ "@preconstruct/cli": "2.8.1",
35
+ "@semantic-release/git": "10.0.1",
36
+ "happy-dom": "12.9.0",
37
+ "prettier": "3.0.3",
38
+ "semantic-release": "22.0.5",
39
+ "typescript": "5.2.2",
40
+ "vitest": "0.34.6"
47
41
  }
48
42
  }
@@ -1,224 +0,0 @@
1
- body, html {
2
- margin:0; padding: 0;
3
- height: 100%;
4
- }
5
- body {
6
- font-family: Helvetica Neue, Helvetica, Arial;
7
- font-size: 14px;
8
- color:#333;
9
- }
10
- .small { font-size: 12px; }
11
- *, *:after, *:before {
12
- -webkit-box-sizing:border-box;
13
- -moz-box-sizing:border-box;
14
- box-sizing:border-box;
15
- }
16
- h1 { font-size: 20px; margin: 0;}
17
- h2 { font-size: 14px; }
18
- pre {
19
- font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
20
- margin: 0;
21
- padding: 0;
22
- -moz-tab-size: 2;
23
- -o-tab-size: 2;
24
- tab-size: 2;
25
- }
26
- a { color:#0074D9; text-decoration:none; }
27
- a:hover { text-decoration:underline; }
28
- .strong { font-weight: bold; }
29
- .space-top1 { padding: 10px 0 0 0; }
30
- .pad2y { padding: 20px 0; }
31
- .pad1y { padding: 10px 0; }
32
- .pad2x { padding: 0 20px; }
33
- .pad2 { padding: 20px; }
34
- .pad1 { padding: 10px; }
35
- .space-left2 { padding-left:55px; }
36
- .space-right2 { padding-right:20px; }
37
- .center { text-align:center; }
38
- .clearfix { display:block; }
39
- .clearfix:after {
40
- content:'';
41
- display:block;
42
- height:0;
43
- clear:both;
44
- visibility:hidden;
45
- }
46
- .fl { float: left; }
47
- @media only screen and (max-width:640px) {
48
- .col3 { width:100%; max-width:100%; }
49
- .hide-mobile { display:none!important; }
50
- }
51
-
52
- .quiet {
53
- color: #7f7f7f;
54
- color: rgba(0,0,0,0.5);
55
- }
56
- .quiet a { opacity: 0.7; }
57
-
58
- .fraction {
59
- font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
60
- font-size: 10px;
61
- color: #555;
62
- background: #E8E8E8;
63
- padding: 4px 5px;
64
- border-radius: 3px;
65
- vertical-align: middle;
66
- }
67
-
68
- div.path a:link, div.path a:visited { color: #333; }
69
- table.coverage {
70
- border-collapse: collapse;
71
- margin: 10px 0 0 0;
72
- padding: 0;
73
- }
74
-
75
- table.coverage td {
76
- margin: 0;
77
- padding: 0;
78
- vertical-align: top;
79
- }
80
- table.coverage td.line-count {
81
- text-align: right;
82
- padding: 0 5px 0 20px;
83
- }
84
- table.coverage td.line-coverage {
85
- text-align: right;
86
- padding-right: 10px;
87
- min-width:20px;
88
- }
89
-
90
- table.coverage td span.cline-any {
91
- display: inline-block;
92
- padding: 0 5px;
93
- width: 100%;
94
- }
95
- .missing-if-branch {
96
- display: inline-block;
97
- margin-right: 5px;
98
- border-radius: 3px;
99
- position: relative;
100
- padding: 0 4px;
101
- background: #333;
102
- color: yellow;
103
- }
104
-
105
- .skip-if-branch {
106
- display: none;
107
- margin-right: 10px;
108
- position: relative;
109
- padding: 0 4px;
110
- background: #ccc;
111
- color: white;
112
- }
113
- .missing-if-branch .typ, .skip-if-branch .typ {
114
- color: inherit !important;
115
- }
116
- .coverage-summary {
117
- border-collapse: collapse;
118
- width: 100%;
119
- }
120
- .coverage-summary tr { border-bottom: 1px solid #bbb; }
121
- .keyline-all { border: 1px solid #ddd; }
122
- .coverage-summary td, .coverage-summary th { padding: 10px; }
123
- .coverage-summary tbody { border: 1px solid #bbb; }
124
- .coverage-summary td { border-right: 1px solid #bbb; }
125
- .coverage-summary td:last-child { border-right: none; }
126
- .coverage-summary th {
127
- text-align: left;
128
- font-weight: normal;
129
- white-space: nowrap;
130
- }
131
- .coverage-summary th.file { border-right: none !important; }
132
- .coverage-summary th.pct { }
133
- .coverage-summary th.pic,
134
- .coverage-summary th.abs,
135
- .coverage-summary td.pct,
136
- .coverage-summary td.abs { text-align: right; }
137
- .coverage-summary td.file { white-space: nowrap; }
138
- .coverage-summary td.pic { min-width: 120px !important; }
139
- .coverage-summary tfoot td { }
140
-
141
- .coverage-summary .sorter {
142
- height: 10px;
143
- width: 7px;
144
- display: inline-block;
145
- margin-left: 0.5em;
146
- background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
147
- }
148
- .coverage-summary .sorted .sorter {
149
- background-position: 0 -20px;
150
- }
151
- .coverage-summary .sorted-desc .sorter {
152
- background-position: 0 -10px;
153
- }
154
- .status-line { height: 10px; }
155
- /* yellow */
156
- .cbranch-no { background: yellow !important; color: #111; }
157
- /* dark red */
158
- .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
159
- .low .chart { border:1px solid #C21F39 }
160
- .highlighted,
161
- .highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
162
- background: #C21F39 !important;
163
- }
164
- /* medium red */
165
- .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
166
- /* light red */
167
- .low, .cline-no { background:#FCE1E5 }
168
- /* light green */
169
- .high, .cline-yes { background:rgb(230,245,208) }
170
- /* medium green */
171
- .cstat-yes { background:rgb(161,215,106) }
172
- /* dark green */
173
- .status-line.high, .high .cover-fill { background:rgb(77,146,33) }
174
- .high .chart { border:1px solid rgb(77,146,33) }
175
- /* dark yellow (gold) */
176
- .status-line.medium, .medium .cover-fill { background: #f9cd0b; }
177
- .medium .chart { border:1px solid #f9cd0b; }
178
- /* light yellow */
179
- .medium { background: #fff4c2; }
180
-
181
- .cstat-skip { background: #ddd; color: #111; }
182
- .fstat-skip { background: #ddd; color: #111 !important; }
183
- .cbranch-skip { background: #ddd !important; color: #111; }
184
-
185
- span.cline-neutral { background: #eaeaea; }
186
-
187
- .coverage-summary td.empty {
188
- opacity: .5;
189
- padding-top: 4px;
190
- padding-bottom: 4px;
191
- line-height: 1;
192
- color: #888;
193
- }
194
-
195
- .cover-fill, .cover-empty {
196
- display:inline-block;
197
- height: 12px;
198
- }
199
- .chart {
200
- line-height: 0;
201
- }
202
- .cover-empty {
203
- background: white;
204
- }
205
- .cover-full {
206
- border-right: none !important;
207
- }
208
- pre.prettyprint {
209
- border: none !important;
210
- padding: 0 !important;
211
- margin: 0 !important;
212
- }
213
- .com { color: #999 !important; }
214
- .ignore-none { color: #999; font-weight: normal; }
215
-
216
- .wrapper {
217
- min-height: 100%;
218
- height: auto !important;
219
- height: 100%;
220
- margin: 0 auto -48px;
221
- }
222
- .footer, .push {
223
- height: 48px;
224
- }
@@ -1,87 +0,0 @@
1
- /* eslint-disable */
2
- var jumpToCode = (function init() {
3
- // Classes of code we would like to highlight in the file view
4
- var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
5
-
6
- // Elements to highlight in the file listing view
7
- var fileListingElements = ['td.pct.low'];
8
-
9
- // We don't want to select elements that are direct descendants of another match
10
- var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
11
-
12
- // Selecter that finds elements on the page to which we can jump
13
- var selector =
14
- fileListingElements.join(', ') +
15
- ', ' +
16
- notSelector +
17
- missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
18
-
19
- // The NodeList of matching elements
20
- var missingCoverageElements = document.querySelectorAll(selector);
21
-
22
- var currentIndex;
23
-
24
- function toggleClass(index) {
25
- missingCoverageElements
26
- .item(currentIndex)
27
- .classList.remove('highlighted');
28
- missingCoverageElements.item(index).classList.add('highlighted');
29
- }
30
-
31
- function makeCurrent(index) {
32
- toggleClass(index);
33
- currentIndex = index;
34
- missingCoverageElements.item(index).scrollIntoView({
35
- behavior: 'smooth',
36
- block: 'center',
37
- inline: 'center'
38
- });
39
- }
40
-
41
- function goToPrevious() {
42
- var nextIndex = 0;
43
- if (typeof currentIndex !== 'number' || currentIndex === 0) {
44
- nextIndex = missingCoverageElements.length - 1;
45
- } else if (missingCoverageElements.length > 1) {
46
- nextIndex = currentIndex - 1;
47
- }
48
-
49
- makeCurrent(nextIndex);
50
- }
51
-
52
- function goToNext() {
53
- var nextIndex = 0;
54
-
55
- if (
56
- typeof currentIndex === 'number' &&
57
- currentIndex < missingCoverageElements.length - 1
58
- ) {
59
- nextIndex = currentIndex + 1;
60
- }
61
-
62
- makeCurrent(nextIndex);
63
- }
64
-
65
- return function jump(event) {
66
- if (
67
- document.getElementById('fileSearch') === document.activeElement &&
68
- document.activeElement != null
69
- ) {
70
- // if we're currently focused on the search input, we don't want to navigate
71
- return;
72
- }
73
-
74
- switch (event.which) {
75
- case 78: // n
76
- case 74: // j
77
- goToNext();
78
- break;
79
- case 66: // b
80
- case 75: // k
81
- case 80: // p
82
- goToPrevious();
83
- break;
84
- }
85
- };
86
- })();
87
- window.addEventListener('keydown', jumpToCode);