@flyingrobots/bijou 0.10.0 → 1.0.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 (256) hide show
  1. package/dist/adapters/test/assertions.d.ts +51 -0
  2. package/dist/adapters/test/assertions.d.ts.map +1 -0
  3. package/dist/adapters/test/assertions.js +67 -0
  4. package/dist/adapters/test/assertions.js.map +1 -0
  5. package/dist/adapters/test/audit-style.d.ts +28 -7
  6. package/dist/adapters/test/audit-style.d.ts.map +1 -1
  7. package/dist/adapters/test/audit-style.js +61 -4
  8. package/dist/adapters/test/audit-style.js.map +1 -1
  9. package/dist/adapters/test/index.d.ts +36 -1
  10. package/dist/adapters/test/index.d.ts.map +1 -1
  11. package/dist/adapters/test/index.js +12 -1
  12. package/dist/adapters/test/index.js.map +1 -1
  13. package/dist/adapters/test/io.d.ts +27 -0
  14. package/dist/adapters/test/io.d.ts.map +1 -1
  15. package/dist/adapters/test/io.js +56 -0
  16. package/dist/adapters/test/io.js.map +1 -1
  17. package/dist/adapters/test/runtime.d.ts +17 -0
  18. package/dist/adapters/test/runtime.d.ts.map +1 -1
  19. package/dist/adapters/test/runtime.js +14 -0
  20. package/dist/adapters/test/runtime.js.map +1 -1
  21. package/dist/adapters/test/style.d.ts +9 -0
  22. package/dist/adapters/test/style.d.ts.map +1 -1
  23. package/dist/adapters/test/style.js +54 -0
  24. package/dist/adapters/test/style.js.map +1 -1
  25. package/dist/context.d.ts +21 -0
  26. package/dist/context.d.ts.map +1 -1
  27. package/dist/context.js +21 -0
  28. package/dist/context.js.map +1 -1
  29. package/dist/core/bg-fill.d.ts +32 -0
  30. package/dist/core/bg-fill.d.ts.map +1 -0
  31. package/dist/core/bg-fill.js +42 -0
  32. package/dist/core/bg-fill.js.map +1 -0
  33. package/dist/core/components/accordion.d.ts +20 -0
  34. package/dist/core/components/accordion.d.ts.map +1 -1
  35. package/dist/core/components/accordion.js +13 -6
  36. package/dist/core/components/accordion.js.map +1 -1
  37. package/dist/core/components/alert.d.ts +16 -0
  38. package/dist/core/components/alert.d.ts.map +1 -1
  39. package/dist/core/components/alert.js +17 -6
  40. package/dist/core/components/alert.js.map +1 -1
  41. package/dist/core/components/badge.d.ts +18 -0
  42. package/dist/core/components/badge.d.ts.map +1 -1
  43. package/dist/core/components/badge.js +15 -11
  44. package/dist/core/components/badge.js.map +1 -1
  45. package/dist/core/components/box.d.ts +31 -0
  46. package/dist/core/components/box.d.ts.map +1 -1
  47. package/dist/core/components/box.js +45 -10
  48. package/dist/core/components/box.js.map +1 -1
  49. package/dist/core/components/breadcrumb.d.ts +15 -0
  50. package/dist/core/components/breadcrumb.d.ts.map +1 -1
  51. package/dist/core/components/breadcrumb.js +13 -6
  52. package/dist/core/components/breadcrumb.js.map +1 -1
  53. package/dist/core/components/dag-source.d.ts +52 -9
  54. package/dist/core/components/dag-source.d.ts.map +1 -1
  55. package/dist/core/components/dag-source.js +53 -9
  56. package/dist/core/components/dag-source.js.map +1 -1
  57. package/dist/core/components/dag-stats.d.ts +2 -0
  58. package/dist/core/components/dag-stats.d.ts.map +1 -1
  59. package/dist/core/components/dag-stats.js.map +1 -1
  60. package/dist/core/components/dag.d.ts +88 -1
  61. package/dist/core/components/dag.d.ts.map +1 -1
  62. package/dist/core/components/dag.js +127 -6
  63. package/dist/core/components/dag.js.map +1 -1
  64. package/dist/core/components/enumerated-list.d.ts +30 -0
  65. package/dist/core/components/enumerated-list.d.ts.map +1 -1
  66. package/dist/core/components/enumerated-list.js +50 -11
  67. package/dist/core/components/enumerated-list.js.map +1 -1
  68. package/dist/core/components/hyperlink.d.ts +16 -0
  69. package/dist/core/components/hyperlink.d.ts.map +1 -1
  70. package/dist/core/components/hyperlink.js +22 -11
  71. package/dist/core/components/hyperlink.js.map +1 -1
  72. package/dist/core/components/index.d.ts +7 -0
  73. package/dist/core/components/index.d.ts.map +1 -1
  74. package/dist/core/components/index.js +7 -0
  75. package/dist/core/components/index.js.map +1 -1
  76. package/dist/core/components/kbd.d.ts +14 -0
  77. package/dist/core/components/kbd.d.ts.map +1 -1
  78. package/dist/core/components/kbd.js +13 -6
  79. package/dist/core/components/kbd.js.map +1 -1
  80. package/dist/core/components/log.d.ts +20 -0
  81. package/dist/core/components/log.d.ts.map +1 -1
  82. package/dist/core/components/log.js +24 -11
  83. package/dist/core/components/log.js.map +1 -1
  84. package/dist/core/components/logo.d.ts +32 -0
  85. package/dist/core/components/logo.d.ts.map +1 -1
  86. package/dist/core/components/logo.js +38 -0
  87. package/dist/core/components/logo.js.map +1 -1
  88. package/dist/core/components/markdown.d.ts +7 -1
  89. package/dist/core/components/markdown.d.ts.map +1 -1
  90. package/dist/core/components/markdown.js +76 -0
  91. package/dist/core/components/markdown.js.map +1 -1
  92. package/dist/core/components/paginator.d.ts +16 -0
  93. package/dist/core/components/paginator.d.ts.map +1 -1
  94. package/dist/core/components/paginator.js +12 -6
  95. package/dist/core/components/paginator.js.map +1 -1
  96. package/dist/core/components/progress.d.ts +55 -0
  97. package/dist/core/components/progress.d.ts.map +1 -1
  98. package/dist/core/components/progress.js +37 -6
  99. package/dist/core/components/progress.js.map +1 -1
  100. package/dist/core/components/separator.d.ts +16 -0
  101. package/dist/core/components/separator.d.ts.map +1 -1
  102. package/dist/core/components/separator.js +12 -6
  103. package/dist/core/components/separator.js.map +1 -1
  104. package/dist/core/components/skeleton.d.ts +15 -0
  105. package/dist/core/components/skeleton.d.ts.map +1 -1
  106. package/dist/core/components/skeleton.js +12 -6
  107. package/dist/core/components/skeleton.js.map +1 -1
  108. package/dist/core/components/spinner.d.ts +37 -0
  109. package/dist/core/components/spinner.d.ts.map +1 -1
  110. package/dist/core/components/spinner.js +26 -6
  111. package/dist/core/components/spinner.js.map +1 -1
  112. package/dist/core/components/stepper.d.ts +20 -0
  113. package/dist/core/components/stepper.d.ts.map +1 -1
  114. package/dist/core/components/stepper.js +16 -6
  115. package/dist/core/components/stepper.js.map +1 -1
  116. package/dist/core/components/table.d.ts +20 -0
  117. package/dist/core/components/table.d.ts.map +1 -1
  118. package/dist/core/components/table.js +31 -6
  119. package/dist/core/components/table.js.map +1 -1
  120. package/dist/core/components/tabs.d.ts +19 -0
  121. package/dist/core/components/tabs.d.ts.map +1 -1
  122. package/dist/core/components/tabs.js +19 -6
  123. package/dist/core/components/tabs.js.map +1 -1
  124. package/dist/core/components/timeline.d.ts +19 -0
  125. package/dist/core/components/timeline.d.ts.map +1 -1
  126. package/dist/core/components/timeline.js +20 -6
  127. package/dist/core/components/timeline.js.map +1 -1
  128. package/dist/core/components/tree.d.ts +19 -0
  129. package/dist/core/components/tree.d.ts.map +1 -1
  130. package/dist/core/components/tree.js +49 -11
  131. package/dist/core/components/tree.js.map +1 -1
  132. package/dist/core/detect/index.d.ts +8 -2
  133. package/dist/core/detect/index.d.ts.map +1 -1
  134. package/dist/core/detect/index.js +7 -1
  135. package/dist/core/detect/index.js.map +1 -1
  136. package/dist/core/detect/tty.d.ts +36 -0
  137. package/dist/core/detect/tty.d.ts.map +1 -1
  138. package/dist/core/detect/tty.js +34 -0
  139. package/dist/core/detect/tty.js.map +1 -1
  140. package/dist/core/forms/confirm.d.ts +14 -0
  141. package/dist/core/forms/confirm.d.ts.map +1 -1
  142. package/dist/core/forms/confirm.js +15 -5
  143. package/dist/core/forms/confirm.js.map +1 -1
  144. package/dist/core/forms/filter.d.ts +30 -0
  145. package/dist/core/forms/filter.d.ts.map +1 -1
  146. package/dist/core/forms/filter.js +67 -49
  147. package/dist/core/forms/filter.js.map +1 -1
  148. package/dist/core/forms/form-utils.d.ts +103 -0
  149. package/dist/core/forms/form-utils.d.ts.map +1 -0
  150. package/dist/core/forms/form-utils.js +135 -0
  151. package/dist/core/forms/form-utils.js.map +1 -0
  152. package/dist/core/forms/group.d.ts +12 -0
  153. package/dist/core/forms/group.d.ts.map +1 -1
  154. package/dist/core/forms/group.js +7 -0
  155. package/dist/core/forms/group.js.map +1 -1
  156. package/dist/core/forms/index.d.ts +6 -0
  157. package/dist/core/forms/index.d.ts.map +1 -1
  158. package/dist/core/forms/index.js +6 -0
  159. package/dist/core/forms/index.js.map +1 -1
  160. package/dist/core/forms/input.d.ts +17 -0
  161. package/dist/core/forms/input.d.ts.map +1 -1
  162. package/dist/core/forms/input.js +27 -15
  163. package/dist/core/forms/input.js.map +1 -1
  164. package/dist/core/forms/multiselect.d.ts +16 -0
  165. package/dist/core/forms/multiselect.d.ts.map +1 -1
  166. package/dist/core/forms/multiselect.js +54 -38
  167. package/dist/core/forms/multiselect.js.map +1 -1
  168. package/dist/core/forms/select.d.ts +17 -0
  169. package/dist/core/forms/select.d.ts.map +1 -1
  170. package/dist/core/forms/select.js +51 -37
  171. package/dist/core/forms/select.js.map +1 -1
  172. package/dist/core/forms/textarea.d.ts +19 -0
  173. package/dist/core/forms/textarea.d.ts.map +1 -1
  174. package/dist/core/forms/textarea.js +51 -47
  175. package/dist/core/forms/textarea.js.map +1 -1
  176. package/dist/core/forms/types.d.ts +41 -2
  177. package/dist/core/forms/types.d.ts.map +1 -1
  178. package/dist/core/forms/wizard.d.ts +19 -0
  179. package/dist/core/forms/wizard.d.ts.map +1 -1
  180. package/dist/core/forms/wizard.js +4 -0
  181. package/dist/core/forms/wizard.js.map +1 -1
  182. package/dist/core/resolve-ctx.d.ts +30 -0
  183. package/dist/core/resolve-ctx.d.ts.map +1 -0
  184. package/dist/core/resolve-ctx.js +43 -0
  185. package/dist/core/resolve-ctx.js.map +1 -0
  186. package/dist/core/text/clip.d.ts +6 -1
  187. package/dist/core/text/clip.d.ts.map +1 -1
  188. package/dist/core/text/clip.js +12 -3
  189. package/dist/core/text/clip.js.map +1 -1
  190. package/dist/core/text/grapheme.d.ts +15 -3
  191. package/dist/core/text/grapheme.d.ts.map +1 -1
  192. package/dist/core/text/grapheme.js +21 -3
  193. package/dist/core/text/grapheme.js.map +1 -1
  194. package/dist/core/text/index.d.ts +7 -0
  195. package/dist/core/text/index.d.ts.map +1 -1
  196. package/dist/core/text/index.js +7 -0
  197. package/dist/core/text/index.js.map +1 -1
  198. package/dist/core/theme/color.d.ts +47 -8
  199. package/dist/core/theme/color.d.ts.map +1 -1
  200. package/dist/core/theme/color.js +77 -8
  201. package/dist/core/theme/color.js.map +1 -1
  202. package/dist/core/theme/downsample.d.ts +24 -6
  203. package/dist/core/theme/downsample.d.ts.map +1 -1
  204. package/dist/core/theme/downsample.js +41 -10
  205. package/dist/core/theme/downsample.js.map +1 -1
  206. package/dist/core/theme/dtcg.d.ts +28 -2
  207. package/dist/core/theme/dtcg.d.ts.map +1 -1
  208. package/dist/core/theme/dtcg.js +112 -9
  209. package/dist/core/theme/dtcg.js.map +1 -1
  210. package/dist/core/theme/extend.d.ts +14 -0
  211. package/dist/core/theme/extend.d.ts.map +1 -1
  212. package/dist/core/theme/extend.js +14 -0
  213. package/dist/core/theme/extend.js.map +1 -1
  214. package/dist/core/theme/gradient.d.ts +16 -0
  215. package/dist/core/theme/gradient.d.ts.map +1 -1
  216. package/dist/core/theme/gradient.js +13 -0
  217. package/dist/core/theme/gradient.js.map +1 -1
  218. package/dist/core/theme/index.d.ts +7 -0
  219. package/dist/core/theme/index.d.ts.map +1 -1
  220. package/dist/core/theme/index.js +7 -0
  221. package/dist/core/theme/index.js.map +1 -1
  222. package/dist/core/theme/presets.d.ts +6 -1
  223. package/dist/core/theme/presets.d.ts.map +1 -1
  224. package/dist/core/theme/presets.js +34 -1
  225. package/dist/core/theme/presets.js.map +1 -1
  226. package/dist/core/theme/resolve.d.ts +59 -13
  227. package/dist/core/theme/resolve.d.ts.map +1 -1
  228. package/dist/core/theme/resolve.js +36 -9
  229. package/dist/core/theme/resolve.js.map +1 -1
  230. package/dist/core/theme/styled.d.ts +12 -0
  231. package/dist/core/theme/styled.d.ts.map +1 -1
  232. package/dist/core/theme/styled.js +12 -0
  233. package/dist/core/theme/styled.js.map +1 -1
  234. package/dist/core/theme/tokens.d.ts +29 -0
  235. package/dist/core/theme/tokens.d.ts.map +1 -1
  236. package/dist/factory.d.ts +18 -0
  237. package/dist/factory.d.ts.map +1 -1
  238. package/dist/factory.js +11 -0
  239. package/dist/factory.js.map +1 -1
  240. package/dist/index.d.ts +10 -2
  241. package/dist/index.d.ts.map +1 -1
  242. package/dist/index.js +11 -1
  243. package/dist/index.js.map +1 -1
  244. package/dist/ports/context.d.ts +11 -0
  245. package/dist/ports/context.d.ts.map +1 -1
  246. package/dist/ports/index.d.ts +6 -1
  247. package/dist/ports/index.d.ts.map +1 -1
  248. package/dist/ports/index.js +5 -0
  249. package/dist/ports/index.js.map +1 -1
  250. package/dist/ports/io.d.ts +66 -2
  251. package/dist/ports/io.d.ts.map +1 -1
  252. package/dist/ports/runtime.d.ts +11 -0
  253. package/dist/ports/runtime.d.ts.map +1 -1
  254. package/dist/ports/style.d.ts +14 -0
  255. package/dist/ports/style.d.ts.map +1 -1
  256. package/package.json +1 -1
