@devschile/chucao 2.4.0 → 2.5.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 (241) hide show
  1. package/README.md +17 -16
  2. package/dist/chucao/chucao.css +1 -1
  3. package/dist/chucao/chucao.esm.js +1 -1
  4. package/dist/chucao/index.esm.js +1 -1
  5. package/dist/chucao/index.esm.js.map +1 -1
  6. package/dist/chucao/{p-1ebd9dc4.entry.js → p-0bc141a2.entry.js} +2 -2
  7. package/dist/chucao/{p-449e1ba0.entry.js → p-0e044eff.entry.js} +2 -2
  8. package/dist/chucao/{p-a07e0e97.entry.js → p-1108062e.entry.js} +2 -2
  9. package/dist/chucao/{p-85db779c.entry.js → p-26e144ff.entry.js} +2 -2
  10. package/dist/chucao/p-2c681cc0.entry.js +2 -0
  11. package/dist/chucao/p-2c681cc0.entry.js.map +1 -0
  12. package/dist/chucao/p-2e785177.entry.js +2 -0
  13. package/dist/chucao/{p-0e3c83a6.entry.js.map → p-2e785177.entry.js.map} +1 -1
  14. package/dist/chucao/{p-6e95f31f.entry.js → p-337d7f68.entry.js} +2 -2
  15. package/dist/chucao/{p-7c85f5fe.entry.js → p-350f974d.entry.js} +2 -2
  16. package/dist/chucao/p-4846cac4.entry.js +2 -0
  17. package/dist/chucao/{p-d0533af6.entry.js → p-6345c9e1.entry.js} +2 -2
  18. package/dist/chucao/p-957acf39.entry.js +2 -0
  19. package/dist/chucao/p-957acf39.entry.js.map +1 -0
  20. package/dist/chucao/{p-34a9d1f4.entry.js → p-97655c41.entry.js} +2 -2
  21. package/dist/chucao/{p-b5552b50.entry.js → p-9f73855e.entry.js} +2 -2
  22. package/dist/chucao/p-CIV5Gg1o.js +3 -0
  23. package/dist/chucao/p-CIV5Gg1o.js.map +1 -0
  24. package/dist/chucao/p-CnivhwvG.js +2 -0
  25. package/dist/chucao/p-CnivhwvG.js.map +1 -0
  26. package/dist/chucao/{p-17451d92.entry.js → p-b53d954e.entry.js} +2 -2
  27. package/dist/chucao/{p-d776b092.entry.js → p-b6cc08f0.entry.js} +2 -2
  28. package/dist/chucao/p-be7b5c21.entry.js +2 -0
  29. package/dist/chucao/p-be7b5c21.entry.js.map +1 -0
  30. package/dist/chucao/p-c165f839.entry.js +2 -0
  31. package/dist/chucao/p-c165f839.entry.js.map +1 -0
  32. package/dist/chucao/{p-56d64d84.entry.js → p-c251b0d1.entry.js} +2 -2
  33. package/dist/chucao/p-f5b74bca.entry.js +2 -0
  34. package/dist/chucao/p-f5b74bca.entry.js.map +1 -0
  35. package/dist/chucao/{p-84d875e9.entry.js → p-f9fe752c.entry.js} +2 -2
  36. package/dist/chucao/{p-1778a313.entry.js → p-fdf065e6.entry.js} +2 -2
  37. package/dist/cjs/ch-accordion.cjs.entry.js +1 -1
  38. package/dist/cjs/ch-alert_8.cjs.entry.js +34 -10
  39. package/dist/cjs/ch-alert_8.cjs.entry.js.map +1 -1
  40. package/dist/cjs/ch-checkbox.cjs.entry.js +2 -2
  41. package/dist/cjs/ch-cluster.cjs.entry.js +3 -3
  42. package/dist/cjs/ch-divider.cjs.entry.js +2 -2
  43. package/dist/cjs/ch-drawer.cjs.entry.js +2 -2
  44. package/dist/cjs/ch-emoji.cjs.entry.js +2 -2
  45. package/dist/cjs/ch-empty-state.cjs.entry.js +2 -2
  46. package/dist/cjs/ch-grid.cjs.entry.js +2 -2
  47. package/dist/cjs/ch-icon-button.cjs.entry.js +51 -0
  48. package/dist/cjs/ch-icon-button.cjs.entry.js.map +1 -0
  49. package/dist/cjs/ch-icon.cjs.entry.js +38 -0
  50. package/dist/cjs/ch-icon.cjs.entry.js.map +1 -0
  51. package/dist/cjs/ch-link.cjs.entry.js +1 -1
  52. package/dist/cjs/ch-modal.cjs.entry.js +2 -2
  53. package/dist/cjs/ch-page-header.cjs.entry.js +45 -0
  54. package/dist/cjs/ch-page-header.cjs.entry.js.map +1 -0
  55. package/dist/cjs/ch-radio.cjs.entry.js +2 -2
  56. package/dist/cjs/ch-segmented-control.cjs.entry.js +2 -2
  57. package/dist/cjs/ch-skeleton.cjs.entry.js +2 -2
  58. package/dist/cjs/ch-stack.cjs.entry.js +2 -2
  59. package/dist/cjs/ch-tabs.cjs.entry.js +2 -2
  60. package/dist/cjs/ch-textarea.cjs.entry.js +2 -2
  61. package/dist/cjs/ch-tooltip.cjs.entry.js +204 -5
  62. package/dist/cjs/ch-tooltip.cjs.entry.js.map +1 -1
  63. package/dist/cjs/chucao.cjs.js +2 -2
  64. package/dist/cjs/icons-CNyDgV-q.js +88 -0
  65. package/dist/cjs/icons-CNyDgV-q.js.map +1 -0
  66. package/dist/cjs/{index-ysucLiAq.js → index-ByZY6aTj.js} +81 -5
  67. package/dist/cjs/index-ByZY6aTj.js.map +1 -0
  68. package/dist/cjs/index.cjs.js +16 -0
  69. package/dist/cjs/index.cjs.js.map +1 -1
  70. package/dist/cjs/loader.cjs.js +2 -2
  71. package/dist/collection/collection-manifest.json +3 -0
  72. package/dist/collection/components/ch-alert/ch-alert.css +13 -0
  73. package/dist/collection/components/ch-alert/ch-alert.js +44 -1
  74. package/dist/collection/components/ch-alert/ch-alert.js.map +1 -1
  75. package/dist/collection/components/ch-badge/ch-badge.css +30 -1
  76. package/dist/collection/components/ch-badge/ch-badge.js +35 -1
  77. package/dist/collection/components/ch-badge/ch-badge.js.map +1 -1
  78. package/dist/collection/components/ch-card/ch-card.js +1 -1
  79. package/dist/collection/components/ch-checkbox/ch-checkbox.js +1 -1
  80. package/dist/collection/components/ch-cluster/ch-cluster.js +2 -2
  81. package/dist/collection/components/ch-divider/ch-divider.js +1 -1
  82. package/dist/collection/components/ch-drawer/ch-drawer.js +1 -1
  83. package/dist/collection/components/ch-emoji/ch-emoji.js +1 -1
  84. package/dist/collection/components/ch-empty-state/ch-empty-state.js +1 -1
  85. package/dist/collection/components/ch-grid/ch-grid.js +1 -1
  86. package/dist/collection/components/ch-icon/ch-icon.css +25 -0
  87. package/dist/collection/components/ch-icon/ch-icon.js +121 -0
  88. package/dist/collection/components/ch-icon/ch-icon.js.map +1 -0
  89. package/dist/collection/components/ch-icon-button/ch-icon-button.css +99 -0
  90. package/dist/collection/components/ch-icon-button/ch-icon-button.js +216 -0
  91. package/dist/collection/components/ch-icon-button/ch-icon-button.js.map +1 -0
  92. package/dist/collection/components/ch-input/ch-input.js +1 -1
  93. package/dist/collection/components/ch-modal/ch-modal.js +1 -1
  94. package/dist/collection/components/ch-page-header/ch-page-header.css +84 -0
  95. package/dist/collection/components/ch-page-header/ch-page-header.js +162 -0
  96. package/dist/collection/components/ch-page-header/ch-page-header.js.map +1 -0
  97. package/dist/collection/components/ch-radio/ch-radio.js +1 -1
  98. package/dist/collection/components/ch-segmented-control/ch-segmented-control.js +1 -1
  99. package/dist/collection/components/ch-select/ch-select.js +1 -1
  100. package/dist/collection/components/ch-skeleton/ch-skeleton.js +1 -1
  101. package/dist/collection/components/ch-spinner/ch-spinner.js +1 -1
  102. package/dist/collection/components/ch-stack/ch-stack.js +1 -1
  103. package/dist/collection/components/ch-switch/ch-switch.js +1 -1
  104. package/dist/collection/components/ch-tabs/ch-tabs.js +1 -1
  105. package/dist/collection/components/ch-textarea/ch-textarea.js +1 -1
  106. package/dist/collection/components/ch-tooltip/ch-tooltip.css +29 -1
  107. package/dist/collection/components/ch-tooltip/ch-tooltip.js +125 -6
  108. package/dist/collection/components/ch-tooltip/ch-tooltip.js.map +1 -1
  109. package/dist/collection/tokens/tokens.js +12 -0
  110. package/dist/collection/tokens/tokens.js.map +1 -1
  111. package/dist/collection/tokens/types.js.map +1 -1
  112. package/dist/collection/utils/icons.js +82 -0
  113. package/dist/collection/utils/icons.js.map +1 -0
  114. package/dist/collection/utils/overlay.js +101 -0
  115. package/dist/collection/utils/overlay.js.map +1 -0
  116. package/dist/components/ch-accordion.js +1 -1
  117. package/dist/components/ch-alert.js +1 -1
  118. package/dist/components/ch-alert.js.map +1 -1
  119. package/dist/components/ch-badge.js +1 -1
  120. package/dist/components/ch-badge.js.map +1 -1
  121. package/dist/components/ch-button.js +1 -1
  122. package/dist/components/ch-card.js +1 -1
  123. package/dist/components/ch-checkbox.js +1 -1
  124. package/dist/components/ch-cluster.js +1 -1
  125. package/dist/components/ch-divider.js +1 -1
  126. package/dist/components/ch-drawer.js +1 -1
  127. package/dist/components/ch-emoji.js +1 -1
  128. package/dist/components/ch-empty-state.js +1 -1
  129. package/dist/components/ch-grid.js +1 -1
  130. package/dist/components/ch-icon-button.d.ts +11 -0
  131. package/dist/components/ch-icon-button.js +2 -0
  132. package/dist/components/ch-icon-button.js.map +1 -0
  133. package/dist/components/ch-icon.d.ts +11 -0
  134. package/dist/components/ch-icon.js +2 -0
  135. package/dist/components/ch-icon.js.map +1 -0
  136. package/dist/components/ch-input.js +1 -1
  137. package/dist/components/ch-link.js +1 -1
  138. package/dist/components/ch-modal.js +1 -1
  139. package/dist/components/ch-page-header.d.ts +11 -0
  140. package/dist/components/ch-page-header.js +2 -0
  141. package/dist/components/ch-page-header.js.map +1 -0
  142. package/dist/components/ch-radio.js +1 -1
  143. package/dist/components/ch-segmented-control.js +1 -1
  144. package/dist/components/ch-select.js +1 -1
  145. package/dist/components/ch-skeleton.js +1 -1
  146. package/dist/components/ch-spinner.js +1 -1
  147. package/dist/components/ch-stack.js +1 -1
  148. package/dist/components/ch-switch.js +1 -1
  149. package/dist/components/ch-tabs.js +1 -1
  150. package/dist/components/ch-textarea.js +1 -1
  151. package/dist/components/ch-tooltip.js +1 -1
  152. package/dist/components/ch-tooltip.js.map +1 -1
  153. package/dist/components/index.js +1 -1
  154. package/dist/components/index.js.map +1 -1
  155. package/dist/components/{p-no2_9Jk-.js → p-CV0rD-fF.js} +2 -2
  156. package/dist/components/p-CnivhwvG.js +2 -0
  157. package/dist/components/p-CnivhwvG.js.map +1 -0
  158. package/dist/components/p-qP_9qshx.js +2 -0
  159. package/dist/components/p-qP_9qshx.js.map +1 -0
  160. package/dist/esm/ch-accordion.entry.js +1 -1
  161. package/dist/esm/ch-alert_8.entry.js +34 -10
  162. package/dist/esm/ch-alert_8.entry.js.map +1 -1
  163. package/dist/esm/ch-checkbox.entry.js +2 -2
  164. package/dist/esm/ch-cluster.entry.js +3 -3
  165. package/dist/esm/ch-divider.entry.js +2 -2
  166. package/dist/esm/ch-drawer.entry.js +2 -2
  167. package/dist/esm/ch-emoji.entry.js +2 -2
  168. package/dist/esm/ch-empty-state.entry.js +2 -2
  169. package/dist/esm/ch-grid.entry.js +2 -2
  170. package/dist/esm/ch-icon-button.entry.js +49 -0
  171. package/dist/esm/ch-icon-button.entry.js.map +1 -0
  172. package/dist/esm/ch-icon.entry.js +36 -0
  173. package/dist/esm/ch-icon.entry.js.map +1 -0
  174. package/dist/esm/ch-link.entry.js +1 -1
  175. package/dist/esm/ch-modal.entry.js +2 -2
  176. package/dist/esm/ch-page-header.entry.js +43 -0
  177. package/dist/esm/ch-page-header.entry.js.map +1 -0
  178. package/dist/esm/ch-radio.entry.js +2 -2
  179. package/dist/esm/ch-segmented-control.entry.js +2 -2
  180. package/dist/esm/ch-skeleton.entry.js +2 -2
  181. package/dist/esm/ch-stack.entry.js +2 -2
  182. package/dist/esm/ch-tabs.entry.js +2 -2
  183. package/dist/esm/ch-textarea.entry.js +2 -2
  184. package/dist/esm/ch-tooltip.entry.js +204 -5
  185. package/dist/esm/ch-tooltip.entry.js.map +1 -1
  186. package/dist/esm/chucao.js +3 -3
  187. package/dist/esm/icons-CnivhwvG.js +86 -0
  188. package/dist/esm/icons-CnivhwvG.js.map +1 -0
  189. package/dist/esm/{index-DVKZbUp9.js → index-CIV5Gg1o.js} +81 -6
  190. package/dist/esm/index-CIV5Gg1o.js.map +1 -0
  191. package/dist/esm/index.js +13 -1
  192. package/dist/esm/index.js.map +1 -1
  193. package/dist/esm/loader.js +3 -3
  194. package/dist/types/components/ch-alert/ch-alert.d.ts +11 -0
  195. package/dist/types/components/ch-badge/ch-badge.d.ts +14 -0
  196. package/dist/types/components/ch-icon/ch-icon.d.ts +29 -0
  197. package/dist/types/components/ch-icon-button/ch-icon-button.d.ts +36 -0
  198. package/dist/types/components/ch-page-header/ch-page-header.d.ts +39 -0
  199. package/dist/types/components/ch-tooltip/ch-tooltip.d.ts +32 -2
  200. package/dist/types/components.d.ts +406 -2
  201. package/dist/types/tokens/tokens.d.ts +12 -0
  202. package/dist/types/tokens/types.d.ts +2 -1
  203. package/dist/types/utils/icons.d.ts +15 -0
  204. package/dist/types/utils/overlay.d.ts +49 -0
  205. package/dist-react/components.d.ts +12 -1
  206. package/dist-react/components.js +27 -0
  207. package/dist-react/components.ts +37 -1
  208. package/dist-vue/index.d.ts +3 -0
  209. package/dist-vue/index.js +29 -1
  210. package/dist-vue/index.ts +35 -1
  211. package/hydrate/index.js +601 -34
  212. package/hydrate/index.mjs +601 -34
  213. package/package.json +91 -4
  214. package/dist/chucao/p-0e3c83a6.entry.js +0 -2
  215. package/dist/chucao/p-82216381.entry.js +0 -2
  216. package/dist/chucao/p-82216381.entry.js.map +0 -1
  217. package/dist/chucao/p-907195ff.entry.js +0 -2
  218. package/dist/chucao/p-DVKZbUp9.js +0 -3
  219. package/dist/chucao/p-DVKZbUp9.js.map +0 -1
  220. package/dist/chucao/p-b392021c.entry.js +0 -2
  221. package/dist/chucao/p-b392021c.entry.js.map +0 -1
  222. package/dist/cjs/index-ysucLiAq.js.map +0 -1
  223. package/dist/components/p-DQOKq7af.js +0 -2
  224. package/dist/components/p-DQOKq7af.js.map +0 -1
  225. package/dist/esm/index-DVKZbUp9.js.map +0 -1
  226. /package/dist/chucao/{p-1ebd9dc4.entry.js.map → p-0bc141a2.entry.js.map} +0 -0
  227. /package/dist/chucao/{p-449e1ba0.entry.js.map → p-0e044eff.entry.js.map} +0 -0
  228. /package/dist/chucao/{p-a07e0e97.entry.js.map → p-1108062e.entry.js.map} +0 -0
  229. /package/dist/chucao/{p-85db779c.entry.js.map → p-26e144ff.entry.js.map} +0 -0
  230. /package/dist/chucao/{p-6e95f31f.entry.js.map → p-337d7f68.entry.js.map} +0 -0
  231. /package/dist/chucao/{p-7c85f5fe.entry.js.map → p-350f974d.entry.js.map} +0 -0
  232. /package/dist/chucao/{p-907195ff.entry.js.map → p-4846cac4.entry.js.map} +0 -0
  233. /package/dist/chucao/{p-d0533af6.entry.js.map → p-6345c9e1.entry.js.map} +0 -0
  234. /package/dist/chucao/{p-34a9d1f4.entry.js.map → p-97655c41.entry.js.map} +0 -0
  235. /package/dist/chucao/{p-b5552b50.entry.js.map → p-9f73855e.entry.js.map} +0 -0
  236. /package/dist/chucao/{p-17451d92.entry.js.map → p-b53d954e.entry.js.map} +0 -0
  237. /package/dist/chucao/{p-d776b092.entry.js.map → p-b6cc08f0.entry.js.map} +0 -0
  238. /package/dist/chucao/{p-56d64d84.entry.js.map → p-c251b0d1.entry.js.map} +0 -0
  239. /package/dist/chucao/{p-84d875e9.entry.js.map → p-f9fe752c.entry.js.map} +0 -0
  240. /package/dist/chucao/{p-1778a313.entry.js.map → p-fdf065e6.entry.js.map} +0 -0
  241. /package/dist/components/{p-no2_9Jk-.js.map → p-CV0rD-fF.js.map} +0 -0
