@ukic/web-components 2.27.1 → 2.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/dist/cjs/core.cjs.js +1 -1
  2. package/dist/cjs/ic-alert.cjs.entry.js +9 -4
  3. package/dist/cjs/ic-alert.cjs.entry.js.map +1 -1
  4. package/dist/cjs/ic-badge.cjs.entry.js +2 -2
  5. package/dist/cjs/ic-badge.cjs.entry.js.map +1 -1
  6. package/dist/cjs/ic-dialog.cjs.entry.js.map +1 -1
  7. package/dist/cjs/ic-text-field.cjs.entry.js +2 -1
  8. package/dist/cjs/ic-text-field.cjs.entry.js.map +1 -1
  9. package/dist/cjs/loader.cjs.js +1 -1
  10. package/dist/collection/components/ic-alert/ic-alert.css +9 -1
  11. package/dist/collection/components/ic-alert/ic-alert.js +27 -3
  12. package/dist/collection/components/ic-alert/ic-alert.js.map +1 -1
  13. package/dist/collection/components/ic-alert/test/basic/ic-alert.spec.js +114 -0
  14. package/dist/collection/components/ic-alert/test/basic/ic-alert.spec.js.map +1 -1
  15. package/dist/collection/components/ic-badge/ic-badge.css +5 -0
  16. package/dist/collection/components/ic-badge/ic-badge.js +1 -1
  17. package/dist/collection/components/ic-badge/ic-badge.js.map +1 -1
  18. package/dist/collection/components/ic-dialog/ic-dialog.js +1 -1
  19. package/dist/collection/components/ic-dialog/ic-dialog.js.map +1 -1
  20. package/dist/collection/components/ic-text-field/ic-text-field.js +20 -1
  21. package/dist/collection/components/ic-text-field/ic-text-field.js.map +1 -1
  22. package/dist/collection/components/ic-text-field/test/basic/ic-text-field.input.spec.js +7 -0
  23. package/dist/collection/components/ic-text-field/test/basic/ic-text-field.input.spec.js.map +1 -1
  24. package/dist/collection/components/ic-text-field/test/basic/ic-text-field.textarea.spec.js +47 -17
  25. package/dist/collection/components/ic-text-field/test/basic/ic-text-field.textarea.spec.js.map +1 -1
  26. package/dist/components/ic-alert2.js +11 -5
  27. package/dist/components/ic-alert2.js.map +1 -1
  28. package/dist/components/ic-badge.js +2 -2
  29. package/dist/components/ic-badge.js.map +1 -1
  30. package/dist/components/ic-dialog.js.map +1 -1
  31. package/dist/components/ic-text-field2.js +3 -1
  32. package/dist/components/ic-text-field2.js.map +1 -1
  33. package/dist/core/core.esm.js +1 -1
  34. package/dist/core/core.esm.js.map +1 -1
  35. package/dist/core/{p-9146a7f9.entry.js → p-4562904d.entry.js} +2 -2
  36. package/dist/core/p-4562904d.entry.js.map +1 -0
  37. package/dist/core/p-55b11f6f.entry.js.map +1 -1
  38. package/dist/core/p-78605899.entry.js +2 -0
  39. package/dist/core/p-78605899.entry.js.map +1 -0
  40. package/dist/core/p-9e15d0e1.entry.js +2 -0
  41. package/dist/core/p-9e15d0e1.entry.js.map +1 -0
  42. package/dist/esm/core.js +1 -1
  43. package/dist/esm/ic-alert.entry.js +10 -5
  44. package/dist/esm/ic-alert.entry.js.map +1 -1
  45. package/dist/esm/ic-badge.entry.js +2 -2
  46. package/dist/esm/ic-badge.entry.js.map +1 -1
  47. package/dist/esm/ic-dialog.entry.js.map +1 -1
  48. package/dist/esm/ic-text-field.entry.js +2 -1
  49. package/dist/esm/ic-text-field.entry.js.map +1 -1
  50. package/dist/esm/loader.js +1 -1
  51. package/dist/types/components/ic-alert/ic-alert.d.ts +5 -0
  52. package/dist/types/components/ic-dialog/ic-dialog.d.ts +1 -1
  53. package/dist/types/components/ic-text-field/ic-text-field.d.ts +4 -0
  54. package/dist/types/components.d.ts +18 -2
  55. package/hydrate/index.js +16 -7
  56. package/package.json +2 -2
  57. package/vscode-data.json +9 -1
  58. package/dist/core/p-9146a7f9.entry.js.map +0 -1
  59. package/dist/core/p-ad67c84f.entry.js +0 -2
  60. package/dist/core/p-ad67c84f.entry.js.map +0 -1
  61. package/dist/core/p-f735a277.entry.js +0 -2
  62. package/dist/core/p-f735a277.entry.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"names":["icAlertCss","Alert","this","hostMutationObserver","dismissAction","dismiss","emit","icDismiss","hostMutationCallback","mutationList","some","type","addedNodes","removedNodes","checkSlotInChildMutations","forceUpdate","disconnectedCallback","_a","disconnect","componentDidLoad","alertTitleShouldWrap","MutationObserver","observe","el","childList","handleClick","visible","titleHeight","shadowRoot","querySelector","clientHeight","alertTitleWrap","render","variant","heading","message","titleAbove","dismissible","announced","h","Host","role","class","IcThemeForegroundEnum","Dark","innerHTML","VARIANT_ICONS","icon","name","isSlotUsed","closeIcon","onClick","appearance","title"],"sources":["src/components/ic-alert/ic-alert.css?tag=ic-alert&encapsulation=shadow","src/components/ic-alert/ic-alert.tsx"],"sourcesContent":["@import \"../../global/normalize.css\";\n\n:host {\n display: block;\n}\n\n.container {\n min-height: 3.5rem;\n border-radius: var(--ic-border-radius);\n position: relative;\n display: flex;\n align-items: center;\n}\n\n.container-neutral {\n background-color: var(--ic-status-unknown-light);\n}\n\n.container-info {\n background-color: var(--ic-status-info-light);\n}\n\n.container-warning {\n background-color: var(--ic-status-warning-light);\n}\n\n.container-error {\n background-color: var(--ic-status-error-light);\n}\n\n.container-success {\n background-color: var(--ic-status-success-light);\n}\n\n.alert-icon-container {\n height: 100%;\n display: flex;\n align-items: center;\n}\n\n.divider {\n height: 100%;\n width: var(--ic-space-xs);\n border-radius: var(--ic-space-xxxs) 0 0 var(--ic-space-xxxs);\n position: absolute;\n}\n\n.divider-neutral {\n background-color: var(--ic-status-unknown);\n}\n\n.divider-info {\n background-color: var(--ic-status-info);\n}\n\n.divider-warning {\n background-color: var(--ic-status-warning);\n}\n\n.divider-error {\n background-color: var(--ic-status-error);\n}\n\n.divider-success {\n background-color: var(--ic-status-success);\n}\n\n.alert-icon {\n height: var(--ic-space-lg);\n width: 1.375rem;\n margin-left: 1.125rem;\n}\n\n.alert-icon > svg {\n height: var(--ic-space-lg);\n width: var(--ic-space-lg);\n display: inline-block;\n}\n\n.icon-neutral > svg {\n fill: var(--ic-status-unknown);\n}\n\n:host([variant=\"info\"]) .alert-icon svg {\n fill: var(--ic-status-info);\n}\n\n:host([variant=\"warning\"]) .alert-icon svg {\n fill: var(--ic-status-warning);\n}\n\n:host([variant=\"error\"]) .alert-icon svg {\n fill: var(--ic-status-error);\n}\n\n:host([variant=\"success\"]) .alert-icon svg {\n fill: var(--ic-status-success);\n}\n\n.alert-content {\n display: flex;\n align-items: center;\n margin-left: 0.625rem;\n width: 100%;\n}\n\n.alert-message {\n display: flex;\n align-items: center;\n padding: var(--ic-space-xs) var(--ic-space-xs) var(--ic-space-xs) 0;\n flex: 1;\n}\n\n.alert-message-title-above {\n display: inline;\n}\n\n.alert-title {\n margin-right: var(--ic-space-xs);\n}\n\n.alert-title-above {\n white-space: normal;\n}\n\n.alert-action-container {\n margin-right: var(--ic-space-xs);\n display: flex;\n align-items: center;\n}\n\n.dismiss-icon {\n margin-right: var(--ic-space-xxxs);\n margin-left: -0.375rem;\n padding: 0.375rem;\n border: none;\n border-radius: 50%;\n background-color: inherit;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.dismiss-icon:hover {\n cursor: pointer;\n}\n\n@media (max-width: 628px) {\n .alert-content {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n }\n\n .alert-message {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n }\n\n .alert-title {\n white-space: normal;\n }\n\n .alert-action-container {\n margin-bottom: var(--ic-space-xs);\n }\n}\n\n@media (forced-colors: active) {\n .container {\n border: var(--ic-hc-border);\n }\n}\n","import {\n Component,\n Element,\n Event,\n EventEmitter,\n Host,\n State,\n Listen,\n Prop,\n h,\n forceUpdate,\n} from \"@stencil/core\";\nimport closeIcon from \"../../assets/close-icon.svg\";\nimport { isSlotUsed, checkSlotInChildMutations } from \"../../utils/helpers\";\nimport { IcThemeForegroundEnum, IcStatusVariants } from \"../../utils/types\";\nimport { VARIANT_ICONS } from \"../../utils/constants\";\n\n/**\n * @slot message - Content is placed to the right of the title.\n * @slot action - Content is placed to the right of the message.\n */\n@Component({\n tag: \"ic-alert\",\n styleUrl: \"ic-alert.css\",\n shadow: true,\n})\nexport class Alert {\n private hostMutationObserver: MutationObserver = null;\n\n @Element() el: HTMLIcAlertElement;\n\n @State() alertTitleWrap: boolean = false;\n @State() visible: boolean = true;\n\n /**\n * If `true`, the alert will have the 'alert' ARIA role and will be announced to screen readers.\n */\n @Prop() announced?: boolean = true;\n\n /**\n * If `true`, the alert will have a close icon at the end to dismiss it.\n */\n @Prop() dismissible?: boolean = false;\n\n /**\n * The optional title to display at the start of the alert.\n */\n @Prop() heading?: string = \"\";\n\n /**\n * The main body message of the alert.\n */\n @Prop() message?: string;\n\n /**\n * If `true`, the title and message will appear above and below instead of inline.\n */\n @Prop() titleAbove?: boolean = false;\n\n /**\n * The variant of the alert which will be rendered.\n */\n @Prop() variant?: IcStatusVariants = \"neutral\";\n\n /**\n * @deprecated This event should not be used anymore. Use icDismiss instead.\n */\n @Event() dismiss: EventEmitter<void>;\n\n /**\n * Is emitted when the user dismisses the alert.\n */\n @Event() icDismiss: EventEmitter<void>;\n\n disconnectedCallback(): void {\n this.hostMutationObserver?.disconnect();\n }\n\n componentDidLoad(): void {\n this.alertTitleShouldWrap();\n\n this.hostMutationObserver = new MutationObserver(this.hostMutationCallback);\n this.hostMutationObserver.observe(this.el, {\n childList: true,\n });\n }\n\n @Listen(\"icDismiss\", { capture: true })\n handleClick(): void {\n this.visible = !this.visible;\n }\n\n private dismissAction = (): void => {\n this.dismiss.emit();\n this.icDismiss.emit();\n };\n\n private alertTitleShouldWrap() {\n const titleHeight =\n this.el.shadowRoot.querySelector(\".alert-title\")?.clientHeight;\n if (titleHeight > 24) this.alertTitleWrap = true;\n }\n\n private hostMutationCallback = (mutationList: MutationRecord[]): void => {\n if (\n mutationList.some(({ type, addedNodes, removedNodes }) =>\n type === \"childList\"\n ? checkSlotInChildMutations(addedNodes, removedNodes, \"action\")\n : false\n )\n ) {\n forceUpdate(this);\n }\n };\n\n render() {\n const {\n variant,\n heading,\n message,\n titleAbove,\n dismissible,\n announced,\n visible,\n } = this;\n\n return (\n visible && (\n <Host\n role={announced ? \"alert\" : null}\n class={{\n [IcThemeForegroundEnum.Dark]: true,\n }}\n >\n <div\n class={{\n [\"container\"]: true,\n [`container-${variant}`]: true,\n }}\n >\n <div class=\"alert-icon-container\">\n <div\n class={{\n [\"divider\"]: true,\n [`divider-${variant}`]: true,\n }}\n ></div>\n <span\n class={{\n [\"alert-icon\"]: true,\n [\"svg-container\"]: true,\n [`icon-${variant}`]: true,\n }}\n innerHTML={VARIANT_ICONS[variant].icon}\n ></span>\n </div>\n <div class=\"alert-content\">\n <div\n class={{\n [\"alert-message\"]: true,\n [\"alert-message-title-above\"]:\n titleAbove || this.alertTitleWrap,\n }}\n >\n {heading && (\n <ic-typography\n class={{\n [\"alert-title\"]: true,\n [\"alert-title-above\"]: titleAbove || this.alertTitleWrap,\n }}\n variant=\"subtitle-large\"\n >\n <p>{heading}</p>\n </ic-typography>\n )}\n <slot name=\"message\">\n <ic-typography variant=\"body\">{message}</ic-typography>\n </slot>\n </div>\n {isSlotUsed(this.el, \"action\") && (\n <div class=\"alert-action-container\">\n <slot name=\"action\" />\n </div>\n )}\n </div>\n <div class=\"dismiss-icon-container\">\n {dismissible && (\n <ic-button\n class={{\n [\"svg-container\"]: true,\n [\"dismiss-icon\"]: true,\n }}\n innerHTML={closeIcon}\n onClick={this.dismissAction}\n variant=\"icon\"\n appearance={IcThemeForegroundEnum.Dark}\n title=\"dismiss\"\n ></ic-button>\n )}\n </div>\n </div>\n </Host>\n )\n );\n }\n}\n"],"mappings":"iMAAA,MAAMA,EAAa,0sJ,MC0BNC,EAAK,M,+FACRC,KAAAC,qBAAyC,KAiEzCD,KAAAE,cAAgB,KACtBF,KAAKG,QAAQC,OACbJ,KAAKK,UAAUD,MAAM,EASfJ,KAAAM,qBAAwBC,IAC9B,GACEA,EAAaC,MAAK,EAAGC,OAAMC,aAAYC,kBACrCF,IAAS,YACLG,EAA0BF,EAAYC,EAAc,UACpD,QAEN,CACAE,EAAYb,K,uBAhFmB,M,aACP,K,eAKE,K,iBAKE,M,aAKL,G,uCAUI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lCc,EAAW/C,KAAKqB,GAAI,WACnBgB,EAAA,OAAKG,MAAM,0BACTH,EAAA,QAAMS,KAAK,aAIjBT,EAAA,OAAKG,MAAM,0BACRL,GACCE,EAAA,aACEG,MAAO,CACL,CAAC,iBAAkB,KACnB,CAAC,gBAAiB,MAEpBG,UAAWK,EACXC,QAASjD,KAAKE,cACd6B,QAAQ,OACRmB,WAAYT,EAAsBC,KAClCS,MAAM,c"}