@@ -1,14 +1,68 @@
1
+ /**
2
+ * Create a no-op {@link StylePort} that returns text unchanged.
3
+ *
4
+ * Use in tests where color output is irrelevant; all methods act as
5
+ * identity functions so string equality assertions work without
6
+ * stripping ANSI escape codes.
7
+ *
8
+ * @returns A {@link StylePort} whose methods pass text through unmodified.
9
+ */
1
10
  export function plainStyle() {
2
11
  return {
12
+ /**
13
+ * Return text unchanged, ignoring the design token.
14
+ * @param _token - Ignored design-token value.
15
+ * @param text - The text to return.
16
+ * @returns The original text.
17
+ */
3
18
  styled(_token, text) {
4
19
  return text;
5
20
  },
21
+ /**
22
+ * Return text unchanged, ignoring RGB color channels.
23
+ * @param _r - Ignored red channel.
24
+ * @param _g - Ignored green channel.
25
+ * @param _b - Ignored blue channel.
26
+ * @param text - The text to return.
27
+ * @returns The original text.
28
+ */
6
29
  rgb(_r, _g, _b, text) {
7
30
  return text;
8
31
  },
32
+ /**
33
+ * Return text unchanged, ignoring the hex color.
34
+ * @param _color - Ignored hex color string.
35
+ * @param text - The text to return.
36
+ * @returns The original text.
37
+ */
9
38
  hex(_color, text) {
10
39
  return text;
11
40
  },
41
+ /**
42
+ * Return text unchanged, ignoring RGB background color.
43
+ * @param _r - Ignored red channel.
44
+ * @param _g - Ignored green channel.
45
+ * @param _b - Ignored blue channel.
46
+ * @param text - The text to return.
47
+ * @returns The original text.
48
+ */
49
+ bgRgb(_r, _g, _b, text) {
50
+ return text;
51
+ },
52
+ /**
53
+ * Return text unchanged, ignoring the hex background color.
54
+ * @param _color - Ignored hex color string.
55
+ * @param text - The text to return.
56
+ * @returns The original text.
57
+ */
58
+ bgHex(_color, text) {
59
+ return text;
60
+ },
61
+ /**
62
+ * Return text unchanged, ignoring bold decoration.
63
+ * @param text - The text to return.
64
+ * @returns The original text.
65
+ */
12
66
  bold(text) {
13
67
  return text;
14
68
  },
@@ -1 +1 @@
1
- {"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/adapters/test/style.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,MAAM,CAAC,MAAkB,EAAE,IAAY;YACrC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,GAAG,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,IAAY;YAClD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,GAAG,CAAC,MAAc,EAAE,IAAY;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAC,IAAY;YACf,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/adapters/test/style.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO;QACL;;;;;WAKG;QACH,MAAM,CAAC,MAAkB,EAAE,IAAY;YACrC,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;;;;;;WAOG;QACH,GAAG,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,IAAY;YAClD,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;;;;WAKG;QACH,GAAG,CAAC,MAAc,EAAE,IAAY;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;;;;;;WAOG;QACH,KAAK,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,IAAY;YACpD,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;;;;WAKG;QACH,KAAK,CAAC,MAAc,EAAE,IAAY;YAChC,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;;;WAIG;QACH,IAAI,CAAC,IAAY;YACf,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/context.d.ts CHANGED
@@ -1,5 +1,26 @@
1
1
  import type { BijouContext } from './ports/context.js';
2
+ /**
3
+ * Retrieve the global default {@link BijouContext}.
4
+ *
5
+ * @returns The currently configured default context.
6
+ * @throws {Error} If no context has been set via {@link setDefaultContext}
7
+ * or by importing `@flyingrobots/bijou-node`.
8
+ */
2
9
  export declare function getDefaultContext(): BijouContext;
10
+ /**
11
+ * Set the global default {@link BijouContext}.
12
+ *
13
+ * Typically called once at startup by an adapter package (e.g. bijou-node).
14
+ * After this call, components that omit the optional `ctx` parameter will
15
+ * use the context provided here.
16
+ *
17
+ * @param ctx - The context to set as the global default.
18
+ */
3
19
  export declare function setDefaultContext(ctx: BijouContext): void;
20
+ /**
21
+ * Reset the default context to `null`.
22
+ *
23
+ * **Test-only** — ensures isolation between test cases.
24
+ */
4
25
  export declare function _resetDefaultContextForTesting(): void;
5
26
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,wBAAgB,iBAAiB,IAAI,YAAY,CAShD;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAEzD;AAED,wBAAgB,8BAA8B,IAAI,IAAI,CAErD"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,CAShD;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,IAAI,IAAI,CAErD"}
package/dist/context.js CHANGED
@@ -1,4 +1,11 @@
1
1
  let defaultContext = null;
2
+ /**
3
+ * Retrieve the global default {@link BijouContext}.
4
+ *
5
+ * @returns The currently configured default context.
6
+ * @throws {Error} If no context has been set via {@link setDefaultContext}
7
+ * or by importing `@flyingrobots/bijou-node`.
8
+ */
2
9
  export function getDefaultContext() {
3
10
  if (defaultContext === null) {
4
11
  throw new Error('[bijou] No default context configured. ' +
@@ -7,9 +14,23 @@ export function getDefaultContext() {
7
14
  }
8
15
  return defaultContext;
9
16
  }
17
+ /**
18
+ * Set the global default {@link BijouContext}.
19
+ *
20
+ * Typically called once at startup by an adapter package (e.g. bijou-node).
21
+ * After this call, components that omit the optional `ctx` parameter will
22
+ * use the context provided here.
23
+ *
24
+ * @param ctx - The context to set as the global default.
25
+ */
10
26
  export function setDefaultContext(ctx) {
11
27
  defaultContext = ctx;
12
28
  }
29
+ /**
30
+ * Reset the default context to `null`.
31
+ *
32
+ * **Test-only** — ensures isolation between test cases.
33
+ */
13
34
  export function _resetDefaultContextForTesting() {
14
35
  defaultContext = null;
15
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,IAAI,cAAc,GAAwB,IAAI,CAAC;AAE/C,MAAM,UAAU,iBAAiB;IAC/B,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,yCAAyC;YACzC,qDAAqD;YACrD,yCAAyC,CAC1C,CAAC;IACJ,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAiB;IACjD,cAAc,GAAG,GAAG,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,IAAI,cAAc,GAAwB,IAAI,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,yCAAyC;YACzC,qDAAqD;YACrD,yCAAyC,CAC1C,CAAC;IACJ,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAiB;IACjD,cAAc,GAAG,GAAG,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B;IAC5C,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared background-fill utility for components that support `bgToken`.
3
+ *
4
+ * Centralises the guard logic (noColor, pipe, accessible) so every call site
5
+ * stays in sync.
6
+ *
7
+ * @module
8
+ */
9
+ import type { BijouContext } from '../ports/context.js';
10
+ import type { TokenValue } from './theme/tokens.js';
11
+ /**
12
+ * Determine whether background color should be applied in the current context.
13
+ *
14
+ * Returns `false` when the context is missing, `noColor` is enabled, or the
15
+ * output mode is `pipe` or `accessible`.
16
+ *
17
+ * @param ctx - Bijou context (may be undefined).
18
+ * @returns `true` when it is safe to emit background ANSI sequences.
19
+ */
20
+ export declare function shouldApplyBg(ctx: BijouContext | undefined): boolean;
21
+ /**
22
+ * Create a background-fill wrapper function that routes through StylePort.
23
+ *
24
+ * Returns `undefined` when the background should not be applied (missing
25
+ * token/bg, missing context, noColor, pipe mode, or accessible mode).
26
+ *
27
+ * @param token - Token with optional `bg` hex color.
28
+ * @param ctx - Bijou context for styled output.
29
+ * @returns Wrapper function, or `undefined` if bg should not be applied.
30
+ */
31
+ export declare function makeBgFill(token: TokenValue | undefined, ctx: BijouContext | undefined): ((text: string) => string) | undefined;
32
+ //# sourceMappingURL=bg-fill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bg-fill.d.ts","sourceRoot":"","sources":["../../src/core/bg-fill.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAKpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,GAAG,SAAS,EAC7B,GAAG,EAAE,YAAY,GAAG,SAAS,GAC5B,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAGxC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Shared background-fill utility for components that support `bgToken`.
3
+ *
4
+ * Centralises the guard logic (noColor, pipe, accessible) so every call site
5
+ * stays in sync.
6
+ *
7
+ * @module
8
+ */
9
+ /**
10
+ * Determine whether background color should be applied in the current context.
11
+ *
12
+ * Returns `false` when the context is missing, `noColor` is enabled, or the
13
+ * output mode is `pipe` or `accessible`.
14
+ *
15
+ * @param ctx - Bijou context (may be undefined).
16
+ * @returns `true` when it is safe to emit background ANSI sequences.
17
+ */
18
+ export function shouldApplyBg(ctx) {
19
+ if (!ctx)
20
+ return false;
21
+ if (ctx.theme.noColor)
22
+ return false;
23
+ if (ctx.mode === 'pipe' || ctx.mode === 'accessible')
24
+ return false;
25
+ return true;
26
+ }
27
+ /**
28
+ * Create a background-fill wrapper function that routes through StylePort.
29
+ *
30
+ * Returns `undefined` when the background should not be applied (missing
31
+ * token/bg, missing context, noColor, pipe mode, or accessible mode).
32
+ *
33
+ * @param token - Token with optional `bg` hex color.
34
+ * @param ctx - Bijou context for styled output.
35
+ * @returns Wrapper function, or `undefined` if bg should not be applied.
36
+ */
37
+ export function makeBgFill(token, ctx) {
38
+ if (!token?.bg || !shouldApplyBg(ctx))
39
+ return undefined;
40
+ return (text) => ctx.style.bgHex(token.bg, text);
41
+ }
42
+ //# sourceMappingURL=bg-fill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bg-fill.js","sourceRoot":"","sources":["../../src/core/bg-fill.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,GAA6B;IACzD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,KAAK,CAAC;IACnE,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CACxB,KAA6B,EAC7B,GAA6B;IAE7B,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACxD,OAAO,CAAC,IAAY,EAAE,EAAE,CAAC,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAG,EAAE,IAAI,CAAC,CAAC;AAC7D,CAAC"}
@@ -1,14 +1,34 @@
1
1
  import type { BijouContext } from '../../ports/context.js';
2
2
  import type { TokenValue } from '../theme/tokens.js';
3
+ /** Represent a single collapsible section within an accordion. */
3
4
  export interface AccordionSection {
5
+ /** Section heading text. */
4
6
  title: string;
7
+ /** Body content shown when the section is expanded. */
5
8
  content: string;
9
+ /** Whether the section is expanded. Defaults to `false`. */
6
10
  expanded?: boolean;
7
11
  }
12
+ /** Configuration options for the {@link accordion} component. */
8
13
  export interface AccordionOptions {
14
+ /** Token used to style the expand/collapse indicator arrows. */
9
15
  indicatorToken?: TokenValue;
16
+ /** Token used to style section titles. */
10
17
  titleToken?: TokenValue;
18
+ /** Bijou context for rendering mode and theme resolution. */
11
19
  ctx?: BijouContext;
12
20
  }
21
+ /**
22
+ * Render a collapsible accordion with expand/collapse indicators.
23
+ *
24
+ * Adapts output by mode:
25
+ * - `pipe`: sections rendered as `# title` headings with content.
26
+ * - `accessible`: sections tagged `[expanded]` or `[collapsed]`.
27
+ * - `interactive`/`static`: styled `▼`/`▶` indicators with themed titles.
28
+ *
29
+ * @param sections - Array of accordion sections to render.
30
+ * @param options - Rendering options including indicator/title tokens and context.
31
+ * @returns The formatted accordion string.
32
+ */
13
33
  export declare function accordion(sections: AccordionSection[], options?: AccordionOptions): string;
14
34
  //# sourceMappingURL=accordion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../../src/core/components/accordion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAOD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAwC9F"}
1
+ {"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../../src/core/components/accordion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,kEAAkE;AAClE,MAAM,WAAW,gBAAgB;IAC/B,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,iEAAiE;AACjE,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,0CAA0C;IAC1C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAwC9F"}
@@ -1,9 +1,16 @@
1
- import { getDefaultContext } from '../../context.js';
2
- function resolveCtx(ctx) {
3
- if (ctx)
4
- return ctx;
5
- return getDefaultContext();
6
- }
1
+ import { resolveCtx } from '../resolve-ctx.js';
2
+ /**
3
+ * Render a collapsible accordion with expand/collapse indicators.
4
+ *
5
+ * Adapts output by mode:
6
+ * - `pipe`: sections rendered as `# title` headings with content.
7
+ * - `accessible`: sections tagged `[expanded]` or `[collapsed]`.
8
+ * - `interactive`/`static`: styled `▼`/`▶` indicators with themed titles.
9
+ *
10
+ * @param sections - Array of accordion sections to render.
11
+ * @param options - Rendering options including indicator/title tokens and context.
12
+ * @returns The formatted accordion string.
13
+ */
7
14
  export function accordion(sections, options = {}) {
8
15
  const ctx = resolveCtx(options.ctx);
9
16
  const mode = ctx.mode;
@@ -1 +1 @@
1
- {"version":3,"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C;QACD,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO,GAAG,SAAS,IAAI,KAAK,EAAE,CAAC;IACjC,CAAC,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC"}
@@ -1,8 +1,24 @@
1
1
  import type { BijouContext } from '../../ports/context.js';
2
+ /** Alert severity level. */
2
3
  export type AlertVariant = 'success' | 'error' | 'warning' | 'info';
4
+ /** Configuration for rendering an alert box. */
3
5
  export interface AlertOptions {
6
+ /** Severity variant (defaults to `'info'`). */
4
7
  variant?: AlertVariant;
8
+ /** Bijou context for I/O, styling, and mode detection. */
5
9
  ctx?: BijouContext;
6
10
  }
11
+ /**
12
+ * Render an alert box with an icon and message.
13
+ *
14
+ * Output adapts to the current output mode:
15
+ * - `interactive` / `static` — bordered box with a colored status icon.
16
+ * - `pipe` — bracketed label like `[ERROR] message`.
17
+ * - `accessible` — plain label like `Error: message`.
18
+ *
19
+ * @param message - Alert body text.
20
+ * @param options - Alert configuration.
21
+ * @returns The rendered alert string.
22
+ */
7
23
  export declare function alert(message: string, options?: AlertOptions): string;
8
24
  //# sourceMappingURL=alert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../src/core/components/alert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAK3D,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpE,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAmCD,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CAkBzE"}
1
+ {"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../src/core/components/alert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAK3D,4BAA4B;AAC5B,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpE,gDAAgD;AAChD,MAAM,WAAW,YAAY;IAC3B,+CAA+C;IAC/C,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAkCD;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CAkBzE"}
@@ -1,34 +1,45 @@
1
- import { getDefaultContext } from '../../context.js';
1
+ import { resolveCtx } from '../resolve-ctx.js';
2
2
  import { box } from './box.js';
3
+ /** Unicode icon characters for each alert variant. */
3
4
  const ICONS = {
4
5
  success: '\u2713',
5
6
  error: '\u2717',
6
7
  warning: '\u26A0',
7
8
  info: '\u2139',
8
9
  };
10
+ /** Uppercase labels used in pipe mode output. */
9
11
  const PIPE_LABELS = {
10
12
  success: 'SUCCESS',
11
13
  error: 'ERROR',
12
14
  warning: 'WARNING',
13
15
  info: 'INFO',
14
16
  };
17
+ /** Title-cased labels used in accessible mode output. */
15
18
  const ACCESSIBLE_LABELS = {
16
19
  success: 'Success',
17
20
  error: 'Error',
18
21
  warning: 'Warning',
19
22
  info: 'Info',
20
23
  };
24
+ /** Mapping from alert variant to the corresponding border theme token key. */
21
25
  const BORDER_TOKENS = {
22
26
  success: 'success',
23
27
  error: 'error',
24
28
  warning: 'warning',
25
29
  info: 'primary',
26
30
  };
27
- function resolveCtx(ctx) {
28
- if (ctx)
29
- return ctx;
30
- return getDefaultContext();
31
- }
31
+ /**
32
+ * Render an alert box with an icon and message.
33
+ *
34
+ * Output adapts to the current output mode:
35
+ * - `interactive` / `static` — bordered box with a colored status icon.
36
+ * - `pipe` — bracketed label like `[ERROR] message`.
37
+ * - `accessible` — plain label like `Error: message`.
38
+ *
39
+ * @param message - Alert body text.
40
+ * @param options - Alert configuration.
41
+ * @returns The rendered alert string.
42
+ */
32
43
  export function alert(message, options = {}) {
33
44
  const ctx = resolveCtx(options.ctx);
34
45
  const mode = ctx.mode;
@@ -1 +1 @@
1
- {"version":3,"file":"alert.js","sourceRoot":"","sources":["../../../src/core/components/alert.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAS/B,MAAM,KAAK,GAAiC;IAC1C,OAAO,EAAE,QAAQ;IACjB,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,QAAQ;CACf,CAAC;AAEF,MAAM,WAAW,GAAiC;IAChD,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,MAAM,iBAAiB,GAAiC;IACtD,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,MAAM,aAAa,GAAyE;IAC1F,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;CAChB,CAAC;AAEF,SAAS,UAAU,CAAC,GAAkB;IACpC,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IACpB,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,OAAe,EAAE,UAAwB,EAAE;IAC/D,MAAM,GAAG,GAAG,UAAU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CAAC;IACnE,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAE1D,OAAO,GAAG,CAAC,WAAW,GAAG,GAAG,GAAG,OAAO,EAAE;QACtC,WAAW;QACX,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;QAC9B,GAAG;KACJ,CAAC,CAAC;AACL,CAAC"}
@@ -1,9 +1,27 @@
1
1
  import type { BijouContext } from '../../ports/context.js';
2
2
  import type { BaseStatusKey } from '../theme/tokens.js';
3
+ /** Badge color variant — any status key, plus `'accent'` and `'primary'`. */
3
4
  export type BadgeVariant = BaseStatusKey | 'accent' | 'primary';
5
+ /** Configuration for rendering a badge. */
4
6
  export interface BadgeOptions {
7
+ /** Color variant (defaults to `'info'`). */
5
8
  variant?: BadgeVariant;
9
+ /** Bijou context for I/O, styling, and mode detection. */
6
10
  ctx?: BijouContext;
7
11
  }
12
+ /**
13
+ * Render an inline badge (pill-shaped label) for the given text.
14
+ *
15
+ * Output adapts to the current output mode:
16
+ * - `interactive` / `static` — inverse-colored pill using the variant token.
17
+ * - `pipe` — bracketed text like `[OK]`.
18
+ * - `accessible` — plain text.
19
+ *
20
+ * Falls back to a plain space-padded string when no context or theme is available.
21
+ *
22
+ * @param text - Label to display inside the badge.
23
+ * @param options - Badge configuration.
24
+ * @returns The rendered badge string.
25
+ */
8
26
  export declare function badge(text: string, options?: BadgeOptions): string;
9
27
  //# sourceMappingURL=badge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../src/core/components/badge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGpE,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhE,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAWD,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CA2BtE"}
1
+ {"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../src/core/components/badge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAc,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGpE,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhE,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CA2BtE"}
@@ -1,14 +1,18 @@
1
- import { getDefaultContext } from '../../context.js';
2
- function resolveCtx(ctx) {
3
- if (ctx)
4
- return ctx;
5
- try {
6
- return getDefaultContext();
7
- }
8
- catch {
9
- return undefined;
10
- }
11
- }
1
+ import { resolveSafeCtx as resolveCtx } from '../resolve-ctx.js';
2
+ /**
3
+ * Render an inline badge (pill-shaped label) for the given text.
4
+ *
5
+ * Output adapts to the current output mode:
6
+ * - `interactive` / `static` — inverse-colored pill using the variant token.
7
+ * - `pipe` — bracketed text like `[OK]`.
8
+ * - `accessible` — plain text.
9
+ *
10
+ * Falls back to a plain space-padded string when no context or theme is available.
11
+ *
12
+ * @param text - Label to display inside the badge.
13
+ * @param options - Badge configuration.
14
+ * @returns The rendered badge string.
15
+ */
12
16
  export function badge(text, options = {}) {
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AAM,CAAC,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC;IAEpE,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpD,SAAS,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;IACjC,CAAC;IAED,MAAM,YAAY,GAAe;QAC/B,GAAG,EAAE,SAAS,CAAC,GAAG;QAClB,SAAS,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC;KACvD,CAAC;IAEF,OAAO,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,IAAI,GAAG,CAAC,CAAC;AACrD,CAAC"}
@@ -1,7 +1,12 @@
1
1
  import type { BijouContext } from '../../ports/context.js';
2
2
  import type { TokenValue } from '../theme/tokens.js';
3
+ /** Configuration for rendering a bordered box. */
3
4
  export interface BoxOptions {
5
+ /** Theme token applied to border characters. */
4
6
  borderToken?: TokenValue;
7
+ /** Background fill token. Interior spaces are styled with this token's bg color. */
8
+ bgToken?: TokenValue;
9
+ /** Inner padding between the border and content (in characters/lines). */
5
10
  padding?: {
6
11
  top?: number;
7
12
  bottom?: number;
@@ -10,12 +15,38 @@ export interface BoxOptions {
10
15
  };
11
16
  /** Lock outer width (including borders). Content is clipped/padded to fit. */
12
17
  width?: number;
18
+ /** Bijou context for I/O, styling, and mode detection. */
13
19
  ctx?: BijouContext;
14
20
  }
21
+ /**
22
+ * Render content inside a bordered box.
23
+ *
24
+ * Output adapts to the current output mode:
25
+ * - `interactive` / `static` — unicode box with themed border color.
26
+ * - `pipe` / `accessible` — raw content without borders.
27
+ *
28
+ * @param content - Text to display inside the box (may contain newlines).
29
+ * @param options - Box configuration.
30
+ * @returns The rendered box string, or plain content in non-visual modes.
31
+ */
15
32
  export declare function box(content: string, options?: BoxOptions): string;
33
+ /** Configuration for {@link headerBox}, extending {@link BoxOptions} with label support. */
16
34
  export interface HeaderBoxOptions extends BoxOptions {
35
+ /** Optional detail text displayed after the label in a muted style. */
17
36
  detail?: string;
37
+ /** Theme token applied to the label text. */
18
38
  labelToken?: TokenValue;
19
39
  }
40
+ /**
41
+ * Render a labeled box with an optional detail line.
42
+ *
43
+ * In visual modes the label is styled with `options.labelToken` (defaults to
44
+ * the primary semantic token) and wrapped in a {@link box}. Pipe mode returns
45
+ * plain text; accessible mode uses a colon separator.
46
+ *
47
+ * @param label - Primary heading text.
48
+ * @param options - Header box configuration.
49
+ * @returns The rendered header box string.
50
+ */
20
51
  export declare function headerBox(label: string, options?: HeaderBoxOptions): string;
21
52
  //# sourceMappingURL=box.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../../src/core/components/box.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKrD,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,OAAO,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3E,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AA8DD,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,MAAM,CAmBrE;AAED,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAkB/E"}
1
+ {"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../../src/core/components/box.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAMrD,kDAAkD;AAClD,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,oFAAoF;IACpF,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,0EAA0E;IAC1E,OAAO,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3E,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AA0ED;;;;;;;;;;GAUG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,MAAM,CAqBrE;AAED,4FAA4F;AAC5F,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAkB/E"}
@@ -1,8 +1,24 @@
1
- import { getDefaultContext } from '../../context.js';
1
+ import { resolveCtx } from '../resolve-ctx.js';
2
+ import { makeBgFill } from '../bg-fill.js';
2
3
  import { graphemeWidth } from '../text/grapheme.js';
3
4
  import { clipToWidth } from '../text/clip.js';
5
+ /** Unicode box-drawing characters for single-line borders. */
4
6
  const BORDER = { tl: '\u250c', tr: '\u2510', bl: '\u2514', br: '\u2518', h: '\u2500', v: '\u2502' };
5
- function drawBox(content, borderColor, padding, fixedWidth) {
7
+ /**
8
+ * Draw a unicode box around the given content string.
9
+ *
10
+ * Supports both auto-width (measured from content) and fixed-width modes.
11
+ * Content lines wider than the available space are hard-truncated via
12
+ * `clipToWidth` (no ellipsis is appended).
13
+ *
14
+ * @param content - Multiline string to place inside the box.
15
+ * @param borderColor - Function that wraps border characters with color styling.
16
+ * @param padding - Resolved padding values (top, bottom, left, right).
17
+ * @param fixedWidth - If provided, lock the outer width and clip/pad content to fit.
18
+ * @param bgFill - Optional function to wrap interior content with background color styling.
19
+ * @returns The rendered box as a multiline string.
20
+ */
21
+ function drawBox(content, borderColor, padding, fixedWidth, bgFill) {
6
22
  const contentLines = content.split('\n');
7
23
  let innerWidth;
8
24
  let contentWidth;
@@ -31,25 +47,32 @@ function drawBox(content, borderColor, padding, fixedWidth) {
31
47
  const rightPad = ' '.repeat(effectiveRight + Math.max(0, contentWidth - processedVisible));
32
48
  return leftPad + processed + rightPad;
33
49
  };
50
+ const fill = bgFill ?? ((s) => s);
34
51
  const top = borderColor(BORDER.tl + BORDER.h.repeat(innerWidth) + BORDER.tr);
35
52
  const bottom = borderColor(BORDER.bl + BORDER.h.repeat(innerWidth) + BORDER.br);
36
- const emptyLine = borderColor(BORDER.v) + ' '.repeat(innerWidth) + borderColor(BORDER.v);
53
+ const emptyLine = borderColor(BORDER.v) + fill(' '.repeat(innerWidth)) + borderColor(BORDER.v);
37
54
  const lines = [top];
38
55
  for (let i = 0; i < padding.top; i++)
39
56
  lines.push(emptyLine);
40
57
  for (const line of contentLines) {
41
- lines.push(borderColor(BORDER.v) + pad(line) + borderColor(BORDER.v));
58
+ lines.push(borderColor(BORDER.v) + fill(pad(line)) + borderColor(BORDER.v));
42
59
  }
43
60
  for (let i = 0; i < padding.bottom; i++)
44
61
  lines.push(emptyLine);
45
62
  lines.push(bottom);
46
63
  return lines.join('\n');
47
64
  }
48
- function resolveCtx(ctx) {
49
- if (ctx)
50
- return ctx;
51
- return getDefaultContext();
52
- }
65
+ /**
66
+ * Render content inside a bordered box.
67
+ *
68
+ * Output adapts to the current output mode:
69
+ * - `interactive` / `static` — unicode box with themed border color.
70
+ * - `pipe` / `accessible` — raw content without borders.
71
+ *
72
+ * @param content - Text to display inside the box (may contain newlines).
73
+ * @param options - Box configuration.
74
+ * @returns The rendered box string, or plain content in non-visual modes.
75
+ */
53
76
  export function box(content, options = {}) {
54
77
  const ctx = resolveCtx(options.ctx);
55
78
  const mode = ctx.mode;
@@ -64,8 +87,20 @@ export function box(content, options = {}) {
64
87
  right: options.padding?.right ?? 1,
65
88
  };
66
89
  const colorize = (s) => ctx.style.styled(borderToken, s);
67
- return drawBox(content, colorize, padding, options.width);
90
+ const bgFill = makeBgFill(options.bgToken, ctx);
91
+ return drawBox(content, colorize, padding, options.width, bgFill);
68
92
  }
93
+ /**
94
+ * Render a labeled box with an optional detail line.
95
+ *
96
+ * In visual modes the label is styled with `options.labelToken` (defaults to
97
+ * the primary semantic token) and wrapped in a {@link box}. Pipe mode returns
98
+ * plain text; accessible mode uses a colon separator.
99
+ *
100
+ * @param label - Primary heading text.
101
+ * @param options - Header box configuration.
102
+ * @returns The rendered header box string.
103
+ */
69
104
  export function headerBox(label, options = {}) {
70
105
  const ctx = resolveCtx(options.ctx);
71
106
  const mode = ctx.mode;