@haiilo/catalyst 0.3.2 → 0.4.0

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 (39) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/catalyst.esm.js.map +1 -1
  3. package/dist/catalyst/p-89a97b7b.entry.js +10 -0
  4. package/dist/catalyst/p-89a97b7b.entry.js.map +1 -0
  5. package/dist/cjs/{cat-alert_8.cjs.entry.js → cat-alert_9.cjs.entry.js} +158 -51
  6. package/dist/cjs/cat-alert_9.cjs.entry.js.map +1 -0
  7. package/dist/cjs/catalyst.cjs.js +1 -1
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/collection/collection-manifest.json +2 -1
  10. package/dist/collection/components/cat-menu/cat-menu.js +3 -5
  11. package/dist/collection/components/cat-menu/cat-menu.js.map +1 -1
  12. package/dist/collection/components/cat-tooltip/cat-tooltip.css +37 -0
  13. package/dist/collection/components/cat-tooltip/cat-tooltip.js +254 -0
  14. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -0
  15. package/dist/collection/utils/first-tabbable.js +6 -0
  16. package/dist/collection/utils/first-tabbable.js.map +1 -0
  17. package/dist/collection/utils/is-touch-screen.js +3 -0
  18. package/dist/collection/utils/is-touch-screen.js.map +1 -0
  19. package/dist/components/cat-menu.js +11 -1519
  20. package/dist/components/cat-menu.js.map +1 -1
  21. package/dist/components/cat-tooltip.d.ts +11 -0
  22. package/dist/components/cat-tooltip.js +154 -0
  23. package/dist/components/cat-tooltip.js.map +1 -0
  24. package/dist/components/first-tabbable.js +1495 -0
  25. package/dist/components/first-tabbable.js.map +1 -0
  26. package/dist/esm/{cat-alert_8.entry.js → cat-alert_9.entry.js} +158 -52
  27. package/dist/esm/cat-alert_9.entry.js.map +1 -0
  28. package/dist/esm/catalyst.js +1 -1
  29. package/dist/esm/loader.js +1 -1
  30. package/dist/types/components/cat-menu/cat-menu.d.ts +0 -1
  31. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +46 -0
  32. package/dist/types/components.d.ts +61 -0
  33. package/dist/types/utils/first-tabbable.d.ts +4 -0
  34. package/dist/types/utils/is-touch-screen.d.ts +2 -0
  35. package/package.json +7 -7
  36. package/dist/catalyst/p-31b500c7.entry.js +0 -10
  37. package/dist/catalyst/p-31b500c7.entry.js.map +0 -1
  38. package/dist/cjs/cat-alert_8.cjs.entry.js.map +0 -1
  39. package/dist/esm/cat-alert_8.entry.js.map +0 -1