@@ -1,2 +0,0 @@
1
- import{r as s,h as a,H as t,g as i}from"./p-6b5e91e2.js";import{c,h as e,g as r,r as o,b as h,d as l,a as n}from"./p-fef9e8c9.js";import"./p-26b7b18f.js";const p="@media (prefers-reduced-motion: no-preference){:host(.show){animation:expand var(--ic-transition-duration-slow)}:host(.hide){animation:shrink var(--ic-transition-duration-slow)}}:host{display:flex;height:var(--ic-space-md);min-width:var(--ic-space-md);width:-moz-fit-content;width:fit-content;border-radius:calc(2 * var(--ic-space-xxl));position:absolute}:host(.neutral){background-color:var(--ic-architectural-500)}:host(.light){background-color:var(--ic-architectural-40)}:host(.info){background-color:var(--ic-status-info)}:host(.warning){background-color:var(--ic-status-warning-mid)}:host(.error){background-color:var(--ic-status-error)}:host(.success){background-color:var(--ic-status-success)}:host(.small){height:var(--ic-space-sm);min-width:var(--ic-space-sm)}:host(.large){height:calc(var(--ic-space-md) + var(--ic-space-xxs));min-width:calc(var(--ic-space-md) + var(--ic-space-xxs))}:host(.dot.default){height:var(--ic-space-xs);width:var(--ic-space-xs);min-width:var(--ic-space-xs)}:host(.dot.small){height:calc(var(--ic-space-xxs) + var(--ic-space-xxxs));width:calc(var(--ic-space-xxs) + var(--ic-space-xxxs));min-width:calc(var(--ic-space-xxs) + var(--ic-space-xxxs))}:host(.dot.large){height:var(--ic-space-sm);width:var(--ic-space-sm);min-width:var(--ic-space-sm)}:host(.foreground-dark) ::slotted(*){fill:var(--ic-color-primary-text)}:host(.foreground-light) ::slotted(*){fill:white}:host(.foreground-dark) ic-typography{color:var(--ic-color-primary-text)}:host(.foreground-light) ic-typography{color:white}:host(.text) ic-typography{align-self:center;padding:0 calc((var(--ic-space-xs) + var(--ic-space-1px)) / 2)\n var(--ic-space-1px)}:host(.text.small) ic-typography{padding:0 0.2132rem}:host(.text.large) ic-typography{padding:0 calc((var(--ic-space-sm) + var(--ic-space-1px)) / 2)\n var(--ic-space-1px)}:host(.icon) ::slotted(svg){width:var(--ic-space-sm);height:var(--ic-space-sm);padding:var(--ic-space-xxxs)}:host(.icon.small) ::slotted(svg){width:var(--ic-space-xs);height:var(--ic-space-xs)}:host(.icon.large) ::slotted(svg){width:calc(var(--ic-space-sm) + var(--ic-space-xxxs));height:calc(var(--ic-space-sm) + var(--ic-space-xxxs));padding:calc(var(--ic-space-xxxs) + var(--ic-space-1px))}:host(.far){top:calc(-1 * var(--ic-space-xs));right:calc(-1 * var(--ic-space-xs))}:host(.far.small),:host(.dot.far.large){top:calc(-1 * var(--ic-space-xxs));right:calc(-1 * var(--ic-space-xxs))}:host(.dot.far),:host(.dot.far.small){top:calc(-1 * var(--ic-space-xxxs));right:calc(-1 * var(--ic-space-xxxs))}:host(.near){top:calc(-1 * calc(var(--ic-space-xxs) + var(--ic-space-1px)));right:calc(-1 * calc(var(--ic-space-xxs) + var(--ic-space-1px)))}:host(.dot.near){top:calc(-1 * var(--ic-space-1px));right:calc(-1 * var(--ic-space-1px))}:host(.inline){position:static}:host(.hide){visibility:hidden !important;transition:visibility var(--ic-transition-duration-slow)}@keyframes expand{from{opacity:0;transform:scale(0)}to{opacity:1;transform:scale(1)}}@keyframes shrink{from{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(0)}}";const d=class{constructor(a){s(this,a);this.ariaLabel=null;this.setBadgeColour=()=>{const s=c(this.customColor);if(s){this.customColorRGBA=s;const{r:a,g:t,b:i,a:c}=s;this.el.style.backgroundColor=`rgba(${a}, ${t}, ${i}, ${c})`}};this.getBadgeRGB=()=>{switch(this.variant){case"custom":return this.customColorRGBA;case"error":case"success":case"warning":case"info":{return o(r(`--ic-status-${this.variant}`))}case"neutral":case"light":return e(r(`--ic-architectural-${this.variant==="neutral"?500:40}`))}};this.getBadgeForeground=()=>{const{r:s,g:a,b:t}=this.getBadgeRGB();this.foregroundColour=h((s*299+a*587+t*114)/1e3)};this.getTextLabel=()=>this.maxNumber&&Number(this.textLabel)>this.maxNumber?`${this.maxNumber}+`:this.textLabel;this.setAccessibleLabel=()=>{const s=this.el.parentElement;const a=this.isAccessibleLabelDefined()?this.accessibleLabel:this.textLabel||"with badge being displayed";if(s){const{tagName:t}=s;if(t!=="IC-CARD"&&(t!=="IC-TAB"||t==="IC-TAB"&&this.parentAriaLabel)){const t=this.parentAriaLabel?`${this.parentAriaLabel} ,`:"";s.ariaLabel=this.visible?`${t} ${a}`:undefined}else{this.ariaLabel=`, ${a}`}}};this.isAccessibleLabelDefined=()=>l(this.accessibleLabel)&&this.accessibleLabel!==null;this.accessibleLabel=undefined;this.customColor=null;this.maxNumber=undefined;this.position="far";this.size="default";this.textLabel=undefined;this.type="text";this.variant="neutral";this.visible=true}accessibleLabelHandler(){this.setAccessibleLabel()}customColorHandler(){this.variant==="custom"&&this.setBadgeColour()}variantHandler(){this.getBadgeForeground()}visibleHandler(){this.setAccessibleLabel()}componentWillLoad(){var s;this.variant==="custom"&&this.setBadgeColour();this.getBadgeForeground();const a=(s=this.el.parentElement)===null||s===void 0?void 0:s.ariaLabel;if(a)this.parentAriaLabel=a;this.setAccessibleLabel()}componentDidLoad(){this.type==="text"&&n([{prop:this.textLabel,propName:"text-label"}],"Badge")}async showBadge(){this.visible=true}async hideBadge(){this.visible=false}render(){const{ariaLabel:s,el:i,foregroundColour:c,getTextLabel:e,position:r,size:o,textLabel:h,type:l,variant:n,visible:p}=this;return a(t,{class:{[`${r}`]:true,[`${o}`]:true,[`${n}`]:true,[`${l}`]:true,[`foreground-${c}`]:c!==null,[`${p?"show":"hide"}`]:true},id:i.id||null,"aria-label":s,role:"status"},l==="icon"&&a("slot",{name:"badge-icon"}),l==="text"&&h&&a("ic-typography",{variant:o==="small"?"badge-small":"badge"},e()))}static get delegatesFocus(){return true}get el(){return i(this)}static get watchers(){return{accessibleLabel:["accessibleLabelHandler"],customColor:["customColorHandler"],variant:["variantHandler"],visible:["visibleHandler"]}}};d.style=p;export{d as ic_badge};
2
- //# sourceMappingURL=p-f735a277.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["icBadgeCss","Badge","this","ariaLabel","setBadgeColour","colorRGBA","convertToRGBA","customColor","customColorRGBA","r","g","b","a","el","style","backgroundColor","getBadgeRGB","variant","rgbaStrToObj","getCssProperty","hexToRgba","getBadgeForeground","foregroundColour","getThemeForegroundColor","getTextLabel","maxNumber","Number","textLabel","setAccessibleLabel","parentEl","parentElement","defaultAriaLabel","isAccessibleLabelDefined","accessibleLabel","tagName","parentAriaLabel","ariaLabelPrefix","visible","undefined","isPropDefined","accessibleLabelHandler","customColorHandler","variantHandler","visibleHandler","componentWillLoad","_a","componentDidLoad","type","onComponentRequiredPropUndefined","prop","propName","showBadge","hideBadge","render","position","size","h","Host","class","id","role","name"],"sources":["src/components/ic-badge/ic-badge.css?tag=ic-badge&encapsulation=shadow","src/components/ic-badge/ic-badge.tsx"],"sourcesContent":["@media (prefers-reduced-motion: no-preference) {\n :host(.show) {\n animation: expand var(--ic-transition-duration-slow);\n }\n\n :host(.hide) {\n animation: shrink var(--ic-transition-duration-slow);\n }\n}\n\n:host {\n display: flex;\n height: var(--ic-space-md);\n min-width: var(--ic-space-md);\n width: fit-content;\n border-radius: calc(2 * var(--ic-space-xxl));\n position: absolute;\n}\n\n:host(.neutral) {\n background-color: var(--ic-architectural-500);\n}\n\n:host(.light) {\n background-color: var(--ic-architectural-40);\n}\n\n:host(.info) {\n background-color: var(--ic-status-info);\n}\n\n:host(.warning) {\n background-color: var(--ic-status-warning-mid);\n}\n\n:host(.error) {\n background-color: var(--ic-status-error);\n}\n\n:host(.success) {\n background-color: var(--ic-status-success);\n}\n\n:host(.small) {\n height: var(--ic-space-sm);\n min-width: var(--ic-space-sm);\n}\n\n:host(.large) {\n height: calc(var(--ic-space-md) + var(--ic-space-xxs));\n min-width: calc(var(--ic-space-md) + var(--ic-space-xxs));\n}\n\n:host(.dot.default) {\n height: var(--ic-space-xs);\n width: var(--ic-space-xs);\n min-width: var(--ic-space-xs);\n}\n\n:host(.dot.small) {\n height: calc(var(--ic-space-xxs) + var(--ic-space-xxxs));\n width: calc(var(--ic-space-xxs) + var(--ic-space-xxxs));\n min-width: calc(var(--ic-space-xxs) + var(--ic-space-xxxs));\n}\n\n:host(.dot.large) {\n height: var(--ic-space-sm);\n width: var(--ic-space-sm);\n min-width: var(--ic-space-sm);\n}\n\n:host(.foreground-dark) ::slotted(*) {\n fill: var(--ic-color-primary-text);\n}\n\n:host(.foreground-light) ::slotted(*) {\n fill: white;\n}\n\n:host(.foreground-dark) ic-typography {\n color: var(--ic-color-primary-text);\n}\n\n:host(.foreground-light) ic-typography {\n color: white;\n}\n\n:host(.text) ic-typography {\n align-self: center;\n padding: 0 calc((var(--ic-space-xs) + var(--ic-space-1px)) / 2)\n var(--ic-space-1px);\n}\n\n:host(.text.small) ic-typography {\n padding: 0 0.2132rem;\n}\n\n:host(.text.large) ic-typography {\n padding: 0 calc((var(--ic-space-sm) + var(--ic-space-1px)) / 2)\n var(--ic-space-1px);\n}\n\n:host(.icon) ::slotted(svg) {\n width: var(--ic-space-sm);\n height: var(--ic-space-sm);\n padding: var(--ic-space-xxxs);\n}\n\n:host(.icon.small) ::slotted(svg) {\n width: var(--ic-space-xs);\n height: var(--ic-space-xs);\n}\n\n:host(.icon.large) ::slotted(svg) {\n width: calc(var(--ic-space-sm) + var(--ic-space-xxxs));\n height: calc(var(--ic-space-sm) + var(--ic-space-xxxs));\n padding: calc(var(--ic-space-xxxs) + var(--ic-space-1px));\n}\n\n:host(.far) {\n top: calc(-1 * var(--ic-space-xs));\n right: calc(-1 * var(--ic-space-xs));\n}\n\n:host(.far.small),\n:host(.dot.far.large) {\n top: calc(-1 * var(--ic-space-xxs));\n right: calc(-1 * var(--ic-space-xxs));\n}\n\n:host(.dot.far),\n:host(.dot.far.small) {\n top: calc(-1 * var(--ic-space-xxxs));\n right: calc(-1 * var(--ic-space-xxxs));\n}\n\n:host(.near) {\n top: calc(-1 * calc(var(--ic-space-xxs) + var(--ic-space-1px)));\n right: calc(-1 * calc(var(--ic-space-xxs) + var(--ic-space-1px)));\n}\n\n:host(.dot.near) {\n top: calc(-1 * var(--ic-space-1px));\n right: calc(-1 * var(--ic-space-1px));\n}\n\n:host(.inline) {\n position: static;\n}\n\n:host(.hide) {\n visibility: hidden !important;\n transition: visibility var(--ic-transition-duration-slow);\n}\n\n@keyframes expand {\n from {\n opacity: 0;\n transform: scale(0);\n }\n\n to {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n@keyframes shrink {\n from {\n opacity: 1;\n transform: scale(1);\n }\n\n to {\n opacity: 0;\n transform: scale(0);\n }\n}\n","import {\n Component,\n Element,\n Host,\n Method,\n Prop,\n Watch,\n h,\n} from \"@stencil/core\";\nimport {\n IcBadgePositions,\n IcBadgeTypes,\n IcBadgeVariants,\n} from \"./ic-badge.types\";\nimport {\n IcColorRGBA,\n IcSizes,\n IcThemeForeground,\n IcColor,\n} from \"../../utils/types\";\nimport {\n convertToRGBA,\n getCssProperty,\n getThemeForegroundColor,\n hexToRgba,\n isPropDefined,\n onComponentRequiredPropUndefined,\n rgbaStrToObj,\n} from \"../../utils/helpers\";\n\n/**\n * @slot badge-icon - Icon will be rendered inside the badge if type is set to icon.\n */\n@Component({\n tag: \"ic-badge\",\n styleUrl: \"ic-badge.css\",\n shadow: {\n delegatesFocus: true,\n },\n})\nexport class Badge {\n private ariaLabel: string = null;\n private customColorRGBA: IcColorRGBA;\n private foregroundColour: IcThemeForeground;\n private parentAriaLabel: string;\n\n @Element() el: HTMLIcBadgeElement;\n\n /**\n * The accessible label of the badge component to provide context for screen reader users.\n */\n @Prop() accessibleLabel?: string;\n\n @Watch(\"accessibleLabel\")\n accessibleLabelHandler(): void {\n this.setAccessibleLabel();\n }\n\n /**\n * The custom badge colour. This will only style the badge component if variant=\"custom\".\n * Can be a hex value e.g. \"#ff0000\", RGB e.g. \"rgb(255, 0, 0)\", or RGBA e.g. \"rgba(255, 0, 0, 1)\".\n */\n @Prop() customColor?: IcColor = null;\n\n @Watch(\"customColor\")\n customColorHandler(): void {\n this.variant === \"custom\" && this.setBadgeColour();\n }\n\n /**\n * The maximum number shown on the badge appended with a +.\n * This will only be displayed if type=\"text\" and textLabel is not empty.\n */\n @Prop() maxNumber?: number;\n\n /**\n * The positioning of the badge in reference to the parent element.\n */\n @Prop() position?: IcBadgePositions = \"far\";\n\n /**\n * The size of the badge to be displayed.\n */\n @Prop() size?: IcSizes = \"default\";\n\n /**\n * The text displayed in the badge. This will only be displayed if type=\"text\".\n */\n @Prop() textLabel?: string;\n\n /**\n * The type of badge to be displayed.\n */\n @Prop() type?: IcBadgeTypes = \"text\";\n\n /**\n * The variant of the badge to be displayed.\n */\n @Prop() variant?: IcBadgeVariants = \"neutral\";\n\n @Watch(\"variant\")\n variantHandler(): void {\n this.getBadgeForeground();\n }\n\n /**\n * If `true`, the badge will be displayed.\n */\n @Prop({ mutable: true }) visible: boolean = true;\n\n @Watch(\"visible\")\n visibleHandler(): void {\n this.setAccessibleLabel();\n }\n\n componentWillLoad(): void {\n this.variant === \"custom\" && this.setBadgeColour();\n\n this.getBadgeForeground();\n\n const ariaLabel = this.el.parentElement?.ariaLabel;\n if (ariaLabel) this.parentAriaLabel = ariaLabel;\n this.setAccessibleLabel();\n }\n\n componentDidLoad(): void {\n this.type === \"text\" &&\n onComponentRequiredPropUndefined(\n [{ prop: this.textLabel, propName: \"text-label\" }],\n \"Badge\"\n );\n }\n\n /**\n * @deprecated This method should not be used anymore. Use visible prop to set badge visibility.\n */\n @Method()\n async showBadge(): Promise<void> {\n this.visible = true;\n }\n\n /**\n * @deprecated This method should not be used anymore. Use visible prop to set badge visibility.\n */\n @Method()\n async hideBadge(): Promise<void> {\n this.visible = false;\n }\n\n private setBadgeColour = () => {\n const colorRGBA = convertToRGBA(this.customColor);\n\n if (colorRGBA) {\n this.customColorRGBA = colorRGBA;\n const { r, g, b, a } = colorRGBA;\n this.el.style.backgroundColor = `rgba(${r}, ${g}, ${b}, ${a})`;\n }\n };\n\n private getBadgeRGB = () => {\n switch (this.variant) {\n case \"custom\":\n return this.customColorRGBA;\n case \"error\":\n case \"success\":\n case \"warning\":\n case \"info\": {\n return rgbaStrToObj(getCssProperty(`--ic-status-${this.variant}`));\n }\n case \"neutral\":\n case \"light\":\n return hexToRgba(\n getCssProperty(\n `--ic-architectural-${this.variant === \"neutral\" ? 500 : 40}`\n )\n );\n }\n };\n\n private getBadgeForeground = () => {\n const { r, g, b } = this.getBadgeRGB();\n this.foregroundColour = getThemeForegroundColor(\n (r * 299 + g * 587 + b * 114) / 1000\n );\n };\n\n private getTextLabel = () =>\n this.maxNumber && Number(this.textLabel) > this.maxNumber\n ? `${this.maxNumber}+`\n : this.textLabel;\n\n // Set aria-label on badge and / or parent element\n // Aria-describedby seems to not work, probably due to shadow DOM\n private setAccessibleLabel = () => {\n const parentEl = this.el.parentElement;\n const defaultAriaLabel = this.isAccessibleLabelDefined()\n ? this.accessibleLabel\n : this.textLabel || \"with badge being displayed\";\n\n if (parentEl) {\n const { tagName } = parentEl;\n if (\n tagName !== \"IC-CARD\" &&\n (tagName !== \"IC-TAB\" || (tagName === \"IC-TAB\" && this.parentAriaLabel))\n ) {\n const ariaLabelPrefix = this.parentAriaLabel\n ? `${this.parentAriaLabel} ,`\n : \"\";\n parentEl.ariaLabel = this.visible\n ? `${ariaLabelPrefix} ${defaultAriaLabel}`\n : undefined;\n } else {\n this.ariaLabel = `, ${defaultAriaLabel}`;\n }\n }\n };\n\n private isAccessibleLabelDefined = () =>\n isPropDefined(this.accessibleLabel) && this.accessibleLabel !== null;\n\n render() {\n const {\n ariaLabel,\n el,\n foregroundColour,\n getTextLabel,\n position,\n size,\n textLabel,\n type,\n variant,\n visible,\n } = this;\n\n return (\n <Host\n class={{\n [`${position}`]: true,\n [`${size}`]: true,\n [`${variant}`]: true,\n [`${type}`]: true,\n [`foreground-${foregroundColour}`]: foregroundColour !== null,\n [`${visible ? \"show\" : \"hide\"}`]: true,\n }}\n id={el.id || null}\n aria-label={ariaLabel}\n role=\"status\"\n >\n {type === \"icon\" && <slot name=\"badge-icon\"></slot>}\n {type === \"text\" && textLabel && (\n <ic-typography variant={size === \"small\" ? \"badge-small\" : \"badge\"}>\n {getTextLabel()}\n </ic-typography>\n )}\n </Host>\n );\n }\n}\n"],"mappings":"0JAAA,MAAMA,EAAa,u/F,MCwCNC,EAAK,M,yBACRC,KAAAC,UAAoB,KA4GpBD,KAAAE,eAAiB,KACvB,MAAMC,EAAYC,EAAcJ,KAAKK,aAErC,GAAIF,EAAW,CACbH,KAAKM,gBAAkBH,EACvB,MAAMI,EAAEA,EAACC,EAAEA,EAACC,EAAEA,EAACC,EAAEA,GAAMP,EACvBH,KAAKW,GAAGC,MAAMC,gBAAkB,QAAQN,MAAMC,MAAMC,MAAMC,I,GAItDV,KAAAc,YAAc,KACpB,OAAQd,KAAKe,SACX,IAAK,SACH,OAAOf,KAAKM,gBACd,IAAK,QACL,IAAK,UACL,IAAK,UACL,IAAK,OAAQ,CACX,OAAOU,EAAaC,EAAe,eAAejB,KAAKe,W,CAEzD,IAAK,UACL,IAAK,QACH,OAAOG,EACLD,EACE,sBAAsBjB,KAAKe,UAAY,UAAY,IAAM,O,EAM3Df,KAAAmB,mBAAqB,KAC3B,MAAMZ,EAAEA,EAACC,EAAEA,EAACC,EAAEA,GAAMT,KAAKc,cACzBd,KAAKoB,iBAAmBC,GACrBd,EAAI,IAAMC,EAAI,IAAMC,EAAI,KAAO,IACjC,EAGKT,KAAAsB,aAAe,IACrBtB,KAAKuB,WAAaC,OAAOxB,KAAKyB,WAAazB,KAAKuB,UAC5C,GAAGvB,KAAKuB,aACRvB,KAAKyB,UAIH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