@@ -0,0 +1,162 @@
1
+ import { Host, h } from "@stencil/core";
2
+ /**
3
+ * The heading block at the top of a page: title, optional eyebrow and
4
+ * description, and a trailing actions area.
5
+ *
6
+ * The title is a `title` prop rather than a slot so the heading level always
7
+ * matches the page. A slotted heading lets a consumer nest a second `h1`, and
8
+ * "one top-level heading per page" then depends on every caller remembering it;
9
+ * here the level is explicit and defaults to `h1`. The actions wrap rather than
10
+ * push the page sideways at 390px, and the DOM order keeps the heading before
11
+ * the actions so reading and focus order still start with the title.
12
+ */
13
+ export class ChPageHeader {
14
+ /**
15
+ * The page title. Rendered as a real heading, so it also works as the
16
+ * accessible name of the page region.
17
+ */
18
+ title;
19
+ /**
20
+ * Heading element to render. Use `h2` (or `h3`) when the page already has a
21
+ * higher-level heading above this block, so the document outline stays valid.
22
+ */
23
+ headingLevel = 'h1';
24
+ /**
25
+ * Optional small label above the title, as slotted content. Use it for a
26
+ * section or entity kind ("Proyecto", "Factura #1042"), not for the title.
27
+ */
28
+ eyebrow;
29
+ /**
30
+ * Optional supporting line under the title.
31
+ */
32
+ description;
33
+ /**
34
+ * Puts the actions below the title instead of beside it. Use it when the
35
+ * actions are too wide to sit on the same row even after wrapping.
36
+ */
37
+ actionsStacked = false;
38
+ render() {
39
+ const Heading = this.headingLevel;
40
+ return (h(Host, { key: '02317c9b8a8164400ac269cbfd872e066e3269e3' }, h("div", { key: 'c1ab176079e95f4854826588405cd49c1bc42b58', class: { 'header': true, 'header--stacked': this.actionsStacked } }, h("div", { key: '57553e0d8ac563dfd55bedb23fb6896f922c187c', class: "header-text" }, this.eyebrow && h("p", { key: 'b38cbdfbc5a08cfddf60e9f82481df3ed8ad48e6', class: "header-eyebrow" }, this.eyebrow), h(Heading, { key: '521003f555a4adaae81bac11a6410638db923399', class: "header-title" }, this.title), this.description && h("p", { key: '0625bcd1903f52dfe16963bfc6d3ccf7e404d13a', class: "header-description" }, this.description)), h("div", { key: '23b65e1729bfa24324c24958b946435ff247cb4d', class: "header-actions" }, h("slot", { key: '45b4c24e4ce2bb4edc2929a2f17563260efb410f', name: "actions" })))));
41
+ }
42
+ static get is() { return "ch-page-header"; }
43
+ static get encapsulation() { return "shadow"; }
44
+ static get originalStyleUrls() {
45
+ return {
46
+ "$": ["ch-page-header.css"]
47
+ };
48
+ }
49
+ static get styleUrls() {
50
+ return {
51
+ "$": ["ch-page-header.css"]
52
+ };
53
+ }
54
+ static get properties() {
55
+ return {
56
+ "title": {
57
+ "type": "string",
58
+ "mutable": false,
59
+ "complexType": {
60
+ "original": "string",
61
+ "resolved": "string",
62
+ "references": {}
63
+ },
64
+ "required": true,
65
+ "optional": false,
66
+ "docs": {
67
+ "tags": [],
68
+ "text": "The page title. Rendered as a real heading, so it also works as the\naccessible name of the page region."
69
+ },
70
+ "getter": false,
71
+ "setter": false,
72
+ "reflect": false,
73
+ "attribute": "title"
74
+ },
75
+ "headingLevel": {
76
+ "type": "string",
77
+ "mutable": false,
78
+ "complexType": {
79
+ "original": "ChPageHeaderHeadingLevel",
80
+ "resolved": "\"h1\" | \"h2\" | \"h3\"",
81
+ "references": {
82
+ "ChPageHeaderHeadingLevel": {
83
+ "location": "local",
84
+ "path": "/home/runner/work/chucao/chucao/src/components/ch-page-header/ch-page-header.tsx",
85
+ "id": "src/components/ch-page-header/ch-page-header.tsx::ChPageHeaderHeadingLevel"
86
+ }
87
+ }
88
+ },
89
+ "required": false,
90
+ "optional": false,
91
+ "docs": {
92
+ "tags": [],
93
+ "text": "Heading element to render. Use `h2` (or `h3`) when the page already has a\nhigher-level heading above this block, so the document outline stays valid."
94
+ },
95
+ "getter": false,
96
+ "setter": false,
97
+ "reflect": false,
98
+ "attribute": "heading-level",
99
+ "defaultValue": "'h1'"
100
+ },
101
+ "eyebrow": {
102
+ "type": "string",
103
+ "mutable": false,
104
+ "complexType": {
105
+ "original": "string",
106
+ "resolved": "string",
107
+ "references": {}
108
+ },
109
+ "required": false,
110
+ "optional": true,
111
+ "docs": {
112
+ "tags": [],
113
+ "text": "Optional small label above the title, as slotted content. Use it for a\nsection or entity kind (\"Proyecto\", \"Factura #1042\"), not for the title."
114
+ },
115
+ "getter": false,
116
+ "setter": false,
117
+ "reflect": false,
118
+ "attribute": "eyebrow"
119
+ },
120
+ "description": {
121
+ "type": "string",
122
+ "mutable": false,
123
+ "complexType": {
124
+ "original": "string",
125
+ "resolved": "string",
126
+ "references": {}
127
+ },
128
+ "required": false,
129
+ "optional": true,
130
+ "docs": {
131
+ "tags": [],
132
+ "text": "Optional supporting line under the title."
133
+ },
134
+ "getter": false,
135
+ "setter": false,
136
+ "reflect": false,
137
+ "attribute": "description"
138
+ },
139
+ "actionsStacked": {
140
+ "type": "boolean",
141
+ "mutable": false,
142
+ "complexType": {
143
+ "original": "boolean",
144
+ "resolved": "boolean",
145
+ "references": {}
146
+ },
147
+ "required": false,
148
+ "optional": false,
149
+ "docs": {
150
+ "tags": [],
151
+ "text": "Puts the actions below the title instead of beside it. Use it when the\nactions are too wide to sit on the same row even after wrapping."
152
+ },
153
+ "getter": false,
154
+ "setter": false,
155
+ "reflect": false,
156
+ "attribute": "actions-stacked",
157
+ "defaultValue": "false"
158
+ }
159
+ };
160
+ }
161
+ }
162
+ //# sourceMappingURL=ch-page-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ch-page-header.js","sourceRoot":"","sources":["../../../../src/components/ch-page-header/ch-page-header.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAIzD;;;;;;;;;;GAUG;AAMH,MAAM,OAAO,YAAY;IACvB;;;OAGG;IACK,KAAK,CAAU;IAEvB;;;OAGG;IACK,YAAY,GAA6B,IAAI,CAAC;IAEtD;;;OAGG;IACK,OAAO,CAAU;IAEzB;;OAEG;IACK,WAAW,CAAU;IAE7B;;;OAGG;IACK,cAAc,GAAG,KAAK,CAAC;IAE/B,MAAM;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC;QAElC,OAAO,CACL,EAAC,IAAI;YACH,4DAAK,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,CAAC,cAAc,EAAE;gBACpE,4DAAK,KAAK,EAAC,aAAa;oBACrB,IAAI,CAAC,OAAO,IAAI,0DAAG,KAAK,EAAC,gBAAgB,IAAE,IAAI,CAAC,OAAO,CAAK;oBAC7D,EAAC,OAAO,qDAAC,KAAK,EAAC,cAAc,IAAE,IAAI,CAAC,KAAK,CAAW;oBACnD,IAAI,CAAC,WAAW,IAAI,0DAAG,KAAK,EAAC,oBAAoB,IAAE,IAAI,CAAC,WAAW,CAAK,CACrE;gBACN,4DAAK,KAAK,EAAC,gBAAgB;oBACzB,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACxB,CACF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, h } from '@stencil/core';\n\nexport type ChPageHeaderHeadingLevel = 'h1' | 'h2' | 'h3';\n\n/**\n * The heading block at the top of a page: title, optional eyebrow and\n * description, and a trailing actions area.\n *\n * The title is a `title` prop rather than a slot so the heading level always\n * matches the page. A slotted heading lets a consumer nest a second `h1`, and\n * \"one top-level heading per page\" then depends on every caller remembering it;\n * here the level is explicit and defaults to `h1`. The actions wrap rather than\n * push the page sideways at 390px, and the DOM order keeps the heading before\n * the actions so reading and focus order still start with the title.\n */\n@Component({\n tag: 'ch-page-header',\n styleUrl: 'ch-page-header.css',\n shadow: true,\n})\nexport class ChPageHeader {\n /**\n * The page title. Rendered as a real heading, so it also works as the\n * accessible name of the page region.\n */\n @Prop() title!: string;\n\n /**\n * Heading element to render. Use `h2` (or `h3`) when the page already has a\n * higher-level heading above this block, so the document outline stays valid.\n */\n @Prop() headingLevel: ChPageHeaderHeadingLevel = 'h1';\n\n /**\n * Optional small label above the title, as slotted content. Use it for a\n * section or entity kind (\"Proyecto\", \"Factura #1042\"), not for the title.\n */\n @Prop() eyebrow?: string;\n\n /**\n * Optional supporting line under the title.\n */\n @Prop() description?: string;\n\n /**\n * Puts the actions below the title instead of beside it. Use it when the\n * actions are too wide to sit on the same row even after wrapping.\n */\n @Prop() actionsStacked = false;\n\n render() {\n const Heading = this.headingLevel;\n\n return (\n <Host>\n <div class={{ 'header': true, 'header--stacked': this.actionsStacked }}>\n <div class=\"header-text\">\n {this.eyebrow && <p class=\"header-eyebrow\">{this.eyebrow}</p>}\n <Heading class=\"header-title\">{this.title}</Heading>\n {this.description && <p class=\"header-description\">{this.description}</p>}\n </div>\n <div class=\"header-actions\">\n <slot name=\"actions\"></slot>\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -98,7 +98,7 @@ export class ChRadio {
98
98
  }