@@ -18,7 +18,7 @@ const patchBrowser = () => {
18
18
 
19
19
  patchBrowser().then(options => {
20
20
  appGlobals.globalScripts();
21
- return index.bootstrapLazy([["cat-alert_8.cjs",[[1,"cat-button",{"variant":[1],"color":[1],"size":[1],"name":[1],"value":[1],"disabled":[4],"loading":[4],"submit":[4],"ellipsed":[4],"round":[4],"url":[1],"urlTarget":[1,"url-target"],"icon":[1],"iconOnly":[8,"icon-only"],"iconSuffix":[4,"icon-suffix"],"buttonId":[1,"button-id"],"a11yLabel":[1,"a11y-label"],"_iconOnly":[32],"setFocus":[64]},[[0,"click","haltDisabledEvents"]]],[1,"cat-alert",{"color":[1]}],[1,"cat-badge",{"variant":[1],"color":[1],"size":[1],"round":[4],"pulse":[4]}],[1,"cat-menu",{"placement":[1]},[[0,"catClick","clickHandler"]]],[1,"cat-scrollable",{"shadowX":[4,"shadow-x"],"shadowY":[4,"shadow-y"],"overflowX":[4,"overflow-x"],"overflowY":[4,"overflow-y"],"overscroll":[4],"scrolledInit":[4,"scrolled-init"],"scrolledBuffer":[2,"scrolled-buffer"]}],[1,"cat-skeleton",{"effect":[1],"variant":[1],"size":[1],"lines":[2]}],[1,"cat-icon",{"icon":[1],"size":[1],"a11yLabel":[1,"a11y-label"]}],[1,"cat-spinner",{"size":[1],"a11yLabel":[1,"a11y-label"]}]]]], options);
21
+ return index.bootstrapLazy([["cat-alert_9.cjs",[[1,"cat-button",{"variant":[1],"color":[1],"size":[1],"name":[1],"value":[1],"disabled":[4],"loading":[4],"submit":[4],"ellipsed":[4],"round":[4],"url":[1],"urlTarget":[1,"url-target"],"icon":[1],"iconOnly":[8,"icon-only"],"iconSuffix":[4,"icon-suffix"],"buttonId":[1,"button-id"],"a11yLabel":[1,"a11y-label"],"_iconOnly":[32],"setFocus":[64]},[[0,"click","haltDisabledEvents"]]],[1,"cat-alert",{"color":[1]}],[1,"cat-badge",{"variant":[1],"color":[1],"size":[1],"round":[4],"pulse":[4]}],[1,"cat-menu",{"placement":[1]},[[0,"catClick","clickHandler"]]],[1,"cat-scrollable",{"shadowX":[4,"shadow-x"],"shadowY":[4,"shadow-y"],"overflowX":[4,"overflow-x"],"overflowY":[4,"overflow-y"],"overscroll":[4],"scrolledInit":[4,"scrolled-init"],"scrolledBuffer":[2,"scrolled-buffer"]}],[1,"cat-skeleton",{"effect":[1],"variant":[1],"size":[1],"lines":[2]}],[1,"cat-tooltip",{"content":[1],"disabled":[4],"placement":[1],"showDelay":[2,"show-delay"],"hideDelay":[2,"hide-delay"],"longTouchDuration":[2,"long-touch-duration"]},[[0,"keydown","handleKeyDown"]]],[1,"cat-icon",{"icon":[1],"size":[1],"a11yLabel":[1,"a11y-label"]}],[1,"cat-spinner",{"size":[1],"a11yLabel":[1,"a11y-label"]}]]]], options);
22
22
  });
23
23
 
24
24
  //# sourceMappingURL=catalyst.cjs.js.map
@@ -17,7 +17,7 @@ const defineCustomElements = (win, options) => {
17
17
  if (typeof window === 'undefined') return Promise.resolve();
18
18
  return patchEsm().then(() => {
19
19
  appGlobals.globalScripts();
20
- return index.bootstrapLazy([["cat-alert_8.cjs",[[1,"cat-button",{"variant":[1],"color":[1],"size":[1],"name":[1],"value":[1],"disabled":[4],"loading":[4],"submit":[4],"ellipsed":[4],"round":[4],"url":[1],"urlTarget":[1,"url-target"],"icon":[1],"iconOnly":[8,"icon-only"],"iconSuffix":[4,"icon-suffix"],"buttonId":[1,"button-id"],"a11yLabel":[1,"a11y-label"],"_iconOnly":[32],"setFocus":[64]},[[0,"click","haltDisabledEvents"]]],[1,"cat-alert",{"color":[1]}],[1,"cat-badge",{"variant":[1],"color":[1],"size":[1],"round":[4],"pulse":[4]}],[1,"cat-menu",{"placement":[1]},[[0,"catClick","clickHandler"]]],[1,"cat-scrollable",{"shadowX":[4,"shadow-x"],"shadowY":[4,"shadow-y"],"overflowX":[4,"overflow-x"],"overflowY":[4,"overflow-y"],"overscroll":[4],"scrolledInit":[4,"scrolled-init"],"scrolledBuffer":[2,"scrolled-buffer"]}],[1,"cat-skeleton",{"effect":[1],"variant":[1],"size":[1],"lines":[2]}],[1,"cat-icon",{"icon":[1],"size":[1],"a11yLabel":[1,"a11y-label"]}],[1,"cat-spinner",{"size":[1],"a11yLabel":[1,"a11y-label"]}]]]], options);
20
+ return index.bootstrapLazy([["cat-alert_9.cjs",[[1,"cat-button",{"variant":[1],"color":[1],"size":[1],"name":[1],"value":[1],"disabled":[4],"loading":[4],"submit":[4],"ellipsed":[4],"round":[4],"url":[1],"urlTarget":[1,"url-target"],"icon":[1],"iconOnly":[8,"icon-only"],"iconSuffix":[4,"icon-suffix"],"buttonId":[1,"button-id"],"a11yLabel":[1,"a11y-label"],"_iconOnly":[32],"setFocus":[64]},[[0,"click","haltDisabledEvents"]]],[1,"cat-alert",{"color":[1]}],[1,"cat-badge",{"variant":[1],"color":[1],"size":[1],"round":[4],"pulse":[4]}],[1,"cat-menu",{"placement":[1]},[[0,"catClick","clickHandler"]]],[1,"cat-scrollable",{"shadowX":[4,"shadow-x"],"shadowY":[4,"shadow-y"],"overflowX":[4,"overflow-x"],"overflowY":[4,"overflow-y"],"overscroll":[4],"scrolledInit":[4,"scrolled-init"],"scrolledBuffer":[2,"scrolled-buffer"]}],[1,"cat-skeleton",{"effect":[1],"variant":[1],"size":[1],"lines":[2]}],[1,"cat-tooltip",{"content":[1],"disabled":[4],"placement":[1],"showDelay":[2,"show-delay"],"hideDelay":[2,"hide-delay"],"longTouchDuration":[2,"long-touch-duration"]},[[0,"keydown","handleKeyDown"]]],[1,"cat-icon",{"icon":[1],"size":[1],"a11yLabel":[1,"a11y-label"]}],[1,"cat-spinner",{"size":[1],"a11yLabel":[1,"a11y-label"]}]]]], options);
21
21
  });
22
22
  };
23
23
 
@@ -7,7 +7,8 @@
7
7
  "./components/cat-menu/cat-menu.js",
8
8
  "./components/cat-scrollable/cat-scrollable.js",
9
9
  "./components/cat-skeleton/cat-skeleton.js",
10
- "./components/cat-spinner/cat-spinner.js"
10
+ "./components/cat-spinner/cat-spinner.js",
11
+ "./components/cat-tooltip/cat-tooltip.js"
11
12
  ],