99
99
  render() {
100
100
  const groupName = this.name || `${this.groupId}-group`;
101
- return (h(Host, { key: 'a2e08f3a0b409472f8f49e3c7f1a7f16619e66ec' }, this.label && (h("span", { key: '95d3bbd01c7301aeef7c64cd500d247184f5c4b3', class: "group-label", id: this.labelId }, this.label)), h("div", { key: 'fc8a4de53693e2a5e642dce6cb8d740c04b9e64e', class: "radio-group", role: "radiogroup", "aria-labelledby": this.label ? this.labelId : undefined }, this.options.map(option => (h("label", { class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled || option.disabled } }, h("input", { class: { 'input': true, 'input--invalid': this.invalid }, type: "radio", name: groupName, value: option.value, checked: option.value === this.value, disabled: this.disabled || this.formDisabled || option.disabled, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }), h("span", { class: "mark" }), h("span", { class: "label-text" }, option.label))))), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '0712a66b5344123bdce6b984de588465554b5c78', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: 'ce8111b984cd5280a960c4814ef124963ce95815', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
101
+ return (h(Host, { key: '9803d5b41d3985503d1b304d53504239d2a2de1d' }, this.label && (h("span", { key: 'f75cf217d50a300e5c6ddcdcfb9c5832e1f6b964', class: "group-label", id: this.labelId }, this.label)), h("div", { key: 'd8e9e24e82dfb77f728e8d9c994102202a9ce85b', class: "radio-group", role: "radiogroup", "aria-labelledby": this.label ? this.labelId : undefined }, this.options.map(option => (h("label", { class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled || option.disabled } }, h("input", { class: { 'input': true, 'input--invalid': this.invalid }, type: "radio", name: groupName, value: option.value, checked: option.value === this.value, disabled: this.disabled || this.formDisabled || option.disabled, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }), h("span", { class: "mark" }), h("span", { class: "label-text" }, option.label))))), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '91bed0d5cd70a032de7b8ba6e298903b387e1a4a', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: 'a2e6d6c87d60e98ac3d396f7dde907ce1e46946a', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
102
102
  }
103
103
  static get is() { return "ch-radio"; }
104
104
  static get encapsulation() { return "shadow"; }
@@ -92,7 +92,7 @@ export class ChSegmentedControl {
92
92
  }
93
93
  render() {
94
94
  const groupName = this.name || `${this.groupId}-group`;
95
- return (h(Host, { key: 'fde08d667755f78242d3c8c26e0c6df417c716ae' }, this.label && (h("span", { key: 'abadad2f4b7140fc77b78e25d15b64ed95fd150e', class: "group-label", id: this.labelId }, this.label)), h("div", { key: '7361933a554eec0728f10812907495813da8f3a3', class: { segmented: true, [`segmented--${this.size}`]: true }, role: "radiogroup", "aria-labelledby": this.label ? this.labelId : undefined }, this.options.map(option => (h("label", { class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled || option.disabled } }, h("input", { class: "input", type: "radio", name: groupName, value: option.value, checked: option.value === this.value, disabled: this.disabled || this.formDisabled || option.disabled, onChange: this.handleChange }), h("span", { class: "label-text" }, option.label)))))));
95
+ return (h(Host, { key: 'd6a9a720a1a210c73711cff1f7cd6c1ffa0c89b2' }, this.label && (h("span", { key: 'af5fb9ab87e918ac6047ebd6e65e540044c6a2d0', class: "group-label", id: this.labelId }, this.label)), h("div", { key: '8dd76ea8d792d918ac5e413946e8a08cb89480c7', class: { segmented: true, [`segmented--${this.size}`]: true }, role: "radiogroup", "aria-labelledby": this.label ? this.labelId : undefined }, this.options.map(option => (h("label", { class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled || option.disabled } }, h("input", { class: "input", type: "radio", name: groupName, value: option.value, checked: option.value === this.value, disabled: this.disabled || this.formDisabled || option.disabled, onChange: this.handleChange }), h("span", { class: "label-text" }, option.label)))))));
96
96
  }
97
97
  static get is() { return "ch-segmented-control"; }
98
98
  static get encapsulation() { return "shadow"; }
@@ -99,7 +99,7 @@ export class ChSelect {
99
99
  return undefined;
100
100
  }
101
101
  render() {
102
- return (h(Host, { key: '62230ff57779f812a3a9bdd7683ba6be8ac8cb74' }, this.label && (h("label", { key: '9a9cc9bbcefa0785f90221e6b7426b1cfe5fba02', class: "label", htmlFor: this.selectId }, this.label)), h("select", { key: 'e3faccac8af282a0ac571841d731d88b814f26c1', id: this.label ? this.selectId : undefined, class: { 'select': true, 'select--invalid': this.invalid }, name: this.name, disabled: this.disabled || this.formDisabled, required: this.required, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }, this.placeholder && (h("option", { key: '86e5f5af47bec9867f5f53c4b9b07766f55d56a7', value: "", disabled: true, hidden: true, selected: !this.value }, this.placeholder)), this.options.map(option => (h("option", { value: option.value, disabled: option.disabled, selected: option.value === this.value }, option.label)))), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: 'a6f36d726ed141eb8cd22d914b8901af24dc78b0', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '6d65c3890e13037fa58190f619fe6abc5f8964eb', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
102
+ return (h(Host, { key: 'b01c1dca70dbf88556521faa1be7430dc3d2355c' }, this.label && (h("label", { key: '265a09b70dafca0c9330ceaec2477b6b203a71eb', class: "label", htmlFor: this.selectId }, this.label)), h("select", { key: '43b387edff4fd326beac608fa16e50f3407e8cac', id: this.label ? this.selectId : undefined, class: { 'select': true, 'select--invalid': this.invalid }, name: this.name, disabled: this.disabled || this.formDisabled, required: this.required, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }, this.placeholder && (h("option", { key: '456e5220d2fd6fdb2a2171d10bcd11c6d2c58956', value: "", disabled: true, hidden: true, selected: !this.value }, this.placeholder)), this.options.map(option => (h("option", { value: option.value, disabled: option.disabled, selected: option.value === this.value }, option.label)))), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '7f4609f6441f9ce6c5f13b4a12875d85c110ccd8', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: 'e05a04a3f43ad055cd7cc57deb48f8b19d1a7084', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
103
103
  }
104
104
  static get is() { return "ch-select"; }
105
105
  static get encapsulation() { return "shadow"; }
@@ -47,7 +47,7 @@ export class ChSkeleton {
47
47
  return { width: this.width, height: this.height };
48
48
  }
49
49
  render() {
50
- return (h(Host, { key: 'd55fcc926f439555de011ae5f730a53ac42d1a28', "aria-hidden": "true", class: { 'skeleton': true, [`skeleton--${this.shape}`]: true, 'skeleton--animated': this.animated } }, Array.from({ length: this.items }).map((value, index) => (h("span", { class: "skeleton__item", style: this.sizeStyle, key: index, "data-index": String(value) })))));
50
+ return (h(Host, { key: 'bbcafacc79f0288204028378f2cf460f793ca702', "aria-hidden": "true", class: { 'skeleton': true, [`skeleton--${this.shape}`]: true, 'skeleton--animated': this.animated } }, Array.from({ length: this.items }).map((value, index) => (h("span", { class: "skeleton__item", style: this.sizeStyle, key: index, "data-index": String(value) })))));
51
51
  }
52
52
  static get is() { return "ch-skeleton"; }
53
53
  static get encapsulation() { return "shadow"; }
@@ -23,7 +23,7 @@ export class ChSpinner {
23
23
  label;
24
24
  render() {
25
25
  const labelled = Boolean(this.label);
26
- return (h(Host, { key: 'f90e872cf734e67bd8e422d681b7c053c882ee01' }, h("span", { key: '82314f5e4ccc80e1b6f1e026b8888d5daf43f1ca', class: { spinner: true, [`spinner--${this.size}`]: true }, role: labelled ? 'status' : undefined, "aria-label": labelled ? this.label : undefined, "aria-hidden": labelled ? undefined : 'true' })));
26
+ return (h(Host, { key: '9e1cc36781db28cded8318f67158332168b0bbfc' }, h("span", { key: '9c923d38545c0fceab0f244b4374708e2b7e2043', class: { spinner: true, [`spinner--${this.size}`]: true }, role: labelled ? 'status' : undefined, "aria-label": labelled ? this.label : undefined, "aria-hidden": labelled ? undefined : 'true' })));
27
27
  }
28
28
  static get is() { return "ch-spinner"; }
29
29
  static get encapsulation() { return "shadow"; }
@@ -24,7 +24,7 @@ export class ChStack {
24
24
  return GAPS.has(this.gap) ? this.gap : 'md';
25
25
  }
26
26
  render() {
27
- return (h(Host, { key: '0408430206db8b807cd879679a643b196699e2a9', class: { stack: true, [`stack--gap-${this.gapStep}`]: true, [`stack--align-${this.align}`]: true, [`stack--justify-${this.justify}`]: true } }, h("slot", { key: 'e05b9a1c4a944d8029e2738395828232098da324' })));
27
+ return (h(Host, { key: '646286c45adc0d816b0fdbcdfe9e70f809fedb95', class: { stack: true, [`stack--gap-${this.gapStep}`]: true, [`stack--align-${this.align}`]: true, [`stack--justify-${this.justify}`]: true } }, h("slot", { key: '1c18713eb95fc568a08bcbd6e018add9336a0fd0' })));
28
28
  }
29
29
  static get is() { return "ch-stack"; }
30
30
  static get encapsulation() { return "shadow"; }
@@ -95,7 +95,7 @@ export class ChSwitch {
95
95
  return undefined;
96
96
  }
97
97
  render() {
98
- return (h(Host, { key: '9a11339fb6204a2166dde9d71e30408ddd078512' }, h("label", { key: '6fb1c2ac4a61f1ac731c2093837a5813f82f5dbd', class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled }, htmlFor: this.switchId }, h("input", { key: '5a131871ae9c0c6ed0657e8a8371d08146566cb9', id: this.switchId, class: { 'input': true, 'input--invalid': this.invalid }, type: "checkbox", role: "switch", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled || this.formDisabled, required: this.required, "aria-checked": this.checked ? 'true' : 'false', "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }), h("span", { key: '5bf51dac83b3c2ba33e53b91fb3ec7819a5b8f24', class: "track" }, h("span", { key: '2d130d6e369664c76b337cd39d61f14be534cf66', class: "thumb" })), this.label && h("span", { key: 'e0552b9932018f6fbe7a0545db644846792cb1dc', class: "label-text" }, this.label)), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: 'd9a5ecbdff8e1b8ab5ee94cb2f02b796627e5991', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '2bcb7c3fc272b248aa0a52194d6cc97d7ec2615b', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
98
+ return (h(Host, { key: '7c862590fa8ce9c53d168cb670361259405c72bb' }, h("label", { key: 'e5602d4daa8ebf1a9832282fffb9e538fc1592a8', class: { 'control': true, 'control--disabled': this.disabled || this.formDisabled }, htmlFor: this.switchId }, h("input", { key: 'd29c00496c4a05ccbe66ffdbebf3a496c5ae6995', id: this.switchId, class: { 'input': true, 'input--invalid': this.invalid }, type: "checkbox", role: "switch", name: this.name, value: this.value, checked: this.checked, disabled: this.disabled || this.formDisabled, required: this.required, "aria-checked": this.checked ? 'true' : 'false', "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onChange: this.handleChange }), h("span", { key: '5739a0b689ac7ed9ebc917e6102b3951e80ac06d', class: "track" }, h("span", { key: 'e10c21f740092750dd9bb00cde84fa1c26746eb9', class: "thumb" })), this.label && h("span", { key: 'bec86897b1ef0023d3eb8c8438bf6740f32a5921', class: "label-text" }, this.label)), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '2568bcf74334e5f081df8efa9a1196c69cb3093d', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '319d5583cf10e329f05430a577d2f1f956ac8dd5', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
99
99
  }
100
100
  static get is() { return "ch-switch"; }
101
101
  static get encapsulation() { return "shadow"; }
@@ -77,7 +77,7 @@ export class ChTabs {
77
77
  }
78
78
  render() {
79
79
  const active = this.activeValue;
80
- return (h(Host, { key: '4dfeb1c42a7dd10d73e6372da15649eae502e565' }, h("div", { key: '1c75500e73377920e3629734316c103b8c0b2a60', class: "tablist", role: "tablist", "aria-label": this.label, onKeyDown: this.handleKeyDown, ref: el => (this.tablistEl = el) }, this.tabs.map(tab => {
80
+ return (h(Host, { key: '915c7a584397bbe10a72642a1ce5ed68f2264ed2' }, h("div", { key: 'b37a294722442c73d224410793cd0c098734993f', class: "tablist", role: "tablist", "aria-label": this.label, onKeyDown: this.handleKeyDown, ref: el => (this.tablistEl = el) }, this.tabs.map(tab => {
81
81
  const selected = tab.value === active;
82
82
  return (h("button", { key: tab.value, type: "button", class: { 'tab': true, 'tab--active': selected, 'tab--disabled': Boolean(tab.disabled) }, role: "tab", id: this.tabId(tab.value), "data-value": tab.value, "aria-selected": selected ? 'true' : 'false', "aria-controls": this.panelId(tab.value), tabIndex: selected ? FIRST_TAB_INDEX : LAST_TAB_INDEX, disabled: tab.disabled, onClick: () => this.select(tab.value) }, tab.label));
83
83
  })), this.tabs.map(tab => (h("div", { key: `${tab.value}-panel`, class: "tabpanel", id: this.panelId(tab.value), role: "tabpanel", "aria-labelledby": this.tabId(tab.value), tabIndex: FIRST_TAB_INDEX, hidden: tab.value !== active }, h("slot", { name: `panel-${tab.value}` }))))));
@@ -108,7 +108,7 @@ export class ChTextarea {
108
108
  return undefined;
109
109
  }
110
110
  render() {
111
- return (h(Host, { key: '0c7cb5ba7d3ccc84286a7cef5ca4208aa248c11b' }, this.label && (h("label", { key: 'a8b5e1e97394ab822cd43b8d70683e4add572d59', class: "label", htmlFor: this.textareaId }, this.label)), h("textarea", { key: '979f0a57566fdf8d0d946a9120b2431863f69ce4', id: this.label ? this.textareaId : undefined, class: { 'textarea': true, 'textarea--invalid': this.invalid }, rows: this.rows, name: this.name, placeholder: this.placeholder, disabled: this.disabled || this.formDisabled, required: this.required, value: this.value, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onInput: this.handleInput, onChange: this.handleChange }), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: 'ca0e931102deaf36d9524f889d93a72850f70a63', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: '595add930eedf5675c7a2aacd45d891fb8edb0f0', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
111
+ return (h(Host, { key: '5e7f4e6c779b677f259b56ebf6cb2e829511275e' }, this.label && (h("label", { key: '73a3a3d44b4926aaf0681aa68f878932c7932dae', class: "label", htmlFor: this.textareaId }, this.label)), h("textarea", { key: '10edc56d4846b578bd11c7bd001e7ca47aa1838d', id: this.label ? this.textareaId : undefined, class: { 'textarea': true, 'textarea--invalid': this.invalid }, rows: this.rows, name: this.name, placeholder: this.placeholder, disabled: this.disabled || this.formDisabled, required: this.required, value: this.value, "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.describedBy, onInput: this.handleInput, onChange: this.handleChange }), this.hint && !(this.invalid && this.errorMessage) && (h("p", { key: '393ea00da6e7def75d4305c242a9cf957013359b', class: "hint", id: this.hintId }, this.hint)), this.invalid && this.errorMessage && (h("p", { key: 'ba405aec9d92b410e063cec29235240a4a4ec715', class: "error", id: this.errorId, role: "alert" }, this.errorMessage))));
112
112
  }
113
113
  static get is() { return "ch-textarea"; }
114
114
  static get encapsulation() { return "shadow"; }
@@ -11,7 +11,7 @@
11
11
  position: absolute;
12
12
  z-index: var(--z-index-dropdown);
13
13
  width: max-content;
14
- max-width: 16rem;
14
+ max-width: min(16rem, calc(100vw - 2 * var(--spacing-2xl)));
15
15
  padding: var(--spacing-md) var(--spacing-2xl);
16
16
  border: var(--border-width) solid var(--border);
17
17
  border-radius: var(--radius-sm);
@@ -37,6 +37,19 @@
37
37
  position: absolute;
38
38
  }
39
39
 
40
+ /*
41
+ * Once the component has measured the anchor, the bubble is placed with fixed
42
+ * coordinates. Viewport coordinates do not depend on ancestors' transforms or
43
+ * overflow, so a tooltip inside a scrolling drawer or modal stays anchored.
44
+ */
45
+ .bubble--positioned {
46
+ position: fixed;
47
+ top: var(--ch-tooltip-offset-top);
48
+ left: var(--ch-tooltip-offset-left);
49
+ transform: none;
50
+ margin: 0;
51
+ }
52
+
40
53
  .bubble--top {
41
54
  bottom: 100%;
42
55
  left: 50%;
@@ -44,6 +57,21 @@
44
57
  margin-bottom: var(--spacing-md);
45
58
  }
46
59
 
60
+ /* Stencil scopes each rule by doubling its classes, so a three-class selector
61
+ is what actually outranks the single-class placement rules above. */
62
+ .bubble.bubble--positioned.bubble--top,
63
+ .bubble.bubble--positioned.bubble--bottom,
64
+ .bubble.bubble--positioned.bubble--left,
65
+ .bubble.bubble--positioned.bubble--right {
66
+ inset: auto;
67
+ top: var(--ch-tooltip-offset-top);
68
+ left: var(--ch-tooltip-offset-left);
69
+ right: auto;
70
+ bottom: auto;
71
+ transform: none;
72
+ margin: 0;
73
+ }
74
+
47
75
  .bubble--top::before {
48
76
  top: 100%;
49
77
  left: 0;
@@ -1,5 +1,8 @@
1
- import { Host, h } from "@stencil/core";
1
+ import { forceUpdate, Host, h } from "@stencil/core";
2
+ import { placeOverlay } from "../../utils/overlay";
2
3
  let tooltipIds = 0;
4
+ /** Space between the trigger and the bubble, matching `--spacing-md`. */
5
+ const GAP = 8;
3
6
  /**
4
7
  * Short help text shown on hover and on focus.
5
8
  *
@@ -15,12 +18,22 @@ let tooltipIds = 0;
15
18
  * `<input>`). A chucao component such as `ch-button` will not be described,
16
19
  * because `aria-*` set on a custom element host does not reach the native
17
20
  * element inside it — see the discussion in issue #47.
21
+ *
22
+ * Positioning is measured, not purely CSS: `placement` is the preferred side,
23
+ * and the bubble flips to the opposite side when the preferred one does not
24
+ * fit, then shifts along the other axis to stay inside the viewport. It
25
+ * re-measures on scroll, resize and visual-viewport changes, which is what
26
+ * keeps it correct inside a scrolling modal or drawer and when a mobile
27
+ * keyboard shrinks the visible area.
18
28
  */
19
29
  export class ChTooltip {
20
30
  el;
21
31
  fallbackId = `ch-tooltip-${++tooltipIds}`;
32
+ bubbleEl;
33
+ cleanup;
22
34
  /**
23
- * Which side of the trigger the bubble is placed on.
35
+ * The side the bubble is placed on. It is a preference: when that side has no
36
+ * room the bubble flips to the opposite one.
24
37
  */
25
38
  placement = 'top';
26
39
  // Hover and focus are tracked apart so that neither cancels the other: a
@@ -29,15 +42,26 @@ export class ChTooltip {
29
42
  hovered = false;
30
43
  focused = false;
31
44
  dismissed = false;
45
+ /** The placement actually used, which may differ from the prop after a flip. */
46
+ resolvedPlacement;
47
+ /** Offset applied to the bubble once it has been measured. */
48
+ offset;
32
49
  get visible() {
33
50
  return (this.hovered || this.focused) && !this.dismissed;
34
51
  }
35
52
  componentDidLoad() {
36
53
  this.associate();
37
54
  }
55
+ connectedCallback() {
56
+ this.watchViewport();
57
+ }
58
+ disconnectedCallback() {
59
+ this.cleanup?.();
60
+ }
38
61
  handleMouseEnter() {
39
62
  this.hovered = true;
40
63
  this.dismissed = false;
64
+ this.position();
41
65
  }
42
66
  handleMouseLeave() {
43
67
  this.hovered = false;
@@ -45,6 +69,7 @@ export class ChTooltip {
45
69
  handleFocusIn() {
46
70
  this.focused = true;
47
71
  this.dismissed = false;
72
+ this.position();
48
73
  }
49
74
  handleFocusOut() {
50
75
  this.focused = false;
@@ -52,15 +77,83 @@ export class ChTooltip {
52
77
  /**
53
78
  * Listens on the document because a tooltip opened by hovering leaves focus
54
79
  * wherever it was, so a host-scoped handler would never see the key.
80
+ *
81
+ * Only the outermost Escape handler is stopped from propagating, so a
82
+ * tooltip inside an open modal closes itself and leaves the modal open.
55
83
  */
56
84
  handleKeyDown(event) {
57
- if (event.key === 'Escape' && this.visible) {
85
+ if (event.key === 'Escape' && this.visible && !event.defaultPrevented) {
86
+ event.preventDefault();
58
87
  this.dismissed = true;
59
88
  }
60
89
  }
90
+ /** Cheap guard so scroll frames do not measure while nothing is shown. */
91
+ handleScroll() {
92
+ if (this.visible && this.offset) {
93
+ this.position();
94
+ }
95
+ }
96
+ handleResize() {
97
+ this.position();
98
+ }
99
+ watchViewport() {
100
+ if (typeof window === 'undefined') {
101
+ return;
102
+ }
103
+ const viewport = window.visualViewport;
104
+ if (!viewport || this.cleanup) {
105
+ return;
106
+ }
107
+ const update = () => this.position();
108
+ viewport.addEventListener('resize', update);
109
+ viewport.addEventListener('scroll', update);
110
+ this.cleanup = () => {
111
+ viewport.removeEventListener('resize', update);
112
+ viewport.removeEventListener('scroll', update);
113
+ };
114
+ }
61
115
  slotted(name) {
62
116
  return Array.from(this.el.children).find(child => child.getAttribute('slot') === name);
63
117
  }
118
+ /**
119
+ * Measures the anchor and the bubble and stores the offset that keeps the
120
+ * bubble inside the viewport. Nothing is measured before the bubble has a
121
+ * box to measure, so the pre-paint render uses plain CSS.
122
+ */
123
+ position() {
124
+ if (typeof window === 'undefined') {
125
+ return;
126
+ }
127
+ const bubble = this.bubbleEl ?? (this.bubbleEl = this.el.shadowRoot?.querySelector('.bubble') ?? undefined);
128
+ if (!bubble || bubble.offsetWidth === 0) {
129
+ return;
130
+ }
131
+ const anchorRect = this.slotted('trigger')?.getBoundingClientRect?.();
132
+ if (!anchorRect) {
133
+ return;
134
+ }
135
+ const surface = {
136
+ width: bubble.offsetWidth + horizontalMargin(bubble),
137
+ height: bubble.offsetHeight,
138
+ };
139
+ const viewport = window.visualViewport;
140
+ const { placement, top, left } = placeOverlay({
141
+ anchor: { top: anchorRect.top, left: anchorRect.left, width: anchorRect.width, height: anchorRect.height },
142
+ surface,
143
+ viewport: viewport
144
+ ? { top: viewport.offsetTop, left: viewport.offsetLeft, width: viewport.width, height: viewport.height }
145
+ : { top: 0, left: 0, width: window.innerWidth, height: window.innerHeight },
146
+ preferred: this.placement,
147
+ gap: GAP,
148
+ });
149
+ const current = this.offset;
150
+ const unchanged = current?.top === top && current?.left === left && this.resolvedPlacement === placement;
151
+ this.resolvedPlacement = placement;
152
+ this.offset = { top, left };
153
+ if (!unchanged) {
154
+ forceUpdate(this);
155
+ }
156
+ }
64
157
  /**
65
158
  * Points the trigger at the text with `aria-describedby`. Re-run on
66
159
  * `slotchange` because a framework re-render can replace the slotted nodes
@@ -79,7 +172,16 @@ export class ChTooltip {
79
172
  trigger.setAttribute('aria-describedby', content.id);
80
173
  };
81
174
  render() {
82
- return (h(Host, { key: 'e05ba1cdb8f3ee499762a04c8271c772c7cbe201' }, h("span", { key: 'c5a0bd2f6107e99114fc9328a3f731dfe59753d4', class: "anchor" }, h("slot", { key: 'ffd09d90395e2ffb2349e7d2eb8e349b2a7991b8', name: "trigger", onSlotchange: this.associate }), h("span", { key: '4af10e86d9f61e2defef8b86df3ba55f280acd91', class: { 'bubble': true, [`bubble--${this.placement}`]: true, 'bubble--visible': this.visible } }, h("slot", { key: '047ba42d8846f43d31823318258f1761f15efc64', name: "content", onSlotchange: this.associate })))));
175
+ const { offset } = this;
176
+ return (h(Host, { key: 'fb651dc0bf007fb86c9f69b2c714106520df4d4a' }, h("span", { key: '74324b8e4c0b7c552255605c6aa4ae739e16d832', class: "anchor" }, h("slot", { key: 'd4c2025af2d96b2ea4e7d8d601ce803be82a4a3e', name: "trigger", onSlotchange: this.associate }), h("span", { key: 'f6561dce022d8d9d2d0fb2b6984591301483b1f3', ref: el => (this.bubbleEl = el), style: {
177
+ '--ch-tooltip-offset-top': offset ? `${offset.top}px` : null,
178
+ '--ch-tooltip-offset-left': offset ? `${offset.left}px` : null,
179
+ }, class: {
180
+ 'bubble': true,
181
+ 'bubble--positioned': Boolean(this.offset),
182
+ [`bubble--${this.resolvedPlacement ?? this.placement}`]: true,
183
+ 'bubble--visible': this.visible,
184
+ } }, h("slot", { key: 'a099d15660ea17211b4c50912842b3152e5f652c', name: "content", onSlotchange: this.associate })))));
83
185
  }
84
186
  static get is() { return "ch-tooltip"; }
85
187
  static get encapsulation() { return "shadow"; }
@@ -113,7 +215,7 @@ export class ChTooltip {
113
215
  "optional": false,
114
216
  "docs": {
115
217
  "tags": [],
116
- "text": "Which side of the trigger the bubble is placed on."
218
+ "text": "The side the bubble is placed on. It is a preference: when that side has no\nroom the bubble flips to the opposite one."
117
219
  },
118
220
  "getter": false,
119
221
  "setter": false,
@@ -127,7 +229,8 @@ export class ChTooltip {
127
229
  return {
128
230
  "hovered": {},
129
231
  "focused": {},
130
- "dismissed": {}
232
+ "dismissed": {},
233
+ "resolvedPlacement": {}
131
234
  };
132
235
  }
133
236
  static get elementRef() { return "el"; }
@@ -162,7 +265,23 @@ export class ChTooltip {
162
265
  "target": "document",
163
266
  "capture": false,
164
267
  "passive": false
268
+ }, {
269
+ "name": "scroll",
270
+ "method": "handleScroll",
271
+ "target": "window",
272
+ "capture": true,
273
+ "passive": true
274
+ }, {
275
+ "name": "resize",
276
+ "method": "handleResize",
277
+ "target": "window",
278
+ "capture": false,
279
+ "passive": true
165
280
  }];
166
281
  }
167
282
  }
283
+ function horizontalMargin(el) {
284
+ const style = getComputedStyle(el);
285
+ return (parseFloat(style.marginLeft) || 0) + (parseFloat(style.marginRight) || 0);
286
+ }
168
287
  //# sourceMappingURL=ch-tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ch-tooltip.js","sourceRoot":"","sources":["../../../../src/components/ch-tooltip/ch-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAIjF,IAAI,UAAU,GAAG,CAAC,CAAC;AAEnB;;;;;;;;;;;;;;;GAeG;AAMH,MAAM,OAAO,SAAS;IACD,EAAE,CAAc;IAElB,UAAU,GAAG,cAAc,EAAE,UAAU,EAAE,CAAC;IAE3D;;OAEG;IACK,SAAS,GAAuB,KAAK,CAAC;IAE9C,yEAAyE;IACzE,4EAA4E;IAC5E,wBAAwB;IACf,OAAO,GAAG,KAAK,CAAC;IAChB,OAAO,GAAG,KAAK,CAAC;IAChB,SAAS,GAAG,KAAK,CAAC;IAE3B,IAAY,OAAO;QACjB,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;IAC3D,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAGD,gBAAgB;QACd,IAAI,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C,CAAC;IAEF,MAAM;QACJ,OAAO,CACL,EAAC,IAAI;YACH,6DAAM,KAAK,EAAC,QAAQ;gBAClB,6DAAM,IAAI,EAAC,SAAS,EAAC,YAAY,EAAE,IAAI,CAAC,SAAS,GAAS;gBAC1D,6DAAM,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,WAAW,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,CAAC,OAAO,EAAE;oBACnG,6DAAM,IAAI,EAAC,SAAS,EAAC,YAAY,EAAE,IAAI,CAAC,SAAS,GAAS,CACrD,CACF,CACF,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Host, Listen, Prop, State, h } from '@stencil/core';\n\nexport type ChTooltipPlacement = 'top' | 'bottom' | 'left' | 'right';\n\nlet tooltipIds = 0;\n\n/**\n * Short help text shown on hover and on focus.\n *\n * Both the trigger and the text come from the consumer's light DOM through\n * named slots. That is what makes the accessible association work: an\n * `aria-describedby` IDREF only resolves within a single tree, and slotted\n * nodes stay in the document tree even though they render inside the shadow\n * root. Keeping the text in the shadow root instead would need a reference\n * pointing into a shadow tree, which the platform does not allow — element\n * reflection only points outwards, and `referenceTarget` is not available yet.\n *\n * The trigger has to be a natively focusable element (`<button>`, `<a>`,\n * `<input>`). A chucao component such as `ch-button` will not be described,\n * because `aria-*` set on a custom element host does not reach the native\n * element inside it — see the discussion in issue #47.\n */\n@Component({\n tag: 'ch-tooltip',\n styleUrl: 'ch-tooltip.css',\n shadow: true,\n})\nexport class ChTooltip {\n @Element() private el: HTMLElement;\n\n private readonly fallbackId = `ch-tooltip-${++tooltipIds}`;\n\n /**\n * Which side of the trigger the bubble is placed on.\n */\n @Prop() placement: ChTooltipPlacement = 'top';\n\n // Hover and focus are tracked apart so that neither cancels the other: a\n // pointer passing over and away must not hide a tooltip whose trigger still\n // holds keyboard focus.\n @State() hovered = false;\n @State() focused = false;\n @State() dismissed = false;\n\n private get visible() {\n return (this.hovered || this.focused) && !this.dismissed;\n }\n\n componentDidLoad() {\n this.associate();\n }\n\n @Listen('mouseenter')\n handleMouseEnter() {\n this.hovered = true;\n this.dismissed = false;\n }\n\n @Listen('mouseleave')\n handleMouseLeave() {\n this.hovered = false;\n }\n\n @Listen('focusin')\n handleFocusIn() {\n this.focused = true;\n this.dismissed = false;\n }\n\n @Listen('focusout')\n handleFocusOut() {\n this.focused = false;\n }\n\n /**\n * Listens on the document because a tooltip opened by hovering leaves focus\n * wherever it was, so a host-scoped handler would never see the key.\n */\n @Listen('keydown', { target: 'document' })\n handleKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape' && this.visible) {\n this.dismissed = true;\n }\n }\n\n private slotted(name: string) {\n return Array.from(this.el.children).find(child => child.getAttribute('slot') === name);\n }\n\n /**\n * Points the trigger at the text with `aria-describedby`. Re-run on\n * `slotchange` because a framework re-render can replace the slotted nodes\n * and take the attributes with them.\n */\n private associate = () => {\n const trigger = this.slotted('trigger');\n const content = this.slotted('content');\n if (!trigger || !content) {\n return;\n }\n if (!content.id) {\n content.id = this.fallbackId;\n }\n content.setAttribute('role', 'tooltip');\n trigger.setAttribute('aria-describedby', content.id);\n };\n\n render() {\n return (\n <Host>\n <span class=\"anchor\">\n <slot name=\"trigger\" onSlotchange={this.associate}></slot>\n <span class={{ 'bubble': true, [`bubble--${this.placement}`]: true, 'bubble--visible': this.visible }}>\n <slot name=\"content\" onSlotchange={this.associate}></slot>\n </span>\n </span>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"ch-tooltip.js","sourceRoot":"","sources":["../../../../src/components/ch-tooltip/ch-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EA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component, Element, forceUpdate, Host, Listen, Prop, State, h } from '@stencil/core';\n\nimport { placeOverlay, type ChOverlayPlacement } from '../../utils/overlay';\n\nexport type ChTooltipPlacement = ChOverlayPlacement;\n\nlet tooltipIds = 0;\n\n/** Space between the trigger and the bubble, matching `--spacing-md`. */\nconst GAP = 8;\n\n/**\n * Short help text shown on hover and on focus.\n *\n * Both the trigger and the text come from the consumer's light DOM through\n * named slots. That is what makes the accessible association work: an\n * `aria-describedby` IDREF only resolves within a single tree, and slotted\n * nodes stay in the document tree even though they render inside the shadow\n * root. Keeping the text in the shadow root instead would need a reference\n * pointing into a shadow tree, which the platform does not allow — element\n * reflection only points outwards, and `referenceTarget` is not available yet.\n *\n * The trigger has to be a natively focusable element (`<button>`, `<a>`,\n * `<input>`). A chucao component such as `ch-button` will not be described,\n * because `aria-*` set on a custom element host does not reach the native\n * element inside it — see the discussion in issue #47.\n *\n * Positioning is measured, not purely CSS: `placement` is the preferred side,\n * and the bubble flips to the opposite side when the preferred one does not\n * fit, then shifts along the other axis to stay inside the viewport. It\n * re-measures on scroll, resize and visual-viewport changes, which is what\n * keeps it correct inside a scrolling modal or drawer and when a mobile\n * keyboard shrinks the visible area.\n */\n@Component({\n tag: 'ch-tooltip',\n styleUrl: 'ch-tooltip.css',\n shadow: true,\n})\nexport class ChTooltip {\n @Element() private el: HTMLElement;\n\n private readonly fallbackId = `ch-tooltip-${++tooltipIds}`;\n\n private bubbleEl?: HTMLElement;\n\n private cleanup?: () => void;\n\n /**\n * The side the bubble is placed on. It is a preference: when that side has no\n * room the bubble flips to the opposite one.\n */\n @Prop() placement: ChTooltipPlacement = 'top';\n\n // Hover and focus are tracked apart so that neither cancels the other: a\n // pointer passing over and away must not hide a tooltip whose trigger still\n // holds keyboard focus.\n @State() hovered = false;\n @State() focused = false;\n @State() dismissed = false;\n\n /** The placement actually used, which may differ from the prop after a flip. */\n @State() resolvedPlacement?: ChTooltipPlacement;\n\n /** Offset applied to the bubble once it has been measured. */\n private offset?: { top: number; left: number };\n\n private get visible() {\n return (this.hovered || this.focused) && !this.dismissed;\n }\n\n componentDidLoad() {\n this.associate();\n }\n\n connectedCallback() {\n this.watchViewport();\n }\n\n disconnectedCallback() {\n this.cleanup?.();\n }\n\n @Listen('mouseenter')\n handleMouseEnter() {\n this.hovered = true;\n this.dismissed = false;\n this.position();\n }\n\n @Listen('mouseleave')\n handleMouseLeave() {\n this.hovered = false;\n }\n\n @Listen('focusin')\n handleFocusIn() {\n this.focused = true;\n this.dismissed = false;\n this.position();\n }\n\n @Listen('focusout')\n handleFocusOut() {\n this.focused = false;\n }\n\n /**\n * Listens on the document because a tooltip opened by hovering leaves focus\n * wherever it was, so a host-scoped handler would never see the key.\n *\n * Only the outermost Escape handler is stopped from propagating, so a\n * tooltip inside an open modal closes itself and leaves the modal open.\n */\n @Listen('keydown', { target: 'document' })\n handleKeyDown(event: KeyboardEvent) {\n if (event.key === 'Escape' && this.visible && !event.defaultPrevented) {\n event.preventDefault();\n this.dismissed = true;\n }\n }\n\n /** Cheap guard so scroll frames do not measure while nothing is shown. */\n @Listen('scroll', { target: 'window', capture: true, passive: true })\n handleScroll() {\n if (this.visible && this.offset) {\n this.position();\n }\n }\n\n @Listen('resize', { target: 'window', passive: true })\n handleResize() {\n this.position();\n }\n\n private watchViewport() {\n if (typeof window === 'undefined') {\n return;\n }\n const viewport = window.visualViewport;\n if (!viewport || this.cleanup) {\n return;\n }\n const update = () => this.position();\n viewport.addEventListener('resize', update);\n viewport.addEventListener('scroll', update);\n this.cleanup = () => {\n viewport.removeEventListener('resize', update);\n viewport.removeEventListener('scroll', update);\n };\n }\n\n private slotted(name: string) {\n return Array.from(this.el.children).find(child => child.getAttribute('slot') === name);\n }\n\n /**\n * Measures the anchor and the bubble and stores the offset that keeps the\n * bubble inside the viewport. Nothing is measured before the bubble has a\n * box to measure, so the pre-paint render uses plain CSS.\n */\n private position() {\n if (typeof window === 'undefined') {\n return;\n }\n const bubble = this.bubbleEl ?? (this.bubbleEl = this.el.shadowRoot?.querySelector<HTMLElement>('.bubble') ?? undefined);\n if (!bubble || bubble.offsetWidth === 0) {\n return;\n }\n\n const anchorRect = (this.slotted('trigger') as HTMLElement | undefined)?.getBoundingClientRect?.();\n if (!anchorRect) {\n return;\n }\n\n const surface = {\n width: bubble.offsetWidth + horizontalMargin(bubble),\n height: bubble.offsetHeight,\n };\n const viewport = window.visualViewport;\n\n const { placement, top, left } = placeOverlay({\n anchor: { top: anchorRect.top, left: anchorRect.left, width: anchorRect.width, height: anchorRect.height },\n surface,\n viewport: viewport\n ? { top: viewport.offsetTop, left: viewport.offsetLeft, width: viewport.width, height: viewport.height }\n : { top: 0, left: 0, width: window.innerWidth, height: window.innerHeight },\n preferred: this.placement,\n gap: GAP,\n });\n\n const current = this.offset;\n const unchanged = current?.top === top && current?.left === left && this.resolvedPlacement === placement;\n this.resolvedPlacement = placement;\n this.offset = { top, left };\n if (!unchanged) {\n forceUpdate(this);\n }\n }\n\n /**\n * Points the trigger at the text with `aria-describedby`. Re-run on\n * `slotchange` because a framework re-render can replace the slotted nodes\n * and take the attributes with them.\n */\n private associate = () => {\n const trigger = this.slotted('trigger');\n const content = this.slotted('content');\n if (!trigger || !content) {\n return;\n }\n if (!content.id) {\n content.id = this.fallbackId;\n }\n content.setAttribute('role', 'tooltip');\n trigger.setAttribute('aria-describedby', content.id);\n };\n\n render() {\n const { offset } = this;\n\n return (\n <Host>\n <span class=\"anchor\">\n {/* Pre-measure render uses the preferred side so the bubble never\n jumps from the wrong edge on its first frame. */}\n <slot name=\"trigger\" onSlotchange={this.associate}></slot>\n <span\n ref={el => (this.bubbleEl = el)}\n style={{\n '--ch-tooltip-offset-top': offset ? `${offset.top}px` : null,\n '--ch-tooltip-offset-left': offset ? `${offset.left}px` : null,\n }}\n class={{\n 'bubble': true,\n 'bubble--positioned': Boolean(this.offset),\n [`bubble--${this.resolvedPlacement ?? this.placement}`]: true,\n 'bubble--visible': this.visible,\n }}\n >\n <slot name=\"content\" onSlotchange={this.associate}></slot>\n </span>\n </span>\n </Host>\n );\n }\n}\n\nfunction horizontalMargin(el: HTMLElement) {\n const style = getComputedStyle(el);\n return (parseFloat(style.marginLeft) || 0) + (parseFloat(style.marginRight) || 0);\n}\n"]}
@@ -63,6 +63,10 @@ export const zIndexBase = 0;
63
63
  export const zIndexDropdown = 100;
64
64
  export const zIndexModal = 1000;
65
65
  export const layoutMaxWidth = '68rem';
66
+ export const iconSizeSm = '16px';
67
+ export const iconSizeMd = '20px';
68
+ export const iconSizeLg = '24px';
69
+ export const iconStroke = '2px';
66
70
  export const tokens = {
67
71
  'color': {
68
72
  background: {
@@ -176,5 +180,13 @@ export const tokens = {
176
180
  'layout': {
177
181
  maxWidth: '68rem',
178
182
  },
183
+ 'icon': {
184
+ size: {
185
+ sm: '16px',
186
+ md: '20px',
187
+ lg: '24px',
188
+ },
189
+ stroke: '2px',
190
+ },
179
191
  };
180
192
  //# sourceMappingURL=tokens.js.map