12
13
  "compiler": {
13
14
  "name": "@stencil/core",
@@ -2,6 +2,7 @@ import { autoUpdate, computePosition, flip, offset } from '@floating-ui/dom';
2
2
  import { Component, Event, h, Host, Listen, Prop } from '@stencil/core';
3
3
  import * as focusTrap from 'focus-trap';
4
4
  import { tabbable } from 'tabbable';
5
+ import firstTabbable from '../../utils/first-tabbable';
5
6
  let nextUniqueId = 0;
6
7
  export class CatMenu {
7
8
  constructor() {
@@ -21,7 +22,7 @@ export class CatMenu {
21
22
  }
22
23
  componentDidLoad() {
23
24
  var _a, _b, _c, _d, _e;
24
- this.trigger = this.firstTabbable(this.triggerSlot);
25
+ this.trigger = firstTabbable(this.triggerSlot);
25
26
  (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-haspopup', 'true');
26
27
  (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-expanded', 'false');
27
28
  (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-controls', this.contentId);
@@ -33,7 +34,7 @@ export class CatMenu {
33
34
  this.keyListener = event => {
34
35
  if (this.content && ['ArrowDown', 'ArrowUp'].includes(event.key)) {
35
36
  const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });
36
- const activeElement = this.firstTabbable(document.activeElement);
37
+ const activeElement = firstTabbable(document.activeElement);
37
38
  const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
38
39
  const activeOff = event.key === 'ArrowDown' ? 1 : -1;
39
40
  const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
@@ -99,9 +100,6 @@ export class CatMenu {
99
100
  });
100
101
  }
101
102
  }
102
- firstTabbable(container) {
103
- return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
104
- }
105
103
  static get is() { return "cat-menu"; }
106
104
  static get encapsulation() { return "shadow"; }
107
105
  static get originalStyleUrls() { return {
@@ -1 +1 @@
1
- {"version":3,"file":"cat-menu.js","sourceRoot":"","sources":["../../../src/components/cat-menu/cat-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAa,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAoB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEtD,IAAI,YAAY,GAAG,CAAC,CAAC;AAOrB,MAAM,OAAO,OAAO;EALpB;IAOmB,OAAE,GAAG,YAAY,EAAE,CAAC;IAOrC;;OAEG;IACK,cAAS,GAAc,cAAc,CAAC;GAiH/C;EApGC,YAAY,CAAC,KAA8B;;IACzC,4BAA4B;IAC5B,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;MAC/D,MAAA,IAAI,CAAC,IAAI,0CAAE,UAAU,EAAE,CAAC;MACxB,IAAI,CAAC,IAAI,EAAE,CAAC;KACb;EACH,CAAC;EAED,gBAAgB;;IACd,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,MAAA,IAAI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E,GAAG,CAAC,IAAI;YACd,GAAG,EAAE,GAAG,CAAC,IAAI;WACd,CAAC,CAAC;SACJ;MACH,CAAC,CAAC,CAAC;KACJ;EACH,CAAC;EAEO,aAAa,CAAC,SAA0B;IAC9C,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;EACzG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA3HuB,cAAM,GAAG,CAAE,CAAA","sourcesContent":["import { autoUpdate, computePosition, flip, offset, Placement } from '@floating-ui/dom';\nimport { Component, Event, EventEmitter, h, Host, Listen, Prop } from '@stencil/core';\nimport * as focusTrap from 'focus-trap';\nimport { FocusableElement, tabbable } from 'tabbable';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-menu',\n styleUrl: 'cat-menu.scss',\n shadow: true\n})\nexport class CatMenu {\n private static readonly OFFSET = 4;\n private readonly id = nextUniqueId++;\n private triggerSlot?: Element;\n private trigger?: FocusableElement;\n private content?: HTMLElement;\n private trap?: focusTrap.FocusTrap;\n private keyListener?: (event: KeyboardEvent) => void;\n\n /**\n * The placement of the menu.\n */\n @Prop() placement: Placement = 'bottom-start';\n\n /**\n * Emitted when the menu is opened.\n */\n @Event() catOpen!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the menu is closed.\n */\n @Event() catClose!: EventEmitter<FocusEvent>;\n\n @Listen('catClick')\n clickHandler(event: CustomEvent<MouseEvent>) {\n // hide menu on button click\n if (this.content && event.composedPath().includes(this.content)) {\n this.trap?.deactivate();\n this.hide();\n }\n }\n\n componentDidLoad(): void {\n this.trigger = this.firstTabbable(this.triggerSlot);\n this.trigger?.setAttribute('aria-haspopup', 'true');\n this.trigger?.setAttribute('aria-expanded', 'false');\n this.trigger?.setAttribute('aria-controls', this.contentId);\n this.content?.setAttribute('id', this.contentId);\n if (this.trigger && this.content) {\n this.trigger?.addEventListener('click', () => this.show());\n autoUpdate(this.trigger, this.content, () => this.update());\n }\n\n this.keyListener = event => {\n if (this.content && ['ArrowDown', 'ArrowUp'].includes(event.key)) {\n const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });\n const activeElement = this.firstTabbable(document.activeElement);\n const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;\n const activeOff = event.key === 'ArrowDown' ? 1 : -1;\n const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;\n targetElements[targetIdx].focus();\n event.preventDefault();\n }\n };\n document.addEventListener('keydown', this.keyListener);\n }\n\n disconnectedCallback(): void {\n if (this.keyListener) {\n document.removeEventListener('keydown', this.keyListener);\n }\n }\n\n render() {\n return (\n <Host>\n <slot name=\"trigger\" ref={el => (this.triggerSlot = el)}></slot>\n <div class=\"content\" ref={el => (this.content = el)}>\n <slot name=\"content\"></slot>\n </div>\n </Host>\n );\n }\n\n private get contentId() {\n return `cat-menu-${this.id}`;\n }\n\n private show() {\n if (this.content) {\n this.content.style.display = 'block';\n this.trigger?.setAttribute('aria-expanded', 'true');\n this.catOpen.emit();\n this.trap = this.trap\n ? this.trap.updateContainerElements(this.content)\n : focusTrap.createFocusTrap(this.content, {\n tabbableOptions: {\n getShadowRoot: true\n },\n allowOutsideClick: true,\n clickOutsideDeactivates: event => !this.content || !event.composedPath().includes(this.content),\n onPostDeactivate: () => this.hide()\n });\n this.trap.activate();\n }\n }\n\n private hide() {\n if (this.content) {\n this.content.style.display = '';\n this.trigger?.setAttribute('aria-expanded', 'false');\n this.catClose.emit();\n }\n }\n\n private update() {\n if (this.trigger && this.content) {\n computePosition(this.trigger, this.content, {\n placement: this.placement,\n middleware: [offset(CatMenu.OFFSET), flip()]\n }).then(({ x, y }) => {\n if (this.content) {\n Object.assign(this.content.style, {\n left: `${x}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private firstTabbable(container?: Element | null) {\n return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();\n }\n}\n"]}
1
+ {"version":3,"file":"cat-menu.js","sourceRoot":"","sources":["../../../src/components/cat-menu/cat-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAa,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AACxC,OAAO,EAAoB,QAAQ,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAEvD,IAAI,YAAY,GAAG,CAAC,CAAC;AAOrB,MAAM,OAAO,OAAO;EALpB;IAOmB,OAAE,GAAG,YAAY,EAAE,CAAC;IAOrC;;OAEG;IACK,cAAS,GAAc,cAAc,CAAC;GA6G/C;EAhGC,YAAY,CAAC,KAA8B;;IACzC,4BAA4B;IAC5B,IAAI,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;MAC/D,MAAA,IAAI,CAAC,IAAI,0CAAE,UAAU,EAAE,CAAC;MACxB,IAAI,CAAC,IAAI,EAAE,CAAC;KACb;EACH,CAAC;EAED,gBAAgB;;IACd,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAA,IAAI,CAAC,OAAO,0CAAE,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IACpD,MAAA,IAAI,CAAC,OAAO,0CAAE,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;I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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAvHuB,cAAM,GAAG,CAAE,CAAA","sourcesContent":["import { autoUpdate, computePosition, flip, offset, Placement } from '@floating-ui/dom';\nimport { Component, Event, EventEmitter, h, Host, Listen, Prop } from '@stencil/core';\nimport * as focusTrap from 'focus-trap';\nimport { FocusableElement, tabbable } from 'tabbable';\nimport firstTabbable from '../../utils/first-tabbable';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-menu',\n styleUrl: 'cat-menu.scss',\n shadow: true\n})\nexport class CatMenu {\n private static readonly OFFSET = 4;\n private readonly id = nextUniqueId++;\n private triggerSlot?: Element;\n private trigger?: FocusableElement;\n private content?: HTMLElement;\n private trap?: focusTrap.FocusTrap;\n private keyListener?: (event: KeyboardEvent) => void;\n\n /**\n * The placement of the menu.\n */\n @Prop() placement: Placement = 'bottom-start';\n\n /**\n * Emitted when the menu is opened.\n */\n @Event() catOpen!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the menu is closed.\n */\n @Event() catClose!: EventEmitter<FocusEvent>;\n\n @Listen('catClick')\n clickHandler(event: CustomEvent<MouseEvent>) {\n // hide menu on button click\n if (this.content && event.composedPath().includes(this.content)) {\n this.trap?.deactivate();\n this.hide();\n }\n }\n\n componentDidLoad(): void {\n this.trigger = firstTabbable(this.triggerSlot);\n this.trigger?.setAttribute('aria-haspopup', 'true');\n this.trigger?.setAttribute('aria-expanded', 'false');\n this.trigger?.setAttribute('aria-controls', this.contentId);\n this.content?.setAttribute('id', this.contentId);\n if (this.trigger && this.content) {\n this.trigger?.addEventListener('click', () => this.show());\n autoUpdate(this.trigger, this.content, () => this.update());\n }\n\n this.keyListener = event => {\n if (this.content && ['ArrowDown', 'ArrowUp'].includes(event.key)) {\n const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });\n const activeElement = firstTabbable(document.activeElement);\n const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;\n const activeOff = event.key === 'ArrowDown' ? 1 : -1;\n const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;\n targetElements[targetIdx].focus();\n event.preventDefault();\n }\n };\n document.addEventListener('keydown', this.keyListener);\n }\n\n disconnectedCallback(): void {\n if (this.keyListener) {\n document.removeEventListener('keydown', this.keyListener);\n }\n }\n\n render() {\n return (\n <Host>\n <slot name=\"trigger\" ref={el => (this.triggerSlot = el)}></slot>\n <div class=\"content\" ref={el => (this.content = el)}>\n <slot name=\"content\"></slot>\n </div>\n </Host>\n );\n }\n\n private get contentId() {\n return `cat-menu-${this.id}`;\n }\n\n private show() {\n if (this.content) {\n this.content.style.display = 'block';\n this.trigger?.setAttribute('aria-expanded', 'true');\n this.catOpen.emit();\n this.trap = this.trap\n ? this.trap.updateContainerElements(this.content)\n : focusTrap.createFocusTrap(this.content, {\n tabbableOptions: {\n getShadowRoot: true\n },\n allowOutsideClick: true,\n clickOutsideDeactivates: event => !this.content || !event.composedPath().includes(this.content),\n onPostDeactivate: () => this.hide()\n });\n this.trap.activate();\n }\n }\n\n private hide() {\n if (this.content) {\n this.content.style.display = '';\n this.trigger?.setAttribute('aria-expanded', 'false');\n this.catClose.emit();\n }\n }\n\n private update() {\n if (this.trigger && this.content) {\n computePosition(this.trigger, this.content, {\n placement: this.placement,\n middleware: [offset(CatMenu.OFFSET), flip()]\n }).then(({ x, y }) => {\n if (this.content) {\n Object.assign(this.content.style, {\n left: `${x}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n}\n"]}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Auto-generated file. Do not edit directly.
3
+ */
4
+ /* stylelint-disable value-keyword-case */
5
+ /* stylelint-enable value-keyword-case */
6
+ :host {
7
+ display: contents;
8
+ }
9
+
10
+ :host([hidden]) {
11
+ display: none;
12
+ }
13
+
14
+ .tooltip {
15
+ position: absolute;
16
+ font-size: 0.875rem;
17
+ line-height: 1rem;
18
+ padding: 0.25rem;
19
+ background-color: rgba(0, 0, 0, 0.7);
20
+ border-radius: 0.125rem;
21
+ color: white;
22
+ white-space: nowrap;
23
+ transition: 0.13s linear;
24
+ visibility: hidden;
25
+ opacity: 0;
26
+ }
27
+ .tooltip-show {
28
+ opacity: 1;
29
+ visibility: visible;
30
+ }
31
+
32
+ .tooltip-trigger {
33
+ display: inline-block;
34
+ }
35
+ .tooltip-trigger:focus {
36
+ outline: none;
37
+ }
@@ -0,0 +1,254 @@
1
+ import { Component, h, Host, Listen, Prop } from '@stencil/core';
2
+ import { autoUpdate, computePosition, flip, offset } from '@floating-ui/dom';
3
+ import isTouchScreen from '../../utils/is-touch-screen';
4
+ import firstTabbable from '../../utils/first-tabbable';
5
+ let nextUniqueId = 0;
6
+ export class CatTooltip {
7
+ constructor() {
8
+ this.id = `cat-tooltip-${nextUniqueId++}`;
9
+ /**
10
+ * The content of the tooltip.
11
+ */
12
+ this.content = '';
13
+ /**
14
+ * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,
15
+ * and invisible. Corresponds with the native HTML disabled attribute.
16
+ */
17
+ this.disabled = false;
18
+ /**
19
+ * The placement of the tooltip.
20
+ */
21
+ this.placement = 'top';
22
+ /**
23
+ * The delay time for showing tooltip in ms.
24
+ */
25
+ this.showDelay = 1000;
26
+ /**
27
+ * The delay time for hiding tooltip in ms.
28
+ */
29
+ this.hideDelay = 0;
30
+ /**
31
+ * The duration of tap to show the tooltip.
32
+ */
33
+ this.longTouchDuration = 1000;
34
+ }
35
+ handleKeyDown({ key }) {
36
+ key === 'Escape' && this.hideListener();
37
+ }
38
+ componentDidLoad() {
39
+ var _a, _b, _c, _d, _e, _f, _g;
40
+ this.trigger = firstTabbable(this.triggerElement) || this.triggerElement;
41
+ if (!this.isTabbable) {
42
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
43
+ }
44
+ if (this.trigger && this.tooltip) {
45
+ autoUpdate(this.trigger, this.tooltip, () => this.update());
46
+ }
47
+ if (isTouchScreen) {
48
+ (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.addEventListener('touchstart', this.touchStartListener.bind(this));
49
+ (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.addEventListener('touchend', this.touchEndListener.bind(this));
50
+ }
51
+ else {
52
+ (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.addEventListener('focusin', this.showListener.bind(this));
53
+ (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('focusout', this.hideListener.bind(this));
54
+ (_f = this.trigger) === null || _f === void 0 ? void 0 : _f.addEventListener('mouseenter', this.showListener.bind(this));
55
+ (_g = this.trigger) === null || _g === void 0 ? void 0 : _g.addEventListener('mouseleave', this.hideListener.bind(this));
56
+ }
57
+ }
58
+ disconnectedCallback() {
59
+ var _a, _b, _c, _d, _e, _f;
60
+ if (isTouchScreen) {
61
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.removeEventListener('touchstart', this.touchStartListener.bind(this));
62
+ (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.removeEventListener('touchend', this.touchEndListener.bind(this));
63
+ }
64
+ else {
65
+ (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.removeEventListener('mouseenter', this.showListener.bind(this));
66
+ (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseleave', this.hideListener.bind(this));
67
+ (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.removeEventListener('focusin', this.showListener.bind(this));
68
+ (_f = this.trigger) === null || _f === void 0 ? void 0 : _f.removeEventListener('focusout', this.hideListener.bind(this));
69
+ }
70
+ }
71
+ render() {
72
+ return (h(Host, null,
73
+ h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" },
74
+ h("slot", null)),
75
+ this.content && !this.disabled && (h("div", { ref: el => (this.tooltip = el), id: this.id, class: "tooltip" }, this.content))));
76
+ }
77
+ get isTabbable() {
78
+ return firstTabbable(this.trigger);
79
+ }
80
+ update() {
81
+ if (this.trigger && this.tooltip) {
82
+ computePosition(this.trigger, this.tooltip, {
83
+ placement: this.placement,
84
+ middleware: [offset(CatTooltip.OFFSET), flip()]
85
+ }).then(({ x, y }) => {
86
+ if (this.tooltip) {
87
+ Object.assign(this.tooltip.style, {
88
+ left: `${Math.max(0, x)}px`,
89
+ top: `${y}px`
90
+ });
91
+ }
92
+ });
93
+ }
94
+ }
95
+ showListener() {
96
+ window.clearTimeout(this.hideTimeout);
97
+ this.showTimeout = window.setTimeout(() => {
98
+ var _a, _b;
99
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.focus();
100
+ (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.classList.add('tooltip-show');
101
+ }, this.showDelay);
102
+ }
103
+ hideListener() {
104
+ window.clearTimeout(this.showTimeout);
105
+ this.hideTimeout = window.setTimeout(() => {
106
+ var _a, _b;
107
+ (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.blur();
108
+ (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.classList.remove('tooltip-show');
109
+ }, this.hideDelay);
110
+ }
111
+ touchStartListener() {
112
+ this.touchTimeout = window.setTimeout(() => {
113
+ var _a;
114
+ (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show');
115
+ }, this.longTouchDuration);
116
+ }
117
+ touchEndListener() {
118
+ var _a;
119
+ window.clearTimeout(this.touchTimeout);
120
+ (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.remove('tooltip-show');
121
+ }
122
+ static get is() { return "cat-tooltip"; }
123
+ static get encapsulation() { return "shadow"; }
124
+ static get originalStyleUrls() { return {
125
+ "$": ["cat-tooltip.scss"]
126
+ }; }
127
+ static get styleUrls() { return {
128
+ "$": ["cat-tooltip.css"]
129
+ }; }
130
+ static get properties() { return {
131
+ "content": {
132
+ "type": "string",
133
+ "mutable": false,
134
+ "complexType": {
135
+ "original": "string",
136
+ "resolved": "string",
137
+ "references": {}
138
+ },
139
+ "required": false,
140
+ "optional": false,
141
+ "docs": {
142
+ "tags": [],
143
+ "text": "The content of the tooltip."
144
+ },
145
+ "attribute": "content",
146
+ "reflect": false,
147
+ "defaultValue": "''"
148
+ },
149
+ "disabled": {
150
+ "type": "boolean",
151
+ "mutable": false,
152
+ "complexType": {
153
+ "original": "boolean",
154
+ "resolved": "boolean",
155
+ "references": {}
156
+ },
157
+ "required": false,
158
+ "optional": false,
159
+ "docs": {
160
+ "tags": [],
161
+ "text": "Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\nand invisible. Corresponds with the native HTML disabled attribute."
162
+ },
163
+ "attribute": "disabled",
164
+ "reflect": false,
165
+ "defaultValue": "false"
166
+ },
167
+ "placement": {
168
+ "type": "string",
169
+ "mutable": false,
170
+ "complexType": {
171
+ "original": "Placement",
172
+ "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
173
+ "references": {
174
+ "Placement": {
175
+ "location": "import",
176
+ "path": "@floating-ui/dom"
177
+ }
178
+ }
179
+ },
180
+ "required": false,
181
+ "optional": false,
182
+ "docs": {
183
+ "tags": [],
184
+ "text": "The placement of the tooltip."
185
+ },
186
+ "attribute": "placement",
187
+ "reflect": false,
188
+ "defaultValue": "'top'"
189
+ },
190
+ "showDelay": {
191
+ "type": "number",
192
+ "mutable": false,
193
+ "complexType": {
194
+ "original": "number",
195
+ "resolved": "number",
196
+ "references": {}
197
+ },
198
+ "required": false,
199
+ "optional": false,
200
+ "docs": {
201
+ "tags": [],
202
+ "text": "The delay time for showing tooltip in ms."
203
+ },
204
+ "attribute": "show-delay",
205
+ "reflect": false,
206
+ "defaultValue": "1000"
207
+ },
208
+ "hideDelay": {
209
+ "type": "number",
210
+ "mutable": false,
211
+ "complexType": {
212
+ "original": "number",
213
+ "resolved": "number",
214
+ "references": {}
215
+ },
216
+ "required": false,
217
+ "optional": false,
218
+ "docs": {
219
+ "tags": [],
220
+ "text": "The delay time for hiding tooltip in ms."
221
+ },
222
+ "attribute": "hide-delay",
223
+ "reflect": false,
224
+ "defaultValue": "0"
225
+ },
226
+ "longTouchDuration": {
227
+ "type": "number",
228
+ "mutable": false,
229
+ "complexType": {
230
+ "original": "number",
231
+ "resolved": "number",
232
+ "references": {}
233
+ },
234
+ "required": false,
235
+ "optional": false,
236
+ "docs": {
237
+ "tags": [],
238
+ "text": "The duration of tap to show the tooltip."
239
+ },
240
+ "attribute": "long-touch-duration",
241
+ "reflect": false,
242
+ "defaultValue": "1000"
243
+ }
244
+ }; }
245
+ static get listeners() { return [{
246
+ "name": "keydown",
247
+ "method": "handleKeyDown",
248
+ "target": undefined,
249
+ "capture": false,
250
+ "passive": false
251
+ }]; }
252
+ }
253
+ CatTooltip.OFFSET = 4;
254
+ //# sourceMappingURL=cat-tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat-tooltip.js","sourceRoot":"","sources":["../../../src/components/cat-tooltip/cat-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAa,MAAM,kBAAkB,CAAC;AACxF,OAAO,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAGvD,IAAI,YAAY,GAAG,CAAC,CAAC;AAOrB,MAAM,OAAO,UAAU;EALvB;IAOmB,OAAE,GAAG,eAAe,YAAY,EAAE,EAAE,CAAC;IAQtD;;OAEG;IACK,YAAO,GAAG,EAAE,CAAC;IAErB;;;OAGG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,cAAS,GAAc,KAAK,CAAC;IAErC;;OAEG;IACK,cAAS,GAAG,IAAI,CAAC;IAEzB;;OAEG;IACK,cAAS,GAAG,CAAC,CAAC;I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AAS,CAAC,CAAC;EACrB,CAAC;EAEO,YAAY;IAClB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;;MACxC,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,EAAE,CAAC;MACrB,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACjD,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;EACrB,CAAC;EAEO,kBAAkB;IACxB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;;MACzC,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC9C,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;EAC7B,CAAC;EAEO,gBAAgB;;IACtB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACvC,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;EACjD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAzIuB,iBAAM,GAAG,CAAE,CAAA","sourcesContent":["import { Component, h, Host, Listen, Prop } from '@stencil/core';\nimport { autoUpdate, computePosition, flip, offset, Placement } from '@floating-ui/dom';\nimport isTouchScreen from '../../utils/is-touch-screen';\nimport firstTabbable from '../../utils/first-tabbable';\nimport { FocusableElement } from 'tabbable';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tooltip',\n styleUrl: 'cat-tooltip.scss',\n shadow: true\n})\nexport class CatTooltip {\n private static readonly OFFSET = 4;\n private readonly id = `cat-tooltip-${nextUniqueId++}`;\n private tooltip?: HTMLElement;\n private triggerElement?: HTMLElement;\n private trigger?: FocusableElement;\n private showTimeout?: number;\n private hideTimeout?: number;\n private touchTimeout?: number;\n\n /**\n * The content of the tooltip.\n */\n @Prop() content = '';\n\n /**\n * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\n * and invisible. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * The placement of the tooltip.\n */\n @Prop() placement: Placement = 'top';\n\n /**\n * The delay time for showing tooltip in ms.\n */\n @Prop() showDelay = 1000;\n\n /**\n * The delay time for hiding tooltip in ms.\n */\n @Prop() hideDelay = 0;\n\n /**\n * The duration of tap to show the tooltip.\n */\n @Prop() longTouchDuration = 1000;\n\n @Listen('keydown')\n handleKeyDown({ key }: KeyboardEvent) {\n key === 'Escape' && this.hideListener();\n }\n\n componentDidLoad(): void {\n this.trigger = firstTabbable(this.triggerElement) || this.triggerElement;\n if (!this.isTabbable) {\n this.trigger?.setAttribute('tabindex', '0');\n }\n if (this.trigger && this.tooltip) {\n autoUpdate(this.trigger, this.tooltip, () => this.update());\n }\n\n if (isTouchScreen) {\n this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.addEventListener('focusin', this.showListener.bind(this));\n this.trigger?.addEventListener('focusout', this.hideListener.bind(this));\n this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));\n }\n }\n\n disconnectedCallback(): void {\n if (isTouchScreen) {\n this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));\n this.trigger?.removeEventListener('focusin', this.showListener.bind(this));\n this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));\n }\n }\n\n render() {\n return (\n <Host>\n <div ref={el => (this.triggerElement = el)} aria-describedby={this.id} class=\"tooltip-trigger\">\n <slot />\n </div>\n {this.content && !this.disabled && (\n <div ref={el => (this.tooltip = el)} id={this.id} class=\"tooltip\">\n {this.content}\n </div>\n )}\n </Host>\n );\n }\n\n private get isTabbable() {\n return firstTabbable(this.trigger);\n }\n\n private update() {\n if (this.trigger && this.tooltip) {\n computePosition(this.trigger, this.tooltip, {\n placement: this.placement,\n middleware: [offset(CatTooltip.OFFSET), flip()]\n }).then(({ x, y }) => {\n if (this.tooltip) {\n Object.assign(this.tooltip.style, {\n left: `${Math.max(0, x)}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private showListener() {\n window.clearTimeout(this.hideTimeout);\n this.showTimeout = window.setTimeout(() => {\n this.trigger?.focus();\n this.tooltip?.classList.add('tooltip-show');\n }, this.showDelay);\n }\n\n private hideListener() {\n window.clearTimeout(this.showTimeout);\n this.hideTimeout = window.setTimeout(() => {\n this.trigger?.blur();\n this.tooltip?.classList.remove('tooltip-show');\n }, this.hideDelay);\n }\n\n private touchStartListener() {\n this.touchTimeout = window.setTimeout(() => {\n this.tooltip?.classList.add('tooltip-show');\n }, this.longTouchDuration);\n }\n\n private touchEndListener() {\n window.clearTimeout(this.touchTimeout);\n this.tooltip?.classList.remove('tooltip-show');\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { tabbable } from 'tabbable';
2
+ const firstTabbable = (container) => {
3
+ return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
4
+ };
5
+ export default firstTabbable;
6
+ //# sourceMappingURL=first-tabbable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-tabbable.js","sourceRoot":"","sources":["../../src/utils/first-tabbable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,QAAQ,EAAE,MAAM,UAAU,CAAC;AAItD,MAAM,aAAa,GAAG,CAAC,SAAqB,EAAgC,EAAE;EAC5E,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;AACzG,CAAC,CAAC;AAEF,eAAe,aAAa,CAAC","sourcesContent":["import { FocusableElement, tabbable } from 'tabbable';\n\ntype Container = Element | FocusableElement | null;\n\nconst firstTabbable = (container?: Container): FocusableElement | undefined => {\n return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();\n};\n\nexport default firstTabbable;\n"]}
@@ -0,0 +1,3 @@
1
+ const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
2
+ export default isTouchDevice;
3
+ //# sourceMappingURL=is-touch-screen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-touch-screen.js","sourceRoot":"","sources":["../../src/utils/is-touch-screen.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,cAAc,IAAI,MAAM,IAAI,SAAS,CAAC,cAAc,GAAG,CAAC,CAAC;AAE/E,eAAe,aAAa,CAAC","sourcesContent":["const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;\n\nexport default isTouchDevice;\n"]}